Merge pull request #1882 from ONLYOFFICE/fix/plugins

Fix/plugins
This commit is contained in:
Julia Radzhabova 2022-07-29 16:10:18 +03:00 committed by GitHub
commit db25f52a41
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 61 additions and 9 deletions

View file

@ -162,6 +162,8 @@ define([
this.api.asc_registerCallback("asc_onPluginMouseMove", _.bind(this.onPluginMouseMove, this));
this.api.asc_registerCallback('asc_onPluginsReset', _.bind(this.resetPluginsList, this));
this.api.asc_registerCallback('asc_onPluginsInit', _.bind(this.onPluginsInit, this));
this.api.asc_registerCallback('asc_onPluginShowButton', _.bind(this.onPluginShowButton, this));
this.api.asc_registerCallback('asc_onPluginHideButton', _.bind(this.onPluginHideButton, this));
this.loadPlugins();
}
@ -381,6 +383,7 @@ define([
buttons: isCustomWindow ? undefined : newBtns,
toolcallback: _.bind(this.onToolClose, this),
help: !!help,
loader: plugin.get_Loader(),
modal: isModal!==undefined ? isModal : true
});
me.pluginDlg.on({
@ -399,6 +402,9 @@ define([
},
'help': function(){
help && window.open(help, '_blank');
},
'header:click': function(type){
me.api.asc_pluginButtonClick(type);
}
});
@ -458,6 +464,14 @@ define([
this.parsePlugins(pluginsdata)
},
onPluginShowButton: function(id) {
this.pluginDlg && this.pluginDlg.showButton(id);
},
onPluginHideButton: function(id) {
this.pluginDlg && this.pluginDlg.hideButton(id);
},
runAutoStartPlugins: function() {
if (this.autostart && this.autostart.length > 0) {
this.api.asc_pluginRun(this.autostart.shift(), 0, '');

View file

@ -77,6 +77,7 @@ define([
_options.tpl = _.template(this.template)(_options);
this.url = options.url || '';
this.loader = (options.loader!==undefined) ? options.loader : true;
this.frameId = options.frameId || 'plugin_iframe';
Common.UI.Window.prototype.initialize.call(this, _options);
},
@ -90,6 +91,8 @@ define([
if (!this.options.header) this._headerFooterHeight -= 34;
this._headerFooterHeight += ((parseInt(this.$window.css('border-top-width')) + parseInt(this.$window.css('border-bottom-width'))));
this.$window.find('.header').prepend($('<div class="tools left hidden"></div>'));
var iframe = document.createElement("iframe");
iframe.id = this.frameId;
iframe.name = 'pluginFrameEditor';
@ -102,13 +105,15 @@ define([
iframe.onload = _.bind(this._onLoad,this);
var me = this;
setTimeout(function(){
if (me.isLoaded) return;
me.loadMask = new Common.UI.LoadMask({owner: $('#id-plugin-placeholder')});
me.loadMask.setTitle(me.textLoading);
me.loadMask.show();
if (me.isLoaded) me.loadMask.hide();
}, 500);
if (this.loader) {
setTimeout(function(){
if (me.isLoaded) return;
me.loadMask = new Common.UI.LoadMask({owner: $('#id-plugin-placeholder')});
me.loadMask.setTitle(me.textLoading);
me.loadMask.show();
if (me.isLoaded) me.loadMask.hide();
}, 500);
}
iframe.src = this.url;
$('#id-plugin-placeholder').append(iframe);
@ -180,6 +185,32 @@ define([
}
},
showButton: function(id) {
var header = this.$window.find('.header .tools.left');
if (id=='back') {
var btn = header.find('#id-plugindlg-' + id);
if (btn.length<1) {
btn = $('<div id="id-plugindlg-' + id + '" class="tool help" style="font-size:20px;">←</div>');
btn.on('click', _.bind(function() {
this.fireEvent('header:click',id);
}, this));
header.prepend(btn);
}
btn.show();
header.removeClass('hidden');
}
},
hideButton: function(id) {
var header = this.$window.find('.header .tools.left');
if (id=='back') {
var btn = header.find('#id-plugindlg-' + id);
if (btn.length>0) {
btn.hide();
}
}
},
textLoading : 'Loading'
}, Common.Views.PluginDlg || {}));
});

View file

@ -46,8 +46,8 @@
&:before, &:after {
content: ' ';
position: absolute;
left: 7px;
left: calc(7px / @pixel-ratio-factor);
left: 8px;
left: calc(8px / @pixel-ratio-factor);
top: @scaled-one-px-value-ie;
top: @scaled-one-px-value;
height: 14px;
@ -116,6 +116,12 @@
position: absolute;
right: 0;
padding-right: 6px;
&.left {
left: 0;
right: auto;
padding-left: 6px;
}
}
.tool.help {

View file

@ -175,6 +175,7 @@ define([
buttons: isCustomWindow ? undefined : newBtns,
toolcallback: _.bind(this.onToolClose, this),
help: !!help,
loader: plugin.get_Loader(),
modal: isModal!==undefined ? isModal : true
});
me.pluginDlg.on({