From f3ca0ddf58905afaae3c5fd3ec634c6b8688d4dc Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Thu, 19 Jan 2012 17:57:15 +0100 Subject: [PATCH] Enhanced InlineEditor class --- wcfsetup/install/files/js/WCF.js | 57 +++++++++++++++++++++----------- 1 file changed, 38 insertions(+), 19 deletions(-) diff --git a/wcfsetup/install/files/js/WCF.js b/wcfsetup/install/files/js/WCF.js index f20de77230..5e59b9a457 100644 --- a/wcfsetup/install/files/js/WCF.js +++ b/wcfsetup/install/files/js/WCF.js @@ -3424,12 +3424,6 @@ WCF.InlineEditor = Class.extend({ */ _dropdowns: { }, - /** - * element jQuery selector - * @var string - */ - _elementSelector: '', - /** * list of known options * @var array @@ -3442,15 +3436,17 @@ WCF.InlineEditor = Class.extend({ */ _proxy: null, + /** + * list of data to update upon success + * @var array + */ + _updateData: [ ], + /** * Initializes a new inline editor. */ - init: function() { - if (!this._elementSelector) { - return; - } - - var $elements = $(this._elementSelector); + init: function(elementSelector) { + var $elements = $(elementSelector); if (!$elements.length) { return; } @@ -3461,22 +3457,31 @@ WCF.InlineEditor = Class.extend({ var $elementID = $element.wcfIdentify(); // find trigger element - var $trigger = this._getTriggerElement($element); + var $trigger = self._getTriggerElement($element); if ($trigger === null || $trigger.length !== 1) { return; } - $trigger.click(self._show).data('elementID', $elementID); + $trigger.click($.proxy(self._show, self)).data('elementID', $elementID); // store reference self._elements[$elementID] = $element; }); this._proxy = new WCF.Action.Proxy({ - success: self._success + success: $.proxy(this._success, this) }); + + this._setOptions(); }, + /** + * Sets options for this inline editor. + */ + _setOptions: function() { + this._options = [ ]; + } + /** * Register an option callback for validation and execution. * @@ -3505,11 +3510,11 @@ WCF.InlineEditor = Class.extend({ */ _show: function(event) { var $elementID = $(event.currentTarget).data('elementID'); - + console.debug(this); // build drop down if (!this._dropdowns[$elementID]) { - this._elements[$elementID].wrap(''); - this._dropdowns[$elementID] = $('