Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Twinkle JS does not reload after RevisionSlider is used to switch diffs #360

Closed
addshore opened this issue Oct 4, 2016 · 4 comments · Fixed by #407
Closed

Twinkle JS does not reload after RevisionSlider is used to switch diffs #360

addshore opened this issue Oct 4, 2016 · 4 comments · Fixed by #407

Comments

@addshore
Copy link

addshore commented Oct 4, 2016

Twinkle should listen to the JS hooks in core and reinit itself.

https://www.mediawiki.org/wiki/Extension:RevisionSlider#JavaScript_Hooks

@terrorist96
Copy link

Sadly I'll have to disable RevisionSlider due to this issue. I'd love to be able to use RS and TW together. No news on this being fixed?

@atlight
Copy link
Collaborator

atlight commented Apr 18, 2017

Twinkle was written well before JS hooks existed in MediaWiki, so that's our excuse. To make matters worse there seems to be no documentation about JS hooks on mediawiki.org, apart from a tiny mention at https://www.mediawiki.org/wiki/ResourceLoader/Core_modules#mediaWiki.hook, so I don't know how we were meant to know that we were able to take advantage of this feature.

Whingeing aside, it doesn't look like that ought to be too troublesome to implement.

@hartman
Copy link
Collaborator

hartman commented May 5, 2017

@atlight

hooks are 'dom events' to which you can add handlers. These handlers are then guaranteed to run whenever the event is triggered. It functions a bit like document.ready, but also works for JS loaded blobs and are in wide use by wikEd, VE, live preview, ajax preview etc.

wikipage.content is triggered whenever content is added to the page (either initially for page views, on page preview, or on JS live preview). similarly wikipage.diff is triggered when a 'diff' is inserted in a page. There are also hooks for categories, collapsible content, the editform, postedit and a few more.

The contents being added to the page, are passed as a parameter (so you don't query the document, but the blob).

Twinkle can attach to these and reinitialise it's UI.

@atlight
Copy link
Collaborator

atlight commented May 17, 2017

Looks like RevisionSlider is about to be enabled by default: https://lists.wikimedia.org/pipermail/wikitech-l/2017-May/088199.html

So we ought to fix this. I don't have time right now unfortunately.

Amorymeltzer added a commit that referenced this issue Mar 21, 2019
This patch will hook Twinklefluff initialization to the mw.hook
responsible for pages containing a diff. Hooking is only done when
the methods for diff pages are loaded.

Now for example the RevisionSlider extension that fires that hook
will re-initiate the Twinkle links added to the page when moving
through the revisions.

This should fix #360

The hook gets fired everytime a diff page loads / reloads. To
avoid having the diff links twice the original method got re-
factored and the part addressing diff pages reacts only to the
hook now.

Further modules that might need to be re-initiated by hook
could be added in a follow up.

Co-authored-by: Amory Meltzer <Amorymeltzer@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants