mirror of
https://github.com/pretix/pretix.git
synced 2026-08-26 13:14:40 +00:00
Show first up arrow and last down arrow
This commit is contained in:
@@ -3,15 +3,30 @@ $(function () {
|
|||||||
$("[data-dnd-url]").each(function(){
|
$("[data-dnd-url]").each(function(){
|
||||||
var container = $(this),
|
var container = $(this),
|
||||||
url = container.data("dnd-url"),
|
url = container.data("dnd-url"),
|
||||||
handle = $("<span>", {class: "btn btn-default btn-sm dnd-sort-handle"});
|
up = container.find("a:has(.fa-arrow-up)"),
|
||||||
handle.append('<i class="fa fa-arrows"></i>');
|
handle = $('<span class="btn btn-default btn-sm dnd-sort-handle"><i class="fa fa-arrows"></i></span>');
|
||||||
container.find("a:has(.fa-arrow-up)").remove();
|
|
||||||
container.find("a:has(.fa-arrow-down)").replaceWith(handle);
|
function hideArrows(container){
|
||||||
|
var up = container.find("a:has(.fa-arrow-up)"),
|
||||||
|
firstUp = up.first(),
|
||||||
|
down = container.find("a:has(.fa-arrow-down)"),
|
||||||
|
lastDown = down.last();
|
||||||
|
up.not(firstUp).css("display","none");
|
||||||
|
down.not(lastDown).css("display","none");
|
||||||
|
firstUp.css("display","inline-block");
|
||||||
|
lastDown.css("display","inline-block");
|
||||||
|
}
|
||||||
|
up.after(handle);
|
||||||
|
hideArrows(container);
|
||||||
|
|
||||||
Sortable.create(container.get(0), {
|
Sortable.create(container.get(0), {
|
||||||
handle: ".dnd-sort-handle",
|
handle: ".dnd-sort-handle",
|
||||||
onSort: function(evt){
|
onSort: function(evt){
|
||||||
var ids = $(evt.to).find("[data-dnd-id]").toArray().map(e => e.dataset.dndId);
|
var container = $(evt.to),
|
||||||
|
ids = container.find("[data-dnd-id]").toArray().map(e => e.dataset.dndId);
|
||||||
|
|
||||||
|
hideArrows(container);
|
||||||
|
|
||||||
$.ajax(
|
$.ajax(
|
||||||
{
|
{
|
||||||
'type': 'POST',
|
'type': 'POST',
|
||||||
|
|||||||
Reference in New Issue
Block a user