[DE] Change plugins loading.
This commit is contained in:
parent
be56f9e3de
commit
6c427e9229
|
@ -72,7 +72,7 @@ define([
|
||||||
|
|
||||||
initialize: function(options) {
|
initialize: function(options) {
|
||||||
_.extend(this, options);
|
_.extend(this, options);
|
||||||
this.pluginsPath = '../../../../sdkjs-plugins/';
|
this.pluginsPath = '';
|
||||||
this._locked = false;
|
this._locked = false;
|
||||||
this._state = {
|
this._state = {
|
||||||
DisabledControls: true
|
DisabledControls: true
|
||||||
|
|
|
@ -864,6 +864,7 @@ define([
|
||||||
|
|
||||||
pluginsController.setApi(me.api);
|
pluginsController.setApi(me.api);
|
||||||
me.updatePlugins(me.plugins, false);
|
me.updatePlugins(me.plugins, false);
|
||||||
|
me.requestPlugins('../../../../sdkjs-plugins/config.json');
|
||||||
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);
|
||||||
|
@ -1852,6 +1853,48 @@ define([
|
||||||
if (url) this.iframePrint.src = url;
|
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
|
updatePlugins: function(plugins, uiCustomize) { // plugins from config
|
||||||
if (!plugins) return;
|
if (!plugins) return;
|
||||||
|
|
||||||
|
@ -1892,20 +1935,17 @@ define([
|
||||||
return null;
|
return null;
|
||||||
};
|
};
|
||||||
|
|
||||||
var arr = [],
|
var arr = [];
|
||||||
baseUrl = plugins.url;
|
|
||||||
pluginsData.forEach(function(item){
|
pluginsData.forEach(function(item){
|
||||||
var url = item;
|
var url = item,
|
||||||
if (!/(^https?:\/\/)/i.test(url) && !/(^www.)/i.test(item))
|
value = _getPluginJson(url);
|
||||||
url = baseUrl + item;
|
value.baseUrl = url.substring(0, url.lastIndexOf("config.json"));
|
||||||
var value = _getPluginJson(url);
|
|
||||||
if (value) arr.push(value);
|
if (value) arr.push(value);
|
||||||
});
|
});
|
||||||
|
|
||||||
if (arr.length>0)
|
if (arr.length>0)
|
||||||
this.updatePluginsList({
|
this.updatePluginsList({
|
||||||
autoStartGuid: plugins.autoStartGuid,
|
autoStartGuid: plugins.autoStartGuid,
|
||||||
url: plugins.url,
|
|
||||||
pluginsData: arr
|
pluginsData: arr
|
||||||
}, !!uiCustomize);
|
}, !!uiCustomize);
|
||||||
},
|
},
|
||||||
|
@ -1927,7 +1967,7 @@ define([
|
||||||
}
|
}
|
||||||
if (isSupported && (isEdit || itemVar.isViewer)) {
|
if (isSupported && (isEdit || itemVar.isViewer)) {
|
||||||
var isRelativeUrl = !(/(^https?:\/\/)/i.test(itemVar.url) || /(^www.)/i.test(itemVar.url));
|
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((isRelativeUrl) ? (item.baseUrl + 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,
|
||||||
|
|
Loading…
Reference in a new issue