From 42932dc55b4fa6e2ee8b111bc196aa9372530a55 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Tue, 17 May 2016 18:38:54 +0300 Subject: [PATCH] =?UTF-8?q?[DE]=20=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=B0=20=D0=BF=D0=BE=D0=B4=D0=B4=D0=B5=D1=80=D0=B6?= =?UTF-8?q?=D0=BA=D0=B0=20=D0=BF=D0=BB=D0=B0=D0=B3=D0=B8=D0=BD=D0=BE=D0=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/api/documents/api.js | 33 +++++- apps/api/documents/index.html | 33 +++++- apps/common/main/lib/collection/Plugins.js | 54 +++++++++ apps/common/main/lib/controller/Plugins.js | 105 ++++++++++++++++++ apps/common/main/lib/model/Plugin.js | 69 ++++++++++++ apps/common/main/lib/view/Plugins.js | 88 +++++++++++++++ apps/common/main/resources/less/plugins.less | 19 ++++ apps/documenteditor/main/app.js | 2 + .../main/app/controller/LeftMenu.js | 5 + .../main/app/controller/Main.js | 32 +++++- .../main/app/template/LeftMenu.template | 2 + apps/documenteditor/main/app/view/LeftMenu.js | 28 ++++- apps/documenteditor/main/app_dev.js | 2 + .../main/resources/img/toolbar-menu.png | Bin 16939 -> 17471 bytes .../main/resources/img/toolbar-menu@2x.png | Bin 42729 -> 43888 bytes .../main/resources/less/app.less | 1 + .../main/resources/less/leftmenu.less | 1 + apps/documenteditor/sdk_dev_scripts.js | 5 +- 18 files changed, 474 insertions(+), 5 deletions(-) create mode 100644 apps/common/main/lib/collection/Plugins.js create mode 100644 apps/common/main/lib/controller/Plugins.js create mode 100644 apps/common/main/lib/model/Plugin.js create mode 100644 apps/common/main/lib/view/Plugins.js create mode 100644 apps/common/main/resources/less/plugins.less diff --git a/apps/api/documents/api.js b/apps/api/documents/api.js index cd018fa5b..b7c8988a0 100644 --- a/apps/api/documents/api.js +++ b/apps/api/documents/api.js @@ -106,7 +106,38 @@ }, 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}] + }, + { + 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: [] + } + ] }, events: { 'onReady': , diff --git a/apps/api/documents/index.html b/apps/api/documents/index.html index a3fb92ed1..86cd97bec 100644 --- a/apps/api/documents/index.html +++ b/apps/api/documents/index.html @@ -291,7 +291,38 @@ // goback: {text: 'Go To London', url: 'http://...'}, about: true, feedback: true - } + }, + 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}] + }, + { + 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: [] + } + ] }; } diff --git a/apps/common/main/lib/collection/Plugins.js b/apps/common/main/lib/collection/Plugins.js new file mode 100644 index 000000000..97deb6f42 --- /dev/null +++ b/apps/common/main/lib/collection/Plugins.js @@ -0,0 +1,54 @@ +/* + * + * (c) Copyright Ascensio System Limited 2010-2016 + * + * This program is a free software product. You can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License (AGPL) + * version 3 as published by the Free Software Foundation. In accordance with + * Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect + * that Ascensio System SIA expressly excludes the warranty of non-infringement + * of any third-party rights. + * + * This program is distributed WITHOUT ANY WARRANTY; without even the implied + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For + * details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html + * + * You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia, + * EU, LV-1021. + * + * The interactive user interfaces in modified source and object code versions + * of the Program must display Appropriate Legal Notices, as required under + * Section 5 of the GNU AGPL version 3. + * + * Pursuant to Section 7(b) of the License you must retain the original Product + * logo when distributing the program. Pursuant to Section 7(e) we decline to + * grant you any rights under trademark law for use of our trademarks. + * + * All the Product's GUI elements, including illustrations and icon sets, as + * well as technical writing content are licensed under the terms of the + * Creative Commons Attribution-ShareAlike 4.0 International. See the License + * terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode + * +*/ +/** + * User: Julia.Radzhabova + * Date: 17.05.16 + * Time: 15:54 + */ + +if (Common === undefined) + var Common = {}; + +Common.Collections = Common.Collections || {}; + +define([ + 'underscore', + 'backbone', + 'common/main/lib/model/Plugin' +], function(_, Backbone){ + 'use strict'; + + Common.Collections.Plugins = Backbone.Collection.extend({ + model: Common.Models.Plugin + }); +}); diff --git a/apps/common/main/lib/controller/Plugins.js b/apps/common/main/lib/controller/Plugins.js new file mode 100644 index 000000000..4b1173c90 --- /dev/null +++ b/apps/common/main/lib/controller/Plugins.js @@ -0,0 +1,105 @@ +/* + * + * (c) Copyright Ascensio System Limited 2010-2016 + * + * This program is a free software product. You can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License (AGPL) + * version 3 as published by the Free Software Foundation. In accordance with + * Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect + * that Ascensio System SIA expressly excludes the warranty of non-infringement + * of any third-party rights. + * + * This program is distributed WITHOUT ANY WARRANTY; without even the implied + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For + * details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html + * + * You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia, + * EU, LV-1021. + * + * The interactive user interfaces in modified source and object code versions + * of the Program must display Appropriate Legal Notices, as required under + * Section 5 of the GNU AGPL version 3. + * + * Pursuant to Section 7(b) of the License you must retain the original Product + * logo when distributing the program. Pursuant to Section 7(e) we decline to + * grant you any rights under trademark law for use of our trademarks. + * + * All the Product's GUI elements, including illustrations and icon sets, as + * well as technical writing content are licensed under the terms of the + * Creative Commons Attribution-ShareAlike 4.0 International. See the License + * terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode + * +*/ +/** + * User: Julia.Radzhabova + * Date: 17.05.16 + * Time: 15:38 + */ + +define([ + 'core', + 'common/main/lib/collection/Plugins', + 'common/main/lib/view/Plugins' +], function () { + 'use strict'; + + Common.Controllers.Plugins = Backbone.Controller.extend(_.extend({ + models: [], + collections: [ + 'Common.Collections.Plugins' + ], + views: [ + 'Common.Views.Plugins' + ], + + initialize: function() { + }, + + events: { + }, + + onLaunch: function() { + this.panelPlugins= this.createView('Common.Views.Plugins', { + storePlugins: this.getApplication().getCollection('Common.Collections.Plugins') + }); + this.panelPlugins.on('render:after', _.bind(this.onAfterRender, this)); + }, + + 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); + return this; + }, + + setMode: function(mode) { + }, + + onAfterRender: function(historyView) { + historyView.viewPluginsList.on('item:click', _.bind(this.onSelectPlugin, this)); + }, + + onSelectPlugin: function(picker, item, record){ + this.api.asc_pluginRun(record.get('guid'), ''); + }, + + notcriticalErrorTitle: 'Warning' + + }, Common.Controllers.Plugins || {})); +}); diff --git a/apps/common/main/lib/model/Plugin.js b/apps/common/main/lib/model/Plugin.js new file mode 100644 index 000000000..eba49aa57 --- /dev/null +++ b/apps/common/main/lib/model/Plugin.js @@ -0,0 +1,69 @@ +/* + * + * (c) Copyright Ascensio System Limited 2010-2016 + * + * This program is a free software product. You can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License (AGPL) + * version 3 as published by the Free Software Foundation. In accordance with + * Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect + * that Ascensio System SIA expressly excludes the warranty of non-infringement + * of any third-party rights. + * + * This program is distributed WITHOUT ANY WARRANTY; without even the implied + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For + * details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html + * + * You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia, + * EU, LV-1021. + * + * The interactive user interfaces in modified source and object code versions + * of the Program must display Appropriate Legal Notices, as required under + * Section 5 of the GNU AGPL version 3. + * + * Pursuant to Section 7(b) of the License you must retain the original Product + * logo when distributing the program. Pursuant to Section 7(e) we decline to + * grant you any rights under trademark law for use of our trademarks. + * + * All the Product's GUI elements, including illustrations and icon sets, as + * well as technical writing content are licensed under the terms of the + * Creative Commons Attribution-ShareAlike 4.0 International. See the License + * terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode + * +*/ +/** + * User: Julia.Radzhabova + * Date: 17.05.16 + * Time: 15:56 + */ + +if (Common === undefined) + var Common = {}; + +Common.Models = Common.Models || {}; + +define([ + 'underscore', + 'backbone', + 'common/main/lib/component/BaseView' +], function(_, Backbone){ + 'use strict'; + + 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}], + pluginObj: undefined, + allowSelected: false, + selected: false + } + } + }); +}); diff --git a/apps/common/main/lib/view/Plugins.js b/apps/common/main/lib/view/Plugins.js new file mode 100644 index 000000000..0a978d41f --- /dev/null +++ b/apps/common/main/lib/view/Plugins.js @@ -0,0 +1,88 @@ +/* + * + * (c) Copyright Ascensio System Limited 2010-2016 + * + * This program is a free software product. You can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License (AGPL) + * version 3 as published by the Free Software Foundation. In accordance with + * Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect + * that Ascensio System SIA expressly excludes the warranty of non-infringement + * of any third-party rights. + * + * This program is distributed WITHOUT ANY WARRANTY; without even the implied + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For + * details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html + * + * You can contact Ascensio System SIA at Lubanas st. 125a-25, Riga, Latvia, + * EU, LV-1021. + * + * The interactive user interfaces in modified source and object code versions + * of the Program must display Appropriate Legal Notices, as required under + * Section 5 of the GNU AGPL version 3. + * + * Pursuant to Section 7(b) of the License you must retain the original Product + * logo when distributing the program. Pursuant to Section 7(e) we decline to + * grant you any rights under trademark law for use of our trademarks. + * + * All the Product's GUI elements, including illustrations and icon sets, as + * well as technical writing content are licensed under the terms of the + * Creative Commons Attribution-ShareAlike 4.0 International. See the License + * terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode + * +*/ +/** + * User: Julia.Radzhabova + * Date: 17.05.16 + * Time: 15:38 + */ + +if (Common === undefined) + var Common = {}; + +Common.Views = Common.Views || {}; + +define([ + 'common/main/lib/util/utils', + 'common/main/lib/component/BaseView', + 'common/main/lib/component/Layout' +], function (template) { + 'use strict'; + + Common.Views.Plugins = Common.UI.BaseView.extend(_.extend({ + el: '#left-panel-plugins', + + storePlugins: undefined, + template: _.template([ + '
', + '', + '
', + '
', + '
' + ].join('')), + + initialize: function(options) { + _.extend(this, options); + this.pluginsPath = '../../../../sdkjs-plugins/'; + Common.UI.BaseView.prototype.initialize.call(this, arguments); + }, + + render: function(el) { + el = el || this.el; + $(el).html(this.template({scope: this})).width( (parseInt(Common.localStorage.getItem('de-mainmenu-width')) || MENU_SCALE_PART) - SCALE_MIN); + + this.viewPluginsList = new Common.UI.DataView({ + el: $('#plugins-list'), + store: this.storePlugins, + enableKeyEvents: false, + itemTemplate: _.template('
') +// itemTemplate: _.template('
') + }); + + this.trigger('render:after', this); + return this; + }, + + strPlugins: 'Plugins' + + }, Common.Views.Plugins || {})) +}); \ No newline at end of file diff --git a/apps/common/main/resources/less/plugins.less b/apps/common/main/resources/less/plugins.less new file mode 100644 index 000000000..6a55d9e1b --- /dev/null +++ b/apps/common/main/resources/less/plugins.less @@ -0,0 +1,19 @@ +#plugins-box { + display: table; + position: relative; + width: 100%; + height: 100%; + margin: 10px; + + #plugins-list { + height: 100%; + overflow: hidden; + padding-top: 10px; + + .item-plugins { + width: 40px; + height: 40px; + } + } +} + diff --git a/apps/documenteditor/main/app.js b/apps/documenteditor/main/app.js index 1dd8bdf6a..40df85e8a 100644 --- a/apps/documenteditor/main/app.js +++ b/apps/documenteditor/main/app.js @@ -161,6 +161,7 @@ require([ ,'Common.Controllers.Chat' ,'Common.Controllers.Comments' /** coauthoring end **/ + ,'Common.Controllers.Plugins' ,'Common.Controllers.ExternalDiagramEditor' ,'Common.Controllers.ExternalMergeEditor' ,'Common.Controllers.ReviewChanges' @@ -191,6 +192,7 @@ require([ ,'common/main/lib/controller/Comments' ,'common/main/lib/controller/Chat' /** coauthoring end **/ + ,'common/main/lib/controller/Plugins' ,'documenteditor/main/app/view/ChartSettings' ,'common/main/lib/controller/ExternalDiagramEditor' ,'common/main/lib/controller/ExternalMergeEditor' diff --git a/apps/documenteditor/main/app/controller/LeftMenu.js b/apps/documenteditor/main/app/controller/LeftMenu.js index 5d47539e6..674db783f 100644 --- a/apps/documenteditor/main/app/controller/LeftMenu.js +++ b/apps/documenteditor/main/app/controller/LeftMenu.js @@ -174,6 +174,11 @@ define([ if (this.mode.canUseHistory) this.leftMenu.setOptionsPanel('history', this.getApplication().getController('Common.Controllers.History').getView('Common.Views.History')); + if (this.mode.canPlugins) + 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; }, diff --git a/apps/documenteditor/main/app/controller/Main.js b/apps/documenteditor/main/app/controller/Main.js index 796d60a2c..cf2696386 100644 --- a/apps/documenteditor/main/app/controller/Main.js +++ b/apps/documenteditor/main/app/controller/Main.js @@ -138,6 +138,7 @@ define([ // Initialize api gateway this.editorConfig = {}; this.appOptions = {}; + this.plugins = []; Common.Gateway.on('init', _.bind(this.loadConfig, this)); Common.Gateway.on('showmessage', _.bind(this.onExternalMessage, this)); Common.Gateway.on('opendocument', _.bind(this.loadDocument, this)); @@ -253,6 +254,9 @@ 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) { @@ -816,7 +820,8 @@ define([ fontsController = application.getController('Common.Controllers.Fonts'), rightmenuController = application.getController('RightMenu'), leftmenuController = application.getController('LeftMenu'), - chatController = application.getController('Common.Controllers.Chat'); + chatController = application.getController('Common.Controllers.Chat'), + pluginsController = application.getController('Common.Controllers.Plugins'); leftmenuController.getView('LeftMenu').getMenu('file').loadDocument({doc:me.document}); leftmenuController.setMode(me.appOptions).createDelayedElements().setApi(me.api); @@ -825,6 +830,8 @@ define([ application.getController('Common.Controllers.ExternalDiagramEditor').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(this.api); + documentHolderController.setApi(me.api); documentHolderController.createDelayedElements(); statusbarController.createDelayedElements(); @@ -1081,6 +1088,8 @@ define([ // Message on window close window.onbeforeunload = _.bind(me.onBeforeUnload, me); window.onunload = _.bind(me.onUnload, me); + + me.updatePluginsList(); } }, @@ -1686,6 +1695,27 @@ define([ if (url) this.iframePrint.src = url; }, + updatePluginsList: function() { + var pluginStore = this.getApplication().getCollection('Common.Collections.Plugins'); + if (pluginStore && this.plugins) { + var arr = []; + this.plugins.forEach(function(item){ + 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 + })); + }); + + pluginStore.reset(arr); + } + }, + 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.', defaultTitleText: 'ONLYOFFICE Document Editor', criticalErrorTitle: 'Error', diff --git a/apps/documenteditor/main/app/template/LeftMenu.template b/apps/documenteditor/main/app/template/LeftMenu.template index 039703e46..a06f2850a 100644 --- a/apps/documenteditor/main/app/template/LeftMenu.template +++ b/apps/documenteditor/main/app/template/LeftMenu.template @@ -8,11 +8,13 @@ +