Ticket #30468: 30468.patch
| File 30468.patch, 16.8 KB (added by , 12 years ago) |
|---|
-
src/wp-includes/class-wp-editor.php
1406 1406 // display: none is required here, see #WP27605 1407 1407 ?> 1408 1408 <div id="wp-link-backdrop" style="display: none"></div> 1409 <div id="wp-link-wrap" class="wp-core-ui<?php echo $search_panel_visible; ?>" style="display: none" >1409 <div id="wp-link-wrap" class="wp-core-ui<?php echo $search_panel_visible; ?>" style="display: none" role="dialog" aria-labelledby="link-modal-title" tabindex="0"> 1410 1410 <form id="wp-link" tabindex="-1"> 1411 1411 <?php wp_nonce_field( 'internal-linking', '_ajax_linking_nonce', false ); ?> 1412 <div id="link-modal-title"> 1413 <?php _e( 'Insert/edit link' ) ?> 1414 <button type="button" id="wp-link-close"><span class="screen-reader-text"><?php _e( 'Close' ); ?></span></button> 1415 </div> 1412 <h1 id="link-modal-title"><?php _e( 'Insert/edit link' ) ?></h1> 1413 <button type="button" id="wp-link-close"><span class="screen-reader-text"><?php _e( 'Close' ); ?></span></button> 1416 1414 <div id="link-selector"> 1417 1415 <div id="link-options"> 1418 <p class="howto" ><?php _e( 'Enter the destination URL' ); ?></p>1416 <p class="howto" id="wp-link-howto-url"><?php _e( 'Enter the destination URL' ); ?></p> 1419 1417 <div> 1420 <label><span><?php _e( 'URL' ); ?></span><input id="url-field" type="text" name="href" /></label>1418 <label><span><?php _e( 'URL' ); ?></span><input id="url-field" type="text" name="href" aria-describedby="wp-link-howto-url" /></label> 1421 1419 </div> 1422 1420 <div> 1423 1421 <label><span><?php _e( 'Title' ); ?></span><input id="link-title-field" type="text" name="linktitle" /></label> 1424 1422 </div> 1425 1423 <div class="link-target"> 1426 <label><span> </span><input type="checkbox" id="link-target-checkbox" /> <?php _e( 'Open link in a new window/tab' ); ?></label>1424 <label><span></span><input type="checkbox" id="link-target-checkbox" /> <?php _e( 'Open link in a new window/tab' ); ?></label> 1427 1425 </div> 1428 1426 </div> 1429 < p class="howto"><a href="#" id="wp-link-search-toggle"><?php _e( 'Or link to existing content' ); ?></a></p>1427 <div class="howto"><button type="button" id="wp-link-search-toggle" class="button" aria-expanded="false"><?php _e( 'Or link to existing content' ); ?></button></div> 1430 1428 <div id="search-panel"> 1431 1429 <div class="link-search-wrapper"> 1432 1430 <label> 1433 1431 <span class="search-label"><?php _e( 'Search' ); ?></span> 1434 <input type="search" id="search-field" class="link-search-field" autocomplete="off" />1432 <input type="search" id="search-field" class="link-search-field" autocomplete="off" aria-describedby="query-notice-hint" /> 1435 1433 <span class="spinner"></span> 1436 1434 </label> 1437 1435 </div> 1438 <div id="search-results" class="query-results" tabindex="0"> 1439 <ul></ul> 1440 <div class="river-waiting"> 1441 <span class="spinner"></span> 1436 <div role="application" aria-label="<?php esc_attr_e( 'Links:' ); ?>"> 1437 <div id="search-results" class="query-results" tabindex="0" role="list" aria-label="<?php esc_attr_e( 'Search results:' ); ?>"> 1438 <ul aria-live="polite"></ul> 1439 <div class="river-waiting"> 1440 <span class="spinner"></span> 1441 </div> 1442 1442 </div> 1443 </div> 1444 <div id="most-recent-results" class="query-results" tabindex="0"> 1445 <div class="query-notice" id="query-notice-message"> 1446 <em class="query-notice-default"><?php _e( 'No search term specified. Showing recent items.' ); ?></em> 1447 <em class="query-notice-hint screen-reader-text"><?php _e( 'Search or use up and down arrow keys to select an item.' ); ?></em> 1443 <div id="most-recent-results" class="query-results" tabindex="0" role="list" aria-labelledby="query-notice-default"> 1444 <div class="query-notice" id="query-notice-message"> 1445 <em class="query-notice-default" id="query-notice-default"><?php _e( 'No search term specified. Showing recent items.' ); ?></em> 1446 <em class="query-notice-hint screen-reader-text" id="query-notice-hint"><?php _e( 'Search or use up and down arrow keys to select an item.' ); ?></em> 1447 </div> 1448 <ul></ul> 1449 <div class="river-waiting"> 1450 <span class="spinner"></span> 1451 </div> 1448 1452 </div> 1449 <ul></ul>1450 <div class="river-waiting">1451 <span class="spinner"></span>1452 </div>1453 1453 </div> 1454 1454 </div> 1455 1455 </div> 1456 1456 <div class="submitbox"> 1457 1457 <div id="wp-link-cancel"> 1458 < a class="submitdelete deletion" href="#"><?php _e( 'Cancel' ); ?></a>1458 <button type="button" id="wp-link-cancel-button" class="button"><?php _e( 'Cancel' ); ?></button> 1459 1459 </div> 1460 1460 <div id="wp-link-update"> 1461 1461 <input type="submit" value="<?php esc_attr_e( 'Add Link' ); ?>" class="button button-primary" id="wp-link-submit" name="wp-link-submit"> -
src/wp-includes/css/editor.css
158 158 border: 1px solid #aaa; 159 159 -webkit-border-radius: 2px; 160 160 border-radius: 2px; 161 -webkit-box-shadow: 0 1px 4px rgba( 0, 0, 0, 0.2 ) 162 box-shadow: 0 1px 4px rgba( 0, 0, 0, 0.2 ) 161 -webkit-box-shadow: 0 1px 4px rgba( 0, 0, 0, 0.2 ); 162 box-shadow: 0 1px 4px rgba( 0, 0, 0, 0.2 ); 163 163 -webkit-box-sizing: border-box; 164 164 -moz-box-sizing: border-box; 165 165 -webkit-box-sizing: border-box; … … 919 919 padding: 10px; 920 920 margin: 1px 0 0; 921 921 line-height: 150%; 922 border: 0 none;922 border: 0; 923 923 outline: none; 924 924 display: block; 925 925 resize: vertical; … … 1183 1183 -webkit-box-shadow: 0 3px 6px rgba( 0, 0, 0, 0.3 ); 1184 1184 box-shadow: 0 3px 6px rgba( 0, 0, 0, 0.3 ); 1185 1185 width: 500px; 1186 height: 2 50px;1186 height: 260px; 1187 1187 overflow: hidden; 1188 1188 margin-left: -250px; 1189 1189 margin-top: -125px; … … 1215 1215 } 1216 1216 1217 1217 #wp-link-wrap.search-panel-visible { 1218 height: 5 00px;1219 margin-top: -25 0px;1218 height: 510px; 1219 margin-top: -255px; 1220 1220 } 1221 1221 1222 1222 #link-modal-title { … … 1226 1226 font-size: 18px; 1227 1227 font-weight: 600; 1228 1228 line-height: 36px; 1229 margin: 0; 1229 1230 padding: 0 36px 0 16px; 1230 top: 0;1231 right: 0;1232 left: 0;1233 1231 } 1234 1232 1235 1233 #wp-link-close { … … 1294 1292 1295 1293 #wp-link-search-toggle:after { 1296 1294 display: inline-block; 1297 font: normal 20px/ 1'dashicons';1295 font: normal 20px/26px 'dashicons'; 1298 1296 vertical-align: top; 1299 1297 speak: none; 1300 1298 -webkit-font-smoothing: antialiased; … … 1320 1318 margin: 3px 0; 1321 1319 } 1322 1320 1321 #wp-link div.howto { 1322 margin: 0 0 12px 85px; 1323 } 1324 1323 1325 #wp-link p.howto a { 1324 1326 text-decoration: none; 1325 1327 color: inherit; 1326 1328 } 1327 1329 1328 #wp-link-search-toggle {1329 cursor: pointer;1330 }1331 1332 1330 #wp-link label input[type="text"] { 1333 1331 margin-top: 5px; 1334 1332 width: 70%; … … 1345 1343 1346 1344 #wp-link .link-search-field { 1347 1345 float: left; 1348 width: 250px; 1349 max-width: 70%; 1346 width: 70%; 1350 1347 } 1351 1348 1352 1349 #wp-link .link-search-wrapper { … … 1370 1367 white-space: nowrap; 1371 1368 overflow: hidden; 1372 1369 text-overflow: ellipsis; 1370 max-width: 90%; 1373 1371 } 1374 1372 1375 #wp-link .link-target label {1376 max-width: 70%;1377 }1378 1379 1373 #wp-link .query-results { 1380 1374 border: 1px #dfdfdf solid; 1381 1375 margin: 0; … … 1385 1379 left: 16px; 1386 1380 right: 16px; 1387 1381 bottom: 16px; 1388 top: 2 05px;1382 top: 215px; 1389 1383 } 1390 1384 1391 1385 #wp-link li { … … 1396 1390 padding: 4px 6px 4px 10px; 1397 1391 cursor: pointer; 1398 1392 position: relative; 1393 outline: 0; 1399 1394 } 1400 1395 1401 1396 #wp-link .query-notice { … … 1881 1876 1882 1877 #wp-fullscreen-buttons .mce-btn button { 1883 1878 margin: 0; 1884 outline: 0 none;1885 border: 0 none;1879 outline: 0; 1880 border: 0; 1886 1881 white-space: nowrap; 1887 1882 width: auto; 1888 1883 background: none; -
src/wp-includes/js/wplink.js
5 5 var editor, searchTimer, River, Query, 6 6 inputs = {}, 7 7 rivers = {}, 8 isTouch = ( 'ontouchend' in document ); 8 isTouch = ( 'ontouchend' in document ), 9 visible; 9 10 10 11 wpLink = { 11 12 timeToTriggerRiver: 150, 12 13 minRiverAJAXDuration: 200, 13 14 riverBottomThreshold: 5, 14 keySensitivity: 1 00,15 keySensitivity: 150, 15 16 lastSearch: '', 16 17 textarea: '', 17 18 … … 28 29 inputs.title = $( '#link-title-field' ); 29 30 // Advanced Options 30 31 inputs.openInNewTab = $( '#link-target-checkbox' ); 32 inputs.searchToggle = $( '#wp-link-search-toggle' ); 31 33 inputs.search = $( '#search-field' ); 32 34 // Build Rivers 33 35 rivers.search = new River( $( '#search-results' ) ); … … 46 48 event.preventDefault(); 47 49 wpLink.update(); 48 50 }); 49 inputs.close.add( inputs.backdrop ).add( '#wp-link-cancel a' ).click( function( event ) {51 inputs.close.add( inputs.backdrop ).add( '#wp-link-cancel-button' ).click( function( event ) { 50 52 event.preventDefault(); 51 53 wpLink.close(); 52 54 }); 53 55 54 $( '#wp-link-search-toggle' ).on( 'click', wpLink.toggleInternalLinking );56 inputs.searchToggle.on( 'click', wpLink.toggleInternalLinking ); 55 57 56 58 rivers.elements.on( 'river-select', wpLink.updateFields ); 57 59 … … 110 112 111 113 inputs.wrap.show(); 112 114 inputs.backdrop.show(); 115 $( 'body' ).addClass( 'modal-open' ); 113 116 114 117 wpLink.refresh(); 115 118 $( document ).trigger( 'wplink-open', inputs.wrap ); … … 123 126 // Refresh rivers (clear links, check visibility) 124 127 rivers.search.refresh(); 125 128 rivers.recent.refresh(); 129 visible = inputs.wrap.hasClass( 'search-panel-visible' ); 126 130 127 131 if ( wpLink.isMCE() ) { 128 132 wpLink.mceRefresh(); … … 144 148 if ( ! rivers.recent.ul.children().length ) { 145 149 rivers.recent.ajax(); 146 150 } 151 152 // Toggle the button aria-expanded attribute. 153 if ( visible ) { 154 inputs.searchToggle.attr( 'aria-expanded', 'true' ); 155 } else { 156 inputs.searchToggle.attr( 'aria-expanded', 'false' ); 157 } 147 158 }, 148 159 149 160 mceRefresh: function() { … … 179 190 180 191 inputs.backdrop.hide(); 181 192 inputs.wrap.hide(); 193 $( 'body' ).removeClass( 'modal-open' ); 182 194 $( document ).trigger( 'wplink-close', inputs.wrap ); 183 195 }, 184 196 … … 191 203 }, 192 204 193 205 update: function() { 194 if ( wpLink.isMCE() ) 206 if ( wpLink.isMCE() ) { 195 207 wpLink.mceUpdate(); 196 else208 } else { 197 209 wpLink.htmlUpdate(); 210 } 198 211 }, 199 212 200 213 htmlUpdate: function() { … … 201 214 var attrs, html, begin, end, cursor, title, selection, 202 215 textarea = wpLink.textarea; 203 216 204 if ( ! textarea ) 217 if ( ! textarea ) { 205 218 return; 219 } 206 220 207 221 attrs = wpLink.getAttrs(); 208 222 209 223 // If there's no href, return. 210 if ( ! attrs.href || attrs.href == 'http://' ) 224 if ( ! attrs.href || attrs.href == 'http://' ) { 211 225 return; 226 } 212 227 213 228 // Build HTML 214 229 html = '<a href="' + attrs.href + '"'; … … 244 259 cursor = begin + html.length; 245 260 246 261 // If no text is selected, place the cursor inside the closing tag. 247 if ( begin == end ) 262 if ( begin == end ) { 248 263 cursor -= '</a>'.length; 264 } 249 265 250 266 textarea.value = textarea.value.substring( 0, begin ) + html + 251 267 textarea.value.substring( end, textarea.value.length ); … … 324 340 rivers.search.show(); 325 341 326 342 // Don't search if the keypress didn't change the title. 327 if ( wpLink.lastSearch == search ) 343 if ( wpLink.lastSearch == search ) { 328 344 return; 345 } 329 346 330 347 wpLink.lastSearch = search; 331 348 waiting = t.parent().find('.spinner').show(); … … 375 392 return; 376 393 } 377 394 378 if ( document.activeElement && 379 ( document.activeElement.id === 'link-title-field' || document.activeElement.id === 'url-field' ) ) { 395 if ( document.activeElement && ( 396 'wp-link-close' === document.activeElement.id || 397 'link-title-field' === document.activeElement.id || 398 'url-field' === document.activeElement.id || 399 'link-target-checkbox' === document.activeElement.id || 400 'wp-link-search-toggle' === document.activeElement.id || 401 'wp-link-cancel-button' === document.activeElement.id || 402 'wp-link-submit' === document.activeElement.id 403 ) ) { 380 404 return; 381 405 } 382 406 … … 399 423 delayedCallback: function( func, delay ) { 400 424 var timeoutTriggered, funcTriggered, funcArgs, funcContext; 401 425 402 if ( ! delay ) 426 if ( ! delay ) { 403 427 return func; 428 } 404 429 405 430 setTimeout( function() { 406 if ( funcTriggered ) 431 if ( funcTriggered ) { 407 432 return func.apply( funcContext, funcArgs ); 433 } 408 434 // Otherwise, wait. 409 435 timeoutTriggered = true; 410 436 }, delay ); 411 437 412 438 return function() { 413 if ( timeoutTriggered ) 439 if ( timeoutTriggered ) { 414 440 return func.apply( this, arguments ); 441 } 415 442 // Otherwise, wait. 416 443 funcArgs = arguments; 417 444 funcContext = this; … … 420 447 }, 421 448 422 449 toggleInternalLinking: function( event ) { 423 v ar visible = inputs.wrap.hasClass( 'search-panel-visible' );450 visible = inputs.wrap.hasClass( 'search-panel-visible' ); 424 451 425 452 inputs.wrap.toggleClass( 'search-panel-visible', ! visible ); 426 453 setUserSetting( 'wplink', visible ? '0' : '1' ); 427 inputs[ ! visible ? 'search' : 'url' ].focus(); 454 if ( ! visible ) { 455 inputs.search.focus(); 456 inputs.searchToggle.attr( 'aria-expanded', 'true' ); 457 } else { 458 inputs.searchToggle.attr( 'aria-expanded', 'false' ); 459 } 428 460 event.preventDefault(); 429 461 } 430 462 }; … … 467 499 select: function( li, event ) { 468 500 var liHeight, elHeight, liTop, elTop; 469 501 470 if ( li.hasClass( 'unselectable' ) || li == this.selected ) 502 if ( li.hasClass( 'unselectable' ) || li == this.selected ) { 471 503 return; 504 } 472 505 473 506 this.deselect(); 474 this.selected = li.addClass( 'selected' ) ;507 this.selected = li.addClass( 'selected' ).attr( 'aria-selected', 'true' ).focus(); 475 508 // Make sure the element is visible 476 509 liHeight = li.outerHeight(); 477 510 elHeight = this.element.height(); … … 478 511 liTop = li.position().top; 479 512 elTop = this.element.scrollTop(); 480 513 481 if ( liTop < 0 ) // Make first visible element514 if ( liTop < 0 ) { // Make first visible element 482 515 this.element.scrollTop( elTop + liTop ); 483 else if ( liTop + liHeight > elHeight )// Make last visible element516 } else if ( liTop + liHeight > elHeight ) { // Make last visible element 484 517 this.element.scrollTop( elTop + liTop - elHeight + liHeight ); 518 } 485 519 486 520 // Trigger the river-select event 487 521 this.element.trigger( 'river-select', [ li, event, this ] ); 488 522 }, 489 523 deselect: function() { 490 if ( this.selected ) 491 this.selected.removeClass( 'selected' ); 524 if ( this.selected ) { 525 this.selected.removeClass( 'selected' ).attr( 'aria-selected', 'false' ); 526 } 492 527 this.selected = false; 493 528 }, 494 529 prev: function() { 495 if ( ! this.visible ) 530 if ( ! this.visible ) { 496 531 return; 532 } 497 533 498 534 var to; 499 535 if ( this.selected ) { 500 536 to = this.selected.prev( 'li' ); 501 if ( to.length ) 537 if ( to.length ) { 502 538 this.select( to ); 539 } 503 540 } 504 541 }, 505 542 next: function() { 506 if ( ! this.visible ) 543 if ( ! this.visible ) { 507 544 return; 545 } 508 546 509 547 var to = this.selected ? this.selected.next( 'li' ) : $( 'li:not(.unselectable):first', this.element ); 510 if ( to.length ) 548 if ( to.length ) { 511 549 this.select( to ); 550 } 512 551 }, 513 552 ajax: function( callback ) { 514 553 var self = this, … … 515 554 delay = this.query.page == 1 ? 0 : wpLink.minRiverAJAXDuration, 516 555 response = wpLink.delayedCallback( function( results, params ) { 517 556 self.process( results, params ); 518 if ( callback ) 557 if ( callback ) { 519 558 callback( results, params ); 559 } 520 560 }, delay ); 521 561 522 562 this.query.ajax( response ); 523 563 }, 524 564 change: function( search ) { 525 if ( this.query && this._search == search ) 565 if ( this.query && this._search == search ) { 526 566 return; 567 } 527 568 528 569 this._search = search; 529 570 this.query = new Query( search ); … … 542 583 $.each( results, function() { 543 584 classes = alt ? 'alternate' : ''; 544 585 classes += this.title ? '' : ' no-title'; 545 list += classes ? '<li class="' + classes + '" >' : '<li>';586 list += classes ? '<li class="' + classes + '" tabindex="-1" role="listitem">' : '<li tabindex="-1" role="listitem">'; 546 587 list += '<input type="hidden" class="item-permalink" value="' + this.permalink + '" />'; 547 588 list += '<span class="item-title">'; 548 589 list += this.title ? this.title : wpLinkL10n.noTitle; … … 558 599 el = this.element, 559 600 bottom = el.scrollTop() + el.height(); 560 601 561 if ( ! this.query.ready() || bottom < this.contentHeight.height() - wpLink.riverBottomThreshold ) 602 if ( ! this.query.ready() || bottom < this.contentHeight.height() - wpLink.riverBottomThreshold ) { 562 603 return; 604 } 563 605 564 606 setTimeout(function() { 565 607 var newTop = el.scrollTop(), 566 608 newBottom = newTop + el.height(); 567 609 568 if ( ! self.query.ready() || newBottom < self.contentHeight.height() - wpLink.riverBottomThreshold ) 610 if ( ! self.query.ready() || newBottom < self.contentHeight.height() - wpLink.riverBottomThreshold ) { 569 611 return; 612 } 570 613 571 614 self.waiting.show(); 572 615 el.scrollTop( newTop + self.waiting.outerHeight() ); … … 597 640 '_ajax_linking_nonce' : inputs.nonce.val() 598 641 }; 599 642 600 if ( this.search ) 643 if ( this.search ) { 601 644 query.search = this.search; 645 } 602 646 603 647 this.querying = true; 604 648