$rtbody.
sortable(
{
axis:
"y",
cancel:
".rowsortdisabled,input,textarea,button,select,option",
cursor:
"move",
delay:
delay_opt,
distance:
distance_opt,
handle:
".dragpoint",
helper:
function(
e,
ui)
{
$helper =
ui;
$scroll =
ui.
closest(
".rtscrollbody");
//save scroll offset so that we can reset it during "start" event
scrollOffset =
$scroll.
scrollTop();
//create placeholder content with cell sizes based on dragged row
h =
ui.
height();
$placeholder =
$helper.
children().
map(
function(
i,
el)
{
var
w =
ui.
children().
eq(
i).
width();
$pweb(
this).
width(
w);
return (
$pweb(
"<td class='" + (
placeholderstyle ?
placeholderstyle :
'') +
"' style='border-left:none; border-right:none;width:" +
w +
"px;height:" +
h +
"px;'> </td>")[
0]);
});
$placeholder.
first().
css(
"border-right",
null);
$placeholder.
last().
css(
"border-left",
null);
$placeholder.
css(
{
"box-sizing":
"border-box"
});
return
$helper;
},
items:
"> .rowsortable",
opacity:
"0.5",
placeholder:
placeholderstyle ?
placeholderstyle :
false,
revert:
revert_opt,
scroll:
true,
scrollSpeed:
scrollSpeed_opt,
start:
function(
event,
ui)
{
var
$parent =
ui.
item.
parent();
// insert the placeholder content
ui.
placeholder.
empty().
append(
$placeholder);
// suppress the bottom border on the last row since it will appear once the item being sorted is moved to the end
$lastRow.
children().
css(
"border-bottom",
"none");
// move hidden item to the bottom so that it doesn't screw up alternating colors
ui.
item.
detach().
appendTo(
$parent);
// reset the scrollOffset
$scroll.
scrollTop(
scrollOffset);
},
stop:
Pweb.
process.
wrapCallback(
function(
event,
ui)
{
if (
PwebProc.
validation.
errorElementId)
{
$rtbody.
sortable(
'cancel');
}
}),
update:
Pweb.
process.
wrapCallback(
function(
event,
ui)
{
// restore the last row's bottom border
$lastRow.
children().
css(
"border-bottom",
'');
if (
Pweb.
process.
isVisible())
{
var
dragEndEvent =
$pweb.
Event(
"dragend",
{
dragdata:
ui
});
var
$comp =
$pweb(
ui.
item).
find(
'.dragpoint').
first();
$comp.
trigger(
dragEndEvent);
}
// If process isn't visible then cancel the sort operation
else
{
$rtbody.
sortable(
'cancel');
}
})
});