Ticket #31661: 31661.patch
| File 31661.patch, 3.7 KB (added by , 11 years ago) |
|---|
-
src/wp-includes/js/quicktags.js
150 150 zeroise( now.getUTCSeconds() ) + 151 151 '+00:00'; 152 152 })(), 153 qt; 153 qt, 154 keyboardSelectionIE = false; 154 155 155 156 qt = QTags = function(settings) { 156 157 if ( typeof(settings) === 'string' ) { … … 220 221 tb.attachEvent('onclick', onclick); 221 222 } 222 223 224 if ( canvas.addEventListener ) { 225 canvas.addEventListener( 'keydown', qt.OnTab, false ); 226 } else if ( canvas.attachEvent ) { 227 canvas.attachEvent( 'onkeydown', qt.OnTab ); 228 } 229 223 230 t.getButton = function(id) { 224 231 return t.theButtons[id]; 225 232 }; … … 243 250 }; 244 251 245 252 qt._buttonsInit = function() { 246 var t = this, canvas, name, settings, theButtons, html, inst, ed, id, i, use, 253 var t = this, canvas, name, settings, theButtons, html, inst, ed, id, i, use, closeAllButton, 247 254 defaults = ',strong,em,link,block,del,ins,img,ul,ol,li,code,more,close,'; 248 255 249 256 for ( inst in t.instances ) { … … 299 306 } 300 307 301 308 ed.toolbar.innerHTML = html; 309 310 // Disable the Close All button on init. 311 closeAllButton = document.getElementById( ed.name + '_' + theButtons.close.id ); 312 if ( closeAllButton ) { 313 closeAllButton.setAttribute( 'disabled', 'disabled' ); 314 } 315 302 316 ed.theButtons = theButtons; 303 317 304 318 if ( typeof jQuery !== 'undefined' ) { … … 439 453 }; 440 454 qt.TagButton.prototype = new qt.Button(); 441 455 qt.TagButton.prototype.openTag = function(e, ed) { 442 var t = this; 456 var t = this, 457 closeAllButton = document.getElementById( ed.name + '_' + ed.theButtons.close.id ); 443 458 459 // Enable the Close All button now that we have open tags. 460 if ( closeAllButton ) { 461 closeAllButton.removeAttribute( 'disabled' ); 462 } 463 444 464 if ( ! ed.openTags ) { 445 465 ed.openTags = []; 446 466 } 467 447 468 if ( t.tagEnd ) { 448 469 ed.openTags.push(t.id); 449 470 e.value = '/' + e.value; … … 450 471 } 451 472 }; 452 473 qt.TagButton.prototype.closeTag = function(e, ed) { 453 var t = this, i = t.isOpen(ed); 474 var t = this, i = t.isOpen(ed), 475 closeAllButton = document.getElementById( ed.name + '_' + ed.theButtons.close.id ); 454 476 455 477 if ( i !== false ) { 456 478 ed.openTags.splice(i, 1); 457 479 } 458 480 481 // Disable the Close All button when there are no more open tags. 482 if ( 0 === i && closeAllButton ) { 483 closeAllButton.setAttribute( 'disabled', 'disabled' ); 484 } 485 // Handle focus when the Close All button gets disabled. 486 ed.canvas.focus(); 487 459 488 e.value = t.display; 460 489 }; 461 490 // whether a tag is open or not. Returns false if not open, or current open depth of the tag … … 476 505 477 506 if ( document.selection ) { // IE 478 507 canvas.focus(); 479 sel = document.selection.createRange(); 508 // Check if we already have an IE keyboard selection first. 509 sel = keyboardSelectionIE || document.selection.createRange(); 480 510 if ( sel.text.length > 0 ) { 481 511 if ( !t.tagEnd ) { 482 512 sel.text = sel.text + t.tagStart; … … 494 524 t.closeTag(element, ed); 495 525 } 496 526 } 527 // Reset IE keyboard selection 528 keyboardSelectionIE = false; 497 529 canvas.focus(); 498 530 } else if ( canvas.selectionStart || canvas.selectionStart === 0 ) { // FF, WebKit, Opera 499 531 startPos = canvas.selectionStart; … … 544 576 } 545 577 }; 546 578 579 // IE keyboard selection: get and store the selection when reverse tabbing. 580 qt.OnTab = function( event ) { 581 var key; 582 583 if ( document.selection && 'keydown' === event.type ) { 584 key = event.keyCode || event.charCode; 585 if ( event.shiftKey && 9 === key ) { 586 keyboardSelectionIE = document.selection.createRange(); 587 } 588 } 589 }; 590 547 591 // removed 548 592 qt.SpellButton = function() {}; 549 593