From 58e50b58c160af42fbd042c292c17f10ec39ae31 Mon Sep 17 00:00:00 2001 From: Matthias Schmidt Date: Tue, 1 Jan 2013 16:17:21 +0100 Subject: [PATCH] Removes double code --- wcfsetup/install/files/js/WCF.ACL.js | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/wcfsetup/install/files/js/WCF.ACL.js b/wcfsetup/install/files/js/WCF.ACL.js index 36ac507ec3..0aec613326 100644 --- a/wcfsetup/install/files/js/WCF.ACL.js +++ b/wcfsetup/install/files/js/WCF.ACL.js @@ -171,9 +171,7 @@ WCF.ACL.List = Class.extend({ * @param object data */ addObject: function(data) { - var $listItem = $('
  • ' + data.label + '
  • ').appendTo(this._containerElements.aclList); - $listItem.data('objectID', data.objectID).data('type', data.type).click($.proxy(this._click, this)); - $('').click($.proxy(this._removeItem, this)).appendTo($listItem); + var $listItem = this._createListItem(data.objectID, data.label, data.type); // toggle element this._savePermissions(); @@ -192,6 +190,22 @@ WCF.ACL.List = Class.extend({ this._containerElements.permissionList.show(); }, + /** + * Creates a list item with the given data and returns it. + * + * @param integer objectID + * @param string label + * @param string type + * @return jQuery + */ + _createListItem: function(objectID, label, type) { + var $listItem = $('
  • ' + label + '
  • ').appendTo(this._containerElements.aclList); + $listItem.data('objectID', objectID).data('type', type).click($.proxy(this._click, this)); + $('').click($.proxy(this._removeItem, this)).appendTo($listItem); + + return $listItem; + }, + /** * Removes an item from list. * @@ -315,9 +329,7 @@ WCF.ACL.List = Class.extend({ // add list items for (var $typeID in data.returnValues[type].label) { - var $listItem = $('
  • ' + data.returnValues[type].label[$typeID] + '
  • ').appendTo(this._containerElements.aclList); - $listItem.data('objectID', $typeID).data('type', type).click($.proxy(this._click, this)); - $('').click($.proxy(this._removeItem, this)).appendTo($listItem); + this._createListItem($typeID, data.returnValues[type].label[$typeID], type); this._search.addExcludedSearchValue(data.returnValues[type].label[$typeID]); } -- 2.20.1