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 |
1 | 1 | + 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 |
2 | 2 | + application/octet-stream |
Index: branches/wmf-deployment-work/extensions/UsabilityInitiative/ClickTracking/ClickTracking.hooks.php |
— | — | @@ -62,7 +62,7 @@ |
63 | 63 | 'wgTrackingToken' => ClickTrackingHooks::get_session_id() |
64 | 64 | ) |
65 | 65 | ); |
66 | | - UsabilityInitiativeHooks::addLiteralVariables( |
| 66 | + UsabilityInitiativeHooks::addVariables( |
67 | 67 | array( |
68 | 68 | 'wgClickTrackingIsThrottled' => ClickTrackingHooks::isUserThrottled() |
69 | 69 | ) |
Index: branches/wmf-deployment-work/extensions/UsabilityInitiative/EditToolbar/EditToolbar.i18n.php |
— | — | @@ -15,12 +15,17 @@ |
16 | 16 | 'edittoolbar' => 'Editing toolbar', |
17 | 17 | 'edittoolbar-desc' => 'Edit page toolbar with enhanced usability', |
18 | 18 | 'edittoolbar-preference' => 'Enable enhanced editing toolbar', |
| 19 | + 'edittoolbar-cgd-preference' => 'Enable content generation dialogs in enhanced editing toolbar', |
19 | 20 | 'edittoolbar-loading' => 'Loading...', |
20 | 21 | /* Main Section */ |
21 | 22 | 'edittoolbar-tool-bold' => 'Bold', |
22 | 23 | 'edittoolbar-tool-bold-example' => 'Bold text', |
23 | 24 | 'edittoolbar-tool-italic' => 'Italic', |
24 | 25 | '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', |
25 | 30 | 'edittoolbar-tool-link' => 'Link', |
26 | 31 | 'edittoolbar-tool-link-title' => 'Insert link', |
27 | 32 | 'edittoolbar-tool-link-int' => 'To a wiki page', |
— | — | @@ -72,6 +77,18 @@ |
73 | 78 | {{ns:file}}:Example.jpg|Caption2", |
74 | 79 | 'edittoolbar-tool-newline' => 'New line', |
75 | 80 | '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", |
76 | 93 | 'edittoolbar-tool-table-example' => 'Row $1, cell $2', |
77 | 94 | 'edittoolbar-tool-table-example-header' => 'Row $1, cell $2 (header)', |
78 | 95 | 'edittoolbar-tool-table-title' => 'Insert table', |
Index: branches/wmf-deployment-work/extensions/UsabilityInitiative/EditToolbar/EditToolbar.php |
— | — | @@ -19,7 +19,7 @@ |
20 | 20 | /* Configuration */ |
21 | 21 | |
22 | 22 | // Bump the version number every time you change any of the .css/.js files |
23 | | -$wgEditToolbarStyleVersion = 28; |
| 23 | +$wgEditToolbarStyleVersion = 33; |
24 | 24 | |
25 | 25 | // Set this to true to simply override the stock toolbar for everyone |
26 | 26 | $wgEditToolbarGlobalEnable = false; |
— | — | @@ -29,6 +29,15 @@ |
30 | 30 | // will not do anything) |
31 | 31 | $wgEditToolbarUserEnable = true; |
32 | 32 | |
| 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 | + |
33 | 42 | // Set if we should include a client-side testing script |
34 | 43 | $wgEditToolbarRunTests = false; |
35 | 44 | |
Index: branches/wmf-deployment-work/extensions/UsabilityInitiative/EditToolbar/EditToolbar.hooks.php |
— | — | @@ -15,7 +15,9 @@ |
16 | 16 | * Intercept the display of the toolbar, replacing the content of $toolbar |
17 | 17 | */ |
18 | 18 | public static function addToolbar( &$toolbar ) { |
19 | | - global $wgUser, $wgEditToolbarGlobalEnable, $wgEditToolbarUserEnable; |
| 19 | + global $wgUser, $wgEditToolbarGlobalEnable; |
| 20 | + global $wgEditToolbarUserEnable, $wgEditToolbarCGDGlobalEnable; |
| 21 | + global $wgEditToolbarCGDUserEnable; |
20 | 22 | |
21 | 23 | // Only proceed if some specific conditions are met |
22 | 24 | if ( $wgEditToolbarGlobalEnable || ( $wgEditToolbarUserEnable && $wgUser->getOption( 'usebetatoolbar' ) ) ) { |
— | — | @@ -25,6 +27,9 @@ |
26 | 28 | UsabilityInitiativeHooks::addScript( |
27 | 29 | 'EditToolbar/EditToolbar.js', $wgEditToolbarStyleVersion |
28 | 30 | ); |
| 31 | + UsabilityInitiativeHooks::addVariables( array( |
| 32 | + 'wgEditToolbarCGD' => $wgEditToolbarCGDGlobalEnable || ( $wgEditToolbarCGDUserEnable && $wgUser->getOption( 'usebetatoolbar-cgd' ) ) |
| 33 | + ) ); |
29 | 34 | // Internationalization |
30 | 35 | wfLoadExtensionMessages( 'EditToolbar' ); |
31 | 36 | UsabilityInitiativeHooks::addMessages( |
— | — | @@ -35,6 +40,10 @@ |
36 | 41 | 'edittoolbar-tool-bold-example', |
37 | 42 | 'edittoolbar-tool-italic', |
38 | 43 | 'edittoolbar-tool-italic-example', |
| 44 | + 'edittoolbar-tool-ilink', |
| 45 | + 'edittoolbar-tool-ilink-example', |
| 46 | + 'edittoolbar-tool-xlink', |
| 47 | + 'edittoolbar-tool-xlink-example', |
39 | 48 | 'edittoolbar-tool-link', |
40 | 49 | 'edittoolbar-tool-link-title', |
41 | 50 | 'edittoolbar-tool-link-int', |
— | — | @@ -85,6 +94,7 @@ |
86 | 95 | 'edittoolbar-tool-gallery-example', |
87 | 96 | 'edittoolbar-tool-newline', |
88 | 97 | 'edittoolbar-tool-table', |
| 98 | + 'edittoolbar-tool-table-example-old', |
89 | 99 | 'edittoolbar-tool-table-example', |
90 | 100 | 'edittoolbar-tool-table-example-header', |
91 | 101 | 'edittoolbar-tool-table-title', |
— | — | @@ -196,15 +206,9 @@ |
197 | 207 | */ |
198 | 208 | public static function addPreferences( $user, &$defaultPreferences ) { |
199 | 209 | global $wgEditToolbarGlobalEnable, $wgEditToolbarUserEnable; |
| 210 | + global $wgEditToolbarCGDGlobalEnable, $wgEditToolbarCGDUserEnable; |
200 | 211 | |
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 ) { |
209 | 213 | wfLoadExtensionMessages( 'EditToolbar' ); |
210 | 214 | // Adds preference for opting in |
211 | 215 | $defaultPreferences['usebetatoolbar'] = |
— | — | @@ -214,6 +218,15 @@ |
215 | 219 | 'section' => 'editing/advancedediting', |
216 | 220 | ); |
217 | 221 | } |
| 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 | + } |
218 | 231 | return true; |
219 | 232 | } |
220 | 233 | } |
Index: branches/wmf-deployment-work/extensions/UsabilityInitiative/EditToolbar/EditToolbar.js |
— | — | @@ -1,6 +1,10 @@ |
2 | 2 | /* JavaScript for EditToolbar extension */ |
3 | 3 | |
4 | 4 | js2AddOnloadHook( function() { |
| 5 | + // Only show content generation dialogs if enabled |
| 6 | + if ( typeof wgEditToolbarCGD != 'undefined' && wgEditToolbarCGD ) |
| 7 | + $j( '#wpTextbox1' ).addClass( 'withCGD' ); |
| 8 | + |
5 | 9 | if ( $j.wikiEditor != undefined && $j.wikiEditor.isSupported() || !$j.wikiEditor.isSupportKnown() ) { |
6 | 10 | // Remove the old toolbar |
7 | 11 | $j( '#toolbar' ).remove(); |
— | — | @@ -47,10 +51,39 @@ |
48 | 52 | }, |
49 | 53 | 'insert': { |
50 | 54 | 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': { |
52 | 84 | labelMsg: 'edittoolbar-tool-link', |
53 | 85 | type: 'button', |
54 | 86 | icon: 'insert-link.png', |
| 87 | + filters: [ '#wpTextbox1.withCGD' ], |
55 | 88 | action: { |
56 | 89 | type: 'dialog', |
57 | 90 | module: 'insert-link' |
— | — | @@ -271,15 +304,30 @@ |
272 | 305 | } |
273 | 306 | } |
274 | 307 | }, |
275 | | - 'table': { |
| 308 | + 'tableCGD': { |
276 | 309 | labelMsg: 'edittoolbar-tool-table', |
277 | 310 | type: 'button', |
278 | 311 | icon: 'insert-table.png', |
| 312 | + filters: [ '#wpTextbox1.withCGD' ], |
279 | 313 | action: { |
280 | 314 | type: 'dialog', |
281 | 315 | module: 'insert-table' |
282 | 316 | } |
283 | 317 | }, |
| 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 | + }, |
284 | 332 | 'newline': { |
285 | 333 | labelMsg: 'edittoolbar-tool-newline', |
286 | 334 | type: 'button', |
— | — | @@ -299,6 +347,7 @@ |
300 | 348 | labelMsg: 'edittoolbar-tool-replace', |
301 | 349 | type: 'button', |
302 | 350 | icon: 'search-replace.png', |
| 351 | + filters: [ '#wpTextbox1.withCGD' ], |
303 | 352 | action: { |
304 | 353 | type: 'dialog', |
305 | 354 | module: 'search-and-replace' |
Index: branches/wmf-deployment-work/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.js |
— | — | @@ -65,96 +65,88 @@ |
66 | 66 | // gets called again we can pick up where we left off |
67 | 67 | var context = $(this).data( 'wikiEditor-context' ); |
68 | 68 | |
69 | | -/* API */ |
70 | 69 | |
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 | + } |
126 | 105 | } |
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 | + } |
134 | 113 | } |
135 | 114 | } |
136 | 115 | } |
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 | + } |
147 | 126 | } |
148 | 127 | } |
149 | 128 | } |
| 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 ); |
150 | 132 | } |
| 133 | + |
151 | 134 | // 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 |
153 | 136 | if ( arguments.length > 0 && typeof arguments[0] == 'object' ) { |
154 | 137 | 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 | + } |
155 | 149 | } |
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 | + |
159 | 151 | // Store the context for next time, and support chaining |
160 | 152 | return $(this).data( 'wikiEditor-context', context ); |
161 | 153 | |
Index: branches/wmf-deployment-work/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.toc.js |
— | — | @@ -45,7 +45,7 @@ |
46 | 46 | context.$textarea |
47 | 47 | .bind( 'keyup encapsulateSelection', |
48 | 48 | function( event ) { |
49 | | - var context = $(this).data( 'context' ); |
| 49 | + var context = $(this).data( 'wikiEditor-context' ); |
50 | 50 | $(this).eachAsync( { |
51 | 51 | bulk: 0, |
52 | 52 | loop: function() { |
— | — | @@ -55,9 +55,9 @@ |
56 | 56 | } ); |
57 | 57 | } |
58 | 58 | ) |
59 | | - .bind( 'mouseup scrollToPosition', |
| 59 | + .bind( 'mouseup scrollToPosition focus', |
60 | 60 | function( event ) { |
61 | | - var context = $(this).data( 'context' ); |
| 61 | + var context = $(this).data( 'wikiEditor-context' ); |
62 | 62 | $(this).eachAsync( { |
63 | 63 | bulk: 0, |
64 | 64 | loop: function() { |
— | — | @@ -65,15 +65,23 @@ |
66 | 66 | } |
67 | 67 | } ); |
68 | 68 | } |
69 | | - ); |
| 69 | + ) |
| 70 | + .blur( function() { |
| 71 | + var context = $(this).data( 'wikiEditor-context' ); |
| 72 | + $.wikiEditor.modules.toc.fn.unhighlight( context ); |
| 73 | + }); |
70 | 74 | }, |
| 75 | + |
| 76 | + unhighlight: function( context ) { |
| 77 | + context.modules.$toc.find( 'a' ).removeClass( 'currentSelection' ); |
| 78 | + }, |
71 | 79 | /** |
72 | 80 | * Highlight the section the cursor is currently within |
73 | 81 | * |
74 | 82 | * @param {Object} context |
75 | 83 | */ |
76 | 84 | update: function( context ) { |
77 | | - context.modules.$toc.find( 'a' ).removeClass( 'currentSelection' ); |
| 85 | + $.wikiEditor.modules.toc.fn.unhighlight( context ); |
78 | 86 | var position = context.$textarea.getCaretPosition(); |
79 | 87 | var section = 0; |
80 | 88 | if ( context.data.outline.length > 0 ) { |
— | — | @@ -220,4 +228,4 @@ |
221 | 229 | } |
222 | 230 | } |
223 | 231 | |
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 |
225 | 233 | Merged /trunk/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.toc.js:r56195,56207,56209,56296,56333,56355,56417 |
226 | 234 | Merged /trunk/phase3/extensions/UsabilityInitiative/js/plugins/jquery.wikiEditor.toc.js:r56213,56215-56216,56218,56325,56334-56336,56338,56340,56343,56345,56347,56350 |
227 | 235 | 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 @@ |
1001 | 1001 | // gets called again we can pick up where we left off |
1002 | 1002 | var context = $(this).data( 'wikiEditor-context' ); |
1003 | 1003 | |
1004 | | -/* API */ |
1005 | 1004 | |
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 { |
1011 | 1074 | // Since javascript gives arguments as an object, we need to convert them |
1012 | 1075 | // so they can be used more easily |
1013 | 1076 | arguments = $.makeArray( arguments ); |
— | — | @@ -1016,80 +1079,9 @@ |
1017 | 1080 | if ( call in context.api ) { |
1018 | 1081 | context.api[call]( context, arguments[0] == undefined ? {} : arguments[0] ); |
1019 | 1082 | } |
1020 | | - // Store the context for next time and return |
1021 | | - return $(this).data( 'context', context ); |
1022 | 1083 | } |
1023 | | - // Nothing to do, just return |
1024 | | - return $(this); |
1025 | 1084 | } |
1026 | 1085 | |
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 ); |
1094 | 1086 | // Store the context for next time, and support chaining |
1095 | 1087 | return $(this).data( 'wikiEditor-context', context ); |
1096 | 1088 | |
— | — | @@ -1782,7 +1774,7 @@ |
1783 | 1775 | context.$textarea |
1784 | 1776 | .bind( 'keyup encapsulateSelection', |
1785 | 1777 | function( event ) { |
1786 | | - var context = $(this).data( 'context' ); |
| 1778 | + var context = $(this).data( 'wikiEditor-context' ); |
1787 | 1779 | $(this).eachAsync( { |
1788 | 1780 | bulk: 0, |
1789 | 1781 | loop: function() { |
— | — | @@ -1792,9 +1784,9 @@ |
1793 | 1785 | } ); |
1794 | 1786 | } |
1795 | 1787 | ) |
1796 | | - .bind( 'mouseup scrollToPosition', |
| 1788 | + .bind( 'mouseup scrollToPosition focus', |
1797 | 1789 | function( event ) { |
1798 | | - var context = $(this).data( 'context' ); |
| 1790 | + var context = $(this).data( 'wikiEditor-context' ); |
1799 | 1791 | $(this).eachAsync( { |
1800 | 1792 | bulk: 0, |
1801 | 1793 | loop: function() { |
— | — | @@ -1802,15 +1794,23 @@ |
1803 | 1795 | } |
1804 | 1796 | } ); |
1805 | 1797 | } |
1806 | | - ); |
| 1798 | + ) |
| 1799 | + .blur( function() { |
| 1800 | + var context = $(this).data( 'wikiEditor-context' ); |
| 1801 | + $.wikiEditor.modules.toc.fn.unhighlight( context ); |
| 1802 | + }); |
1807 | 1803 | }, |
| 1804 | + |
| 1805 | + unhighlight: function( context ) { |
| 1806 | + context.modules.$toc.find( 'a' ).removeClass( 'currentSelection' ); |
| 1807 | + }, |
1808 | 1808 | /** |
1809 | 1809 | * Highlight the section the cursor is currently within |
1810 | 1810 | * |
1811 | 1811 | * @param {Object} context |
1812 | 1812 | */ |
1813 | 1813 | update: function( context ) { |
1814 | | - context.modules.$toc.find( 'a' ).removeClass( 'currentSelection' ); |
| 1814 | + $.wikiEditor.modules.toc.fn.unhighlight( context ); |
1815 | 1815 | var position = context.$textarea.getCaretPosition(); |
1816 | 1816 | var section = 0; |
1817 | 1817 | if ( context.data.outline.length > 0 ) { |
— | — | @@ -1957,4 +1957,4 @@ |
1958 | 1958 | } |
1959 | 1959 | } |
1960 | 1960 | |
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 @@ |
69 | 69 | 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;} |
70 | 70 | range.moveToElementText(this);range.collapse();range.move('character',pos);range.select();this.scrollTop+=range.offsetTop;if(goBack){range.move('character',-1);range.select();}} |
71 | 71 | $(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);}} |
76 | 73 | 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];} |
79 | 77 | 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];} |
80 | 78 | $('<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;} |
81 | 79 | $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 @@ |
124 | 122 | 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);} |
125 | 123 | $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]));}} |
126 | 124 | $.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++;} |
128 | 126 | section=Math.max(0,section);} |
129 | 127 | 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;} |
130 | 128 | 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 @@ |
16 | 16 | * Adds the TOC to the edit form |
17 | 17 | */ |
18 | 18 | public static function addTOC( &$toolbar ) { |
19 | | - global $wgNavigableTOCStyleVersion, $wgParser, $wgUser; |
20 | | - global $wgEnableParserCache; |
| 19 | + global $wgNavigableTOCStyleVersion, $wgUser; |
| 20 | + global $wgNavigableTOCGlobalEnable, $wgNavigableTOCUserEnable; |
21 | 21 | |
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 | + } |
27 | 29 | return true; |
28 | 30 | } |
| 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 | + } |
29 | 51 | } |
Index: branches/wmf-deployment-work/extensions/UsabilityInitiative/NavigableTOC/NavigableTOC.i18n.php |
— | — | @@ -14,6 +14,7 @@ |
15 | 15 | $messages['en'] = array( |
16 | 16 | 'navigabletoc' => 'Navigable table of contents', |
17 | 17 | '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', |
18 | 19 | ); |
19 | 20 | |
20 | 21 | /** Afrikaans (Afrikaans) |
Index: branches/wmf-deployment-work/extensions/UsabilityInitiative/NavigableTOC/NavigableTOC.php |
— | — | @@ -18,6 +18,14 @@ |
19 | 19 | |
20 | 20 | /* Configuration */ |
21 | 21 | |
| 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 | + |
22 | 30 | // Bump the version number every time you change any of the .css/.js files |
23 | 31 | $wgNavigableTOCStyleVersion = 3; |
24 | 32 | |
— | — | @@ -45,4 +53,5 @@ |
46 | 54 | dirname( __FILE__ ) . '/NavigableTOC.i18n.php'; |
47 | 55 | |
48 | 56 | // 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 @@ |
46 | 46 | |
47 | 47 | // Registers Hooks |
48 | 48 | $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 @@ |
63 | 63 | array( 'src' => 'js/plugins/jquery.namespaceSelect.js', 'version' => 0 ), |
64 | 64 | array( 'src' => 'js/plugins/jquery.suggestions.js', 'version' => 2 ), |
65 | 65 | 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 ), |
67 | 67 | 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 ), |
69 | 69 | array( 'src' => 'js/plugins/jquery.wikiEditor.toc.js', 'version' => 6 ), |
70 | 70 | array( 'src' => 'js/js2/jquery-ui-1.7.2.js', 'version' => '1.7.2x' ), |
71 | 71 | ), |
72 | 72 | 'combined' => array( |
73 | | - array( 'src' => 'js/plugins.combined.js', 'version' => 17 ), |
| 73 | + array( 'src' => 'js/plugins.combined.js', 'version' => 22 ), |
74 | 74 | ), |
75 | 75 | 'minified' => array( |
76 | | - array( 'src' => 'js/plugins.combined.min.js', 'version' => 17 ), |
| 76 | + array( 'src' => 'js/plugins.combined.min.js', 'version' => 22 ), |
77 | 77 | ), |
78 | 78 | ), |
79 | 79 | ); |
— | — | @@ -124,31 +124,7 @@ |
125 | 125 | |
126 | 126 | if ( !self::$doOutput ) |
127 | 127 | 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 | | - } |
135 | 128 | |
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 | | - |
153 | 129 | // Loops over each script |
154 | 130 | foreach ( self::$scripts as $script ) { |
155 | 131 | // Add javascript to document |
— | — | @@ -198,6 +174,14 @@ |
199 | 175 | } |
200 | 176 | return true; |
201 | 177 | } |
| 178 | + |
| 179 | + /** |
| 180 | + * MakeGlobalVariablesScript hook |
| 181 | + */ |
| 182 | + public static function addJSVars( &$vars ) { |
| 183 | + $vars = array_merge( $vars, self::$variables ); |
| 184 | + return true; |
| 185 | + } |
202 | 186 | |
203 | 187 | /** |
204 | 188 | * Adds a reference to a javascript file to the head of the document |
— | — | @@ -233,13 +217,4 @@ |
234 | 218 | public static function addVariables( $variables ) { |
235 | 219 | self::$variables = array_merge( self::$variables, $variables ); |
236 | 220 | } |
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 | | - |
246 | 221 | } |
Property changes on: branches/wmf-deployment-work/extensions/UsabilityInitiative |
___________________________________________________________________ |
Added: svn:mergeinfo |
247 | 222 | Merged /trunk/phase3/extensions/UsabilityInitiative:r56213,56215-56216,56218,56325,56334-56336,56338,56340,56343,56345,56347,56350 |
248 | 223 | Merged /branches/REL1_15/phase3/extensions/UsabilityInitiative:r51646 |
249 | 224 | Merged /trunk/extensions/UsabilityInitiative:r56207,56209,56296,56333,56355,56417 |