SuchetaG has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/171488

Change subject: Matching pages from suggestions in link dialog now actually 
work as links
......................................................................

Matching pages from suggestions in link dialog now actually work as links

A subclass of MenuItemWidget from OOUI is introduced that, when used in 
MWLinkTargetInputWidget for both
external and internal links, returns actual page links.

Bug: 51205
Change-Id: I3ac18dabd514ca539fff1db3c67ae97931c3d4fc
---
M VisualEditor.php
A modules/ve-mw/ui/widgets/ve.ui.MWLinkMenuItemWidget.js
M modules/ve-mw/ui/widgets/ve.ui.MWLinkTargetInputWidget.js
3 files changed, 41 insertions(+), 8 deletions(-)


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

diff --git a/VisualEditor.php b/VisualEditor.php
index 3104619..71b539b 100644
--- a/VisualEditor.php
+++ b/VisualEditor.php
@@ -968,6 +968,7 @@
                        
'modules/ve-mw/ce/annotations/ve.ce.MWInternalLinkAnnotation.js',
 
                        
'modules/ve-mw/ui/widgets/ve.ui.MWLinkTargetInputWidget.js',
+                       
'modules/ve-mw/ui/widgets/ve.ui.MWLinkMenuItemWidget.js',
 
                        
'modules/ve-mw/ui/inspectors/ve.ui.MWLinkAnnotationInspector.js',
                        
'modules/ve-mw/ui/inspectors/ve.ui.MWLinkNodeInspector.js',
diff --git a/modules/ve-mw/ui/widgets/ve.ui.MWLinkMenuItemWidget.js 
b/modules/ve-mw/ui/widgets/ve.ui.MWLinkMenuItemWidget.js
new file mode 100644
index 0000000..1438df1
--- /dev/null
+++ b/modules/ve-mw/ui/widgets/ve.ui.MWLinkMenuItemWidget.js
@@ -0,0 +1,32 @@
+ /*!
+ * VisualEditor UserInterface MWLinkMenuWidget class
+ *
+ * @copyright 2011-2014 VisualEditor Team and others; see 
http://ve.mit-license.org
+ */
+
+ /**
+ * Creates a ve.ui.MWLinkMenuItemWidget object.
+ *
+ * @class
+ * @extends OO.ui.MenuItemWidget
+ *
+ * @constructor
+ * @param {Object} [config] Configuration options
+ * @cfg {string} [href] href to point to pages from link suggestions
+ */
+
+ve.ui.MWLinkMenuItemWidget = function VeUiMWLinkMenuItemWidget( data, config ) 
{
+       // Config intialization
+       config = config || {};
+
+       // Parent constructor
+       ve.ui.MWLinkMenuItemWidget.super.call( this, data, config );
+
+       // Intialization
+       this.$label.wrap( '<a>' );
+       this.$label.parent().attr( 'href', config.href );
+};
+
+/* Inheritance */
+
+OO.inheritClass( ve.ui.MWLinkMenuItemWidget, OO.ui.MenuItemWidget );
diff --git a/modules/ve-mw/ui/widgets/ve.ui.MWLinkTargetInputWidget.js 
b/modules/ve-mw/ui/widgets/ve.ui.MWLinkTargetInputWidget.js
index 6ed0d8c..6b7375d 100644
--- a/modules/ve-mw/ui/widgets/ve.ui.MWLinkTargetInputWidget.js
+++ b/modules/ve-mw/ui/widgets/ve.ui.MWLinkTargetInputWidget.js
@@ -182,9 +182,9 @@
                        'externalLink',
                        { $: menu$, label: ve.msg( 
'visualeditor-linkinspector-suggest-external-link' ) }
                ) );
-               items.push( new OO.ui.MenuItemWidget(
+               items.push( new ve.ui.MWLinkMenuItemWidget(
                        this.getExternalLinkAnnotationFromUrl( this.value ),
-                       { $: menu$, rel: 'externalLink', label: this.value }
+                       { $: menu$, rel: 'externalLink', label: this.value, 
href: this.value }
                ) );
        }
 
@@ -195,9 +195,9 @@
                                'newPage',
                                { $: menu$, label: ve.msg( 
'visualeditor-linkinspector-suggest-new-page' ) }
                        ) );
-                       items.push( new OO.ui.MenuItemWidget(
+                       items.push( new ve.ui.MWLinkMenuItemWidget(
                                this.getInternalLinkAnnotationFromTitle( 
this.value ),
-                               { $: menu$, rel: 'newPage', label: this.value }
+                               { $: menu$, rel: 'newPage', label: this.value, 
href: mw.util.getUrl( this.value ) }
                        ) );
                } else {
                        // If no title object could be created, it means the 
title is illegal
@@ -221,9 +221,9 @@
                        matchingPages.unshift( this.value );
                }
                for ( i = 0, len = matchingPages.length; i < len; i++ ) {
-                       items.push( new OO.ui.MenuItemWidget(
+                       items.push( new ve.ui.MWLinkMenuItemWidget(
                                this.getInternalLinkAnnotationFromTitle( 
matchingPages[i] ),
-                               { $: menu$, rel: 'matchingPage', label: 
matchingPages[i] }
+                               { $: menu$, rel: 'matchingPage', label: 
matchingPages[i], href: mw.util.getUrl( matchingPages[i] ) }
                        ) );
                }
        }
@@ -235,9 +235,9 @@
                        { $: menu$, label: ve.msg( 
'visualeditor-linkinspector-suggest-disambig-page', disambigPages.length ) }
                ) );
                for ( i = 0, len = disambigPages.length; i < len; i++ ) {
-                       items.push( new OO.ui.MenuItemWidget(
+                       items.push( new ve.ui.MWLinkMenuItemWidget(
                                this.getInternalLinkAnnotationFromTitle( 
disambigPages[i] ),
-                               { $: menu$, rel: 'disambigPage', label: 
disambigPages[i] }
+                               { $: menu$, rel: 'disambigPage', label: 
disambigPages[i], href: mw.util.getUrl( disambigPages[i] ) }
                        ) );
                }
        }

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I3ac18dabd514ca539fff1db3c67ae97931c3d4fc
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/VisualEditor
Gerrit-Branch: master
Gerrit-Owner: SuchetaG <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to