{*
/**
* Copyright (c) 2016, Yaser Alimardany
* All rights reserved.
*/
*}
{script}
{literal}
$(document).ready( function() {
$('#s1').sortable({
items: 'tr.draggable-item',
helper: 'clone',
placeholder: 'lang_placeholder',
start: function (event, ui) {
$(ui.placeholder).append('
| ');
$(ui.placeholder).css('backgroundColor', 'rgb(220,220,220)');
},
stop: function (event, ui) {
switch (this) {
case $('#s1')[0]:
$('tr.draggable-item:odd', this).each(function () {
if (!$(this).hasClass('ow_even')) $(this).addClass('ow_even');
});
$('tr.draggable-item:even', this).each(function () {
if ($(this).hasClass('ow_even')) $(this).removeClass('ow_even');
});
break;
}
},
receive: function (event, ui) {
switch (this) {
case $('#s1')[0] :
$('tr.draggable-item', this).each(function () {
$('td:nth(1) a.deact', this).show();
$('td:nth(1) a.act', this).hide();
$('td:nth(1) a.del', this).hide();
if ($(this).hasClass('ow_high2')) {
$(this).removeClass('ow_high2');
}
});
if ($('tr.draggable-item', this).length == 0) {
$.alert('{text key="admin+msg_one_active_constraint"}');
$(this).sortable('cancel');
$('#s1 tr.empty').remove();
break;
}
$('tr.draggable-item:odd', this).each(function () {
if (!$(this).hasClass('ow_even')) $(this).addClass('ow_even');
});
$('tr.draggable-item:even', this).each(function () {
if ($(this).hasClass('ow_even')) $(this).removeClass('ow_even');
});
break;
}
},
update: function (event, ui) {
if (ui.sender) {
if ($('tr', ui.sender[0]).length == 0) $(ui.sender[0]).append('| {/literal}{text key="iisvitrin+empty_row_label"}{literal} |
');
return;
}
if ($('#s1 tr.empty').length == 1 && $('#s1 tr.draggable-item').length > 0)
$('#s1 tr.empty').remove();
var set = {};
$('tr.draggable-item', '#s1').each(function (i) {
set['itemsId[' + i + ']'] = parseInt($('input:hidden', this).attr('value'));
});
$('td:nth(0) span.ow_mild_green', $('tr.draggable-item', '#s1')).remove();
$.ajax({
type: "POST",
url: '{/literal}{url_for for="iisvitrin_CTRL_Admin:ajaxSaveItemsOrder"}{literal}',
data: set
});
},
connectWith: '#s1'
}).each(function () {
$('tr.draggable-item', this).hover(
function () {
$('td:nth-child(3) div span', this).show()
},
function () {
$('td:nth-child(3) div span', this).hide()
}
);
if ($('tr.draggable-item', this).length == 0)
$(this).append('| {/literal}{text key="iisvitrin+empty_row_label"}{literal} |
');
});
});
{/literal}
{/script}
{form name="item"}
{/form}
{form name="descriptionForm"}
{/form}