mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/RelatedArticles
synced 2024-12-18 19:10:54 +00:00
0fa064728f
Replace * $.each( array, function ( index, value ) { ... } ) by array.forEach( function ( value ) { ... } ) * $.map( array, function ( value ) { ... } ) by array.map( function ( value ) { ... } ) * $.isArray( var ) by Array.isArray( var ) * $.isFunction( var ) by typeof var === 'function' Change-Id: I450f5a75eb9c3fe20517da02986b0a491ebca67a
38 lines
877 B
JavaScript
38 lines
877 B
JavaScript
( function ( $, mw ) {
|
|
'use strict';
|
|
|
|
/**
|
|
* View that renders multiple {@link mw.cards.CardView cards}
|
|
*
|
|
* @class mw.cards.CardListView
|
|
* @param {mw.cards.CardView[]} cardViews
|
|
*/
|
|
function CardListView( cardViews ) {
|
|
var self = this;
|
|
|
|
/**
|
|
* @property {mw.cards.CardView[]|Array}
|
|
*/
|
|
this.cardViews = cardViews || [];
|
|
|
|
/**
|
|
* @property {jQuery}
|
|
*/
|
|
this.$el = $( this.template.render() );
|
|
|
|
// We don't want to use template partials because we want to
|
|
// preserve event handlers of each card view.
|
|
this.cardViews.forEach( function ( cardView ) {
|
|
self.$el.append( cardView.$el );
|
|
} );
|
|
}
|
|
OO.initClass( CardListView );
|
|
|
|
/**
|
|
* @property {Object} compiled template
|
|
*/
|
|
CardListView.prototype.template = mw.template.get( 'ext.relatedArticles.cards', 'cards.muhogan' );
|
|
|
|
mw.cards.CardListView = CardListView;
|
|
}( jQuery, mediaWiki ) );
|