storage.js: Add method `on` to `StorageAwareSet`
This commit is contained in:
parent
ffec2ebd4c
commit
3b7a1a5ab4
|
@ -22,12 +22,12 @@
|
|||
this.defaultVisibleRows = 2;
|
||||
this.defaultVisibleHeight = 36;
|
||||
|
||||
$(window).on('StorageAwareSetAdd', { self: this }, this.onExternalExpansion);
|
||||
$(window).on('StorageAwareSetDelete', { self: this }, this.onExternalCollapse);
|
||||
this.state = new Icinga.Storage.StorageAwareSet.withStorage(
|
||||
new Icinga.BehaviorStorage('collapsible'),
|
||||
'expanded'
|
||||
);
|
||||
)
|
||||
.on('add', { self: this }, this.onExternalExpansion)
|
||||
.on('delete', { self: this }, this.onExternalCollapse);
|
||||
};
|
||||
Collapsible.prototype = new Icinga.EventListener();
|
||||
|
||||
|
|
|
@ -250,6 +250,27 @@
|
|||
}, this);
|
||||
},
|
||||
|
||||
/**
|
||||
* Register an event handler to handle storage updates
|
||||
*
|
||||
* Available events are: add, delete
|
||||
*
|
||||
* @param {string} event
|
||||
* @param {object} data
|
||||
* @param {function} handler
|
||||
*
|
||||
* @returns {this}
|
||||
*/
|
||||
on: function(event, data, handler) {
|
||||
$(window).on(
|
||||
'StorageAwareSet' + event.charAt(0).toUpperCase() + event.slice(1),
|
||||
data,
|
||||
handler
|
||||
);
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
* Return the number of (unique) elements in the set
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue