- Timestamp:
- 10/25/2016 01:39:15 AM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/js/tinymce/plugins/wordpress/plugin.js
r38160 r38897 232 232 table1 = [], 233 233 table2 = [], 234 row1 = {}, 235 row2 = {}, 236 i1 = 0, 237 i2 = 0, 238 labels = editor.settings.wp_shortcut_labels, 234 239 header, html, dialog, $wrap; 235 240 236 each( [ 237 { c: 'Copy', x: 'Cut' }, 238 { v: 'Paste', a: 'Select all' }, 239 { z: 'Undo', y: 'Redo' }, 240 { b: 'Bold', i: 'Italic' }, 241 { u: 'Underline', k: 'Insert/edit link' } 242 ], function( row ) { 243 table1.push( tr( row ) ); 241 if ( ! labels ) { 242 return; 243 } 244 245 function tr( row, columns ) { 246 var out = '<tr>'; 247 var i = 0; 248 249 columns = columns || 1; 250 251 each( row, function( text, key ) { 252 out += '<td><kbd>' + key + '</kbd></td><td>' + __( text ) + '</td>'; 253 i++; 254 }); 255 256 while ( i < columns ) { 257 out += '<td></td><td></td>'; 258 i++; 259 } 260 261 return out + '</tr>'; 262 } 263 264 each ( labels, function( label, name ) { 265 var letter; 266 267 if ( label.indexOf( 'meta' ) !== -1 ) { 268 i1++; 269 letter = label.replace( 'meta', '' ).toLowerCase(); 270 271 if ( letter ) { 272 row1[ letter ] = name; 273 274 if ( i1 % 2 === 0 ) { 275 table1.push( tr( row1, 2 ) ); 276 row1 = {}; 277 } 278 } 279 } else if ( label.indexOf( 'access' ) !== -1 ) { 280 i2++; 281 letter = label.replace( 'access', '' ).toLowerCase(); 282 283 if ( letter ) { 284 row2[ letter ] = name; 285 286 if ( i2 % 2 === 0 ) { 287 table2.push( tr( row2, 2 ) ); 288 row2 = {}; 289 } 290 } 291 } 244 292 } ); 245 293 246 each( [ 247 { 1: 'Heading 1', 2: 'Heading 2' }, 248 { 3: 'Heading 3', 4: 'Heading 4' }, 249 { 5: 'Heading 5', 6: 'Heading 6' }, 250 { l: 'Align left', c: 'Align center' }, 251 { r: 'Align right', j: 'Justify' }, 252 { d: 'Strikethrough', q: 'Blockquote' }, 253 { u: 'Bullet list', o: 'Numbered list' }, 254 { a: 'Insert/edit link', s: 'Remove link' }, 255 { m: 'Insert/edit image', t: 'Insert Read More tag' }, 256 { h: 'Keyboard Shortcuts', x: 'Code' }, 257 { p: 'Insert Page Break tag', w: 'Distraction-free writing mode' } 258 ], function( row ) { 259 table2.push( tr( row ) ); 260 } ); 261 262 function tr( row ) { 263 var out = '<tr>'; 264 265 each( row, function( text, key ) { 266 if ( ! text ) { 267 out += '<td></td><td></td>'; 268 } else { 269 out += '<td><kbd>' + key + '</kbd></td><td>' + __( text ) + '</td>'; 270 } 271 }); 272 273 return out + '</tr>'; 294 // Add remaining single entries. 295 if ( i1 % 2 > 0 ) { 296 table1.push( tr( row1, 2 ) ); 297 } 298 299 if ( i2 % 2 > 0 ) { 300 table2.push( tr( row2, 2 ) ); 274 301 } 275 302 … … 521 548 }); 522 549 }); 550 } 551 552 if ( editor.settings.wp_shortcut_labels ) { 553 var labels = {}; 554 var access = 'Shift+Alt+'; 555 var meta = 'Ctrl+'; 556 557 // For Mac: shift = \u2303, ctrl = \u21E7, cmd = \u2318, alt = \u2325 558 559 if ( tinymce.Env.mac ) { 560 access = '\u2303\u2325 '; 561 meta = '\u2318'; 562 } 563 564 each( editor.settings.wp_shortcut_labels, function( value, name ) { 565 labels[ name ] = value.replace( 'access', access ).replace( 'meta', meta ); 566 } ); 567 568 each( editor.theme.panel.find('button'), function( button ) { 569 if ( button && button.settings.tooltip && labels.hasOwnProperty( button.settings.tooltip ) ) { 570 // Need to translate now. We are changing the string so it won't match and cannot be translated later. 571 button.settings.tooltip = editor.translate( button.settings.tooltip ) + ' (' + labels[ button.settings.tooltip ] + ')'; 572 } 573 } ); 574 575 // listbox for the "blocks" drop-down 576 each( editor.theme.panel.find('listbox'), function( listbox ) { 577 if ( listbox && listbox.settings.text === 'Paragraph' ) { 578 each( listbox.settings.values, function( item ) { 579 if ( item.text && labels.hasOwnProperty( item.text ) ) { 580 item.shortcut = '(' + labels[ item.text ] + ')'; 581 } 582 } ); 583 } 584 } ); 523 585 } 524 586 });
Note: See TracChangeset
for help on using the changeset viewer.