Mooeypoo has uploaded a new change for review. https://gerrit.wikimedia.org/r/173105
Change subject: Separate appendItems from addItems in GroupElement ...................................................................... Separate appendItems from addItems in GroupElement In some cases we want to append the items into the group in a different manner. For example, this is done in the MediaSearchWidget, where we append the result items into separate (resized) rows for better view. This fix allows us to override only the way the items are being attached and appended/prepended to the $group element when items are added without touching the rest of the addItems method. Change-Id: I5e6a27169bc5217432026835b7ae010e444d2269 --- M src/elements/GroupElement.js 1 file changed, 16 insertions(+), 3 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/oojs/ui refs/changes/05/173105/1 diff --git a/src/elements/GroupElement.js b/src/elements/GroupElement.js index 5d97be2..4cf3482 100644 --- a/src/elements/GroupElement.js +++ b/src/elements/GroupElement.js @@ -148,20 +148,33 @@ } if ( index === undefined || index < 0 || index >= this.items.length ) { - this.$group.append( itemElements ); this.items.push.apply( this.items, items ); } else if ( index === 0 ) { - this.$group.prepend( itemElements ); this.items.unshift.apply( this.items, items ); } else { - this.items[index].$element.before( itemElements ); this.items.splice.apply( this.items, [ index, 0 ].concat( items ) ); } + this.appendItems( itemElements, index ); return this; }; /** + * Append items to the group element + * @param {jQuery[]} itemsElements An array of item elements + * @param {number} [index] Index to insert items at + */ +OO.ui.GroupElement.prototype.appendItems = function ( itemElements, index ) { + if ( index === undefined || index < 0 || index >= this.items.length ) { + this.$group.append( itemElements ); + } else if ( index === 0 ) { + this.$group.prepend( itemElements ); + } else { + this.items[index].$element.before( itemElements ); + } +}; + +/** * Remove items. * * Items will be detached, not removed, so they can be used later. -- To view, visit https://gerrit.wikimedia.org/r/173105 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I5e6a27169bc5217432026835b7ae010e444d2269 Gerrit-PatchSet: 1 Gerrit-Project: oojs/ui Gerrit-Branch: master Gerrit-Owner: Mooeypoo <mor...@gmail.com> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits