Index: trunk/extensions/UsabilityInitiative/UsabilityInitiative.hooks.php |
— | — | @@ -19,6 +19,7 @@ |
20 | 20 | $scripts = array( |
21 | 21 | '/extensions/UsabilityInitiative/Resources/jquery.js', |
22 | 22 | '/extensions/UsabilityInitiative/Resources/jquery.textSelection.js', |
| 23 | + '/extensions/UsabilityInitiative/Resources/jquery.cookie.js', |
23 | 24 | ); |
24 | 25 | foreach ( $scripts as $script ) { |
25 | 26 | // Add javascript resources to document |
Index: trunk/extensions/UsabilityInitiative/EditToolbar/EditToolbar.hooks.php |
— | — | @@ -102,14 +102,6 @@ |
103 | 103 | $messagesList = implode( ',', $messages ); |
104 | 104 | // Encapsulates list in javascript code to set them durring load |
105 | 105 | $messagesJs = "loadGM({{$messagesList}});"; |
106 | | - |
107 | | - // Ensure persistency of tabs' show/hide status between submits |
108 | | - $persistentTabs = array( 'format' ); |
109 | | - $tabsJs = ""; |
110 | | - foreach( $persistentTabs as $tab ) |
111 | | - if( $wgRequest->wasPosted() && $wgRequest->getInt( "ET$tab" ) == 1 ) |
112 | | - $tabsJs .= "editToolbarConfiguration['$tab'].showInitially = '1';"; |
113 | | - |
114 | 106 | // Appends javascript message setting code |
115 | 107 | $toolbar .= Xml::element( |
116 | 108 | 'script', array( 'type' => $wgJsMimeType ), $messagesJs . $tabsJs |
Index: trunk/extensions/UsabilityInitiative/EditToolbar/EditToolbar.js |
— | — | @@ -70,6 +70,8 @@ |
71 | 71 | .appendTo( $(this) ); |
72 | 72 | // Appends float-clearing div |
73 | 73 | $(this).append( $( '<div style="clear:both"></div>' ) ); |
| 74 | + // Cookie name for storing section state |
| 75 | + var sectionCookie = 'edittoolbar-' + $(this).attr( 'id' ) + '-section'; |
74 | 76 | // Loops over each section |
75 | 77 | for ( section in tools ) { |
76 | 78 | // Skips over main (was handled as special case already) |
— | — | @@ -80,41 +82,42 @@ |
81 | 83 | var sectionDiv = $( '<div />') |
82 | 84 | .attr( { 'class': 'section', 'id': $(this).attr( 'id' ) + '-section-' + section } ) |
83 | 85 | .appendTo( sectionsDiv ); |
| 86 | + // Respects state |
| 87 | + var current = false; |
| 88 | + if ( $.cookie( sectionCookie ) == sectionDiv.attr( 'id' ) ) { |
| 89 | + sectionDiv.attr( 'style', 'display:block' ); |
| 90 | + current = true; |
| 91 | + } |
84 | 92 | // Appends toolbar to section div |
85 | 93 | sectionDiv.addToolbarSection( tools[section], textbox ); |
86 | | - // Add hidden form field used for show/hide persistency |
87 | | - if( $( '#ET' + section ).length == 0 ) |
88 | | - textbox.parent( 'form' ).append( |
89 | | - $( '<input />' ) |
90 | | - .attr( { 'type': 'hidden', |
91 | | - 'id': 'ET' + section, |
92 | | - 'name': 'ET' + section } ) |
93 | | - .val( tools[section].showInitially ) |
94 | | - ); |
95 | | - var showHideLink = $( '<a />' ) |
96 | | - .text( tools[section].label || gM( tools[section].labelMsg ) ) |
97 | | - .attr( { 'href': '#', 'rel': section } ) |
98 | | - .data( 'sectionDiv', sectionDiv ) |
99 | | - .click( function() { |
100 | | - $(this).blur(); |
101 | | - var show = ( $(this).data( 'sectionDiv' ).css( 'display' ) == 'none' ); |
102 | | - $(this).data( 'sectionDiv' ).parent().children().hide(); |
103 | | - $(this).parent().parent().find( 'a' ).removeClass( 'current' ); |
104 | | - if ( show ) { |
105 | | - $(this).data( 'sectionDiv' ).show(); |
106 | | - $(this).addClass( 'current' ); |
107 | | - } |
108 | | - $( '#ET' + section ).val( ( show ? '1' : '0' ) ); |
109 | | - return false; |
110 | | - }); |
111 | 94 | // Appends section tab |
112 | 95 | tabDiv.append( |
113 | 96 | $( '<div />' ) |
114 | 97 | .attr( 'class', 'tab' ) |
115 | | - .append( showHideLink ) |
| 98 | + .append( |
| 99 | + $( '<a />' ) |
| 100 | + .text( tools[section].label || gM( tools[section].labelMsg ) ) |
| 101 | + .attr( { 'href': '#', 'rel': section, 'class': current ? 'current' : null } ) |
| 102 | + .data( 'sectionDiv', sectionDiv ) |
| 103 | + .data( 'sectionCookie', sectionCookie ) |
| 104 | + .click( function() { |
| 105 | + $(this).blur(); |
| 106 | + var show = ( $(this).data( 'sectionDiv' ).css( 'display' ) == 'none' ); |
| 107 | + $(this).data( 'sectionDiv' ).parent().children().hide(); |
| 108 | + $(this).parent().parent().find( 'a' ).removeClass( 'current' ); |
| 109 | + if ( show ) { |
| 110 | + $(this).data( 'sectionDiv' ).show(); |
| 111 | + $(this).addClass( 'current' ); |
| 112 | + } |
| 113 | + // Sets or deletes cookie when sections are shown or hidden |
| 114 | + $.cookie( |
| 115 | + $(this).data( 'sectionCookie' ), |
| 116 | + show ? $(this).data( 'sectionDiv' ).attr( 'id' ) : null |
| 117 | + ); |
| 118 | + return false; |
| 119 | + }) |
| 120 | + ) |
116 | 121 | ); |
117 | | - if( $( '#ET' + section ).val() != '0' ) |
118 | | - showHideLink.click(); |
119 | 122 | } |
120 | 123 | }); |
121 | 124 | }, |
— | — | @@ -370,7 +373,6 @@ |
371 | 374 | }, |
372 | 375 | // Format section |
373 | 376 | 'format': { |
374 | | - showInitially: '0', |
375 | 377 | labelMsg: 'edittoolbar-section-format', |
376 | 378 | groups: { |
377 | 379 | 'heading': { |
— | — | @@ -535,7 +537,6 @@ |
536 | 538 | }, |
537 | 539 | // Insert section |
538 | 540 | 'insert': { |
539 | | - showInitially: '0', |
540 | 541 | labelMsg: 'edittoolbar-section-insert', |
541 | 542 | groups: { |
542 | 543 | 'media': { |
Index: trunk/extensions/UsabilityInitiative/EditToolbar/EditToolbar.i18n.php |
— | — | @@ -58,7 +58,7 @@ |
59 | 59 | 'edittoolbar-section-insert' => 'Insert', |
60 | 60 | 'edittoolbar-group-insert-media' => 'Media', |
61 | 61 | 'edittoolbar-tool-insert-gallery' => 'Picture gallery', |
62 | | - 'edittoolbar-tool-insert-gallery-example' => "Image:Example.jpg|Caption1\nImage:Example.jpg|Caption2", |
| 62 | + 'edittoolbar-tool-insert-gallery-example' => "File:Example.jpg|Caption1\File:Example.jpg|Caption2", |
63 | 63 | 'edittoolbar-tool-insert-newline' => 'New line', |
64 | 64 | /* Special Characters Section */ |
65 | 65 | 'edittoolbar-section-characters' => 'Special Characters', |
Index: trunk/extensions/UsabilityInitiative/Resources/jquery.cookie.js |
— | — | @@ -0,0 +1,10 @@ |
| 2 | +/** |
| 3 | + * Cookie plugin |
| 4 | + * |
| 5 | + * Copyright (c) 2006 Klaus Hartl (stilbuero.de) |
| 6 | + * Dual licensed under the MIT and GPL licenses: |
| 7 | + * http://www.opensource.org/licenses/mit-license.php |
| 8 | + * http://www.gnu.org/licenses/gpl.html |
| 9 | + * |
| 10 | + */ |
| 11 | +eval(function(p,a,c,k,e,r){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('q.5=x(k,d,a){4(m d!=\'H\'){a=a||{};4(d===p){d=\'\';a=$.A({},a);a.3=-1}2 g=\'\';4(a.3&&(m a.3==\'u\'||a.3.s)){2 f;4(m a.3==\'u\'){f=F C();f.B(f.z()+(a.3*y*o*o*v))}n{f=a.3}g=\'; 3=\'+f.s()}2 b=a.7?\'; 7=\'+(a.7):\'\';2 e=a.9?\'; 9=\'+(a.9):\'\';2 l=a.t?\'; t\':\'\';6.5=[k,\'=\',L(d),g,b,e,l].K(\'\')}n{2 h=p;4(6.5&&6.5!=\'\'){2 c=6.5.E(\';\');D(2 i=0;i<c.8;i++){2 j=q.G(c[i]);4(j.r(0,k.8+1)==(k+\'=\')){h=I(j.r(k.8+1));J}}}w h}};',48,48,'||var|expires|if|cookie|document|path|length|domain|||||||||||||typeof|else|60|null|jQuery|substring|toUTCString|secure|number|1000|return|function|24|getTime|extend|setTime|Date|for|split|new|trim|undefined|decodeURIComponent|break|join|encodeURIComponent'.split('|'),0,{})) |
\ No newline at end of file |