Better AJAX feedback messages and markup fixes. Props mdawaffe. fixes #3208
git-svn-id: http://svn.automattic.com/wordpress/trunk@4583 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
d1245edae6
commit
ccacbf47cd
|
@ -147,7 +147,7 @@ case 'add-cat' : // From Manage->Categories
|
||||||
'what' => 'cat',
|
'what' => 'cat',
|
||||||
'id' => $cat->cat_ID,
|
'id' => $cat->cat_ID,
|
||||||
'data' => _cat_row( $cat, $level, $cat_full_name ),
|
'data' => _cat_row( $cat, $level, $cat_full_name ),
|
||||||
'supplemental' => array('name' => $cat_full_name)
|
'supplemental' => array('name' => $cat_full_name, 'show-link' => sprintf(__( 'Category <a href="#%s">%s</a> added' ), "cat-$cat->cat_ID", $cat_full_name))
|
||||||
) );
|
) );
|
||||||
$x->send();
|
$x->send();
|
||||||
break;
|
break;
|
||||||
|
@ -211,10 +211,12 @@ case 'add-user' :
|
||||||
echo "<p>$message<p>";
|
echo "<p>$message<p>";
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
$user_object = new WP_User( $user_id );
|
||||||
$x = new WP_Ajax_Response( array(
|
$x = new WP_Ajax_Response( array(
|
||||||
'what' => 'user',
|
'what' => 'user',
|
||||||
'id' => $user_id,
|
'id' => $user_id,
|
||||||
'data' => user_row( $user_id )
|
'data' => user_row( $user_object ),
|
||||||
|
'supplemental' => array('show-link' => sprintf(__( 'User <a href="#%s">%s</a> added' ), "user-$user_id", $user_object->user_login))
|
||||||
) );
|
) );
|
||||||
$x->send();
|
$x->send();
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -814,11 +814,13 @@ function user_row( $user_object, $style = '' ) {
|
||||||
if ( $numposts > 0 ) {
|
if ( $numposts > 0 ) {
|
||||||
$r .= "<a href='edit.php?author=$user_object->ID' title='" . __( 'View posts by this author' ) . "' class='edit'>";
|
$r .= "<a href='edit.php?author=$user_object->ID' title='" . __( 'View posts by this author' ) . "' class='edit'>";
|
||||||
$r .= sprintf( __('View %1$s %2$s' ), $numposts, __ngettext( 'post', 'posts', $numposts ));
|
$r .= sprintf( __('View %1$s %2$s' ), $numposts, __ngettext( 'post', 'posts', $numposts ));
|
||||||
|
$r .= '</a>';
|
||||||
}
|
}
|
||||||
$r .= "</td>\n\t\t<td>";
|
$r .= "</td>\n\t\t<td>";
|
||||||
$edit_link = add_query_arg( 'wp_http_referer', wp_specialchars( urlencode( stripslashes( $_SERVER['REQUEST_URI'] ) ) ), "user-edit.php?user_id=$user_object->ID" );
|
if ( current_user_can( 'edit_user', $user_object->ID ) ) {
|
||||||
if ( current_user_can( 'edit_user', $user_object->ID ) )
|
$edit_link = wp_specialchars( add_query_arg( 'wp_http_referer', urlencode( stripslashes( $_SERVER['REQUEST_URI'] ) ), "user-edit.php?user_id=$user_object->ID" ) );
|
||||||
$r .= "<a href='$edit_link' class='edit'>".__( 'Edit' )."</a>";
|
$r .= "<a href='$edit_link' class='edit'>".__( 'Edit' )."</a>";
|
||||||
|
}
|
||||||
$r .= "</td>\n\t</tr>";
|
$r .= "</td>\n\t</tr>";
|
||||||
return $r;
|
return $r;
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,6 +16,7 @@ if ( ! empty($cat_ID) ) {
|
||||||
|
|
||||||
<div class="wrap">
|
<div class="wrap">
|
||||||
<h2><?php echo $heading ?></h2>
|
<h2><?php echo $heading ?></h2>
|
||||||
|
<div id="ajax-response"></div>
|
||||||
<?php echo $form ?>
|
<?php echo $form ?>
|
||||||
<input type="hidden" name="action" value="<?php echo $action ?>" />
|
<input type="hidden" name="action" value="<?php echo $action ?>" />
|
||||||
<input type="hidden" name="cat_ID" value="<?php echo $category->cat_ID ?>" />
|
<input type="hidden" name="cat_ID" value="<?php echo $category->cat_ID ?>" />
|
||||||
|
@ -41,7 +42,6 @@ if ( ! empty($cat_ID) ) {
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
<p class="submit"><input type="submit" name="submit" value="<?php echo $submit_text ?>" /></p>
|
<p class="submit"><input type="submit" name="submit" value="<?php echo $submit_text ?>" /></p>
|
||||||
<div id="ajax-response"></div>
|
|
||||||
<?php do_action('edit_category_form', $category); ?>
|
<?php do_action('edit_category_form', $category); ?>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -2,6 +2,7 @@ addLoadEvent(function() {
|
||||||
theListEls = document.getElementsByTagName('tbody');
|
theListEls = document.getElementsByTagName('tbody');
|
||||||
theUserLists = new Array();
|
theUserLists = new Array();
|
||||||
for ( var l = 0; l < theListEls.length; l++ ) {
|
for ( var l = 0; l < theListEls.length; l++ ) {
|
||||||
|
if ( theListEls[l].id )
|
||||||
theUserLists[theListEls[l].id] = new listMan(theListEls[l].id);
|
theUserLists[theListEls[l].id] = new listMan(theListEls[l].id);
|
||||||
}
|
}
|
||||||
addUserInputs = document.getElementById('adduser').getElementsByTagName('input');
|
addUserInputs = document.getElementById('adduser').getElementsByTagName('input');
|
||||||
|
|
|
@ -376,7 +376,7 @@ default:
|
||||||
foreach($roleclasses as $role => $roleclass) {
|
foreach($roleclasses as $role => $roleclass) {
|
||||||
uksort($roleclass, "strnatcasecmp");
|
uksort($roleclass, "strnatcasecmp");
|
||||||
?>
|
?>
|
||||||
|
<tbody>
|
||||||
<tr>
|
<tr>
|
||||||
<?php if ( !empty($role) ) : ?>
|
<?php if ( !empty($role) ) : ?>
|
||||||
<th colspan="7"><h3><?php echo $wp_roles->role_names[$role]; ?></h3></th>
|
<th colspan="7"><h3><?php echo $wp_roles->role_names[$role]; ?></h3></th>
|
||||||
|
@ -392,7 +392,7 @@ foreach($roleclasses as $role => $roleclass) {
|
||||||
<th><?php _e('Website') ?></th>
|
<th><?php _e('Website') ?></th>
|
||||||
<th colspan="2" style="text-align: center"><?php _e('Actions') ?></th>
|
<th colspan="2" style="text-align: center"><?php _e('Actions') ?></th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</tbody>
|
||||||
<tbody id="role-<?php echo $role; ?>"><?php
|
<tbody id="role-<?php echo $role; ?>"><?php
|
||||||
$style = '';
|
$style = '';
|
||||||
foreach ( (array) $roleclass as $user_object ) {
|
foreach ( (array) $roleclass as $user_object ) {
|
||||||
|
@ -437,7 +437,19 @@ foreach ( (array) $roleclass as $user_object ) {
|
||||||
|
|
||||||
<div class="wrap">
|
<div class="wrap">
|
||||||
<h2 id="add-new-user"><?php _e('Add New User') ?></h2>
|
<h2 id="add-new-user"><?php _e('Add New User') ?></h2>
|
||||||
|
|
||||||
|
<?php if ( is_wp_error( $add_user_errors ) ) : ?>
|
||||||
|
<div class="error">
|
||||||
|
<?php
|
||||||
|
foreach ( $add_user_errors->get_error_messages() as $message )
|
||||||
|
echo "<p>$message</p>";
|
||||||
|
?>
|
||||||
|
</div>
|
||||||
|
<?php endif; ?>
|
||||||
|
<div id="ajax-response"></div>
|
||||||
|
|
||||||
<div class="narrow">
|
<div class="narrow">
|
||||||
|
|
||||||
<?php echo '<p>'.sprintf(__('Users can <a href="%1$s">register themselves</a> or you can manually create users here.'), get_option('siteurl').'/wp-register.php').'</p>'; ?>
|
<?php echo '<p>'.sprintf(__('Users can <a href="%1$s">register themselves</a> or you can manually create users here.'), get_option('siteurl').'/wp-register.php').'</p>'; ?>
|
||||||
<form action="#add-new-user" method="post" name="adduser" id="adduser">
|
<form action="#add-new-user" method="post" name="adduser" id="adduser">
|
||||||
<?php wp_nonce_field('add-user') ?>
|
<?php wp_nonce_field('add-user') ?>
|
||||||
|
@ -488,18 +500,9 @@ foreach ( (array) $roleclass as $user_object ) {
|
||||||
<?php echo $referer; ?>
|
<?php echo $referer; ?>
|
||||||
<input name="adduser" type="submit" id="addusersub" value="<?php _e('Add User »') ?>" />
|
<input name="adduser" type="submit" id="addusersub" value="<?php _e('Add User »') ?>" />
|
||||||
</p>
|
</p>
|
||||||
</div>
|
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
<?php if ( is_wp_error( $add_user_errors ) ) : ?>
|
|
||||||
<div class="error">
|
|
||||||
<?php
|
|
||||||
foreach ( $add_user_errors->get_error_messages() as $message )
|
|
||||||
echo "<p>$message</p>";
|
|
||||||
?>
|
|
||||||
</div>
|
</div>
|
||||||
<?php endif; ?>
|
|
||||||
<div id="ajax-response"></div>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
|
|
|
@ -180,7 +180,7 @@ function wp_dropdown_categories($args = '') {
|
||||||
|
|
||||||
$output = '';
|
$output = '';
|
||||||
if ( ! empty($categories) ) {
|
if ( ! empty($categories) ) {
|
||||||
$output = "<select name='$name' class='$class'>\n";
|
$output = "<select name='$name' id='$name' class='$class'>\n";
|
||||||
|
|
||||||
if ( $show_option_all ) {
|
if ( $show_option_all ) {
|
||||||
$show_option_all = apply_filters('list_cats', $show_option_all);
|
$show_option_all = apply_filters('list_cats', $show_option_all);
|
||||||
|
|
|
@ -37,6 +37,8 @@ Object.extend(listMan.prototype, {
|
||||||
ajaxAdd.addOnComplete( function(transport) {
|
ajaxAdd.addOnComplete( function(transport) {
|
||||||
var newItems = $A(transport.responseXML.getElementsByTagName(what));
|
var newItems = $A(transport.responseXML.getElementsByTagName(what));
|
||||||
if ( newItems ) {
|
if ( newItems ) {
|
||||||
|
var showLinkMessage = '';
|
||||||
|
var m = '';
|
||||||
newItems.each( function(i) {
|
newItems.each( function(i) {
|
||||||
var id = i.getAttribute('id');
|
var id = i.getAttribute('id');
|
||||||
var exists = $(what+'-'+id);
|
var exists = $(what+'-'+id);
|
||||||
|
@ -44,10 +46,15 @@ Object.extend(listMan.prototype, {
|
||||||
tempObj.replaceListItem( exists, getNodeValue(i,'response_data'), update );
|
tempObj.replaceListItem( exists, getNodeValue(i,'response_data'), update );
|
||||||
else
|
else
|
||||||
tempObj.addListItem( getNodeValue(i, 'response_data') );
|
tempObj.addListItem( getNodeValue(i, 'response_data') );
|
||||||
if ( tempObj.showLink )
|
m = getNodeValue(i, 'show-link');
|
||||||
tempObj.showLink = id;
|
showLinkMessage += showLinkMessage ? "<br />\n" : '';
|
||||||
|
if ( m )
|
||||||
|
showLinkMessage += m;
|
||||||
|
else
|
||||||
|
showLinkMessage += "<a href='#" + what + '-' + id + "'><?php echo js_escape(__('Jump to new item')); ?>";
|
||||||
});
|
});
|
||||||
ajaxAdd.myResponseElement.update(tempObj.showLink ? ( "<div id='jumplink' class='updated fade'><p><a href='#" + what + '-' + tempObj.showLink + "'><?php js_escape(__('Jump to new item')); ?></a></p></div>" ) : '');
|
if ( tempObj.showLink && showLinkMessage )
|
||||||
|
ajaxAdd.myResponseElement.update("<div id='jumplink' class='updated fade'><p>" + showLinkMessage + "</p></div>");
|
||||||
}
|
}
|
||||||
if ( tempObj.addComplete && typeof tempObj.addComplete == 'function' )
|
if ( tempObj.addComplete && typeof tempObj.addComplete == 'function' )
|
||||||
tempObj.addComplete( what, where, update, transport );
|
tempObj.addComplete( what, where, update, transport );
|
||||||
|
|
|
@ -21,16 +21,16 @@ class WP_Scripts {
|
||||||
$this->add( 'prototype', '/wp-includes/js/prototype.compressed.js', false, '1.5.0');
|
$this->add( 'prototype', '/wp-includes/js/prototype.compressed.js', false, '1.5.0');
|
||||||
$this->add( 'autosave', '/wp-includes/js/autosave.js.php', array('prototype', 'sack'), '4508');
|
$this->add( 'autosave', '/wp-includes/js/autosave.js.php', array('prototype', 'sack'), '4508');
|
||||||
$this->add( 'wp-ajax', '/wp-includes/js/wp-ajax-js.php', array('prototype'), '4459');
|
$this->add( 'wp-ajax', '/wp-includes/js/wp-ajax-js.php', array('prototype'), '4459');
|
||||||
$this->add( 'listman', '/wp-includes/js/list-manipulation-js.php', array('wp-ajax', 'fat'), '4459');
|
$this->add( 'listman', '/wp-includes/js/list-manipulation-js.php', array('wp-ajax', 'fat'), '4583');
|
||||||
if ( is_admin() ) {
|
if ( is_admin() ) {
|
||||||
$this->add( 'dbx-admin-key', '/wp-admin/dbx-admin-key-js.php', array('dbx'), '3651' );
|
$this->add( 'dbx-admin-key', '/wp-admin/dbx-admin-key-js.php', array('dbx'), '3651' );
|
||||||
$this->add( 'ajaxcat', '/wp-admin/cat-js.php', array('listman'), '3684' );
|
$this->add( 'ajaxcat', '/wp-admin/cat-js.php', array('listman'), '3684' );
|
||||||
$this->add( 'admin-categories', '/wp-admin/categories.js', array('listman'), '3684' );
|
$this->add( 'admin-categories', '/wp-admin/categories.js', array('listman'), '3684' );
|
||||||
$this->add( 'admin-custom-fields', '/wp-admin/custom-fields.js', array('listman'), '3733' );
|
$this->add( 'admin-custom-fields', '/wp-admin/custom-fields.js', array('listman'), '3733' );
|
||||||
$this->add( 'admin-comments', '/wp-admin/edit-comments.js', array('listman'), '3847' );
|
$this->add( 'admin-comments', '/wp-admin/edit-comments.js', array('listman'), '3847' );
|
||||||
$this->add( 'admin-users', '/wp-admin/users.js', array('listman'), '3684' );
|
$this->add( 'admin-users', '/wp-admin/users.js', array('listman'), '4583' );
|
||||||
$this->add( 'xfn', '/wp-admin/xfn.js', false, '3517' );
|
$this->add( 'xfn', '/wp-admin/xfn.js', false, '3517' );
|
||||||
$this->add( 'upload', '/wp-admin/upload-js.php', array('prototype'), '####' );
|
$this->add( 'upload', '/wp-admin/upload-js.php', array('prototype'), '4535' );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue