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.6.7.1 7.6.8 7.6.9 7.7.0 7.8.0 7.8.1 7.8.10 7.8.11 7.8.12 7.8.13 7.8.14 7.8.15 7.8.16 7.8.17 7.8.18 7.8.2 7.8.3 7.8.4 7.8.5 7.8.5.1 7.8.6 7.8.7 7.8.8 7.8.9 7.9.0 7.9.1 7.9.10 7.9.11 7.9.2 7.9.3 7.9.4 7.9.5 7.9.6 7.9.7 7.9.8 7.9.9 8.0.0 8.0.1 8.0.2 8.0.3 8.0.4 8.0.5 8.0.6 8.0.7 8.0.8 8.1.0 8.1.1 8.1.2 8.1.3 8.1.4 8.2.0 trunk 1.0.0 1.1.0 1.2.0 1.3.0 1.4.0 1.5.0 1.6.0 1.7.0 1.8.0 1.9.0 2.0.0 2.1.0 2.2.0 2.3.0 2.4.0 2.5.0 2.6.0 2.7.0 2.8.0 2.8.1 2.8.2 2.8.3 2.9.0 3.0.0 3.0.1 3.0.2 3.0.3 3.0.4 3.0.5 3.0.6 3.1.0 3.2.0 3.3.0 3.4.0 3.5.0 3.6.1 3.7.0 3.8.0 3.9.0 3.9.1 3.9.2 4.0.0 4.0.1 4.1.0 4.2.0 4.2.1 4.2.2 4.3.0 4.3.1 4.4.0 4.5.0 4.6.0 4.7.0 4.7.1 4.7.2 4.7.3 4.7.4 4.8.0 4.8.1 4.8.2 4.8.3 4.9.0 4.9.1 4.9.2 4.9.3 5.0.0
admin-site-enhancements / assets / js / content-order-sort.js
admin-site-enhancements / assets / js Last commit date
codemirror 7 months ago datatables 7 months ago admin-menu-organizer.js 7 months ago admin-page.js 7 months ago content-order-sort.js 7 months ago custom-admin-menu.js 7 months ago external-permalinks.js 7 months ago gutenberg-content-duplication.js 7 months ago hide-admin-notices.js 7 months ago jBox.all.min.js 7 months ago jquery.jsticky.mod.js 7 months ago jquery.jsticky.mod.min.js 7 months ago jquery.mjs.nestedSortable.js 7 months ago jquery.ui.touch-punch.min.js 7 months ago js.cookie.min.js 7 months ago list-tables-content-order.js 7 months ago media-replace.js 7 months ago multiple-user-roles.js 7 months ago select2.full.min.js 7 months ago toggle-hidden-menu.js 7 months ago
content-order-sort.js
171 lines
1 (function( $ ) {
2 'use strict';
3
4 $(document).ready( function() {
5 var itemList = $('#item-list'), // Container of item list
6 maxLevel = 6,
7 sort_started = {}, // For data related to the dragged element when dragging started
8 sort_finished = {}; // For data related to the dragged element when dragging has finished
9
10 // console.log(contentOrderSort); // Data passed from PHP via wp_localize_script
11 if (contentOrderSort.hierarchical == 'false') {
12 maxLevel = 1;
13 }
14
15 // Make item list into nested sortable
16 // Ref: https://api.jqueryui.com/sortable/
17 // Ref: https://github.com/ilikenwf/nestedSortable
18 // See options at https://github.com/ilikenwf/nestedSortable/blob/master/jquery.mjs.nestedSortable.js#L37
19 // Ref: https://ilikenwf.github.io/example.html (demo)
20 itemList.nestedSortable({
21 // Disable nesting if set to true
22 protectRoot: false,
23 // Disable moving sub-item to a different parent or up the nested structure
24 disableParentChange: false,
25 isTree: true,
26 // Forces the placeholder to have a size.
27 forcePlaceholderSize: true,
28 // Restricts sort start click to the specified element.
29 // Allows for a helper element to be used for dragging display.
30 // If set to "clone", then the element will be cloned and the clone will be dragged.
31 helper: 'clone',
32 listType: 'ul',
33 items: 'li',
34 toleranceElement: '> div', // Direct children of the li element
35 handle: 'div', // The same <div> for toleranceElement is set as the drag handle
36 // Specifies which mode to use for testing whether the item being moved is hovering over another item.
37 // If set to 'pointr', is when the mouse pointer overlaps the other item.
38 tolerance: 'pointer',
39 // The maximum depth of nested items the list can accept.
40 maxLevels: maxLevel,
41 // Defines the opacity of the helper while sorting.
42 opacity: 0.6,
43 placeholder: 'ui-sortable-placeholder',
44 // Whether the sortable items should revert to their new positions using a smooth animation.
45 // If set as a number, it's in miliseconds
46 revert: 250,
47 // How far right or left (in pixels) the item has to travel
48 // in order to be nested or to be sent outside its current list. Default: 20
49 tabSize: 20,
50 // This event is triggered when sorting starts.
51 start: function (event, ui) {
52 // console.log('ui.item -- start');
53 // console.log(ui.item);
54 sort_started.item = ui.item; // The jQuery object representing the current dragged element.
55 sort_started.prev = ui.item.prev(':not(".ui-sortable-placeholder")');
56 sort_started.next = ui.item.next(':not(".ui-sortable-placeholder")');
57 },
58 // This event is triggered when the user stopped sorting and the DOM position has changed.
59 update: function (event, ui) {
60 // console.log('ui.item -- update');
61 // console.log(ui.item);
62 // Elements of the "Updating order..." notice
63 var updateNotice = $('#updating-order-notice'), // Wrapper
64 spinner = $('#spinner-img'), // Spinner
65 updateSuccess = $('.updating-order-notice .dashicons.dashicons-saved'); // Check mark
66
67 ui.item.find('div.row-content:first').append(updateNotice);
68
69 // Reset the state of the "Updating order..." indicator
70 $(spinner).show();
71 $(updateSuccess).hide();
72 $(updateNotice).css('background-color','#eee').fadeIn();
73
74 // Get the end items where the item was placed
75 // console.log('sort_finished');
76 // console.log(sort_finished);
77 sort_finished.item = ui.item; // The jQuery object representing the current dragged element.
78 // sort_finished.prev = ui.item.prev(':not(".ui-sortable-placeholder")');
79 // sort_finished.next = ui.item.next(':not(".ui-sortable-placeholder")');
80
81 // If an item is moved as a child of another item
82 // it will be inserted inside the ul.child-list with a data-parent
83 if ( ui.item.parent('.child-list').length ) {
84 // if ( ui.item.siblings('.list-item').length ) {
85 // Do something
86 // } else {
87 // Let's set the item's parent ID here, taking from ul.child-list's data-parent info
88 sort_finished.item.attr('data-parent', ui.item.parent('.child-list').attr('data-parent'));
89 // }
90 } else {
91 sort_finished.item.attr('data-parent', '0');
92 }
93 // console.log('sort_finished.prev');
94 // console.log(sort_finished.prev);
95
96 var list_offset = parseInt(sort_finished.item.index());
97 sort_finished.item.attr('data-menu-order', list_offset);
98
99 // Get attributes
100 var attributes = {};
101 $.each(sort_finished.item[0].attributes, function () {
102 attributes[this.name] = this.value;
103 });
104 // console.log('attributes: ' + cleanStringify(attributes));
105
106 // Data for ajax call
107 var dataArgs = {
108 action: contentOrderSort.action, // from wp_localize_script
109 item_parent: 0, // We only deal with top-level items, not child items
110 start: 0, // Start processing menu_order update in DB from item with menu_order defined here
111 nonce: contentOrderSort.nonce,
112 post_id: sort_finished.item.attr('data-id'),
113 menu_order: sort_finished.item.attr('data-menu-order'),
114 excluded_items: {},
115 post_type: sort_started.item.attr('data-post-type'),
116 attributes: attributes,
117 };
118
119
120 // console.log('dataArgs: ' + cleanStringify(dataArgs));
121
122 // AJAX call to update menu_order for items in the list
123 $.ajax({
124 type: "POST",
125 url: ajaxurl,
126 data: dataArgs,
127 success: function(response) {
128 // console.log(response);
129 // Update the state of the "Updating order..." indicator
130 $(spinner).hide();
131 $(updateSuccess).show();
132 $(updateNotice).css('background-color','#cce5cc').delay(1000).fadeOut();
133 },
134 error: function(errorThrown) {
135 console.log(errorThrown);
136 }
137 });
138 }
139 });
140
141
142 });
143
144 // Convert object to simpler string for console.log. Ref: https://stackoverflow.com/a/48845206
145 // function cleanStringify(object) {
146 // if (object && typeof object === 'object') {
147 // object = copyWithoutCircularReferences([object], object);
148 // }
149 // return JSON.stringify(object);
150
151 // function copyWithoutCircularReferences(references, object) {
152 // var cleanObject = {};
153 // Object.keys(object).forEach(function(key) {
154 // var value = object[key];
155 // if (value && typeof value === 'object') {
156 // if (references.indexOf(value) < 0) {
157 // references.push(value);
158 // cleanObject[key] = copyWithoutCircularReferences(references, value);
159 // references.pop();
160 // } else {
161 // cleanObject[key] = '###_Circular_###';
162 // }
163 // } else if (typeof value !== 'function') {
164 // cleanObject[key] = value;
165 // }
166 // });
167 // return cleanObject;
168 // }
169 // }
170
171 })( jQuery );