Changeset 45558
- Timestamp:
- 06/20/2019 02:44:30 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/js/_enqueues/admin/edit-comments.js
r45553 r45558 1 1 /** 2 3 4 5 2 6 * @output wp-admin/js/edit-comments.js 3 7 */ … … 12 16 titleDiv, titleRegEx; 13 17 18 19 20 21 22 23 24 25 26 27 14 28 getCount = function(el) { 15 29 var n = parseInt( el.html().replace(/[^0-9]+/g, ''), 10 ); … … 20 34 }; 21 35 36 37 38 39 40 41 42 43 44 45 46 22 47 updateCount = function(el, n) { 23 48 var n1 = ''; … … 36 61 }; 37 62 63 64 65 66 67 68 69 70 71 72 73 38 74 updateApproved = function( diff, commentPostId ) { 39 75 var postSelector = '.post-com-count-' + commentPostId, … … 49 85 } 50 86 51 // cache selectors to not get dupes87 // 52 88 approved = $( 'span.' + approvedClass, postSelector ); 53 89 noComments = $( 'span.' + noClass, postSelector ); … … 77 113 }; 78 114 115 116 117 118 119 120 121 122 123 124 125 126 79 127 updateCountText = function( selector, diff ) { 80 128 $( selector ).each(function() { … … 87 135 }; 88 136 137 138 139 140 141 142 143 144 145 146 147 89 148 updateDashboardText = function( response ) { 90 149 if ( ! isDashboard || ! response || ! response.i18n_comments_text ) { … … 100 159 * @since 5.2.0 101 160 * 102 * @param {object} response Ajax response from the server. 161 * @param {object} response Ajax response from the server that includes a 162 * translated "comments in moderation" message. 103 163 * 104 164 * @return {void} … … 118 178 }; 119 179 180 181 182 183 184 185 186 187 188 189 190 120 191 updateHtmlTitle = function( diff ) { 121 192 var newTitle, regExMatch, titleCount, commentFrag; … … 151 222 }; 152 223 224 225 226 227 228 229 230 231 232 233 234 153 235 updatePending = function( diff, commentPostId ) { 154 236 var postSelector = '.post-com-count-' + commentPostId, … … 207 289 }; 208 290 291 292 293 294 295 296 297 298 299 209 300 window.setCommentsList = function() { 210 301 var totalInput, perPageInput, pageInput, dimAfter, delBefore, updateTotalCount, delAfter, refillTheExtraList, diff, … … 215 306 pageInput = $('input[name="_page"]', '#comments-form'); 216 307 217 // Updates the current total (stored in the _total input) 308 /** 309 * Updates the total with the latest count. 310 * 311 * The time parameter makes sure that we only update the total if this value is 312 * a newer value than we previously received. 313 * 314 * The time and setConfidentTime parameters make sure that we only update the 315 * total when necessary. So a value that has been generated earlier will not 316 * update the total. 317 * 318 * @since 2.8.0 319 * @access private 320 * 321 * @param {number} total Total number of comments. 322 * @param {number} time Unix timestamp of response. 323 * @param {boolean} setConfidentTime Whether to update the last confident time 324 * with the given time. 325 * 326 * @return {void} 327 */ 218 328 updateTotalCount = function( total, time, setConfidentTime ) { 219 329 if ( time < lastConfidentTime ) … … 226 336 }; 227 337 228 // this fires when viewing "All" 338 /** 339 * Changes DOM that need to be changed after a list item has been dimmed. 340 * 341 * @since 2.5.0 342 * @access private 343 * 344 * @param {Object} r Ajax response object. 345 * @param {Object} settings Settings for the wpList object. 346 * 347 * @return {void} 348 */ 229 349 dimAfter = function( r, settings ) { 230 350 var editRow, replyID, replyButton, response, … … 266 386 }; 267 387 268 // Send current total, page, per_page and url 388 /** 389 * Handles marking a comment as spam or trashing the comment. 390 * 391 * Is executed in the list delBefore hook. 392 * 393 * @since 2.8.0 394 * @access private 395 * 396 * @param {Object} settings Settings for the wpList object. 397 * @param {HTMLElement} list Comments table element. 398 * 399 * @return {Object} The settings object. 400 */ 269 401 delBefore = function( settings, list ) { 270 402 var note, id, el, n, h, a, author, … … 325 457 }; 326 458 327 // In admin-ajax.php, we send back the unix time stamp instead of 1 on success 459 /** 460 * Handles actions that need to be done after marking as spam or thrashing a 461 * comment. 462 * 463 * The ajax requests return the unix time stamp a comment was marked as spam or 464 * trashed. We use this to have a correct total amount of comments. 465 * 466 * @since 2.5.0 467 * @access private 468 * 469 * @param {Object} r Ajax response object. 470 * @param {Object} settings Settings for the wpList object. 471 * 472 * @return {void} 473 */ 328 474 delAfter = function( r, settings ) { 329 475 var total_items_i18n, total, animated, animatedCallback, … … 546 692 }; 547 693 694 695 696 697 698 699 700 701 702 703 548 704 refillTheExtraList = function(ev) { 549 705 var args = $.query.get(), total_pages = $('.total-pages').text(), per_page = $('input[name="_per_page"]', '#comments-form').val(); … … 589 745 }; 590 746 747 748 749 750 751 591 752 window.theExtraList = $('#the-extra-comment-list').wpList( { alt: '', delColor: 'none', addColor: 'none' } ); 753 754 755 756 757 758 592 759 window.theList = $('#the-comment-list').wpList( { alt: '', delBefore: delBefore, dimAfter: dimAfter, delAfter: delAfter, addColor: 'none' } ) 593 760 .bind('wpListDelEnd', function(e, s){ … … 599 766 }; 600 767 768 769 770 771 772 773 774 775 601 776 window.commentReply = { 602 777 cid : '', … … 604 779 originalContent : '', 605 780 781 782 783 784 785 786 787 606 788 init : function() { 607 789 var row = $('#replyrow'); … … 630 812 }, 631 813 814 815 816 817 818 819 820 821 822 823 824 825 826 632 827 addEvents : function(r) { 633 828 r.each(function() { … … 638 833 }, 639 834 835 836 837 838 839 840 841 842 843 844 845 640 846 toggle : function(el) { 641 847 if ( 'none' !== $( el ).css( 'display' ) && ( $( '#replyrow' ).parent().is('#com-reply') || window.confirm( adminCommentsL10n.warnQuickEdit ) ) ) { … … 644 850 }, 645 851 852 853 854 855 856 857 858 859 860 646 861 revert : function() { 647 862 … … 654 869 }, 655 870 871 872 873 874 875 876 877 878 879 656 880 close : function() { 657 881 var commentRow = $(), 658 882 replyRow = $( '#replyrow' ); 659 883 660 // replyrow is not showing?884 // 661 885 if ( replyRow.parent().is( '#com-reply' ) ) { 662 886 return; … … 689 913 690 914 // reset the Quicktags buttons 691 if ( typeof QTags != 'undefined' )915 if ( typeof QTags != 'undefined' ) 692 916 QTags.closeAllTags('replycontent'); 693 917 … … 707 931 }, 708 932 933 934 935 936 937 938 939 940 941 942 943 944 945 709 946 open : function(comment_id, post_id, action) { 710 947 var editRow, rowData, act, replyButton, editHeight, … … 800 1037 }, 801 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 802 1048 send : function() { 803 1049 var post = {}, … … 829 1075 }, 830 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 831 1092 show : function(xml) { 832 1093 var t = this, r, c, id, bg, pid; … … 890 1151 }, 891 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 892 1164 error : function(r) { 893 1165 var er = r.statusText, … … 906 1178 }, 907 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 908 1191 addcomment: function(post_id) { 909 1192 var t = this; … … 917 1200 918 1201 /** 919 * Alert the user if they have unsaved changes on a comment that will be 920 * lost if they proceed. 921 * 922 * @returns {boolean} 1202 * Alert the user if they have unsaved changes on a comment that will be lost if 1203 * they proceed with the intended action. 1204 * 1205 * @since 4.6.0 1206 * 1207 * @memberof commentReply 1208 * 1209 * @return {boolean} Whether it is safe the continue with the intended action. 923 1210 */ 924 1211 discardCommentChanges: function() { … … 944 1231 945 1232 if ( typeof $.table_hotkeys != 'undefined' ) { 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 946 1243 make_hotkeys_redirect = function(which) { 947 1244 return function() { … … 955 1252 }; 956 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 957 1265 edit_comment = function(event, current_row) { 958 1266 window.location = $('span.edit a', current_row).attr('href'); 959 1267 }; 960 1268 1269 1270 1271 1272 1273 1274 1275 1276 961 1277 toggle_all = function() { 962 1278 $('#cb-select-all-1').data( 'wp-toggle', 1 ).trigger( 'click' ).removeData( 'wp-toggle' ); 963 1279 }; 964 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 965 1291 make_bulk = function(value) { 966 1292 return function() {
Note: See TracChangeset
for help on using the changeset viewer.