PluginProbe
MainWP Dashboard: Self-hosted WordPress Management for Agencies / 6.2.2
MainWP Dashboard: Self-hosted WordPress Management for Agencies v6.2.2
6.2.2 6.2.1 6.2 6.1.8 6.1.7 6.1.6 6.1.5 6.1.4 6.1.3 6.1.2 6.1.1 6.1 6.0.12 6.0.11 4.6.0.1 5.0 5.0.1 5.0.2 5.0.3 5.0.3.1 5.0.3.2 5.1 5.1.1 5.2 5.2.1 All 155 releases
← All changes | assets/js/mainwp-post-edit.js +29 -30 4.6.0.1 → 6.2.2 View file →
@@ -7,18 +7,20 @@
7 7
8 8 // Make sure the wp object exists.
9 9 window.wp = window.wp || {};
10 10
11 -mainwp_post_newmeta_submit = function (action, me) {
11 +let mainwp_post_newmeta_submit = function (action, me) {
12 12
13 13 if (action != 'add' && action != 'delete' && action != 'update')
14 14 return false;
15 15
16 - var data;
16 + let data;
17 + let newkey;
17 18
18 19 if (action == 'add') {
19 20
20 - var metakey = jQuery('#metakeyselect').val(), newkey = false;
21 + let metakey = jQuery('#metakeyselect').val();
22 + newkey = false;
21 23 if (jQuery('#metakeyinput').is(':visible')) {
22 24 metakey = '#NONE#';
23 25 newkey = true;
24 26 }
@@ -32,10 +34,10 @@
32 34 });
33 35
34 36 } else {
35 37
36 - var row = jQuery(me).closest('.row');
37 - var metaid = row.attr('meta-id');
38 + let row = jQuery(me).closest('.row');
39 + let metaid = row.attr('meta-id');
38 40
39 41 if ((row.length == 0) || !metaid)
40 42 return false;
41 43
@@ -85,10 +87,10 @@
85 87
86 88 /**
87 89 * All post and postbox controls and functionality.
88 90 */
89 -jQuery(document).ready(function ($) {
90 - var updateText,
91 +jQuery(function ($) {
92 + let updateText,
91 93 $textarea = $('#content'),
92 94 $document = $(document),
93 95 $timestampdiv = $('#timestampdiv');
94 96
@@ -136,9 +138,9 @@
136 138
137 139 if (!$timestampdiv.length)
138 140 return true;
139 141
140 - var attemptedDate,
142 + let attemptedDate,
141 143 aa = $('#aa').val(),
142 144 mm = $('#mm').val(), jj = $('#jj').val(), hh = $('#hh').val(), mn = $('#mn').val();
143 145
144 146 attemptedDate = new Date(aa, mm - 1, jj, hh, mn);
@@ -156,11 +158,10 @@
156 158 // init post datetime calendar
157 159 jQuery('#schedule_post_datetime').calendar({
158 160 type: 'datetime',
159 161 initialDate: function () {
160 - var aa = $('#aa').val(), mm = $('#mm').val(), jj = $('#jj').val(), hh = $('#hh').val(), mn = $('#mn').val();
161 - var ind = new Date(aa, mm - 1, jj, hh, mn);
162 - console.log(ind);
162 + let aa = $('#aa').val(), mm = $('#mm').val(), jj = $('#jj').val(), hh = $('#hh').val(), mn = $('#mn').val();
163 + let ind = new Date(aa, mm - 1, jj, hh, mn);
163 164 return ind;
164 165 }(),
165 166 monthFirst: false,
166 167 formatter: {
@@ -165,17 +166,16 @@
165 166 monthFirst: false,
166 167 formatter: {
167 168 date: function (date) {
168 169 if (!date) return '';
169 - var jj = date.getDate();
170 - var mm = date.getMonth() + 1;
171 - var aa = date.getFullYear();
170 + let jj = date.getDate();
171 + let mm = date.getMonth() + 1;
172 + let aa = date.getFullYear();
172 173 return aa + '-' + mm + '-' + jj;
173 174 }
174 175 },
175 176 onChange: function (attemptedDate, textDate) {
176 - console.log('onChange:' + textDate);
177 - var aa = attemptedDate.getFullYear(), mm = attemptedDate.getMonth() + 1, jj = attemptedDate.getDate(), mn = attemptedDate.getMinutes(), hh = attemptedDate.getHours();
177 + let aa = attemptedDate.getFullYear(), mm = attemptedDate.getMonth() + 1, jj = attemptedDate.getDate(), mn = attemptedDate.getMinutes(), hh = attemptedDate.getHours();
178 178 mm = ('0' + mm).slice(-2); // to format 01,02,03, ... 11,12
179 179 $('#aa').val(aa);
180 180 $('#mm').val(mm).trigger("change"); // selector element
181 181 $('#jj').val(jj);
@@ -183,10 +183,9 @@
183 183 $('#mn').val(mn);
184 184 return updateText(); // not set if invalid date
185 185 },
186 186 onSelect: function (attemptedDate, mode) {
187 - console.log('onSelect mode:' + mode);
188 - var aa = attemptedDate.getFullYear(), mm = attemptedDate.getMonth() + 1, jj = attemptedDate.getDate(), mn = attemptedDate.getMinutes(), hh = attemptedDate.getHours();
187 + let aa = attemptedDate.getFullYear(), mm = attemptedDate.getMonth() + 1, jj = attemptedDate.getDate(), mn = attemptedDate.getMinutes(), hh = attemptedDate.getHours();
189 188 mm = ('0' + mm).slice(-2); // to format 01,02,03, ... 11,12
190 189 $('#aa').val(aa);
191 190 $('#mm').val(mm).trigger("change"); // selector element
192 191 $('#jj').val(jj);
@@ -204,9 +203,9 @@
204 203 // Don't do anything when [tab] is pressed.
205 204 if (e.which != 9)
206 205 return;
207 206
208 - var target = $(e.target);
207 + let target = $(e.target);
209 208
210 209 // [shift] + [tab] on first tab cycles back to last tab.
211 210 if (target.hasClass('wp-tab-first') && e.shiftKey) {
212 211 $(this).find('.wp-tab-last').trigger('focus');
@@ -219,9 +218,9 @@
219 218 }).filter(':visible').find('.wp-tab-first').trigger('focus');
220 219
221 220 // This code is meant to allow tabbing from Title to Post content.
222 221 $('#title').on('keydown.editor-focus', function (event) {
223 - var editor;
222 + let editor;
224 223
225 224 if (event.keyCode === 9 && !event.ctrlKey && !event.altKey && !event.shiftKey) {
226 225 editor = typeof tinymce != 'undefined' && tinymce.get('content');
227 226
@@ -241,9 +240,9 @@
241 240
242 241
243 242 // Resize the WYSIWYG and plain text editors.
244 243 (function () {
245 - var editor, offset, mce,
244 + let editor, offset, mce,
246 245 $handle = $('#post-status-info'),
247 246 $postdivrich = $('#postdivrich');
248 247
249 248 // If there are no textareas or we are on a touch device, we can't do anything.
@@ -275,9 +274,9 @@
275 274 /**
276 275 * When the dragging stopped make sure we return focus and do a sanity check on the height.
277 276 */
278 277 function endDrag() {
279 - var height, toolbarHeight;
278 + let height, toolbarHeight;
280 279
281 280 if ($postdivrich.hasClass('wp-editor-expand')) {
282 281 return;
283 282 }
@@ -283,18 +282,18 @@
283 282 }
284 283
285 284 if (mce) {
286 285 editor.focus();
287 - toolbarHeight = parseInt($('#wp-content-editor-container .mce-toolbar-grp').height(), 10);
286 + toolbarHeight = Number.parseInt($('#wp-content-editor-container .mce-toolbar-grp').height(), 10);
288 287
289 288 if (toolbarHeight < 10 || toolbarHeight > 200) {
290 289 toolbarHeight = 30;
291 290 }
292 291
293 - height = parseInt($('#content_ifr').css('height'), 10) + toolbarHeight - 28;
292 + height = Number.parseInt($('#content_ifr').css('height'), 10) + toolbarHeight - 28;
294 293 } else {
295 294 $textarea.trigger('focus');
296 - height = parseInt($textarea.css('height'), 10);
295 + height = Number.parseInt($textarea.css('height'), 10);
297 296 }
298 297
299 298 $document.off('.wp-editor-resize');
300 299
@@ -328,9 +327,9 @@
328 327 // TinyMCE specific handling of Post Format changes to reflect in the editor.
329 328 if (typeof tinymce !== 'undefined') {
330 329 // When changing post formats, change the editor body class.
331 330 $('#post-formats-select input.post-format').on('change.set-editor-class', function () {
332 - var editor, body, format = this.id;
331 + let editor, body, format = this.id;
333 332
334 333 if (format && $(this).prop('checked') && (editor = tinymce.get('content'))) {
335 334 body = editor.getBody();
336 335 body.className = body.className.replace(/\bpost-format-[^ ]+/, '');
@@ -340,11 +339,11 @@
340 339 });
341 340
342 341 // When changing page template, change the editor body class
343 342 $('#page_template').on('change.set-editor-class', function () {
344 - var editor, body, pageTemplate = $(this).val() || '';
343 + let editor, body, pageTemplate = $(this).val() || '';
345 344
346 - pageTemplate = pageTemplate.substr(pageTemplate.lastIndexOf('/') + 1, pageTemplate.length)
345 + pageTemplate = pageTemplate.substring(pageTemplate.lastIndexOf('/') + 1)
347 346 .replace(/\.php$/, '')
348 347 .replace(/\./g, '-');
349 348
350 349 if (pageTemplate && (editor = tinymce.get('content'))) {
@@ -363,9 +362,9 @@
363 362 * TinyMCE word count display
364 363 */
365 364 (function ($, counter) {
366 365 $(function () {
367 - var $content = $('#content'),
366 + let $content = $('#content'),
368 367 $count = $('#wp-word-count').find('.word-count'),
369 368 prevCount = 0,
370 369 contentEditor;
371 370
@@ -372,9 +371,9 @@
372 371 /**
373 372 * Get the word count from TinyMCE and display it
374 373 */
375 374 function update() {
376 - var text, count;
375 + let text, count;
377 376
378 377 if (!contentEditor || contentEditor.isHidden()) {
379 378 text = $content.val();
380 379 } else {