Browse Source

Replace getConfig(string) to getConfig()

pull/4264/head
Alex Ritter 4 years ago
parent
commit
f4b1fc7b6c
  1. 4
      src/asset_manager/index.js
  2. 2
      src/canvas/view/CanvasView.js
  3. 2
      src/canvas/view/FramesView.js
  4. 4
      src/code_manager/model/CssGenerator.js
  5. 2
      src/commands/view/ComponentDrag.js
  6. 2
      src/commands/view/SelectComponent.js
  7. 2
      src/css_composer/model/CssRule.js
  8. 2
      src/css_composer/view/CssRulesView.js
  9. 10
      src/dom_components/model/Component.js
  10. 4
      src/dom_components/model/Components.js
  11. 2
      src/dom_components/view/ComponentView.js
  12. 8
      src/dom_components/view/ToolbarButtonView.js
  13. 2
      src/domain_abstract/ui/InputColor.js
  14. 4
      src/editor/model/Editor.js
  15. 2
      src/selector_manager/model/Selector.js
  16. 2
      src/selector_manager/view/ClassTagsView.js
  17. 2
      src/style_manager/view/LayerView.js
  18. 2
      src/style_manager/view/PropertyFileView.js
  19. 2
      src/style_manager/view/PropertyStackView.js
  20. 2
      src/style_manager/view/PropertyView.js
  21. 2
      src/style_manager/view/SectorView.js

4
src/asset_manager/index.js

@ -136,7 +136,7 @@ export default () => {
__trgCustom() { __trgCustom() {
const bhv = this.__getBehaviour(); const bhv = this.__getBehaviour();
if (!bhv.container && !this.getConfig('custom').open) { if (!bhv.container && !this.getConfig().custom.open) {
return; return;
} }
this.em.trigger(this.events.custom, this.__customData()); this.em.trigger(this.events.custom, this.__customData());
@ -321,7 +321,7 @@ export default () => {
* )); * ));
*/ */
render(assts) { render(assts) {
if (this.getConfig('custom')) return; if (this.getConfig().custom) return;
const toRender = assts || this.getAll().models; const toRender = assts || this.getAll().models;
if (!am) { if (!am) {

2
src/canvas/view/CanvasView.js

@ -108,7 +108,7 @@ export default class CanvasView extends View {
} }
onWheel(ev) { onWheel(ev) {
if ((ev.ctrlKey || ev.metaKey) && this.em.getConfig('multiFrames')) { if ((ev.ctrlKey || ev.metaKey) && this.em.getConfig().multiFrames) {
this.preventDefault(ev); this.preventDefault(ev);
const { model } = this; const { model } = this;
const delta = Math.max(-1, Math.min(1, ev.wheelDelta || -ev.detail)); const delta = Math.max(-1, Math.min(1, ev.wheelDelta || -ev.detail));

2
src/canvas/view/FramesView.js

@ -14,7 +14,7 @@ export default class FramesView extends DomainViews {
onRender() { onRender() {
const { config, $el } = this; const { config, $el } = this;
const { em } = config; const { em } = config;
em && $el.attr({ class: `${em.getConfig('stylePrefix')}frames` }); em && $el.attr({ class: `${em.getConfig().stylePrefix}frames` });
} }
} }

4
src/code_manager/model/CssGenerator.js

@ -24,7 +24,7 @@ export default class CssGenerator extends Model {
buildFromModel(model, opts = {}) { buildFromModel(model, opts = {}) {
let code = ''; let code = '';
const em = this.em; const em = this.em;
const avoidInline = em && em.getConfig('avoidInlineStyle'); const avoidInline = em && em.getConfig().avoidInlineStyle;
const style = model.styleToString(); const style = model.styleToString();
const classes = model.get('classes'); const classes = model.get('classes');
this.ids.push(`#${model.getId()}`); this.ids.push(`#${model.getId()}`);
@ -51,7 +51,7 @@ export default class CssGenerator extends Model {
this.model = model; this.model = model;
const codeJson = []; const codeJson = [];
let code = model ? this.buildFromModel(model, opts) : ''; let code = model ? this.buildFromModel(model, opts) : '';
const clearStyles = isUndefined(opts.clearStyles) && em ? em.getConfig('clearStyles') : opts.clearStyles; const clearStyles = isUndefined(opts.clearStyles) && em ? em.getConfig().clearStyles : opts.clearStyles;
if (cssc) { if (cssc) {
let rules = opts.rules || cssc.getAll(); let rules = opts.rules || cssc.getAll();

2
src/commands/view/ComponentDrag.js

@ -80,7 +80,7 @@ export default {
if (!guidesEl) { if (!guidesEl) {
const { editor, em, opts } = this; const { editor, em, opts } = this;
const pfx = editor.getConfig('stylePrefix'); const pfx = editor.getConfig().stylePrefix;
const elInfoX = document.createElement('div'); const elInfoX = document.createElement('div');
const elInfoY = document.createElement('div'); const elInfoY = document.createElement('div');
const guideContent = `<div class="${pfx}guide-info__line ${pfx}danger-bg"> const guideContent = `<div class="${pfx}guide-info__line ${pfx}danger-bg">

2
src/commands/view/SelectComponent.js

@ -61,7 +61,7 @@ export default {
* */ * */
toggleSelectComponent(enable) { toggleSelectComponent(enable) {
const { em } = this; const { em } = this;
const listenToEl = em.getConfig('listenToEl'); const listenToEl = em.getConfig().listenToEl;
const { parentNode } = em.getContainer(); const { parentNode } = em.getContainer();
const method = enable ? 'on' : 'off'; const method = enable ? 'on' : 'off';
const methods = { on, off }; const methods = { on, off };

2
src/css_composer/model/CssRule.js

@ -228,7 +228,7 @@ export default class CssRule extends Model.extend(Styleable) {
toJSON(...args) { toJSON(...args) {
const obj = Model.prototype.toJSON.apply(this, args); const obj = Model.prototype.toJSON.apply(this, args);
if (this.em.getConfig('avoidDefaults')) { if (this.em.getConfig().avoidDefaults) {
const defaults = this.defaults(); const defaults = this.defaults();
forEach(defaults, (value, key) => { forEach(defaults, (value, key) => {

2
src/css_composer/view/CssRulesView.js

@ -101,7 +101,7 @@ export default class CssRulesView extends View {
} }
getMediaWidth(mediaText) { getMediaWidth(mediaText) {
return mediaText && mediaText.replace(`(${this.em.getConfig('mediaCondition')}: `, '').replace(')', ''); return mediaText && mediaText.replace(`(${this.em.getConfig().mediaCondition}: `, '').replace(')', '');
} }
render() { render() {

10
src/dom_components/model/Component.js

@ -23,7 +23,7 @@ const escapeRegExp = str => {
return str.replace(/[|\\{}()[\]^$+*?.]/g, '\\$&'); return str.replace(/[|\\{}()[\]^$+*?.]/g, '\\$&');
}; };
const avoidInline = em => em && em.getConfig('avoidInlineStyle'); const avoidInline = em => em && em.getConfig().avoidInlineStyle;
export const eventDrag = 'component:drag'; export const eventDrag = 'component:drag';
export const keySymbols = '__symbols'; export const keySymbols = '__symbols';
@ -465,7 +465,7 @@ export default class Component extends Model.extend(Styleable) {
const prop = isString(options) ? options : ''; const prop = isString(options) ? options : '';
const opts = prop ? optsAdd : options; const opts = prop ? optsAdd : options;
if (em && em.getConfig('avoidInlineStyle') && !opts.inline) { if (em && em.getConfig().avoidInlineStyle && !opts.inline) {
const state = em.get('state'); const state = em.get('state');
const cc = em.get('CssComposer'); const cc = em.get('CssComposer');
const rule = cc.getIdRule(this.getId(), { state, ...opts }); const rule = cc.getIdRule(this.getId(), { state, ...opts });
@ -490,7 +490,7 @@ export default class Component extends Model.extend(Styleable) {
const em = this.em; const em = this.em;
const { opt } = this; const { opt } = this;
if (em && em.getConfig('avoidInlineStyle') && !opt.temporary && !opts.inline) { if (em && em.getConfig().avoidInlineStyle && !opt.temporary && !opts.inline) {
const style = this.get('style') || {}; const style = this.get('style') || {};
prop = isString(prop) ? this.parseStyle(prop) : prop; prop = isString(prop) ? this.parseStyle(prop) : prop;
prop = { ...prop, ...style }; prop = { ...prop, ...style };
@ -1062,7 +1062,7 @@ export default class Component extends Model.extend(Styleable) {
initToolbar() { initToolbar() {
const { em } = this; const { em } = this;
const model = this; const model = this;
const ppfx = (em && em.getConfig('stylePrefix')) || ''; const ppfx = (em && em.getConfig().stylePrefix) || '';
if (!model.get('toolbar') && em) { if (!model.get('toolbar') && em) {
const tb = []; const tb = [];
@ -1495,7 +1495,7 @@ export default class Component extends Model.extend(Styleable) {
} }
} }
if (this.em.getConfig('avoidDefaults')) { if (this.em.getConfig().avoidDefaults) {
this.getChangedProps(obj); this.getChangedProps(obj);
} }

4
src/dom_components/model/Components.js

@ -255,10 +255,10 @@ export default Backbone.Collection.extend({
onAdd(model, c, opts = {}) { onAdd(model, c, opts = {}) {
const { domc, em } = this; const { domc, em } = this;
const style = model.getStyle(); const style = model.getStyle();
const avoidInline = em && em.getConfig('avoidInlineStyle'); const avoidInline = em && em.getConfig().avoidInlineStyle;
domc && domc.Component.ensureInList(model); domc && domc.Component.ensureInList(model);
if (!isEmpty(style) && !avoidInline && em && em.get && em.getConfig('forceClass') && !opts.temporary) { if (!isEmpty(style) && !avoidInline && em && em.get && em.getConfig().forceClass && !opts.temporary) {
const name = model.cid; const name = model.cid;
const rule = em.get('CssComposer').setClassRule(name, style); const rule = em.get('CssComposer').setClassRule(name, style);
model.setStyle({}); model.setStyle({});

2
src/dom_components/view/ComponentView.js

@ -232,7 +232,7 @@ export default Backbone.View.extend({
updateStyle(m, v, opts = {}) { updateStyle(m, v, opts = {}) {
const { model, em } = this; const { model, em } = this;
if (em && em.getConfig('avoidInlineStyle') && !opts.inline) { if (em && em.getConfig().avoidInlineStyle && !opts.inline) {
const style = model.getStyle(); const style = model.getStyle();
!isEmpty(style) && model.setStyle(style); !isEmpty(style) && model.setStyle(style);
} else { } else {

8
src/dom_components/view/ToolbarButtonView.js

@ -4,7 +4,7 @@ export default Backbone.View.extend({
events() { events() {
return ( return (
this.model.get('events') || { this.model.get('events') || {
mousedown: 'handleClick' mousedown: 'handleClick',
} }
); );
}, },
@ -43,7 +43,7 @@ export default Backbone.View.extend({
const calibrated = { const calibrated = {
...event, ...event,
clientX: event.clientX - left, clientX: event.clientX - left,
clientY: event.clientY - top clientY: event.clientY - top,
}; };
em.trigger('toolbar:run:before'); em.trigger('toolbar:run:before');
@ -68,10 +68,10 @@ export default Backbone.View.extend({
const { editor, $el, model } = this; const { editor, $el, model } = this;
const id = model.get('id'); const id = model.get('id');
const label = model.get('label'); const label = model.get('label');
const pfx = editor.getConfig('stylePrefix'); const pfx = editor.getConfig().stylePrefix;
$el.addClass(`${pfx}toolbar-item`); $el.addClass(`${pfx}toolbar-item`);
id && $el.addClass(`${pfx}toolbar-item__${id}`); id && $el.addClass(`${pfx}toolbar-item__${id}`);
label && $el.append(label); label && $el.append(label);
return this; return this;
} },
}); });

2
src/domain_abstract/ui/InputColor.js

@ -99,7 +99,7 @@ export default class InputColor extends Input {
var colorEl = $(`<div class="${this.ppfx}field-color-picker"></div>`); var colorEl = $(`<div class="${this.ppfx}field-color-picker"></div>`);
var cpStyle = colorEl.get(0).style; var cpStyle = colorEl.get(0).style;
var elToAppend = em && em.config ? em.config.el : ''; var elToAppend = em && em.config ? em.config.el : '';
var colorPickerConfig = (em && em.getConfig && em.getConfig('colorPicker')) || {}; var colorPickerConfig = (em && em.getConfig && em.getConfig().colorPicker) || {};
let changed = 0; let changed = 0;
let previousColor; let previousColor;

4
src/editor/model/Editor.js

@ -326,7 +326,7 @@ export default class EditorModel extends Model {
const multiple = isArray(el); const multiple = isArray(el);
const els = (multiple ? el : [el]).map(el => getModel(el, $)); const els = (multiple ? el : [el]).map(el => getModel(el, $));
const selected = this.getSelectedAll(); const selected = this.getSelectedAll();
const mltSel = this.getConfig('multipleSelection'); const mltSel = this.getConfig().multipleSelection;
let added; let added;
// If an array is passed remove all selected // If an array is passed remove all selected
@ -749,7 +749,7 @@ export default class EditorModel extends Model {
} }
getIcon(icon) { getIcon(icon) {
const icons = this.getConfig('icons') || {}; const icons = this.getConfig().icons || {};
return icons[icon] || ''; return icons[icon] || '';
} }

2
src/selector_manager/model/Selector.js

@ -127,7 +127,7 @@ export default class Selector extends Model {
let obj = Model.prototype.toJSON.call(this, [opts]); let obj = Model.prototype.toJSON.call(this, [opts]);
const defaults = result(this, 'defaults'); const defaults = result(this, 'defaults');
if (em && em.getConfig('avoidDefaults')) { if (em && em.getConfig().avoidDefaults) {
forEach(defaults, (value, key) => { forEach(defaults, (value, key) => {
if (obj[key] === value) { if (obj[key] === value) {
delete obj[key]; delete obj[key];

2
src/selector_manager/view/ClassTagsView.js

@ -234,7 +234,7 @@ export default class ClassTagsView extends View {
*/ */
updateStateVis(target) { updateStateVis(target) {
const em = this.em; const em = this.em;
const avoidInline = em && em.getConfig('avoidInlineStyle'); const avoidInline = em && em.getConfig().avoidInlineStyle;
const display = this.collection.length || avoidInline ? '' : 'none'; const display = this.collection.length || avoidInline ? '' : 'none';
this.getStatesC().css('display', display); this.getStatesC().css('display', display);
this.updateSelector(target); this.updateSelector(target);

2
src/style_manager/view/LayerView.js

@ -13,7 +13,7 @@ export default class LayerView extends View {
template() { template() {
const { pfx, ppfx, em } = this; const { pfx, ppfx, em } = this;
const icons = em?.getConfig('icons'); const icons = em?.getConfig().icons;
const iconClose = icons?.close || ''; const iconClose = icons?.close || '';
const iconMove = icons?.move || ''; const iconMove = icons?.move || '';

2
src/style_manager/view/PropertyFileView.js

@ -12,7 +12,7 @@ export default class PropertyFileView extends PropertyView {
templateInput() { templateInput() {
const { pfx, em } = this; const { pfx, em } = this;
const icons = this.em?.getConfig('icons'); const icons = this.em?.getConfig().icons;
const iconClose = icons?.close; const iconClose = icons?.close;
return ` return `

2
src/style_manager/view/PropertyStackView.js

@ -13,7 +13,7 @@ export default class PropertyStackView extends PropertyCompositeView {
templateInput() { templateInput() {
const { pfx, em } = this; const { pfx, em } = this;
const icons = em?.getConfig('icons'); const icons = em?.getConfig().icons;
const iconPlus = icons?.plus || '+'; const iconPlus = icons?.plus || '+';
return ` return `
<div class="${pfx}field ${pfx}stack"> <div class="${pfx}field ${pfx}stack">

2
src/style_manager/view/PropertyView.js

@ -17,7 +17,7 @@ export default class Property extends View {
const { pfx, em } = this; const { pfx, em } = this;
const { parent } = model; const { parent } = model;
const { icon = '', info = '' } = model.attributes; const { icon = '', info = '' } = model.attributes;
const icons = em?.getConfig('icons'); const icons = em?.getConfig().icons;
const iconClose = icons?.close || ''; const iconClose = icons?.close || '';
return ` return `

2
src/style_manager/view/SectorView.js

@ -4,7 +4,7 @@ import PropertiesView from './PropertiesView';
export default class SectorView extends View { export default class SectorView extends View {
template({ pfx, label }) { template({ pfx, label }) {
const icons = this.em?.getConfig('icons'); const icons = this.em?.getConfig().icons;
const iconCaret = icons?.caret || ''; const iconCaret = icons?.caret || '';
const clsPfx = `${pfx}sector-`; const clsPfx = `${pfx}sector-`;

Loading…
Cancel
Save