Ticket #22659: 22659.2.diff
| File 22659.2.diff, 2.5 KB (added by , 14 years ago) |
|---|
-
wp-includes/js/media-views.js
1991 1991 } 1992 1992 }); 1993 1993 1994 // wp.media.view.FocusManager 1995 // ---------------------------- 1996 media.view.FocusManager = media.View.extend({ 1997 events: { 1998 keydown: 'recordTab', 1999 focusin: 'updateIndex' 2000 }, 2001 2002 focus: function() { 2003 if ( _.isUndefined( this.index ) ) 2004 return; 2005 2006 // Update our collection of `$tabbables`. 2007 this.$tabbables = this.$(':tabbable'); 2008 2009 // If tab is saved, focus it. 2010 this.$tabbables.eq( this.index ).focus(); 2011 }, 2012 2013 recordTab: function( event ) { 2014 // Look for the tab key. 2015 if ( 9 !== event.keyCode ) 2016 return; 2017 2018 // First try to update the index. 2019 if ( _.isUndefined( this.index ) ) 2020 this.updateIndex( event ); 2021 2022 // If we still don't have an index, bail. 2023 if ( _.isUndefined( this.index ) ) 2024 return; 2025 2026 var index = this.index + ( event.shiftKey ? -1 : 1 ); 2027 2028 if ( index >= 0 && index < this.$tabbables.length ) 2029 this.index = index; 2030 else 2031 delete this.index; 2032 }, 2033 2034 updateIndex: function( event ) { 2035 this.$tabbables = this.$(':tabbable'); 2036 2037 var index = this.$tabbables.index( event.target ); 2038 2039 if ( -1 === index ) 2040 delete this.index; 2041 else 2042 this.index = index; 2043 } 2044 }); 2045 1994 2046 // wp.media.view.UploaderWindow 1995 2047 // ---------------------------- 1996 2048 media.view.UploaderWindow = media.View.extend({ … … 2832 2884 this.updateSave(); 2833 2885 2834 2886 this.views.render(); 2887 2835 2888 return this; 2836 2889 }, 2837 2890 … … 3951 4004 'click .delete-attachment': 'deleteAttachment' 3952 4005 }, 3953 4006 4007 initialize: function() { 4008 this.focusManager = new media.view.FocusManager({ 4009 el: this.el 4010 }); 4011 4012 media.view.Attachment.prototype.initialize.apply( this, arguments ); 4013 }, 4014 4015 render: function() { 4016 media.view.Attachment.prototype.render.apply( this, arguments ); 4017 this.focusManager.focus(); 4018 return this; 4019 }, 4020 3954 4021 deleteAttachment: function(event) { 3955 4022 event.preventDefault(); 3956 4023 … … 3974 4041 }, 3975 4042 3976 4043 initialize: function() { 4044 this.focusManager = new media.view.FocusManager({ 4045 el: this.el 4046 }); 4047 3977 4048 this.model.on( 'change:compat', this.render, this ); 3978 4049 }, 3979 4050 … … 3982 4053 if ( ! compat || ! compat.item ) 3983 4054 return; 3984 4055 4056 this.views.detach(); 3985 4057 this.$el.html( compat.item ); 4058 this.views.render(); 4059 4060 this.focusManager.focus(); 3986 4061 return this; 3987 4062 }, 3988 4063
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)