Commit 42932dc5 authored by Julia Radzhabova's avatar Julia Radzhabova

[DE] Добавлена поддержка плагинов

parent 4ee5489e
......@@ -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': <document ready callback>,
......
......@@ -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: []
}
]
};
}
......
/*
*
* (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
});
});
/*
*
* (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 || {}));
});
/*
*
* (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
}
}
});
});
/*
*
* (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([
'<div id="plugins-box" class="layout-ct vbox">',
'<label style="font-weight: bold;"><%= scope.strPlugins %></label>',
'<div id="plugins-list" class="">',
'</div>',
'</div>'
].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('<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 + 'chess/icon.png' + '); background-position: 0 0;"></div>')
});
this.trigger('render:after', this);
return this;
},
strPlugins: 'Plugins'
}, Common.Views.Plugins || {}))
});
\ No newline at end of file
#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;
}
}
}
......@@ -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'
......
......@@ -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;
},
......
......@@ -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',
......
......@@ -8,11 +8,13 @@
<!-- /** coauthoring end **/ -->
<button id="left-btn-support" class="btn btn-category" content-target=""><span class="btn-icon img-toolbarmenu btn-menu-support">&nbsp;</span></button>
<button id="left-btn-about" class="btn btn-category" content-target=""><span class="btn-icon img-toolbarmenu btn-menu-about">&nbsp;</span></button>
<button id="left-btn-plugins" class="btn btn-category" content-target="" style="position: absolute; bottom: 0;"><span class="btn-icon img-toolbarmenu btn-menu-plugin">&nbsp;</span></button>
</div>
<div class="left-panel" style="">
<!-- /** coauthoring begin **/ -->
<div id="left-panel-comments" class="" style="display: none;" />
<div id="left-panel-chat" class="" style="display: none;" />
<!-- /** coauthoring end **/ -->
<div id="left-panel-plugins" class="" style="display: none;" />
</div>
</div>
\ No newline at end of file
......@@ -50,6 +50,7 @@ define([
'common/main/lib/view/Chat',
/** coauthoring end **/
'common/main/lib/view/History',
'common/main/lib/view/Plugins',
'common/main/lib/view/About',
'common/main/lib/view/SearchDialog',
'documenteditor/main/app/view/FileMenu'
......@@ -71,6 +72,7 @@ define([
'click #left-btn-comments': _.bind(this.onCoauthOptions, this),
'click #left-btn-chat': _.bind(this.onCoauthOptions, this),
/** coauthoring end **/
'click #left-btn-plugins': _.bind(this.onCoauthOptions, this),
'click #left-btn-support': function() {
var config = this.mode.customization;
config && !!config.feedback && !!config.feedback.url ?
......@@ -139,11 +141,20 @@ define([
toggleGroup: 'leftMenuGroup'
});
this.btnPlugins = new Common.UI.Button({
el: $('#left-btn-plugins'),
hint: this.tipPlugins,
enableToggle: true,
disabled: true,
toggleGroup: 'leftMenuGroup'
});
this.btnComments.hide();
this.btnChat.hide();
this.btnComments.on('click', _.bind(this.onBtnMenuClick, this));
this.btnChat.on('click', _.bind(this.onBtnMenuClick, this));
this.btnPlugins.on('click', _.bind(this.onBtnMenuClick, this));
/** coauthoring end **/
this.btnSearch.on('click', _.bind(this.onBtnMenuClick, this));
......@@ -215,6 +226,12 @@ define([
}
}
/** coauthoring end **/
if (this.mode.canPlugins) {
if (this.btnPlugins.pressed) {
this.panelPlugins.show();
} else
this.panelPlugins['hide']();
}
},
setOptionsPanel: function(name, panel) {
......@@ -226,6 +243,9 @@ define([
} else /** coauthoring end **/
if (name == 'history') {
this.panelHistory = panel.render('#left-panel-history');
} else
if (name == 'plugins') {
this.panelPlugins = panel.render('#left-panel-plugins');
}
},
......@@ -258,6 +278,10 @@ define([
this.panelChat['hide']();
this.btnChat.toggle(false, true);
}
if (this.mode.canPlugins) {
this.panelPlugins['hide']();
this.btnPlugins.toggle(false, true);
}
}
/** coauthoring end **/
},
......@@ -279,6 +303,7 @@ define([
this.btnComments.setDisabled(false);
this.btnChat.setDisabled(false);
/** coauthoring end **/
this.btnPlugins.setDisabled(false);
},
showMenu: function(menu, opts) {
......@@ -338,6 +363,7 @@ define([
tipAbout : 'About',
tipSupport : 'Feedback & Support',
tipFile : 'File',
tipSearch : 'Search'
tipSearch : 'Search',
tipPlugins : 'Plugins'
}, DE.Views.LeftMenu || {}));
});
......@@ -151,6 +151,7 @@ require([
,'Common.Controllers.Chat'
,'Common.Controllers.Comments'
/** coauthoring end **/
,'Common.Controllers.Plugins'
,'Common.Controllers.ExternalDiagramEditor'
,'Common.Controllers.ExternalMergeEditor'
,'Common.Controllers.ReviewChanges'
......@@ -181,6 +182,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'
......
......@@ -113,6 +113,7 @@
@import "../../../../common/main/resources/less/history.less";
@import "../../../../common/main/resources/less/opendialog.less";
@import "../../../../common/main/resources/less/review-changes.less";
@import "../../../../common/main/resources/less/plugins.less";
// App
// --------------------------------------------------
......
......@@ -20,6 +20,7 @@ button.notify .btn-menu-comments {background-position: -0*@toolbar-icon-size -60
.button-normal-icon(btn-menu-chat, 62, @toolbar-icon-size);
.button-normal-icon(btn-menu-about, 68, @toolbar-icon-size);
.button-normal-icon(btn-menu-support, 70, @toolbar-icon-size);
.button-normal-icon(btn-menu-plugin, 84, @toolbar-icon-size);
.tool-menu-btns {
width: 40px;
......
......@@ -141,5 +141,8 @@ var sdk_dev_scrpipts = [
"../../../../sdkjs/word/Private/StyleManager.js",
"../../../../sdkjs/word/Private/MailMerge.js",
"../../../../sdkjs/word/Private/TrackRevisions.js",
"../../../../sdkjs/common/applyDocumentChanges.js"
"../../../../sdkjs/common/applyDocumentChanges.js",
"../../../../sdkjs/common/clipboard_base.js",
"../../../../sdkjs/common/plugins.js",
"../../../../sdkjs/word/apiBuilder.js"
];
\ No newline at end of file
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