diff --git a/core/js/app.js b/core/js/app.js index 59b5d14419..6592ea93b2 100644 --- a/core/js/app.js +++ b/core/js/app.js @@ -7,11 +7,24 @@ * @author Bernhard Posselt * @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)); \ No newline at end of file +}(document, jQuery, OC)); \ No newline at end of file