Divec has uploaded a new change for review. ( 
https://gerrit.wikimedia.org/r/370823 )

Change subject: Expose ve.ui.MWInternalLinkContextItem generateBody logic
......................................................................

Expose ve.ui.MWInternalLinkContextItem generateBody logic

Change-Id: I94912ac2c471cc5d227fa8b9cb29c302ca29814d
---
M modules/ve-mw/ui/contextitems/ve.ui.MWInternalLinkContextItem.js
1 file changed, 31 insertions(+), 18 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/VisualEditor 
refs/changes/23/370823/1

diff --git a/modules/ve-mw/ui/contextitems/ve.ui.MWInternalLinkContextItem.js 
b/modules/ve-mw/ui/contextitems/ve.ui.MWInternalLinkContextItem.js
index 03072ef..7170feb 100644
--- a/modules/ve-mw/ui/contextitems/ve.ui.MWInternalLinkContextItem.js
+++ b/modules/ve-mw/ui/contextitems/ve.ui.MWInternalLinkContextItem.js
@@ -33,35 +33,26 @@
 
 ve.ui.MWInternalLinkContextItem.static.modelClasses = [ 
ve.dm.MWInternalLinkAnnotation ];
 
-/* Methods */
+/* Static methods */
 
 /**
- * @inheritdoc
+ * Render
  */
-ve.ui.MWInternalLinkContextItem.prototype.getDescription = function () {
-       return this.model.getAttribute( 'normalizedTitle' );
-};
-
-/**
- * @inheritdoc
- */
-ve.ui.MWInternalLinkContextItem.prototype.renderBody = function () {
+ve.ui.MWInternalLinkContextItem.static.generateBody = function ( linkCache, 
title, htmlDoc, description, href, fragment ) {
        var icon, $description,
                usePageImages = mw.config.get( 'wgVisualEditor' ).usePageImages,
                usePageDescriptions = mw.config.get( 'wgVisualEditor' 
).usePageDescriptions,
-               title = this.model.getAttribute( 'lookupTitle' ),
-               htmlDoc = 
this.context.getSurface().getModel().getDocument().getHtmlDocument(),
                $wrapper = $( '<div>' ),
                $link = $( '<a>' )
                        .addClass( 've-ui-mwInternalLinkContextItem-link' )
-                       .text( this.getDescription() )
+                       .text( description )
                        .attr( {
-                               href: ve.resolveUrl( this.model.getHref(), 
htmlDoc ),
+                               href: ve.resolveUrl( href, htmlDoc ),
                                target: '_blank'
                        } );
 
        // Style based on link cache information
-       ve.init.platform.linkCache.styleElement( title, $link, 
this.model.getFragment() );
+       ve.init.platform.linkCache.styleElement( title, $link, fragment );
        // Don't style as a self-link in the context menu (but do elsewhere)
        $link.removeClass( 'mw-selflink' );
 
@@ -78,10 +69,8 @@
                $wrapper.addClass( 
've-ui-mwInternalLinkContextItem-withDescription' );
        }
 
-       this.$body.empty().append( $wrapper );
-
        if ( usePageImages || usePageDescriptions ) {
-               ve.init.platform.linkCache.get( title ).then( function ( 
linkData ) {
+               linkCache.get( title ).then( function ( linkData ) {
                        if ( usePageImages ) {
                                if ( linkData.imageUrl ) {
                                        icon.$element
@@ -99,6 +88,30 @@
                        }
                } );
        }
+       return $wrapper;
+};
+
+/* Methods */
+
+/**
+ * @inheritdoc
+ */
+ve.ui.MWInternalLinkContextItem.prototype.getDescription = function () {
+       return this.model.getAttribute( 'normalizedTitle' );
+};
+
+/**
+ * @inheritdoc
+ */
+ve.ui.MWInternalLinkContextItem.prototype.renderBody = function () {
+       this.$body.empty().append( this.constructor.static.generateBody(
+               ve.init.platform.linkCache,
+               this.model.getAttribute( 'lookupTitle' ),
+               
this.context.getSurface().getModel().getDocument().getHtmlDocument(),
+               this.getDescription(),
+               this.model.getHref(),
+               this.model.getFragment()
+       ) );
 };
 
 /* Registration */

-- 
To view, visit https://gerrit.wikimedia.org/r/370823
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I94912ac2c471cc5d227fa8b9cb29c302ca29814d
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/VisualEditor
Gerrit-Branch: master
Gerrit-Owner: Divec <da...@troi.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to