51
modules/an_banners/views/js/sorting.js
Normal file
51
modules/an_banners/views/js/sorting.js
Normal file
@@ -0,0 +1,51 @@
|
||||
/**
|
||||
* 2022 Anvanto
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Academic Free License (AFL 3.0)
|
||||
*
|
||||
* @author Anvanto <anvantoco@gmail.com>
|
||||
* @copyright 2022 Anvanto
|
||||
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
||||
*/
|
||||
|
||||
! function(t) {
|
||||
"use strict";
|
||||
var n = t.when(),
|
||||
e = "undefined" != typeof baseAdminDir ? location.origin + baseAdminDir + currentIndex + "&token=" + token : location.href,
|
||||
o = e + "&ajax";
|
||||
t(document).ready(function() {
|
||||
var e = t("#table-banner tbody")[0];
|
||||
return "undefined" != typeof e && void new Sortable(e, {
|
||||
group: "name",
|
||||
sort: !0,
|
||||
handle: '.handle',
|
||||
delay: 0,
|
||||
disabled: !1,
|
||||
draggable: "tr",
|
||||
store: null,
|
||||
animation: 150,
|
||||
setData: function(t, n) {
|
||||
t.setData("Text", n.textContent)
|
||||
},
|
||||
onStart: function(t) {},
|
||||
onEnd: function(t) {},
|
||||
onSort: function(e) {
|
||||
n = n.then(function() {
|
||||
return t.post(o, {
|
||||
action: "updatePositions",
|
||||
positions: t("#table-banner tbody tr").toArray().map(function(n) {
|
||||
return parseInt(t(n).children("td").eq(1).html()) || 0
|
||||
})
|
||||
})
|
||||
}).then(function(n) {
|
||||
var e = 1;
|
||||
n.success ? (t("#table-banner tbody tr").each(function() {
|
||||
t(t(this).children("td")[6]).find('span').html(e++)
|
||||
}), showSuccessMessage(n.message)) : showErrorMessage(n.message)
|
||||
})
|
||||
}
|
||||
})
|
||||
})
|
||||
}(jQuery);
|
||||
Reference in New Issue
Block a user