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

Change subject: Let the browser handle click events with a modifier key on 
examples links so that the links can be open in a new tab or window
......................................................................

Let the browser handle click events with a modifier key on examples links
so that the links can be open in a new tab or window

Bug: T181885
Change-Id: If28748bd75424b030d84250d329375c65f1056be
---
M wikibase/queryService/ui/QueryExampleDialog.js
1 file changed, 13 insertions(+), 6 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/wikidata/query/gui 
refs/changes/71/394871/1

diff --git a/wikibase/queryService/ui/QueryExampleDialog.js 
b/wikibase/queryService/ui/QueryExampleDialog.js
index 2d1754e..6181360 100644
--- a/wikibase/queryService/ui/QueryExampleDialog.js
+++ b/wikibase/queryService/ui/QueryExampleDialog.js
@@ -253,12 +253,19 @@
         */
        SELF.prototype._addExample = function( title, query, href, tags, 
category ) {
                var self = this,
-                       $link = $( '<a title="Select" data-dismiss="modal">' 
).text( title ).attr( 'href', '#' )
-                                       .click( function() {
-                                               self._callback( query, title );
-                                               self._track( 'select' );
-                                               self._track( 'select.category.' 
+ category.replace( /[^a-zA-Z0-9]/g, '_' ) );
-                                       } ),
+                 href = '#' + encodeURIComponent( query );
+
+               var $link = $( '<a title="Select">' ).text( title ).attr( 
'href', href )
+                               .click( function(e) {
+                                       // if one of those keys is presssed, 
the link is opened in a new tab or window
+                                       // instead of being displayed in the 
current tab, so there is nothing more to do here
+                                       if (e.ctrlKey || e.metaKey || 
e.shiftKey) return
+
+                                       $( '#QueryExamples' ).modal('hide');
+                                       self._callback( query, title );
+                                       self._track( 'select' );
+                                       self._track( 'select.category.' + 
category.replace( /[^a-zA-Z0-9]/g, '_' ) );
+                               } ),
                        $edit = $( '<a>' )
                                .attr( { title: 'Edit', href: href, target: 
'_blank' } )
                                .append( '<span>' ).addClass( 'glyphicon 
glyphicon-pencil' )

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: If28748bd75424b030d84250d329375c65f1056be
Gerrit-PatchSet: 1
Gerrit-Project: wikidata/query/gui
Gerrit-Branch: master
Gerrit-Owner: Maxlath <k...@maxlath.eu>

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

Reply via email to