PluginProbe
Jetpack – WP Security, Backup, Speed, & Growth / 16.3-a.7
Jetpack – WP Security, Backup, Speed, & Growth v16.3-a.7
16.3-a.5 16.3-a.7 16.3-a.3 16.3-a.1 16.2 16.2-beta 12.0.3 12.1.3 12.2.3 12.3.2 12.4.2 12.5.2 12.6.4 12.7.3 12.8.3 12.9.5 13.0.2 13.1.5 13.2.4 13.3.3 13.4.5 13.5.2 13.6.2 13.7.2 13.8.3 All 506 releases
jetpack / modules / custom-post-types / js / nova-drag-drop.js

nova-drag-drop.js in Jetpack – WP Security, Backup, Speed, & Growth 16.3-a.7, at modules/custom-post-types/js/nova-drag-drop.js

67 lines 1.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 /* global _novaDragDrop */
2
3 ( function ( $ ) {
4 var list;
5
6 function init() {
7 list = $( '#the-list' );
8 dragMenus();
9 addNonce();
10 addSubmitButton();
11 changeToPost();
12 }
13
14 function dragMenus() {
15 list.sortable( {
16 cancel: '.no-items, .inline-edit-row',
17 stop: function ( event, ui ) {
18 if ( ui.item.is( ':first-child' ) ) {
19 return list.sortable( 'cancel' );
20 }
21 //
22 reOrder();
23 },
24 } );
25 }
26
27 function reOrder() {
28 list.find( '.menu-label-row' ).each( function () {
29 var term_id = $( this ).data( 'term_id' );
30 $( this )
31 .nextUntil( '.menu-label-row' )
32 .each( function ( i ) {
33 var row = $( this );
34 row.find( '.menu-order-value' ).val( i );
35 row.find( '.nova-menu-term' ).val( term_id );
36 } );
37 } );
38 }
39
40 function addSubmitButton() {
41 $( '.tablenav' ).prepend(
42 '<input type="submit" class="button-primary button-reorder alignright" value="' +
43 _novaDragDrop.reorder +
44 '" name="' +
45 _novaDragDrop.reorderName +
46 '" />'
47 );
48 }
49
50 function addNonce() {
51 $( '#posts-filter' ).append(
52 '<input type="hidden" name="' +
53 _novaDragDrop.nonceName +
54 '" value="' +
55 _novaDragDrop.nonce +
56 '" />'
57 );
58 }
59
60 function changeToPost() {
61 $( '#posts-filter' ).attr( 'method', 'post' );
62 }
63
64 // do it
65 $( document ).ready( init );
66 } )( jQuery );
67