2020-06-08 22:14:37 +00:00
/ * *
* @ external MenuDefinition
* /
/* eslint-disable quotes */
2020-05-05 23:26:35 +00:00
import menuTemplate from '!!raw-loader!../includes/templates/Menu.mustache' ;
2020-07-14 21:40:28 +00:00
import { htmlUserLanguageAttributes } from './utils' ;
2020-02-17 19:49:43 +00:00
2020-10-08 21:56:52 +00:00
/ * *
* @ param { string } name of the menu
* @ param { string } htmlItems
* @ return { MenuDefinition }
* /
function helperMakeMenuData ( name , htmlItems ) {
let label ;
switch ( name ) {
case 'personal' :
label = 'Personal tools' ;
break ;
default :
label = 'Menu label' ;
break ;
}
return {
id : ` p- ${ name } ` ,
class : ` mw-portlet mw-portlet- ${ name } vector-menu ` ,
label ,
'html-user-language-attributes' : htmlUserLanguageAttributes ,
'html-items' : htmlItems
} ;
}
2020-04-03 20:05:22 +00:00
/ * *
* @ type { MenuDefinition }
* /
2020-10-08 21:56:52 +00:00
const loggedOut = helperMakeMenuData (
'personal' ,
` <li id="pt-anonuserpage">Not logged in</li><li id="pt-anontalk"><a href="/wiki/Special:MyTalk" title="Discussion about edits from this IP address [⌃⌥n]" accesskey="n">Talk</a></li><li id="pt-anoncontribs"><a href="/wiki/Special:MyContributions" title="A list of edits made from this IP address [⌃⌥y]" accesskey="y">Contributions</a></li><li id="pt-createaccount"><a href="/w/index.php?title=Special:CreateAccount&returnto=Main+Page" title="You are encouraged to create an account and log in; however, it is not mandatory">Create account</a></li><li id="pt-login"><a href="/w/index.php?title=Special:UserLogin&returnto=Main+Page" title="You're encouraged to log in; however, it's not mandatory. [⌃⌥o]" accesskey="o">Log in</a></li> `
) ;
2020-02-17 19:49:43 +00:00
2020-04-03 20:05:22 +00:00
/ * *
* @ type { MenuDefinition }
* /
2020-10-08 21:56:52 +00:00
const loggedInWithEcho = helperMakeMenuData (
'personal' ,
` <li id="pt-userpage"><a href="/wiki/User:Jdlrobson" dir="auto" title="Your user page [⌃⌥.]" accesskey=".">Jdlrobson</a></li><li id="pt-notifications-alert"><a href="/wiki/Special:Notifications" class="mw-echo-notifications-badge mw-echo-notification-badge-nojs oo-ui-icon-bell mw-echo-notifications-badge-all-read" data-counter-num="0" data-counter-text="0" title="Your alerts">Alerts (0)</a></li><li id="pt-notifications-notice"><a href="/wiki/Special:Notifications" class="mw-echo-notifications-badge mw-echo-notification-badge-nojs oo-ui-icon-tray" data-counter-num="3" data-counter-text="3" title="Your notices">Notices (3)</a></li><li id="pt-mytalk"><a href="/wiki/User_talk:Jdlrobson" title="Your talk page [⌃⌥n]" accesskey="n">Talk</a></li><li id="pt-sandbox"><a href="/wiki/User:Jdlrobson/sandbox" title="Your sandbox">Sandbox</a></li><li id="pt-preferences"><a href="/wiki/Special:Preferences" title="Your preferences">Preferences</a></li><li id="pt-betafeatures"><a href="/wiki/Special:Preferences#mw-prefsection-betafeatures" title="Beta features">Beta</a></li><li id="pt-watchlist"><a href="/wiki/Special:Watchlist" title="A list of pages you are monitoring for changes [⌃⌥l]" accesskey="l">Watchlist</a></li><li id="pt-mycontris"><a href="/wiki/Special:Contributions/Jdlrobson" title="A list of your contributions [⌃⌥y]" accesskey="y">Contributions</a></li><li id="pt-logout"><a href="/w/index.php?title=Special:UserLogout&returnto=Main+Page&returntoquery=useskin%3Dvector" title="Log out">Log out</a></li> `
) ;
2020-02-17 19:49:43 +00:00
2020-04-03 20:05:22 +00:00
const ULS _LANGUAGE _SELECTOR = '<li class="uls-trigger active"><a href="#">English</a></li>' ;
2020-05-05 23:26:35 +00:00
/ * *
* @ type { MenuDefinition }
* /
2020-10-08 21:56:52 +00:00
const defaultMenu = helperMakeMenuData (
'generic' ,
` <li><a href='#'>Item 1</a></li>
2020-05-05 23:26:35 +00:00
< li > < a href = '#' > Item 2 < / a > < / l i >
< li > < a href = '#' > Item 3 < / a > < / l i > `
2020-10-08 21:56:52 +00:00
) ;
2020-05-05 23:26:35 +00:00
2020-04-03 20:05:22 +00:00
/ * *
* @ type { MenuDefinition }
* /
2020-10-08 21:56:52 +00:00
const loggedInWithULS = helperMakeMenuData (
'personal' ,
` ${ ULS _LANGUAGE _SELECTOR } <li id="pt-userpage"><a href="/wiki/User:Jdlrobson" dir="auto" title="Your user page [⌃⌥.]" accesskey=".">Jdlrobson</a></li><li id="pt-notifications-alert"><a href="/wiki/Special:Notifications" class="mw-echo-notifications-badge mw-echo-notification-badge-nojs oo-ui-icon-bell mw-echo-notifications-badge-all-read" data-counter-num="0" data-counter-text="0" title="Your alerts">Alerts (0)</a></li><li id="pt-notifications-notice"><a href="/wiki/Special:Notifications" class="mw-echo-notifications-badge mw-echo-notification-badge-nojs oo-ui-icon-tray" data-counter-num="3" data-counter-text="3" title="Your notices">Notices (3)</a></li><li id="pt-mytalk"><a href="/wiki/User_talk:Jdlrobson" title="Your talk page [⌃⌥n]" accesskey="n">Talk</a></li><li id="pt-sandbox"><a href="/wiki/User:Jdlrobson/sandbox" title="Your sandbox">Sandbox</a></li><li id="pt-preferences"><a href="/wiki/Special:Preferences" title="Your preferences">Preferences</a></li><li id="pt-betafeatures"><a href="/wiki/Special:Preferences#mw-prefsection-betafeatures" title="Beta features">Beta</a></li><li id="pt-watchlist"><a href="/wiki/Special:Watchlist" title="A list of pages you are monitoring for changes [⌃⌥l]" accesskey="l">Watchlist</a></li><li id="pt-mycontris"><a href="/wiki/Special:Contributions/Jdlrobson" title="A list of your contributions [⌃⌥y]" accesskey="y">Contributions</a></li><li id="pt-logout"><a href="/w/index.php?title=Special:UserLogout&returnto=Main+Page&returntoquery=useskin%3Dvector" title="Log out">Log out</a></li> `
) ;
2020-02-17 19:49:43 +00:00
2020-04-03 20:05:22 +00:00
/ * *
* @ type { Object . < string , MenuDefinition > }
* /
2020-02-17 19:49:43 +00:00
const PERSONAL _MENU _TEMPLATE _DATA = {
loggedOut ,
2020-05-05 23:26:35 +00:00
defaultMenu ,
2020-02-17 19:49:43 +00:00
loggedInWithEcho ,
loggedInWithULS
} ;
2020-05-05 23:26:35 +00:00
export { PERSONAL _MENU _TEMPLATE _DATA , menuTemplate } ;