require(['EventHandler'], (function(EventHandler) {
this.WoltLabEvent._setEvents(EventHandler);
- var uuid = EventHandler.add('com.woltlab.wcf.redactor2', 'showEditor', (function (data) {
-
+ EventHandler.add('com.woltlab.wcf.redactor2', 'destroy_' + this._elementId, (function () {
+ EventHandler.removeAllBySuffix('com.woltlab.wcf.redactor2', this._elementId);
}).bind(this))
}).bind(this));
else {
actions['delete'](action);
}
+ },
+
+ /**
+ * Removes all listeners registered for an identifer and ending with a special suffix.
+ * This is commonly used to unbound event handlers for the editor.
+ *
+ * @param {string} identifier event identifier
+ * @param {string} suffix action suffix
+ */
+ removeAllBySuffix: function (identifier, suffix) {
+ var actions = _listeners.get(identifier);
+ if (actions === undefined) {
+ return;
+ }
+
+ suffix = '_' + suffix;
+ var length = suffix.length * -1;
+ actions.forEach((function (callbacks, action) {
+ //noinspection JSUnresolvedFunction
+ if (action.substr(length) === suffix) {
+ this.removeAll(identifier, action);
+ }
+ }).bind(this));
}
};
});