r56421 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r56420‎ | r56421 | r56422 >
Date:17:47, 16 September 2009
Author:catrope
Status:deferred
Tags:
Comment:
wmf-deployment-work: Merge r56417 (pre-deployment usability fixes) from
trunk. Also merge r56195 (NTOC bugfix), made conflict resolution easier.
Modified paths:
  • /branches/wmf-deployment-work/extensions/UsabilityInitiative (modified) (history)
  • /branches/wmf-deployment-work/extensions/UsabilityInitiative/ClickTracking/ClickTracking.hooks.php (modified) (history)
  • /branches/wmf-deployment-work/extensions/UsabilityInitiative/EditToolbar/EditToolbar.hooks.php (modified) (history)
  • /branches/wmf-deployment-work/extensions/UsabilityInitiative/EditToolbar/EditToolbar.i18n.php (modified) (history)
  • /branches/wmf-deployment-work/extensions/UsabilityInitiative/EditToolbar/EditToolbar.js (modified) (history)
  • /branches/wmf-deployment-work/extensions/UsabilityInitiative/EditToolbar/EditToolbar.php (modified) (history)
  • /branches/wmf-deployment-work/extensions/UsabilityInitiative/NavigableTOC/NavigableTOC.hooks.php (modified) (history)
  • /branches/wmf-deployment-work/extensions/UsabilityInitiative/NavigableTOC/NavigableTOC.i18n.php (modified) (history)
  • /branches/wmf-deployment-work/extensions/UsabilityInitiative/NavigableTOC/NavigableTOC.php (modified) (history)
  • /branches/wmf-deployment-work/extensions/UsabilityInitiative/UsabilityInitiative.hooks.php (modified) (history)
  • /branches/wmf-deployment-work/extensions/UsabilityInitiative/UsabilityInitiative.php (modified) (history)
  • /branches/wmf-deployment-work/extensions/UsabilityInitiative/images/wikiEditor/toolbar/insert-ilink.png (added) (history)
  • /branches/wmf-deployment-work/extensions/UsabilityInitiative/images/wikiEditor/toolbar/insert-xlink.png (added) (history)
  • /branches/wmf-deployment-work/extensions/UsabilityInitiative/js/plugins.combined.js (modified) (history)
  • /branches/wmf-deployment-work/extensions/UsabilityInitiative/js/plugins.combined.min.js (modified) (history)
  • /branches/wmf-deployment-work/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.js (modified) (history)
  • /branches/wmf-deployment-work/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.toc.js (modified) (history)

Diff [purge]

Index: branches/wmf-deployment-work/extensions/UsabilityInitiative/images/wikiEditor/toolbar/insert-xlink.png
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes on: branches/wmf-deployment-work/extensions/UsabilityInitiative/images/wikiEditor/toolbar/insert-xlink.png
___________________________________________________________________
Added: svn:mime-type
11 + application/octet-stream
Index: branches/wmf-deployment-work/extensions/UsabilityInitiative/images/wikiEditor/toolbar/insert-ilink.png
Cannot display: file marked as a binary type.
svn:mime-type = application/octet-stream
Property changes on: branches/wmf-deployment-work/extensions/UsabilityInitiative/images/wikiEditor/toolbar/insert-ilink.png
___________________________________________________________________
Added: svn:mime-type
22 + application/octet-stream
Index: branches/wmf-deployment-work/extensions/UsabilityInitiative/ClickTracking/ClickTracking.hooks.php
@@ -62,7 +62,7 @@
6363 'wgTrackingToken' => ClickTrackingHooks::get_session_id()
6464 )
6565 );
66 - UsabilityInitiativeHooks::addLiteralVariables(
 66+ UsabilityInitiativeHooks::addVariables(
6767 array(
6868 'wgClickTrackingIsThrottled' => ClickTrackingHooks::isUserThrottled()
6969 )
Index: branches/wmf-deployment-work/extensions/UsabilityInitiative/EditToolbar/EditToolbar.i18n.php
@@ -15,12 +15,17 @@
1616 'edittoolbar' => 'Editing toolbar',
1717 'edittoolbar-desc' => 'Edit page toolbar with enhanced usability',
1818 'edittoolbar-preference' => 'Enable enhanced editing toolbar',
 19+ 'edittoolbar-cgd-preference' => 'Enable content generation dialogs in enhanced editing toolbar',
1920 'edittoolbar-loading' => 'Loading...',
2021 /* Main Section */
2122 'edittoolbar-tool-bold' => 'Bold',
2223 'edittoolbar-tool-bold-example' => 'Bold text',
2324 'edittoolbar-tool-italic' => 'Italic',
2425 'edittoolbar-tool-italic-example' => 'Italic text',
 26+ 'edittoolbar-tool-ilink' => 'Internal link',
 27+ 'edittoolbar-tool-ilink-example' => 'Link title',
 28+ 'edittoolbar-tool-xlink' => 'External link (remember http:// prefix)',
 29+ 'edittoolbar-tool-xlink-example' => 'http://www.example.com link title',
2530 'edittoolbar-tool-link' => 'Link',
2631 'edittoolbar-tool-link-title' => 'Insert link',
2732 'edittoolbar-tool-link-int' => 'To a wiki page',
@@ -72,6 +77,18 @@
7378 {{ns:file}}:Example.jpg|Caption2",
7479 'edittoolbar-tool-newline' => 'New line',
7580 'edittoolbar-tool-table' => 'Table',
 81+ 'edittoolbar-tool-table-example-old' => "-
 82+! header 1
 83+! header 2
 84+! header 3
 85+|-
 86+| row 1, cell 1
 87+| row 1, cell 2
 88+| row 1, cell 3
 89+|-
 90+| row 2, cell 1
 91+| row 2, cell 2
 92+| row 2, cell 3",
7693 'edittoolbar-tool-table-example' => 'Row $1, cell $2',
7794 'edittoolbar-tool-table-example-header' => 'Row $1, cell $2 (header)',
7895 'edittoolbar-tool-table-title' => 'Insert table',
Index: branches/wmf-deployment-work/extensions/UsabilityInitiative/EditToolbar/EditToolbar.php
@@ -19,7 +19,7 @@
2020 /* Configuration */
2121
2222 // Bump the version number every time you change any of the .css/.js files
23 -$wgEditToolbarStyleVersion = 28;
 23+$wgEditToolbarStyleVersion = 33;
2424
2525 // Set this to true to simply override the stock toolbar for everyone
2626 $wgEditToolbarGlobalEnable = false;
@@ -29,6 +29,15 @@
3030 // will not do anything)
3131 $wgEditToolbarUserEnable = true;
3232
 33+// Set this to true to enable content generation dialogs for everyone who gets
 34+// the toolbar
 35+$wgEditToolbarCGDGlobalEnable = false;
 36+
 37+// Set this to true to add a preference to the editing section of preferences
 38+// which enabled and disables content generation dialogs
 39+// If $wgEditToolbatCGDGlobalEnable is true, this will be ignored
 40+$wgEditToolbarCGDUserEnable = true;
 41+
3342 // Set if we should include a client-side testing script
3443 $wgEditToolbarRunTests = false;
3544
Index: branches/wmf-deployment-work/extensions/UsabilityInitiative/EditToolbar/EditToolbar.hooks.php
@@ -15,7 +15,9 @@
1616 * Intercept the display of the toolbar, replacing the content of $toolbar
1717 */
1818 public static function addToolbar( &$toolbar ) {
19 - global $wgUser, $wgEditToolbarGlobalEnable, $wgEditToolbarUserEnable;
 19+ global $wgUser, $wgEditToolbarGlobalEnable;
 20+ global $wgEditToolbarUserEnable, $wgEditToolbarCGDGlobalEnable;
 21+ global $wgEditToolbarCGDUserEnable;
2022
2123 // Only proceed if some specific conditions are met
2224 if ( $wgEditToolbarGlobalEnable || ( $wgEditToolbarUserEnable && $wgUser->getOption( 'usebetatoolbar' ) ) ) {
@@ -25,6 +27,9 @@
2628 UsabilityInitiativeHooks::addScript(
2729 'EditToolbar/EditToolbar.js', $wgEditToolbarStyleVersion
2830 );
 31+ UsabilityInitiativeHooks::addVariables( array(
 32+ 'wgEditToolbarCGD' => $wgEditToolbarCGDGlobalEnable || ( $wgEditToolbarCGDUserEnable && $wgUser->getOption( 'usebetatoolbar-cgd' ) )
 33+ ) );
2934 // Internationalization
3035 wfLoadExtensionMessages( 'EditToolbar' );
3136 UsabilityInitiativeHooks::addMessages(
@@ -35,6 +40,10 @@
3641 'edittoolbar-tool-bold-example',
3742 'edittoolbar-tool-italic',
3843 'edittoolbar-tool-italic-example',
 44+ 'edittoolbar-tool-ilink',
 45+ 'edittoolbar-tool-ilink-example',
 46+ 'edittoolbar-tool-xlink',
 47+ 'edittoolbar-tool-xlink-example',
3948 'edittoolbar-tool-link',
4049 'edittoolbar-tool-link-title',
4150 'edittoolbar-tool-link-int',
@@ -85,6 +94,7 @@
8695 'edittoolbar-tool-gallery-example',
8796 'edittoolbar-tool-newline',
8897 'edittoolbar-tool-table',
 98+ 'edittoolbar-tool-table-example-old',
8999 'edittoolbar-tool-table-example',
90100 'edittoolbar-tool-table-example-header',
91101 'edittoolbar-tool-table-title',
@@ -196,15 +206,9 @@
197207 */
198208 public static function addPreferences( $user, &$defaultPreferences ) {
199209 global $wgEditToolbarGlobalEnable, $wgEditToolbarUserEnable;
 210+ global $wgEditToolbarCGDGlobalEnable, $wgEditToolbarCGDUserEnable;
200211
201 - // Checks if...
202 - if (
203 - // Toolbar is NOT globablly enabled
204 - !$wgEditToolbarGlobalEnable &&
205 - // And Toolbar is per-user enablable
206 - $wgEditToolbarUserEnable
207 - ) {
208 - // Internationalization
 212+ if ( !$wgEditToolbarGlobalEnable && $wgEditToolbarUserEnable ) {
209213 wfLoadExtensionMessages( 'EditToolbar' );
210214 // Adds preference for opting in
211215 $defaultPreferences['usebetatoolbar'] =
@@ -214,6 +218,15 @@
215219 'section' => 'editing/advancedediting',
216220 );
217221 }
 222+
 223+ if ( !$wgEditToolbarGlobalEnable && $wgEditToolbarUserEnable ) {
 224+ wfLoadExtensionMessages( 'EditToolbar' );
 225+ $defaultPreferences['usebetatoolbar-cgd'] = array(
 226+ 'type' => 'toggle',
 227+ 'label-message' => 'edittoolbar-cgd-preference',
 228+ 'section' => 'editing/advancedediting',
 229+ );
 230+ }
218231 return true;
219232 }
220233 }
Index: branches/wmf-deployment-work/extensions/UsabilityInitiative/EditToolbar/EditToolbar.js
@@ -1,6 +1,10 @@
22 /* JavaScript for EditToolbar extension */
33
44 js2AddOnloadHook( function() {
 5+ // Only show content generation dialogs if enabled
 6+ if ( typeof wgEditToolbarCGD != 'undefined' && wgEditToolbarCGD )
 7+ $j( '#wpTextbox1' ).addClass( 'withCGD' );
 8+
59 if ( $j.wikiEditor != undefined && $j.wikiEditor.isSupported() || !$j.wikiEditor.isSupportKnown() ) {
610 // Remove the old toolbar
711 $j( '#toolbar' ).remove();
@@ -47,10 +51,39 @@
4852 },
4953 'insert': {
5054 tools: {
51 - 'link': {
 55+ 'xlink': {
 56+ labelMsg: 'edittoolbar-tool-xlink',
 57+ type: 'button',
 58+ icon: 'insert-xlink.png',
 59+ filters: [ '#wpTextbox1:not(.withCGD)' ],
 60+ action: {
 61+ type: 'encapsulate',
 62+ options: {
 63+ pre: "[",
 64+ periMsg: 'edittoolbar-tool-xlink-example',
 65+ post: "]"
 66+ }
 67+ }
 68+ },
 69+ 'ilink': {
 70+ labelMsg: 'edittoolbar-tool-ilink',
 71+ type: 'button',
 72+ icon: 'insert-ilink.png',
 73+ filters: [ '#wpTextbox1:not(.withCGD)' ],
 74+ action: {
 75+ type: 'encapsulate',
 76+ options: {
 77+ pre: "[[",
 78+ periMsg: 'edittoolbar-tool-ilink-example',
 79+ post: "]]"
 80+ }
 81+ }
 82+ },
 83+ 'linkCGD': {
5284 labelMsg: 'edittoolbar-tool-link',
5385 type: 'button',
5486 icon: 'insert-link.png',
 87+ filters: [ '#wpTextbox1.withCGD' ],
5588 action: {
5689 type: 'dialog',
5790 module: 'insert-link'
@@ -271,15 +304,30 @@
272305 }
273306 }
274307 },
275 - 'table': {
 308+ 'tableCGD': {
276309 labelMsg: 'edittoolbar-tool-table',
277310 type: 'button',
278311 icon: 'insert-table.png',
 312+ filters: [ '#wpTextbox1.withCGD' ],
279313 action: {
280314 type: 'dialog',
281315 module: 'insert-table'
282316 }
283317 },
 318+ 'table': {
 319+ labelMsg: 'edittoolbar-tool-table',
 320+ type: 'button',
 321+ icon: 'insert-table.png',
 322+ filters: [ '#wpTextbox1:not(.withCGD)' ],
 323+ action: {
 324+ type: 'encapsulate',
 325+ options: {
 326+ pre: "{| class=\"wikitable\" border=\"1\"\n|",
 327+ periMsg: 'edittoolbar-tool-table-example-old',
 328+ post: "\n|}"
 329+ }
 330+ }
 331+ },
284332 'newline': {
285333 labelMsg: 'edittoolbar-tool-newline',
286334 type: 'button',
@@ -299,6 +347,7 @@
300348 labelMsg: 'edittoolbar-tool-replace',
301349 type: 'button',
302350 icon: 'search-replace.png',
 351+ filters: [ '#wpTextbox1.withCGD' ],
303352 action: {
304353 type: 'dialog',
305354 module: 'search-and-replace'
Index: branches/wmf-deployment-work/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.js
@@ -65,96 +65,88 @@
6666 // gets called again we can pick up where we left off
6767 var context = $(this).data( 'wikiEditor-context' );
6868
69 -/* API */
7069
71 -// The first time this is called, we expect context to be undefined, meaning
72 -// the editing UI has not yet been, and still needs to be, built. However, each
73 -// additional call after that is expected to be an API call, which contains a
74 -// string as the first argument which corresponds to a supported API call
75 -if ( typeof context !== 'undefined' ) {
76 - // Since javascript gives arguments as an object, we need to convert them
77 - // so they can be used more easily
78 - arguments = $.makeArray( arguments );
79 - if ( arguments.length > 0 ) {
80 - // Handle API calls
81 - var call = arguments.shift();
82 - if ( call in context.api ) {
83 - context.api[call]( context, arguments[0] == undefined ? {} : arguments[0] );
84 - }
85 - // Store the context for next time and return
86 - return $(this).data( 'context', context );
87 - }
88 - // Nothing to do, just return
89 - return $(this);
90 -}
91 -
92 -/* Construction */
93 -
94 -var instance = $.wikiEditor.instances.length;
95 -context = { '$textarea': $(this), 'modules': {}, 'data': {}, 'instance': instance };
96 -$.wikiEditor.instances[instance] = $(this);
97 -
98 -// Encapsulate the textarea with some containers for layout
99 -$(this)
100 - .wrap( $( '<div></div>' ).addClass( 'wikiEditor-ui' ).attr( 'id', 'wikiEditor-ui' ) )
101 - .wrap( $( '<div></div>' ).addClass( 'wikiEditor-ui-bottom' ).attr( 'id', 'wikiEditor-ui-bottom' ) )
102 - .wrap( $( '<div></div>' ).addClass( 'wikiEditor-ui-text' ).attr( 'id', 'wikiEditor-ui-text' ) );
103 -
104 -// Get a reference to the outer container
105 -context.$ui = $(this).parent().parent().parent();
106 -context.$ui.after( $( '<div style="clear:both;"></div>' ) );
107 -// Attach a container in the top
108 -context.$ui.prepend( $( '<div></div>' ).addClass( 'wikiEditor-ui-top' ).attr( 'id', 'wikiEditor-ui-top' ) );
109 -
110 -// Create a set of standard methods for internal and external use
111 -context.api = {
112 - /**
113 - * Accepts either a string of the name of a module to add without any
114 - * additional configuration parameters, or an object with members keyed with
115 - * module names and valued with configuration objects
116 - */
117 - addModule: function( context, data ) {
118 - // A safe way of calling an API function on a module
119 - function callModuleApi( module, call, data ) {
120 - if (
121 - module in $.wikiEditor.modules &&
122 - 'fn' in $.wikiEditor.modules[module] &&
123 - call in $.wikiEditor.modules[module].fn
124 - ) {
125 - $.wikiEditor.modules[module].fn[call]( context, data );
 70+if ( typeof context == 'undefined' ) {
 71+ /* Construction */
 72+ var instance = $.wikiEditor.instances.length;
 73+ context = { '$textarea': $(this), 'modules': {}, 'data': {}, 'instance': instance };
 74+ $.wikiEditor.instances[instance] = $(this);
 75+
 76+ // Encapsulate the textarea with some containers for layout
 77+ $(this)
 78+ .wrap( $( '<div></div>' ).addClass( 'wikiEditor-ui' ).attr( 'id', 'wikiEditor-ui' ) )
 79+ .wrap( $( '<div></div>' ).addClass( 'wikiEditor-ui-bottom' ).attr( 'id', 'wikiEditor-ui-bottom' ) )
 80+ .wrap( $( '<div></div>' ).addClass( 'wikiEditor-ui-text' ).attr( 'id', 'wikiEditor-ui-text' ) );
 81+
 82+ // Get a reference to the outer container
 83+ context.$ui = $(this).parent().parent().parent();
 84+ context.$ui.after( $( '<div style="clear:both;"></div>' ) );
 85+ // Attach a container in the top
 86+ context.$ui.prepend( $( '<div></div>' ).addClass( 'wikiEditor-ui-top' ).attr( 'id', 'wikiEditor-ui-top' ) );
 87+
 88+ // Create a set of standard methods for internal and external use
 89+ context.api = {
 90+ /**
 91+ * Accepts either a string of the name of a module to add without any
 92+ * additional configuration parameters, or an object with members keyed with
 93+ * module names and valued with configuration objects
 94+ */
 95+ addModule: function( context, data ) {
 96+ // A safe way of calling an API function on a module
 97+ function callModuleApi( module, call, data ) {
 98+ if (
 99+ module in $.wikiEditor.modules &&
 100+ 'fn' in $.wikiEditor.modules[module] &&
 101+ call in $.wikiEditor.modules[module].fn
 102+ ) {
 103+ $.wikiEditor.modules[module].fn[call]( context, data );
 104+ }
126105 }
127 - }
128 - if ( typeof data == 'string' ) {
129 - callModuleApi( data, 'create', {} );
130 - } else if ( typeof data == 'object' ) {
131 - for ( module in data ) {
132 - if ( typeof module == 'string' ) {
133 - callModuleApi( module, 'create', data[module] );
 106+ if ( typeof data == 'string' ) {
 107+ callModuleApi( data, 'create', {} );
 108+ } else if ( typeof data == 'object' ) {
 109+ for ( module in data ) {
 110+ if ( typeof module == 'string' ) {
 111+ callModuleApi( module, 'create', data[module] );
 112+ }
134113 }
135114 }
136115 }
137 - }
138 -};
139 -// Allow modules to extend the API
140 -for ( module in $.wikiEditor.modules ) {
141 - if ( 'api' in $.wikiEditor.modules[module] ) {
142 - for ( call in $.wikiEditor.modules[module].api ) {
143 - // Modules may not overwrite existing API functions - first come,
144 - // first serve
145 - if ( !( call in context.api ) ) {
146 - context.api[call] = $.wikiEditor.modules[module].api[call];
 116+ };
 117+ // Allow modules to extend the API
 118+ for ( module in $.wikiEditor.modules ) {
 119+ if ( 'api' in $.wikiEditor.modules[module] ) {
 120+ for ( call in $.wikiEditor.modules[module].api ) {
 121+ // Modules may not overwrite existing API functions - first come,
 122+ // first serve
 123+ if ( !( call in context.api ) ) {
 124+ context.api[call] = $.wikiEditor.modules[module].api[call];
 125+ }
147126 }
148127 }
149128 }
 129+ //Each browser seems to do this differently, so let's keep our editor
 130+ //consistent by always starting at the begining
 131+ context.$textarea.scrollToCaretPosition( 0 );
150132 }
 133+
151134 // If there was a configuration passed, it's assumed to be for the addModule
152 -// API call, so we can just send it on it's way right now
 135+// API call
153136 if ( arguments.length > 0 && typeof arguments[0] == 'object' ) {
154137 context.api.addModule( context, arguments[0] );
 138+} else {
 139+ // Since javascript gives arguments as an object, we need to convert them
 140+ // so they can be used more easily
 141+ arguments = $.makeArray( arguments );
 142+ if ( arguments.length > 0 ) {
 143+ // Handle API calls
 144+ var call = arguments.shift();
 145+ if ( call in context.api ) {
 146+ context.api[call]( context, arguments[0] == undefined ? {} : arguments[0] );
 147+ }
 148+ }
155149 }
156 -//Each browser seems to do this differently, so let's keep our editor
157 -//consistent by always starting at the begining
158 -context.$textarea.scrollToCaretPosition( 0 );
 150+
159151 // Store the context for next time, and support chaining
160152 return $(this).data( 'wikiEditor-context', context );
161153
Index: branches/wmf-deployment-work/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.toc.js
@@ -45,7 +45,7 @@
4646 context.$textarea
4747 .bind( 'keyup encapsulateSelection',
4848 function( event ) {
49 - var context = $(this).data( 'context' );
 49+ var context = $(this).data( 'wikiEditor-context' );
5050 $(this).eachAsync( {
5151 bulk: 0,
5252 loop: function() {
@@ -55,9 +55,9 @@
5656 } );
5757 }
5858 )
59 - .bind( 'mouseup scrollToPosition',
 59+ .bind( 'mouseup scrollToPosition focus',
6060 function( event ) {
61 - var context = $(this).data( 'context' );
 61+ var context = $(this).data( 'wikiEditor-context' );
6262 $(this).eachAsync( {
6363 bulk: 0,
6464 loop: function() {
@@ -65,15 +65,23 @@
6666 }
6767 } );
6868 }
69 - );
 69+ )
 70+ .blur( function() {
 71+ var context = $(this).data( 'wikiEditor-context' );
 72+ $.wikiEditor.modules.toc.fn.unhighlight( context );
 73+ });
7074 },
 75+
 76+ unhighlight: function( context ) {
 77+ context.modules.$toc.find( 'a' ).removeClass( 'currentSelection' );
 78+ },
7179 /**
7280 * Highlight the section the cursor is currently within
7381 *
7482 * @param {Object} context
7583 */
7684 update: function( context ) {
77 - context.modules.$toc.find( 'a' ).removeClass( 'currentSelection' );
 85+ $.wikiEditor.modules.toc.fn.unhighlight( context );
7886 var position = context.$textarea.getCaretPosition();
7987 var section = 0;
8088 if ( context.data.outline.length > 0 ) {
@@ -220,4 +228,4 @@
221229 }
222230 }
223231
224 -}; } ) ( jQuery );
\ No newline at end of file
 232+}; } ) ( jQuery );
Property changes on: branches/wmf-deployment-work/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.toc.js
___________________________________________________________________
Added: svn:mergeinfo
225233 Merged /trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.toc.js:r56195,56207,56209,56296,56333,56355,56417
226234 Merged /trunk/phase3/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.toc.js:r56213,56215-56216,56218,56325,56334-56336,56338,56340,56343,56345,56347,56350
227235 Merged /branches/REL1_15/phase3/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.toc.js:r51646
Index: branches/wmf-deployment-work/extensions/UsabilityInitiative/js/plugins.combined.js
@@ -1000,13 +1000,76 @@
10011001 // gets called again we can pick up where we left off
10021002 var context = $(this).data( 'wikiEditor-context' );
10031003
1004 -/* API */
10051004
1006 -// The first time this is called, we expect context to be undefined, meaning
1007 -// the editing UI has not yet been, and still needs to be, built. However, each
1008 -// additional call after that is expected to be an API call, which contains a
1009 -// string as the first argument which corresponds to a supported API call
1010 -if ( typeof context !== 'undefined' ) {
 1005+if ( typeof context == 'undefined' ) {
 1006+ /* Construction */
 1007+ var instance = $.wikiEditor.instances.length;
 1008+ context = { '$textarea': $(this), 'modules': {}, 'data': {}, 'instance': instance };
 1009+ $.wikiEditor.instances[instance] = $(this);
 1010+
 1011+ // Encapsulate the textarea with some containers for layout
 1012+ $(this)
 1013+ .wrap( $( '<div></div>' ).addClass( 'wikiEditor-ui' ).attr( 'id', 'wikiEditor-ui' ) )
 1014+ .wrap( $( '<div></div>' ).addClass( 'wikiEditor-ui-bottom' ).attr( 'id', 'wikiEditor-ui-bottom' ) )
 1015+ .wrap( $( '<div></div>' ).addClass( 'wikiEditor-ui-text' ).attr( 'id', 'wikiEditor-ui-text' ) );
 1016+
 1017+ // Get a reference to the outer container
 1018+ context.$ui = $(this).parent().parent().parent();
 1019+ context.$ui.after( $( '<div style="clear:both;"></div>' ) );
 1020+ // Attach a container in the top
 1021+ context.$ui.prepend( $( '<div></div>' ).addClass( 'wikiEditor-ui-top' ).attr( 'id', 'wikiEditor-ui-top' ) );
 1022+
 1023+ // Create a set of standard methods for internal and external use
 1024+ context.api = {
 1025+ /**
 1026+ * Accepts either a string of the name of a module to add without any
 1027+ * additional configuration parameters, or an object with members keyed with
 1028+ * module names and valued with configuration objects
 1029+ */
 1030+ addModule: function( context, data ) {
 1031+ // A safe way of calling an API function on a module
 1032+ function callModuleApi( module, call, data ) {
 1033+ if (
 1034+ module in $.wikiEditor.modules &&
 1035+ 'fn' in $.wikiEditor.modules[module] &&
 1036+ call in $.wikiEditor.modules[module].fn
 1037+ ) {
 1038+ $.wikiEditor.modules[module].fn[call]( context, data );
 1039+ }
 1040+ }
 1041+ if ( typeof data == 'string' ) {
 1042+ callModuleApi( data, 'create', {} );
 1043+ } else if ( typeof data == 'object' ) {
 1044+ for ( module in data ) {
 1045+ if ( typeof module == 'string' ) {
 1046+ callModuleApi( module, 'create', data[module] );
 1047+ }
 1048+ }
 1049+ }
 1050+ }
 1051+ };
 1052+ // Allow modules to extend the API
 1053+ for ( module in $.wikiEditor.modules ) {
 1054+ if ( 'api' in $.wikiEditor.modules[module] ) {
 1055+ for ( call in $.wikiEditor.modules[module].api ) {
 1056+ // Modules may not overwrite existing API functions - first come,
 1057+ // first serve
 1058+ if ( !( call in context.api ) ) {
 1059+ context.api[call] = $.wikiEditor.modules[module].api[call];
 1060+ }
 1061+ }
 1062+ }
 1063+ }
 1064+ //Each browser seems to do this differently, so let's keep our editor
 1065+ //consistent by always starting at the begining
 1066+ context.$textarea.scrollToCaretPosition( 0 );
 1067+}
 1068+
 1069+// If there was a configuration passed, it's assumed to be for the addModule
 1070+// API call
 1071+if ( arguments.length > 0 && typeof arguments[0] == 'object' ) {
 1072+ context.api.addModule( context, arguments[0] );
 1073+} else {
10111074 // Since javascript gives arguments as an object, we need to convert them
10121075 // so they can be used more easily
10131076 arguments = $.makeArray( arguments );
@@ -1016,80 +1079,9 @@
10171080 if ( call in context.api ) {
10181081 context.api[call]( context, arguments[0] == undefined ? {} : arguments[0] );
10191082 }
1020 - // Store the context for next time and return
1021 - return $(this).data( 'context', context );
10221083 }
1023 - // Nothing to do, just return
1024 - return $(this);
10251084 }
10261085
1027 -/* Construction */
1028 -
1029 -var instance = $.wikiEditor.instances.length;
1030 -context = { '$textarea': $(this), 'modules': {}, 'data': {}, 'instance': instance };
1031 -$.wikiEditor.instances[instance] = $(this);
1032 -
1033 -// Encapsulate the textarea with some containers for layout
1034 -$(this)
1035 - .wrap( $( '<div></div>' ).addClass( 'wikiEditor-ui' ).attr( 'id', 'wikiEditor-ui' ) )
1036 - .wrap( $( '<div></div>' ).addClass( 'wikiEditor-ui-bottom' ).attr( 'id', 'wikiEditor-ui-bottom' ) )
1037 - .wrap( $( '<div></div>' ).addClass( 'wikiEditor-ui-text' ).attr( 'id', 'wikiEditor-ui-text' ) );
1038 -
1039 -// Get a reference to the outer container
1040 -context.$ui = $(this).parent().parent().parent();
1041 -context.$ui.after( $( '<div style="clear:both;"></div>' ) );
1042 -// Attach a container in the top
1043 -context.$ui.prepend( $( '<div></div>' ).addClass( 'wikiEditor-ui-top' ).attr( 'id', 'wikiEditor-ui-top' ) );
1044 -
1045 -// Create a set of standard methods for internal and external use
1046 -context.api = {
1047 - /**
1048 - * Accepts either a string of the name of a module to add without any
1049 - * additional configuration parameters, or an object with members keyed with
1050 - * module names and valued with configuration objects
1051 - */
1052 - addModule: function( context, data ) {
1053 - // A safe way of calling an API function on a module
1054 - function callModuleApi( module, call, data ) {
1055 - if (
1056 - module in $.wikiEditor.modules &&
1057 - 'fn' in $.wikiEditor.modules[module] &&
1058 - call in $.wikiEditor.modules[module].fn
1059 - ) {
1060 - $.wikiEditor.modules[module].fn[call]( context, data );
1061 - }
1062 - }
1063 - if ( typeof data == 'string' ) {
1064 - callModuleApi( data, 'create', {} );
1065 - } else if ( typeof data == 'object' ) {
1066 - for ( module in data ) {
1067 - if ( typeof module == 'string' ) {
1068 - callModuleApi( module, 'create', data[module] );
1069 - }
1070 - }
1071 - }
1072 - }
1073 -};
1074 -// Allow modules to extend the API
1075 -for ( module in $.wikiEditor.modules ) {
1076 - if ( 'api' in $.wikiEditor.modules[module] ) {
1077 - for ( call in $.wikiEditor.modules[module].api ) {
1078 - // Modules may not overwrite existing API functions - first come,
1079 - // first serve
1080 - if ( !( call in context.api ) ) {
1081 - context.api[call] = $.wikiEditor.modules[module].api[call];
1082 - }
1083 - }
1084 - }
1085 -}
1086 -// If there was a configuration passed, it's assumed to be for the addModule
1087 -// API call, so we can just send it on it's way right now
1088 -if ( arguments.length > 0 && typeof arguments[0] == 'object' ) {
1089 - context.api.addModule( context, arguments[0] );
1090 -}
1091 -//Each browser seems to do this differently, so let's keep our editor
1092 -//consistent by always starting at the begining
1093 -context.$textarea.scrollToCaretPosition( 0 );
10941086 // Store the context for next time, and support chaining
10951087 return $(this).data( 'wikiEditor-context', context );
10961088
@@ -1782,7 +1774,7 @@
17831775 context.$textarea
17841776 .bind( 'keyup encapsulateSelection',
17851777 function( event ) {
1786 - var context = $(this).data( 'context' );
 1778+ var context = $(this).data( 'wikiEditor-context' );
17871779 $(this).eachAsync( {
17881780 bulk: 0,
17891781 loop: function() {
@@ -1792,9 +1784,9 @@
17931785 } );
17941786 }
17951787 )
1796 - .bind( 'mouseup scrollToPosition',
 1788+ .bind( 'mouseup scrollToPosition focus',
17971789 function( event ) {
1798 - var context = $(this).data( 'context' );
 1790+ var context = $(this).data( 'wikiEditor-context' );
17991791 $(this).eachAsync( {
18001792 bulk: 0,
18011793 loop: function() {
@@ -1802,15 +1794,23 @@
18031795 }
18041796 } );
18051797 }
1806 - );
 1798+ )
 1799+ .blur( function() {
 1800+ var context = $(this).data( 'wikiEditor-context' );
 1801+ $.wikiEditor.modules.toc.fn.unhighlight( context );
 1802+ });
18071803 },
 1804+
 1805+ unhighlight: function( context ) {
 1806+ context.modules.$toc.find( 'a' ).removeClass( 'currentSelection' );
 1807+ },
18081808 /**
18091809 * Highlight the section the cursor is currently within
18101810 *
18111811 * @param {Object} context
18121812 */
18131813 update: function( context ) {
1814 - context.modules.$toc.find( 'a' ).removeClass( 'currentSelection' );
 1814+ $.wikiEditor.modules.toc.fn.unhighlight( context );
18151815 var position = context.$textarea.getCaretPosition();
18161816 var section = 0;
18171817 if ( context.data.outline.length > 0 ) {
@@ -1957,4 +1957,4 @@
19581958 }
19591959 }
19601960
1961 -}; } ) ( jQuery );
\ No newline at end of file
 1961+}; } ) ( jQuery );
Index: branches/wmf-deployment-work/extensions/UsabilityInitiative/js/plugins.combined.min.js
@@ -68,13 +68,11 @@
6969 return this.each(function(){$(this).focus();if(this.selectionStart||this.selectionStart=='0'){this.selectionStart=pos;this.selectionEnd=pos;$(this).scrollTop(getCaretScrollPosition(this));}else if(document.selection&&document.selection.createRange){var range=document.selection.createRange();var oldPos=$(this).getCaretPosition();var goBack=false;if(oldPos==pos){pos++;goBack=true;}
7070 range.moveToElementText(this);range.collapse();range.move('character',pos);range.select();this.scrollTop+=range.offsetTop;if(goBack){range.move('character',-1);range.select();}}
7171 $(this).trigger('scrollToPosition');});}});})(jQuery);(function($){$.wikiEditor={'modules':{},'instances':[],'supportedBrowsers':{'ltr':{'msie':7,'firefox':2,'opera':9,'safari':3,'chrome':1,'camino':1},'rtl':{'msie':8,'firefox':2,'opera':9,'safari':3,'chrome':1,'camino':1}},imgPath:wgScriptPath+'/extensions/UsabilityInitiative/images/wikiEditor/'};$.wikiEditor.isSupportKnown=function(){return(function(supportedBrowsers){return $.browser.name in supportedBrowsers;})($.wikiEditor.supportedBrowsers[$('body.rtl').size()?'rtl':'ltr']);};$.wikiEditor.isSupported=function(){return(function(supportedBrowsers){return $.browser.name in supportedBrowsers&&$.browser.versionNumber>=supportedBrowsers[$.browser.name];})($.wikiEditor.supportedBrowsers[$('body.rtl').size()?'rtl':'ltr']);};$.wikiEditor.autoMsg=function(object,property){if(typeof property=='object'){for(i in property){if(property[i]in object||property[i]+'Msg'in object){property=property[i];break;}}}
72 -if(property in object){return object[property];}else if(property+'Msg'in object){return gM(object[property+'Msg']);}else{return'';}};$.fn.wikiEditor=function(){var context=$(this).data('wikiEditor-context');if(typeof context!=='undefined'){arguments=$.makeArray(arguments);if(arguments.length>0){var call=arguments.shift();if(call in context.api){context.api[call](context,arguments[0]==undefined?{}:arguments[0]);}
73 -return $(this).data('context',context);}
74 -return $(this);}
75 -var instance=$.wikiEditor.instances.length;context={'$textarea':$(this),'modules':{},'data':{},'instance':instance};$.wikiEditor.instances[instance]=$(this);$(this).wrap($('<div></div>').addClass('wikiEditor-ui').attr('id','wikiEditor-ui')).wrap($('<div></div>').addClass('wikiEditor-ui-bottom').attr('id','wikiEditor-ui-bottom')).wrap($('<div></div>').addClass('wikiEditor-ui-text').attr('id','wikiEditor-ui-text'));context.$ui=$(this).parent().parent().parent();context.$ui.after($('<div style="clear:both;"></div>'));context.$ui.prepend($('<div></div>').addClass('wikiEditor-ui-top').attr('id','wikiEditor-ui-top'));context.api={addModule:function(context,data){function callModuleApi(module,call,data){if(module in $.wikiEditor.modules&&'fn'in $.wikiEditor.modules[module]&&call in $.wikiEditor.modules[module].fn){$.wikiEditor.modules[module].fn[call](context,data);}}
 72+if(property in object){return object[property];}else if(property+'Msg'in object){return gM(object[property+'Msg']);}else{return'';}};$.fn.wikiEditor=function(){var context=$(this).data('wikiEditor-context');if(typeof context=='undefined'){var instance=$.wikiEditor.instances.length;context={'$textarea':$(this),'modules':{},'data':{},'instance':instance};$.wikiEditor.instances[instance]=$(this);$(this).wrap($('<div></div>').addClass('wikiEditor-ui').attr('id','wikiEditor-ui')).wrap($('<div></div>').addClass('wikiEditor-ui-bottom').attr('id','wikiEditor-ui-bottom')).wrap($('<div></div>').addClass('wikiEditor-ui-text').attr('id','wikiEditor-ui-text'));context.$ui=$(this).parent().parent().parent();context.$ui.after($('<div style="clear:both;"></div>'));context.$ui.prepend($('<div></div>').addClass('wikiEditor-ui-top').attr('id','wikiEditor-ui-top'));context.api={addModule:function(context,data){function callModuleApi(module,call,data){if(module in $.wikiEditor.modules&&'fn'in $.wikiEditor.modules[module]&&call in $.wikiEditor.modules[module].fn){$.wikiEditor.modules[module].fn[call](context,data);}}
7673 if(typeof data=='string'){callModuleApi(data,'create',{});}else if(typeof data=='object'){for(module in data){if(typeof module=='string'){callModuleApi(module,'create',data[module]);}}}}};for(module in $.wikiEditor.modules){if('api'in $.wikiEditor.modules[module]){for(call in $.wikiEditor.modules[module].api){if(!(call in context.api)){context.api[call]=$.wikiEditor.modules[module].api[call];}}}}
77 -if(arguments.length>0&&typeof arguments[0]=='object'){context.api.addModule(context,arguments[0]);}
78 -context.$textarea.scrollToCaretPosition(0);return $(this).data('wikiEditor-context',context);};})(jQuery);RegExp.escape=function(s){return s.replace(/([.*+?^${}()|\/\\[\]])/g,'\\$1');};(function($){$.wikiEditor.modules.dialogs={api:{addDialog:function(context,data){$.wikiEditor.modules.dialogs.fn.create(context,{'modules':data})},openDialog:function(context,data){if(data.dialog in $.wikiEditor.modules.dialogs.modules){$('#'+$.wikiEditor.modules.dialogs.modules[data.dialog].id).dialog('open');}},closeDialog:function(context,data){if(data.dialog in $.wikiEditor.modules.dialogs.modules){$('#'+$.wikiEditor.modules.dialogs.modules[data.dialog].id).dialog('close');}}},fn:{create:function(context,config){for(module in config){$.wikiEditor.modules.dialogs.modules[module]=config[module];}
 74+context.$textarea.scrollToCaretPosition(0);}
 75+if(arguments.length>0&&typeof arguments[0]=='object'){context.api.addModule(context,arguments[0]);}else{arguments=$.makeArray(arguments);if(arguments.length>0){var call=arguments.shift();if(call in context.api){context.api[call](context,arguments[0]==undefined?{}:arguments[0]);}}}
 76+return $(this).data('wikiEditor-context',context);};})(jQuery);RegExp.escape=function(s){return s.replace(/([.*+?^${}()|\/\\[\]])/g,'\\$1');};(function($){$.wikiEditor.modules.dialogs={api:{addDialog:function(context,data){$.wikiEditor.modules.dialogs.fn.create(context,{'modules':data})},openDialog:function(context,data){if(data.dialog in $.wikiEditor.modules.dialogs.modules){$('#'+$.wikiEditor.modules.dialogs.modules[data.dialog].id).dialog('open');}},closeDialog:function(context,data){if(data.dialog in $.wikiEditor.modules.dialogs.modules){$('#'+$.wikiEditor.modules.dialogs.modules[data.dialog].id).dialog('close');}}},fn:{create:function(context,config){for(module in config){$.wikiEditor.modules.dialogs.modules[module]=config[module];}
7977 for(module in $.wikiEditor.modules.dialogs.modules){var module=$.wikiEditor.modules.dialogs.modules[module];if($('#'+module.id).size()==0){var configuration=module.dialog;configuration.bgiframe=true;configuration.autoOpen=false;configuration.modal=true;configuration.title=$.wikiEditor.autoMsg(module,'title');for(msg in configuration.buttons){configuration.buttons[gM(msg)]=configuration.buttons[msg];delete configuration.buttons[msg];}
8078 $('<div /> ').attr('id',module.id).html(module.html).data('context',context).appendTo($('body')).each(module.init).dialog(configuration);}}}},'modules':{}};})(jQuery);(function($){$.wikiEditor.modules.toolbar={api:{addToToolbar:function(context,data){for(type in data){switch(type){case'sections':var $sections=context.modules.$toolbar.find('div.sections');var $tabs=context.modules.$toolbar.find('div.tabs');for(section in data[type]){if(section=='main'){context.modules.$toolbar.prepend($.wikiEditor.modules.toolbar.fn.buildSection(context,section,data[type][section]));continue;}
8179 $sections.append($.wikiEditor.modules.toolbar.fn.buildSection(context,section,data[type][section]));$tabs.append($.wikiEditor.modules.toolbar.fn.buildTab(context,section,data[type][section]));}
@@ -123,7 +121,7 @@
124122 return $section;},updateBookletSelection:function(context,id,$pages,$index){var cookie='wikiEditor-'+context.instance+'-booklet-'+id+'-page';var selected=$.cookie(cookie);var $selectedIndex=$index.find('*[rel='+selected+']');if($selectedIndex.size()==0){selected=$index.children().eq(0).attr('rel');$.cookie(cookie,selected);}
125123 $pages.children().hide();$pages.find('*[rel='+selected+']').show();$index.children().removeClass('current');$selectedIndex.addClass('current');},build:function(context,config){var $tabs=$('<div />').addClass('tabs').appendTo(context.modules.$toolbar);var $sections=$('<div />').addClass('sections').appendTo(context.modules.$toolbar);context.modules.$toolbar.append($('<div />').css('clear','both'));var sectionQueue=[];for(section in config){if(section=='main'){context.modules.$toolbar.prepend($.wikiEditor.modules.toolbar.fn.buildSection(context,section,config[section]));}else{sectionQueue.push({'$sections':$sections,'context':context,'id':section,'config':config[section]});$tabs.append($.wikiEditor.modules.toolbar.fn.buildTab(context,section,config[section]));}}
126124 $.eachAsync(sectionQueue,{'bulk':0,'end':function(){$('body').css('position','static');$('body').css('position','relative');},'loop':function(i,s){s.$sections.append($.wikiEditor.modules.toolbar.fn.buildSection(s.context,s.id,s.config));}});}}};})(jQuery);(function($){$.wikiEditor.modules.toc={api:{},fn:{create:function(context,config){if('$toc'in context.modules){return;}
127 -context.modules.$toc=$('<div></div>').addClass('wikiEditor-ui-toc').attr('id','wikiEditor-ui-toc');$.wikiEditor.modules.toc.fn.build(context,config);context.$ui.find('.wikiEditor-ui-bottom').append(context.modules.$toc);context.modules.$toc.height(context.$ui.find('.wikiEditor-ui-bottom').height());context.modules.$toc.css('width','12em').css('marginTop',-(context.$ui.find('.wikiEditor-ui-bottom').height()));context.$ui.find('.wikiEditor-ui-text').css(($('body.rtl').size()?'marginLeft':'marginRight'),'12em');$.wikiEditor.modules.toc.fn.build(context);$.wikiEditor.modules.toc.fn.update(context);context.$textarea.bind('keyup encapsulateSelection',function(event){var context=$(this).data('context');$(this).eachAsync({bulk:0,loop:function(){$.wikiEditor.modules.toc.fn.build(context);$.wikiEditor.modules.toc.fn.update(context);}});}).bind('mouseup scrollToPosition',function(event){var context=$(this).data('context');$(this).eachAsync({bulk:0,loop:function(){$.wikiEditor.modules.toc.fn.update(context);}});});},update:function(context){context.modules.$toc.find('a').removeClass('currentSelection');var position=context.$textarea.getCaretPosition();var section=0;if(context.data.outline.length>0){if(!(position<context.data.outline[0].position-1)){while(section<context.data.outline.length&&context.data.outline[section].position-1<position){section++;}
 125+context.modules.$toc=$('<div></div>').addClass('wikiEditor-ui-toc').attr('id','wikiEditor-ui-toc');$.wikiEditor.modules.toc.fn.build(context,config);context.$ui.find('.wikiEditor-ui-bottom').append(context.modules.$toc);context.modules.$toc.height(context.$ui.find('.wikiEditor-ui-bottom').height());context.modules.$toc.css('width','12em').css('marginTop',-(context.$ui.find('.wikiEditor-ui-bottom').height()));context.$ui.find('.wikiEditor-ui-text').css(($('body.rtl').size()?'marginLeft':'marginRight'),'12em');$.wikiEditor.modules.toc.fn.build(context);$.wikiEditor.modules.toc.fn.update(context);context.$textarea.bind('keyup encapsulateSelection',function(event){var context=$(this).data('wikiEditor-context');$(this).eachAsync({bulk:0,loop:function(){$.wikiEditor.modules.toc.fn.build(context);$.wikiEditor.modules.toc.fn.update(context);}});}).bind('mouseup scrollToPosition focus',function(event){var context=$(this).data('wikiEditor-context');$(this).eachAsync({bulk:0,loop:function(){$.wikiEditor.modules.toc.fn.update(context);}});}).blur(function(){var context=$(this).data('wikiEditor-context');$.wikiEditor.modules.toc.fn.unhighlight(context);});},unhighlight:function(context){context.modules.$toc.find('a').removeClass('currentSelection');},update:function(context){$.wikiEditor.modules.toc.fn.unhighlight(context);var position=context.$textarea.getCaretPosition();var section=0;if(context.data.outline.length>0){if(!(position<context.data.outline[0].position-1)){while(section<context.data.outline.length&&context.data.outline[section].position-1<position){section++;}
128126 section=Math.max(0,section);}
129127 context.modules.$toc.find('a.section-'+section).addClass('currentSelection');}},build:function(context){function buildStructure(outline,offset,level){if(offset==undefined)offset=0;if(level==undefined)level=1;var sections=[];for(var i=offset;i<outline.length;i++){if(outline[i].nLevel==level){var sub=buildStructure(outline,i+1,level+1);if(sub.length){outline[i].sections=sub;}
130128 sections[sections.length]=outline[i];}else if(outline[i].nLevel<level){break;}}
Index: branches/wmf-deployment-work/extensions/UsabilityInitiative/NavigableTOC/NavigableTOC.hooks.php
@@ -15,14 +15,36 @@
1616 * Adds the TOC to the edit form
1717 */
1818 public static function addTOC( &$toolbar ) {
19 - global $wgNavigableTOCStyleVersion, $wgParser, $wgUser;
20 - global $wgEnableParserCache;
 19+ global $wgNavigableTOCStyleVersion, $wgUser;
 20+ global $wgNavigableTOCGlobalEnable, $wgNavigableTOCUserEnable;
2121
22 - // Adds script to document
23 - UsabilityInitiativeHooks::initialize();
24 - UsabilityInitiativeHooks::addScript(
25 - 'NavigableTOC/NavigableTOC.js', $wgNavigableTOCStyleVersion
26 - );
 22+ if ( $wgNavigableTOCGlobalEnable || ( $wgNavigableTOCUserEnable && $wgUser->getOption( 'usenavigabletoc' ) ) ) {
 23+ // Adds script to document
 24+ UsabilityInitiativeHooks::initialize();
 25+ UsabilityInitiativeHooks::addScript(
 26+ 'NavigableTOC/NavigableTOC.js', $wgNavigableTOCStyleVersion
 27+ );
 28+ }
2729 return true;
2830 }
 31+
 32+ /**
 33+ * GetPreferences hook
 34+ * Add NTOC-related items to the preferences
 35+ */
 36+ public static function addPreferences( $user, &$defaultPreferences ) {
 37+ global $wgNavigableTOCGlobalEnable, $wgNavigableTOCUserEnable;
 38+
 39+ if ( !$wgNavigableTOCGlobalEnable && $wgNavigableTOCUserEnable ) {
 40+ wfLoadExtensionMessages( 'NavigableTOC' );
 41+ // Adds preference for opting in
 42+ $defaultPreferences['usenavigabletoc'] =
 43+ array(
 44+ 'type' => 'toggle',
 45+ 'label-message' => 'navigabletoc-preference',
 46+ 'section' => 'editing/advancedediting',
 47+ );
 48+ }
 49+ return true;
 50+ }
2951 }
Index: branches/wmf-deployment-work/extensions/UsabilityInitiative/NavigableTOC/NavigableTOC.i18n.php
@@ -14,6 +14,7 @@
1515 $messages['en'] = array(
1616 'navigabletoc' => 'Navigable table of contents',
1717 'navigabletoc-desc' => 'Adds a table of contents to the edit form that scrolls the text box when a section is clicked',
 18+ 'navigabletoc-preference' => 'Enable navigable table of contents',
1819 );
1920
2021 /** Afrikaans (Afrikaans)
Index: branches/wmf-deployment-work/extensions/UsabilityInitiative/NavigableTOC/NavigableTOC.php
@@ -18,6 +18,14 @@
1919
2020 /* Configuration */
2121
 22+// Set this to true to simply force NavigableTOC on everyone
 23+$wgNavigableTOCGlobalEnable = false;
 24+
 25+// Set this to true to add a preference to the editing section of preferences
 26+// which enables and disables NavigableTOC (if $wgNavigableTOCGlobalEnable, this
 27+// will not do anything)
 28+$wgNavigableTOCUserEnable = true;
 29+
2230 // Bump the version number every time you change any of the .css/.js files
2331 $wgNavigableTOCStyleVersion = 3;
2432
@@ -45,4 +53,5 @@
4654 dirname( __FILE__ ) . '/NavigableTOC.i18n.php';
4755
4856 // Registers Hooks
49 -$wgHooks['EditPageBeforeEditToolbar'][] = 'NavigableTOCHooks::addTOC';
\ No newline at end of file
 57+$wgHooks['EditPageBeforeEditToolbar'][] = 'NavigableTOCHooks::addTOC';
 58+$wgHooks['GetPreferences'][] = 'NavigableTOCHooks::addPreferences';
Index: branches/wmf-deployment-work/extensions/UsabilityInitiative/UsabilityInitiative.php
@@ -45,3 +45,4 @@
4646
4747 // Registers Hooks
4848 $wgHooks['BeforePageDisplay'][] = 'UsabilityInitiativeHooks::addResources';
 49+$wgHooks['MakeGlobalVariablesScript'][] = 'UsabilityInitiativeHooks::addJSVars';
\ No newline at end of file
Index: branches/wmf-deployment-work/extensions/UsabilityInitiative/UsabilityInitiative.hooks.php
@@ -62,17 +62,17 @@
6363 array( 'src' => 'js/plugins/jquery.namespaceSelect.js', 'version' => 0 ),
6464 array( 'src' => 'js/plugins/jquery.suggestions.js', 'version' => 2 ),
6565 array( 'src' => 'js/plugins/jquery.textSelection.js', 'version' => 9 ),
66 - array( 'src' => 'js/plugins/jquery.wikiEditor.js', 'version' => 4 ),
 66+ array( 'src' => 'js/plugins/jquery.wikiEditor.js', 'version' => 5 ),
6767 array( 'src' => 'js/plugins/jquery.wikiEditor.toolbar.js', 'version' => 11 ),
68 - array( 'src' => 'js/plugins/jquery.wikiEditor.dialogs.js', 'version' => 1 ),
 68+ array( 'src' => 'js/plugins/jquery.wikiEditor.dialogs.js', 'version' => 2 ),
6969 array( 'src' => 'js/plugins/jquery.wikiEditor.toc.js', 'version' => 6 ),
7070 array( 'src' => 'js/js2/jquery-ui-1.7.2.js', 'version' => '1.7.2x' ),
7171 ),
7272 'combined' => array(
73 - array( 'src' => 'js/plugins.combined.js', 'version' => 17 ),
 73+ array( 'src' => 'js/plugins.combined.js', 'version' => 22 ),
7474 ),
7575 'minified' => array(
76 - array( 'src' => 'js/plugins.combined.min.js', 'version' => 17 ),
 76+ array( 'src' => 'js/plugins.combined.min.js', 'version' => 22 ),
7777 ),
7878 ),
7979 );
@@ -124,31 +124,7 @@
125125
126126 if ( !self::$doOutput )
127127 return true;
128 - // Transforms variables into javascript global variables
129 - foreach ( self::$variables as $key => $value ) {
130 - $escapedVariableValue = Xml::escapeJsString( $value );
131 - $escapedVariableKey = Xml::escapeJsString( $key );
132 - self::$variables[$key] =
133 - "var {$escapedVariableKey} = '{$escapedVariableValue}';";
134 - }
135128
136 - //literal variables, ie ones we do not want escaped as strings
137 - foreach( self::$literalVariables as $key => $value){
138 - $escapedVariableValue = Xml::escapeJsString( $value );
139 - $escapedVariableKey = Xml::escapeJsString( $key );
140 - self::$variables[$key] =
141 - "var {$escapedVariableKey} = {$escapedVariableValue};";
142 - }
143 - if ( count( self::$variables ) > 0 ) {
144 - $out->addScript(
145 - Xml::tags(
146 - 'script',
147 - array( 'type' => $wgJsMimeType ),
148 - implode( self::$variables )
149 - )
150 - );
151 - }
152 -
153129 // Loops over each script
154130 foreach ( self::$scripts as $script ) {
155131 // Add javascript to document
@@ -198,6 +174,14 @@
199175 }
200176 return true;
201177 }
 178+
 179+ /**
 180+ * MakeGlobalVariablesScript hook
 181+ */
 182+ public static function addJSVars( &$vars ) {
 183+ $vars = array_merge( $vars, self::$variables );
 184+ return true;
 185+ }
202186
203187 /**
204188 * Adds a reference to a javascript file to the head of the document
@@ -233,13 +217,4 @@
234218 public static function addVariables( $variables ) {
235219 self::$variables = array_merge( self::$variables, $variables );
236220 }
237 -
238 - /**
239 - * Adds variables that will be turned into global variables in JS, but not escaped as strings
240 - * @param $variables array of "name" => "value"
241 - */
242 - public static function addLiteralVariables( $variables ) {
243 - self::$literalVariables = array_merge( self::$literalVariables, $variables );
244 - }
245 -
246221 }
Property changes on: branches/wmf-deployment-work/extensions/UsabilityInitiative
___________________________________________________________________
Added: svn:mergeinfo
247222 Merged /trunk/phase3/extensions/UsabilityInitiative:r56213,56215-56216,56218,56325,56334-56336,56338,56340,56343,56345,56347,56350
248223 Merged /branches/REL1_15/phase3/extensions/UsabilityInitiative:r51646
249224 Merged /trunk/extensions/UsabilityInitiative:r56207,56209,56296,56333,56355,56417

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r56195NavigableTOC: (bug 20585) Unhighlight section in NTOC when textarea loses focuscatrope18:13, 11 September 2009
r56417UsabilityInitiative:...catrope15:33, 16 September 2009

Status & tagging log