Index: trunk/extensions/UsabilityInitiative/EditToolbar/EditToolbar.js |
— | — | @@ -96,6 +96,13 @@ |
97 | 97 | function msg( object, property ) { |
98 | 98 | return object[property] || gM( object[property + 'Msg'] ); |
99 | 99 | } |
| 100 | + // Creates generic action |
| 101 | + var action = function() { |
| 102 | + $(this).useTool( |
| 103 | + $(this).data( 'context' ).tool, |
| 104 | + $(this).data( 'context' ).textbox |
| 105 | + ); |
| 106 | + }; |
100 | 107 | switch ( section.type ) { |
101 | 108 | case 'toolbar': |
102 | 109 | // Check for groups |
— | — | @@ -116,13 +123,6 @@ |
117 | 124 | .text( msg( section.groups[group], 'label' ) ) |
118 | 125 | ) |
119 | 126 | } |
120 | | - // Creates generic action |
121 | | - var action = function() { |
122 | | - $(this).useTool( |
123 | | - $(this).data( 'context' ).tool, |
124 | | - $(this).data( 'context' ).textbox |
125 | | - ); |
126 | | - }; |
127 | 127 | // Loops over each tool |
128 | 128 | for ( tool in section.groups[group].tools ) { |
129 | 129 | // Filters are jQuery selectors which must select 1 or more |
— | — | @@ -256,6 +256,31 @@ |
257 | 257 | } |
258 | 258 | } |
259 | 259 | break; |
| 260 | + case 'specialchar': |
| 261 | + // Appends special character adders |
| 262 | + var chars = section.pages[page].chars; |
| 263 | + for ( char in chars ) { |
| 264 | + switch( chars[char].type ) { |
| 265 | + case 'break': |
| 266 | + pageDiv.append( $( '<br />' ) ); |
| 267 | + break; |
| 268 | + case 'link': |
| 269 | + var context = { |
| 270 | + 'tool' : chars[char], |
| 271 | + 'textbox': textbox |
| 272 | + }; |
| 273 | + pageDiv.append( $( '<a />' ) |
| 274 | + .attr( chars[char].attrs ) |
| 275 | + .attr( { 'href': '#', 'rel': char } ) |
| 276 | + .text( chars[char].text ) |
| 277 | + .data( 'context', context) |
| 278 | + .click( action ) |
| 279 | + .click( function() { return false; } ) |
| 280 | + ); |
| 281 | + pageDiv.append( ' ' ); |
| 282 | + } |
| 283 | + } |
| 284 | + break; |
260 | 285 | default: break; |
261 | 286 | } |
262 | 287 | } |
— | — | @@ -287,6 +312,7 @@ |
288 | 313 | } |
289 | 314 | switch ( tool.type ) { |
290 | 315 | case 'button': |
| 316 | + case 'link': |
291 | 317 | performAction( tool.action, textbox ); |
292 | 318 | break; |
293 | 319 | case 'select': |
— | — | @@ -298,6 +324,55 @@ |
299 | 325 | break; |
300 | 326 | default: break; |
301 | 327 | } |
| 328 | + }, |
| 329 | + |
| 330 | + /** |
| 331 | + * Converts a charinsert array like the one used on dewiki to |
| 332 | + * the format expected in editToolbarConfiguration |
| 333 | + */ |
| 334 | + parseCharinsert: function( charinsert ) { |
| 335 | + var retval = {}; |
| 336 | + for( page in charinsert ) { |
| 337 | + var chars = [], attrs = {}; |
| 338 | + var i = 0; |
| 339 | + for( line in charinsert[page] ) { |
| 340 | + if( !( charinsert[page][line] instanceof Array ) ) { |
| 341 | + attrs = charinsert[page][line]; |
| 342 | + continue; |
| 343 | + } |
| 344 | + for( chr in charinsert[page][line] ) { |
| 345 | + var tool = { |
| 346 | + type: 'link', |
| 347 | + attrs: attrs, |
| 348 | + text: '', |
| 349 | + action: { |
| 350 | + type: 'encapsulate', |
| 351 | + options: { |
| 352 | + pre: '', |
| 353 | + post: '' |
| 354 | + } |
| 355 | + } |
| 356 | + }; |
| 357 | + if( charinsert[page][line][chr] instanceof Array ) { |
| 358 | + tool.action.options.pre = charinsert[page][line][chr][0]; |
| 359 | + tool.action.options.post = charinsert[page][line][chr][1]; |
| 360 | + //tool.text = charinsert[page][line][chr][0] + charinsert[page][line][chr][1]; |
| 361 | + } else { |
| 362 | + tool.action.options.pre = charinsert[page][line][chr]; |
| 363 | + //tool.text = charinsert[page][line][chr]; |
| 364 | + } |
| 365 | + tool.text = tool.action.options.pre + tool.action.options.post; |
| 366 | + chars[i++] = tool; |
| 367 | + } |
| 368 | + chars[i++] = { type: 'break' }; |
| 369 | + } |
| 370 | + retval[page] = { |
| 371 | + label: page, |
| 372 | + layout: 'specialchar', |
| 373 | + chars: chars |
| 374 | + }; |
| 375 | + } |
| 376 | + return retval; |
302 | 377 | } |
303 | 378 | }); |
304 | 379 | })(jQuery); |
— | — | @@ -805,5 +880,11 @@ |
806 | 881 | ] |
807 | 882 | } |
808 | 883 | } |
| 884 | + }, |
| 885 | + 'specialchars': { |
| 886 | + label: 'Special characters', |
| 887 | + labelMsg: 'edittoolbar-section-specialchars', |
| 888 | + type: 'booklet', |
| 889 | + pages: {} // Set by the document.ready handler |
809 | 890 | } |
810 | 891 | }; |
\ No newline at end of file |
Index: trunk/extensions/UsabilityInitiative/EditToolbar/EditToolbar.php |
— | — | @@ -18,7 +18,7 @@ |
19 | 19 | /* Configuration */ |
20 | 20 | |
21 | 21 | // Bump the version number every time you change any of the .css/.js files |
22 | | -$wgEditToolbarStyleVersion = 1; |
| 22 | +$wgEditToolbarStyleVersion = 2; |
23 | 23 | |
24 | 24 | // Set this to true to simply override the stock toolbar for everyone |
25 | 25 | $wgEditToolbarGlobalEnable = false; |