Ajax tweaks for edit-comments.php from mdawaffe. fixes #6009
git-svn-id: https://develop.svn.wordpress.org/trunk@7050 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
2aa0422fdf
commit
7bcc30635b
@ -88,7 +88,7 @@ if ( isset( $_GET['approved'] ) || isset( $_GET['deleted'] ) || isset( $_GET['sp
|
|||||||
<?php
|
<?php
|
||||||
$status_links = array();
|
$status_links = array();
|
||||||
$num_comments = wp_count_comments();
|
$num_comments = wp_count_comments();
|
||||||
$stati = array('moderated' => sprintf(__('Awaiting Moderation (%s)'), $num_comments->moderated), 'approved' => __('Approved'));
|
$stati = array('moderated' => sprintf(__('Awaiting Moderation (%s)'), "<span class='comment-count'>$num_comments->moderated</span>"), 'approved' => __('Approved'));
|
||||||
foreach ( $stati as $status => $label ) {
|
foreach ( $stati as $status => $label ) {
|
||||||
$class = '';
|
$class = '';
|
||||||
|
|
||||||
@ -178,9 +178,9 @@ if ($comments) {
|
|||||||
foreach ($comments as $comment) {
|
foreach ($comments as $comment) {
|
||||||
$post = get_post($comment->comment_post_ID);
|
$post = get_post($comment->comment_post_ID);
|
||||||
$authordata = get_userdata($post->post_author);
|
$authordata = get_userdata($post->post_author);
|
||||||
$comment_status = wp_get_comment_status($comment->comment_ID);
|
$the_comment_status = wp_get_comment_status($comment->comment_ID);
|
||||||
$class = ('alternate' == $class) ? '' : '';
|
$class = ('alternate' == $class) ? '' : '';
|
||||||
$class .= ('unapproved' == $comment_status) ? ' unapproved' : '';
|
$class .= ('unapproved' == $the_comment_status) ? ' unapproved' : '';
|
||||||
$post_link = '<a href="' . get_comment_link() . '">' . get_the_title($comment->comment_post_ID) . '</a>';
|
$post_link = '<a href="' . get_comment_link() . '">' . get_the_title($comment->comment_post_ID) . '</a>';
|
||||||
$author_url = get_comment_author_url();
|
$author_url = get_comment_author_url();
|
||||||
if ( 'http://' == $author_url )
|
if ( 'http://' == $author_url )
|
||||||
@ -217,8 +217,12 @@ if ($comments) {
|
|||||||
<td><?php comment_date(__('Y/m/d')); ?></td>
|
<td><?php comment_date(__('Y/m/d')); ?></td>
|
||||||
<td>
|
<td>
|
||||||
<?php if ( current_user_can('edit_post', $comment->comment_post_ID) ) {
|
<?php if ( current_user_can('edit_post', $comment->comment_post_ID) ) {
|
||||||
if ( 'approved' != $comment_status )
|
if ( 'approved' != $the_comment_status ) {
|
||||||
echo "<a href='$approve_url' class='delete:the-comment-list:comment-$comment->comment_ID:33FF33:action=dim-comment' title='" . __( 'Approve this comment' ) . "'>" . __( 'Approve' ) . '</a> | ';
|
if ( $comment_status ) // we're looking at list of only approved or only unapproved comments
|
||||||
|
echo "<a href='$approve_url' class='delete:the-comment-list:comment-$comment->comment_ID:33FF33:action=dim-comment' title='" . __( 'Approve this comment' ) . "'>" . __( 'Approve' ) . '</a> | ';
|
||||||
|
else // we're looking at all comments
|
||||||
|
echo "<span class='approve'><a href='$approve_url' class='dim:the-comment-list:comment-$comment->comment_ID:unapproved:none:33FF33' title='" . __( 'Approve this comment' ) . "'>" . __( 'Approve' ) . '</a> | </span>';
|
||||||
|
}
|
||||||
echo "<a href='$spam_url' class='delete:the-comment-list:comment-$comment->comment_ID::spam=1' title='" . __( 'Mark this comment as spam' ) . "'>" . __( 'Spam' ) . '</a> | ';
|
echo "<a href='$spam_url' class='delete:the-comment-list:comment-$comment->comment_ID::spam=1' title='" . __( 'Mark this comment as spam' ) . "'>" . __( 'Spam' ) . '</a> | ';
|
||||||
echo "<a href='$delete_url' class='delete:the-comment-list:comment-$comment->comment_ID delete'>" . __('Delete') . '</a>';
|
echo "<a href='$delete_url' class='delete:the-comment-list:comment-$comment->comment_ID delete'>" . __('Delete') . '</a>';
|
||||||
}
|
}
|
||||||
|
@ -113,7 +113,7 @@ foreach($posts_columns as $column_name=>$column_display_name) {
|
|||||||
$pending_phrase = sprintf( __('%s pending'), number_format( $left ) );
|
$pending_phrase = sprintf( __('%s pending'), number_format( $left ) );
|
||||||
if ( $left )
|
if ( $left )
|
||||||
echo '<strong>';
|
echo '<strong>';
|
||||||
comments_number("<a href='edit.php?p=$id&c=1' title='$pending_phrase' class='post-com-count comment-count'><span>" . __('0') . '</span></a>', "<a href='edit.php?p=$id&c=1' title='$pending_phrase' class='post-com-count comment-count'><span>" . __('1') . '</span></a>', "<a href='edit.php?p=$id&c=1' title='$pending_phrase' class='post-com-count comment-count'><span>" . __('%') . '</span></a>');
|
comments_number("<a href='edit.php?p=$id&c=1' title='$pending_phrase' class='post-com-count'><span class='comment-count'>" . __('0') . '</span></a>', "<a href='edit.php?p=$id&c=1' title='$pending_phrase' class='post-com-count'><span class='comment-count'>" . __('1') . '</span></a>', "<a href='edit.php?p=$id&c=1' title='$pending_phrase' class='post-com-count'><span class='comment-count'>" . __('%') . '</span></a>');
|
||||||
if ( $left )
|
if ( $left )
|
||||||
echo '</strong>';
|
echo '</strong>';
|
||||||
?>
|
?>
|
||||||
|
@ -416,7 +416,7 @@ foreach ($posts_columns as $column_name=>$column_display_name) {
|
|||||||
$pending_phrase = sprintf( __('%s pending'), number_format( $left ) );
|
$pending_phrase = sprintf( __('%s pending'), number_format( $left ) );
|
||||||
if ( $left )
|
if ( $left )
|
||||||
echo '<strong>';
|
echo '<strong>';
|
||||||
comments_number("<a href='edit-pages.php?p=$id&c=1' title='$pending_phrase' class='post-com-count comment-count'><span>" . __('0') . '</span></a>', "<a href='edit-pages.php?p=$id&c=1' title='$pending_phrase' class='post-com-count comment-count'><span>" . __('1') . '</span></a>', "<a href='edit-pages.php?p=$id&c=1' title='$pending_phrase' class='post-com-count comment-count'><span>" . __('%') . '</span></a>');
|
comments_number("<a href='edit-pages.php?p=$id&c=1' title='$pending_phrase' class='post-com-count'><span class='comment-count'>" . __('0') . '</span></a>', "<a href='edit-pages.php?p=$id&c=1' title='$pending_phrase' class='post-com-count'><span class='comment-count'>" . __('1') . '</span></a>', "<a href='edit-pages.php?p=$id&c=1' title='$pending_phrase' class='post-com-count'><span class='comment-count'>" . __('%') . '</span></a>');
|
||||||
if ( $left )
|
if ( $left )
|
||||||
echo '</strong>';
|
echo '</strong>';
|
||||||
?>
|
?>
|
||||||
|
@ -2,5 +2,6 @@ addLoadEvent( function() {
|
|||||||
// pulse
|
// pulse
|
||||||
jQuery('.fade').animate( { backgroundColor: '#ffffe0' }, 300).animate( { backgroundColor: '#fffbcc' }, 300).animate( { backgroundColor: '#ffffe0' }, 300).animate( { backgroundColor: '#fffbcc' }, 300);
|
jQuery('.fade').animate( { backgroundColor: '#ffffe0' }, 300).animate( { backgroundColor: '#fffbcc' }, 300).animate( { backgroundColor: '#ffffe0' }, 300).animate( { backgroundColor: '#fffbcc' }, 300);
|
||||||
|
|
||||||
|
// Reveal
|
||||||
jQuery('.wp-no-js-hidden').removeClass( 'wp-no-js-hidden' );
|
jQuery('.wp-no-js-hidden').removeClass( 'wp-no-js-hidden' );
|
||||||
});
|
});
|
||||||
|
@ -2,7 +2,7 @@ var list; var extra;
|
|||||||
jQuery(function($) {
|
jQuery(function($) {
|
||||||
|
|
||||||
var dimAfter = function( r, settings ) {
|
var dimAfter = function( r, settings ) {
|
||||||
$('.comment-count span').each( function() {
|
$('span.comment-count').each( function() {
|
||||||
var a = $(this);
|
var a = $(this);
|
||||||
var n = parseInt(a.html(),10) + ( $('#' + settings.element).is('.' + settings.dimClass) ? 1 : -1 );
|
var n = parseInt(a.html(),10) + ( $('#' + settings.element).is('.' + settings.dimClass) ? 1 : -1 );
|
||||||
a.html( n.toString() );
|
a.html( n.toString() );
|
||||||
@ -16,7 +16,7 @@ var dimAfter = function( r, settings ) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var delAfter = function( r, settings ) {
|
var delAfter = function( r, settings ) {
|
||||||
$('.comment-count span').each( function() {
|
$('span.comment-count').each( function() {
|
||||||
var a = $(this);
|
var a = $(this);
|
||||||
if ( a.parent('.current').size() || $('#' + settings.element).is('.unapproved') && parseInt(a.html(),10) > 0 ) {
|
if ( a.parent('.current').size() || $('#' + settings.element).is('.unapproved') && parseInt(a.html(),10) > 0 ) {
|
||||||
var n = parseInt(a.html(),10) - 1;
|
var n = parseInt(a.html(),10) - 1;
|
||||||
|
@ -17,7 +17,7 @@ else
|
|||||||
|
|
||||||
$awaiting_mod = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->comments WHERE comment_approved = '0'");
|
$awaiting_mod = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->comments WHERE comment_approved = '0'");
|
||||||
$menu[15] = array(__('Design'), 'switch_themes', 'themes.php');
|
$menu[15] = array(__('Design'), 'switch_themes', 'themes.php');
|
||||||
$menu[20] = array( sprintf( __('Comments %s'), "<span id='awaiting-mod' class='comment-count'><span>$awaiting_mod</span></span>" ), 'edit_posts', 'edit-comments.php');
|
$menu[20] = array( sprintf( __('Comments %s'), "<span id='awaiting-mod'><span class='comment-count'>$awaiting_mod</span></span>" ), 'edit_posts', 'edit-comments.php');
|
||||||
$menu[30] = array(__('Settings'), 'manage_options', 'options-general.php');
|
$menu[30] = array(__('Settings'), 'manage_options', 'options-general.php');
|
||||||
$menu[35] = array(__('Plugins'), 'activate_plugins', 'plugins.php');
|
$menu[35] = array(__('Plugins'), 'activate_plugins', 'plugins.php');
|
||||||
if ( current_user_can('edit_users') )
|
if ( current_user_can('edit_users') )
|
||||||
|
@ -1,9 +1,128 @@
|
|||||||
(function(jQuery){jQuery.each(['backgroundColor','borderBottomColor','borderLeftColor','borderRightColor','borderTopColor','color','outlineColor'],function(i,attr){jQuery.fx.step[attr]=function(fx){if(fx.state==0){fx.start=getColor(fx.elem,attr);fx.end=getRGB(fx.end);}
|
/*
|
||||||
fx.elem.style[attr]="rgb("+[Math.max(Math.min(parseInt((fx.pos*(fx.end[0]-fx.start[0]))+fx.start[0]),255),0),Math.max(Math.min(parseInt((fx.pos*(fx.end[1]-fx.start[1]))+fx.start[1]),255),0),Math.max(Math.min(parseInt((fx.pos*(fx.end[2]-fx.start[2]))+fx.start[2]),255),0)].join(",")+")";}});function getRGB(color){var result;if(color&&color.constructor==Array&&color.length==3)
|
* jQuery Color Animations
|
||||||
return color;if(result=/rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/.exec(color))
|
* Copyright 2007 John Resig
|
||||||
return[parseInt(result[1]),parseInt(result[2]),parseInt(result[3])];if(result=/rgb\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*\)/.exec(color))
|
* Released under the MIT and GPL licenses.
|
||||||
return[parseFloat(result[1])*2.55,parseFloat(result[2])*2.55,parseFloat(result[3])*2.55];if(result=/#([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})/.exec(color))
|
*/
|
||||||
return[parseInt(result[1],16),parseInt(result[2],16),parseInt(result[3],16)];if(result=/#([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])/.exec(color))
|
|
||||||
return[parseInt(result[1]+result[1],16),parseInt(result[2]+result[2],16),parseInt(result[3]+result[3],16)];return colors[jQuery.trim(color).toLowerCase()];}
|
(function(jQuery){
|
||||||
function getColor(elem,attr){var color;do{color=jQuery.curCSS(elem,attr);if(color!=''&&color!='transparent'||jQuery.nodeName(elem,"body"))
|
|
||||||
break;attr="backgroundColor";}while(elem=elem.parentNode);return getRGB(color);};var colors={aqua:[0,255,255],azure:[240,255,255],beige:[245,245,220],black:[0,0,0],blue:[0,0,255],brown:[165,42,42],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgrey:[169,169,169],darkgreen:[0,100,0],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkviolet:[148,0,211],fuchsia:[255,0,255],gold:[255,215,0],green:[0,128,0],indigo:[75,0,130],khaki:[240,230,140],lightblue:[173,216,230],lightcyan:[224,255,255],lightgreen:[144,238,144],lightgrey:[211,211,211],lightpink:[255,182,193],lightyellow:[255,255,224],lime:[0,255,0],magenta:[255,0,255],maroon:[128,0,0],navy:[0,0,128],olive:[128,128,0],orange:[255,165,0],pink:[255,192,203],purple:[128,0,128],violet:[128,0,128],red:[255,0,0],silver:[192,192,192],white:[255,255,255],yellow:[255,255,0]};})(jQuery);
|
// We override the animation for all of these color styles
|
||||||
|
jQuery.each(['backgroundColor', 'borderBottomColor', 'borderLeftColor', 'borderRightColor', 'borderTopColor', 'color', 'outlineColor'], function(i,attr){
|
||||||
|
jQuery.fx.step[attr] = function(fx){
|
||||||
|
if ( fx.state == 0 ) {
|
||||||
|
fx.start = getColor( fx.elem, attr );
|
||||||
|
fx.end = getRGB( fx.end );
|
||||||
|
}
|
||||||
|
|
||||||
|
fx.elem.style[attr] = "rgb(" + [
|
||||||
|
Math.max(Math.min( parseInt((fx.pos * (fx.end[0] - fx.start[0])) + fx.start[0]), 255), 0),
|
||||||
|
Math.max(Math.min( parseInt((fx.pos * (fx.end[1] - fx.start[1])) + fx.start[1]), 255), 0),
|
||||||
|
Math.max(Math.min( parseInt((fx.pos * (fx.end[2] - fx.start[2])) + fx.start[2]), 255), 0)
|
||||||
|
].join(",") + ")";
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Color Conversion functions from highlightFade
|
||||||
|
// By Blair Mitchelmore
|
||||||
|
// http://jquery.offput.ca/highlightFade/
|
||||||
|
|
||||||
|
// Parse strings looking for color tuples [255,255,255]
|
||||||
|
function getRGB(color) {
|
||||||
|
var result;
|
||||||
|
|
||||||
|
// Check if we're already dealing with an array of colors
|
||||||
|
if ( color && color.constructor == Array && color.length == 3 )
|
||||||
|
return color;
|
||||||
|
|
||||||
|
// Look for rgb(num,num,num)
|
||||||
|
if (result = /rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/.exec(color))
|
||||||
|
return [parseInt(result[1]), parseInt(result[2]), parseInt(result[3])];
|
||||||
|
|
||||||
|
// Look for rgb(num%,num%,num%)
|
||||||
|
if (result = /rgb\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*\)/.exec(color))
|
||||||
|
return [parseFloat(result[1])*2.55, parseFloat(result[2])*2.55, parseFloat(result[3])*2.55];
|
||||||
|
|
||||||
|
// Look for #a0b1c2
|
||||||
|
if (result = /#([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})/.exec(color))
|
||||||
|
return [parseInt(result[1],16), parseInt(result[2],16), parseInt(result[3],16)];
|
||||||
|
|
||||||
|
// Look for #fff
|
||||||
|
if (result = /#([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])/.exec(color))
|
||||||
|
return [parseInt(result[1]+result[1],16), parseInt(result[2]+result[2],16), parseInt(result[3]+result[3],16)];
|
||||||
|
|
||||||
|
// Look for rgba(0, 0, 0, 0) == transparent in Safari 3
|
||||||
|
if (result = /rgba\(0, 0, 0, 0\)/.exec(color))
|
||||||
|
return colors['transparent']
|
||||||
|
|
||||||
|
// Otherwise, we're most likely dealing with a named color
|
||||||
|
return colors[jQuery.trim(color).toLowerCase()];
|
||||||
|
}
|
||||||
|
|
||||||
|
function getColor(elem, attr) {
|
||||||
|
var color;
|
||||||
|
|
||||||
|
do {
|
||||||
|
color = jQuery.curCSS(elem, attr);
|
||||||
|
|
||||||
|
// Keep going until we find an element that has color, or we hit the body
|
||||||
|
if ( color != '' && color != 'transparent' || jQuery.nodeName(elem, "body") )
|
||||||
|
break;
|
||||||
|
|
||||||
|
attr = "backgroundColor";
|
||||||
|
} while ( elem = elem.parentNode );
|
||||||
|
|
||||||
|
return getRGB(color);
|
||||||
|
};
|
||||||
|
|
||||||
|
// Some named colors to work with
|
||||||
|
// From Interface by Stefan Petre
|
||||||
|
// http://interface.eyecon.ro/
|
||||||
|
|
||||||
|
var colors = {
|
||||||
|
aqua:[0,255,255],
|
||||||
|
azure:[240,255,255],
|
||||||
|
beige:[245,245,220],
|
||||||
|
black:[0,0,0],
|
||||||
|
blue:[0,0,255],
|
||||||
|
brown:[165,42,42],
|
||||||
|
cyan:[0,255,255],
|
||||||
|
darkblue:[0,0,139],
|
||||||
|
darkcyan:[0,139,139],
|
||||||
|
darkgrey:[169,169,169],
|
||||||
|
darkgreen:[0,100,0],
|
||||||
|
darkkhaki:[189,183,107],
|
||||||
|
darkmagenta:[139,0,139],
|
||||||
|
darkolivegreen:[85,107,47],
|
||||||
|
darkorange:[255,140,0],
|
||||||
|
darkorchid:[153,50,204],
|
||||||
|
darkred:[139,0,0],
|
||||||
|
darksalmon:[233,150,122],
|
||||||
|
darkviolet:[148,0,211],
|
||||||
|
fuchsia:[255,0,255],
|
||||||
|
gold:[255,215,0],
|
||||||
|
green:[0,128,0],
|
||||||
|
indigo:[75,0,130],
|
||||||
|
khaki:[240,230,140],
|
||||||
|
lightblue:[173,216,230],
|
||||||
|
lightcyan:[224,255,255],
|
||||||
|
lightgreen:[144,238,144],
|
||||||
|
lightgrey:[211,211,211],
|
||||||
|
lightpink:[255,182,193],
|
||||||
|
lightyellow:[255,255,224],
|
||||||
|
lime:[0,255,0],
|
||||||
|
magenta:[255,0,255],
|
||||||
|
maroon:[128,0,0],
|
||||||
|
navy:[0,0,128],
|
||||||
|
olive:[128,128,0],
|
||||||
|
orange:[255,165,0],
|
||||||
|
pink:[255,192,203],
|
||||||
|
purple:[128,0,128],
|
||||||
|
violet:[128,0,128],
|
||||||
|
red:[255,0,0],
|
||||||
|
silver:[192,192,192],
|
||||||
|
white:[255,255,255],
|
||||||
|
yellow:[255,255,0],
|
||||||
|
transparent: [255,255,255]
|
||||||
|
};
|
||||||
|
|
||||||
|
})(jQuery);
|
||||||
|
@ -21,9 +21,9 @@ wpAjax = {
|
|||||||
var err = '';
|
var err = '';
|
||||||
errs.each( function() {
|
errs.each( function() {
|
||||||
var code = $(this).attr('code');
|
var code = $(this).attr('code');
|
||||||
if ( formField = $('wp_error_data[@code="' + code + '"] form-field', x).text() )
|
if ( formField = $('wp_error_data[code="' + code + '"] form-field', x).text() )
|
||||||
code = formField;
|
code = formField;
|
||||||
wpAjax.invalidateForm( $('#' + e + ' :input[@name="' + code + '"]' ).parents('.form-field:first') );
|
wpAjax.invalidateForm( $('#' + e + ' :input[name="' + code + '"]' ).parents('.form-field:first') );
|
||||||
err += '<p>' + this.firstChild.nodeValue + '</p>';
|
err += '<p>' + this.firstChild.nodeValue + '</p>';
|
||||||
} );
|
} );
|
||||||
return !re.html( '<div class="error">' + err + '</div>' );
|
return !re.html( '<div class="error">' + err + '</div>' );
|
||||||
@ -58,7 +58,7 @@ var wpList = {
|
|||||||
|
|
||||||
nonce: function(e,s) {
|
nonce: function(e,s) {
|
||||||
var url = wpAjax.unserialize(e.attr('href'));
|
var url = wpAjax.unserialize(e.attr('href'));
|
||||||
return s.nonce || url._ajax_nonce || $('#' + s.element + ' input[@name=_ajax_nonce]').val() || url._wpnonce || $('#' + s.element + ' input[@name=_wpnonce]').val() || 0;
|
return s.nonce || url._ajax_nonce || $('#' + s.element + ' input[name=_ajax_nonce]').val() || url._wpnonce || $('#' + s.element + ' input[name=_wpnonce]').val() || 0;
|
||||||
},
|
},
|
||||||
|
|
||||||
parseClass: function(e,t) {
|
parseClass: function(e,t) {
|
||||||
@ -74,11 +74,11 @@ var wpList = {
|
|||||||
}, s || {} );
|
}, s || {} );
|
||||||
if ( $.isFunction( s.confirm ) ) {
|
if ( $.isFunction( s.confirm ) ) {
|
||||||
if ( 'add' != a ) {
|
if ( 'add' != a ) {
|
||||||
bg = $('#' + s.element).css('background-color');
|
bg = $('#' + s.element).css('backgroundColor');
|
||||||
$('#' + s.element).css('background-color', '#FF9966');
|
$('#' + s.element).css('backgroundColor', '#FF9966');
|
||||||
}
|
}
|
||||||
r = s.confirm.call(this,e,s,a,bg);
|
r = s.confirm.call(this,e,s,a,bg);
|
||||||
if ( 'add' != a ) { $('#' + s.element).css('background-color', bg ); }
|
if ( 'add' != a ) { $('#' + s.element).css('backgroundColor', bg ); }
|
||||||
if ( !r ) { return false; }
|
if ( !r ) { return false; }
|
||||||
}
|
}
|
||||||
return s;
|
return s;
|
||||||
@ -94,7 +94,7 @@ var wpList = {
|
|||||||
s = wpList.pre.call( list, e, s, 'add' );
|
s = wpList.pre.call( list, e, s, 'add' );
|
||||||
if ( !s ) { return false; }
|
if ( !s ) { return false; }
|
||||||
|
|
||||||
if ( !e.is("[@class^=add:" + list.id + ":]") ) { return !wpList.add.call( list, e, s ); }
|
if ( !e.is("[class^=add:" + list.id + ":]") ) { return !wpList.add.call( list, e, s ); }
|
||||||
|
|
||||||
if ( !s.element ) { return true; }
|
if ( !s.element ) { return true; }
|
||||||
|
|
||||||
@ -102,8 +102,8 @@ var wpList = {
|
|||||||
|
|
||||||
s.nonce = wpList.nonce(e,s);
|
s.nonce = wpList.nonce(e,s);
|
||||||
|
|
||||||
var es = $('#' + s.element + ' :input').not('[@name=_ajax_nonce], [@name=_wpnonce], [@name=action]');
|
var es = $('#' + s.element + ' :input').not('[name=_ajax_nonce], [name=_wpnonce], [name=action]');
|
||||||
var required = $('#' + s.element + ' .form-required:has(:input[@value=""]), #' + s.element + ' .form-required:input[@value=""]');
|
var required = $('#' + s.element + ' .form-required:has(:input[value=""]), #' + s.element + ' .form-required:input[value=""]');
|
||||||
if ( required.size() ) {
|
if ( required.size() ) {
|
||||||
wpAjax.invalidateForm( required );
|
wpAjax.invalidateForm( required );
|
||||||
return false;
|
return false;
|
||||||
@ -172,28 +172,32 @@ var wpList = {
|
|||||||
}
|
}
|
||||||
if ( !s.data._ajax_nonce ) { return true; }
|
if ( !s.data._ajax_nonce ) { return true; }
|
||||||
|
|
||||||
var func = function() { list.wpList.recolor(); };
|
var element = $('#' + s.element);
|
||||||
var hideTO = -1;
|
|
||||||
if ( 'none' != s.delColor ) {
|
if ( 'none' != s.delColor ) {
|
||||||
$('#' + s.element).animate( { backgroundColor: s.delColor }, 100 ).slideUp();
|
var anim = 'slideUp';
|
||||||
hideTO = setTimeout(func, 500);
|
if ( element.css( 'display' ).match(/table/) )
|
||||||
|
anim = 'fadeOut'; // Can't slideup table rows and other table elements. Known jQuery bug
|
||||||
|
element
|
||||||
|
.animate( { backgroundColor: s.delColor }, 'fast' )[anim]( 'fast' )
|
||||||
|
.queue( function() { list.wpList.recolor(); $(this).dequeue(); } );
|
||||||
} else {
|
} else {
|
||||||
func();
|
list.wpList.recolor();
|
||||||
}
|
}
|
||||||
|
|
||||||
s.success = function(r) {
|
s.success = function(r) {
|
||||||
if ( !wpAjax.parseAjaxResponse(r, s.response, s.element) ) {
|
if ( !wpAjax.parseAjaxResponse(r, s.response, s.element) ) {
|
||||||
clearTimeout(hideTO);
|
element.stop().css( 'backgroundColor', '#FF3333' ).show().queue( function() { list.wpList.recolor(); $(this).dequeue(); } );
|
||||||
func = function() { $('#' + s.element).css( 'background-color', '#FF3333' ).show(); list.wpList.recolor(); };
|
|
||||||
func(); setTimeout(func, 705); // In case it's still fading
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if ( $.isFunction(s.delAfter) ) {
|
if ( $.isFunction(s.delAfter) ) {
|
||||||
var o = this.complete;
|
var o = this.complete;
|
||||||
this.complete = function(x,st) {
|
this.complete = function(x,st) {
|
||||||
var _s = $.extend( { xml: x, status: st }, s );
|
element.queue( function() {
|
||||||
s.delAfter( r, _s );
|
var _s = $.extend( { xml: x, status: st }, s );
|
||||||
if ( $.isFunction(o) ) { o(x,st); }
|
s.delAfter( r, _s );
|
||||||
|
if ( $.isFunction(o) ) { o(x,st); }
|
||||||
|
} ).dequeue();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -227,34 +231,33 @@ var wpList = {
|
|||||||
if ( !s ) { return true; }
|
if ( !s ) { return true; }
|
||||||
}
|
}
|
||||||
|
|
||||||
var thisclass = $('#' + s.element).attr('class');
|
var element = $('#' + s.element);
|
||||||
if ( thisclass && thisclass.match(/alternate/) )
|
var isClass = element.toggleClass(s.dimClass).is('.' + s.dimClass);
|
||||||
var color = '#f1f1f1';
|
var color = wpList.getColor( element );
|
||||||
else
|
element.toggleClass( s.dimClass )
|
||||||
var color = '#fff';
|
var dimColor = isClass ? s.dimAddColor : s.dimDelColor;
|
||||||
var isClass = $('#' + s.element).toggleClass(s.dimClass).is('.' + s.dimClass);
|
if ( 'none' != dimColor ) {
|
||||||
if ( isClass && 'none' != s.dimAddColor ) {
|
element
|
||||||
$('#' + s.element).animate( { backgroundColor: s.dimAddColor }, 50 ).animate( { backgroundColor: color }, 400 );
|
.animate( { backgroundColor: dimColor }, 'fast' )
|
||||||
}
|
.queue( function() { element.toggleClass(s.dimClass); $(this).dequeue(); } )
|
||||||
else if ( !isClass && 'none' != s.dimDelColor ) {
|
.animate( { backgroundColor: color }, { complete: function() { $(this).css( 'backgroundColor', '' ); } } );
|
||||||
$('#' + s.element).animate( { backgroundColor: s.dimDelColor }, 50 ).animate( { backgroundColor: color }, 400 );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !s.data._ajax_nonce ) { return true; }
|
if ( !s.data._ajax_nonce ) { return true; }
|
||||||
|
|
||||||
s.success = function(r) {
|
s.success = function(r) {
|
||||||
if ( !wpAjax.parseAjaxResponse(r, s.response, s.element) ) {
|
if ( !wpAjax.parseAjaxResponse(r, s.response, s.element) ) {
|
||||||
clearTimeout(dimTO);
|
element.stop().css( 'backgroundColor', '#FF3333' )[isClass?'removeClass':'addClass'](s.dimClass).show().queue( function() { list.wpList.recolor(); $(this).dequeue(); } );
|
||||||
func = function() { $('#' + s.element).css( 'background-color', '#FF3333' )[isClass?'removeClass':'addClass'](s.dimClass); };
|
|
||||||
func(); setTimeout(func, 705);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if ( $.isFunction(s.dimAfter) ) {
|
if ( $.isFunction(s.dimAfter) ) {
|
||||||
var o = this.complete;
|
var o = this.complete;
|
||||||
this.complete = function(x,st) {
|
this.complete = function(x,st) {
|
||||||
var _s = $.extend( { xml: x, status: st }, s );
|
element.queue( function() {
|
||||||
s.dimAfter( r, _s );
|
var _s = $.extend( { xml: x, status: st }, s );
|
||||||
if ( $.isFunction(o) ) { o(x,st); }
|
s.dimAfter( r, _s );
|
||||||
|
if ( $.isFunction(o) ) { o(x,st); }
|
||||||
|
} ).dequeue();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -263,6 +266,19 @@ var wpList = {
|
|||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// From jquery.color.js: jQuery Color Animation by John Resig
|
||||||
|
getColor: function( el ) {
|
||||||
|
if ( el.constructor == Object )
|
||||||
|
el = el.get(0);
|
||||||
|
var elem = el, color, rgbaTrans = new RegExp( "rgba\\(\\s*0,\\s*0,\\s*0,\\s*0\\s*\\)", "i" );
|
||||||
|
do {
|
||||||
|
color = jQuery.curCSS(elem, 'backgroundColor');
|
||||||
|
if ( color != '' && color != 'transparent' && !color.match(rgbaTrans) || jQuery.nodeName(elem, "body") )
|
||||||
|
break;
|
||||||
|
} while ( elem = elem.parentNode );
|
||||||
|
return color || '#ffffff';
|
||||||
|
},
|
||||||
|
|
||||||
add: function( e, s ) {
|
add: function( e, s ) {
|
||||||
list = $(this);
|
list = $(this);
|
||||||
e = $(e);
|
e = $(e);
|
||||||
@ -271,7 +287,6 @@ var wpList = {
|
|||||||
var _s = { pos: 0, id: 0, oldId: null };
|
var _s = { pos: 0, id: 0, oldId: null };
|
||||||
if ( 'string' == typeof s ) { s = { what: s }; }
|
if ( 'string' == typeof s ) { s = { what: s }; }
|
||||||
s = $.extend(_s, this.wpList.settings, s);
|
s = $.extend(_s, this.wpList.settings, s);
|
||||||
|
|
||||||
if ( !e.size() || !s.what ) { return false; }
|
if ( !e.size() || !s.what ) { return false; }
|
||||||
if ( s.oldId ) { old = $('#' + s.what + '-' + s.oldId); }
|
if ( s.oldId ) { old = $('#' + s.what + '-' + s.oldId); }
|
||||||
if ( s.id && ( s.id != s.oldId || !old || !old.size() ) ) { $('#' + s.what + '-' + s.id).remove(); }
|
if ( s.id && ( s.id != s.oldId || !old || !old.size() ) ) { $('#' + s.what + '-' + s.id).remove(); }
|
||||||
@ -299,9 +314,8 @@ var wpList = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ( 'none' != s.addColor ) {
|
if ( 'none' != s.addColor ) {
|
||||||
var b = e.css( 'background-color' );
|
var color = wpList.getColor( e );
|
||||||
if ( b == 'transparent' ) { b = ''; }
|
e.css( 'backgroundColor', s.addColor ).animate( { backgroundColor: color }, { complete: function() { $(this).css( 'backgroundColor', '' ); } } );
|
||||||
e.css('background-color', s.addColor).animate( { backgroundColor: '#fff' }, 300 );
|
|
||||||
}
|
}
|
||||||
list.each( function() { this.wpList.process( e ); } );
|
list.each( function() { this.wpList.process( e ); } );
|
||||||
return e;
|
return e;
|
||||||
@ -323,7 +337,7 @@ var wpList = {
|
|||||||
|
|
||||||
process: function(el) {
|
process: function(el) {
|
||||||
var list = this;
|
var list = this;
|
||||||
var a = $("[@class^=add:" + list.id + ":]", el || null)
|
$("[class^=add:" + list.id + ":]", el || null)
|
||||||
.filter('form').submit( function() { return list.wpList.add(this); } ).end()
|
.filter('form').submit( function() { return list.wpList.add(this); } ).end()
|
||||||
.not('form').click( function() { return list.wpList.add(this); } ).each( function() {
|
.not('form').click( function() { return list.wpList.add(this); } ).each( function() {
|
||||||
var addEl = this;
|
var addEl = this;
|
||||||
@ -343,8 +357,8 @@ var wpList = {
|
|||||||
}
|
}
|
||||||
} );
|
} );
|
||||||
} );
|
} );
|
||||||
var d = $("[@class^=delete:" + list.id + ":]", el || null).click( function() { return list.wpList.del(this); } );
|
$("[class^=delete:" + list.id + ":]", el || null).click( function() { return list.wpList.del(this); } );
|
||||||
var c = $("[@class^=dim:" + list.id + ":]", el || null).click( function() { return list.wpList.dim(this); } );
|
$("[class^=dim:" + list.id + ":]", el || null).click( function() { return list.wpList.dim(this); } );
|
||||||
},
|
},
|
||||||
|
|
||||||
recolor: function() {
|
recolor: function() {
|
||||||
|
@ -67,7 +67,7 @@ class WP_Scripts {
|
|||||||
'delText' => __('Are you sure you want to delete this %thing%?')
|
'delText' => __('Are you sure you want to delete this %thing%?')
|
||||||
) );
|
) );
|
||||||
|
|
||||||
$this->add( 'wp-lists', '/wp-includes/js/wp-lists.js', array('jquery'), '20080110' );
|
$this->add( 'wp-lists', '/wp-includes/js/wp-lists.js', array('jquery'), '20080226' );
|
||||||
$this->localize( 'wp-lists', 'wpListL10n', array(
|
$this->localize( 'wp-lists', 'wpListL10n', array(
|
||||||
'url' => get_option( 'siteurl' ) . '/wp-admin/admin-ajax.php'
|
'url' => get_option( 'siteurl' ) . '/wp-admin/admin-ajax.php'
|
||||||
) );
|
) );
|
||||||
|
Loading…
Reference in New Issue
Block a user