*
* @param string className
* @param jQuery containerList
+ * @param string toggleButtonSelector
*/
-WCF.Action.Toggle = function(className, containerList) { this.init(className, containerList); };
+WCF.Action.Toggle = function(className, containerList, toggleButtonSelector) { this.init(className, containerList, toggleButtonSelector); };
WCF.Action.Toggle.prototype = {
/**
* Initializes 'toggle'-Proxy
* @param string className
* @param jQuery containerList
*/
- init: function(className, containerList) {
+ init: function(className, containerList, toggleButtonSelector) {
if (!containerList.length) return;
this.containerList = containerList;
this.className = className;
+ this.toggleButtonSelector = '.toggleButton';
+ if (toggleButtonSelector) {
+ this.toggleButtonSelector = toggleButtonSelector;
+ }
+
// initialize proxy
var options = {
success: $.proxy(this._success, this)
// bind event listener
this.containerList.each($.proxy(function(index, container) {
- $(container).find('.toggleButton').bind('click', $.proxy(this._click, this));
+ $(container).find(this.toggleButtonSelector).bind('click', $.proxy(this._click, this));
}, this));
},
*/
_success: function(data, textStatus, jqXHR) {
// remove items
- this.containerList.each(function(index, container) {
- var $toggleButton = $(container).find('.toggleButton');
+ this.containerList.each($.proxy(function(index, container) {
+ var $toggleButton = $(container).find(this.toggleButtonSelector);
if (WCF.inArray($toggleButton.data('objectID'), data.objectIDs)) {
$(container).wcfHighlight();
}
});
}
- });
+ }, this));
}
};