Interface customization using plugins. Need to append config->editorConfig->pluigns->UIpluginsData field with list of customizer plugins.

(cherry picked from commit 7dfcc927f6)
This commit is contained in:
Julia Radzhabova 2016-11-16 12:38:16 +03:00 committed by Maxim Kadushkin
parent f1e58c6a5b
commit 2e6cb63f00
4 changed files with 167 additions and 66 deletions

View file

@ -648,6 +648,48 @@ Common.Utils.applyCustomization = function(config, elmap) {
} }
}; };
Common.Utils.applyCustomizationPlugins = function(plugins) {
if (!plugins || plugins.length<1) 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 _getPluginCode = function(url) {
if (!url) return '';
try {
var xhrObj = _createXMLHTTPObject();
if (xhrObj && url) {
xhrObj.open('GET', url, false);
xhrObj.send('');
if (xhrObj.status == 200)
eval(xhrObj.responseText);
}
}
catch (e) {}
return null;
};
plugins.forEach(function(url){
if (url) _getPluginCode(url);
});
};
Common.Utils.fillUserInfo = function(info, lang, defname) { Common.Utils.fillUserInfo = function(info, lang, defname) {
var _user = info || {}; var _user = info || {};
!_user.id && (_user.id = ('uid-' + Date.now())); !_user.id && (_user.id = ('uid-' + Date.now()));

View file

@ -147,6 +147,7 @@ define([
this.editorConfig = {}; this.editorConfig = {};
this.appOptions = {}; this.appOptions = {};
this.plugins = undefined; this.plugins = undefined;
this.UICustomizePlugins = [];
Common.Gateway.on('init', _.bind(this.loadConfig, this)); Common.Gateway.on('init', _.bind(this.loadConfig, this));
Common.Gateway.on('showmessage', _.bind(this.onExternalMessage, this)); Common.Gateway.on('showmessage', _.bind(this.onExternalMessage, this));
Common.Gateway.on('opendocument', _.bind(this.loadDocument, this)); Common.Gateway.on('opendocument', _.bind(this.loadDocument, this));
@ -860,7 +861,7 @@ define([
application.getController('Common.Controllers.ExternalMergeEditor').setApi(this.api).loadConfig({config:this.editorConfig, customization: this.editorConfig.customization}); application.getController('Common.Controllers.ExternalMergeEditor').setApi(this.api).loadConfig({config:this.editorConfig, customization: this.editorConfig.customization});
pluginsController.setApi(me.api); pluginsController.setApi(me.api);
me.updatePlugins(me.plugins); me.updatePlugins(me.plugins, false);
me.api.asc_registerCallback('asc_onPluginsInit', _.bind(me.updatePluginsList, me)); me.api.asc_registerCallback('asc_onPluginsInit', _.bind(me.updatePluginsList, me));
documentHolderController.setApi(me.api); documentHolderController.setApi(me.api);
@ -905,9 +906,14 @@ define([
toolbarController.onApiCoAuthoringDisconnect(); toolbarController.onApiCoAuthoringDisconnect();
me.api.UpdateInterfaceState(); me.api.UpdateInterfaceState();
me.fillTextArt(me.api.asc_getTextArtPreviews()); me.fillTextArt(me.api.asc_getTextArtPreviews());
if (me.appOptions.canBrandingExt)
Common.NotificationCenter.trigger('document:ready', 'main');
} }
}, 50); }, 50);
} } else if (me.appOptions.canBrandingExt)
Common.NotificationCenter.trigger('document:ready', 'main');
if (this.appOptions.canAnalytics && false) if (this.appOptions.canAnalytics && false)
Common.component.Analytics.initialize('UA-12442749-13', 'Document Editor'); Common.component.Analytics.initialize('UA-12442749-13', 'Document Editor');
@ -1013,7 +1019,9 @@ define([
params.asc_getTrial() && headerView.setDeveloperMode(true); params.asc_getTrial() && headerView.setDeveloperMode(true);
this.appOptions.canRename && headerView.setCanRename(true); this.appOptions.canRename && headerView.setCanRename(true);
this.appOptions.canBrandingExt = params.asc_getCanBranding() && (typeof this.editorConfig.customization == 'object'); this.appOptions.canBrandingExt = params.asc_getCanBranding() && (typeof this.editorConfig.customization == 'object' || this.editorConfig.plugins);
if (this.appOptions.canBrandingExt)
this.updatePlugins(this.plugins, true);
this.applyModeCommonElements(); this.applyModeCommonElements();
this.applyModeEditorElements(); this.applyModeEditorElements();
@ -1464,13 +1472,15 @@ define([
}, },
hidePreloader: function() { hidePreloader: function() {
if (!!this.appOptions.customization && !this.appOptions.customization.done) { if (!this._state.customizationDone) {
this.appOptions.customization.done = true; this._state.customizationDone = true;
if (!this.appOptions.isDesktopApp) if (this.appOptions.customization && !this.appOptions.isDesktopApp)
this.appOptions.customization.about = true; this.appOptions.customization.about = true;
Common.Utils.applyCustomization(this.appOptions.customization, mapCustomizationElements); Common.Utils.applyCustomization(this.appOptions.customization, mapCustomizationElements);
if (this.appOptions.canBrandingExt) if (this.appOptions.canBrandingExt) {
Common.Utils.applyCustomization(this.appOptions.customization, mapCustomizationExtElements); Common.Utils.applyCustomization(this.appOptions.customization, mapCustomizationExtElements);
Common.Utils.applyCustomizationPlugins(this.UICustomizePlugins);
}
} }
Common.NotificationCenter.trigger('layout:changed', 'main'); Common.NotificationCenter.trigger('layout:changed', 'main');
@ -1803,8 +1813,11 @@ define([
if (url) this.iframePrint.src = url; if (url) this.iframePrint.src = url;
}, },
updatePlugins: function(plugins) { // plugins from config updatePlugins: function(plugins, uiCustomize) { // plugins from config
if (!plugins || !plugins.pluginsData || plugins.pluginsData.length<1) return; if (!plugins) return;
var pluginsData = (uiCustomize) ? plugins.UIpluginsData : plugins.pluginsData;
if (!pluginsData || pluginsData.length<1) return;
var _createXMLHTTPObject = function() { var _createXMLHTTPObject = function() {
var xmlhttp; var xmlhttp;
@ -1842,7 +1855,7 @@ define([
var arr = [], var arr = [],
baseUrl = plugins.url; baseUrl = plugins.url;
plugins.pluginsData.forEach(function(item){ pluginsData.forEach(function(item){
var url = item; var url = item;
if (!/(^https?:\/\/)/i.test(url) && !/(^www.)/i.test(item)) if (!/(^https?:\/\/)/i.test(url) && !/(^www.)/i.test(item))
url = baseUrl + item; url = baseUrl + item;
@ -1855,14 +1868,14 @@ define([
autoStartGuid: plugins.autoStartGuid, autoStartGuid: plugins.autoStartGuid,
url: plugins.url, url: plugins.url,
pluginsData: arr pluginsData: arr
}); }, !!uiCustomize);
}, },
updatePluginsList: function(plugins) { updatePluginsList: function(plugins, uiCustomize) {
var pluginStore = this.getApplication().getCollection('Common.Collections.Plugins'), var pluginStore = this.getApplication().getCollection('Common.Collections.Plugins'),
isEdit = this.appOptions.isEdit; isEdit = this.appOptions.isEdit;
if (pluginStore && plugins) { if (plugins) {
var arr = []; var arr = [], arrUI = [];
plugins.pluginsData.forEach(function(item){ plugins.pluginsData.forEach(function(item){
var variations = item.variations, var variations = item.variations,
variationsArr = []; variationsArr = [];
@ -1873,7 +1886,9 @@ define([
isSupported = true; break; isSupported = true; break;
} }
} }
if (isSupported && (isEdit || itemVar.isViewer)) 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) :
variationsArr.push(new Common.Models.PluginVariation({ variationsArr.push(new Common.Models.PluginVariation({
description: itemVar.description, description: itemVar.description,
index: variationsArr.length, index: variationsArr.length,
@ -1890,10 +1905,11 @@ define([
buttons: itemVar.buttons, buttons: itemVar.buttons,
size: itemVar.size, size: itemVar.size,
initOnSelectionChanged: itemVar.initOnSelectionChanged, initOnSelectionChanged: itemVar.initOnSelectionChanged,
isRelativeUrl: !(/(^https?:\/\/)/i.test(itemVar.url) || /(^www.)/i.test(itemVar.url)) isRelativeUrl: isRelativeUrl
})); }));
}
}); });
if (variationsArr.length>0) if (variationsArr.length>0 && !item.isUICustomizer)
arr.push(new Common.Models.Plugin({ arr.push(new Common.Models.Plugin({
name : item.name, name : item.name,
guid: item.guid, guid: item.guid,
@ -1903,11 +1919,15 @@ define([
})); }));
}); });
pluginStore.reset(arr); if (uiCustomize!==false) // from ui customizer in editor config or desktop event
this.UICustomizePlugins = arrUI;
this.appOptions.pluginsPath = (plugins.url); if (!uiCustomize) {
this.appOptions.canPlugins = (arr.length>0); if (pluginStore) pluginStore.reset(arr);
} else { this.appOptions.pluginsPath = (plugins.url);
this.appOptions.canPlugins = (arr.length>0);
}
} else if (!uiCustomize){
this.appOptions.pluginsPath = ''; this.appOptions.pluginsPath = '';
this.appOptions.canPlugins = false; this.appOptions.canPlugins = false;
} }
@ -1916,7 +1936,7 @@ define([
if (plugins.autoStartGuid) if (plugins.autoStartGuid)
this.api.asc_pluginRun(plugins.autoStartGuid, 0, ''); this.api.asc_pluginRun(plugins.autoStartGuid, 0, '');
} }
this.getApplication().getController('LeftMenu').enablePlugins(); if (!uiCustomize) this.getApplication().getController('LeftMenu').enablePlugins();
}, },
leavePageText: 'You have unsaved changes in this document. Click \'Stay on this Page\' then \'Save\' to save them. Click \'Leave this Page\' to discard all the unsaved changes.', leavePageText: 'You have unsaved changes in this document. Click \'Stay on this Page\' then \'Save\' to save them. Click \'Leave this Page\' to discard all the unsaved changes.',

View file

@ -142,6 +142,7 @@ define([
this.editorConfig = {}; this.editorConfig = {};
this.appOptions = {}; this.appOptions = {};
this.plugins = undefined; this.plugins = undefined;
this.UICustomizePlugins = [];
Common.Gateway.on('init', _.bind(this.loadConfig, this)); Common.Gateway.on('init', _.bind(this.loadConfig, this));
Common.Gateway.on('showmessage', _.bind(this.onExternalMessage, this)); Common.Gateway.on('showmessage', _.bind(this.onExternalMessage, this));
Common.Gateway.on('opendocument', _.bind(this.loadDocument, this)); Common.Gateway.on('opendocument', _.bind(this.loadDocument, this));
@ -639,7 +640,7 @@ define([
application.getController('Common.Controllers.ExternalDiagramEditor').setApi(this.api).loadConfig({config:this.editorConfig, customization: this.editorConfig.customization}); application.getController('Common.Controllers.ExternalDiagramEditor').setApi(this.api).loadConfig({config:this.editorConfig, customization: this.editorConfig.customization});
pluginsController.setApi(me.api); pluginsController.setApi(me.api);
me.updatePlugins(me.plugins); me.updatePlugins(me.plugins, false);
me.api.asc_registerCallback('asc_onPluginsInit', _.bind(me.updatePluginsList, me)); me.api.asc_registerCallback('asc_onPluginsInit', _.bind(me.updatePluginsList, me));
documentHolderController.setApi(me.api); documentHolderController.setApi(me.api);
@ -686,9 +687,14 @@ define([
if (me.needToUpdateVersion) if (me.needToUpdateVersion)
toolbarController.onApiCoAuthoringDisconnect(); toolbarController.onApiCoAuthoringDisconnect();
me.api.UpdateInterfaceState(); me.api.UpdateInterfaceState();
if (me.appOptions.canBrandingExt)
Common.NotificationCenter.trigger('document:ready', 'main');
} }
}, 50); }, 50);
} } else if (me.appOptions.canBrandingExt)
Common.NotificationCenter.trigger('document:ready', 'main');
if (this.appOptions.canAnalytics && false) if (this.appOptions.canAnalytics && false)
Common.component.Analytics.initialize('UA-12442749-13', 'Presentation Editor'); Common.component.Analytics.initialize('UA-12442749-13', 'Presentation Editor');
@ -778,7 +784,9 @@ define([
params.asc_getTrial() && headerView.setDeveloperMode(true); params.asc_getTrial() && headerView.setDeveloperMode(true);
this.appOptions.canRename && headerView.setCanRename(true); this.appOptions.canRename && headerView.setCanRename(true);
this.appOptions.canBrandingExt = params.asc_getCanBranding() && (typeof this.editorConfig.customization == 'object'); this.appOptions.canBrandingExt = params.asc_getCanBranding() && (typeof this.editorConfig.customization == 'object' || this.editorConfig.plugins);
if (this.appOptions.canBrandingExt)
this.updatePlugins(this.plugins, true);
this.applyModeCommonElements(); this.applyModeCommonElements();
this.applyModeEditorElements(); this.applyModeEditorElements();
@ -1217,13 +1225,15 @@ define([
}, },
hidePreloader: function() { hidePreloader: function() {
if (!!this.appOptions.customization && !this.appOptions.customization.done) { if (!this._state.customizationDone) {
this.appOptions.customization.done = true; this._state.customizationDone = true;
if (!this.appOptions.isDesktopApp) if (this.appOptions.customization && !this.appOptions.isDesktopApp)
this.appOptions.customization.about = true; this.appOptions.customization.about = true;
Common.Utils.applyCustomization(this.appOptions.customization, mapCustomizationElements); Common.Utils.applyCustomization(this.appOptions.customization, mapCustomizationElements);
if (this.appOptions.canBrandingExt) if (this.appOptions.canBrandingExt) {
Common.Utils.applyCustomization(this.appOptions.customization, mapCustomizationExtElements); Common.Utils.applyCustomization(this.appOptions.customization, mapCustomizationExtElements);
Common.Utils.applyCustomizationPlugins(this.UICustomizePlugins);
}
} }
Common.NotificationCenter.trigger('layout:changed', 'main'); Common.NotificationCenter.trigger('layout:changed', 'main');
@ -1581,8 +1591,11 @@ define([
} }
}, },
updatePlugins: function(plugins) { // plugins from config updatePlugins: function(plugins, uiCustomize) { // plugins from config
if (!plugins || !plugins.pluginsData || plugins.pluginsData.length<1) return; if (!plugins) return;
var pluginsData = (uiCustomize) ? plugins.UIpluginsData : plugins.pluginsData;
if (!pluginsData || pluginsData.length<1) return;
var _createXMLHTTPObject = function() { var _createXMLHTTPObject = function() {
var xmlhttp; var xmlhttp;
@ -1620,7 +1633,7 @@ define([
var arr = [], var arr = [],
baseUrl = plugins.url; baseUrl = plugins.url;
plugins.pluginsData.forEach(function(item){ pluginsData.forEach(function(item){
var url = item; var url = item;
if (!/(^https?:\/\/)/i.test(url) && !/(^www.)/i.test(item)) if (!/(^https?:\/\/)/i.test(url) && !/(^www.)/i.test(item))
url = baseUrl + item; url = baseUrl + item;
@ -1633,14 +1646,14 @@ define([
autoStartGuid: plugins.autoStartGuid, autoStartGuid: plugins.autoStartGuid,
url: plugins.url, url: plugins.url,
pluginsData: arr pluginsData: arr
}); }, !!uiCustomize);
}, },
updatePluginsList: function(plugins) { updatePluginsList: function(plugins, uiCustomize) {
var pluginStore = this.getApplication().getCollection('Common.Collections.Plugins'), var pluginStore = this.getApplication().getCollection('Common.Collections.Plugins'),
isEdit = this.appOptions.isEdit; isEdit = this.appOptions.isEdit;
if (pluginStore && plugins) { if (plugins) {
var arr = []; var arr = [], arrUI = [];
plugins.pluginsData.forEach(function(item){ plugins.pluginsData.forEach(function(item){
var variations = item.variations, var variations = item.variations,
variationsArr = []; variationsArr = [];
@ -1651,7 +1664,9 @@ define([
isSupported = true; break; isSupported = true; break;
} }
} }
if (isSupported && (isEdit || itemVar.isViewer)) 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) :
variationsArr.push(new Common.Models.PluginVariation({ variationsArr.push(new Common.Models.PluginVariation({
description: itemVar.description, description: itemVar.description,
index: variationsArr.length, index: variationsArr.length,
@ -1668,10 +1683,11 @@ define([
buttons: itemVar.buttons, buttons: itemVar.buttons,
size: itemVar.size, size: itemVar.size,
initOnSelectionChanged: itemVar.initOnSelectionChanged, initOnSelectionChanged: itemVar.initOnSelectionChanged,
isRelativeUrl: !(/(^https?:\/\/)/i.test(itemVar.url) || /(^www.)/i.test(itemVar.url)) isRelativeUrl: isRelativeUrl
})); }));
}
}); });
if (variationsArr.length>0) if (variationsArr.length>0 && !item.isUICustomizer)
arr.push(new Common.Models.Plugin({ arr.push(new Common.Models.Plugin({
name : item.name, name : item.name,
guid: item.guid, guid: item.guid,
@ -1681,11 +1697,15 @@ define([
})); }));
}); });
pluginStore.reset(arr); if (uiCustomize!==false) // from ui customizer in editor config or desktop event
this.UICustomizePlugins = arrUI;
this.appOptions.pluginsPath = (plugins.url); if (!uiCustomize) {
this.appOptions.canPlugins = (arr.length>0); if (pluginStore) pluginStore.reset(arr);
} else { this.appOptions.pluginsPath = (plugins.url);
this.appOptions.canPlugins = (arr.length>0);
}
} else if (!uiCustomize){
this.appOptions.pluginsPath = ''; this.appOptions.pluginsPath = '';
this.appOptions.canPlugins = false; this.appOptions.canPlugins = false;
} }
@ -1694,7 +1714,7 @@ define([
if (plugins.autoStartGuid) if (plugins.autoStartGuid)
this.api.asc_pluginRun(plugins.autoStartGuid, 0, ''); this.api.asc_pluginRun(plugins.autoStartGuid, 0, '');
} }
this.getApplication().getController('LeftMenu').enablePlugins(); if (!uiCustomize) this.getApplication().getController('LeftMenu').enablePlugins();
}, },
// Translation // Translation

View file

@ -147,6 +147,7 @@ define([
// Initialize api gateway // Initialize api gateway
this.editorConfig = {}; this.editorConfig = {};
this.plugins = undefined; this.plugins = undefined;
this.UICustomizePlugins = [];
Common.Gateway.on('init', _.bind(this.loadConfig, this)); Common.Gateway.on('init', _.bind(this.loadConfig, this));
Common.Gateway.on('showmessage', _.bind(this.onExternalMessage, this)); Common.Gateway.on('showmessage', _.bind(this.onExternalMessage, this));
Common.Gateway.on('opendocument', _.bind(this.loadDocument, this)); Common.Gateway.on('opendocument', _.bind(this.loadDocument, this));
@ -620,7 +621,7 @@ define([
if (!me.appOptions.isEditMailMerge && !me.appOptions.isEditDiagram) { if (!me.appOptions.isEditMailMerge && !me.appOptions.isEditDiagram) {
pluginsController.setApi(me.api); pluginsController.setApi(me.api);
me.updatePlugins(me.plugins); me.updatePlugins(me.plugins, false);
me.api.asc_registerCallback('asc_onPluginsInit', _.bind(me.updatePluginsList, me)); me.api.asc_registerCallback('asc_onPluginsInit', _.bind(me.updatePluginsList, me));
} }
@ -692,9 +693,13 @@ define([
} }
if (me.needToUpdateVersion) if (me.needToUpdateVersion)
toolbarController.onApiCoAuthoringDisconnect(); toolbarController.onApiCoAuthoringDisconnect();
if (me.appOptions.canBrandingExt)
Common.NotificationCenter.trigger('document:ready', 'main');
} }
}, 50); }, 50);
} } else if (me.appOptions.canBrandingExt)
Common.NotificationCenter.trigger('document:ready', 'main');
if (me.appOptions.canAnalytics && false) if (me.appOptions.canAnalytics && false)
Common.component.Analytics.initialize('UA-12442749-13', 'Spreadsheet Editor'); Common.component.Analytics.initialize('UA-12442749-13', 'Spreadsheet Editor');
@ -790,7 +795,9 @@ define([
if (this.appOptions.canBranding) if (this.appOptions.canBranding)
this.headerView.setBranding(this.editorConfig.customization); this.headerView.setBranding(this.editorConfig.customization);
this.appOptions.canBrandingExt = params.asc_getCanBranding() && (typeof this.editorConfig.customization == 'object'); this.appOptions.canBrandingExt = params.asc_getCanBranding() && (typeof this.editorConfig.customization == 'object' || this.editorConfig.plugins);
if (this.appOptions.canBrandingExt)
this.updatePlugins(this.plugins, true);
params.asc_getTrial() && this.headerView.setDeveloperMode(true); params.asc_getTrial() && this.headerView.setDeveloperMode(true);
this.appOptions.canRename && this.headerView.setCanRename(true); this.appOptions.canRename && this.headerView.setCanRename(true);
@ -1356,13 +1363,15 @@ define([
}, },
hidePreloader: function() { hidePreloader: function() {
if (!!this.appOptions.customization && !this.appOptions.customization.done) { if (!this._state.customizationDone) {
this.appOptions.customization.done = true; this._state.customizationDone = true;
if (!this.appOptions.isDesktopApp) if (this.appOptions.customization && !this.appOptions.isDesktopApp)
this.appOptions.customization.about = true; this.appOptions.customization.about = true;
Common.Utils.applyCustomization(this.appOptions.customization, mapCustomizationElements); Common.Utils.applyCustomization(this.appOptions.customization, mapCustomizationElements);
if (this.appOptions.canBrandingExt) if (this.appOptions.canBrandingExt) {
Common.Utils.applyCustomization(this.appOptions.customization, mapCustomizationExtElements); Common.Utils.applyCustomization(this.appOptions.customization, mapCustomizationExtElements);
Common.Utils.applyCustomizationPlugins(this.UICustomizePlugins);
}
} }
this.stackLongActions.pop({id: InitApplication, type: Asc.c_oAscAsyncActionType.BlockInteraction}); this.stackLongActions.pop({id: InitApplication, type: Asc.c_oAscAsyncActionType.BlockInteraction});
@ -1807,8 +1816,11 @@ define([
if (url) this.iframePrint.src = url; if (url) this.iframePrint.src = url;
}, },
updatePlugins: function(plugins) { // plugins from config updatePlugins: function(plugins, uiCustomize) { // plugins from config
if (!plugins || !plugins.pluginsData || plugins.pluginsData.length<1) return; if (!plugins) return;
var pluginsData = (uiCustomize) ? plugins.UIpluginsData : plugins.pluginsData;
if (!pluginsData || pluginsData.length<1) return;
var _createXMLHTTPObject = function() { var _createXMLHTTPObject = function() {
var xmlhttp; var xmlhttp;
@ -1846,7 +1858,7 @@ define([
var arr = [], var arr = [],
baseUrl = plugins.url; baseUrl = plugins.url;
plugins.pluginsData.forEach(function(item){ pluginsData.forEach(function(item){
var url = item; var url = item;
if (!/(^https?:\/\/)/i.test(url) && !/(^www.)/i.test(item)) if (!/(^https?:\/\/)/i.test(url) && !/(^www.)/i.test(item))
url = baseUrl + item; url = baseUrl + item;
@ -1859,14 +1871,14 @@ define([
autoStartGuid: plugins.autoStartGuid, autoStartGuid: plugins.autoStartGuid,
url: plugins.url, url: plugins.url,
pluginsData: arr pluginsData: arr
}); }, !!uiCustomize);
}, },
updatePluginsList: function(plugins) { updatePluginsList: function(plugins, uiCustomize) {
var pluginStore = this.getApplication().getCollection('Common.Collections.Plugins'), var pluginStore = this.getApplication().getCollection('Common.Collections.Plugins'),
isEdit = this.appOptions.isEdit; isEdit = this.appOptions.isEdit;
if (pluginStore && plugins) { if (plugins) {
var arr = []; var arr = [], arrUI = [];
plugins.pluginsData.forEach(function(item){ plugins.pluginsData.forEach(function(item){
var variations = item.variations, var variations = item.variations,
variationsArr = []; variationsArr = [];
@ -1877,7 +1889,9 @@ define([
isSupported = true; break; isSupported = true; break;
} }
} }
if (isSupported && (isEdit || itemVar.isViewer)) 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) :
variationsArr.push(new Common.Models.PluginVariation({ variationsArr.push(new Common.Models.PluginVariation({
description: itemVar.description, description: itemVar.description,
index: variationsArr.length, index: variationsArr.length,
@ -1894,10 +1908,11 @@ define([
buttons: itemVar.buttons, buttons: itemVar.buttons,
size: itemVar.size, size: itemVar.size,
initOnSelectionChanged: itemVar.initOnSelectionChanged, initOnSelectionChanged: itemVar.initOnSelectionChanged,
isRelativeUrl: !(/(^https?:\/\/)/i.test(itemVar.url) || /(^www.)/i.test(itemVar.url)) isRelativeUrl: isRelativeUrl
})); }));
}
}); });
if (variationsArr.length>0) if (variationsArr.length>0 && !item.isUICustomizer)
arr.push(new Common.Models.Plugin({ arr.push(new Common.Models.Plugin({
name : item.name, name : item.name,
guid: item.guid, guid: item.guid,
@ -1907,11 +1922,15 @@ define([
})); }));
}); });
pluginStore.reset(arr); if (uiCustomize!==false) // from ui customizer in editor config or desktop event
this.UICustomizePlugins = arrUI;
this.appOptions.pluginsPath = (plugins.url); if (!uiCustomize) {
this.appOptions.canPlugins = (arr.length>0); if (pluginStore) pluginStore.reset(arr);
} else { this.appOptions.pluginsPath = (plugins.url);
this.appOptions.canPlugins = (arr.length>0);
}
} else if (!uiCustomize){
this.appOptions.pluginsPath = ''; this.appOptions.pluginsPath = '';
this.appOptions.canPlugins = false; this.appOptions.canPlugins = false;
} }
@ -1920,7 +1939,7 @@ define([
if (plugins.autoStartGuid) if (plugins.autoStartGuid)
this.api.asc_pluginRun(plugins.autoStartGuid, 0, ''); this.api.asc_pluginRun(plugins.autoStartGuid, 0, '');
} }
this.getApplication().getController('LeftMenu').enablePlugins(); if (!uiCustomize) this.getApplication().getController('LeftMenu').enablePlugins();
}, },
leavePageText: 'You have unsaved changes in this document. Click \'Stay on this Page\' then \'Save\' to save them. Click \'Leave this Page\' to discard all the unsaved changes.', leavePageText: 'You have unsaved changes in this document. Click \'Stay on this Page\' then \'Save\' to save them. Click \'Leave this Page\' to discard all the unsaved changes.',