Skip to content

Commit

Permalink
Apply behaviors correctly on startup
Browse files Browse the repository at this point in the history
  • Loading branch information
majentsch committed Sep 10, 2014
1 parent d99d50b commit 5d2e849
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 13 deletions.
2 changes: 1 addition & 1 deletion public/js/icinga.js
Expand Up @@ -97,7 +97,7 @@
this.history = new Icinga.History(this);
var self = this;
$.each(Icinga.Behaviors, function(name, Behavior) {
self.behaviors[name.toLowerCase()] = new Behavior();
self.behaviors[name.toLowerCase()] = new Behavior(self);
});

this.timezone.initialize();
Expand Down
22 changes: 10 additions & 12 deletions public/js/icinga/events.js
Expand Up @@ -32,26 +32,17 @@
initialize: function () {
this.applyGlobalDefaults();
this.applyHandlers($('#layout'));
var self = this;

// define global site behavior
$.each(self.icinga.behaviors, function (name, behavior) {
behavior.bind();
});

// prepare container html
$('.container').each(function(idx, el) {
// apply event handlers
icinga.events.applyHandlers($(el));
icinga.ui.initializeControls($(el));
$.each(self.icinga.behaviors, function (name, behavior) {
behavior.apply(el);
});
});
},

// TODO: What's this?
applyHandlers: function (el) {
$.each(this.icinga.behaviors, function (name, behavior) {
behavior.apply(el);
});

var icinga = this.icinga;

Expand Down Expand Up @@ -152,6 +143,10 @@
* Global default event handlers
*/
applyGlobalDefaults: function () {
$.each(self.icinga.behaviors, function (name, behavior) {
behavior.bind();
});

// We catch resize events
$(window).on('resize', { self: this.icinga.ui }, this.icinga.ui.onWindowResize);

Expand Down Expand Up @@ -673,6 +668,9 @@
*/

unbindGlobalHandlers: function () {
$.each(self.icinga.behaviors, function (name, behavior) {
behavior.unbind();
});
$(window).off('resize', this.onWindowResize);
$(window).off('load', this.onLoad);
$(window).off('unload', this.onUnload);
Expand Down

0 comments on commit 5d2e849

Please sign in to comment.