diff --git a/apps/common/main/lib/controller/Plugins.js b/apps/common/main/lib/controller/Plugins.js index c5c7d32b2..fe13068e2 100644 --- a/apps/common/main/lib/controller/Plugins.js +++ b/apps/common/main/lib/controller/Plugins.js @@ -102,6 +102,8 @@ define([ Common.Gateway.on('init', this.loadConfig.bind(this)); Common.NotificationCenter.on('app:face', this.onAppShowed.bind(this)); + Common.NotificationCenter.on('uitheme:changed', this.updatePluginsButtons.bind(this)); + Common.NotificationCenter.on('window:resize', this.updatePluginsButtons.bind(this)); }, loadConfig: function(data) { @@ -283,6 +285,14 @@ define([ } }, + updatePluginsButtons: function() { + var storePlugins = this.getApplication().getCollection('Common.Collections.Plugins'), + me = this; + storePlugins.each(function(item){ + me.panelPlugins.updatePluginButton(item); + }); + }, + onSelectPlugin: function(picker, item, record, e){ var btn = $(e.target); if (btn && btn.hasClass('plugin-caret')) { diff --git a/apps/common/main/lib/view/Plugins.js b/apps/common/main/lib/view/Plugins.js index 9f79a2af5..159ddc0c6 100644 --- a/apps/common/main/lib/view/Plugins.js +++ b/apps/common/main/lib/view/Plugins.js @@ -151,7 +151,7 @@ define([ var modes = model.get('variations'), guid = model.get('guid'), icons = modes[model.get('currentVariation')].get('icons'), - _icon_url = model.get('baseUrl') + icons[((Common.Utils.applicationPixelRatio() > 1) ? 1 : 0) + (icons.length>2 ? 2 : 0)], + _icon_url = model.get('baseUrl') + me.parseIcons(icons), btn = new Common.UI.Button({ cls: 'btn-toolbar x-huge icon-top', iconImg: _icon_url, @@ -280,6 +280,65 @@ define([ _onAppReady: function (mode) { }, + parseIcons: function(icons) { + if (icons.length && typeof icons[0] !== 'string') { + var theme = Common.UI.Themes.current().toLowerCase(), + style = Common.UI.Themes.isDarkTheme() ? 'dark' : 'light', + idx = -1; + for (var i=0; i0.01 && defUrl) && (bestUrl = defUrl); + return bestUrl; + } else { // old version + return icons[((Common.Utils.applicationPixelRatio() > 1) ? 1 : 0) + (icons.length > 2 ? 2 : 0)] + } + }, + + updatePluginButton: function(model) { + if (!model.get('visible')) + return null; + + var modes = model.get('variations'), + icons = modes[model.get('currentVariation')].get('icons'), + btn = model.get('button'); + if (btn && btn.cmpEl) { + btn.cmpEl.find(".inner-box-icon img").attr("src", model.get('baseUrl') + this.parseIcons(icons)); + } + }, + createPluginButton: function (model) { if (!model.get('visible')) return null; @@ -289,8 +348,7 @@ define([ var modes = model.get('variations'), guid = model.get('guid'), icons = modes[model.get('currentVariation')].get('icons'), - icon_url = model.get('baseUrl') + icons[((Common.Utils.applicationPixelRatio() > 1) ? 1 : 0) + (icons.length > 2 ? 2 : 0)]; - + icon_url = model.get('baseUrl') + this.parseIcons(icons); var _menu_items = []; _.each(model.get('variations'), function(variation, index) { if (variation.get('visible'))