Don't bind every form element to form.submit in wp-lists, fixes #7838, see #9696

git-svn-id: http://svn.automattic.com/wordpress/trunk@11201 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
azaozz 2009-05-05 10:29:37 +00:00
parent 62b2e5e278
commit 2c2878bc80
3 changed files with 6 additions and 21 deletions

View File

@ -1,5 +1,5 @@
(function($) {
var currentFormEl = false, fs = {add:'ajaxAdd',del:'ajaxDel',dim:'ajaxDim',process:'process',recolor:'recolor'}, wpList;
var fs = {add:'ajaxAdd',del:'ajaxDel',dim:'ajaxDim',process:'process',recolor:'recolor'}, wpList;
wpList = {
settings: {
@ -264,7 +264,8 @@ wpList = {
if ( s.id && ( s.id != s.oldId || !old || !old.size() ) ) { $('#' + s.what + '-' + s.id).remove(); }
if ( old && old.size() ) {
old.replaceWith(e);
old.before(e);
old.remove();
} else if ( isNaN(s.pos) ) {
ba = 'after';
if ( '-' == s.pos.substr(0,1) ) {
@ -312,23 +313,7 @@ wpList = {
var list = this;
$("[class^=add:" + list.id + ":]", el || null)
.filter('form').submit( function() { return list.wpList.add(this); } ).end()
.not('form').click( function() { return list.wpList.add(this); } ).each( function() {
var addEl = this, c = wpList.parseClass(this,'add')[2] || addEl.id, forms = [], ins = [];
if ( !c ) { return; }
// this is all really inefficient
$('#' + c + ' :input').focus( function() { currentFormEl = this; } ).blur( function() { currentFormEl = false; } ).each( function() {
ins.push(this);
var f = $(this).parents('form:first').get(0);
if ( $.inArray(f,forms) < 0 ) { forms.push(f); }
} );
$(forms).submit( function() {
if ( 0 <= $.inArray(currentFormEl,ins) ) {
$(addEl).trigger( 'click' );
$(currentFormEl).focus();
return false;
}
} );
} );
.not('form').click( function() { return list.wpList.add(this); } );
$("[class^=delete:" + list.id + ":]", el || null).click( function() { return list.wpList.del(this); } );
$("[class^=dim:" + list.id + ":]", el || null).click( function() { return list.wpList.dim(this); } );
},

File diff suppressed because one or more lines are too long

View File

@ -107,7 +107,7 @@ function wp_default_scripts( &$scripts ) {
$scripts->add( 'autosave', "/wp-includes/js/autosave$suffix.js", array('schedule', 'wp-ajax-response'), '20090106' );
$scripts->add_data( 'autosave', 'group', 1 );
$scripts->add( 'wp-lists', "/wp-includes/js/wp-lists$suffix.js", array('wp-ajax-response'), '20090128' );
$scripts->add( 'wp-lists', "/wp-includes/js/wp-lists$suffix.js", array('wp-ajax-response'), '20090504' );
$scripts->add_data( 'wp-lists', 'group', 1 );
$scripts->localize( 'wp-lists', 'wpListL10n', array(
'url' => admin_url('admin-ajax.php')