Browse Source

Make use of `getCurrentMedia` in SectorsView

pull/540/head
Artur Arseniev 9 years ago
parent
commit
5da34522f0
  1. 5
      src/editor/model/Editor.js
  2. 12
      src/style_manager/view/SectorsView.js

5
src/editor/model/Editor.js

@ -616,15 +616,16 @@ module.exports = Backbone.Model.extend({
/** /**
* Get current media text * Get the current media text
* @return {string} * @return {string}
*/ */
getCurrentMedia() { getCurrentMedia() {
const config = this.config; const config = this.config;
const device = this.getDeviceModel(); const device = this.getDeviceModel();
const condition = config.mediaCondition; const condition = config.mediaCondition;
const preview = config.devicePreviewMode;
const width = device && device.get('widthMedia'); const width = device && device.get('widthMedia');
return device && width ? `(${condition}: ${width})` : ''; return device && width && !preview ? `(${condition}: ${width})` : '';
}, },

12
src/style_manager/view/SectorsView.js

@ -50,16 +50,12 @@ module.exports = Backbone.View.extend({
// TODO make use of getModelToStyle here // TODO make use of getModelToStyle here
const config = em.get('Config'); const config = em.get('Config');
var previewMode = config.devicePreviewMode;
var classes = el.get('classes'); var classes = el.get('classes');
var pt = this.propTarget; var pt = this.propTarget;
var device = em.getDeviceModel(); var state = !config.devicePreviewMode ? el.get('state') : '';
var state = !previewMode ? el.get('state') : '';
var widthMedia = device && device.get('widthMedia');
var stateStr = state ? `:${state}` : null; var stateStr = state ? `:${state}` : null;
var view = el.view; var view = el.view;
var mediaText = device && !previewMode && widthMedia ? const media = em.getCurrentMedia();
`(${config.mediaCondition}: ${widthMedia})` : '';
pt.helper = null; pt.helper = null;
if (view) { if (view) {
@ -69,7 +65,7 @@ module.exports = Backbone.View.extend({
if (classes.length) { if (classes.length) {
var cssC = em.get('CssComposer'); var cssC = em.get('CssComposer');
var valid = classes.getStyleable(); var valid = classes.getStyleable();
var iContainer = cssC.get(valid, state, mediaText); var iContainer = cssC.get(valid, state, media);
if (!iContainer && valid.length) { if (!iContainer && valid.length) {
// I stop undo manager here as after adding the CSSRule (generally after // I stop undo manager here as after adding the CSSRule (generally after
@ -77,7 +73,7 @@ module.exports = Backbone.View.extend({
// the collection, therefore updating it in style manager will not affect it // the collection, therefore updating it in style manager will not affect it
// #268 // #268
um.stopTracking(); um.stopTracking();
iContainer = cssC.add(valid, state, mediaText); iContainer = cssC.add(valid, state, media);
iContainer.set('style', el.get('style')); iContainer.set('style', el.get('style'));
el.set('style', {}); el.set('style', {});
um.startTracking(); um.startTracking();

Loading…
Cancel
Save