PluginProbe ʕ •ᴥ•ʔ
Strong Testimonials / 2.38
Strong Testimonials v2.38
3.3.2 3.3.1 trunk 1.0.1 2.30.9 2.31.10 2.32 2.32.1 2.32.2 2.32.3 2.32.4 2.33 2.34 2.35 2.36 2.37 2.38 2.38.1 2.39 2.39.1 2.39.2 2.39.3 2.40.0 2.40.1 2.40.2 2.40.3 2.40.4 2.40.5 2.40.6 2.40.7 2.41.0 2.41.1 2.50.0 2.50.1 2.50.2 2.50.3 2.50.4 2.51.0 2.51.1 2.51.2 2.51.3 2.51.4 2.51.5 2.51.6 2.51.7 2.51.8 2.51.9 3.0.0 3.0.1 3.0.2 3.0.3 3.1.0 3.1.1 3.1.10 3.1.11 3.1.12 3.1.13 3.1.14 3.1.15 3.1.16 3.1.17 3.1.18 3.1.19 3.1.2 3.1.20 3.1.3 3.1.4 3.1.5 3.1.6 3.1.7 3.1.8 3.1.9 3.2.0 3.2.1 3.2.10 3.2.11 3.2.12 3.2.13 3.2.14 3.2.15 3.2.16 3.2.17 3.2.18 3.2.19 3.2.2 3.2.20 3.2.21 3.2.22 3.2.3 3.2.4 3.2.5 3.2.6 3.2.7 3.2.8 3.2.9 3.3.0
strong-testimonials / admin / js / admin-order.js
strong-testimonials / admin / js Last commit date
lib 7 years ago addon-licenses.js 7 years ago admin-compat.js 7 years ago admin-fields.js 7 years ago admin-form.js 7 years ago admin-global.js 7 years ago admin-order.js 7 years ago custom-spinner.js 7 years ago help.js 7 years ago rating-edit.js 7 years ago view-category-filter.js 7 years ago views.js 7 years ago
admin-order.js
129 lines
1 /**
2 * Admin list order
3 * Strong Testimonials
4 */
5
6 // set cell widths to prevent shrinkage
7 function setCellWidths() {
8 jQuery('td, th', 'table.posts').each(function () {
9 var cell = jQuery(this);
10 cell.width(cell.width());
11 });
12 };
13
14 // reset cell widths
15 function resetCellWidths(reset) {
16 jQuery('td, th', 'table.posts').each(function () {
17 var cell = jQuery(this);
18 cell.width('');
19 }).promise().done(setCellWidths);
20 };
21
22 // Returns a function, that, as long as it continues to be invoked, will not
23 // be triggered. The function will be called after it stops being called for
24 // N milliseconds. If `immediate` is passed, trigger the function on the
25 // leading edge, instead of the trailing.
26 // Thanks http://davidwalsh.name/javascript-debounce-function
27 function debounce(func, wait, immediate) {
28 var timeout;
29 return function () {
30 var context = this, args = arguments;
31 var later = function () {
32 timeout = null;
33 if (!immediate) func.apply(context, args);
34 };
35 var callNow = immediate && !timeout;
36 clearTimeout(timeout);
37 timeout = setTimeout(later, wait);
38 if (callNow) func.apply(context, args);
39 };
40 };
41
42 // window resize listener
43 var myEfficientFn = debounce(resetCellWidths, 100);
44 window.addEventListener('resize', myEfficientFn);
45
46
47 jQuery(document).ready(function ($) {
48
49 $.fn.strongSort = function (options) {
50
51 var $this = this;
52 var $handles = $(options.handles);
53
54 var toggleReorder = function () {
55 $this.sortable("enable");
56 $handles.show();
57 }
58
59 this.sortable({
60 disabled: true, // initially disabled
61 items: 'tr',
62 axis: 'y',
63 handle: options.handles,
64 forcePlaceholderSize: true,
65 placeholder: "sortable-placeholder",
66 start: function (e, ui) {
67 // set height of placeholder to match current dragged element
68 ui.placeholder.height(ui.helper.height());
69 ui.helper.css("cursor", "move");
70 },
71 helper: function (e, ui) {
72 var $originals = ui.children();
73 var $helper = ui.clone();
74 $helper.children().each(function (index) {
75 // set helper cell sizes to match the original sizes
76 $(this).width($originals.eq(index).width());
77 });
78 return $helper;
79 },
80 update: function (e, ui) {
81 ui.item.find(".column-handle").addClass("refresh");
82 $.post(ajaxurl, {
83 action: 'update-menu-order',
84 order: $('#the-list').sortable('serialize'),
85 },
86 function (data) {
87 // update menu order shown
88 var $orders = $(".menu-order");
89 var obj = JSON.parse(data);
90 var orderArray = $.map(obj, function (val, i) {
91 $orders.eq(i).html(val);
92 });
93 })
94 .done(function () {
95 // update zebra striping
96 $("#the-list").find("tr:even").removeClass("alternate");
97 ui.item.effect('highlight', {}, 2000);
98 ui.item.find(".column-handle").removeClass("refresh");
99 })
100
101 }
102 });
103
104 toggleReorder();
105
106 return this;
107 }
108
109 // Init
110
111 setCellWidths();
112
113 $("#screen-meta").on("change", ".metabox-prefs", resetCellWidths);
114
115 $("#the-list").strongSort({
116 handles: 'td.column-handle'
117 });
118
119 $("td.column-handle").hover(
120 function () {
121 $(this).closest("tr").addClass("reorder-hover");
122 },
123 function () {
124 $(this).closest("tr").removeClass("reorder-hover");
125 }
126 );
127
128 });
129