Commit Graph

105 Commits

Author SHA1 Message Date
Santhosh Thottingal
c4ce628768 Use navigator.languages as fallback for mw.uls.getAcceptLanguageList
Follow up: Ib603f836f59f7078ac5dbb7bbbb3b84ca358cb43
Bug: T137522
Change-Id: Ia5de997fe393ce99a91b16ed397811391a85bc59
2016-06-14 04:55:34 +00:00
Niklas Laxström
fa7f7e8b57 Increase the number of stored previously selected languages to 9
Discussion about the magic number in the task.

Bug: T135487
Change-Id: I5d0900f191cf277faa19d73de9cf393216d5e6ea
2016-05-23 12:50:06 +00:00
Niklas Laxström
4f82a8650a Make previous languages have most recent in the beginning
This is already expected by the callers. Added addPreviousLanguage
to make updating the list easier.

Change-Id: Ie4f888235ea4de4a2ce6bf5a9f24955e423e8c48
2016-05-23 14:50:02 +02:00
Santhosh Thottingal
a5034fa95f Avoid references to jquery.uls RL module from ext.uls.init
Checks to see if language is supported can be also done using
jquery.uls.data

Bug: T135210
Change-Id: Ib6b0d31b33be10b38aba713c3c4ba5370a27a8f4
2016-05-17 11:50:15 +05:30
Ed Sanders
3cfb0d67e5 Update linting tools, config, and fix subsequent failures
Change-Id: I41e080915441367b3a2ab2de7d7a096872a2f2e8
2016-04-13 17:13:06 +01:00
Santhosh Thottingal
7d90ecef1d Use localstorage instead of cookie for previous language autonym
Change-Id: I1025a8bbb9fad0cfd326547a09c982925a55e55d
2016-04-12 09:40:50 +02:00
Santhosh Thottingal
a29db92746 Remove the years old cookie to localstorage migration code
Change-Id: Icf82e040b7e3f015cb4cbb9b9c7ed4dee240f017
2016-04-12 06:59:12 +00:00
Santhosh Thottingal
64eab95b94 Remove browser checks and use MediaWiki browser policy
We had a browser check to blacklist all browsers older than IE 8
IE <= 7

But that is no longer required since JS support is not there for such
browsers as per https://www.mediawiki.org/wiki/Compatibility#Modern
We can support all modern browsers listed there and we don't need
additional blacklisting now. From 1.27 onwards, there is no JS loaded
for IE 8 too. So we can just use MW browser support policy.

In this commit, the code to do brower checks removed and simplified
the initialization code. Still I am not happy with the interface module,
that need further refactoring.

Change-Id: I655826c55fb2c7c5c88f16368110142d64a96eec
2016-04-12 12:12:35 +05:30
Santhosh Thottingal
d728d8c8a7 Remove logging the language selection method
Removed the code to log whether map(removed long time back), search,
common languages used for selecting the language.

This logs were introduced to measure and adapt UI effectiveness.
No longer needed now.

Change-Id: I83bdd250cb6474da4fbf22aed2011071b9f9eba4
2016-04-06 09:59:12 +05:30
Siebrand Mazeland
6a2b2e0bba Update test files
- Updated versions and order of checkers.
- Some consistency updates in Gruntfile.js.
- Updates to make jscs pass.

Change-Id: I7ed93596ff383dc713bd17af2da0472be934d59d
2016-02-18 18:51:37 +00:00
Fomafix
cd58ac2f18 Use mw.Api.plugin.options to set user options
This requires MediaWiki version 1.25+.

Change-Id: I3a76b0b4ec403b3acdc29e64b0c750a3b57e252a
2016-02-15 14:13:13 +00:00
Fomafix
0d5c69f655 Do not use setlang to change user language
Requests using GET should only retrieve data and should have no other effect.
(https://en.wikipedia.org/wiki/HTTP_GET_request)

* Use API with POST to change the user interface language in user settings.
* When allowed by wgULSAnonCanChangeLanguage set cookie for anonymous user
  or when API fails.

This change uses mediawiki.cookie which requires MediaWiki 1.24+.

Bug: T46649
Change-Id: Iaf6fafbf200933dfc760be69d2adf5e5efcf8245
2015-09-08 20:21:05 +00:00
Ori Livneh
4088b14304 Fix-up for Ib98499040
Specify { path: '/' } so the cookie is actually removed.

Change-Id: Ia2902a2a4f01b8b5be635afd9d58cc5589623210
2015-09-02 12:36:31 -07:00
Ori Livneh
069fd2c454 Use localStorage to store previous languages, not cookies
Automatically migrates data from uls-previous-language cookie to localStorage.
See associated bug for rationale.

Bug: T110353
Change-Id: Ib98499040b9edf4a1f1d9e3afd7661fc2d1f7fea
2015-09-01 10:38:53 -07:00
Fomafix
69475f0308 Prevent predefined object methods to be interpreted as valid language
Change-Id: I97bb0f8eef6a9361118527cecb4680aeac51b7e1
2015-02-14 12:08:07 +00:00
Fomafix
78d9d155f3 Remove support for MediaWiki version < 1.22
On https://www.mediawiki.org/wiki/Extension:UniversalLanguageSelector
MediaWiki 1.22 or later is required.

Change-Id: Ib1b1db6cddb48318dbcae64797b2fa57d3198747
2014-12-04 22:37:55 +00:00
Ed Sanders
d20c067b76 uls- prefix classes and IDs
Needs to merged with https://github.com/wikimedia/jquery.uls/pull/147
in core.

Change-Id: I860e5ac7f2fc17508cc76fb756d39cbd61aa1afe
2014-08-22 20:56:15 +00:00
Niklas Laxström
fe4e101851 Stop using deprecated jquery.json module
Not loading the "json" module either, because of backwards compatibility
and because we are likely already blacklisting browsers which don't
support json natively (mainly IE7 and older and IE8 not in standards mode)

Change-Id: I80b9eb9a7c224b5c843d42c36aca4c5e9f20c207
2014-07-12 19:20:22 +02:00
Santhosh Thottingal
92652c11b1 Reorganize the compact links code, make it a jquery plugin
No change in functionality. Refactored the code a lot and made it as
a jquery plugin, similar to the other components of ULS

Change-Id: I69199ba37b13ec7fd4a9b7b8eba5b3aa28f0edb5
2014-03-29 10:02:55 +05:30
Santhosh Thottingal
ce383b803e Push selected language to previous languages list
Bug: 62692
Change-Id: I3b40ed1038cec0b34d3b0fbefcae4d4ae650ce36
2014-03-24 12:51:03 +05:30
Thiemo Mättig
5fab7bd738 Make sure script execution doesn't stop by assuming unchecked input is set
These methods aren't designed to return "undefined" or "null".
What they return is not checked. It's assumed to always be an
object (2 of them) or an array (1 of them). This simple patch
does make sure the following code does not fail with TypeErrors.

Bug: 55701
Change-Id: I19f51bbff2209044485b9d7cef4c7654cb5f6425
2014-03-22 15:54:47 +00:00
Timo Tijhof
c6d71015ff Various clean up
Files:
* Consistently have one (1) new line at EOF
  (.gitignore, *.css, *.sh)

JSHint:
* Separate the common (general Wikimedia code conventions) from
  the local more stricter rules (nice work!).

Maintenance:
* Use simplified $IP definition where getenv is only called once.
  Based on http://git.io/ve-mw-36fc3b59-makeStaticLoader

JavaScript:
* Use the same closure in all files:
  - No need for "undefined".
  - One linebreak between license header and start of closure
    (sometimes there were 1 or 2 empty lines).
  - ext.uls.ime.js: No need for "document" (redundant in general,
    but especially as it wasn't used anywhere in this file).
  - Use "$, mw" for all ext.* modules (one of them used "mw, $").

Change-Id: Iba5dab14bbc3fbfc9f8fe96dd2d95529587a69aa
2014-02-08 00:11:50 -08:00
Niklas Laxström
15b3c31029 Avoid loading of jquery.i18n and messages until trigger clicked
Use RL for trigger tooltip messages to avoid using jquery.i18n just
to display the triggers. Reordered dependencies so that messages
are loaded for the setting panels and ime menu.

Change-Id: Ic9518f7b63699542deb02a413e03c28344c99fa4
2014-01-23 23:35:27 +00:00
Amir E. Aharoni
b23f937cb7 Remove the dependency on uls.data
Change-Id: I9fa103ee7d338ed8ea2032c82249a47d022d2c90
2013-11-11 09:56:55 +00:00
Santhosh Thottingal
f5ce066c80 Lazyload jquery.uls library
In the "interlanguage" position ULS is shown after 2 clicks,
so don't load it initially.

In the "personal" position ULS is shown immediately after
the language icon click, so load it, but conditionally.

The new RL module ext.uls.mediawiki is added for setting
jquery.uls defaults in a way that will lazy-load the language names.

Change-Id: Ic33ef034c794a523b5403867196c6098a58eb5b1
2013-11-11 14:13:02 +05:30
Siebrand Mazeland
315cf739bc Update formatting
Change-Id: Iaee2ab4f36d3a0dce143c62965ab29de504b31ea
2013-10-09 15:40:39 +02:00
Amir E. Aharoni
7330295ce2 Use the old way of checking browser support for MW < 1.22
Bug: 52322
Change-Id: I346c1119b2ae841b3dbb2e7b8a5a2d924269b150
2013-08-22 09:32:59 +03:00
Niklas Laxström
ec518a03b4 Provide mw.hook when not provided by older MediaWikis
Change-Id: I8d0826722064551cc46be26215ffb954f39babb0
2013-08-22 09:46:07 +05:30
Amir E. Aharoni
a3bca89a42 Implement language-selection-method event
Change-Id: If2d207f8a221c8f2a560b1399ad69a3032b2064b
2013-08-20 05:16:35 +00:00
Santhosh Thottingal
7649b47f5c Followup I59dfcfb25c, language change work with out event logging
In I59dfcfb25c, for logging events when page is navigating away, we
used callbacks with mw.hook. That is wrong approach. If event logging
is disabled those callbacks will never called: it broke language change
and all use cases which navigates away from current page.

Event logging should not interfere with any ULS functionality. If ULS
functionality depends on callbacks from event logging, it is wrong.

In this patch, we give a small time window to make sure event logging is
fired, but we won't wait for its success or failure.

If eventlogging is disabled, this time window does not exist.

Change-Id: I0b7d9d8b9d1d01b99422010596ebfa80b2589d04
2013-08-19 10:13:56 +00:00
Santhosh Thottingal
117cc5bf46 eventlogger module for ULS
Separating event logging out of ULS functionality. Event logging
is now loosely coupled with ULS. ULS core modules can emit an event
whenever EventLogging is required. The eventlogger module will act
on the event if configured.

Change-Id: I59dfcfb25c1acb85376b56239f2355ee7c4aff1e
2013-08-15 17:08:15 +03:00
umherirrender
92a021e147 TypeError: window.navigator.userLanguage is undefined
This can happen, when the user deletes the pref User languages from the
browser.

Change-Id: Ieaf783fbae113724704e2cce2e166e56935e8ce1
2013-08-12 18:14:49 +00:00
Siebrand Mazeland
8b1e6b911b Fix incorrect documentation
Change-Id: I646a5ccb2ff9e3e7f8871b4e55b55ec881c4301d
2013-08-05 09:23:19 +02:00
Niklas Laxström
425709cdb3 Log language-change for interface language
Change-Id: Icf8067078043be0f3a1c4f2c645835d88414b616
2013-08-02 13:43:18 +00:00
Niklas Laxström
8e1726e745 Log login-click event
Our logEvent wrapper now returns jQuery.Promise too.

Added timeout out parameter to our logEvent wrapper. Unlike
GettingStarted, I didn't create separate logUnlessTimeout
function.

Chrome apparently emulates enter on links as a click, so
this catches enters, left and middle clicks, but not if
the link is opened via right click menu. Might not catch
enter in all browsers.

Change-Id: I4b0eb56e7c7d6e56f8fd99d536f9b60b94a2e09e
2013-08-02 13:03:15 +00:00
Santhosh Thottingal
d92c75518b Delay loading of language settings javascript
Load them when language settings is opened using cog or ULS icon click

Change-Id: I472497c549bff0fd578156fa0113dae2d6a7a7fb
2013-07-26 15:55:07 +03:00
Santhosh Thottingal
2159822145 Update jquery.i18n from upstream, use its default message store
In Iddef0805ab a custom message store was introduced for ULS, but
there were updates in jquery.i18n that allows us to use default
message store again.

(see https://github.com/wikimedia/jquery.i18n/pull/40)

Change-Id: I86cb7a44efa83e5811824cd1104c6be11b1e2925
2013-07-23 15:32:45 +05:30
Santhosh Thottingal
6ac12b6584 Better blacklisting of browsers using $.client
Change-Id: Ibc4d15008671700374fdc1e33d2e85f9899f9b35
2013-07-21 19:36:12 +03:00
Santhosh Thottingal
28154206bf Remove jquery.i18n code that the ULS extension overrides
Instead of using the whole jquery.i18n code, use only required parts
that are not customized in MW ULS. For this define a new RL module
ext.uls.i18n.

Also refactor MW message store for jquery.i18n.

Change-Id: Idda9fe505428ade409d937314d7216ebb4232c36
2013-07-15 13:28:12 +00:00
S Page
234692ba6c Stop uls-previous-languages cookie varying by path
Set path to '/' otherwise you get one cookie for /w and another for
/wiki locations.

Bug: 49155

Change-Id: I4756fdf06b0580b5b57a41cd771b94723bb5cdbf
2013-07-12 13:17:31 -07:00
Ori Livneh
1603fd97a8 Use $.Callbacks to queue events until EL has loaded
This patch provides a workaround for bug 50746. It modifies mw.uls.eventLog so
that it does not directly attempt to log events but instead adds them to a
$.Callbacks('memory once') queue. If EventLogging is not enabled, the Callbacks
object never fires. If EventLogging is enabled, it is requested via
mw.loader.using, but only after $(document).ready. This prevents ResourceLoader
from attempting to inject it via document.write. The mw.loader.using callback
sets the schema defaults and calls .fire on the Callbacks object, causing the
EventLogging event queue to be processed. Tested on Opera 12 and Chrome 30 on
OS X.

Bug: 50746
Change-Id: I89cf06990ee85e70698149b4812d7900218e4fb4
2013-07-09 01:48:06 +00:00
Siebrand Mazeland
b5b6aa15f4 Simplify if-statement
Change-Id: Icc91ed0650297935538a6398f4a540899b677317
2013-07-08 14:29:00 +02:00
Santhosh Thottingal
0145529035 Documentation for mw.uls.init
Bug: 50858
Change-Id: Iada465a8228955bf24f7a4628bf2288b3fe0c0ac
2013-07-08 12:40:49 +05:30
Santhosh Thottingal
3d6e4a007f jquery.i18n message store for ULS
Bug: 49935
Change-Id: Iddef0805abbf9b4ff0e606fc311c57e9dfa7107d
2013-07-08 06:55:21 +00:00
Santhosh Thottingal
8ddff0b2fc Use single entry point mw.uls.init for all ULS ui initialization
Change-Id: I485ea27deebb530eb89e4b0935eda01a5276f884
2013-07-04 17:05:10 +00:00
jenkins-bot
ea50b8216c Merge "Allow loading redirects in Common languages" 2013-07-04 13:00:49 +00:00
Amir E. Aharoni
b6698228d4 Allow loading redirects in Common languages
Bug: 49847
Change-Id: Ia2380a77ebad789a2f70a7a88a1bb9970199b1c5
2013-07-04 12:55:39 +00:00
jenkins-bot
7b9f4c863c Merge "Prepare ULS for EventLogging" 2013-07-03 10:42:43 +00:00
Niklas Laxström
4543d43dda Prepare ULS for EventLogging
This change introduces a new configuration variable, $wgULSEventLogging. When
set to true, ULS will register an EventLogging schema module for
<http://meta.wikimedia.org/wiki/Schema:UniversalLanguageSelector>,
making it possible to log events using `mw.uls.logEvent`. When false, the
schema module is not loaded, and `mw.uls.logEvent` is a no-op.

Change-Id: I7139e67cc2f830a6b4b3c8ff1fc72dfcdec9a699
2013-07-02 12:47:22 +00:00
Santhosh Thottingal
2776a28d58 ULS i18n performance fixes
* Since there is an API to load the i18n json files, avoid sending
  list of localizations to client. Previously this list was used to
  avoid 404s for json files. Now API takes care of it. Remove the
  caching for this list too.

* Preload the i18n files on document ready. This avoids delay in
  initializing IME or ULS window after fetch i18n from server.

* ApiULSLocalization can serve messages for all namespaces known if
  namespace parameter is not set

Bug: 50391
Change-Id: I6b848da35f57353790bf460983cdf19a11bb238a
2013-06-30 18:08:19 +05:30