Commit dabdfddb authored by Alexey Golubev's avatar Alexey Golubev

Merge branch 'hotfix/v4.2.8'

parents 65363239 7fff771e
......@@ -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) {
var _user = info || {};
!_user.id && (_user.id = ('uid-' + Date.now()));
......
......@@ -147,6 +147,7 @@ define([
this.editorConfig = {};
this.appOptions = {};
this.plugins = undefined;
this.UICustomizePlugins = [];
Common.Gateway.on('init', _.bind(this.loadConfig, this));
Common.Gateway.on('showmessage', _.bind(this.onExternalMessage, 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});
pluginsController.setApi(me.api);
me.updatePlugins(me.plugins);
me.updatePlugins(me.plugins, false);
me.api.asc_registerCallback('asc_onPluginsInit', _.bind(me.updatePluginsList, me));
documentHolderController.setApi(me.api);
......@@ -905,9 +906,14 @@ define([
toolbarController.onApiCoAuthoringDisconnect();
me.api.UpdateInterfaceState();
me.fillTextArt(me.api.asc_getTextArtPreviews());
if (me.appOptions.canBrandingExt)
Common.NotificationCenter.trigger('document:ready', 'main');
}
}, 50);
}
} else if (me.appOptions.canBrandingExt)
Common.NotificationCenter.trigger('document:ready', 'main');
if (this.appOptions.canAnalytics && false)
Common.component.Analytics.initialize('UA-12442749-13', 'Document Editor');
......@@ -1013,7 +1019,9 @@ define([
params.asc_getTrial() && headerView.setDeveloperMode(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.applyModeEditorElements();
......@@ -1464,13 +1472,15 @@ define([
},
hidePreloader: function() {
if (!!this.appOptions.customization && !this.appOptions.customization.done) {
this.appOptions.customization.done = true;
if (!this.appOptions.isDesktopApp)
if (!this._state.customizationDone) {
this._state.customizationDone = true;
if (this.appOptions.customization && !this.appOptions.isDesktopApp)
this.appOptions.customization.about = true;
Common.Utils.applyCustomization(this.appOptions.customization, mapCustomizationElements);
if (this.appOptions.canBrandingExt)
if (this.appOptions.canBrandingExt) {
Common.Utils.applyCustomization(this.appOptions.customization, mapCustomizationExtElements);
Common.Utils.applyCustomizationPlugins(this.UICustomizePlugins);
}
}
Common.NotificationCenter.trigger('layout:changed', 'main');
......@@ -1803,8 +1813,11 @@ define([
if (url) this.iframePrint.src = url;
},
updatePlugins: function(plugins) { // plugins from config
if (!plugins || !plugins.pluginsData || plugins.pluginsData.length<1) return;
updatePlugins: function(plugins, uiCustomize) { // plugins from config
if (!plugins) return;
var pluginsData = (uiCustomize) ? plugins.UIpluginsData : plugins.pluginsData;
if (!pluginsData || pluginsData.length<1) return;
var _createXMLHTTPObject = function() {
var xmlhttp;
......@@ -1842,7 +1855,7 @@ define([
var arr = [],
baseUrl = plugins.url;
plugins.pluginsData.forEach(function(item){
pluginsData.forEach(function(item){
var url = item;
if (!/(^https?:\/\/)/i.test(url) && !/(^www.)/i.test(item))
url = baseUrl + item;
......@@ -1855,14 +1868,14 @@ define([
autoStartGuid: plugins.autoStartGuid,
url: plugins.url,
pluginsData: arr
});
}, !!uiCustomize);
},
updatePluginsList: function(plugins) {
updatePluginsList: function(plugins, uiCustomize) {
var pluginStore = this.getApplication().getCollection('Common.Collections.Plugins'),
isEdit = this.appOptions.isEdit;
if (pluginStore && plugins) {
var arr = [];
if (plugins) {
var arr = [], arrUI = [];
plugins.pluginsData.forEach(function(item){
var variations = item.variations,
variationsArr = [];
......@@ -1873,7 +1886,9 @@ define([
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({
description: itemVar.description,
index: variationsArr.length,
......@@ -1890,10 +1905,11 @@ define([
buttons: itemVar.buttons,
size: itemVar.size,
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({
name : item.name,
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;
if (!uiCustomize) {
if (pluginStore) pluginStore.reset(arr);
this.appOptions.pluginsPath = (plugins.url);
this.appOptions.canPlugins = (arr.length>0);
} else {
}
} else if (!uiCustomize){
this.appOptions.pluginsPath = '';
this.appOptions.canPlugins = false;
}
......@@ -1916,7 +1936,7 @@ define([
if (plugins.autoStartGuid)
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.',
......
......@@ -142,6 +142,7 @@ define([
this.editorConfig = {};
this.appOptions = {};
this.plugins = undefined;
this.UICustomizePlugins = [];
Common.Gateway.on('init', _.bind(this.loadConfig, this));
Common.Gateway.on('showmessage', _.bind(this.onExternalMessage, 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});
pluginsController.setApi(me.api);
me.updatePlugins(me.plugins);
me.updatePlugins(me.plugins, false);
me.api.asc_registerCallback('asc_onPluginsInit', _.bind(me.updatePluginsList, me));
documentHolderController.setApi(me.api);
......@@ -686,9 +687,14 @@ define([
if (me.needToUpdateVersion)
toolbarController.onApiCoAuthoringDisconnect();
me.api.UpdateInterfaceState();
if (me.appOptions.canBrandingExt)
Common.NotificationCenter.trigger('document:ready', 'main');
}
}, 50);
}
} else if (me.appOptions.canBrandingExt)
Common.NotificationCenter.trigger('document:ready', 'main');
if (this.appOptions.canAnalytics && false)
Common.component.Analytics.initialize('UA-12442749-13', 'Presentation Editor');
......@@ -778,7 +784,9 @@ define([
params.asc_getTrial() && headerView.setDeveloperMode(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.applyModeEditorElements();
......@@ -1217,13 +1225,15 @@ define([
},
hidePreloader: function() {
if (!!this.appOptions.customization && !this.appOptions.customization.done) {
this.appOptions.customization.done = true;
if (!this.appOptions.isDesktopApp)
if (!this._state.customizationDone) {
this._state.customizationDone = true;
if (this.appOptions.customization && !this.appOptions.isDesktopApp)
this.appOptions.customization.about = true;
Common.Utils.applyCustomization(this.appOptions.customization, mapCustomizationElements);
if (this.appOptions.canBrandingExt)
if (this.appOptions.canBrandingExt) {
Common.Utils.applyCustomization(this.appOptions.customization, mapCustomizationExtElements);
Common.Utils.applyCustomizationPlugins(this.UICustomizePlugins);
}
}
Common.NotificationCenter.trigger('layout:changed', 'main');
......@@ -1581,8 +1591,11 @@ define([
}
},
updatePlugins: function(plugins) { // plugins from config
if (!plugins || !plugins.pluginsData || plugins.pluginsData.length<1) return;
updatePlugins: function(plugins, uiCustomize) { // plugins from config
if (!plugins) return;
var pluginsData = (uiCustomize) ? plugins.UIpluginsData : plugins.pluginsData;
if (!pluginsData || pluginsData.length<1) return;
var _createXMLHTTPObject = function() {
var xmlhttp;
......@@ -1620,7 +1633,7 @@ define([
var arr = [],
baseUrl = plugins.url;
plugins.pluginsData.forEach(function(item){
pluginsData.forEach(function(item){
var url = item;
if (!/(^https?:\/\/)/i.test(url) && !/(^www.)/i.test(item))
url = baseUrl + item;
......@@ -1633,14 +1646,14 @@ define([
autoStartGuid: plugins.autoStartGuid,
url: plugins.url,
pluginsData: arr
});
}, !!uiCustomize);
},
updatePluginsList: function(plugins) {
updatePluginsList: function(plugins, uiCustomize) {
var pluginStore = this.getApplication().getCollection('Common.Collections.Plugins'),
isEdit = this.appOptions.isEdit;
if (pluginStore && plugins) {
var arr = [];
if (plugins) {
var arr = [], arrUI = [];
plugins.pluginsData.forEach(function(item){
var variations = item.variations,
variationsArr = [];
......@@ -1651,7 +1664,9 @@ define([
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({
description: itemVar.description,
index: variationsArr.length,
......@@ -1668,10 +1683,11 @@ define([
buttons: itemVar.buttons,
size: itemVar.size,
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({
name : item.name,
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;
if (!uiCustomize) {
if (pluginStore) pluginStore.reset(arr);
this.appOptions.pluginsPath = (plugins.url);
this.appOptions.canPlugins = (arr.length>0);
} else {
}
} else if (!uiCustomize){
this.appOptions.pluginsPath = '';
this.appOptions.canPlugins = false;
}
......@@ -1694,7 +1714,7 @@ define([
if (plugins.autoStartGuid)
this.api.asc_pluginRun(plugins.autoStartGuid, 0, '');
}
this.getApplication().getController('LeftMenu').enablePlugins();
if (!uiCustomize) this.getApplication().getController('LeftMenu').enablePlugins();
},
// Translation
......
......@@ -147,6 +147,7 @@ define([
// Initialize api gateway
this.editorConfig = {};
this.plugins = undefined;
this.UICustomizePlugins = [];
Common.Gateway.on('init', _.bind(this.loadConfig, this));
Common.Gateway.on('showmessage', _.bind(this.onExternalMessage, this));
Common.Gateway.on('opendocument', _.bind(this.loadDocument, this));
......@@ -620,7 +621,7 @@ define([
if (!me.appOptions.isEditMailMerge && !me.appOptions.isEditDiagram) {
pluginsController.setApi(me.api);
me.updatePlugins(me.plugins);
me.updatePlugins(me.plugins, false);
me.api.asc_registerCallback('asc_onPluginsInit', _.bind(me.updatePluginsList, me));
}
......@@ -692,9 +693,13 @@ define([
}
if (me.needToUpdateVersion)
toolbarController.onApiCoAuthoringDisconnect();
if (me.appOptions.canBrandingExt)
Common.NotificationCenter.trigger('document:ready', 'main');
}
}, 50);
}
} else if (me.appOptions.canBrandingExt)
Common.NotificationCenter.trigger('document:ready', 'main');
if (me.appOptions.canAnalytics && false)
Common.component.Analytics.initialize('UA-12442749-13', 'Spreadsheet Editor');
......@@ -790,7 +795,9 @@ define([
if (this.appOptions.canBranding)
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);
this.appOptions.canRename && this.headerView.setCanRename(true);
......@@ -1356,13 +1363,15 @@ define([
},
hidePreloader: function() {
if (!!this.appOptions.customization && !this.appOptions.customization.done) {
this.appOptions.customization.done = true;
if (!this.appOptions.isDesktopApp)
if (!this._state.customizationDone) {
this._state.customizationDone = true;
if (this.appOptions.customization && !this.appOptions.isDesktopApp)
this.appOptions.customization.about = true;
Common.Utils.applyCustomization(this.appOptions.customization, mapCustomizationElements);
if (this.appOptions.canBrandingExt)
if (this.appOptions.canBrandingExt) {
Common.Utils.applyCustomization(this.appOptions.customization, mapCustomizationExtElements);
Common.Utils.applyCustomizationPlugins(this.UICustomizePlugins);
}
}
this.stackLongActions.pop({id: InitApplication, type: Asc.c_oAscAsyncActionType.BlockInteraction});
......@@ -1807,8 +1816,11 @@ define([
if (url) this.iframePrint.src = url;
},
updatePlugins: function(plugins) { // plugins from config
if (!plugins || !plugins.pluginsData || plugins.pluginsData.length<1) return;
updatePlugins: function(plugins, uiCustomize) { // plugins from config
if (!plugins) return;
var pluginsData = (uiCustomize) ? plugins.UIpluginsData : plugins.pluginsData;
if (!pluginsData || pluginsData.length<1) return;
var _createXMLHTTPObject = function() {
var xmlhttp;
......@@ -1846,7 +1858,7 @@ define([
var arr = [],
baseUrl = plugins.url;
plugins.pluginsData.forEach(function(item){
pluginsData.forEach(function(item){
var url = item;
if (!/(^https?:\/\/)/i.test(url) && !/(^www.)/i.test(item))
url = baseUrl + item;
......@@ -1859,14 +1871,14 @@ define([
autoStartGuid: plugins.autoStartGuid,
url: plugins.url,
pluginsData: arr
});
}, !!uiCustomize);
},
updatePluginsList: function(plugins) {
updatePluginsList: function(plugins, uiCustomize) {
var pluginStore = this.getApplication().getCollection('Common.Collections.Plugins'),
isEdit = this.appOptions.isEdit;
if (pluginStore && plugins) {
var arr = [];
if (plugins) {
var arr = [], arrUI = [];
plugins.pluginsData.forEach(function(item){
var variations = item.variations,
variationsArr = [];
......@@ -1877,7 +1889,9 @@ define([
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({
description: itemVar.description,
index: variationsArr.length,
......@@ -1894,10 +1908,11 @@ define([
buttons: itemVar.buttons,
size: itemVar.size,
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({
name : item.name,
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;
if (!uiCustomize) {
if (pluginStore) pluginStore.reset(arr);
this.appOptions.pluginsPath = (plugins.url);
this.appOptions.canPlugins = (arr.length>0);
} else {
}
} else if (!uiCustomize){
this.appOptions.pluginsPath = '';
this.appOptions.canPlugins = false;
}
......@@ -1920,7 +1939,7 @@ define([
if (plugins.autoStartGuid)
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.',
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment