'use strict'; /*! * VisualEditor MWReferenceContextItem class. * * @copyright 2011-2018 VisualEditor Team's Cite sub-team and others; see AUTHORS.txt * @license MIT */ /** * Context item for a MWReference. * * @constructor * @extends ve.ui.LinearContextItem * @param {ve.ui.LinearContext} context Context the item is in * @param {ve.dm.Model} model Model the item is related to * @param {Object} [config] */ ve.ui.MWReferenceContextItem = function VeUiMWReferenceContextItem() { // Parent constructor ve.ui.MWReferenceContextItem.super.apply( this, arguments ); this.view = null; // Initialization this.$element.addClass( 've-ui-mwReferenceContextItem' ); }; /* Inheritance */ OO.inheritClass( ve.ui.MWReferenceContextItem, ve.ui.LinearContextItem ); /* Static Properties */ ve.ui.MWReferenceContextItem.static.name = 'reference'; ve.ui.MWReferenceContextItem.static.icon = 'reference'; ve.ui.MWReferenceContextItem.static.label = OO.ui.deferMsg( 'cite-ve-dialogbutton-reference-title' ); ve.ui.MWReferenceContextItem.static.modelClasses = [ ve.dm.MWReferenceNode ]; ve.ui.MWReferenceContextItem.static.commandName = 'reference'; /* Methods */ /** * Get a DOM rendering of the reference. * * @private * @return {jQuery} DOM rendering of reference */ ve.ui.MWReferenceContextItem.prototype.getRendering = function () { const refNode = this.getReferenceNode(); if ( refNode ) { this.view = new ve.ui.MWPreviewElement( refNode ); // The $element property may be rendered into asynchronously, update the // context's size when the rendering is complete if that's the case this.view.once( 'render', this.context.updateDimensions.bind( this.context ) ); return this.view.$element; } else { return $( '