|
|
|
@ -130,7 +130,7 @@ function start(){ |
|
|
|
|
drop: function(event, ui) { |
|
|
|
|
if($(ui.draggable).parent().parent().html() == $(this).parent().html()){ |
|
|
|
|
var tmp_ui = $(ui.draggable).parent(); |
|
|
|
|
checkOnDrop($(this), $(ui.draggable)); |
|
|
|
|
$(this).append($(ui.draggable)); |
|
|
|
|
checkCorrectness(tmp_ui); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -358,7 +358,7 @@ function importData(data){ |
|
|
|
|
drop: function(event, ui) { |
|
|
|
|
if($(ui.draggable).parent().parent().html() == $(this).parent().html()){ |
|
|
|
|
var tmp_ui = $(ui.draggable).parent(); |
|
|
|
|
checkOnDrop($(this), $(ui.draggable)); |
|
|
|
|
$(this).append($(ui.draggable)); |
|
|
|
|
checkCorrectness(tmp_ui); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -430,7 +430,7 @@ function importData(data){ |
|
|
|
|
drop: function(event, ui) { |
|
|
|
|
if($(ui.draggable).parent().parent().html() == $(this).parent().html()){ |
|
|
|
|
var tmp_ui = $(ui.draggable).parent(); |
|
|
|
|
checkOnDrop($(this), $(ui.draggable)); |
|
|
|
|
$(this).append($(ui.draggable)); |
|
|
|
|
checkCorrectness(tmp_ui); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -475,6 +475,7 @@ function importData(data){ |
|
|
|
|
} |
|
|
|
|
});
|
|
|
|
|
container.appendTo("#data"); |
|
|
|
|
checkCorrectness(all_imgs); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -537,7 +538,7 @@ function showExample(){ |
|
|
|
|
drop: function(event, ui) { |
|
|
|
|
if($(ui.draggable).parent().parent().html() == $(this).parent().html()){ |
|
|
|
|
var tmp_ui = $(ui.draggable).parent(); |
|
|
|
|
checkOnDrop($(this), $(ui.draggable)); |
|
|
|
|
$(this).append($(ui.draggable)); |
|
|
|
|
checkCorrectness(tmp_ui); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -548,7 +549,7 @@ function showExample(){ |
|
|
|
|
drop: function(event, ui) { |
|
|
|
|
if($(ui.draggable).parent().parent().html() == $(this).parent().html()){ |
|
|
|
|
var tmp_ui = $(ui.draggable).parent(); |
|
|
|
|
checkOnDrop($(this), $(ui.draggable)); |
|
|
|
|
$(this).append($(ui.draggable)); |
|
|
|
|
checkCorrectness(tmp_ui); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -578,9 +579,9 @@ function addCategory(obj){ |
|
|
|
|
$("<button class='del_category'></button>").appendTo(imgs_container); |
|
|
|
|
$("<button class='add_category'></button>").appendTo(imgs_container); |
|
|
|
|
imgs_container.attr("ondragenter", "return false;") |
|
|
|
|
.attr("ondragleave", "$(this).css(\"background-color\",\"\"); return false;") |
|
|
|
|
.attr("ondragover", "$(this).css(\"background-color\",\"\"); return false;") |
|
|
|
|
.attr("ondrop", "$(this).css(\"background-color\",\"\"); return onDropTarget(this,event);"); |
|
|
|
|
.attr("ondragleave", "$(this).css(\"background-color\",\"#e6f6ff\"); return false;") |
|
|
|
|
.attr("ondragover", "$(this).css(\"background-color\",\"#c3e9ff\"); return false;") |
|
|
|
|
.attr("ondrop", "$(this).css(\"background-color\",\"#e6f6ff\"); return onDropTarget(this,event);"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//add new container
|
|
|
|
@ -599,9 +600,9 @@ function addContainer(){ |
|
|
|
|
$("<button class='del_category'></button>").appendTo(imgs_container); |
|
|
|
|
$("<button class='add_category'></button>").appendTo(imgs_container); |
|
|
|
|
imgs_container.attr("ondragenter", "return false;") |
|
|
|
|
.attr("ondragleave", "$(this).css(\"background-color\",\"\"); return false;") |
|
|
|
|
.attr("ondragover", "$(this).css(\"background-color\",\"\"); return false;") |
|
|
|
|
.attr("ondrop", "$(this).css(\"background-color\",\"\"); return onDropTarget(this,event);"); |
|
|
|
|
.attr("ondragleave", "$(this).css(\"background-color\",\"#e6f6ff\"); return false;") |
|
|
|
|
.attr("ondragover", "$(this).css(\"background-color\",\"#c3e9ff\"); return false;") |
|
|
|
|
.attr("ondrop", "$(this).css(\"background-color\",\"#e6f6ff\"); return onDropTarget(this,event);"); |
|
|
|
|
container.insertBefore($(".add_block")); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -704,8 +705,7 @@ function returnId(){ |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//a func for checking when smth will drop
|
|
|
|
|
function checkOnDrop(dest, source){ |
|
|
|
|
dest.append(source);
|
|
|
|
|
function checkOnDrop(dest){ |
|
|
|
|
var tmp_count = dest.find("input[name='count']").val(); |
|
|
|
|
var tmp_mask = dest.find("input[name='mask']").val(); |
|
|
|
|
if(dest.find(".img_block").size() == tmp_count){ |
|
|
|
@ -715,47 +715,35 @@ function checkOnDrop(dest, source){ |
|
|
|
|
tmp_right = false; |
|
|
|
|
});
|
|
|
|
|
if(tmp_right) |
|
|
|
|
dest.removeClass("def_cont") |
|
|
|
|
.removeClass("red_cont") |
|
|
|
|
.addClass("green_cont"); |
|
|
|
|
dest.removeClass("def_cont").removeClass("red_cont").addClass("green_cont"); |
|
|
|
|
else |
|
|
|
|
dest.removeClass("def_cont") |
|
|
|
|
.removeClass("green_cont") |
|
|
|
|
.addClass("red_cont"); |
|
|
|
|
dest.removeClass("def_cont").removeClass("green_cont").addClass("red_cont"); |
|
|
|
|
} else
|
|
|
|
|
dest.removeClass("def_cont") |
|
|
|
|
.removeClass("green_cont") |
|
|
|
|
.addClass("red_cont"); |
|
|
|
|
dest.removeClass("def_cont").removeClass("green_cont").addClass("red_cont"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//checking source on correctness
|
|
|
|
|
function checkCorrectness(source){ |
|
|
|
|
if(!source.hasClass("all_imgs")){ |
|
|
|
|
var tmp_count = source.find("input[name='count']").val(); |
|
|
|
|
var tmp_mask = source.find("input[name='mask']").val(); |
|
|
|
|
if(source.find(".img_block").size() == tmp_count){ |
|
|
|
|
var tmp_right = true;
|
|
|
|
|
source.find(".img_block").each(function(){ |
|
|
|
|
if($(this).find("input").val() != tmp_mask) |
|
|
|
|
tmp_right = false; |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
if(tmp_right) |
|
|
|
|
source.removeClass("def_cont") |
|
|
|
|
.removeClass("red_cont") |
|
|
|
|
.addClass("green_cont"); |
|
|
|
|
else |
|
|
|
|
source.removeClass("def_cont") |
|
|
|
|
.removeClass("green_cont") |
|
|
|
|
.addClass("red_cont"); |
|
|
|
|
} else if(source.find(".img_block").size() == 0) |
|
|
|
|
source.addClass("def_cont") |
|
|
|
|
.removeClass("green_cont") |
|
|
|
|
.removeClass("red_cont"); |
|
|
|
|
else
|
|
|
|
|
source.removeClass("def_cont") |
|
|
|
|
.removeClass("green_cont") |
|
|
|
|
.addClass("red_cont"); |
|
|
|
|
if(source.parent().find(".all_imgs").find(".img_block").size() == 0){ |
|
|
|
|
source.parent().find(".imgs_cont").each(function(){ |
|
|
|
|
checkOnDrop($(this)) |
|
|
|
|
}) |
|
|
|
|
} else { |
|
|
|
|
source.parent().find(".imgs_cont").each(function(){ |
|
|
|
|
$(this).addClass("def_cont").removeClass("green_cont").removeClass("red_cont"); |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
if(source.find(".img_block").size() > 0){ |
|
|
|
|
source.parent().find(".imgs_cont").each(function(){ |
|
|
|
|
$(this).addClass("def_cont").removeClass("green_cont").removeClass("red_cont"); |
|
|
|
|
}) |
|
|
|
|
} else { |
|
|
|
|
source.parent().find(".imgs_cont").each(function(){ |
|
|
|
|
checkOnDrop($(this)) |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|