Commit Graph

41 Commits

Author SHA1 Message Date
Stephen Niedzielski 5593b23aa8 Hygiene: replace mobile.startup/paths with props
Replace all occurrences of `M.require( 'mobile.startup/pathToModule' )`
with `M.require( 'mobile.startup' ).pathToModule`. Where multiple
requires existed, add an intermediate variable,
`var mobile = M.require( 'mobile.startup' )`, and dot off that.

This changes improves the consistency of MinervaNeue which currently
contains a mix of require styles and eliminates any deprecated requires.

Bug: T208915
Change-Id: If14f280672d914d07275197100b12421bb217b67
2019-02-07 14:55:04 -07:00
Stephen Niedzielski 0dfdbadb4b Hygiene: migrate View.events to constructor prop
Migrate View.events to constructor property. MobileFrontend supports
both the deprecated View.prototype.events and recently passing events as
an argument at construction (see dependent patch).

As a client, Minerva doesn't provide nearly so many extensible classes
as MobileFrontend. The classes changed in this patch are no different so
events are not expected to be extended.

Bug: T208915
Depends-On: Ic193e97b4cd6f72d226bd9768e904bdec168ba39
Change-Id: I68923e2dfd4b2f3e3f3de5185e9b65ab0b665ab7
2019-02-05 22:03:37 +00:00
Ed Sanders 63ead8075d build: Update eslint-config-wikimedia to 0.10.0
* Add inline exceptions for global selectors
* Exception for $.animate in scrolling code
* Fix $ prefixing in search.js
* Fix repeated selectors in search.js & toc.js
* Disable no-parse-html-literal in tests

Change-Id: Id58fe11d1e09714501a378e4ca7ed9588f02f32d
2019-01-24 17:59:40 +00:00
Ed Sanders 6c53e320bf eslint: Remove exception for computed-property-spacing
Change-Id: Ief22145c02379bdb3d37c96c5e1ef50f0ab519cf
2019-01-24 17:58:36 +00:00
jdlrobson 76be18c788 Tablet code no longer needs to be conditional
The TableOfContents component is now inside mobile.startup
so is readily available.
Thus skins.minerva.tablet.scripts is removed and its code
moved inside skins.minerva.scripts

The check to whether the user is in tablet mode
now happens inside toc.js

The resize handler is dropped on the basis that this is an edge
case that is not worth supporting at the cost of an eventBus.

Depends-On: I353d6d7a6884dae03b55364150c6bb95cd4cc57f
Change-Id: Id16a64573e020b4606fc9b11456163a4cd290e0b
2019-01-14 15:43:50 -08:00
jenkins-bot 0282bb16ca Merge "Composition: DownloadIcon" 2019-01-03 16:41:34 +00:00
jdlrobson c73ff1f7a5 Composition: DownloadIcon
The DownloadIcon is reduced to a factory function that
returns an instance of Icon

Depends-On: I4d703eef68d51bbe0b03579c5cca0845e17b8c9d
Depends-On: I4a4129b2cac7c7c49559beef0b8780f3211edf9c
Bug: T205592
Change-Id: Ib87390d17bef6f50842f52cd84c9ce2b162aaff0
2019-01-02 13:16:09 -08:00
Stephen Niedzielski 9f70a004c7 Hygiene: revise CtaDrawer.events to options
Use CtaDrawer.options.events when available instead of CtaDrawer.events.

Change-Id: I7cf5d97bef9179dfa148fa4d5ca447d128031b57
Related: I4a4129b2cac7c7c49559beef0b8780f3211edf9c
Bug: T210870
2018-12-20 19:31:58 +00:00
Nicholas Ray 5bfd949f9a Remove usage of global event emitter from Minerva
This patch removes the remaining usages of M.on/M.off/M.emit
(functionality derived from moduleLoader.js in MobileFrontend) in
Minerva and continues the work of
Id990b0e1a53221d5c1cb3e3012aed0e27d801fc2 (patch for MobileFrontend).

This patch and the patch for MobileFrontend should be merged together as
they both depend on eachother.

Depends-On: Id990b0e1a53221d5c1cb3e3012aed0e27d801fc2
Bug: T156186
Change-Id: I005d2fcdbf91c2f1ac98178dfa388aa8174e7530
2018-12-06 19:30:09 -07:00
LukBukkit 9e114731ce
Don't open images if control keys are pressed
This replicates the behavior of the MultimediaViewer on the
desktop when using the mobile page with a desktop browser.

But we have to be careful that this change don't break
other extensions or functions of the skin.

Bug: T206348
Change-Id: Ib4b928eae136d781782dc96e82d653806587292b
2018-11-19 22:10:19 +01:00
Ed Sanders def03877ce Remove obsolete aliases from closures
Bug: T208951
Change-Id: I7cd5ab010596d964fc0896ed250f40d5b6344f6e
2018-11-16 15:16:25 +00:00
jenkins-bot 90629a0578 Merge "Move canEdit checks to server from client" 2018-11-09 22:07:47 +00:00
arcayn c64a4cf811 Move canEdit checks to server from client
Bug: T206262
Change-Id: I08bfc56998f4fb42c8ce76cc2ad9fba83106d476
2018-11-09 21:26:49 +00:00
Bartosz Dziewoński 7bbba14ee1 skins.minerva.scripts/init: Use singleton OverlayManager from MF
Bug: T198765
Depends-On: Ie83846e7dfabe302006d0979f2f21913839e1795
Change-Id: I9c07863ab9c68886d6c5b5f09756e034a4d96477
2018-11-08 16:14:40 +01:00
Bartosz Dziewoński 53a80e1bcc Move edit link enabling/disabling out of skins.minerva.editor
These CSS classes are specific to the Minerva skin and we want to move
this file to MobileFrontend.

Now that this code is all in one place, I noticed that it seems to not
do much at all… Everything in this function looks like it could just
be done in the PHP code. If PHP does it all, then we could remove all
of it for a free performance improvement.

Bug: T198765
Change-Id: I6487c2fc520e14e0856b2e9a6f9dfa5066205817
2018-10-04 14:03:19 -07:00
Bartosz Dziewoński 1a89047d3b Move redlink CTA out of skins.minerva.editor
It is not part of the editor. Redlinks are part of page content.

Bug: T198765
Change-Id: Iee77a228b6f2db1c5f2e85226d6cc1c6a73a89be
2018-09-27 20:13:16 +00:00
jenkins-bot ba827d4b3c Merge "Revert "Minerva is responsible for turning on WikimediaEvents itself"" 2018-09-26 20:42:38 +00:00
Bartosz Dziewoński a773c0eed2 Allow mobile TOC on pages in all namespaces
It was limited to the main namespace since its introduction in
Ieabe8f7071696cde6afbdc6df853aacdb741a4a3. Unfortunately that
commit does not explain the reason.

It should be shown e.g. on user pages (so that sandbox pages
look like the real article) or on project pages (many policy
or help pages on Wikipedia are long and would benefit from it).

It looks like some of the CSS code already assumed that the
TOC would be shown in all namespaces (space for it was reserved
using a 'visibility: hidden;' element on all pages).

Bug: T205312
Change-Id: Id6935f5a7a3701c1c7a38fb37b48b6a3bbc80393
2018-09-25 11:49:25 +02:00
Jdlrobson abf445ec9b Revert "Minerva is responsible for turning on WikimediaEvents itself"
While harmless, this patch is not needed if we take a
different approach as discussed in
https://phabricator.wikimedia.org/T204144#4612790

This reverts commit 01dc9de92e.

Change-Id: Id2fdd8677042121142ab2663edfa0ee400b8bf22
2018-09-24 22:52:12 +00:00
jdlrobson 01dc9de92e Minerva is responsible for turning on WikimediaEvents itself
Unlike other skins, Minerva wants to be in charge of when WikimediaEvents
is loaded, so that it can guarantee load order happens at a time that
suits it.

WikimediaEvents will be loaded after initialisation of the interface.
This allows Minerva to enable schemas such as ReadingDepth conditionally.

Upon merging this patch, Ibb45f40ea301727c0c6480043760bd9426106845 can
be merged which will revoke WikimediaEvent's ownership.
Merging in this order will ensure that ReadingDepth  is never
removed from production.

Bug: T204144
Change-Id: If8395033f31485aca0ca3b38fda1be985369b481
2018-09-19 22:09:26 +00:00
Timo Tijhof c1fe42fede Hygiene: Use early returns in a few places for special cases
When handling special cases that are logically distinct from
the function's main branch, it improves code quality (through
readability and maintainability) to place those first and with
an early return.

The has the benefit of the main return statement being easy to
find at the end of the function. (Not early and/or in a block).

It also means when working on the code, there is generally a
less complexity and fewer nesting levels, given that most code
is in the main branch. This makes is easier and quicker to verify
that code does what it should, as well as making it easy to
extend in the future. When considering to add code to end of a
function's main scope, it should relate to the function's main
branch by default, not a special case. For example, a getName()
method should not end with a top-level statement 'return false'
(unless it is a stub). Rather, one would expect it to end with
`return name`.

Change-Id: I1f3088f2409c82dd3bf757fc8fa27dc97ae2767b
2018-09-04 21:08:00 +00:00
jdlrobson ba064c2013 Avoid abrupt and jarring white flash in media viewer
Previously, the image overlay would always be loaded asynchronously.
Given clicking left/right opens a new mediaviewer this left a jarring
white flash. By loading the image overlay synchronously after the first
has been loaded, we avoid this flash.

Note, the task does propose preloading and animating the images
but this is a much bigger change and deemed out of scope for this
particular task.

Additional change:
* Use a shared mw.Api instance for ImageOverlay and PageGateway

Bug: T197110
Change-Id: I28d06b34cdea4fedcd7fb754572191e904ecc81a
2018-08-23 22:55:15 -06:00
jdlrobson 56a10c40e0 Make Deferreds promise compatible
This patch updates the various usages of $.Deferred for loading
overlays in routes to be ES6 Promise compatible

Bug: T188937
Change-Id: I3fc24bf3471a99e7671d1191bdd46cb741286ee1
2018-08-22 14:27:48 -07:00
jdlrobson 40eca4e3f3 Hygiene: IssuesOverlay moved from MobileFrontend to Minerva
The CleanupOverlay is moved to Minerva and renamed the
IssuesOverlay to be consistent with current terminology

The new IssuesOverlay is defined inside the module
skins.minerva.scripts to which it now belongs.

Additional changes:
* various file renames
* overlay-cleanup renames overlay-issues
* cleanuptemplates renamed issues.js
* Add a test stub file to avoid the need to load templates inside
the test environment

After this change, I75f47622d94e504688e04dfb2892540473817053
should be merged to avoid confusion.

Change-Id: I08945a324a6b878abe56efed1e988466085b3018
2018-08-16 14:06:12 -07:00
jdlrobson 100b7951a2 Restore page issues
Follow up to I96808541d48be7869fed3bc30babb80866e139ec
which incorrectly wired up the page issues feature.

Bug: T200867
Change-Id: I7c3198f95dae1f7c5e0991dca651dd64949b3615
2018-08-01 11:34:20 +08:00
jdlrobson 0ca42ee64e Hygiene: Separate cleanups library from initialisation
In order to write tests, we'd like to separate code without side
effects from code that executes it as part of setup.

This shuffles dependencies and makes page and overlayManager
parameters to the init function (injected dependencies)

Change-Id: I96808541d48be7869fed3bc30babb80866e139ec
2018-07-31 11:42:04 +00:00
Stephen Niedzielski 874d9c9e3b Hygiene: update JSDoc boxed and JQuery types
From TypeScript's do's and don'ts:[0]

  Don’t ever use the types Number, String, Boolean, or Object. These
  types refer to non-primitive boxed objects that are almost never used
  appropriately in JavaScript code.

Although Minerva only uses JSDocs at this time which seemingly doesn't
care about casing[1], we should endeavor to use the proper return types.

This patch lowercases typing to indicate primitive / boxed type as
appropriate.[2] As a special case, function types are uppercased for
compatibility with TypeScript type checking.

Also, JQuery types are of type "JQuery". The global JQuery object's
identifier is "jQuery". This patch uppercases J's where appropriate.

Lastly, replace unsupported type "Integer" with "number" and a comment.

[0] https://www.typescriptlang.org/docs/handbook/declaration-files/do-s-and-don-ts.html#general-types

[1] https://github.com/jsdoc3/jsdoc/issues/1046#issuecomment-126477791

[2] find resources tests -iname \*.js|
    xargs -rd\\n sed -ri '
      s%\{\s*(number|string|boolean|object|null|undefined)%{\L\1%gi;
      s%\{\s*function%{Function%g;
      s%\{\s*jquery%{JQuery%gi;
      s%\{\s*integer\s*\}%{number} An integer.%gi
    '

Change-Id: I6cbac15940e4501aee7ede8f421b77ffd027170d
2018-07-03 11:10:12 -05:00
Stephen Niedzielski 41a43c5ce1 Hygiene: remove window.location use from overlays
Bug: T173539
Depends-On: I158dd7883be2846cf0d48bbd7e89fe2cd64a57d3
Change-Id: I87741667ca06cc701e5265aff13ba0492501de26
2018-03-07 17:13:59 -06:00
Stephen Niedzielski 27bc7e7212 Chore: move window.location use to client
Move window.location manipulation from ImageOverlay view to MinervaNeue.
Also, don't leave a hanging empty URL fragment when closing the overlay.

Bug: T173539
Related: I292c0578716ff56e0e069aa8006f840025d78a88
Change-Id: I56ba9217aa9cd4e0a925c623060022392e3021c7
2018-03-06 08:35:48 -06:00
jdlrobson 326ec90cd5 Disable download button on Chrome like browsers
Add Dolphin, Opera and Maxthon to whitelist

Bug: T182059
Change-Id: I39bf9d016aba189016b2ce5b42a2e95b58cb33ce
2018-02-01 10:59:18 -08:00
Piotr Miazga 4ca5666c06 Show Download button only on Android >= 5 & Chrome >= 41
Changes:
 - moved DownloadButtton checks & initialization to separate function
 - introduced supportedNamespaces variable for better readability
 - reorganized huge if(){} statement to set of smaller if's with
 nice comments why this configuration is not supported
 - introduced getAndroidVersion and getChromeVersion helper functions
 - added check to not allow Android < 5 or Chrome < 41
 - added unit tests

Bug: T182059
Change-Id: Ib5064459ee56aed68179389f37b4bc3b5c2c4492
2018-01-16 22:15:07 +01:00
Piotr Miazga 3c4f3a0ddd Send events when user taps download icon
To track "download" button interactions we have to notify
EventLogging that button was clicked. The easiest approach is
to use mw.track() and then in WikimediaEvents subscribe to the
`minerva.downloadAsPdf` events and track page impressions.

Bug: T181297
Change-Id: Iecbebe37c165dda3f26af47906662f6e5a81321d
2018-01-11 18:50:31 +00:00
jdlrobson eaa4dae5af Disable download button in all namespaces except main
The MinervaDownloadIcon config option is replaced with a
more specific wgMinervaDownloadNamespaces config option.
If the list is empty then the download button will not be
shown.

Since the download icon is enabled everywhere in production now
this is good as it means Minerva reflects the production value.

Bug: T181152
Change-Id: Id78c1de9e8e9013530106bc0d45d3cf0297897b5
2017-11-29 20:29:12 +00:00
jdlrobson 7697c262db Limit download button to Google Chrome
As discussed on ticket the download button only appears
to work on Google Chrome on mobile browsers.

Bug: T179529
Bug: T179914
Change-Id: I8bbda8d5a8aa42dd23773fea424c1a70e31d6f85
2017-11-09 21:11:02 +00:00
jdlrobson 58729578ae BetaOptin now managed by MobileFrontend
Depends-On: I83dc2165081332453cd6fc586ae7a3ba04bd3416
Change-Id: I11200f0ff90b359e363ea7a95bf4f3b9e92a67b4
2017-10-30 17:23:41 -07:00
jdlrobson 571895b754 Disable print button on iOS
As documented on the ticket, iOS does not provide PDF functionality
via print.

iOS 11 provides PDF generation but the resulting PDF is unreadable for
our content and missing styles (see T177215#3700576) and we do not know
of any way to invoke that just yet.

Bug: T177215
Change-Id: I7e195ae067625c7865dccee31fa7a2c3c0ee57e5
2017-10-23 16:06:25 -04:00
jdlrobson 45a1b3b423 Add feature flagged DownloadIcon
Shortcut for print. Disabled by default and controlled by
wgMinervaDownloadIcon

Note that with lazy images enabled, images will not appear
in the printed article. This can be easily addressed inside
the onClick function in a later patchset with a few modifications
to the Skin class.

Currently the flag when enabled will show on all browsers. There
are some open questions on the ticket about how we want to limit
the feature. This shouldn't block review or merging.

Bug: T177215
Change-Id: I49f1736870c743990b3fb9916247e07a597b2f59
2017-10-23 18:12:20 +00:00
jdlrobson c04c58a4d7 Minerva is responsible for loading tablet modules in tablet mode
Since Minerva is the only skin which does this kind of thing, it
was premature to add this logic to the Skin module.

By forcing Minerva to do this itself, we allow MobileFrontend to
be responsible for creating a Skin without having to know about
what that skin may want to load in tablet mode.
(see I8503c26bd064ae0d203f95a35031468c7c678ac1)

Bug: T173454
Change-Id: I32e2b4a10799a06138bfee08abc6769a6b96004d
2017-10-11 15:41:46 -07:00
jdlrobson 38474ed73f Hygiene: Cleanup initialisation files
* Remove deprecated module definitions
* Remove unnecessary check for Minerva skin (this is only
ever run by Minerva skin)
* Move overlayManager to place it is first used
* Make Skin::getMainMenu method redundant

Change-Id: I17ea52172e7fae0a8f0e06b8418c7ed5bb01ef64
2017-09-07 17:48:58 +00:00
jdlrobson 9500297090 Don't show ImageOverlay in desktop mode - delegate to multimedia viewer
Bug: T169622
Change-Id: Ie34297a56f8571b161802ea8a708a8bed37c9173
2017-07-27 15:26:31 +00:00
jdlrobson 2cc9516cde Minerva is its own skin
This is programmatic output from python3 scripts/migrate.py

This will result in a Minerva skin dependent on MobileFrontend.

Post merge we will rename message keys to have minerva- prefix

Bug: T166748
Change-Id: Iff1f7e63e796cc5d4a6d2ab0370e0c33248d2fce
2017-07-12 08:12:40 -07:00