2016-05-17 15:38:54 +00:00
|
|
|
/*
|
|
|
|
*
|
|
|
|
* (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',
|
2016-05-18 11:41:30 +00:00
|
|
|
'common/main/lib/component/Layout',
|
|
|
|
'common/main/lib/component/Window'
|
2016-05-17 15:38:54 +00:00
|
|
|
], function (template) {
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
Common.Views.Plugins = Common.UI.BaseView.extend(_.extend({
|
2016-06-28 09:27:00 +00:00
|
|
|
el: '#left-panel-plugins',
|
2016-05-17 15:38:54 +00:00
|
|
|
|
|
|
|
storePlugins: undefined,
|
|
|
|
template: _.template([
|
|
|
|
'<div id="plugins-box" class="layout-ct vbox">',
|
2016-05-18 11:41:30 +00:00
|
|
|
'<label id="plugins-header"><%= scope.strPlugins %></label>',
|
2016-05-17 15:38:54 +00:00
|
|
|
'<div id="plugins-list" class="">',
|
|
|
|
'</div>',
|
2016-06-24 08:30:03 +00:00
|
|
|
'</div>',
|
|
|
|
'<div id="current-plugin-box" class="layout-ct vbox hidden">',
|
2016-06-24 11:07:55 +00:00
|
|
|
'<div id="current-plugin-header">',
|
|
|
|
'<label></label>',
|
|
|
|
'<div id="id-plugin-close" class="plugin-close img-commonctrl"></div>',
|
|
|
|
'</div>',
|
2016-06-24 08:30:03 +00:00
|
|
|
'<div id="current-plugin-frame" class="">',
|
|
|
|
'</div>',
|
2016-07-05 14:12:45 +00:00
|
|
|
'</div>',
|
|
|
|
'<div id="plugins-mask" style="display: none;">'
|
2016-05-17 15:38:54 +00:00
|
|
|
].join('')),
|
|
|
|
|
|
|
|
initialize: function(options) {
|
|
|
|
_.extend(this, options);
|
|
|
|
this.pluginsPath = '../../../../sdkjs-plugins/';
|
2016-06-24 08:30:03 +00:00
|
|
|
this._locked = false;
|
|
|
|
this._state = {
|
|
|
|
DisabledControls: true
|
|
|
|
};
|
|
|
|
this.lockedControls = [];
|
2016-05-17 15:38:54 +00:00
|
|
|
Common.UI.BaseView.prototype.initialize.call(this, arguments);
|
|
|
|
},
|
|
|
|
|
|
|
|
render: function(el) {
|
|
|
|
el = el || this.el;
|
2016-05-25 12:52:21 +00:00
|
|
|
$(el).html(this.template({scope: this}));
|
2016-06-24 08:30:03 +00:00
|
|
|
this.$el = $(el);
|
2016-05-17 15:38:54 +00:00
|
|
|
|
|
|
|
this.viewPluginsList = new Common.UI.DataView({
|
|
|
|
el: $('#plugins-list'),
|
|
|
|
store: this.storePlugins,
|
|
|
|
enableKeyEvents: false,
|
2016-06-24 08:30:03 +00:00
|
|
|
itemTemplate: _.template([
|
|
|
|
'<div id="<%= id %>" class="item-plugins" style="display: block;">',
|
|
|
|
'<div class="plugin-icon" style="background-image: url(' + '<% if (baseUrl !=="") { %>' + '<%= baseUrl %>' + '<% } else { %>' + this.pluginsPath + '<% } %>' + '<%= variations[currentVariation].get("icons")[(window.devicePixelRatio > 1) ? 1 : 0] %>);"></div>',
|
|
|
|
'<% if (variations.length>1) { %>',
|
|
|
|
'<div class="plugin-caret img-commonctrl"></div>',
|
|
|
|
'<% } %>',
|
|
|
|
'<%= name %>',
|
|
|
|
'</div>'
|
|
|
|
].join(''))
|
2016-05-17 15:38:54 +00:00
|
|
|
});
|
2016-06-24 08:30:03 +00:00
|
|
|
this.lockedControls.push(this.viewPluginsList);
|
2016-06-28 09:27:00 +00:00
|
|
|
this.viewPluginsList.cmpEl.off('click');
|
2016-05-17 15:38:54 +00:00
|
|
|
|
2016-06-24 11:07:55 +00:00
|
|
|
this.pluginName = $('#current-plugin-header label');
|
|
|
|
this.pluginsPanel = $('#plugins-box');
|
2016-07-05 14:12:45 +00:00
|
|
|
this.pluginsMask = $('#plugins-mask');
|
2016-06-24 11:07:55 +00:00
|
|
|
this.currentPluginPanel = $('#current-plugin-box');
|
2016-07-07 12:23:36 +00:00
|
|
|
this.currentPluginFrame = $('#current-plugin-frame');
|
2016-06-24 11:07:55 +00:00
|
|
|
|
2016-06-28 09:27:00 +00:00
|
|
|
this.pluginMenu = new Common.UI.Menu({
|
|
|
|
menuAlign : 'tr-br',
|
|
|
|
items: []
|
|
|
|
});
|
|
|
|
|
2016-05-17 15:38:54 +00:00
|
|
|
this.trigger('render:after', this);
|
|
|
|
return this;
|
|
|
|
},
|
|
|
|
|
2016-06-24 08:30:03 +00:00
|
|
|
setLocked: function (locked) {
|
|
|
|
this._locked = locked;
|
|
|
|
},
|
|
|
|
|
|
|
|
ChangeSettings: function(props) {
|
|
|
|
this.disableControls(this._locked);
|
|
|
|
},
|
|
|
|
|
|
|
|
disableControls: function(disable) {
|
|
|
|
if (this._state.DisabledControls!==disable) {
|
|
|
|
this._state.DisabledControls = disable;
|
|
|
|
_.each(this.lockedControls, function(item) {
|
|
|
|
item.setDisabled(disable);
|
|
|
|
});
|
2016-07-05 14:12:45 +00:00
|
|
|
|
|
|
|
this.pluginsMask.css('display', disable ? 'block' : 'none');
|
2016-06-24 08:30:03 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2016-06-24 11:07:55 +00:00
|
|
|
openInsideMode: function(name, url) {
|
|
|
|
this.pluginsPanel.toggleClass('hidden', true);
|
|
|
|
this.currentPluginPanel.toggleClass('hidden', false);
|
|
|
|
|
|
|
|
this.pluginName.text(name);
|
|
|
|
if (!this.iframePlugin) {
|
|
|
|
this.iframePlugin = document.createElement("iframe");
|
|
|
|
this.iframePlugin.id = 'plugin_iframe';
|
|
|
|
this.iframePlugin.name = 'pluginFrameEditor',
|
|
|
|
this.iframePlugin.width = '100%';
|
|
|
|
this.iframePlugin.height = '100%';
|
|
|
|
this.iframePlugin.align = "top";
|
|
|
|
this.iframePlugin.frameBorder = 0;
|
|
|
|
this.iframePlugin.scrolling = "no";
|
|
|
|
this.iframePlugin.onload = _.bind(this._onLoad,this);
|
2016-07-07 12:23:36 +00:00
|
|
|
this.currentPluginFrame.append(this.iframePlugin);
|
2016-06-24 11:07:55 +00:00
|
|
|
|
|
|
|
if (!this.loadMask)
|
2016-07-07 12:23:36 +00:00
|
|
|
this.loadMask = new Common.UI.LoadMask({owner: this.currentPluginFrame});
|
2016-06-24 11:07:55 +00:00
|
|
|
this.loadMask.setTitle(this.textLoading);
|
|
|
|
this.loadMask.show();
|
|
|
|
|
|
|
|
this.iframePlugin.src = url;
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
closeInsideMode: function() {
|
|
|
|
if (this.iframePlugin) {
|
2016-07-07 12:23:36 +00:00
|
|
|
this.currentPluginFrame.empty();
|
2016-06-24 11:07:55 +00:00
|
|
|
this.iframePlugin = null;
|
|
|
|
}
|
|
|
|
this.currentPluginPanel.toggleClass('hidden', true);
|
|
|
|
this.pluginsPanel.toggleClass('hidden', false);
|
|
|
|
},
|
|
|
|
|
2016-08-03 09:41:36 +00:00
|
|
|
openNotVisualMode: function(pluginGuid) {
|
|
|
|
var rec = this.viewPluginsList.store.findWhere({guid: pluginGuid});
|
|
|
|
if (rec)
|
|
|
|
this.viewPluginsList.cmpEl.find('#' + rec.get('id')).parent().addClass('selected');
|
|
|
|
},
|
|
|
|
|
|
|
|
closeNotVisualMode: function() {
|
|
|
|
this.viewPluginsList.cmpEl.find('.selected').removeClass('selected');
|
|
|
|
},
|
|
|
|
|
2016-06-24 11:07:55 +00:00
|
|
|
_onLoad: function() {
|
|
|
|
if (this.loadMask)
|
|
|
|
this.loadMask.hide();
|
|
|
|
},
|
|
|
|
|
|
|
|
strPlugins: 'Add-ons',
|
2016-06-29 07:30:59 +00:00
|
|
|
textLoading: 'Loading',
|
|
|
|
textStart: 'Start'
|
2016-05-17 15:38:54 +00:00
|
|
|
|
2016-05-18 10:42:06 +00:00
|
|
|
}, Common.Views.Plugins || {}));
|
|
|
|
|
|
|
|
Common.Views.PluginDlg = Common.UI.Window.extend(_.extend({
|
|
|
|
initialize : function(options) {
|
|
|
|
var _options = {};
|
|
|
|
_.extend(_options, {
|
|
|
|
cls: 'advanced-settings-dlg',
|
|
|
|
header: true
|
|
|
|
}, options);
|
|
|
|
|
|
|
|
var header_footer = (_options.buttons && _.size(_options.buttons)>0) ? 85 : 34;
|
2016-08-02 10:55:45 +00:00
|
|
|
_options.width = (window.innerWidth-_options.width)<0 ? window.innerWidth: _options.width,
|
|
|
|
_options.height += header_footer;
|
|
|
|
_options.height = (window.innerHeight-_options.height)<0 ? window.innerHeight: _options.height;
|
|
|
|
|
2016-05-18 10:42:06 +00:00
|
|
|
this.template = [
|
|
|
|
'<div id="id-plugin-container" class="box" style="height:' + (_options.height-header_footer) + 'px;">',
|
|
|
|
'<div id="id-plugin-placeholder" style="width: 100%;height: 100%;"></div>',
|
|
|
|
'</div>',
|
|
|
|
'<% if (_.size(buttons) > 0) { %>',
|
|
|
|
'<div class="separator horizontal"/>',
|
|
|
|
'<div class="footer" style="text-align: center;">',
|
|
|
|
'<% for(var bt in buttons) { %>',
|
|
|
|
'<button class="btn normal dlg-btn <%= buttons[bt].cls %>" result="<%= bt %>" style="margin-right: 10px;"><%= buttons[bt].text %></button>',
|
|
|
|
'<% } %>',
|
|
|
|
'</div>',
|
|
|
|
'<% } %>'
|
|
|
|
].join('');
|
|
|
|
|
|
|
|
_options.tpl = _.template(this.template, _options);
|
|
|
|
|
|
|
|
this.url = options.url || '';
|
|
|
|
Common.UI.Window.prototype.initialize.call(this, _options);
|
|
|
|
},
|
|
|
|
|
|
|
|
render: function() {
|
|
|
|
Common.UI.Window.prototype.render.call(this);
|
|
|
|
this.$window.find('> .body').css({height: 'auto', overflow: 'hidden'});
|
|
|
|
|
2016-08-04 11:44:23 +00:00
|
|
|
this.boxEl = this.$window.find('.body > .box');
|
|
|
|
this._headerFooterHeight = (this.options.buttons && _.size(this.options.buttons)>0) ? 85 : 34;
|
|
|
|
this._headerFooterHeight += ((parseInt(this.$window.css('border-top-width')) + parseInt(this.$window.css('border-bottom-width'))));
|
|
|
|
|
2016-05-18 10:42:06 +00:00
|
|
|
var iframe = document.createElement("iframe");
|
|
|
|
iframe.id = 'plugin_iframe';
|
2016-05-24 10:35:51 +00:00
|
|
|
iframe.name = 'pluginFrameEditor',
|
2016-05-18 10:42:06 +00:00
|
|
|
iframe.width = '100%';
|
|
|
|
iframe.height = '100%';
|
|
|
|
iframe.align = "top";
|
|
|
|
iframe.frameBorder = 0;
|
|
|
|
iframe.scrolling = "no";
|
|
|
|
iframe.onload = _.bind(this._onLoad,this);
|
|
|
|
|
|
|
|
var me = this;
|
2016-08-02 10:55:45 +00:00
|
|
|
setTimeout(function(){
|
|
|
|
if (me.isLoaded) return;
|
|
|
|
me.loadMask = new Common.UI.LoadMask({owner: $('#id-plugin-placeholder')});
|
|
|
|
me.loadMask.setTitle(this.textLoading);
|
|
|
|
me.loadMask.show();
|
|
|
|
if (me.isLoaded) me.loadMask.hide();
|
|
|
|
}, 500);
|
2016-05-18 10:42:06 +00:00
|
|
|
|
2016-08-02 10:55:45 +00:00
|
|
|
iframe.src = this.url;
|
|
|
|
$('#id-plugin-placeholder').append(iframe);
|
2016-08-04 11:44:23 +00:00
|
|
|
|
|
|
|
this.on('resizing', function(args){
|
|
|
|
me.boxEl.css('height', parseInt(me.$window.css('height')) - me._headerFooterHeight);
|
|
|
|
});
|
2016-05-18 10:42:06 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
_onLoad: function() {
|
2016-08-02 10:55:45 +00:00
|
|
|
this.isLoaded = true;
|
2016-05-18 10:42:06 +00:00
|
|
|
if (this.loadMask)
|
|
|
|
this.loadMask.hide();
|
|
|
|
},
|
|
|
|
|
2016-07-26 12:08:39 +00:00
|
|
|
setInnerSize: function(width, height) {
|
2016-08-02 10:55:45 +00:00
|
|
|
var maxHeight = parseInt(window.innerHeight),
|
|
|
|
maxWidth = parseInt(window.innerWidth),
|
2016-08-02 14:36:33 +00:00
|
|
|
borders_width = (parseInt(this.$window.css('border-left-width')) + parseInt(this.$window.css('border-right-width')));
|
2016-08-04 11:44:23 +00:00
|
|
|
if (maxHeight<height + this._headerFooterHeight)
|
|
|
|
height = maxHeight - this._headerFooterHeight;
|
2016-08-02 14:36:33 +00:00
|
|
|
if (maxWidth<width + borders_width)
|
|
|
|
width = maxWidth - borders_width;
|
2016-08-02 10:55:45 +00:00
|
|
|
|
2016-08-04 11:44:23 +00:00
|
|
|
this.boxEl.css('height', height);
|
2016-07-26 12:08:39 +00:00
|
|
|
|
2016-08-04 11:44:23 +00:00
|
|
|
Common.UI.Window.prototype.setHeight.call(this, height + this._headerFooterHeight);
|
2016-08-02 14:36:33 +00:00
|
|
|
Common.UI.Window.prototype.setWidth.call(this, width + borders_width);
|
2016-08-02 10:55:45 +00:00
|
|
|
|
2016-08-02 14:36:33 +00:00
|
|
|
this.$window.css('left',(maxWidth - width - borders_width) / 2);
|
2016-08-04 11:44:23 +00:00
|
|
|
this.$window.css('top',((maxHeight - height - this._headerFooterHeight) / 2) * 0.9);
|
2016-07-26 12:08:39 +00:00
|
|
|
},
|
|
|
|
|
2016-05-18 10:42:06 +00:00
|
|
|
textLoading : 'Loading'
|
|
|
|
}, Common.Views.PluginDlg || {}));
|
2016-05-17 15:38:54 +00:00
|
|
|
});
|