allow apps to add buttons on runtime without negatively impacting performance

This commit is contained in:
Bernhard Posselt 2014-05-24 14:23:44 +02:00
parent 41b7e4b8b8
commit 11c5ded96c
1 changed files with 17 additions and 4 deletions

View File

@ -7,11 +7,24 @@
* @author Bernhard Posselt <dev@bernhard-posselt.com>
* @copyright Bernhard Posselt 2014
*/
(function (document, $) {
(function (document, $, exports) {
'use strict';
var buttons = $();
/**
* Allow apps to register buttons at runtime to not impact performance
* negatively on document click
* @param $ button wrapped in jquery result
*/
exports.Apps = {
registerSlideToggleButton: function (button) {
buttons = buttons.add(button);
}
};
/**
* Provides a way to slide down a target area through a button and slide it
* up if the user clicks somewhere else. Used for the news app settings and
@ -23,7 +36,7 @@
*/
var registerAppsSlideToggle = function () {
// use only buttons that are already in the dom
var buttons = $('[data-apps-slide-toggle]');
buttons = buttons.add($('[data-apps-slide-toggle]'));
$(document).click(function (event) {
@ -62,4 +75,4 @@
registerAppsSlideToggle();
});
}(document, jQuery));
}(document, jQuery, OC));