Changeset 29555
- Timestamp:
- 08/20/2014 07:13:50 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/js/media-views.js
r29553 r29555 4855 4855 */ 4856 4856 arrowEvent: function( event ) { 4857 var attachment = $('.attachments-browser .attachment'), 4858 attachmentsWidth = $('.attachments-browser .attachments').width(), 4859 thumbnailWidth = attachment.first().outerWidth(), 4860 thumbnailsPerRow = Math.round( attachmentsWidth / thumbnailWidth ), 4861 totalThumnails = attachment.length, 4862 totalRows = Math.ceil(totalThumnails/thumbnailsPerRow), 4863 thisIndex = attachment.filter( ':focus' ).index(), 4864 thisIndexAdjusted = thisIndex + 1, 4865 thisRow = thisIndexAdjusted <= thumbnailsPerRow ? 1 : Math.ceil(thisIndexAdjusted/thumbnailsPerRow); 4866 4867 // Left arrow 4868 if ( 37 === event.keyCode ) { 4869 if ( 0 === thisIndex ) { 4870 return; 4871 } 4872 attachment.eq( thisIndex - 1 ).focus(); 4873 } 4874 4875 // Up arrow 4876 if ( 38 === event.keyCode ) { 4877 if ( 1 === thisRow ) { 4878 return; 4879 } 4880 attachment.eq( thisIndex - thumbnailsPerRow ).focus(); 4881 } 4882 4883 // Right arrow 4884 if ( 39 === event.keyCode ) { 4885 if ( totalThumnails === thisIndex ) { 4886 return; 4887 } 4888 attachment.eq( thisIndex + 1 ).focus(); 4889 } 4890 4891 // Down arrow 4892 if ( 40 === event.keyCode ) { 4893 if ( totalRows === thisRow ) { 4894 return; 4895 } 4896 attachment.eq( thisIndex + thumbnailsPerRow ).focus(); 4897 } 4898 4899 return false; 4857 this.controller.trigger( 'attachment:keydown:arrow', event ); 4858 return false; 4900 4859 }, 4901 4860 /** … … 5316 5275 this.collection.on( 'reset', this.render, this ); 5317 5276 5277 this.listenTo( this.controller, 'attachment:keydown:arrow', this.arrowEvent ); 5278 5318 5279 // Throttle the scroll handler and bind this. 5319 5280 this.scroll = _.chain( this.scroll ).bind( this ).throttle( this.options.refreshSensitivity ).value(); … … 5334 5295 // attachments get proper width applied. 5335 5296 _.defer( this.setColumns, this ); 5297 }, 5298 5299 arrowEvent: function( event ) { 5300 var attachments = this.$el.children( 'li' ), 5301 perRow = Math.round( this.$el.width() / attachments.first().outerWidth() ), 5302 index = attachments.filter( ':focus' ).index(), 5303 row = ( index + 1 ) <= perRow ? 1 : Math.ceil( ( index + 1 ) / perRow ); 5304 5305 // Left arrow 5306 if ( 37 === event.keyCode ) { 5307 if ( 0 === index ) { 5308 return; 5309 } 5310 attachments.eq( index - 1 ).focus(); 5311 } 5312 5313 // Up arrow 5314 if ( 38 === event.keyCode ) { 5315 if ( 1 === row ) { 5316 return; 5317 } 5318 attachments.eq( index - perRow ).focus(); 5319 } 5320 5321 // Right arrow 5322 if ( 39 === event.keyCode ) { 5323 if ( attachments.length === index ) { 5324 return; 5325 } 5326 attachments.eq( index + 1 ).focus(); 5327 } 5328 5329 // Down arrow 5330 if ( 40 === event.keyCode ) { 5331 if ( Math.ceil( attachments.length / perRow ) === row ) { 5332 return; 5333 } 5334 attachments.eq( index + perRow ).focus(); 5335 } 5336 5336 }, 5337 5337 … … 6582 6582 */ 6583 6583 toggleSelectionHandler: function( event ) { 6584 if ( 'keydown' === event.type && 9 === event.keyCode && event.shiftKey && event.target === $( ':tabbable', this.$el ).filter( ':first' )[0]) {6585 $('.attachments-browser .details').focus();6584 if ( 'keydown' === event.type && 9 === event.keyCode && event.shiftKey && event.target === this.$( ':tabbable' ).get( 0 ) ) { 6585 this.$( ':tabbable' ).eq( 0 ).blur(); 6586 6586 return false; 6587 6587 } 6588 6588 } 6589 6590 6589 }); 6591 6590
Note: See TracChangeset
for help on using the changeset viewer.