Commit Graph

116 Commits

Author SHA1 Message Date
Amir E. Aharoni
95e50bb37b Shorten a comment line (#464)
Recommended atomatically at
https://github.com/wikimedia/jquery.uls/pull/463/files
2023-07-24 13:41:50 +05:30
Abijeet
8292fe90e3 uls.lcd: Add auto-correcting code when index goes beyond max index
Leave the error logging code in place in order to identify any
other places where this issue occurs.

Bug: https://phabricator.wikimedia.org/T328956
2023-05-29 11:14:13 +03:00
Abijeet
ea8af529a2 jquery.uls.lcd: Handle scenario where selected item is undetermined
Throw an error if during keyboard navigation the selected item could
not be determined.

Bug: https://phabricator.wikimedia.org/T328956
2023-04-18 14:32:17 +03:00
Abijeet
a5a4701792 jquery.uls.lcd: Check if languages are present before highlighting
There might not be any languages if uls empty state is set in ULS
extension
2023-03-13 14:16:12 +02:00
Abijeet
02cd462ec2 jquery.uls.lcd: Add null check for navigationIndex for up navigation 2023-02-16 11:11:11 +02:00
Abijeet
6f1c6a4743 Fix line length warnings 2023-01-16 15:04:12 +02:00
Abijeet
cfbfc5d2ff Remove unused variable and add uls prefix for CSS class 2023-01-16 15:04:12 +02:00
Abijeet
f6b1e5cc6e Add some comments to the code 2023-01-16 15:04:12 +02:00
Abijeet
453cc37341 Fix general and usability issues, add some more features
* Scoll to currently highlighted item if its not visible.
* Fix navigation when list is filtered
* Add support for selecting highlighted item by pressing enter
2023-01-16 15:04:12 +02:00
NikG
31bd5c43db Set navigation index to the selected language item index on hover 2023-01-16 15:04:12 +02:00
NikG
d7f7927ec3 Add caching for language option list items 2023-01-16 15:04:12 +02:00
NikG
f3f14a2098 Fix lint errors 2023-01-16 15:04:12 +02:00
NikG
cd1452eb76 Enable up/down keys for navigating the ULS menu 2023-01-16 15:04:12 +02:00
Amir E. Aharoni
c10140c12b Upgrade eslint-config-wikimedia to 0.21.0
JavaScript code and comments changes:
* Remove no-multi-str disabling.
* Document $ parameter.
* Replace .substring() with .slice().
* Change assert.ok() to assert.strictEqual() in a test.
2022-01-31 11:13:58 +02:00
Abijeet
e3a9a11840 ULS LCD: Check if region exists before adding languages
The regions displayed on ULS depend on the showRegions parameter
passed to uls.lcd plugin. If a new language and region have
been added to the language data, the region for it will not be
available to showRegion because it's static.

Bug: T187553
2021-09-28 15:58:32 +03:00
Ed S
7a6e559fe5 Update eslint and other devDependencies (#391)
* Update eslint and other devDependencies

* Lint JS in examples/ using eslint-plugin-html (#392)
2021-05-14 15:18:37 +05:30
Ed Sanders
d53beca719 Update linters
* Update eslint and stylelint config
* Fix Gruntfile.js to actually run stylelint
2019-11-13 04:14:16 +02:00
Kartik Mistry
27c21219b4 Update package.json and fix eslint issues (#322) 2018-09-06 15:41:27 +05:30
Amire80
2c1b2dd1b8 Group languages in each region by script group
sortByScriptGroup and getLanguagesByScriptGroup are updated from language-data.
(jquery.uls.data.utils should be merged to language-data.)

This resolves downstream bug
https://phabricator.wikimedia.org/T189090
2018-05-22 17:50:44 +03:00
Niklas Laxström
798e200b56 Merge pull request #305 from amire80/T189582
Pass the event object when calling the click handler
2018-03-15 18:15:50 +02:00
Amire80
1120ab276c Update the argument for noResults in lcd
Follow up to #306.
2018-03-15 17:05:01 +02:00
Amire80
f11634e6d3 Pass the event object when calling the click handler
This will allow distinguishing Click and Ctrl/Command-Click.
See downstream bug https://phabricator.wikimedia.org/T189582
2018-03-13 14:34:11 +02:00
Santhosh Thottingal
1f900843fe i18n for the noResultsTemplate
See https://phabricator.wikimedia.org/T187390
2018-02-16 09:34:54 +05:30
Santhosh Thottingal
081310b45e Style adjustments for no-results
* 20px spacing above and below the "No results found" message.
* 12px spacing above and below the search indications ("You can search by...")
* Adjusting the text color to use Base20 (#54595D)
* Adjust the background to use the same background color as the area above it (#FCFCFC).
* Add a top border in Base80 (#EAECF0) to separate both areas.

See https://phabricator.wikimedia.org/T175235
2018-01-30 12:52:47 +05:30
Niklas Laxström
d349937772 Do not group search results by region
* Documentation updates
* Do not group search results by region
* Disable grouping by script when region grouping is disabled
* Add docs, clarify names per code review
* Fix bool -> boolean for consistency
2018-01-16 17:04:29 +05:30
Santhosh Thottingal
2aa43148bb Custom no-results message support (#286)
* Custom no-results message support
* Refactoring and clean up for LanguageCategoryDisplay class
* Document the options for LanguageCategoryDisplay class
* Reduce the spreading of no results handler code
* Add an option to accept no results template
* Remove unwanted, unused constructor too
* Use CSS to hide or show the no-results view
* Remove the unwanted noresults method in jquery.uls.core, directly
  call the same method of lcd.
* Add an example
* Support a function returning jquery element as the no-result handler
2018-01-12 16:05:11 +02:00
Santhosh Thottingal
bccf103900 Removing assigned ids to elements that are not guaranteed to be unique (#284)
It is a bad practice to assign id attributes when there is no guarantee
about the uniqueness of element. ULS should function even if there are
more than one instance of it is present in a page.
2018-01-09 09:47:47 +02:00
Santhosh Thottingal
2a77df6c41 Use eslint and stylelint, fix all errors (#282)
* Use eslint and stylelint, fix all errors

* Remove jshint, jsbeautify
* Use Object.keys directly since that is available in all major browsers
* Fixes for eslint, stylelint errors
* stylelint is not included in grunt test yet because jquery.uls.mobile.css
  has so many !important and need to figure out whether they are really needed
2018-01-04 15:58:35 +02:00
Niklas Laxström
ca550e22cd Improve how "no search results" is handled
* Drop the ugly height: 100% hack and do it properly and remove TODO
* after( $suggestions.show() ) seems to not work as expected in recent
  jQuery versions. Changed it to manipulate the presence of 'hide'
  class properly.
* Consistency fix in a comment
* Fixed a bug where creating multiple ULS instances would break the
  "no search results" functionality. This is because we were appending
  a jQuery element wrapped in a $(). This is obviously a no-op and a
  regression when the template actually was a string and not jQuery.
  Fixed by using clone() on it.

https://phabricator.wikimedia.org/T175233
2017-09-07 11:22:26 +02:00
Amire80
cafe908d07 Move the message attribute to the correct element
Follow up to https://github.com/wikimedia/jquery.uls/pull/243 ,
addressing a comment by @Nikerabbit.
2016-12-04 11:40:45 +02:00
Amire80
7d9d2b7947 Using the message uls-search-help in the code
The translatable message uls-search-help was available in
the i18n files, but it was not actually used in the code,
so it was always shown in English.

This patch adds it to the JS code.
2016-11-28 15:53:55 +02:00
Marius Hoch
6ebd1b413c Use an empty array for quickList everywhere, not false/null
Also fix one type quicklist -> quickList, per @edg2s.

Follows cb85cda10e.

https://phabricator.wikimedia.org/T144871
2016-09-07 02:46:32 +02:00
Niklas Laxström
cb85cda10e Avoid showing suggested languages header if the list is empty 2016-09-02 15:45:14 +02:00
Niklas Laxström
0e253cb312 In narrow mode, print "All languages" heading if suggested languages are given
Also changed one instance of "Common languages" to "Suggested languages" in
the no-i18n fallback code.
2016-08-30 15:12:46 +02:00
Niklas Laxström
8a8f502de7 Style changes to lcd
This change is larger than it should because I came across lots of
unused CSS which I removed or simplified.

https://phabricator.wikimedia.org/T138235
2016-08-17 16:29:08 +02:00
Santhosh Thottingal
bb4d96c33a List the languages in Worldwide in their respective regions too
Fix for https://phabricator.wikimedia.org/T137868
This was a wrong solution for https://phabricator.wikimedia.org/T41921

Change-Id: Ib920e75fca71716d14aecd25c163f0c1e8e63270
2016-07-20 09:55:24 +05:30
Niklas Laxström
25775dd147 Adjust styles and code to support custom list bullets
Tweak specificty of the rule that hides bullets so that it is easy
to override.

Move dir and lang attributes from <li> to <a> so that the bullets
appear on the correct side for reverse directionality scripts.

Change-Id: Ic0d0c5220b0b374c2a3a19023c40d81f3e20007c
2016-06-09 15:08:15 +05:30
Santhosh Thottingal
e9c0f3e4db Show "You may be interested in" section when no results found
This was broken long time back

Change-Id: I15f715067d82fb61959763824183a6813536e94e
2016-05-09 17:09:06 +05:30
Santhosh Thottingal
8b3d77dae1 Support language codes that are redirects
Addressing issue #207

Such language codes were not listed in ULS language list.

Root cause was $.uls.data.getLanguagesByScriptGroup was returning
a map of script groups, which contained only resolved language codes.
And later in append method of jquery.uls.lcd.js, there is a check if
that language code is part of languages list passed as option to uls()
call. This test fails and the language code does not get added to display.

Change-Id: Iec914a9694a46eef5750ef3af7346d66e052ab77
2016-04-05 09:17:09 +05:30
Prateek Saxena
0973ddf299 Construct DOM using jQuery instead of an HTML String 2015-01-26 09:26:57 -08:00
Santhosh Thottingal
f417707d67 Remove the unused code to sync region highlight on scroll
Change-Id: Id779c25237584f90ab9132fe24f6cbade1b58da7
2014-12-22 16:38:03 +05:30
Santhosh Thottingal
499c30d0ea Merge branch 'uls-remove-map' of https://github.com/santhoshtr/jquery.uls into santhoshtr-uls-remove-map
Change-Id: Ie59e2a59225873b5cf432df526cbfc135e539d32
2014-12-22 14:51:46 +05:30
Amir E. Aharoni
f44302106b For narrow ULS show one column without separators 2014-12-22 11:09:48 +05:30
Amir E. Aharoni
6d72638d6f A more explicit support for valid columns number
Only 1, 2 or 4.
2014-12-15 11:27:44 +02:00
Amir E. Aharoni
dd59d4d0c8 CSS tweaks for narrow ULS 2014-12-04 00:39:57 +02:00
Amir E. Aharoni
b55bc61dc7 Grid-compatible adjustable columns 2014-12-02 22:16:09 +02:00
Amir E. Aharoni
752a295ee2 Allow sending the number of lcd columns as a parameter
This is needed for https://phabricator.wikimedia.org/T76196
and may also nbe useful for many other features.
2014-12-02 13:23:22 +02:00
Santhosh Thottingal
022efabf38 Minor formatting changes
Change-Id: I3ffd7029165ff614c13000b333ed30d3874fba28
2014-09-23 16:16:44 +05:30
Santhosh Thottingal
7346469e20 Add decorator option for language links
Callback function to be called when a language link is prepared
Can be used for custom decoration.
Arguments:
(a) the $language - the language link jQuery object
(b) languageCode

The function can do any styling, changing properites etc on the passed link.
See examples/decorator.html for example usage.

Change-Id: I5a67654440a07cf7dfac683e22dcb5000ded0bfe
2014-09-22 12:32:05 +05:30
Santhosh Thottingal
c2b68e8cbc Remove the region selector feature
* Maps removed from UI
* From no-results UI, removed the links to navigate by clicking region names
* Removed the $.fn.regionSelctor plugin, Retained the RegionSelector class
* Removed all related css for the removed UI parts
* Reduced the padding for main ULS title so that the top header takes less height
* And a dozen of related changes

Change-Id: I8ac89ebe380047ca267e5c7720c2eaa3da080e9d
2014-07-27 20:29:01 +05:30