Interface customization using plugins. Need to append config->editorConfig->pluigns->UIpluginsData field with list of customizer plugins.
This commit is contained in:
parent
970d1368aa
commit
7dfcc927f6
|
@ -602,6 +602,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()));
|
||||||
|
|
|
@ -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));
|
||||||
|
@ -857,7 +858,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);
|
||||||
|
@ -900,9 +901,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');
|
||||||
|
@ -1008,7 +1014,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();
|
||||||
|
@ -1443,13 +1451,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');
|
||||||
|
@ -1782,8 +1792,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;
|
||||||
|
@ -1821,7 +1834,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;
|
||||||
|
@ -1834,14 +1847,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 = [];
|
||||||
|
@ -1852,7 +1865,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,
|
||||||
|
@ -1869,10 +1884,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,
|
||||||
|
@ -1882,11 +1898,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;
|
||||||
}
|
}
|
||||||
|
@ -1895,7 +1915,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.',
|
||||||
|
|
|
@ -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));
|
||||||
|
@ -636,7 +637,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);
|
||||||
|
@ -681,9 +682,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');
|
||||||
|
@ -773,7 +779,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();
|
||||||
|
@ -1196,13 +1204,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');
|
||||||
|
@ -1563,8 +1573,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;
|
||||||
|
@ -1602,7 +1615,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;
|
||||||
|
@ -1615,14 +1628,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 = [];
|
||||||
|
@ -1633,7 +1646,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,
|
||||||
|
@ -1650,10 +1665,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,
|
||||||
|
@ -1663,11 +1679,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;
|
||||||
}
|
}
|
||||||
|
@ -1676,7 +1696,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
|
||||||
|
|
|
@ -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));
|
||||||
|
@ -614,7 +615,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));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -684,9 +685,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');
|
||||||
|
@ -782,7 +787,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);
|
||||||
|
@ -1325,13 +1332,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});
|
||||||
|
@ -1773,8 +1782,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;
|
||||||
|
@ -1812,7 +1824,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;
|
||||||
|
@ -1825,14 +1837,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 = [];
|
||||||
|
@ -1843,7 +1855,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,
|
||||||
|
@ -1860,10 +1874,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,
|
||||||
|
@ -1873,11 +1888,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;
|
||||||
}
|
}
|
||||||
|
@ -1886,7 +1905,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.',
|
||||||
|
|
Loading…
Reference in a new issue