From 77c434239e7c9332d8605d25d9f0e8eb13402866 Mon Sep 17 00:00:00 2001 From: Marcel Werk Date: Fri, 11 Nov 2011 22:23:28 +0100 Subject: [PATCH] Some small optimizations --- wcfsetup/install/files/js/WCF.js | 62 ++++++++++++++------------------ 1 file changed, 27 insertions(+), 35 deletions(-) diff --git a/wcfsetup/install/files/js/WCF.js b/wcfsetup/install/files/js/WCF.js index 820573b40a..ea4e8f6d1a 100644 --- a/wcfsetup/install/files/js/WCF.js +++ b/wcfsetup/install/files/js/WCF.js @@ -2408,12 +2408,6 @@ WCF.Collapsible.Remote = Class.extend({ */ _className: '', - /** - * content cache per container - * @var object - */ - _content: {}, - /** * list of active containers * @var object @@ -2456,26 +2450,24 @@ WCF.Collapsible.Remote = Class.extend({ var $id = $container.wcfIdentify(); this._containers[$id] = $container; - var $target = this._getTarget($id); - var $buttonContainer = this._getButtonContainer($id); - var $button = this._createButton($id, $buttonContainer); - - // store container meta data - this._containerData[$id] = { - button: $button, - buttonContainer: $buttonContainer, - isOpen: $container.data('isOpen'), - target: $target - }; - - // prepare content cache - /*this._content[$id] = { - 'close': '', - 'open': '' - };*/ + this._initContainer($id, $container); }, this)); }, + _initContainer: function(containerID, container) { + var $target = this._getTarget(containerID); + var $buttonContainer = this._getButtonContainer(containerID); + var $button = this._createButton(containerID, $buttonContainer); + + // store container meta data + this._containerData[containerID] = { + button: $button, + buttonContainer: $buttonContainer, + isOpen: container.data('isOpen'), + target: $target + }; + }, + /** * Returns a collection of collapsible containers. * @@ -2525,16 +2517,6 @@ WCF.Collapsible.Remote = Class.extend({ var $state = ($isOpen) ? 'open' : 'close'; var $newState = ($isOpen) ? 'close' : 'open'; - // save container content - // this._content[$containerID][$state] = this._containerData[$containerID].target.html(); - - // set container content from cache - /*if (this._content[$containerID][$newState] != '') { - this._containerData[$containerID].target.html(this._content[$containerID][$newState]); - this._containerData[$containerID].isOpen = ($isOpen) ? false : true; - return; - }*/ - // fetch content state via AJAX this._proxy.setOption('data', { actionName: 'toggleContainer', @@ -2578,6 +2560,17 @@ WCF.Collapsible.Remote = Class.extend({ return {}; }, + /** + * Updates container content. + * + * @param integer containerID + * @param string newContent + * @param string newState + */ + _updateContent: function(containerID, newContent, newState) { + this._containerData[containerID].target.html(newContent); + }, + /** * Sets content upon successfull AJAX request. * @@ -2596,10 +2589,9 @@ WCF.Collapsible.Remote = Class.extend({ // update content storage this._containerData[$containerID].isOpen = (data.returnValues.isOpen) ? true : false; var $newState = (data.returnValues.isOpen) ? 'opened' : 'closed'; - //this._content[$containerID][$newState] = data.returnValues.content; // update container content - this._containerData[$containerID].target.html(data.returnValues.content); + this._updateContent($containerID, data.returnValues.content, $newState); // update icon this._hideSpinner(this._containerData[$containerID].button, WCF.Icon.get('wcf.icon.' + (data.returnValues.isOpen ? 'opened' : 'closed'))); -- 2.20.1