query buttons on every click to not worry about weird edge case scenarios

This commit is contained in:
Bernhard Posselt 2014-05-24 14:28:24 +02:00
parent 8a30fe8ce3
commit 9112386cbf
1 changed files with 5 additions and 19 deletions

View File

@ -7,24 +7,11 @@
* @author Bernhard Posselt <dev@bernhard-posselt.com>
* @copyright Bernhard Posselt 2014
*/
(function (document, $, exports) {
(function (document, $) {
'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.App = {
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
@ -35,11 +22,10 @@
* <div class=".slide-area" class="hidden">I'm sliding up</div>
*/
var registerAppsSlideToggle = function () {
// use only buttons that are already in the dom
buttons = buttons.add($('[data-apps-slide-toggle]'));
$(document).click(function (event) {
var buttons = $('[data-apps-slide-toggle]');
buttons.each(function (index, button) {
var areaSelector = $(button).data('apps-slide-toggle');
@ -75,4 +61,4 @@
registerAppsSlideToggle();
});
}(document, jQuery, OC));
}(document, jQuery));