[DE] Изменена структура плагинов.
This commit is contained in:
parent
229d7110c0
commit
7b86f88935
|
@ -107,38 +107,63 @@
|
|||
chat: false,
|
||||
comments: false
|
||||
},
|
||||
plugins: [{
|
||||
name: "chess (fen)",
|
||||
guid: "{FFE1F462-1EA2-4391-990D-4CC84940B754}",
|
||||
url: "chess/index.html",
|
||||
icons: ["chess/icon.png", "chess/icon2x.png"],
|
||||
isVisual: true,
|
||||
initDataType: 2,
|
||||
isUpdateOleOnResize: true,
|
||||
buttons: [{text:"Ok",primary:true},{text:"Cancel",primary:false}]
|
||||
},
|
||||
plugins: {
|
||||
url: '../../../../sdkjs-plugins/',
|
||||
pluginsData: [{
|
||||
name : "chess (fen)",
|
||||
guid : "{FFE1F462-1EA2-4391-990D-4CC84940B754}",
|
||||
|
||||
variations : [
|
||||
{
|
||||
name: "glavred",
|
||||
guid: "{B631E142-E40B-4B4C-90B9-2D00222A286E}",
|
||||
url: "glavred/index.html",
|
||||
icons: ["glavred/icon.png", "glavred/icon2x.png"],
|
||||
isVisual: true,
|
||||
initDataType: 1,
|
||||
isUpdateOleOnResize: false,
|
||||
buttons: [{text:"Ok",primary:true}]
|
||||
},
|
||||
{
|
||||
name: "bold",
|
||||
guid: "{14E46CC2-5E56-429C-9D55-1032B596D928}",
|
||||
url: "bold/index.html",
|
||||
icons: ["bold/icon.png", "bold/icon2x.png"],
|
||||
isVisual: false,
|
||||
initDataType: 0,
|
||||
isUpdateOleOnResize: false,
|
||||
buttons: []
|
||||
description : "chess",
|
||||
url : "chess/index.html",
|
||||
|
||||
icons : ["chess/icon.png", "chess/icon@2x.png"],
|
||||
isViewer : true,
|
||||
EditorsSupport : ["word", "cell", "slide"],
|
||||
|
||||
isVisual : true,
|
||||
isModal : true,
|
||||
isInsideMode : false,
|
||||
|
||||
initDataType : "ole",
|
||||
initData : "",
|
||||
|
||||
isUpdateOleOnResize : true,
|
||||
|
||||
buttons : [ { text: "Ok", primary: true },
|
||||
{ text: "Cancel", primary: false } ]
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
name : "glavred",
|
||||
guid : "{B631E142-E40B-4B4C-90B9-2D00222A286E}",
|
||||
|
||||
variations : [
|
||||
{
|
||||
description : "glavred",
|
||||
url : "glavred/index.html",
|
||||
|
||||
icons : ["glavred/icon.png", "glavred/icon@2x.png"],
|
||||
isViewer : true,
|
||||
EditorsSupport : ["word", "cell", "slide"],
|
||||
|
||||
isVisual : true,
|
||||
isModal : true,
|
||||
isInsideMode : false,
|
||||
|
||||
initDataType : "text",
|
||||
initData : "",
|
||||
|
||||
isUpdateOleOnResize : false,
|
||||
|
||||
buttons : [ { text: "Ok", primary: true } ]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
events: {
|
||||
'onReady': <document ready callback>,
|
||||
'onBack': <back to folder callback>,
|
||||
|
|
|
@ -68,24 +68,6 @@ define([
|
|||
setApi: function(api) {
|
||||
this.api = api;
|
||||
|
||||
var me = this;
|
||||
var storePlugins = this.getApplication().getCollection('Common.Collections.Plugins'),
|
||||
arr = [];
|
||||
storePlugins.each(function(item){
|
||||
var plugin = new Asc.CPlugin();
|
||||
plugin.set_Name(item.get('name'));
|
||||
plugin.set_Guid(item.get('guid'));
|
||||
plugin.set_Url(item.get('url'));
|
||||
plugin.set_Icons(item.get('icons'));
|
||||
plugin.set_Visual(item.get('isVisual'));
|
||||
plugin.set_InitDataType(item.get('initDataType'));
|
||||
plugin.set_UpdateOleOnResize(item.get('isUpdateOleOnResize'));
|
||||
plugin.set_Buttons(item.get('buttons'));
|
||||
item.set('pluginObj', plugin);
|
||||
arr.push(plugin);
|
||||
});
|
||||
this.api.asc_pluginsRegister(this.panelPlugins.pluginsPath, arr);
|
||||
|
||||
this.api.asc_registerCallback("asc_onPluginShow", _.bind(this.onPluginShow, this));
|
||||
this.api.asc_registerCallback("asc_onPluginClose", _.bind(this.onPluginClose, this));
|
||||
|
||||
|
@ -93,21 +75,59 @@ define([
|
|||
},
|
||||
|
||||
setMode: function(mode) {
|
||||
if (mode.canPlugins) {
|
||||
this.panelPlugins.pluginsPath = mode.pluginsPath;
|
||||
this.updatePluginsList();
|
||||
}
|
||||
},
|
||||
|
||||
onAfterRender: function(historyView) {
|
||||
historyView.viewPluginsList.on('item:click', _.bind(this.onSelectPlugin, this));
|
||||
},
|
||||
|
||||
updatePluginsList: function() {
|
||||
var me = this;
|
||||
var storePlugins = this.getApplication().getCollection('Common.Collections.Plugins'),
|
||||
arr = [];
|
||||
storePlugins.each(function(item){
|
||||
var plugin = new Asc.CPlugin();
|
||||
plugin.set_Name(item.get('name'));
|
||||
plugin.set_Guid(item.get('guid'));
|
||||
var variations = item.get('variations'),
|
||||
variationsArr = [];
|
||||
variations.forEach(function(itemVar){
|
||||
var variation = new Asc.CPluginVariation();
|
||||
variation.set_Description(itemVar.get('description'));
|
||||
variation.set_Url(itemVar.get('url'));
|
||||
variation.set_Icons(itemVar.get('icons'));
|
||||
variation.set_Visual(itemVar.get('isVisual'));
|
||||
variation.set_Viewer(itemVar.get('isViewer'));
|
||||
variation.set_EditorsSupport(itemVar.get('EditorsSupport'));
|
||||
variation.set_Modal(itemVar.get('isModal'));
|
||||
variation.set_InsideMode(itemVar.get('isInsideMode'));
|
||||
variation.set_InitDataType(itemVar.get('initDataType'));
|
||||
variation.set_InitData(itemVar.get('initData'));
|
||||
variation.set_UpdateOleOnResize(itemVar.get('isUpdateOleOnResize'));
|
||||
variation.set_Buttons(itemVar.get('buttons'));
|
||||
variationsArr.push(variation);
|
||||
});
|
||||
plugin.set_Variations(variationsArr);
|
||||
item.set('pluginObj', plugin);
|
||||
arr.push(plugin);
|
||||
});
|
||||
this.api.asc_pluginsRegister(this.panelPlugins.pluginsPath, arr);
|
||||
},
|
||||
|
||||
onSelectPlugin: function(picker, item, record){
|
||||
this.api.asc_pluginRun(record.get('guid'), '');
|
||||
this.api.asc_pluginRun(record.get('guid'), record.get('currentVariation'), '');
|
||||
},
|
||||
|
||||
onPluginShow: function(plugin) {
|
||||
if (!plugin.get_Visual()) return;
|
||||
var variation = plugin.get_Variations()[0];
|
||||
if (!variation.get_Visual()) return;
|
||||
|
||||
var me = this,
|
||||
arrBtns = plugin.get_Buttons(),
|
||||
arrBtns = variation.get_Buttons(),
|
||||
newBtns = {};
|
||||
|
||||
if (_.isArray(arrBtns)) {
|
||||
|
@ -118,7 +138,7 @@ define([
|
|||
|
||||
me.pluginDlg = new Common.Views.PluginDlg({
|
||||
title: plugin.get_Name(),
|
||||
url: me.panelPlugins.pluginsPath + plugin.get_Url(),
|
||||
url: me.panelPlugins.pluginsPath + variation.get_Url(),
|
||||
buttons: newBtns,
|
||||
toolcallback: _.bind(this.onToolClose, this)
|
||||
});
|
||||
|
@ -130,7 +150,7 @@ define([
|
|||
me.pluginDlg.show();
|
||||
},
|
||||
|
||||
onPluginClose: function(plugin) {
|
||||
onPluginClose: function() {
|
||||
if (this.pluginDlg)
|
||||
this.pluginDlg.close();
|
||||
},
|
||||
|
|
|
@ -48,18 +48,34 @@ define([
|
|||
], function(_, Backbone){
|
||||
'use strict';
|
||||
|
||||
Common.Models.PluginVariation = Backbone.Model.extend({
|
||||
defaults: function() {
|
||||
return {
|
||||
description: "",
|
||||
url: "",
|
||||
index: 0,
|
||||
icons: undefined,
|
||||
isViewer: false,
|
||||
EditorsSupport: ["word", "cell", "slide"],
|
||||
isVisual: false,
|
||||
isModal: false,
|
||||
isInsideMode: false,
|
||||
initDataType: 0,
|
||||
initData: "",
|
||||
isUpdateOleOnResize: false,
|
||||
buttons: []
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Common.Models.Plugin = Backbone.Model.extend({
|
||||
defaults: function() {
|
||||
return {
|
||||
id: Common.UI.getId(),
|
||||
name : '',
|
||||
guid: Common.UI.getId(),
|
||||
url : undefined,
|
||||
icons : undefined,
|
||||
isVisual: false,
|
||||
initDataType: undefined,
|
||||
isUpdateOleOnResize : false,
|
||||
buttons: [{text:"Ok",primary:true},{text:"Cancel",primary:false}],
|
||||
variations: [],
|
||||
currentVariation: 0,
|
||||
pluginObj: undefined,
|
||||
allowSelected: false,
|
||||
selected: false
|
||||
|
|
|
@ -75,7 +75,7 @@ define([
|
|||
el: $('#plugins-list'),
|
||||
store: this.storePlugins,
|
||||
enableKeyEvents: false,
|
||||
itemTemplate: _.template('<div id="<%= id %>" class="item-plugins" style="background-image: url(' + this.pluginsPath + '<%= icons[(window.devicePixelRatio > 1) ? 1 : 0] %>); background-position: 0 0;"></div>')
|
||||
itemTemplate: _.template('<div id="<%= id %>" class="item-plugins" style="background-image: url(' + this.pluginsPath + '<%= variations[currentVariation].get("icons")[(window.devicePixelRatio > 1) ? 1 : 0] %>); background-position: 0 0;"></div>')
|
||||
});
|
||||
|
||||
this.trigger('render:after', this);
|
||||
|
|
|
@ -174,14 +174,18 @@ define([
|
|||
if (this.mode.canUseHistory)
|
||||
this.leftMenu.setOptionsPanel('history', this.getApplication().getController('Common.Controllers.History').getView('Common.Views.History'));
|
||||
|
||||
this.enablePlugins();
|
||||
|
||||
Common.util.Shortcuts.resumeEvents();
|
||||
return this;
|
||||
},
|
||||
|
||||
enablePlugins: function() {
|
||||
if (this.mode.canPlugins) {
|
||||
this.leftMenu.btnPlugins.show();
|
||||
this.leftMenu.setOptionsPanel('plugins', this.getApplication().getController('Common.Controllers.Plugins').getView('Common.Views.Plugins'));
|
||||
} else
|
||||
this.leftMenu.btnPlugins.hide();
|
||||
|
||||
Common.util.Shortcuts.resumeEvents();
|
||||
return this;
|
||||
},
|
||||
|
||||
clickMenuFileItem: function(menu, action, isopts) {
|
||||
|
|
|
@ -138,7 +138,7 @@ define([
|
|||
// Initialize api gateway
|
||||
this.editorConfig = {};
|
||||
this.appOptions = {};
|
||||
this.plugins = [];
|
||||
this.plugins = undefined;
|
||||
Common.Gateway.on('init', _.bind(this.loadConfig, this));
|
||||
Common.Gateway.on('showmessage', _.bind(this.onExternalMessage, this));
|
||||
Common.Gateway.on('opendocument', _.bind(this.loadDocument, this));
|
||||
|
@ -243,6 +243,8 @@ define([
|
|||
this.appOptions.canBackToFolder = (this.editorConfig.canBackToFolder!==false) && (typeof (this.editorConfig.customization) == 'object')
|
||||
&& (typeof (this.editorConfig.customization.goback) == 'object') && !_.isEmpty(this.editorConfig.customization.goback.url);
|
||||
this.appOptions.canBack = this.editorConfig.nativeApp !== true && this.appOptions.canBackToFolder === true;
|
||||
this.appOptions.canPlugins = false;
|
||||
this.plugins = this.editorConfig.plugins;
|
||||
|
||||
this.getApplication()
|
||||
.getController('Viewport')
|
||||
|
@ -254,9 +256,6 @@ define([
|
|||
|
||||
if (this.appOptions.location == 'us' || this.appOptions.location == 'ca')
|
||||
Common.Utils.Metric.setDefaultMetric(Common.Utils.Metric.c_MetricUnits.inch);
|
||||
|
||||
this.plugins = this.editorConfig.plugins;
|
||||
this.appOptions.canPlugins = (this.plugins && this.plugins.length>0);
|
||||
},
|
||||
|
||||
loadDocument: function(data) {
|
||||
|
@ -831,6 +830,8 @@ define([
|
|||
application.getController('Common.Controllers.ExternalMergeEditor').setApi(this.api).loadConfig({config:this.editorConfig, customization: this.editorConfig.customization});
|
||||
|
||||
pluginsController.setApi(this.api);
|
||||
this.updatePluginsList(this.plugins);
|
||||
this.api.asc_registerCallback('asc_onPluginsInit', _.bind(this.updatePluginsList, this));
|
||||
|
||||
documentHolderController.setApi(me.api);
|
||||
documentHolderController.createDelayedElements();
|
||||
|
@ -1010,9 +1011,6 @@ define([
|
|||
var translateArt = new Asc.asc_TextArtTranslate();
|
||||
translateArt.asc_setDefaultText(this.txtArt);
|
||||
this.api.asc_setTextArtTranslate(translateArt);
|
||||
|
||||
if (this.appOptions.canPlugins)
|
||||
this.updatePluginsList();
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -1696,25 +1694,50 @@ define([
|
|||
if (url) this.iframePrint.src = url;
|
||||
},
|
||||
|
||||
updatePluginsList: function() {
|
||||
updatePluginsList: function(plugins) {
|
||||
var pluginStore = this.getApplication().getCollection('Common.Collections.Plugins');
|
||||
if (pluginStore && this.plugins) {
|
||||
if (pluginStore && plugins) {
|
||||
var arr = [];
|
||||
this.plugins.forEach(function(item){
|
||||
plugins.pluginsData.forEach(function(item){
|
||||
var variations = item.variations,
|
||||
variationsArr = [];
|
||||
variations.forEach(function(itemVar){
|
||||
variationsArr.push(new Common.Models.PluginVariation({
|
||||
description: itemVar.description,
|
||||
index: itemVar.index,
|
||||
url : itemVar.url,
|
||||
icons : itemVar.icons,
|
||||
isViewer: itemVar.isViewer,
|
||||
EditorsSupport: itemVar.EditorsSupport,
|
||||
isVisual: itemVar.isVisual,
|
||||
isModal: itemVar.isModal,
|
||||
isInsideMode: itemVar.isInsideMode,
|
||||
initDataType: itemVar.initDataType,
|
||||
initData: itemVar.initData,
|
||||
isUpdateOleOnResize : itemVar.isUpdateOleOnResize,
|
||||
buttons: itemVar.buttons
|
||||
}));
|
||||
});
|
||||
|
||||
arr.push(new Common.Models.Plugin({
|
||||
name : item.name,
|
||||
guid: item.guid,
|
||||
url : item.url,
|
||||
icons : item.icons,
|
||||
isVisual: item.isVisual,
|
||||
initDataType: item.initDataType,
|
||||
isUpdateOleOnResize : item.isUpdateOleOnResize,
|
||||
buttons: item.buttons
|
||||
variations: variationsArr,
|
||||
currentVariation: 0
|
||||
}));
|
||||
});
|
||||
|
||||
pluginStore.reset(arr);
|
||||
|
||||
this.appOptions.pluginsPath = (plugins.url);
|
||||
this.appOptions.canPlugins = (arr.length>0);
|
||||
} else {
|
||||
this.appOptions.pluginsPath = '';
|
||||
this.appOptions.canPlugins = false;
|
||||
}
|
||||
if (this.appOptions.canPlugins)
|
||||
this.getApplication().getController('Common.Controllers.Plugins').setMode(this.appOptions);
|
||||
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.',
|
||||
|
|
|
@ -245,7 +245,7 @@ define([
|
|||
if (name == 'history') {
|
||||
this.panelHistory = panel.render('#left-panel-history');
|
||||
} else
|
||||
if (name == 'plugins') {
|
||||
if (name == 'plugins' && !this.panelPlugins) {
|
||||
this.panelPlugins = panel.render('#left-panel-plugins');
|
||||
}
|
||||
},
|
||||
|
|
Loading…
Reference in a new issue