/* eslint-disable no-underscore-dangle */ 'use strict'; /** * Renders a Card model and updates when it does. * * @class mw.cards.CardView * @param {mw.cards.CardModel} model */ function CardView( model ) { /** * @property {mw.cards.CardModel} */ this.model = model; // listen to model changes and re-render the view this.model.on( 'change', this.render.bind( this ) ); /** * @property {jQuery} */ this.$el = $( this._render() ); } OO.initClass( CardView ); /** * Replace the html of this.$el with a newly rendered html using the model * attributes. */ CardView.prototype.render = function () { this.$el.replaceWith( this._render() ); }; /** * Renders the template using the model attributes. * * @ignore * @return {string} */ CardView.prototype._render = function () { const $listItem = $( '
' ) .attr( { class: 'ext-related-articles-card-extract' } ) .text( attributes.extract ) ) ); return $listItem; }; module.exports = CardView;