Move OC.Plugin to the server bundle
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
This commit is contained in:
parent
4846aea951
commit
3d1a3b6644
|
@ -56,7 +56,7 @@ function(e){var t,n,i,s,r,o,a,l,u,c,d,h,p,f,m,g,_,v,y,b="sizzle"+1*new Date,w=e.
|
|||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/var S={startSaving:function(e){this.startAction(e,t("core","Saving..."))},startAction:function(e,t){M()(e).text(t).removeClass("success").removeClass("error").stop(!0,!0).show()},finishedSaving:function(e,t){this.finishedAction(e,t)},finishedAction:function(e,t){"success"===t.status?this.finishedSuccess(e,t.data.message):this.finishedError(e,t.data.message)},finishedSuccess:function(e,t){M()(e).text(t).addClass("success").removeClass("error").stop(!0,!0).delay(3e3).fadeOut(900).show()},finishedError:function(e,t){M()(e).text(t).addClass("error").removeClass("success").show()}},C={queuedNotifications:[],getDefaultNotificationFunction:null,notificationTimers:[],setDefault:function(e){this.getDefaultNotificationFunction=e},hide:function(e,t){var n=this,i=M()("#notification");if(c.a.isFunction(e)&&(t=e,e=void 0),e||(console.warn("Missing argument $row in OC.Notification.hide() call, caller needs to be adjusted to only dismiss its own notification"),e=i.find(".row:first")),e&&i.find(".row").length>1)return e.remove(),void(t&&t.call());c.a.defer(function(){i.find(".row").length>1?e.remove():i.fadeOut("400",function(){n.isHidden()&&n.getDefaultNotificationFunction&&n.getDefaultNotificationFunction.call(),t&&t.call(),i.empty()})})},showHtml:function(e,n){n=n||{},c.a.defaults(n,{timeout:0});var i=this,s=M()("#notification");this.isHidden()&&s.fadeIn().css("display","inline-block");var r=M()('<div class="row"></div>');if(n.type&&r.addClass("type-"+n.type),"error"===n.type){var o=M()('<a class="action close icon-close" href="#"></a>');o.attr("alt",t("core","Dismiss")),r.append(o),o.one("click",function(){return i.hide(r),!1}),r.addClass("closeable")}return r.prepend(e),s.append(r),n.timeout>0&&this.notificationTimers.push(setTimeout(function(){i.hide(r)},1e3*n.timeout)),r},show:function(e,t){return this.showHtml(M()("<div/>").text(e).html(),t)},showUpdate:function(e){var t=M()("#notification"),n=M()("<div/>").text(e).html();if(e&&0==t.find(".row").length)return this.showHtml(n);var i=M()('<div class="row"></div>').prepend(n);return t.html(i),i},showTemporary:function(e,t){return t=t||{},c.a.defaults(t,{isHTML:!1,timeout:7}),t.isHTML?this.showHtml(e,t):this.show(e,t)},isHidden:function(){return!M()("#notification").find(".row").length}},E=n.a={Apps:s.a,AppConfig:o,Backbone:b,ContactsMenu:w.a,EventSource:A,L10N:T,msg:S,Notification:C};
|
||||
*/var S={startSaving:function(e){this.startAction(e,t("core","Saving..."))},startAction:function(e,t){M()(e).text(t).removeClass("success").removeClass("error").stop(!0,!0).show()},finishedSaving:function(e,t){this.finishedAction(e,t)},finishedAction:function(e,t){"success"===t.status?this.finishedSuccess(e,t.data.message):this.finishedError(e,t.data.message)},finishedSuccess:function(e,t){M()(e).text(t).addClass("success").removeClass("error").stop(!0,!0).delay(3e3).fadeOut(900).show()},finishedError:function(e,t){M()(e).text(t).addClass("error").removeClass("success").show()}},C={queuedNotifications:[],getDefaultNotificationFunction:null,notificationTimers:[],setDefault:function(e){this.getDefaultNotificationFunction=e},hide:function(e,t){var n=this,i=M()("#notification");if(c.a.isFunction(e)&&(t=e,e=void 0),e||(console.warn("Missing argument $row in OC.Notification.hide() call, caller needs to be adjusted to only dismiss its own notification"),e=i.find(".row:first")),e&&i.find(".row").length>1)return e.remove(),void(t&&t.call());c.a.defer(function(){i.find(".row").length>1?e.remove():i.fadeOut("400",function(){n.isHidden()&&n.getDefaultNotificationFunction&&n.getDefaultNotificationFunction.call(),t&&t.call(),i.empty()})})},showHtml:function(e,n){n=n||{},c.a.defaults(n,{timeout:0});var i=this,s=M()("#notification");this.isHidden()&&s.fadeIn().css("display","inline-block");var r=M()('<div class="row"></div>');if(n.type&&r.addClass("type-"+n.type),"error"===n.type){var o=M()('<a class="action close icon-close" href="#"></a>');o.attr("alt",t("core","Dismiss")),r.append(o),o.one("click",function(){return i.hide(r),!1}),r.addClass("closeable")}return r.prepend(e),s.append(r),n.timeout>0&&this.notificationTimers.push(setTimeout(function(){i.hide(r)},1e3*n.timeout)),r},show:function(e,t){return this.showHtml(M()("<div/>").text(e).html(),t)},showUpdate:function(e){var t=M()("#notification"),n=M()("<div/>").text(e).html();if(e&&0==t.find(".row").length)return this.showHtml(n);var i=M()('<div class="row"></div>').prepend(n);return t.html(i),i},showTemporary:function(e,t){return t=t||{},c.a.defaults(t,{isHTML:!1,timeout:7}),t.isHTML?this.showHtml(e,t):this.show(e,t)},isHidden:function(){return!M()("#notification").find(".row").length}},E=n.a={Apps:s.a,AppConfig:o,Backbone:b,ContactsMenu:w.a,EventSource:A,L10N:T,msg:S,Notification:C,Plugins:{_plugins:{},register:function(e,t){var n=this._plugins[e];n||(n=this._plugins[e]=[]),n.push(t)},getPlugins:function(e){return this._plugins[e]||[]},attach:function(e,t,n){for(var i=this.getPlugins(e),s=0;s<i.length;s++)i[s].attach&&i[s].attach(t,n)},detach:function(e,t,n){for(var i=this.getPlugins(e),s=0;s<i.length;s++)i[s].detach&&i[s].detach(t,n)}}};
|
||||
/*
|
||||
* @copyright 2019 Christoph Wurst <christoph@winzerhof-wurst.at>
|
||||
*
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -870,96 +870,6 @@ Object.assign(window.OC, {
|
|||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* Current user attributes
|
||||
*
|
||||
* @typedef {Object} OC.CurrentUser
|
||||
*
|
||||
* @property {String} uid user id
|
||||
* @property {String} displayName display name
|
||||
*/
|
||||
|
||||
/**
|
||||
* @namespace OC.Plugins
|
||||
*/
|
||||
OC.Plugins = {
|
||||
/**
|
||||
* @type Array.<OC.Plugin>
|
||||
*/
|
||||
_plugins: {},
|
||||
|
||||
/**
|
||||
* Register plugin
|
||||
*
|
||||
* @param {String} targetName app name / class name to hook into
|
||||
* @param {OC.Plugin} plugin
|
||||
*/
|
||||
register: function(targetName, plugin) {
|
||||
var plugins = this._plugins[targetName];
|
||||
if (!plugins) {
|
||||
plugins = this._plugins[targetName] = [];
|
||||
}
|
||||
plugins.push(plugin);
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns all plugin registered to the given target
|
||||
* name / app name / class name.
|
||||
*
|
||||
* @param {String} targetName app name / class name to hook into
|
||||
* @return {Array.<OC.Plugin>} array of plugins
|
||||
*/
|
||||
getPlugins: function(targetName) {
|
||||
return this._plugins[targetName] || [];
|
||||
},
|
||||
|
||||
/**
|
||||
* Call attach() on all plugins registered to the given target name.
|
||||
*
|
||||
* @param {String} targetName app name / class name
|
||||
* @param {Object} object to be extended
|
||||
* @param {Object} [options] options
|
||||
*/
|
||||
attach: function(targetName, targetObject, options) {
|
||||
var plugins = this.getPlugins(targetName);
|
||||
for (var i = 0; i < plugins.length; i++) {
|
||||
if (plugins[i].attach) {
|
||||
plugins[i].attach(targetObject, options);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Call detach() on all plugins registered to the given target name.
|
||||
*
|
||||
* @param {String} targetName app name / class name
|
||||
* @param {Object} object to be extended
|
||||
* @param {Object} [options] options
|
||||
*/
|
||||
detach: function(targetName, targetObject, options) {
|
||||
var plugins = this.getPlugins(targetName);
|
||||
for (var i = 0; i < plugins.length; i++) {
|
||||
if (plugins[i].detach) {
|
||||
plugins[i].detach(targetObject, options);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Plugin
|
||||
*
|
||||
* @todo make this a real class in the future
|
||||
* @typedef {Object} OC.Plugin
|
||||
*
|
||||
* @property {String} name plugin name
|
||||
* @property {Function} attach function that will be called when the
|
||||
* plugin is attached
|
||||
* @property {Function} [detach] function that will be called when the
|
||||
* plugin is detached
|
||||
*/
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* @namespace OC.search
|
||||
*/
|
||||
|
|
|
@ -27,6 +27,7 @@ import EventSource from './eventsource'
|
|||
import L10N from './l10n'
|
||||
import msg from './msg'
|
||||
import Notification from './notification'
|
||||
import Plugins from './plugins'
|
||||
|
||||
/** @namespace OC */
|
||||
export default {
|
||||
|
@ -38,4 +39,5 @@ export default {
|
|||
L10N,
|
||||
msg,
|
||||
Notification,
|
||||
Plugins,
|
||||
}
|
||||
|
|
|
@ -0,0 +1,89 @@
|
|||
/*
|
||||
* @copyright 2019 Christoph Wurst <christoph@winzerhof-wurst.at>
|
||||
*
|
||||
* @author 2019 Christoph Wurst <christoph@winzerhof-wurst.at>
|
||||
*
|
||||
* @license GNU AGPL version 3 or any later version
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as
|
||||
* published by the Free Software Foundation, either version 3 of the
|
||||
* License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @namespace OC.Plugins
|
||||
*/
|
||||
export default {
|
||||
|
||||
/**
|
||||
* @type Array.<OC.Plugin>
|
||||
*/
|
||||
_plugins: {},
|
||||
|
||||
/**
|
||||
* Register plugin
|
||||
*
|
||||
* @param {String} targetName app name / class name to hook into
|
||||
* @param {OC.Plugin} plugin
|
||||
*/
|
||||
register: function (targetName, plugin) {
|
||||
var plugins = this._plugins[targetName];
|
||||
if (!plugins) {
|
||||
plugins = this._plugins[targetName] = [];
|
||||
}
|
||||
plugins.push(plugin);
|
||||
},
|
||||
|
||||
/**
|
||||
* Returns all plugin registered to the given target
|
||||
* name / app name / class name.
|
||||
*
|
||||
* @param {String} targetName app name / class name to hook into
|
||||
* @return {Array.<OC.Plugin>} array of plugins
|
||||
*/
|
||||
getPlugins: function (targetName) {
|
||||
return this._plugins[targetName] || [];
|
||||
},
|
||||
|
||||
/**
|
||||
* Call attach() on all plugins registered to the given target name.
|
||||
*
|
||||
* @param {String} targetName app name / class name
|
||||
* @param {Object} object to be extended
|
||||
* @param {Object} [options] options
|
||||
*/
|
||||
attach: function (targetName, targetObject, options) {
|
||||
var plugins = this.getPlugins(targetName);
|
||||
for (var i = 0; i < plugins.length; i++) {
|
||||
if (plugins[i].attach) {
|
||||
plugins[i].attach(targetObject, options);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* Call detach() on all plugins registered to the given target name.
|
||||
*
|
||||
* @param {String} targetName app name / class name
|
||||
* @param {Object} object to be extended
|
||||
* @param {Object} [options] options
|
||||
*/
|
||||
detach: function (targetName, targetObject, options) {
|
||||
var plugins = this.getPlugins(targetName);
|
||||
for (var i = 0; i < plugins.length; i++) {
|
||||
if (plugins[i].detach) {
|
||||
plugins[i].detach(targetObject, options);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue