|
|
|
@ -1,7 +1,6 @@ |
|
|
|
import { |
|
|
|
isUndefined, |
|
|
|
isFunction, |
|
|
|
isObject, |
|
|
|
isArray, |
|
|
|
isEmpty, |
|
|
|
isBoolean, |
|
|
|
@ -12,7 +11,7 @@ import { |
|
|
|
bindAll, |
|
|
|
keys |
|
|
|
} from 'underscore'; |
|
|
|
import { shallowDiff, capitalize, isEmptyObj } from 'utils/mixins'; |
|
|
|
import { shallowDiff, capitalize, isEmptyObj, isObject } from 'utils/mixins'; |
|
|
|
import Styleable from 'domain_abstract/model/Styleable'; |
|
|
|
import Backbone from 'backbone'; |
|
|
|
import Components from './Components'; |
|
|
|
@ -506,13 +505,13 @@ const Component = Backbone.Model.extend(Styleable).extend( |
|
|
|
* Get the style of the component |
|
|
|
* @return {Object} |
|
|
|
*/ |
|
|
|
getStyle() { |
|
|
|
getStyle(opts = {}) { |
|
|
|
const em = this.em; |
|
|
|
|
|
|
|
if (em && em.getConfig('avoidInlineStyle')) { |
|
|
|
if (em && em.getConfig('avoidInlineStyle') && !opts.inline) { |
|
|
|
const state = em.get('state'); |
|
|
|
const cc = em.get('CssComposer'); |
|
|
|
const rule = cc.getIdRule(this.getId(), { state }); |
|
|
|
const rule = cc.getIdRule(this.getId(), { state, ...opts }); |
|
|
|
this.rule = rule; |
|
|
|
|
|
|
|
if (rule) { |
|
|
|
@ -534,13 +533,18 @@ const Component = Backbone.Model.extend(Styleable).extend( |
|
|
|
const em = this.em; |
|
|
|
const { opt } = this; |
|
|
|
|
|
|
|
if (em && em.getConfig('avoidInlineStyle') && !opt.temporary) { |
|
|
|
if ( |
|
|
|
em && |
|
|
|
em.getConfig('avoidInlineStyle') && |
|
|
|
!opt.temporary && |
|
|
|
!opts.inline |
|
|
|
) { |
|
|
|
const style = this.get('style') || {}; |
|
|
|
prop = isString(prop) ? this.parseStyle(prop) : prop; |
|
|
|
prop = { ...prop, ...style }; |
|
|
|
const state = em.get('state'); |
|
|
|
const cc = em.get('CssComposer'); |
|
|
|
const propOrig = this.getStyle(); |
|
|
|
const propOrig = this.getStyle(opts); |
|
|
|
this.rule = cc.setIdRule(this.getId(), prop, { ...opts, state }); |
|
|
|
const diff = shallowDiff(propOrig, prop); |
|
|
|
this.set('style', '', { silent: 1 }); |
|
|
|
@ -571,6 +575,14 @@ const Component = Backbone.Model.extend(Styleable).extend( |
|
|
|
classes.length && (attributes.class = classes.join(' ')); |
|
|
|
} |
|
|
|
|
|
|
|
// Add style
|
|
|
|
if (!opts.noStyle) { |
|
|
|
const style = this.get('style'); |
|
|
|
if (isObject(style) && !isEmptyObj(style)) { |
|
|
|
attributes.style = this.styleToString({ inline: 1 }); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// Check if we need an ID on the component
|
|
|
|
if (!has(attributes, 'id')) { |
|
|
|
let addId; |
|
|
|
|