author | ymh <ymh.work@gmail.com> |
Mon, 14 Oct 2019 17:39:30 +0200 | |
changeset 7 | cf61fcea0001 |
parent 5 | 5e2f62d02dcd |
child 9 | 177826044cd9 |
permissions | -rw-r--r-- |
5 | 1 |
/* global adminCommentsL10n, thousandsSeparator, list_args, QTags, ajaxurl, wpAjax */ |
2 |
var setCommentsList, theList, theExtraList, commentReply; |
|
0 | 3 |
|
4 |
(function($) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
5 |
var getCount, updateCount, updateCountText, updatePending, updateApproved, |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
6 |
updateHtmlTitle, updateDashboardText, adminTitle = document.title, |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
7 |
isDashboard = $('#dashboard_right_now').length, |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
8 |
titleDiv, titleRegEx; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
9 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
10 |
getCount = function(el) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
11 |
var n = parseInt( el.html().replace(/[^0-9]+/g, ''), 10 ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
12 |
if ( isNaN(n) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
13 |
return 0; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
14 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
15 |
return n; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
16 |
}; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
17 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
18 |
updateCount = function(el, n) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
19 |
var n1 = ''; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
20 |
if ( isNaN(n) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
21 |
return; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
22 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
23 |
n = n < 1 ? '0' : n.toString(); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
24 |
if ( n.length > 3 ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
25 |
while ( n.length > 3 ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
26 |
n1 = thousandsSeparator + n.substr(n.length - 3) + n1; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
27 |
n = n.substr(0, n.length - 3); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
28 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
29 |
n = n + n1; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
30 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
31 |
el.html(n); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
32 |
}; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
33 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
34 |
updateApproved = function( diff, commentPostId ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
35 |
var postSelector = '.post-com-count-' + commentPostId, |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
36 |
noClass = 'comment-count-no-comments', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
37 |
approvedClass = 'comment-count-approved', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
38 |
approved, |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
39 |
noComments; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
40 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
41 |
updateCountText( 'span.approved-count', diff ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
42 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
43 |
if ( ! commentPostId ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
44 |
return; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
45 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
46 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
47 |
// cache selectors to not get dupes |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
48 |
approved = $( 'span.' + approvedClass, postSelector ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
49 |
noComments = $( 'span.' + noClass, postSelector ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
50 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
51 |
approved.each(function() { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
52 |
var a = $(this), n = getCount(a) + diff; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
53 |
if ( n < 1 ) |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
54 |
n = 0; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
55 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
56 |
if ( 0 === n ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
57 |
a.removeClass( approvedClass ).addClass( noClass ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
58 |
} else { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
59 |
a.addClass( approvedClass ).removeClass( noClass ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
60 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
61 |
updateCount( a, n ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
62 |
}); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
63 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
64 |
noComments.each(function() { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
65 |
var a = $(this); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
66 |
if ( diff > 0 ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
67 |
a.removeClass( noClass ).addClass( approvedClass ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
68 |
} else { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
69 |
a.addClass( noClass ).removeClass( approvedClass ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
70 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
71 |
updateCount( a, diff ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
72 |
}); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
73 |
}; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
74 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
75 |
updateCountText = function( selector, diff ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
76 |
$( selector ).each(function() { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
77 |
var a = $(this), n = getCount(a) + diff; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
78 |
if ( n < 1 ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
79 |
n = 0; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
80 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
81 |
updateCount( a, n ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
82 |
}); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
83 |
}; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
84 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
85 |
updateDashboardText = function ( response ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
86 |
if ( ! isDashboard || ! response || ! response.i18n_comments_text ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
87 |
return; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
88 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
89 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
90 |
var rightNow = $( '#dashboard_right_now' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
91 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
92 |
$( '.comment-count a', rightNow ).text( response.i18n_comments_text ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
93 |
$( '.comment-mod-count a', rightNow ).text( response.i18n_moderation_text ) |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
94 |
.parent() |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
95 |
[ response.in_moderation > 0 ? 'removeClass' : 'addClass' ]( 'hidden' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
96 |
}; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
97 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
98 |
updateHtmlTitle = function ( diff ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
99 |
var newTitle, regExMatch, titleCount, commentFrag; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
100 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
101 |
titleRegEx = titleRegEx || new RegExp( adminCommentsL10n.docTitleCommentsCount.replace( '%s', '\\([0-9' + thousandsSeparator + ']+\\)' ) + '?' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
102 |
// count funcs operate on a $'d element |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
103 |
titleDiv = titleDiv || $( '<div />' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
104 |
newTitle = adminTitle; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
105 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
106 |
commentFrag = titleRegEx.exec( document.title ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
107 |
if ( commentFrag ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
108 |
commentFrag = commentFrag[0]; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
109 |
titleDiv.html( commentFrag ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
110 |
titleCount = getCount( titleDiv ) + diff; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
111 |
} else { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
112 |
titleDiv.html( 0 ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
113 |
titleCount = diff; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
114 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
115 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
116 |
if ( titleCount >= 1 ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
117 |
updateCount( titleDiv, titleCount ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
118 |
regExMatch = titleRegEx.exec( document.title ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
119 |
if ( regExMatch ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
120 |
newTitle = document.title.replace( regExMatch[0], adminCommentsL10n.docTitleCommentsCount.replace( '%s', titleDiv.text() ) + ' ' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
121 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
122 |
} else { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
123 |
regExMatch = titleRegEx.exec( newTitle ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
124 |
if ( regExMatch ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
125 |
newTitle = newTitle.replace( regExMatch[0], adminCommentsL10n.docTitleComments ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
126 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
127 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
128 |
document.title = newTitle; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
129 |
}; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
130 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
131 |
updatePending = function( diff, commentPostId ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
132 |
var postSelector = '.post-com-count-' + commentPostId, |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
133 |
noClass = 'comment-count-no-pending', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
134 |
noParentClass = 'post-com-count-no-pending', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
135 |
pendingClass = 'comment-count-pending', |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
136 |
pending, |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
137 |
noPending; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
138 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
139 |
if ( ! isDashboard ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
140 |
updateHtmlTitle( diff ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
141 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
142 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
143 |
$( 'span.pending-count' ).each(function() { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
144 |
var a = $(this), n = getCount(a) + diff; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
145 |
if ( n < 1 ) |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
146 |
n = 0; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
147 |
a.closest('.awaiting-mod')[ 0 === n ? 'addClass' : 'removeClass' ]('count-0'); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
148 |
updateCount( a, n ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
149 |
}); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
150 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
151 |
if ( ! commentPostId ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
152 |
return; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
153 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
154 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
155 |
// cache selectors to not get dupes |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
156 |
pending = $( 'span.' + pendingClass, postSelector ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
157 |
noPending = $( 'span.' + noClass, postSelector ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
158 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
159 |
pending.each(function() { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
160 |
var a = $(this), n = getCount(a) + diff; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
161 |
if ( n < 1 ) |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
162 |
n = 0; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
163 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
164 |
if ( 0 === n ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
165 |
a.parent().addClass( noParentClass ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
166 |
a.removeClass( pendingClass ).addClass( noClass ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
167 |
} else { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
168 |
a.parent().removeClass( noParentClass ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
169 |
a.addClass( pendingClass ).removeClass( noClass ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
170 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
171 |
updateCount( a, n ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
172 |
}); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
173 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
174 |
noPending.each(function() { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
175 |
var a = $(this); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
176 |
if ( diff > 0 ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
177 |
a.parent().removeClass( noParentClass ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
178 |
a.removeClass( noClass ).addClass( pendingClass ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
179 |
} else { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
180 |
a.parent().addClass( noParentClass ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
181 |
a.addClass( noClass ).removeClass( pendingClass ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
182 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
183 |
updateCount( a, diff ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
184 |
}); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
185 |
}; |
0 | 186 |
|
187 |
setCommentsList = function() { |
|
5 | 188 |
var totalInput, perPageInput, pageInput, dimAfter, delBefore, updateTotalCount, delAfter, refillTheExtraList, diff, |
189 |
lastConfidentTime = 0; |
|
0 | 190 |
|
191 |
totalInput = $('input[name="_total"]', '#comments-form'); |
|
192 |
perPageInput = $('input[name="_per_page"]', '#comments-form'); |
|
193 |
pageInput = $('input[name="_page"]', '#comments-form'); |
|
194 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
195 |
// Updates the current total (stored in the _total input) |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
196 |
updateTotalCount = function( total, time, setConfidentTime ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
197 |
if ( time < lastConfidentTime ) |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
198 |
return; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
199 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
200 |
if ( setConfidentTime ) |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
201 |
lastConfidentTime = time; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
202 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
203 |
totalInput.val( total.toString() ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
204 |
}; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
205 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
206 |
// this fires when viewing "All" |
0 | 207 |
dimAfter = function( r, settings ) { |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
208 |
var editRow, replyID, replyButton, response, |
5 | 209 |
c = $( '#' + settings.element ); |
0 | 210 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
211 |
if ( true !== settings.parsed ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
212 |
response = settings.parsed.responses[0]; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
213 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
214 |
|
0 | 215 |
editRow = $('#replyrow'); |
216 |
replyID = $('#comment_ID', editRow).val(); |
|
217 |
replyButton = $('#replybtn', editRow); |
|
218 |
||
219 |
if ( c.is('.unapproved') ) { |
|
220 |
if ( settings.data.id == replyID ) |
|
221 |
replyButton.text(adminCommentsL10n.replyApprove); |
|
222 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
223 |
c.find( '.row-actions span.view' ).addClass( 'hidden' ).end() |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
224 |
.find( 'div.comment_status' ).html( '0' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
225 |
|
0 | 226 |
} else { |
227 |
if ( settings.data.id == replyID ) |
|
228 |
replyButton.text(adminCommentsL10n.reply); |
|
229 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
230 |
c.find( '.row-actions span.view' ).removeClass( 'hidden' ).end() |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
231 |
.find( 'div.comment_status' ).html( '1' ); |
0 | 232 |
} |
233 |
||
5 | 234 |
diff = $('#' + settings.element).is('.' + settings.dimClass) ? 1 : -1; |
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
235 |
if ( response ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
236 |
updateDashboardText( response.supplemental ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
237 |
updatePending( diff, response.supplemental.postId ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
238 |
updateApproved( -1 * diff, response.supplemental.postId ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
239 |
} else { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
240 |
updatePending( diff ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
241 |
updateApproved( -1 * diff ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
242 |
} |
0 | 243 |
}; |
244 |
||
245 |
// Send current total, page, per_page and url |
|
246 |
delBefore = function( settings, list ) { |
|
5 | 247 |
var note, id, el, n, h, a, author, |
248 |
action = false, |
|
249 |
wpListsData = $( settings.target ).attr( 'data-wp-lists' ); |
|
0 | 250 |
|
251 |
settings.data._total = totalInput.val() || 0; |
|
252 |
settings.data._per_page = perPageInput.val() || 0; |
|
253 |
settings.data._page = pageInput.val() || 0; |
|
254 |
settings.data._url = document.location.href; |
|
255 |
settings.data.comment_status = $('input[name="comment_status"]', '#comments-form').val(); |
|
256 |
||
257 |
if ( wpListsData.indexOf(':trash=1') != -1 ) |
|
258 |
action = 'trash'; |
|
259 |
else if ( wpListsData.indexOf(':spam=1') != -1 ) |
|
260 |
action = 'spam'; |
|
261 |
||
262 |
if ( action ) { |
|
263 |
id = wpListsData.replace(/.*?comment-([0-9]+).*/, '$1'); |
|
264 |
el = $('#comment-' + id); |
|
265 |
note = $('#' + action + '-undo-holder').html(); |
|
266 |
||
267 |
el.find('.check-column :checkbox').prop('checked', false); // Uncheck the row so as not to be affected by Bulk Edits. |
|
268 |
||
269 |
if ( el.siblings('#replyrow').length && commentReply.cid == id ) |
|
270 |
commentReply.close(); |
|
271 |
||
272 |
if ( el.is('tr') ) { |
|
273 |
n = el.children(':visible').length; |
|
274 |
author = $('.author strong', el).text(); |
|
275 |
h = $('<tr id="undo-' + id + '" class="undo un' + action + '" style="display:none;"><td colspan="' + n + '">' + note + '</td></tr>'); |
|
276 |
} else { |
|
277 |
author = $('.comment-author', el).text(); |
|
278 |
h = $('<div id="undo-' + id + '" style="display:none;" class="undo un' + action + '">' + note + '</div>'); |
|
279 |
} |
|
280 |
||
281 |
el.before(h); |
|
282 |
||
283 |
$('strong', '#undo-' + id).text(author); |
|
284 |
a = $('.undo a', '#undo-' + id); |
|
285 |
a.attr('href', 'comment.php?action=un' + action + 'comment&c=' + id + '&_wpnonce=' + settings.data._ajax_nonce); |
|
286 |
a.attr('data-wp-lists', 'delete:the-comment-list:comment-' + id + '::un' + action + '=1'); |
|
287 |
a.attr('class', 'vim-z vim-destructive'); |
|
5 | 288 |
$('.avatar', el).first().clone().prependTo('#undo-' + id + ' .' + action + '-undo-inside'); |
0 | 289 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
290 |
a.click(function( e ){ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
291 |
e.preventDefault(); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
292 |
e.stopPropagation(); // ticket #35904 |
0 | 293 |
list.wpList.del(this); |
294 |
$('#undo-' + id).css( {backgroundColor:'#ceb'} ).fadeOut(350, function(){ |
|
295 |
$(this).remove(); |
|
5 | 296 |
$('#comment-' + id).css('backgroundColor', '').fadeIn(300, function(){ $(this).show(); }); |
0 | 297 |
}); |
298 |
}); |
|
299 |
} |
|
300 |
||
301 |
return settings; |
|
302 |
}; |
|
303 |
||
304 |
// In admin-ajax.php, we send back the unix time stamp instead of 1 on success |
|
305 |
delAfter = function( r, settings ) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
306 |
var total_items_i18n, total, animated, animatedCallback, |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
307 |
response = true === settings.parsed ? {} : settings.parsed.responses[0], |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
308 |
commentStatus = true === settings.parsed ? '' : response.supplemental.status, |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
309 |
commentPostId = true === settings.parsed ? '' : response.supplemental.postId, |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
310 |
newTotal = true === settings.parsed ? '' : response.supplemental, |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
311 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
312 |
targetParent = $( settings.target ).parent(), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
313 |
commentRow = $('#' + settings.element), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
314 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
315 |
spamDiff, trashDiff, pendingDiff, approvedDiff, |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
316 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
317 |
approved = commentRow.hasClass( 'approved' ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
318 |
unapproved = commentRow.hasClass( 'unapproved' ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
319 |
spammed = commentRow.hasClass( 'spam' ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
320 |
trashed = commentRow.hasClass( 'trash' ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
321 |
undoing = false; // ticket #35904 |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
322 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
323 |
updateDashboardText( newTotal ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
324 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
325 |
// the order of these checks is important |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
326 |
// .unspam can also have .approve or .unapprove |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
327 |
// .untrash can also have .approve or .unapprove |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
328 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
329 |
if ( targetParent.is( 'span.undo' ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
330 |
// the comment was spammed |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
331 |
if ( targetParent.hasClass( 'unspam' ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
332 |
spamDiff = -1; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
333 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
334 |
if ( 'trash' === commentStatus ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
335 |
trashDiff = 1; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
336 |
} else if ( '1' === commentStatus ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
337 |
approvedDiff = 1; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
338 |
} else if ( '0' === commentStatus ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
339 |
pendingDiff = 1; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
340 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
341 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
342 |
// the comment was trashed |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
343 |
} else if ( targetParent.hasClass( 'untrash' ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
344 |
trashDiff = -1; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
345 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
346 |
if ( 'spam' === commentStatus ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
347 |
spamDiff = 1; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
348 |
} else if ( '1' === commentStatus ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
349 |
approvedDiff = 1; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
350 |
} else if ( '0' === commentStatus ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
351 |
pendingDiff = 1; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
352 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
353 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
354 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
355 |
undoing = true; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
356 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
357 |
// user clicked "Spam" |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
358 |
} else if ( targetParent.is( 'span.spam' ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
359 |
// the comment is currently approved |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
360 |
if ( approved ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
361 |
approvedDiff = -1; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
362 |
// the comment is currently pending |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
363 |
} else if ( unapproved ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
364 |
pendingDiff = -1; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
365 |
// the comment was in the trash |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
366 |
} else if ( trashed ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
367 |
trashDiff = -1; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
368 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
369 |
// you can't spam an item on the spam screen |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
370 |
spamDiff = 1; |
0 | 371 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
372 |
// user clicked "Unspam" |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
373 |
} else if ( targetParent.is( 'span.unspam' ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
374 |
if ( approved ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
375 |
pendingDiff = 1; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
376 |
} else if ( unapproved ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
377 |
approvedDiff = 1; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
378 |
} else if ( trashed ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
379 |
// the comment was previously approved |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
380 |
if ( targetParent.hasClass( 'approve' ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
381 |
approvedDiff = 1; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
382 |
// the comment was previously pending |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
383 |
} else if ( targetParent.hasClass( 'unapprove' ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
384 |
pendingDiff = 1; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
385 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
386 |
} else if ( spammed ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
387 |
if ( targetParent.hasClass( 'approve' ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
388 |
approvedDiff = 1; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
389 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
390 |
} else if ( targetParent.hasClass( 'unapprove' ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
391 |
pendingDiff = 1; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
392 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
393 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
394 |
// you can Unspam an item on the spam screen |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
395 |
spamDiff = -1; |
0 | 396 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
397 |
// user clicked "Trash" |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
398 |
} else if ( targetParent.is( 'span.trash' ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
399 |
if ( approved ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
400 |
approvedDiff = -1; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
401 |
} else if ( unapproved ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
402 |
pendingDiff = -1; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
403 |
// the comment was in the spam queue |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
404 |
} else if ( spammed ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
405 |
spamDiff = -1; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
406 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
407 |
// you can't trash an item on the trash screen |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
408 |
trashDiff = 1; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
409 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
410 |
// user clicked "Restore" |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
411 |
} else if ( targetParent.is( 'span.untrash' ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
412 |
if ( approved ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
413 |
pendingDiff = 1; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
414 |
} else if ( unapproved ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
415 |
approvedDiff = 1; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
416 |
} else if ( trashed ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
417 |
if ( targetParent.hasClass( 'approve' ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
418 |
approvedDiff = 1; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
419 |
} else if ( targetParent.hasClass( 'unapprove' ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
420 |
pendingDiff = 1; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
421 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
422 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
423 |
// you can't go from trash to spam |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
424 |
// you can untrash on the trash screen |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
425 |
trashDiff = -1; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
426 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
427 |
// User clicked "Approve" |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
428 |
} else if ( targetParent.is( 'span.approve:not(.unspam):not(.untrash)' ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
429 |
approvedDiff = 1; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
430 |
pendingDiff = -1; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
431 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
432 |
// User clicked "Unapprove" |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
433 |
} else if ( targetParent.is( 'span.unapprove:not(.unspam):not(.untrash)' ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
434 |
approvedDiff = -1; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
435 |
pendingDiff = 1; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
436 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
437 |
// User clicked "Delete Permanently" |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
438 |
} else if ( targetParent.is( 'span.delete' ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
439 |
if ( spammed ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
440 |
spamDiff = -1; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
441 |
} else if ( trashed ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
442 |
trashDiff = -1; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
443 |
} |
0 | 444 |
} |
445 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
446 |
if ( pendingDiff ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
447 |
updatePending( pendingDiff, commentPostId ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
448 |
updateCountText( 'span.all-count', pendingDiff ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
449 |
} |
0 | 450 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
451 |
if ( approvedDiff ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
452 |
updateApproved( approvedDiff, commentPostId ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
453 |
updateCountText( 'span.all-count', approvedDiff ); |
0 | 454 |
} |
455 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
456 |
if ( spamDiff ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
457 |
updateCountText( 'span.spam-count', spamDiff ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
458 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
459 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
460 |
if ( trashDiff ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
461 |
updateCountText( 'span.trash-count', trashDiff ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
462 |
} |
0 | 463 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
464 |
if ( |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
465 |
( ( 'trash' === settings.data.comment_status ) && !getCount( $( 'span.trash-count' ) ) ) || |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
466 |
( ( 'spam' === settings.data.comment_status ) && !getCount( $( 'span.spam-count' ) ) ) |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
467 |
) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
468 |
$( '#delete_all' ).hide(); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
469 |
} |
0 | 470 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
471 |
if ( ! isDashboard ) { |
0 | 472 |
total = totalInput.val() ? parseInt( totalInput.val(), 10 ) : 0; |
473 |
if ( $(settings.target).parent().is('span.undo') ) |
|
474 |
total++; |
|
475 |
else |
|
476 |
total--; |
|
477 |
||
478 |
if ( total < 0 ) |
|
479 |
total = 0; |
|
480 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
481 |
if ( 'object' === typeof r ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
482 |
if ( response.supplemental.total_items_i18n && lastConfidentTime < response.supplemental.time ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
483 |
total_items_i18n = response.supplemental.total_items_i18n || ''; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
484 |
if ( total_items_i18n ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
485 |
$('.displaying-num').text( total_items_i18n ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
486 |
$('.total-pages').text( response.supplemental.total_pages_i18n ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
487 |
$('.tablenav-pages').find('.next-page, .last-page').toggleClass('disabled', response.supplemental.total_pages == $('.current-page').val()); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
488 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
489 |
updateTotalCount( total, response.supplemental.time, true ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
490 |
} else if ( response.supplemental.time ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
491 |
updateTotalCount( total, response.supplemental.time, false ); |
0 | 492 |
} |
493 |
} else { |
|
494 |
updateTotalCount( total, r, false ); |
|
495 |
} |
|
496 |
} |
|
497 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
498 |
if ( ! theExtraList || theExtraList.length === 0 || theExtraList.children().length === 0 || undoing ) { |
0 | 499 |
return; |
500 |
} |
|
501 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
502 |
theList.get(0).wpList.add( theExtraList.children( ':eq(0):not(.no-items)' ).remove().clone() ); |
0 | 503 |
|
504 |
refillTheExtraList(); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
505 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
506 |
animated = $( ':animated', '#the-comment-list' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
507 |
animatedCallback = function () { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
508 |
if ( ! $( '#the-comment-list tr:visible' ).length ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
509 |
theList.get(0).wpList.add( theExtraList.find( '.no-items' ).clone() ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
510 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
511 |
}; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
512 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
513 |
if ( animated.length ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
514 |
animated.promise().done( animatedCallback ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
515 |
} else { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
516 |
animatedCallback(); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
517 |
} |
0 | 518 |
}; |
519 |
||
520 |
refillTheExtraList = function(ev) { |
|
521 |
var args = $.query.get(), total_pages = $('.total-pages').text(), per_page = $('input[name="_per_page"]', '#comments-form').val(); |
|
522 |
||
523 |
if (! args.paged) |
|
524 |
args.paged = 1; |
|
525 |
||
526 |
if (args.paged > total_pages) { |
|
527 |
return; |
|
528 |
} |
|
529 |
||
530 |
if (ev) { |
|
531 |
theExtraList.empty(); |
|
532 |
args.number = Math.min(8, per_page); // see WP_Comments_List_Table::prepare_items() @ class-wp-comments-list-table.php |
|
533 |
} else { |
|
534 |
args.number = 1; |
|
535 |
args.offset = Math.min(8, per_page) - 1; // fetch only the next item on the extra list |
|
536 |
} |
|
537 |
||
538 |
args.no_placeholder = true; |
|
539 |
||
540 |
args.paged ++; |
|
541 |
||
542 |
// $.query.get() needs some correction to be sent into an ajax request |
|
543 |
if ( true === args.comment_type ) |
|
544 |
args.comment_type = ''; |
|
545 |
||
546 |
args = $.extend(args, { |
|
547 |
'action': 'fetch-list', |
|
548 |
'list_args': list_args, |
|
549 |
'_ajax_fetch_list_nonce': $('#_ajax_fetch_list_nonce').val() |
|
550 |
}); |
|
551 |
||
552 |
$.ajax({ |
|
553 |
url: ajaxurl, |
|
554 |
global: false, |
|
555 |
dataType: 'json', |
|
556 |
data: args, |
|
557 |
success: function(response) { |
|
558 |
theExtraList.get(0).wpList.add( response.rows ); |
|
559 |
} |
|
560 |
}); |
|
561 |
}; |
|
562 |
||
563 |
theExtraList = $('#the-extra-comment-list').wpList( { alt: '', delColor: 'none', addColor: 'none' } ); |
|
564 |
theList = $('#the-comment-list').wpList( { alt: '', delBefore: delBefore, dimAfter: dimAfter, delAfter: delAfter, addColor: 'none' } ) |
|
565 |
.bind('wpListDelEnd', function(e, s){ |
|
566 |
var wpListsData = $(s.target).attr('data-wp-lists'), id = s.element.replace(/[^0-9]+/g, ''); |
|
567 |
||
568 |
if ( wpListsData.indexOf(':trash=1') != -1 || wpListsData.indexOf(':spam=1') != -1 ) |
|
5 | 569 |
$('#undo-' + id).fadeIn(300, function(){ $(this).show(); }); |
0 | 570 |
}); |
571 |
}; |
|
572 |
||
573 |
commentReply = { |
|
574 |
cid : '', |
|
575 |
act : '', |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
576 |
originalContent : '', |
0 | 577 |
|
578 |
init : function() { |
|
579 |
var row = $('#replyrow'); |
|
580 |
||
581 |
$('a.cancel', row).click(function() { return commentReply.revert(); }); |
|
582 |
$('a.save', row).click(function() { return commentReply.send(); }); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
583 |
$( 'input#author-name, input#author-email, input#author-url', row ).keypress( function( e ) { |
0 | 584 |
if ( e.which == 13 ) { |
585 |
commentReply.send(); |
|
586 |
e.preventDefault(); |
|
587 |
return false; |
|
588 |
} |
|
589 |
}); |
|
590 |
||
591 |
// add events |
|
592 |
$('#the-comment-list .column-comment > p').dblclick(function(){ |
|
593 |
commentReply.toggle($(this).parent()); |
|
594 |
}); |
|
595 |
||
5 | 596 |
$('#doaction, #doaction2, #post-query-submit').click(function(){ |
0 | 597 |
if ( $('#the-comment-list #replyrow').length > 0 ) |
598 |
commentReply.close(); |
|
599 |
}); |
|
600 |
||
601 |
this.comments_listing = $('#comments-form > input[name="comment_status"]').val() || ''; |
|
602 |
||
603 |
/* $(listTable).bind('beforeChangePage', function(){ |
|
604 |
commentReply.close(); |
|
605 |
}); */ |
|
606 |
}, |
|
607 |
||
608 |
addEvents : function(r) { |
|
609 |
r.each(function() { |
|
610 |
$(this).find('.column-comment > p').dblclick(function(){ |
|
611 |
commentReply.toggle($(this).parent()); |
|
612 |
}); |
|
613 |
}); |
|
614 |
}, |
|
615 |
||
616 |
toggle : function(el) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
617 |
if ( 'none' !== $( el ).css( 'display' ) && ( $( '#replyrow' ).parent().is('#com-reply') || window.confirm( adminCommentsL10n.warnQuickEdit ) ) ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
618 |
$( el ).find( 'a.vim-q' ).click(); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
619 |
} |
0 | 620 |
}, |
621 |
||
622 |
revert : function() { |
|
623 |
||
624 |
if ( $('#the-comment-list #replyrow').length < 1 ) |
|
625 |
return false; |
|
626 |
||
627 |
$('#replyrow').fadeOut('fast', function(){ |
|
628 |
commentReply.close(); |
|
629 |
}); |
|
630 |
||
631 |
return false; |
|
632 |
}, |
|
633 |
||
634 |
close : function() { |
|
635 |
var c, replyrow = $('#replyrow'); |
|
636 |
||
637 |
// replyrow is not showing? |
|
638 |
if ( replyrow.parent().is('#com-reply') ) |
|
639 |
return; |
|
640 |
||
641 |
if ( this.cid && this.act == 'edit-comment' ) { |
|
642 |
c = $('#comment-' + this.cid); |
|
5 | 643 |
c.fadeIn(300, function(){ c.show(); }).css('backgroundColor', ''); |
0 | 644 |
} |
645 |
||
646 |
// reset the Quicktags buttons |
|
647 |
if ( typeof QTags != 'undefined' ) |
|
648 |
QTags.closeAllTags('replycontent'); |
|
649 |
||
650 |
$('#add-new-comment').css('display', ''); |
|
651 |
||
652 |
replyrow.hide(); |
|
653 |
$('#com-reply').append( replyrow ); |
|
654 |
$('#replycontent').css('height', '').val(''); |
|
655 |
$('#edithead input').val(''); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
656 |
$( '.notice-error', replyrow ) |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
657 |
.addClass( 'hidden' ) |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
658 |
.find( '.error' ).empty(); |
5 | 659 |
$( '.spinner', replyrow ).removeClass( 'is-active' ); |
0 | 660 |
|
661 |
this.cid = ''; |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
662 |
this.originalContent = ''; |
0 | 663 |
}, |
664 |
||
665 |
open : function(comment_id, post_id, action) { |
|
5 | 666 |
var editRow, rowData, act, replyButton, editHeight, |
667 |
t = this, |
|
668 |
c = $('#comment-' + comment_id), |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
669 |
h = c.height(), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
670 |
colspanVal = 0; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
671 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
672 |
if ( ! this.discardCommentChanges() ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
673 |
return false; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
674 |
} |
0 | 675 |
|
676 |
t.close(); |
|
677 |
t.cid = comment_id; |
|
678 |
||
679 |
editRow = $('#replyrow'); |
|
680 |
rowData = $('#inline-'+comment_id); |
|
681 |
action = action || 'replyto'; |
|
682 |
act = 'edit' == action ? 'edit' : 'replyto'; |
|
683 |
act = t.act = act + '-comment'; |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
684 |
t.originalContent = $('textarea.comment', rowData).val(); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
685 |
colspanVal = $( '> th:visible, > td:visible', c ).length; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
686 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
687 |
// Make sure it's actually a table and there's a `colspan` value to apply. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
688 |
if ( editRow.hasClass( 'inline-edit-row' ) && 0 !== colspanVal ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
689 |
$( 'td', editRow ).attr( 'colspan', colspanVal ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
690 |
} |
0 | 691 |
|
692 |
$('#action', editRow).val(act); |
|
693 |
$('#comment_post_ID', editRow).val(post_id); |
|
694 |
$('#comment_ID', editRow).val(comment_id); |
|
695 |
||
696 |
if ( action == 'edit' ) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
697 |
$( '#author-name', editRow ).val( $( 'div.author', rowData ).text() ); |
0 | 698 |
$('#author-email', editRow).val( $('div.author-email', rowData).text() ); |
699 |
$('#author-url', editRow).val( $('div.author-url', rowData).text() ); |
|
700 |
$('#status', editRow).val( $('div.comment_status', rowData).text() ); |
|
701 |
$('#replycontent', editRow).val( $('textarea.comment', rowData).val() ); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
702 |
$( '#edithead, #editlegend, #savebtn', editRow ).show(); |
0 | 703 |
$('#replyhead, #replybtn, #addhead, #addbtn', editRow).hide(); |
704 |
||
5 | 705 |
if ( h > 120 ) { |
706 |
// Limit the maximum height when editing very long comments to make it more manageable. |
|
707 |
// The textarea is resizable in most browsers, so the user can adjust it if needed. |
|
708 |
editHeight = h > 500 ? 500 : h; |
|
709 |
$('#replycontent', editRow).css('height', editHeight + 'px'); |
|
710 |
} |
|
711 |
||
0 | 712 |
c.after( editRow ).fadeOut('fast', function(){ |
5 | 713 |
$('#replyrow').fadeIn(300, function(){ $(this).show(); }); |
0 | 714 |
}); |
715 |
} else if ( action == 'add' ) { |
|
716 |
$('#addhead, #addbtn', editRow).show(); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
717 |
$( '#replyhead, #replybtn, #edithead, #editlegend, #savebtn', editRow ) .hide(); |
0 | 718 |
$('#the-comment-list').prepend(editRow); |
719 |
$('#replyrow').fadeIn(300); |
|
5 | 720 |
} else { |
721 |
replyButton = $('#replybtn', editRow); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
722 |
$( '#edithead, #editlegend, #savebtn, #addhead, #addbtn', editRow ).hide(); |
0 | 723 |
$('#replyhead, #replybtn', editRow).show(); |
724 |
c.after(editRow); |
|
725 |
||
726 |
if ( c.hasClass('unapproved') ) { |
|
727 |
replyButton.text(adminCommentsL10n.replyApprove); |
|
728 |
} else { |
|
729 |
replyButton.text(adminCommentsL10n.reply); |
|
730 |
} |
|
731 |
||
5 | 732 |
$('#replyrow').fadeIn(300, function(){ $(this).show(); }); |
0 | 733 |
} |
734 |
||
735 |
setTimeout(function() { |
|
736 |
var rtop, rbottom, scrollTop, vp, scrollBottom; |
|
737 |
||
738 |
rtop = $('#replyrow').offset().top; |
|
739 |
rbottom = rtop + $('#replyrow').height(); |
|
740 |
scrollTop = window.pageYOffset || document.documentElement.scrollTop; |
|
5 | 741 |
vp = document.documentElement.clientHeight || window.innerHeight || 0; |
0 | 742 |
scrollBottom = scrollTop + vp; |
743 |
||
744 |
if ( scrollBottom - 20 < rbottom ) |
|
745 |
window.scroll(0, rbottom - vp + 35); |
|
746 |
else if ( rtop - 20 < scrollTop ) |
|
747 |
window.scroll(0, rtop - 35); |
|
748 |
||
749 |
$('#replycontent').focus().keyup(function(e){ |
|
750 |
if ( e.which == 27 ) |
|
751 |
commentReply.revert(); // close on Escape |
|
752 |
}); |
|
753 |
}, 600); |
|
754 |
||
755 |
return false; |
|
756 |
}, |
|
757 |
||
758 |
send : function() { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
759 |
var post = {}, |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
760 |
$errorNotice = $( '#replysubmit .error-notice' ); |
0 | 761 |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
762 |
$errorNotice.addClass( 'hidden' ); |
5 | 763 |
$( '#replysubmit .spinner' ).addClass( 'is-active' ); |
0 | 764 |
|
765 |
$('#replyrow input').not(':button').each(function() { |
|
766 |
var t = $(this); |
|
767 |
post[ t.attr('name') ] = t.val(); |
|
768 |
}); |
|
769 |
||
770 |
post.content = $('#replycontent').val(); |
|
771 |
post.id = post.comment_post_ID; |
|
772 |
post.comments_listing = this.comments_listing; |
|
773 |
post.p = $('[name="p"]').val(); |
|
774 |
||
775 |
if ( $('#comment-' + $('#comment_ID').val()).hasClass('unapproved') ) |
|
776 |
post.approve_parent = 1; |
|
777 |
||
778 |
$.ajax({ |
|
779 |
type : 'POST', |
|
780 |
url : ajaxurl, |
|
781 |
data : post, |
|
782 |
success : function(x) { commentReply.show(x); }, |
|
783 |
error : function(r) { commentReply.error(r); } |
|
784 |
}); |
|
785 |
||
786 |
return false; |
|
787 |
}, |
|
788 |
||
789 |
show : function(xml) { |
|
790 |
var t = this, r, c, id, bg, pid; |
|
791 |
||
792 |
if ( typeof(xml) == 'string' ) { |
|
793 |
t.error({'responseText': xml}); |
|
794 |
return false; |
|
795 |
} |
|
796 |
||
797 |
r = wpAjax.parseAjaxResponse(xml); |
|
798 |
if ( r.errors ) { |
|
799 |
t.error({'responseText': wpAjax.broken}); |
|
800 |
return false; |
|
801 |
} |
|
802 |
||
803 |
t.revert(); |
|
804 |
||
805 |
r = r.responses[0]; |
|
806 |
id = '#comment-' + r.id; |
|
807 |
||
808 |
if ( 'edit-comment' == t.act ) |
|
809 |
$(id).remove(); |
|
810 |
||
811 |
if ( r.supplemental.parent_approved ) { |
|
812 |
pid = $('#comment-' + r.supplemental.parent_approved); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
813 |
updatePending( -1, r.supplemental.parent_post_id ); |
0 | 814 |
|
815 |
if ( this.comments_listing == 'moderated' ) { |
|
816 |
pid.animate( { 'backgroundColor':'#CCEEBB' }, 400, function(){ |
|
817 |
pid.fadeOut(); |
|
818 |
}); |
|
819 |
return; |
|
820 |
} |
|
821 |
} |
|
822 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
823 |
if ( r.supplemental.i18n_comments_text ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
824 |
if ( isDashboard ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
825 |
updateDashboardText( r.supplemental ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
826 |
} else { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
827 |
updateApproved( 1, r.supplemental.parent_post_id ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
828 |
updateCountText( 'span.all-count', 1 ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
829 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
830 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
831 |
|
0 | 832 |
c = $.trim(r.data); // Trim leading whitespaces |
5 | 833 |
$(c).hide(); |
0 | 834 |
$('#replyrow').after(c); |
835 |
||
836 |
id = $(id); |
|
837 |
t.addEvents(id); |
|
838 |
bg = id.hasClass('unapproved') ? '#FFFFE0' : id.closest('.widefat, .postbox').css('backgroundColor'); |
|
839 |
||
840 |
id.animate( { 'backgroundColor':'#CCEEBB' }, 300 ) |
|
841 |
.animate( { 'backgroundColor': bg }, 300, function() { |
|
842 |
if ( pid && pid.length ) { |
|
843 |
pid.animate( { 'backgroundColor':'#CCEEBB' }, 300 ) |
|
844 |
.animate( { 'backgroundColor': bg }, 300 ) |
|
845 |
.removeClass('unapproved').addClass('approved') |
|
846 |
.find('div.comment_status').html('1'); |
|
847 |
} |
|
848 |
}); |
|
849 |
||
850 |
}, |
|
851 |
||
852 |
error : function(r) { |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
853 |
var er = r.statusText, |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
854 |
$errorNotice = $( '#replysubmit .notice-error' ), |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
855 |
$error = $errorNotice.find( '.error' ); |
0 | 856 |
|
5 | 857 |
$( '#replysubmit .spinner' ).removeClass( 'is-active' ); |
0 | 858 |
|
859 |
if ( r.responseText ) |
|
860 |
er = r.responseText.replace( /<.[^<>]*?>/g, '' ); |
|
861 |
||
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
862 |
if ( er ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
863 |
$errorNotice.removeClass( 'hidden' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
864 |
$error.html( er ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
865 |
} |
0 | 866 |
}, |
867 |
||
868 |
addcomment: function(post_id) { |
|
869 |
var t = this; |
|
870 |
||
871 |
$('#add-new-comment').fadeOut(200, function(){ |
|
872 |
t.open(0, post_id, 'add'); |
|
873 |
$('table.comments-box').css('display', ''); |
|
874 |
$('#no-comments').remove(); |
|
875 |
}); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
876 |
}, |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
877 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
878 |
/** |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
879 |
* Alert the user if they have unsaved changes on a comment that will be |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
880 |
* lost if they proceed. |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
881 |
* |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
882 |
* @returns {boolean} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
883 |
*/ |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
884 |
discardCommentChanges: function() { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
885 |
var editRow = $( '#replyrow' ); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
886 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
887 |
if ( this.originalContent === $( '#replycontent', editRow ).val() ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
888 |
return true; |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
889 |
} |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
890 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
891 |
return window.confirm( adminCommentsL10n.warnCommentChanges ); |
0 | 892 |
} |
893 |
}; |
|
894 |
||
895 |
$(document).ready(function(){ |
|
896 |
var make_hotkeys_redirect, edit_comment, toggle_all, make_bulk; |
|
897 |
||
898 |
setCommentsList(); |
|
899 |
commentReply.init(); |
|
7
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
900 |
|
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
901 |
$(document).on( 'click', 'span.delete a.delete', function( e ) { |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
902 |
e.preventDefault(); |
cf61fcea0001
resynchronize code repo with production
ymh <ymh.work@gmail.com>
parents:
5
diff
changeset
|
903 |
}); |
0 | 904 |
|
905 |
if ( typeof $.table_hotkeys != 'undefined' ) { |
|
906 |
make_hotkeys_redirect = function(which) { |
|
907 |
return function() { |
|
908 |
var first_last, l; |
|
909 |
||
910 |
first_last = 'next' == which? 'first' : 'last'; |
|
911 |
l = $('.tablenav-pages .'+which+'-page:not(.disabled)'); |
|
912 |
if (l.length) |
|
913 |
window.location = l[0].href.replace(/\&hotkeys_highlight_(first|last)=1/g, '')+'&hotkeys_highlight_'+first_last+'=1'; |
|
5 | 914 |
}; |
0 | 915 |
}; |
916 |
||
917 |
edit_comment = function(event, current_row) { |
|
918 |
window.location = $('span.edit a', current_row).attr('href'); |
|
919 |
}; |
|
920 |
||
921 |
toggle_all = function() { |
|
5 | 922 |
$('#cb-select-all-1').data( 'wp-toggle', 1 ).trigger( 'click' ).removeData( 'wp-toggle' ); |
0 | 923 |
}; |
924 |
||
925 |
make_bulk = function(value) { |
|
926 |
return function() { |
|
927 |
var scope = $('select[name="action"]'); |
|
928 |
$('option[value="' + value + '"]', scope).prop('selected', true); |
|
929 |
$('#doaction').click(); |
|
5 | 930 |
}; |
0 | 931 |
}; |
932 |
||
933 |
$.table_hotkeys( |
|
934 |
$('table.widefat'), |
|
5 | 935 |
[ |
936 |
'a', 'u', 's', 'd', 'r', 'q', 'z', |
|
937 |
['e', edit_comment], |
|
938 |
['shift+x', toggle_all], |
|
939 |
['shift+a', make_bulk('approve')], |
|
940 |
['shift+s', make_bulk('spam')], |
|
941 |
['shift+d', make_bulk('delete')], |
|
942 |
['shift+t', make_bulk('trash')], |
|
943 |
['shift+z', make_bulk('untrash')], |
|
944 |
['shift+u', make_bulk('unapprove')] |
|
945 |
], |
|
946 |
{ |
|
947 |
highlight_first: adminCommentsL10n.hotkeys_highlight_first, |
|
948 |
highlight_last: adminCommentsL10n.hotkeys_highlight_last, |
|
949 |
prev_page_link_cb: make_hotkeys_redirect('prev'), |
|
950 |
next_page_link_cb: make_hotkeys_redirect('next'), |
|
951 |
hotkeys_opts: { |
|
952 |
disableInInput: true, |
|
953 |
type: 'keypress', |
|
954 |
noDisable: '.check-column input[type="checkbox"]' |
|
955 |
}, |
|
956 |
cycle_expr: '#the-comment-list tr', |
|
957 |
start_row_index: 0 |
|
958 |
} |
|
0 | 959 |
); |
960 |
} |
|
5 | 961 |
|
962 |
// Quick Edit and Reply have an inline comment editor. |
|
963 |
$( '#the-comment-list' ).on( 'click', '.comment-inline', function (e) { |
|
964 |
e.preventDefault(); |
|
965 |
var $el = $( this ), |
|
966 |
action = 'replyto'; |
|
967 |
||
968 |
if ( 'undefined' !== typeof $el.data( 'action' ) ) { |
|
969 |
action = $el.data( 'action' ); |
|
970 |
} |
|
971 |
||
972 |
commentReply.open( $el.data( 'commentId' ), $el.data( 'postId' ), action ); |
|
973 |
} ); |
|
0 | 974 |
}); |
975 |
||
976 |
})(jQuery); |