diff --git a/apps/common/main/lib/controller/Plugins.js b/apps/common/main/lib/controller/Plugins.js index 28b805329..46b01ccbc 100644 --- a/apps/common/main/lib/controller/Plugins.js +++ b/apps/common/main/lib/controller/Plugins.js @@ -84,7 +84,6 @@ define([ setMode: function(mode) { if (mode.canPlugins) { - this.panelPlugins.pluginsPath = mode.pluginsPath; this.updatePluginsList(); } }, @@ -143,7 +142,7 @@ define([ item.set('pluginObj', plugin); arr.push(plugin); }); - this.api.asc_pluginsRegister(this.panelPlugins.pluginsPath, arr); + this.api.asc_pluginsRegister('', arr); }, onSelectPlugin: function(picker, item, record, e){ @@ -205,7 +204,7 @@ define([ menuContainer.css({left: showPoint[0], top: showPoint[1]}); menu.menuAlignEl = currentTarget; - menu.setOffset(-11, -currentTarget.height()/2 + 2); + menu.setOffset(-20, -currentTarget.height()/2 - 3); menu.show(); _.delay(function() { menu.cmpEl.focus(); @@ -220,8 +219,7 @@ define([ var variation = plugin.get_Variations()[variationIndex]; if (variation.get_Visual()) { var url = variation.get_Url(); - if (!/(^https?:\/\/)/i.test(url) && !/(^www.)/i.test(url)) - url = ((plugin.get_BaseUrl().length == 0) ? this.panelPlugins.pluginsPath : plugin.get_BaseUrl()) + url; + url = ((plugin.get_BaseUrl().length == 0) ? url : plugin.get_BaseUrl()) + url; if (variation.get_InsideMode()) { if (!this.panelPlugins.openInsideMode(plugin.get_Name(), url)) diff --git a/apps/common/main/lib/model/Plugin.js b/apps/common/main/lib/model/Plugin.js index 9cb49b4d7..3612817be 100644 --- a/apps/common/main/lib/model/Plugin.js +++ b/apps/common/main/lib/model/Plugin.js @@ -65,8 +65,7 @@ define([ isUpdateOleOnResize: false, buttons: [], size: [800, 600], - initOnSelectionChanged: false, - isRelativeUrl: true + initOnSelectionChanged: false } } }); diff --git a/apps/common/main/lib/view/Plugins.js b/apps/common/main/lib/view/Plugins.js index ef28ceaf6..2089c7753 100644 --- a/apps/common/main/lib/view/Plugins.js +++ b/apps/common/main/lib/view/Plugins.js @@ -72,7 +72,6 @@ define([ initialize: function(options) { _.extend(this, options); - this.pluginsPath = '../../../../sdkjs-plugins/'; this._locked = false; this._state = { DisabledControls: true @@ -92,7 +91,7 @@ define([ enableKeyEvents: false, itemTemplate: _.template([ '
', - '
' + '<%= baseUrl %>' + '<% } else { %>' + this.pluginsPath + '<% } } %>' + '<%= variations[currentVariation].get("icons")[(window.devicePixelRatio > 1) ? 1 : 0] %>);">
', + '
1) ? 1 : 0] %>);">
', '<% if (variations.length>1) { %>', '
', '<% } %>', diff --git a/apps/common/main/resources/less/plugins.less b/apps/common/main/resources/less/plugins.less index a8243aa70..361eef56d 100644 --- a/apps/common/main/resources/less/plugins.less +++ b/apps/common/main/resources/less/plugins.less @@ -44,8 +44,8 @@ } .plugin-icon { - width: 31px; - height: 31px; + width: 40px; + height: 40px; display: inline-block; .box-shadow(0 0 0 1px transparent); vertical-align: middle; diff --git a/apps/documenteditor/main/app/controller/Main.js b/apps/documenteditor/main/app/controller/Main.js index 6c5f383d9..aa41212e8 100644 --- a/apps/documenteditor/main/app/controller/Main.js +++ b/apps/documenteditor/main/app/controller/Main.js @@ -865,6 +865,7 @@ define([ pluginsController.setApi(me.api); me.updatePlugins(me.plugins, false); + me.requestPlugins('../../../../sdkjs-plugins/config.json'); me.api.asc_registerCallback('asc_onPluginsInit', _.bind(me.updatePluginsList, me)); documentHolderController.setApi(me.api); @@ -1832,6 +1833,48 @@ define([ if (url) this.iframePrint.src = url; }, + requestPlugins: function(pluginsPath) { // request plugins + if (!pluginsPath) return; + + var _createXMLHTTPObject = function() { + var xmlhttp; + try { + xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); + } + catch (e) { + try { + xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); + } + catch (E) { + xmlhttp = false; + } + } + if (!xmlhttp && typeof XMLHttpRequest != 'undefined') { + xmlhttp = new XMLHttpRequest(); + } + return xmlhttp; + }; + + var _getPluginJson = function(plugin) { + if (!plugin) return ''; + try { + var xhrObj = _createXMLHTTPObject(); + if (xhrObj && plugin) { + xhrObj.open('GET', plugin, false); + xhrObj.send(''); + var pluginJson = eval("(" + xhrObj.responseText + ")"); + return pluginJson; + } + } + catch (e) {} + return null; + }; + + var value = _getPluginJson(pluginsPath); + if (value) + this.updatePlugins(value, false); + }, + updatePlugins: function(plugins, uiCustomize) { // plugins from config if (!plugins) return; @@ -1872,20 +1915,18 @@ define([ return null; }; - var arr = [], - baseUrl = plugins.url; + var arr = []; pluginsData.forEach(function(item){ - var url = item; - if (!/(^https?:\/\/)/i.test(url) && !/(^www.)/i.test(item)) - url = baseUrl + item; - var value = _getPluginJson(url); - if (value) arr.push(value); + var value = _getPluginJson(item); + if (value) { + value.baseUrl = item.substring(0, item.lastIndexOf("config.json")); + arr.push(value); + } }); if (arr.length>0) this.updatePluginsList({ autoStartGuid: plugins.autoStartGuid, - url: plugins.url, pluginsData: arr }, !!uiCustomize); }, @@ -1896,6 +1937,8 @@ define([ if (plugins) { var arr = [], arrUI = []; plugins.pluginsData.forEach(function(item){ + if (uiCustomize!==undefined && pluginStore.findWhere({baseUrl : item.baseUrl})) return; + var variations = item.variations, variationsArr = []; variations.forEach(function(itemVar){ @@ -1906,8 +1949,7 @@ define([ } } if (isSupported && (isEdit || itemVar.isViewer)) { - var isRelativeUrl = !(/(^https?:\/\/)/i.test(itemVar.url) || /(^www.)/i.test(itemVar.url)); - item.isUICustomizer ? arrUI.push((isRelativeUrl) ? ((item.baseUrl ? item.baseUrl : plugins.url) + itemVar.url) : itemVar.url) : + item.isUICustomizer ? arrUI.push(item.baseUrl + itemVar.url) : variationsArr.push(new Common.Models.PluginVariation({ description: itemVar.description, index: variationsArr.length, @@ -1923,8 +1965,7 @@ define([ isUpdateOleOnResize : itemVar.isUpdateOleOnResize, buttons: itemVar.buttons, size: itemVar.size, - initOnSelectionChanged: itemVar.initOnSelectionChanged, - isRelativeUrl: isRelativeUrl + initOnSelectionChanged: itemVar.initOnSelectionChanged })); } }); @@ -1941,13 +1982,14 @@ define([ if (uiCustomize!==false) // from ui customizer in editor config or desktop event this.UICustomizePlugins = arrUI; - if (!uiCustomize) { + if (uiCustomize === undefined) { // for desktop if (pluginStore) pluginStore.reset(arr); - this.appOptions.pluginsPath = (plugins.url); - this.appOptions.canPlugins = (arr.length>0); + this.appOptions.canPlugins = (pluginStore.length>0); + } else if (!uiCustomize) { + if (pluginStore) pluginStore.add(arr); + this.appOptions.canPlugins = (pluginStore.length>0); } } else if (!uiCustomize){ - this.appOptions.pluginsPath = ''; this.appOptions.canPlugins = false; } if (this.appOptions.canPlugins) { diff --git a/apps/presentationeditor/main/app/controller/Main.js b/apps/presentationeditor/main/app/controller/Main.js index 63a6009ff..a0032331a 100644 --- a/apps/presentationeditor/main/app/controller/Main.js +++ b/apps/presentationeditor/main/app/controller/Main.js @@ -642,6 +642,7 @@ define([ pluginsController.setApi(me.api); me.updatePlugins(me.plugins, false); + me.requestPlugins('../../../../sdkjs-plugins/config.json'); me.api.asc_registerCallback('asc_onPluginsInit', _.bind(me.updatePluginsList, me)); documentHolderController.setApi(me.api); @@ -1592,6 +1593,49 @@ define([ } }, + requestPlugins: function(pluginsPath) { // request plugins + if (!pluginsPath) return; + + var _createXMLHTTPObject = function() { + var xmlhttp; + try { + xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); + } + catch (e) { + try { + xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); + } + catch (E) { + xmlhttp = false; + } + } + if (!xmlhttp && typeof XMLHttpRequest != 'undefined') { + xmlhttp = new XMLHttpRequest(); + } + return xmlhttp; + }; + + var _getPluginJson = function(plugin) { + if (!plugin) return ''; + try { + var xhrObj = _createXMLHTTPObject(); + if (xhrObj && plugin) { + xhrObj.open('GET', plugin, false); + xhrObj.send(''); + var pluginJson = eval("(" + xhrObj.responseText + ")"); + return pluginJson; + } + } + catch (e) {} + return null; + }; + + var value = _getPluginJson(pluginsPath); + if (value) + this.updatePlugins(value, false); + }, + + updatePlugins: function(plugins, uiCustomize) { // plugins from config if (!plugins) return; @@ -1632,20 +1676,18 @@ define([ return null; }; - var arr = [], - baseUrl = plugins.url; + var arr = []; pluginsData.forEach(function(item){ - var url = item; - if (!/(^https?:\/\/)/i.test(url) && !/(^www.)/i.test(item)) - url = baseUrl + item; - var value = _getPluginJson(url); - if (value) arr.push(value); + var value = _getPluginJson(item); + if (value) { + value.baseUrl = item.substring(0, item.lastIndexOf("config.json")); + arr.push(value); + } }); if (arr.length>0) this.updatePluginsList({ autoStartGuid: plugins.autoStartGuid, - url: plugins.url, pluginsData: arr }, !!uiCustomize); }, @@ -1666,8 +1708,7 @@ define([ } } if (isSupported && (isEdit || itemVar.isViewer)){ - var isRelativeUrl = !(/(^https?:\/\/)/i.test(itemVar.url) || /(^www.)/i.test(itemVar.url)); - item.isUICustomizer ? arrUI.push((isRelativeUrl) ? ((item.baseUrl ? item.baseUrl : plugins.url) + itemVar.url) : itemVar.url) : + item.isUICustomizer ? arrUI.push(item.baseUrl + itemVar.url) : variationsArr.push(new Common.Models.PluginVariation({ description: itemVar.description, index: variationsArr.length, @@ -1683,8 +1724,7 @@ define([ isUpdateOleOnResize : itemVar.isUpdateOleOnResize, buttons: itemVar.buttons, size: itemVar.size, - initOnSelectionChanged: itemVar.initOnSelectionChanged, - isRelativeUrl: isRelativeUrl + initOnSelectionChanged: itemVar.initOnSelectionChanged })); } }); @@ -1701,13 +1741,14 @@ define([ if (uiCustomize!==false) // from ui customizer in editor config or desktop event this.UICustomizePlugins = arrUI; - if (!uiCustomize) { + if (uiCustomize === undefined) { // for desktop if (pluginStore) pluginStore.reset(arr); - this.appOptions.pluginsPath = (plugins.url); - this.appOptions.canPlugins = (arr.length>0); + this.appOptions.canPlugins = (pluginStore.length>0); + } else if (!uiCustomize) { + if (pluginStore) pluginStore.add(arr); + this.appOptions.canPlugins = (pluginStore.length>0); } } else if (!uiCustomize){ - this.appOptions.pluginsPath = ''; this.appOptions.canPlugins = false; } if (this.appOptions.canPlugins) { diff --git a/apps/spreadsheeteditor/main/app/controller/Main.js b/apps/spreadsheeteditor/main/app/controller/Main.js index a4ecd222b..20be05166 100644 --- a/apps/spreadsheeteditor/main/app/controller/Main.js +++ b/apps/spreadsheeteditor/main/app/controller/Main.js @@ -623,6 +623,7 @@ define([ if (!me.appOptions.isEditMailMerge && !me.appOptions.isEditDiagram) { pluginsController.setApi(me.api); me.updatePlugins(me.plugins, false); + me.requestPlugins('../../../../sdkjs-plugins/config.json'); me.api.asc_registerCallback('asc_onPluginsInit', _.bind(me.updatePluginsList, me)); } @@ -1817,6 +1818,48 @@ define([ if (url) this.iframePrint.src = url; }, + requestPlugins: function(pluginsPath) { // request plugins + if (!pluginsPath) return; + + var _createXMLHTTPObject = function() { + var xmlhttp; + try { + xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); + } + catch (e) { + try { + xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); + } + catch (E) { + xmlhttp = false; + } + } + if (!xmlhttp && typeof XMLHttpRequest != 'undefined') { + xmlhttp = new XMLHttpRequest(); + } + return xmlhttp; + }; + + var _getPluginJson = function(plugin) { + if (!plugin) return ''; + try { + var xhrObj = _createXMLHTTPObject(); + if (xhrObj && plugin) { + xhrObj.open('GET', plugin, false); + xhrObj.send(''); + var pluginJson = eval("(" + xhrObj.responseText + ")"); + return pluginJson; + } + } + catch (e) {} + return null; + }; + + var value = _getPluginJson(pluginsPath); + if (value) + this.updatePlugins(value, false); + }, + updatePlugins: function(plugins, uiCustomize) { // plugins from config if (!plugins) return; @@ -1857,20 +1900,18 @@ define([ return null; }; - var arr = [], - baseUrl = plugins.url; + var arr = []; pluginsData.forEach(function(item){ - var url = item; - if (!/(^https?:\/\/)/i.test(url) && !/(^www.)/i.test(item)) - url = baseUrl + item; - var value = _getPluginJson(url); - if (value) arr.push(value); + var value = _getPluginJson(item); + if (value) { + value.baseUrl = item.substring(0, item.lastIndexOf("config.json")); + arr.push(value); + } }); if (arr.length>0) this.updatePluginsList({ autoStartGuid: plugins.autoStartGuid, - url: plugins.url, pluginsData: arr }, !!uiCustomize); }, @@ -1891,8 +1932,7 @@ define([ } } if (isSupported && (isEdit || itemVar.isViewer)) { - var isRelativeUrl = !(/(^https?:\/\/)/i.test(itemVar.url) || /(^www.)/i.test(itemVar.url)); - item.isUICustomizer ? arrUI.push((isRelativeUrl) ? ((item.baseUrl ? item.baseUrl : plugins.url) + itemVar.url) : itemVar.url) : + item.isUICustomizer ? arrUI.push(item.baseUrl + itemVar.url) : variationsArr.push(new Common.Models.PluginVariation({ description: itemVar.description, index: variationsArr.length, @@ -1908,8 +1948,7 @@ define([ isUpdateOleOnResize : itemVar.isUpdateOleOnResize, buttons: itemVar.buttons, size: itemVar.size, - initOnSelectionChanged: itemVar.initOnSelectionChanged, - isRelativeUrl: isRelativeUrl + initOnSelectionChanged: itemVar.initOnSelectionChanged })); } }); @@ -1926,13 +1965,14 @@ define([ if (uiCustomize!==false) // from ui customizer in editor config or desktop event this.UICustomizePlugins = arrUI; - if (!uiCustomize) { + if (uiCustomize === undefined) { // for desktop if (pluginStore) pluginStore.reset(arr); - this.appOptions.pluginsPath = (plugins.url); - this.appOptions.canPlugins = (arr.length>0); + this.appOptions.canPlugins = (pluginStore.length>0); + } else if (!uiCustomize) { + if (pluginStore) pluginStore.add(arr); + this.appOptions.canPlugins = (pluginStore.length>0); } } else if (!uiCustomize){ - this.appOptions.pluginsPath = ''; this.appOptions.canPlugins = false; } if (this.appOptions.canPlugins) {