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