+/* global ajaxurl, wpAjax */
(function($) {
var fs = {add:'ajaxAdd',del:'ajaxDel',dim:'ajaxDim',process:'process',recolor:'recolor'}, wpList;
return s.nonce || url._ajax_nonce || $('#' + s.element + ' input[name="_ajax_nonce"]').val() || url._wpnonce || $('#' + s.element + ' input[name="_wpnonce"]').val() || 0;
},
+ /**
+ * Extract list item data from a DOM element.
+ *
+ * @param {HTMLElement} e The DOM element.
+ * @param {string} t
+ * @return {array}
+ */
parseData: function(e,t) {
var d = [], wpListsData;
return false;
},
+ /**
+ * Delete an item in the list via AJAX.
+ *
+ * @param {HTMLElement} e A DOM element containing item data.
+ * @param {Object} s
+ * @return {boolean}
+ */
ajaxDel: function( e, s ) {
e = $(e);
s = s || {};
res = wpAjax.parseAjaxResponse(r, s.response, s.element);
rres = r;
- if ( !res || res.errors ) {
+ if ( true === res ) {
+ return true;
+ }
+
+ if ( ! res || res.errors ) {
element.stop().stop().css( 'backgroundColor', '#FF3333' )[isClass?'removeClass':'addClass'](s.dimClass).show().queue( function() { list.wpList.recolor(); $(this).dequeue(); } );
return false;
}
+
+ if ( 'undefined' !== typeof res.responses[0].supplemental.comment_link ) {
+ var submittedOn = element.find( '.submitted-on' ),
+ commentLink = submittedOn.find( 'a' );
+
+ // Comment is approved; link the date field.
+ if ( '' !== res.responses[0].supplemental.comment_link ) {
+ submittedOn.html( $('<a></a>').text( submittedOn.text() ).prop( 'href', res.responses[0].supplemental.comment_link ) );
+
+ // Comment is not approved; unlink the date field.
+ } else if ( commentLink.length ) {
+ submittedOn.text( commentLink.text() );
+ }
+ }
};
s.complete = function(x, st) {
},
add: function( e, s ) {
- e = $( $.trim(e) ); // Trim leading whitespaces
+ if ( 'string' == typeof e ) {
+ e = $( $.trim( e ) ); // Trim leading whitespaces
+ } else {
+ e = $( e );
+ }
var list = $(this), old = false, _s = { pos: 0, id: 0, oldId: null }, ba, ref, color;
s = $.extend(_s, this.wpList.settings, s);
- if ( !e.size() || !s.what )
+ if ( !e.length || !s.what )
return false;
if ( s.oldId )
old = $('#' + s.what + '-' + s.oldId);
- if ( s.id && ( s.id != s.oldId || !old || !old.size() ) )
+ if ( s.id && ( s.id != s.oldId || !old || !old.length ) )
$('#' + s.what + '-' + s.id).remove();
- if ( old && old.size() ) {
+ if ( old && old.length ) {
old.before(e);
old.remove();
} else if ( isNaN(s.pos) ) {
ref = list.find( '#' + s.pos );
- if ( 1 === ref.size() )
+ if ( 1 === ref.length )
ref[ba](e);
else
list.append(e);
e = $(e);
- if ( list.wpList && e.parents( '#' + list.id ).size() )
+ if ( list.wpList && e.parents( '#' + list.id ).length )
return;
e.find(':input').each( function() {
- if ( $(this).parents('.form-no-clear').size() )
+ if ( $(this).parents('.form-no-clear').length )
return;
t = this.type.toLowerCase();
items = $('.list-item:visible', list);
- if ( !items.size() )
+ if ( !items.length )
items = $(list).children(':visible');
eo = [':even',':odd'];