@@ -36,44 +36,59 @@ window.onpopstate = function( event ) {
3636
3737$ ( function ( ) {
3838 var $navBar = $ ( 'ul.navbar-head' ) ,
39- selector = new OO . ui . DropdownWidget ( {
40- "label" : mw . msg ( 'accessibility-simulation' ) ,
41- "menu" : { 'items' : [
42- new OO . ui . MenuOptionWidget ( {
43- 'data' : '' ,
44- 'label' : mw . msg ( 'accessibility-simulation-none' ) ,
45- 'selected' : true
46- } ) ,
47- new OO . ui . MenuOptionWidget ( {
48- 'data' : 'protanopia' ,
49- 'label' : mw . msg ( 'accessibility-simulation-protanopia' )
50- } ) ,
51- new OO . ui . MenuOptionWidget ( {
52- 'data' : 'deuteranopia' ,
53- 'label' : mw . msg ( 'accessibility-simulation-deuteranopia' )
54- } ) ,
55- new OO . ui . MenuOptionWidget ( {
56- 'data' : 'tritanopia' ,
57- 'label' : mw . msg ( 'accessibility-simulation-tritanopia' )
58- } ) ,
59- new OO . ui . MenuOptionWidget ( {
60- 'data' : 'monochromacy' ,
61- 'label' : mw . msg ( 'accessibility-simulation-monochromacy' )
62- } )
63- ] }
64- } ) ,
65- menu = selector . getMenu ( ) ,
66- $newItem = $ ( '<li/>' ) . append ( selector . $element ) ,
39+ $dropdown = $ ( '<ul>' )
40+ . attr ( {
41+ 'role' : 'menu' ,
42+ 'aria-labelledby' : 'Accessibility Simulation' ,
43+ 'class' : 'dropdown-menu accessibility-simulation-dropdown'
44+ } )
45+ . append (
46+ $ ( '<li>' ) . append (
47+ $ ( '<a>' )
48+ . text ( mw . msg ( 'accessibility-simulation-none' ) )
49+ . data ( 'name' , '' )
50+ ) ,
51+ $ ( '<li>' ) . append (
52+ $ ( '<a>' )
53+ . text ( mw . msg ( 'accessibility-simulation-protanopia' ) )
54+ . data ( 'name' , 'protanopia' )
55+ ) ,
56+ $ ( '<li>' ) . append (
57+ $ ( '<a>' )
58+ . text ( mw . msg ( 'accessibility-simulation-deuteranopia' ) )
59+ . data ( 'name' , 'deuteranopia' )
60+ ) ,
61+ $ ( '<li>' ) . append (
62+ $ ( '<a>' )
63+ . text ( mw . msg ( 'accessibility-simulation-tritanopia' ) )
64+ . data ( 'name' , 'tritanopia' )
65+ ) ,
66+ $ ( '<li>' ) . append (
67+ $ ( '<a>' )
68+ . text ( mw . msg ( 'accessibility-simulation-monochromacy' ) )
69+ . data ( 'name' , 'monochromacy' )
70+ )
71+ ) ,
72+ $dropdownButton = $ ( '<a>' )
73+ . attr ( {
74+ 'class' : 'btn btn-default dropdown-toggle accessibility-simulation-button' ,
75+ 'role' : 'button' ,
76+ 'data-toggle' : 'dropdown' ,
77+ 'aria-expanded' : 'true'
78+ } ) ,
6779 queryParameters = decodeQueryString ( window . location . search ) ,
6880 selectedSimulation = '' ;
6981
7082 if ( 'simulation' in queryParameters )
7183 selectedSimulation = queryParameters . simulation ;
7284
73- $newItem . appendTo ( $navBar ) ;
85+ $navBar . append ( $ ( '<li>' )
86+ . addClass ( 'dropdown' )
87+ . append ( $dropdownButton , $dropdown )
88+ ) ;
7489
75- menu . on ( 'select ' , function ( item ) {
76- var type = item . getData ( ) ,
90+ $ ( '.accessibility-simulation-dropdown a' ) . on ( 'click ' , function ( ) {
91+ var type = $ ( this ) . data ( 'name' ) ,
7792 newQueryParameters = decodeQueryString ( window . location . search ) ,
7893 newUrl ;
7994
@@ -92,7 +107,5 @@ $( function() {
92107 newUrl
93108 ) ;
94109 } ) ;
95-
96- menu . selectItem ( menu . getItemFromData ( selectedSimulation ) ) ;
97110} ) ;
98111} ) ( jQuery , mediaWiki ) ;
0 commit comments