From 5da34522f076a449e710f409270caf900ffeec91 Mon Sep 17 00:00:00 2001 From: Artur Arseniev Date: Sun, 12 Nov 2017 12:59:11 +0100 Subject: [PATCH] Make use of `getCurrentMedia` in SectorsView --- src/editor/model/Editor.js | 5 +++-- src/style_manager/view/SectorsView.js | 12 ++++-------- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/src/editor/model/Editor.js b/src/editor/model/Editor.js index 971423956..cb4dcf92f 100644 --- a/src/editor/model/Editor.js +++ b/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} */ getCurrentMedia() { const config = this.config; const device = this.getDeviceModel(); const condition = config.mediaCondition; + const preview = config.devicePreviewMode; const width = device && device.get('widthMedia'); - return device && width ? `(${condition}: ${width})` : ''; + return device && width && !preview ? `(${condition}: ${width})` : ''; }, diff --git a/src/style_manager/view/SectorsView.js b/src/style_manager/view/SectorsView.js index 715fd8fa4..a1cfa8faa 100644 --- a/src/style_manager/view/SectorsView.js +++ b/src/style_manager/view/SectorsView.js @@ -50,16 +50,12 @@ module.exports = Backbone.View.extend({ // TODO make use of getModelToStyle here const config = em.get('Config'); - var previewMode = config.devicePreviewMode; var classes = el.get('classes'); var pt = this.propTarget; - var device = em.getDeviceModel(); - var state = !previewMode ? el.get('state') : ''; - var widthMedia = device && device.get('widthMedia'); + var state = !config.devicePreviewMode ? el.get('state') : ''; var stateStr = state ? `:${state}` : null; var view = el.view; - var mediaText = device && !previewMode && widthMedia ? - `(${config.mediaCondition}: ${widthMedia})` : ''; + const media = em.getCurrentMedia(); pt.helper = null; if (view) { @@ -69,7 +65,7 @@ module.exports = Backbone.View.extend({ if (classes.length) { var cssC = em.get('CssComposer'); var valid = classes.getStyleable(); - var iContainer = cssC.get(valid, state, mediaText); + var iContainer = cssC.get(valid, state, media); if (!iContainer && valid.length) { // 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 // #268 um.stopTracking(); - iContainer = cssC.add(valid, state, mediaText); + iContainer = cssC.add(valid, state, media); iContainer.set('style', el.get('style')); el.set('style', {}); um.startTracking();