[MediaWiki-commits] [Gerrit] Autocomplete search operators - change (mediawiki...Translate)

2015-10-05 Thread jenkins-bot (Code Review)
jenkins-bot has submitted this change and it was merged.

Change subject: Autocomplete search operators
..


Autocomplete search operators

Allows a user to easily access search operators with the autocompletion.

Bug: T98559
Change-Id: I168bdcdaf75caf17397c326980a7ddaefb6c3ea3
---
M Resources.php
A resources/js/ext.translate.special.operatorsuggest.js
M specials/SpecialSearchTranslations.php
3 files changed, 47 insertions(+), 0 deletions(-)

Approvals:
  Nikerabbit: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/Resources.php b/Resources.php
index cccb3c2..e95fd3c 100644
--- a/Resources.php
+++ b/Resources.php
@@ -416,6 +416,13 @@
'position' => 'top',
 ) + $resourcePaths;
 
+$wgResourceModules['ext.translate.special.searchtranslations.operatorsuggest'] 
= array(
+   'scripts' => 'resources/js/ext.translate.special.operatorsuggest.js',
+   'dependencies' => array(
+   'jquery.ui.autocomplete',
+   ),
+) + $resourcePaths;
+
 $wgResourceModules['ext.translate.special.searchtranslations.styles'] = array(
'styles' => 
'resources/css/ext.translate.special.searchtranslations.css',
'position' => 'top',
diff --git a/resources/js/ext.translate.special.operatorsuggest.js 
b/resources/js/ext.translate.special.operatorsuggest.js
new file mode 100644
index 000..362a259
--- /dev/null
+++ b/resources/js/ext.translate.special.operatorsuggest.js
@@ -0,0 +1,39 @@
+/*
+ * Autocomplete search operators.
+ */
+( function ( mw, $ ) {
+   'use strict';
+
+   function autocompleteOperators( request, response ) {
+   var operators = [ 'language:', 'group:', 'filter:' ],
+   result = [],
+   lastterm = request.term.split( ' ' ).pop();
+
+   $.each( operators, function ( index, value ) {
+   var pos = value.indexOf( lastterm );
+   if ( pos === 0 ) {
+   result.push( value );
+   }
+   } );
+   response( result );
+   }
+
+   $( '.tux-searchpage .searchinputbox' )
+   .autocomplete( {
+   source: autocompleteOperators,
+   select: function ( event, ui ) {
+   var $value = $( this ).val(),
+   operators = $value.split( ' ' );
+
+   operators.pop();
+   operators.push( ui.item.value );
+
+   $( this ).val( operators.join( ' ' ) );
+   return false;
+   },
+
+   focus: function ( event ) {
+   event.preventDefault();
+   }
+   } );
+}( mediaWiki, jQuery ) );
diff --git a/specials/SpecialSearchTranslations.php 
b/specials/SpecialSearchTranslations.php
index 2077d69..eac869d 100644
--- a/specials/SpecialSearchTranslations.php
+++ b/specials/SpecialSearchTranslations.php
@@ -65,6 +65,7 @@
$out->addModuleStyles( 
'ext.translate.special.searchtranslations.styles' );
$out->addModuleStyles( 'ext.translate.special.translate.styles' 
);
$out->addModules( 'ext.translate.special.searchtranslations' );
+   $out->addModules( 
'ext.translate.special.searchtranslations.operatorsuggest' );
TranslateUtils::addSpecialHelpLink( $out, 
'Help:Extension:Translate#searching' );
 
$this->opts = $opts = new FormOptions();

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I168bdcdaf75caf17397c326980a7ddaefb6c3ea3
Gerrit-PatchSet: 7
Gerrit-Project: mediawiki/extensions/Translate
Gerrit-Branch: master
Gerrit-Owner: Phoenix303 
Gerrit-Reviewer: Krinkle 
Gerrit-Reviewer: Nemo bis 
Gerrit-Reviewer: Nikerabbit 
Gerrit-Reviewer: Phoenix303 
Gerrit-Reviewer: jenkins-bot <>

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


[MediaWiki-commits] [Gerrit] Autocomplete search operators - change (mediawiki...Translate)

2015-07-15 Thread Phoenix303 (Code Review)
Phoenix303 has uploaded a new change for review.

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

Change subject: Autocomplete search operators
..

Autocomplete search operators

Allows a user to easily access search operators with the autocompletion.

Bug: T98559
Change-Id: I168bdcdaf75caf17397c326980a7ddaefb6c3ea3
---
M Resources.php
A resources/js/ext.translate.special.operatorsuggest.js
M specials/SpecialSearchTranslations.php
3 files changed, 44 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Translate 
refs/changes/53/224753/1

diff --git a/Resources.php b/Resources.php
index 93246b4..2ac9831 100644
--- a/Resources.php
+++ b/Resources.php
@@ -418,6 +418,13 @@
'position' => 'top',
 ) + $resourcePaths;
 
+$wgResourceModules['ext.translate.special.operatorsuggest'] = array(
+   'scripts' => 'resources/js/ext.translate.special.operatorsuggest.js',
+   'dependencies' => array(
+   'jquery.ui.autocomplete',
+   ),
+) + $resourcePaths;
+
 $wgResourceModules['ext.translate.special.translate'] = array(
'styles' => 'resources/css/ext.translate.special.translate.css',
'scripts' => 'resources/js/ext.translate.special.translate.js',
diff --git a/resources/js/ext.translate.special.operatorsuggest.js 
b/resources/js/ext.translate.special.operatorsuggest.js
new file mode 100644
index 000..4628487
--- /dev/null
+++ b/resources/js/ext.translate.special.operatorsuggest.js
@@ -0,0 +1,36 @@
+/*
+ * Autocomplete search operators.
+ */
+( function ( mw, $ ) {
+   function autocompleteOperators( request, response ) {
+   var operators = [ 'language:', 'group:' ],
+   result = [],
+   lastterm = request.term.split( ' ' ).pop();
+
+   $.each( operators, function ( index, value ) {
+   var pos = value.indexOf( lastterm );
+   if ( pos === 0 ) {
+   result.push( value );
+   }
+   } );
+   response( result );
+   };
+   $( '.tux-searchpage .searchinputbox' )
+   .autocomplete( {
+   source: autocompleteOperators,
+   select: function ( event, ui ) {
+   var $value = $( this ).val(),
+   operators = $value.split( ' ' );
+
+   operators.pop();
+   operators.push( ui.item.value );
+
+   $( this ).val( operators.join( ' ' ) );
+   return false;
+   },
+
+   focus: function (event, ui) {
+  event.preventDefault();
+   }
+   } );
+}( mediaWiki, jQuery ) );
diff --git a/specials/SpecialSearchTranslations.php 
b/specials/SpecialSearchTranslations.php
index 17c880e..a4169b7 100644
--- a/specials/SpecialSearchTranslations.php
+++ b/specials/SpecialSearchTranslations.php
@@ -61,6 +61,7 @@
 
$out = $this->getOutput();
$out->addModules( 'ext.translate.special.searchtranslations' );
+   $out->addModules( 'ext.translate.special.operatorsuggest' );
 
$this->opts = $opts = new FormOptions();
$opts->add( 'query', '' );

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I168bdcdaf75caf17397c326980a7ddaefb6c3ea3
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Translate
Gerrit-Branch: master
Gerrit-Owner: Phoenix303 

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