In Media microtemplates after [32467], use <button> instead of <a> for several more non-links.

Props afercia.
Fixes #26550.


git-svn-id: https://develop.svn.wordpress.org/trunk@32952 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Scott Taylor
2015-06-26 05:00:42 +00:00
parent 9b671bdf9e
commit d0c3281ea8
8 changed files with 100 additions and 97 deletions

View File

@@ -2625,10 +2625,8 @@ Attachment = View.extend({
'change [data-setting] input': 'updateSetting',
'change [data-setting] select': 'updateSetting',
'change [data-setting] textarea': 'updateSetting',
'click .close': 'removeFromLibrary',
'click .attachment-close': 'removeFromLibrary',
'click .check': 'checkClickHandler',
'click a': 'preventDefault',
'keydown .close': 'removeFromLibrary',
'keydown': 'toggleSelectionHandler'
},
@@ -2756,8 +2754,8 @@ Attachment = View.extend({
toggleSelectionHandler: function( event ) {
var method;
// Don't do anything inside inputs.
if ( 'INPUT' === event.target.nodeName ) {
// Don't do anything inside inputs and on the attachment check and remove buttons.
if ( 'INPUT' === event.target.nodeName || 'BUTTON' === event.target.nodeName ) {
return;
}
@@ -2942,12 +2940,6 @@ Attachment = View.extend({
details = selection.single();
this.$el.toggleClass( 'details', details === this.model );
},
/**
* @param {Object} event
*/
preventDefault: function( event ) {
event.preventDefault();
},
/**
* @param {string} size
* @returns {Object}
@@ -3197,7 +3189,14 @@ Details = Attachment.extend({
initialFocus: function() {
if ( ! wp.media.isTouchDevice ) {
this.$( ':input' ).eq( 0 ).focus();
/*
Previously focused the first ':input' (the readonly URL text field).
Since the first ':input' is now a button (delete/trash): when pressing
spacebar on an attachment, Firefox fires deleteAttachment/trashAttachment
as soon as focus is moved. Explicitly target the first text field for now.
@todo change initial focus logic, also for accessibility.
*/
this.$( 'input[type="text"]' ).eq( 0 ).focus();
}
},
/**

View File

@@ -33,10 +33,8 @@ Attachment = View.extend({
'change [data-setting] input': 'updateSetting',
'change [data-setting] select': 'updateSetting',
'change [data-setting] textarea': 'updateSetting',
'click .close': 'removeFromLibrary',
'click .attachment-close': 'removeFromLibrary',
'click .check': 'checkClickHandler',
'click a': 'preventDefault',
'keydown .close': 'removeFromLibrary',
'keydown': 'toggleSelectionHandler'
},
@@ -164,8 +162,8 @@ Attachment = View.extend({
toggleSelectionHandler: function( event ) {
var method;
// Don't do anything inside inputs.
if ( 'INPUT' === event.target.nodeName ) {
// Don't do anything inside inputs and on the attachment check and remove buttons.
if ( 'INPUT' === event.target.nodeName || 'BUTTON' === event.target.nodeName ) {
return;
}
@@ -350,12 +348,6 @@ Attachment = View.extend({
details = selection.single();
this.$el.toggleClass( 'details', details === this.model );
},
/**
* @param {Object} event
*/
preventDefault: function( event ) {
event.preventDefault();
},
/**
* @param {string} size
* @returns {Object}

View File

@@ -49,7 +49,14 @@ Details = Attachment.extend({
initialFocus: function() {
if ( ! wp.media.isTouchDevice ) {
this.$( ':input' ).eq( 0 ).focus();
/*
Previously focused the first ':input' (the readonly URL text field).
Since the first ':input' is now a button (delete/trash): when pressing
spacebar on an attachment, Firefox fires deleteAttachment/trashAttachment
as soon as focus is moved. Explicitly target the first text field for now.
@todo change initial focus logic, also for accessibility.
*/
this.$( 'input[type="text"]' ).eq( 0 ).focus();
}
},
/**

View File

@@ -106,12 +106,16 @@
}
.media-embed-details .setting p,
.media-embed-details .setting a {
.media-embed-details .setting .remove-setting {
color: #a00;
font-size: 10px;
text-transform: uppercase;
}
.media-embed-details .setting .remove-setting {
padding: 0;
}
.media-embed-details .setting a:hover {
color: #f00;
}