From 36784f7c35c6434e5083e28bdc7f45db974fec2f Mon Sep 17 00:00:00 2001 From: Florian Date: Tue, 19 Apr 2016 19:30:39 +0200 Subject: [PATCH] Search: Change dataLocation default value and add docs Implemented Krinkle's comments of the followed up commit. Follow up I2480149 Change-Id: I8e51c0d3a3ca1690ea3ea08469a1cd52d9c151f3 --- includes/specials/SpecialSearch.php | 1 + includes/widget/SearchInputWidget.php | 4 +++- .../src/mediawiki.widgets/mw.widgets.SearchInputWidget.js | 5 ++++- 3 files changed, 8 insertions(+), 2 deletions(-) mode change 100644 => 100755 includes/widget/SearchInputWidget.php mode change 100644 => 100755 resources/src/mediawiki.widgets/mw.widgets.SearchInputWidget.js diff --git a/includes/specials/SpecialSearch.php b/includes/specials/SpecialSearch.php index 15bf39b920..d474ba5222 100644 --- a/includes/specials/SpecialSearch.php +++ b/includes/specials/SpecialSearch.php @@ -1238,6 +1238,7 @@ class SpecialSearch extends SpecialPage { 'name' => 'search', 'autofocus' => trim( $term ) === '', 'value' => $term, + 'dataLocation' => 'content', ] ); $out = diff --git a/includes/widget/SearchInputWidget.php b/includes/widget/SearchInputWidget.php old mode 100644 new mode 100755 index 5ff411df4e..6baaff05cf --- a/includes/widget/SearchInputWidget.php +++ b/includes/widget/SearchInputWidget.php @@ -16,6 +16,7 @@ class SearchInputWidget extends TitleInputWidget { protected $performSearchOnClick = true; protected $validateTitle = false; protected $highlightFirst = false; + protected $dataLocation = 'header'; /** * @param array $config Configuration options @@ -24,6 +25,8 @@ class SearchInputWidget extends TitleInputWidget { * @param boolean|null $config['performSearchOnClick'] If true, the script will start a search * whenever a user hits a suggestion. If false, the text of the suggestion is inserted into the * text field only (default: true) + * @param string $config['dataLocation'] Where the search input field will be + * used (header or content, default: header) */ public function __construct( array $config = [] ) { $config = array_merge( [ @@ -31,7 +34,6 @@ class SearchInputWidget extends TitleInputWidget { 'maxLength' => null, 'type' => 'search', 'icon' => 'search', - 'dataLocation' => 'content', ], $config ); // Parent constructor diff --git a/resources/src/mediawiki.widgets/mw.widgets.SearchInputWidget.js b/resources/src/mediawiki.widgets/mw.widgets.SearchInputWidget.js old mode 100644 new mode 100755 index 8c2b53af26..df03679980 --- a/resources/src/mediawiki.widgets/mw.widgets.SearchInputWidget.js +++ b/resources/src/mediawiki.widgets/mw.widgets.SearchInputWidget.js @@ -18,13 +18,16 @@ * @cfg {boolean} [performSearchOnClick=true] If true, the script will start a search when- * ever a user hits a suggestion. If false, the text of the suggestion is inserted into the * text field only. + * @cfg {string} [dataLocation='header'] Where the search input field will be + * used (header or content). */ mw.widgets.SearchInputWidget = function MwWidgetsSearchInputWidget( config ) { config = $.extend( { type: 'search', icon: 'search', maxLength: undefined, - performSearchOnClick: true + performSearchOnClick: true, + dataLocation: 'header' }, config ); // Parent constructor -- 2.20.1