Skip to content

Commit

Permalink
twinkle: Put TW menu back on the right side of the More menu (wikimed…
Browse files Browse the repository at this point in the history
…ia-gadgets#1887)

* twinkle: Put TW menu back on the right side of the More menu

Fixes wikimedia-gadgets#1886
Related wikimedia-gadgets#1881

* use var instead of let

* comment

* fix double element bug

* log, fix bug
  • Loading branch information
NovemLinguae committed Nov 23, 2023
1 parent e6e05d9 commit 6e30957
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion twinkle.js
Original file line number Diff line number Diff line change
Expand Up @@ -262,11 +262,27 @@ Twinkle.addPortlet = function(navigation, id, text, type, nextnodeid) {
}
return null;
}

if (type === 'menu') {
// In order to get mw.util.addPortlet to generate a dropdown menu in vector and vector-2022, the nextnodeid must be p-cactions. Any other nextnodeid will generate a non-dropdown portlet instead.
nextnodeid = 'p-cactions';
}
return mw.util.addPortlet(id, text, '#' + nextnodeid);

var portlet = mw.util.addPortlet(id, text, '#' + nextnodeid);

// The Twinkle dropdown menu has been added to the left of p-cactions. Move it to the right.
if (mw.config.get('skin') === 'vector') {
$('#p-twinkle').insertAfter('#p-cactions');
} else if (mw.config.get('skin') === 'vector-2022') {
$('#p-twinkle-dropdown').appendTo('.vector-page-tools-landmark');

// .vector-page-tools-landmark is unstable and could change. If so, log it to console, to hopefully get someone's attention.
if (!document.querySelector('.vector-page-tools-landmark')) {
mw.log.warn('Unexpected change in DOM');
}
}

return portlet;
};

/**
Expand Down

0 comments on commit 6e30957

Please sign in to comment.