aboutsummaryrefslogtreecommitdiffstats
path: root/resources/src/jquery/jquery.suggestions.js
Commit message (Collapse)AuthorAgeFilesLines
* build: Fix and re-enable eslint rule unicorn/prefer-includesJames D. Forrester2025-03-211-2/+2
| | | | Change-Id: I34bb289e941751ae4722c708511326a2a5431bfc
* eslint: Manually enforce prefer-const in all remaining codeEd Sanders2024-10-051-8/+7
| | | | Change-Id: Ic9f254b55d3936f351ba9c7cc3b553544fc63a58
* eslint: Manually fix remaining no-var warningsEd Sanders2024-09-121-2/+3
| | | | Change-Id: I909e59288cea9afd1f832180eabbc375f505ed41
* eslint: Autofix var to let/constEd Sanders2024-09-121-24/+24
| | | | | | | Temporarily disable no-var & prefer-const as resulting errors need to be fixed manually. Change-Id: I6cb62a2c70a4c1fc265a00b1f18af127ac9d5029
* Merge "docs: Document jQuery plugins with modules"jenkins-bot2024-06-151-85/+91
|\
| * docs: Document jQuery plugins with modulesapaskulin2024-06-151-85/+91
| | | | | | | | | | | | | | | | | | * Moves jQuery plugins from a namespace to individual module pages to be more clear about installation requirements. * Removes jQueryPlugins namespace from types and landing pages Bug: T353357 Change-Id: I5634f2e4e759dafb618aecf6361a2bcb7ba1f829
* | ESLint: Enforce prefer-arrow-callback and autofixEd Sanders2024-06-111-13/+13
|/ | | | Change-Id: Iddfa574e42e569ac5e2a2b098ad2f11ca80c5955
* docs: Fix JSDoc syntaxapaskulin2024-03-261-1/+1
| | | | | | | | Various fixes for typos, punctuation, examples, and links Bug: T360241 Bug: T360475 Change-Id: Ib1061b1cd008b947071dde9900d87fd9e0c9d32c
* docs: Migrate @mixins tags to JSDocapaskulin2024-03-051-1/+1
| | | | | Bug: T357811 Change-Id: I2f7d9d79ffcb7aafbec4d9fbb0e4e2fe78d515bb
* Documentation: Move to exclude listJon Robson2024-01-161-1/+1
| | | | | | | | | * Generate documentation for all files in resources/src * Include all files documented in phase 3 as not having public APIs. Add @ignore tag to documentation that shows up in published document. Bug: T352308 Change-Id: I5d643d815ffa2f578d12bb9ca70e26558a442c32
* Document jQuery pluginsJon Robson2024-01-081-7/+5
| | | | | Bug: T352308 Change-Id: Id3a0ec3d71e4e2966baf46f43652001c3b00674a
* src/jquery: Move var declarations inlineEd Sanders2022-07-251-27/+20
| | | | Change-Id: Ie977d8ff13daf790aa28632f34b51f1a2b7ec4d3
* Always $-prefix jQuery variable namesEd Sanders2019-10-081-43/+47
| | | | Change-Id: I82d7788fbd01b73fc8a3255d5af2de75c85279e1
* Preserve grapheme clusters in upper corner completion suggester highlightingtjones2019-08-291-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Grapheme clusters in Indic scripts can be split by highlighting, resulting in really ugly text in the suggestions. For example, म + े should equal मे, but doesn't if highlighting markup comes between the two characters. Affected scripts include Devanagari, Tamil, Telegu, Thai, Myanmar, Khmer, and Javanese, and probably others. Latin and Cyrillic script also have the problem, but the presentation is not as bad (at least on some browser/OS combinations). - Define a comboMarks regex (equivalent to \p{Mark} in other programming languages) and use it in a new highlighting function, prefixPlusComboHighlight, to include trailing combining characters in highlighted text. - Change the calling function to use prefixPlusComboHighlight instead of prefixHighlight. Note: This only fixes problems with **grapheme clusters** in suggestions in the **search box in the upper corner** (upper right in LTR languages, upper left in RTL languages). The main search box on the Special:Search page uses different code. Ligatures, such as Arabic ي + ا becoming يا, are not covered by this simple regex-based solution. Bug: T35242 Change-Id: I915c50180bc2196e0302f27835241624b7837f16
* build: Update eslint-config-wikimedia to 0.13.0Ed Sanders2019-07-051-0/+2
| | | | Change-Id: I7df5840bc97f8bbcd8cfc875c2b48b3061ef2c9e
* Avoid Sizzle's :first/:last selectors. Use $.first()/$.last()Ed Sanders2019-06-271-3/+3
| | | | Change-Id: I11751b812cac1cb1e5590e0e94d1fe7cf4b89f7a
* Merge "jquery.suggestions: Load initial suggestions only when focused"jenkins-bot2019-06-111-1/+1
|\
| * jquery.suggestions: Load initial suggestions only when focusedFomafix2019-06-101-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | Firefox restores the value of the search field on browser history back on some special pages with OOUI search suggestions. In this case the value of the search field gets also changed before JavaScript gets initialized and the search suggestions get loaded. This change loads the initial suggestions only when the search field is focused and the value is changed before initializing JavaScript. Bug: T224952 Change-Id: I30d334ae61b40666f14c2b6f82fe7f66ebc8fba0
* | Merge "jquery.suggestions: Combine two isRTL checks"jenkins-bot2019-06-101-4/+4
|\ \ | |/ |/|
| * jquery.suggestions: Combine two isRTL checksFomafix2019-06-101-4/+4
| | | | | | | | | | | | Also update comment about the direction. Change-Id: Iba9e925eef3148c2964d51cf5e55402dc85d65dc
* | Merge "jquery.suggestions: Use document.documentElement.clientWidth"jenkins-bot2019-06-101-2/+3
|\ \
| * | jquery.suggestions: Use document.documentElement.clientWidthFomafix2019-06-081-2/+3
| |/ | | | | | | | | | | | | | | | | | | On skins with a border and/or a margin on the <body> or the <html> element the width of <body> is smaller than the width of the window. Also use .appendTo( document.body ) instead of .appendTo( $( 'body' ) ). Bug: T47668 Change-Id: I209eb6e3b95ba0fc6e7c5084242a90ca04c9e196
* / jquery.suggestions: Use Object.create( null )Fomafix2019-06-101-4/+2
|/ | | | | | | | | | | Object.create( null ) creates an Object without predefined methods like hasOwnProperty or constructor. This allow to use key in object instead of Object.prototype.hasOwnProperty.call( object, key ) even if the key is 'constructor'. Change-Id: I6ef9019309022a2a990deda685ba71ca61b86df3
* jquery.suggestions: Remove public object $.suggestionsFomafix2019-05-311-459/+448
| | | | | | | | Private functions are sufficient here. Also reorder function declarations to avoid forward references. Change-Id: Idf99e56b6cb1dd0730ea349818fbb2133f941b90
* Consistently use spaces and stars in commentsFomafix2019-05-301-1/+1
| | | | Change-Id: Ia8e005ec65b5a98b12fc1c079604db175b731a88
* jquery.suggestions: Do not show suggestions on prefilled valuesFomafix2019-05-301-4/+6
| | | | | | | | | | | | | Show the suggestions on load only if the current value differs to the defaultValue from the HTML. This prevents suggestions if there is already a prefilled value in the input field. Also direct call $.suggestions.update() instead of trigger a keypress. This change is a follow-up to 72f61f7a5930cf03d4e8ddde62c2ef627b05dd69. Bug: T224524 Change-Id: I501596996a20c62d1497bf66e23c7858b58bf4ea
* jquery.suggestions: Trigger keypress on initializingFomafix2019-05-161-1/+4
| | | | | | | | | The keypress event triggers a search suggestion window when there are already typed characters in the search field while loading the JavaScript. Bug: T223422 Change-Id: I2bd79722ab20cde268fdb43338096c792b95ea28
* jquery.suggestions: Correctly place dropdown for inputs with 'position: fixed'Bartosz Dziewoński2019-04-011-4/+19
| | | | | | | | | | If the input has 'position: fixed', or is within another element with 'position: fixed', then the dropdown must also have 'position: fixed' and its position has to be calculated relative to viewport rather than relative to document. Bug: T210321 Change-Id: Iae795ef03d888c2b8cc1d5e7463c4692a7eeb138
* build: Update eslint-config-wikimedia to 0.10.1Ed Sanders2019-02-021-9/+0
| | | | Change-Id: Id98af16c1ec1c6c4a790948a35e96e2fe925ebb5
* Fix more jquery event shorthand usagesEd Sanders2019-01-181-3/+3
| | | | | | Not yet caught by the linter. Change-Id: I9601bff47c099c4901487e7faaf871f23e2e2d1c
* build: Update eslint-config-wikimedia to 0.10.0Ed Sanders2019-01-081-12/+21
| | | | Change-Id: I2930bcabeeb7b7b2eb36063e77b26e664a691b43
* build: Use eslint-config-wikimedia v0.9.0 and make passEd Sanders2018-11-231-3/+3
| | | | Change-Id: I7b5d228a3de4b3006751a427dec907a5bebf2f51
* resources: Strip '$' and 'mw' from file closuresTimo Tijhof2018-09-141-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Follows-up Id6d13bbea6: - '$': mw.loader.implement does this already. - 'mw': Use the canonical name directly. This replaces the following patterns: File closures (common): - `( function ( $, mw ) {` => `( function () {` - `( function ( $ ) {` => `( function () {` - `( function ( mw ) {` => `( function () {` - `( function ( mw, $ ) {` => `( function () {` File closures (rare): - `( function ( mw, $, OO ) {` => `( function () {` - `( function ( mw, OO, $ ) {` => `( function () {` - `( function ( mw, document ) {` => `( function () {` Combined dom-ready and file closure (rare): - `jQuery( function ( $ ) {` => `$( function () { - `jQuery( function () {` => `$( function () { Remaining references in files without a closure, as found by the new ESLint setting (rare): - `jQuery` => `$` - `mediaWiki` => `mw` Change-Id: I7cf2426cde597259e8c6f3f6f615a1a81a0ca82b
* jquery.suggestions: Remove dead code for returning optionsTimo Tijhof2018-08-171-11/+2
| | | | | | | | | | | | | | | | | | | returnValue = (key in obj) ? undefined : obj[key]; By standard, this cannot return anything other undefined. This code has been broken since the introduction of the module in 2012 (32377424b, r72349). The functionality also didn't have test (naturally), and isn't used anywhere in Wikimedia Git. Simply remove it. Also remove the confusing $() wrapping of the non-getter return value that provides chainability. The 'this' inside a jQuery method is already an instance of jQuery, pulling it through $() again achieves very little. Change-Id: Id13861d42b65a759d74670d8c5850aecee4daf7d
* Fix eslint warnings and switch to error codejdlrobson2018-08-141-1/+1
| | | | | | | | | | | | Follow up to I4552191f639b1022cb085ef5eb4abda835c2d91c * Add eslint-ignores to various files * Correct various uses of isFunction, trim, map, grep where easy fix is available * Switch from eslint warning to error Bug: T200877 Change-Id: I8420db21e548772332e51769aa8ec92d5958715f
* Use native ES5 Array prototype methods instead of jQueryFomafix2018-01-121-2/+2
| | | | | | | | | | | | | | | | | | | Replace * $.each( array, function ( index, value ) { ... } ) by array.forEach( function ( value, index ) { ... } ) * $.grep( array, function ( value ) { ... } ) by array.filter( function ( value ) { ... } ) * $.map( array, function ( value ) { ... } ) by array.map( function ( value ) { ... } ) * $.inArray( value, array ) by array.indexOf( value ) This change is a follow-up to 1edba8029a561919febf8b90f5df689d090665dd. Change-Id: I16134642c52002de0eacb987bed5143f528bf627
* build: Upgrade grunt-eslint from 19.0.0 to 20.0.0Ed Sanders2017-07-181-3/+1
| | | | | | Most indent and escaping fixes. Change-Id: I210e2fc3c0ce3148327ef81f824e1ce9f1e269b6
* Ensure we use mw.now() instead of 'new Date' for relative measurementTimo Tijhof2017-03-251-4/+4
| | | | | | | | | 'new Date' is subject to clock drift etc. mw.now() uses performance.now() when available, which will always increase at a constant rate independent of the system clock. Change-Id: Ib653103bf6116544f35c930fb33421f1bb362c7d
* resources: Replace implicit Bugzilla bug numbers with Phab onesJames D. Forrester2017-02-201-2/+2
| | | | | | | | It's unreasonable to expect newbies to know that "bug 12345" means "Task T14345" except where it doesn't, so let's just standardise on the real numbers. (This is just for resources/src for now; includes/ will be another day. :-)) Change-Id: I5c55bab4f7c8a26dda43de7d169cc7bddc74adc3
* jquery.suggestions: Only highlight prefix matchesBartosz Dziewoński2017-02-061-1/+1
| | | | | | | | * jquery.highlightText: Add an option to highlight a prefix only. * jquery.suggestions: Use the new option. Bug: T27187 Change-Id: I097f012d2022334bbdb8cb32b256ae978aec57c7
* build: Replace jscs+jshint with eslintEd Sanders2016-11-151-4/+3
| | | | Change-Id: Id0a23c03aabadfaf2ec705528ae4b3bd0908fa3e
* autocomplete: fix duplicate/missing tracking eventsErik Bernhardson2016-06-201-9/+9
| | | | | | | | | | | | The submit-form and click-result handlers are in some cases being fired for the same user interaction. The causes duplicate events to be collected from WikimediaEvents. See also Ic1e0d08d for tests of this functionality along with updates necessary to ensure all the right events are showing up on the backend. Additionally adjusts to ensure all reports of position selected/clicked are 0 indexed. Change-Id: Ie7348e470754746c85f53dbe447b88176c2a0bcc
* js suggest: better keyup/keydown handlingErik Bernhardson2016-06-201-3/+17
| | | | | | | | | | | | some actions, like ctrl-click, trigger the keyup event even though it has no bearing on autocomplete. This leads to extra impression-results tracking events being fired. The existing keypress event, per spec, handles input that normally produces a character value. The keyup / keydown events should only be handling special non-character producing keys that directly effect autocomplete. As such put together a list of relevant keys and only fire on those. Change-Id: I8d2a4fade84a5b94a81fa7ee0192912d2407ba92
* jquery.suggestions: Fix typo "singleton" in documentationTimo Tijhof2016-03-241-1/+1
| | | | Change-Id: I81af9a1974ea9c9dcd26f201bf055554087ccd99
* Add additional tracking information to mediawiki.searchSuggestErik Bernhardson2016-03-041-3/+4
| | | | | | | | | | | | | | | | | Adds a few pieces of information to improve tracking of autocomplete usage. * When using Special:Search 'go' feature forward wprov parameter to redirect * Include a data attribute indicating autocomplete location to differentiate usage of the header and Special:Search content autocompletes * Report exact query string that was used for impression-results * Add handling to allow searchSuggest subscribers to append tracking information to generated article links * Add a new hook, SpecialSearchGoResult, that can either change the url redirected to in the 'go' feature or cancel it entirely. Bug: T125915 Change-Id: Iec7171fcf301f1659d852afa87ce271f468177c1
* jquery.suggestions: Improve comment about avoiding click interferenceTimo Tijhof2015-12-181-2/+2
| | | | Change-Id: I971f6163f08cd419c29cac372157c0336b5fd132
* Update grunt-jscs to 2.5.0Paladox2015-12-091-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | 2.5.0 Bump JSCS version to 2.7.0 2.4.0 Bump JSCS version to 2.6.0 2.3.0 Bump JSCS version to 2.5.0 2.2.0 * Update jscs dependency to 2.4.0 * Use new Checker#execute method, which allows to respect maxErrors * option when fix option is enabled * fix option is now directly passed to Checker class of jscs * Use new "idiomatic" preset instead of "jquery" * Test in latest version of node in travis CI * Update dev dependencies https://github.com/jscs-dev/grunt-jscs/releases Change-Id: I472a3c63fff814357799a3889b09bbb6a977474b
* build: Enable jscs jsDoc rule 'checkParamNames' and make passJames D. Forrester2015-09-231-599/+613
| | | | Change-Id: Ib7282e601b1cade506c16d7bac93a197633738cc
* build: Enable jscs jsDoc rule 'checkRedundantReturns' and make passJames D. Forrester2015-09-231-1/+3
| | | | Change-Id: I5006ea3df6798201edfacbf8ad4624266554f064
* build: Enable jscs jsDoc rule 'requireNewlineAfterDescription' and make passJames D. Forrester2015-09-071-0/+4
| | | | Change-Id: I14d699f66cef87f0d93d773902c0a5326025a58c