Browse Source

Move `getCurrentMedia` in Editor

pull/540/head
Artur Arseniev 9 years ago
parent
commit
85cc802e3d
  1. 10
      src/css_composer/index.js
  2. 14
      src/editor/model/Editor.js

10
src/css_composer/index.js

@ -282,7 +282,7 @@ module.exports = () => {
*/
setIdStyle(name, style = {}, opts = {}) {
const state = opts.state || '';
const media = opts.mediaText || this._getCurrentMedia();
const media = opts.mediaText || em.getCurrentMedia();
const sm = em.get('SelectorManager');
const selector = sm.add({ name, type: Selector.TYPE_ID });
const rule = this.add(selector, state, media);
@ -300,13 +300,5 @@ module.exports = () => {
return rulesView.render().el;
},
_getCurrentMedia() {
const config = em.get('Config');
const device = em.getDeviceModel();
const condition = config.mediaCondition;
const width = device && device.get('widthMedia');
return device && width ? `(${condition}: ${width})` : '';
},
};
};

14
src/editor/model/Editor.js

@ -614,6 +614,20 @@ module.exports = Backbone.Model.extend({
w.getSelection().removeAllRanges();
},
/**
* Get current media text
* @return {string}
*/
getCurrentMedia() {
const config = this.config;
const device = this.getDeviceModel();
const condition = config.mediaCondition;
const width = device && device.get('widthMedia');
return device && width ? `(${condition}: ${width})` : '';
},
/**
* Set/get data from the HTMLElement
* @param {HTMLElement} el

Loading…
Cancel
Save