|
|
@ -1,11 +1,17 @@ |
|
|
|
var sankoreLang = { |
|
|
|
var sankoreLang = { |
|
|
|
display: "Display",
|
|
|
|
display: "Display",
|
|
|
|
edit: "Edit",
|
|
|
|
edit: "Edit",
|
|
|
|
first_desc: "Odd numbers",
|
|
|
|
first_desc: "Fruits",
|
|
|
|
second_desc: "Even numbers",
|
|
|
|
second_desc: "Vegetables", |
|
|
|
|
|
|
|
potatoes: "Potato", |
|
|
|
|
|
|
|
carrot: "Carrot", |
|
|
|
|
|
|
|
onion: "Onion", |
|
|
|
|
|
|
|
apple: "Apple", |
|
|
|
|
|
|
|
pear: "Pear", |
|
|
|
enter: "Enter your category name here ...", |
|
|
|
enter: "Enter your category name here ...", |
|
|
|
add: "Add new block", |
|
|
|
add: "Add new block", |
|
|
|
wgt_name: "Order images", |
|
|
|
text: "Some text", |
|
|
|
|
|
|
|
wgt_name: "Categorize text", |
|
|
|
reload: "Reload", |
|
|
|
reload: "Reload", |
|
|
|
slate: "Wood", |
|
|
|
slate: "Wood", |
|
|
|
pad: "Pad" |
|
|
|
pad: "Pad" |
|
|
@ -22,8 +28,8 @@ function start(){ |
|
|
|
$(".style_select option[value='2']").text(sankoreLang.pad); |
|
|
|
$(".style_select option[value='2']").text(sankoreLang.pad); |
|
|
|
|
|
|
|
|
|
|
|
if(window.sankore){ |
|
|
|
if(window.sankore){ |
|
|
|
if(sankore.preference("categoriser_images","")){ |
|
|
|
if(sankore.preference("categoriser_text","")){ |
|
|
|
var data = jQuery.parseJSON(sankore.preference("categoriser_images","")); |
|
|
|
var data = jQuery.parseJSON(sankore.preference("categoriser_text","")); |
|
|
|
importData(data); |
|
|
|
importData(data); |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
showExample(); |
|
|
|
showExample(); |
|
|
@ -61,7 +67,6 @@ function start(){ |
|
|
|
$(this).addClass("selected"); |
|
|
|
$(this).addClass("selected"); |
|
|
|
$("#wgt_edit").removeClass("selected"); |
|
|
|
$("#wgt_edit").removeClass("selected"); |
|
|
|
$(".style_select").css("display","none"); |
|
|
|
$(".style_select").css("display","none"); |
|
|
|
sankore.enableDropOnWidget(false); |
|
|
|
|
|
|
|
$(".add_block").remove(); |
|
|
|
$(".add_block").remove(); |
|
|
|
$(".cont").each(function(){ |
|
|
|
$(".cont").each(function(){ |
|
|
|
var container = $(this); |
|
|
|
var container = $(this); |
|
|
@ -72,6 +77,7 @@ function start(){ |
|
|
|
container.find(".close_cont").remove(); |
|
|
|
container.find(".close_cont").remove(); |
|
|
|
container.find(".imgs_cont").each(function(){
|
|
|
|
container.find(".imgs_cont").each(function(){
|
|
|
|
$(this).find(".del_category").remove(); |
|
|
|
$(this).find(".del_category").remove(); |
|
|
|
|
|
|
|
$(this).find(".add_img").remove(); |
|
|
|
$(this).find(".add_category").remove();
|
|
|
|
$(this).find(".add_category").remove();
|
|
|
|
$(this).removeAttr("ondragenter") |
|
|
|
$(this).removeAttr("ondragenter") |
|
|
|
.removeAttr("ondragleave") |
|
|
|
.removeAttr("ondragleave") |
|
|
@ -82,6 +88,9 @@ function start(){ |
|
|
|
$(this).find("input[name='count']").val(tmp_count); |
|
|
|
$(this).find("input[name='count']").val(tmp_count); |
|
|
|
$(this).find(".img_block").each(function(){ |
|
|
|
$(this).find(".img_block").each(function(){ |
|
|
|
$(this).find(".close_img").remove(); |
|
|
|
$(this).find(".close_img").remove(); |
|
|
|
|
|
|
|
var tmp_text = $(this).find(".text_cont"); |
|
|
|
|
|
|
|
tmp_text.removeAttr("contenteditable") |
|
|
|
|
|
|
|
.css("margin", ($(this).height() - tmp_text.height())/2 + "px 0px"); |
|
|
|
tmp_array.push($(this)); |
|
|
|
tmp_array.push($(this)); |
|
|
|
$(this).remove(); |
|
|
|
$(this).remove(); |
|
|
|
}); |
|
|
|
}); |
|
|
@ -131,19 +140,14 @@ function start(){ |
|
|
|
$(this).addClass("selected"); |
|
|
|
$(this).addClass("selected"); |
|
|
|
$("#wgt_display").removeClass("selected"); |
|
|
|
$("#wgt_display").removeClass("selected"); |
|
|
|
$(".style_select").css("display","block"); |
|
|
|
$(".style_select").css("display","block"); |
|
|
|
sankore.enableDropOnWidget(true); |
|
|
|
|
|
|
|
$(".cont").each(function(){ |
|
|
|
$(".cont").each(function(){ |
|
|
|
var container = $(this); |
|
|
|
var container = $(this); |
|
|
|
|
|
|
|
|
|
|
|
$("<div class='close_cont'>").appendTo(container); |
|
|
|
$("<div class='close_cont'>").appendTo(container); |
|
|
|
container.find(".imgs_cont").each(function(){ |
|
|
|
container.find(".imgs_cont").each(function(){ |
|
|
|
$("<button class='del_category'>-</button>").appendTo($(this)); |
|
|
|
$("<button class='del_category'></button>").appendTo($(this)); |
|
|
|
$("<button class='add_category'>+</button>").appendTo($(this)); |
|
|
|
$("<button class='add_category'></button>").appendTo($(this)); |
|
|
|
$(this).attr("ondragenter", "return false;") |
|
|
|
$(this).removeClass("red_cont") |
|
|
|
.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);") |
|
|
|
|
|
|
|
.removeClass("red_cont") |
|
|
|
|
|
|
|
.removeClass("green_cont") |
|
|
|
.removeClass("green_cont") |
|
|
|
.addClass("def_cont") |
|
|
|
.addClass("def_cont") |
|
|
|
.droppable("destroy") |
|
|
|
.droppable("destroy") |
|
|
@ -151,11 +155,15 @@ function start(){ |
|
|
|
var tmp_img_cont = $(this); |
|
|
|
var tmp_img_cont = $(this); |
|
|
|
var tmp_mask = $(this).find("input[name='mask']").val(); |
|
|
|
var tmp_mask = $(this).find("input[name='mask']").val(); |
|
|
|
container.find(".img_block").each(function(){ |
|
|
|
container.find(".img_block").each(function(){ |
|
|
|
|
|
|
|
$(this).draggable("destroy") |
|
|
|
|
|
|
|
.find(".text_cont").attr("contenteditable","true") |
|
|
|
|
|
|
|
.removeAttr("style"); |
|
|
|
if($(this).find("input").val() == tmp_mask){ |
|
|
|
if($(this).find("input").val() == tmp_mask){ |
|
|
|
$("<div class='close_img'>").appendTo($(this)); |
|
|
|
$("<div class='close_img'>").appendTo($(this)); |
|
|
|
$(this).appendTo(tmp_img_cont); |
|
|
|
$(this).appendTo(tmp_img_cont); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
$("<div class='add_img'>").appendTo($(this)); |
|
|
|
}); |
|
|
|
}); |
|
|
|
container.find(".all_imgs").remove(); |
|
|
|
container.find(".all_imgs").remove(); |
|
|
|
}); |
|
|
|
}); |
|
|
@ -175,7 +183,7 @@ function start(){ |
|
|
|
|
|
|
|
|
|
|
|
//adding new img
|
|
|
|
//adding new img
|
|
|
|
$(".add_img").live("click", function(){ |
|
|
|
$(".add_img").live("click", function(){ |
|
|
|
addImgBlock($(this)); |
|
|
|
addText($(this).parent(), $(this)); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
//deleting a block
|
|
|
|
//deleting a block
|
|
|
@ -208,14 +216,14 @@ function start(){ |
|
|
|
//export
|
|
|
|
//export
|
|
|
|
function exportData(){ |
|
|
|
function exportData(){ |
|
|
|
var array_to_export = []; |
|
|
|
var array_to_export = []; |
|
|
|
if($("#edit").hasClass("selected")){ |
|
|
|
if($("#wgt_edit").hasClass("selected")){ |
|
|
|
$(".cont").each(function(){ |
|
|
|
$(".cont").each(function(){ |
|
|
|
var cont_obj = new Object(); |
|
|
|
var cont_obj = new Object(); |
|
|
|
cont_obj.style = $(".style_select").find("option:selected").val(); |
|
|
|
|
|
|
|
cont_obj.mode = "edit"; |
|
|
|
cont_obj.mode = "edit"; |
|
|
|
cont_obj.conts = []; |
|
|
|
cont_obj.conts = []; |
|
|
|
$(this).find(".imgs_cont").each(function(){ |
|
|
|
$(this).find(".imgs_cont").each(function(){ |
|
|
|
var img_cont = new Object(); |
|
|
|
var img_cont = new Object(); |
|
|
|
|
|
|
|
cont_obj.style = $(".style_select").find("option:selected").val(); |
|
|
|
img_cont.mask = $(this).find("input[name='mask']").val(); |
|
|
|
img_cont.mask = $(this).find("input[name='mask']").val(); |
|
|
|
img_cont.count = $(this).find(".img_block").size(); |
|
|
|
img_cont.count = $(this).find(".img_block").size(); |
|
|
|
img_cont.text = $(this).find(".cat_desc").val(); |
|
|
|
img_cont.text = $(this).find(".cat_desc").val(); |
|
|
@ -223,9 +231,7 @@ function exportData(){ |
|
|
|
$(this).find(".img_block").each(function(){ |
|
|
|
$(this).find(".img_block").each(function(){ |
|
|
|
var img_obj = new Object(); |
|
|
|
var img_obj = new Object(); |
|
|
|
img_obj.value = $(this).find("input").val(); |
|
|
|
img_obj.value = $(this).find("input").val(); |
|
|
|
img_obj.link = $(this).find("img").attr("src"); |
|
|
|
img_obj.text = $(this).find(".text_cont").text(); |
|
|
|
img_obj.ht = $(this).find("img").height(); |
|
|
|
|
|
|
|
img_obj.wd = $(this).find("img").width(); |
|
|
|
|
|
|
|
img_cont.imgs.push(img_obj); |
|
|
|
img_cont.imgs.push(img_obj); |
|
|
|
}); |
|
|
|
}); |
|
|
|
cont_obj.conts.push(img_cont); |
|
|
|
cont_obj.conts.push(img_cont); |
|
|
@ -235,11 +241,11 @@ function exportData(){ |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
$(".cont").each(function(){ |
|
|
|
$(".cont").each(function(){ |
|
|
|
var cont_obj = new Object(); |
|
|
|
var cont_obj = new Object(); |
|
|
|
cont_obj.style = $(".style_select").find("option:selected").val(); |
|
|
|
|
|
|
|
cont_obj.mode = "display"; |
|
|
|
cont_obj.mode = "display"; |
|
|
|
cont_obj.conts = []; |
|
|
|
cont_obj.conts = []; |
|
|
|
$(this).find(".imgs_cont").each(function(){ |
|
|
|
$(this).find(".imgs_cont").each(function(){ |
|
|
|
var img_cont = new Object(); |
|
|
|
var img_cont = new Object(); |
|
|
|
|
|
|
|
cont_obj.style = $(".style_select").find("option:selected").val(); |
|
|
|
img_cont.mask = $(this).find("input[name='mask']").val(); |
|
|
|
img_cont.mask = $(this).find("input[name='mask']").val(); |
|
|
|
img_cont.count = $(this).find("input[name='count']").val(); |
|
|
|
img_cont.count = $(this).find("input[name='count']").val(); |
|
|
|
img_cont.text = $(this).find(".cat_desc").val(); |
|
|
|
img_cont.text = $(this).find(".cat_desc").val(); |
|
|
@ -247,9 +253,7 @@ function exportData(){ |
|
|
|
$(this).find(".img_block").each(function(){ |
|
|
|
$(this).find(".img_block").each(function(){ |
|
|
|
var img_obj = new Object(); |
|
|
|
var img_obj = new Object(); |
|
|
|
img_obj.value = $(this).find("input").val(); |
|
|
|
img_obj.value = $(this).find("input").val(); |
|
|
|
img_obj.link = $(this).find("img").attr("src"); |
|
|
|
img_obj.text = $(this).find(".text_cont").text(); |
|
|
|
img_obj.ht = $(this).find("img").height(); |
|
|
|
|
|
|
|
img_obj.wd = $(this).find("img").width(); |
|
|
|
|
|
|
|
img_cont.imgs.push(img_obj); |
|
|
|
img_cont.imgs.push(img_obj); |
|
|
|
}); |
|
|
|
}); |
|
|
|
cont_obj.conts.push(img_cont); |
|
|
|
cont_obj.conts.push(img_cont); |
|
|
@ -258,9 +262,7 @@ function exportData(){ |
|
|
|
$(this).find(".all_imgs .img_block").each(function(){ |
|
|
|
$(this).find(".all_imgs .img_block").each(function(){ |
|
|
|
var img = new Object(); |
|
|
|
var img = new Object(); |
|
|
|
img.value = $(this).find("input").val(); |
|
|
|
img.value = $(this).find("input").val(); |
|
|
|
img.link = $(this).find("img").attr("src"); |
|
|
|
img.text = $(this).find(".text_cont").text(); |
|
|
|
img.ht = $(this).find("img").height(); |
|
|
|
|
|
|
|
img.wd = $(this).find("img").width(); |
|
|
|
|
|
|
|
cont_obj.all_imgs.push(img); |
|
|
|
cont_obj.all_imgs.push(img); |
|
|
|
}); |
|
|
|
}); |
|
|
|
array_to_export.push(cont_obj); |
|
|
|
array_to_export.push(cont_obj); |
|
|
@ -274,7 +276,7 @@ function exportData(){ |
|
|
|
array_to_export.push(cont_obj); |
|
|
|
array_to_export.push(cont_obj); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
sankore.setPreference("categoriser_images", JSON.stringify(array_to_export)); |
|
|
|
sankore.setPreference("categoriser_text", JSON.stringify(array_to_export)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//import
|
|
|
|
//import
|
|
|
@ -285,14 +287,15 @@ function importData(data){ |
|
|
|
if(data[i].tmp){ |
|
|
|
if(data[i].tmp){ |
|
|
|
changeStyle(data[i].style); |
|
|
|
changeStyle(data[i].style); |
|
|
|
$(".style_select").val(data[i].style); |
|
|
|
$(".style_select").val(data[i].style); |
|
|
|
} else { |
|
|
|
} |
|
|
|
|
|
|
|
else { |
|
|
|
if(i == 0){ |
|
|
|
if(i == 0){ |
|
|
|
changeStyle(data[i].style); |
|
|
|
changeStyle(data[i].style); |
|
|
|
$(".style_select").val(data[i].style); |
|
|
|
$(".style_select").val(data[i].style); |
|
|
|
} |
|
|
|
} |
|
|
|
if(data[i].mode == "edit"){
|
|
|
|
if(data[i].mode == "edit"){
|
|
|
|
var tmp_array = []; |
|
|
|
var tmp_array = []; |
|
|
|
var container = $("<div class='cont'>"); |
|
|
|
var container = $("<div class='cont'>").appendTo("#data"); |
|
|
|
var sub_container = $("<div class='sub_cont'>").appendTo(container);
|
|
|
|
var sub_container = $("<div class='sub_cont'>").appendTo(container);
|
|
|
|
$("<div class='number_cont'>"+ (++tmp) +"</div>").appendTo(sub_container); |
|
|
|
$("<div class='number_cont'>"+ (++tmp) +"</div>").appendTo(sub_container); |
|
|
|
|
|
|
|
|
|
|
@ -306,13 +309,7 @@ function importData(data){ |
|
|
|
for(var k in data[i].conts[j].imgs){ |
|
|
|
for(var k in data[i].conts[j].imgs){ |
|
|
|
var block_img = $("<div class='img_block' style='text-align: center;'></div>"); |
|
|
|
var block_img = $("<div class='img_block' style='text-align: center;'></div>"); |
|
|
|
$("<input type='hidden' value='" + data[i].conts[j].imgs[k].value + "'/>").appendTo(block_img);
|
|
|
|
$("<input type='hidden' value='" + data[i].conts[j].imgs[k].value + "'/>").appendTo(block_img);
|
|
|
|
var img = $("<img src=\"" + data[i].conts[j].imgs[k].link + "\" style=\"display: inline;\"/>").appendTo(block_img); |
|
|
|
$("<div class='text_cont'>" + data[i].conts[j].imgs[k].text + "</div>").appendTo(block_img); |
|
|
|
if(data[i].conts[j].imgs[k].ht >= data[i].conts[j].imgs[k].wd) |
|
|
|
|
|
|
|
img.attr("height", "120"); |
|
|
|
|
|
|
|
else{ |
|
|
|
|
|
|
|
img.attr("width","120"); |
|
|
|
|
|
|
|
img.css("margin",(120 - data[i].conts[j].imgs[k].ht)/2 + "px 0"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
tmp_array.push(block_img); |
|
|
|
tmp_array.push(block_img); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -338,6 +335,8 @@ function importData(data){ |
|
|
|
appendTo: '#data' |
|
|
|
appendTo: '#data' |
|
|
|
}); |
|
|
|
}); |
|
|
|
tmp_array[j].appendTo(all_imgs); |
|
|
|
tmp_array[j].appendTo(all_imgs); |
|
|
|
|
|
|
|
var tmp_text = tmp_array[j].find(".text_cont"); |
|
|
|
|
|
|
|
tmp_text.css("margin", (tmp_array[j].height() - tmp_text.height())/2 + "px 0px"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
all_imgs.sortable(); |
|
|
|
all_imgs.sortable(); |
|
|
@ -354,10 +353,8 @@ function importData(data){ |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
container.appendTo("#data"); |
|
|
|
|
|
|
|
} else { |
|
|
|
} else { |
|
|
|
container = $("<div class='cont'>"); |
|
|
|
container = $("<div class='cont'>").appendTo("#data"); |
|
|
|
sub_container = $("<div class='sub_cont'>").appendTo(container);
|
|
|
|
sub_container = $("<div class='sub_cont'>").appendTo(container);
|
|
|
|
$("<div class='number_cont'>" + (++tmp) + "</div>").appendTo(sub_container); |
|
|
|
$("<div class='number_cont'>" + (++tmp) + "</div>").appendTo(sub_container); |
|
|
|
|
|
|
|
|
|
|
@ -371,13 +368,7 @@ function importData(data){ |
|
|
|
for(k in data[i].conts[j].imgs){ |
|
|
|
for(k in data[i].conts[j].imgs){ |
|
|
|
block_img = $("<div class='img_block' style='text-align: center;'></div>"); |
|
|
|
block_img = $("<div class='img_block' style='text-align: center;'></div>"); |
|
|
|
$("<input type='hidden' value='" + data[i].conts[j].imgs[k].value + "'/>").appendTo(block_img);
|
|
|
|
$("<input type='hidden' value='" + data[i].conts[j].imgs[k].value + "'/>").appendTo(block_img);
|
|
|
|
img = $("<img src=\"" + data[i].conts[j].imgs[k].link + "\" style=\"display: inline;\"/>").appendTo(block_img); |
|
|
|
$("<div class='text_cont'>" + data[i].conts[j].imgs[k].text + "</div>").appendTo(block_img); |
|
|
|
if(data[i].conts[j].imgs[k].ht >= data[i].conts[j].imgs[k].wd) |
|
|
|
|
|
|
|
img.attr("height", "120"); |
|
|
|
|
|
|
|
else{ |
|
|
|
|
|
|
|
img.attr("width","120"); |
|
|
|
|
|
|
|
img.css("margin",(120 - data[i].conts[j].imgs[k].ht)/2 + "px 0"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
tmp_img_array.push(block_img); |
|
|
|
tmp_img_array.push(block_img); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -389,6 +380,8 @@ function importData(data){ |
|
|
|
appendTo: '#data' |
|
|
|
appendTo: '#data' |
|
|
|
}); |
|
|
|
}); |
|
|
|
tmp_img_array[k].appendTo(imgs_container); |
|
|
|
tmp_img_array[k].appendTo(imgs_container); |
|
|
|
|
|
|
|
tmp_text = tmp_img_array[k].find(".text_cont"); |
|
|
|
|
|
|
|
tmp_text.css("margin", (tmp_img_array[k].height() - tmp_text.height())/2 + "px 0px"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
imgs_container.droppable({ |
|
|
|
imgs_container.droppable({ |
|
|
@ -409,7 +402,7 @@ function importData(data){ |
|
|
|
for(j in data[i].all_imgs){
|
|
|
|
for(j in data[i].all_imgs){
|
|
|
|
block_img = $("<div class='img_block' style='text-align: center;'></div>"); |
|
|
|
block_img = $("<div class='img_block' style='text-align: center;'></div>"); |
|
|
|
$("<input type='hidden' value='" + data[i].all_imgs[j].value + "'/>").appendTo(block_img);
|
|
|
|
$("<input type='hidden' value='" + data[i].all_imgs[j].value + "'/>").appendTo(block_img);
|
|
|
|
$("<img src=\"" + data[i].all_imgs[j].link + "\" style=\"display: inline;\" height=\"" + data[i].all_imgs[j].ht + "\"/>").appendTo(block_img); |
|
|
|
$("<div class='text_cont'>" + data[i].all_imgs[j].text + "</div>").appendTo(block_img); |
|
|
|
all_imgs_arr.push(block_img); |
|
|
|
all_imgs_arr.push(block_img); |
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -421,6 +414,8 @@ function importData(data){ |
|
|
|
appendTo: '#data' |
|
|
|
appendTo: '#data' |
|
|
|
}); |
|
|
|
}); |
|
|
|
all_imgs_arr[k].appendTo(all_imgs); |
|
|
|
all_imgs_arr[k].appendTo(all_imgs); |
|
|
|
|
|
|
|
tmp_text = all_imgs_arr[k].find(".text_cont"); |
|
|
|
|
|
|
|
tmp_text.css("margin", (all_imgs_arr[k].height() - tmp_text.height())/2 + "px 0px"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
all_imgs.sortable(); |
|
|
|
all_imgs.sortable(); |
|
|
@ -437,7 +432,6 @@ function importData(data){ |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
});
|
|
|
|
});
|
|
|
|
container.appendTo("#data"); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -467,23 +461,23 @@ function showExample(){ |
|
|
|
var tmp_div_two = $("<div style='width: 100%; overflow: hidden;'>").appendTo(imgs_container_two); |
|
|
|
var tmp_div_two = $("<div style='width: 100%; overflow: hidden;'>").appendTo(imgs_container_two); |
|
|
|
$("<input type='text' class='cat_desc' value='" + sankoreLang.second_desc + "' disabled/>").appendTo(tmp_div_two); |
|
|
|
$("<input type='text' class='cat_desc' value='" + sankoreLang.second_desc + "' disabled/>").appendTo(tmp_div_two); |
|
|
|
|
|
|
|
|
|
|
|
var img1 = $("<div class='img_block' style='text-align: center;'></div>"); |
|
|
|
var text1 = $("<div class='img_block' style='text-align: center;'></div>"); |
|
|
|
$("<input type='hidden' value='2'/>").appendTo(img1); |
|
|
|
$("<input type='hidden' value='2'/>").appendTo(text1); |
|
|
|
$("<img src=\"objects/0.gif\" style=\"display: inline;\" height=\"120\"/>").appendTo(img1); |
|
|
|
$("<div class='text_cont'>" + sankoreLang.potatoes + "</div>").appendTo(text1); |
|
|
|
var img2 = $("<div class='img_block' style='text-align: center;'></div>"); |
|
|
|
var text2 = $("<div class='img_block' style='text-align: center;'></div>"); |
|
|
|
$("<input type='hidden' value='1'/>").appendTo(img2); |
|
|
|
$("<input type='hidden' value='1'/>").appendTo(text2); |
|
|
|
$("<img src=\"objects/1.gif\" style=\"display: inline;\" height=\"120\"/>").appendTo(img2); |
|
|
|
$("<div class='text_cont'>" + sankoreLang.apple + "</div>").appendTo(text2); |
|
|
|
var img3 = $("<div class='img_block' style='text-align: center;'></div>"); |
|
|
|
var text3 = $("<div class='img_block' style='text-align: center;'></div>"); |
|
|
|
$("<input type='hidden' value='2'/>").appendTo(img3); |
|
|
|
$("<input type='hidden' value='2'/>").appendTo(text3); |
|
|
|
$("<img src=\"objects/2.gif\" style=\"display: inline;\" height=\"120\"/>").appendTo(img3); |
|
|
|
$("<div class='text_cont'>" + sankoreLang.carrot + "</div>").appendTo(text3); |
|
|
|
var img4 = $("<div class='img_block' style='text-align: center;'></div>"); |
|
|
|
var text4 = $("<div class='img_block' style='text-align: center;'></div>"); |
|
|
|
$("<input type='hidden' value='1'/>").appendTo(img4); |
|
|
|
$("<input type='hidden' value='1'/>").appendTo(text4); |
|
|
|
$("<img src=\"objects/3.gif\" style=\"display: inline;\" height=\"120\"/>").appendTo(img4); |
|
|
|
$("<div class='text_cont'>" + sankoreLang.pear + "</div>").appendTo(text4); |
|
|
|
var img5 = $("<div class='img_block' style='text-align: center;'></div>"); |
|
|
|
var text5 = $("<div class='img_block' style='text-align: center;'></div>"); |
|
|
|
$("<input type='hidden' value='2'/>").appendTo(img5); |
|
|
|
$("<input type='hidden' value='2'/>").appendTo(text5); |
|
|
|
$("<img src=\"objects/4.gif\" style=\"display: inline;\" height=\"120\"/>").appendTo(img5);
|
|
|
|
$("<div class='text_cont'>" + sankoreLang.onion + "</div>").appendTo(text5);
|
|
|
|
|
|
|
|
|
|
|
|
tmp_array.push(img1, img2, img3, img4, img5); |
|
|
|
tmp_array.push(text1, text2, text3, text4, text5); |
|
|
|
tmp_array = shuffle(tmp_array); |
|
|
|
tmp_array = shuffle(tmp_array); |
|
|
|
for(var i = 0; i<tmp_array.length;i++){ |
|
|
|
for(var i = 0; i<tmp_array.length;i++){ |
|
|
|
tmp_array[i].draggable({ |
|
|
|
tmp_array[i].draggable({ |
|
|
@ -491,6 +485,7 @@ function showExample(){ |
|
|
|
zIndex:100, |
|
|
|
zIndex:100, |
|
|
|
appendTo: '#data' |
|
|
|
appendTo: '#data' |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
tmp_array[i].find(".text_cont").css("margin", "21px 0px"); |
|
|
|
tmp_array[i].appendTo(all_imgs); |
|
|
|
tmp_array[i].appendTo(all_imgs); |
|
|
|
} |
|
|
|
} |
|
|
|
all_imgs.sortable(); |
|
|
|
all_imgs.sortable(); |
|
|
@ -531,6 +526,15 @@ function showExample(){ |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//add text block
|
|
|
|
|
|
|
|
function addText(dest, source){ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var text_block = $("<div class='img_block' style='text-align: center;'>").insertBefore(source); |
|
|
|
|
|
|
|
$("<div class='close_img'>").appendTo(text_block);
|
|
|
|
|
|
|
|
$("<input type='hidden' value='" + dest.find("input[name='mask']").val() + "'/>").appendTo(text_block); |
|
|
|
|
|
|
|
$("<div class='text_cont' contenteditable='true'>" + sankoreLang.text + "</div>").appendTo(text_block);
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//function that allows to add new category
|
|
|
|
//function that allows to add new category
|
|
|
|
function addCategory(obj){ |
|
|
|
function addCategory(obj){ |
|
|
|
var imgs_container = $("<div class='imgs_cont def_cont'>").insertAfter(obj);
|
|
|
|
var imgs_container = $("<div class='imgs_cont def_cont'>").insertAfter(obj);
|
|
|
@ -538,12 +542,9 @@ function addCategory(obj){ |
|
|
|
$("<input type='hidden' name='count' value=''/>").appendTo(imgs_container);
|
|
|
|
$("<input type='hidden' name='count' value=''/>").appendTo(imgs_container);
|
|
|
|
var tmp_div = $("<div style='width: 100%; overflow: hidden;'>").appendTo(imgs_container); |
|
|
|
var tmp_div = $("<div style='width: 100%; overflow: hidden;'>").appendTo(imgs_container); |
|
|
|
$("<input type='text' class='cat_desc' value='" + sankoreLang.enter + "'>").appendTo(tmp_div);
|
|
|
|
$("<input type='text' class='cat_desc' value='" + sankoreLang.enter + "'>").appendTo(tmp_div);
|
|
|
|
$("<button class='del_category'>-</button>").appendTo(imgs_container); |
|
|
|
$("<button class='del_category'></button>").appendTo(imgs_container); |
|
|
|
$("<button class='add_category'>+</button>").appendTo(imgs_container); |
|
|
|
$("<button class='add_category'></button>").appendTo(imgs_container); |
|
|
|
imgs_container.attr("ondragenter", "return false;") |
|
|
|
$("<div class='add_img'>").appendTo(imgs_container); |
|
|
|
.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);"); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//add new container
|
|
|
|
//add new container
|
|
|
@ -559,12 +560,9 @@ function addContainer(){ |
|
|
|
$("<input type='hidden' name='count' value=''/>").appendTo(imgs_container);
|
|
|
|
$("<input type='hidden' name='count' value=''/>").appendTo(imgs_container);
|
|
|
|
var tmp_div = $("<div style='width: 100%; overflow: hidden;'>").appendTo(imgs_container); |
|
|
|
var tmp_div = $("<div style='width: 100%; overflow: hidden;'>").appendTo(imgs_container); |
|
|
|
$("<input type='text' class='cat_desc' value='" + sankoreLang.enter + "'/>").appendTo(tmp_div);
|
|
|
|
$("<input type='text' class='cat_desc' value='" + sankoreLang.enter + "'/>").appendTo(tmp_div);
|
|
|
|
$("<button class='del_category'>-</button>").appendTo(imgs_container); |
|
|
|
$("<button class='del_category'></button>").appendTo(imgs_container); |
|
|
|
$("<button class='add_category'>+</button>").appendTo(imgs_container); |
|
|
|
$("<button class='add_category'></button>").appendTo(imgs_container); |
|
|
|
imgs_container.attr("ondragenter", "return false;") |
|
|
|
$("<div class='add_img'>").appendTo(imgs_container); |
|
|
|
.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")); |
|
|
|
container.insertBefore($(".add_block")); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -590,6 +588,24 @@ function shuffle( arr ) |
|
|
|
return arr; |
|
|
|
return arr; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function stringToXML(text){ |
|
|
|
|
|
|
|
if (window.ActiveXObject){ |
|
|
|
|
|
|
|
var doc=new ActiveXObject('Microsoft.XMLDOM'); |
|
|
|
|
|
|
|
doc.async='false'; |
|
|
|
|
|
|
|
doc.loadXML(text); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
var parser=new DOMParser(); |
|
|
|
|
|
|
|
doc=parser.parseFromString(text,'text/xml'); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return doc; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//return id
|
|
|
|
|
|
|
|
function returnId(){ |
|
|
|
|
|
|
|
var tmp = Math.random().toString(); |
|
|
|
|
|
|
|
return tmp.substr(2); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//changing the style
|
|
|
|
//changing the style
|
|
|
|
function changeStyle(val){ |
|
|
|
function changeStyle(val){ |
|
|
|
if(val == 1){ |
|
|
|
if(val == 1){ |
|
|
@ -623,24 +639,6 @@ function changeStyle(val){ |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function stringToXML(text){ |
|
|
|
|
|
|
|
if (window.ActiveXObject){ |
|
|
|
|
|
|
|
var doc=new ActiveXObject('Microsoft.XMLDOM'); |
|
|
|
|
|
|
|
doc.async='false'; |
|
|
|
|
|
|
|
doc.loadXML(text); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
var parser=new DOMParser(); |
|
|
|
|
|
|
|
doc=parser.parseFromString(text,'text/xml'); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return doc; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//return id
|
|
|
|
|
|
|
|
function returnId(){ |
|
|
|
|
|
|
|
var tmp = Math.random().toString(); |
|
|
|
|
|
|
|
return tmp.substr(2); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//a func for checking when smth will drop
|
|
|
|
//a func for checking when smth will drop
|
|
|
|
function checkOnDrop(dest, source){ |
|
|
|
function checkOnDrop(dest, source){ |
|
|
|
dest.append(source);
|
|
|
|
dest.append(source);
|
|
|
@ -696,60 +694,3 @@ function checkCorrectness(source){ |
|
|
|
.addClass("red_cont"); |
|
|
|
.addClass("red_cont"); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function onDropTarget(obj, event) { |
|
|
|
|
|
|
|
if (event.dataTransfer) { |
|
|
|
|
|
|
|
var format = "text/plain"; |
|
|
|
|
|
|
|
var textData = event.dataTransfer.getData(format); |
|
|
|
|
|
|
|
if (!textData) { |
|
|
|
|
|
|
|
alert(":("); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
textData = stringToXML(textData); |
|
|
|
|
|
|
|
if(textData.getElementsByTagName("ready")[0].firstChild.textContent == "true"){ |
|
|
|
|
|
|
|
var tmp = textData.getElementsByTagName("path")[0].firstChild.textContent; |
|
|
|
|
|
|
|
var img_block = $("<div class='img_block' style='text-align: center;'>"); |
|
|
|
|
|
|
|
$("<div class='close_img'>").appendTo(img_block);
|
|
|
|
|
|
|
|
$("<input type='hidden' value='" + $(obj).find("input[name='mask']").val() + "'/>").appendTo(img_block); |
|
|
|
|
|
|
|
var tmp_img = $("<img style='display: inline;'/>").attr("src", tmp).appendTo(img_block); |
|
|
|
|
|
|
|
img_block.draggable({ |
|
|
|
|
|
|
|
helper:'clone', |
|
|
|
|
|
|
|
zIndex:100, |
|
|
|
|
|
|
|
appendTo: '#data' |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
$(obj).append(img_block); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(tmp_img.height() == 0){ |
|
|
|
|
|
|
|
var tmp_id = setInterval(function(){ |
|
|
|
|
|
|
|
if(tmp_img.height() != 0){ |
|
|
|
|
|
|
|
if(tmp_img.height() >= tmp_img.width()) |
|
|
|
|
|
|
|
tmp_img.attr("height", "120"); |
|
|
|
|
|
|
|
else{ |
|
|
|
|
|
|
|
tmp_img.attr("width","120"); |
|
|
|
|
|
|
|
tmp_img.css("margin",(120 - tmp_img.height())/2 + "px 0"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
clearInterval(tmp_id); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}, 10); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
if(tmp_img.height() >= tmp_img.width()) |
|
|
|
|
|
|
|
tmp_img.attr("height", "120"); |
|
|
|
|
|
|
|
else{ |
|
|
|
|
|
|
|
tmp_img.attr("width","120"); |
|
|
|
|
|
|
|
tmp_img.css("margin",(120 - tmp_img.height())/2 + "px 0"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
exportData(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else { |
|
|
|
|
|
|
|
alert ("Your browser does not support the dataTransfer object."); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (event.stopPropagation) { |
|
|
|
|
|
|
|
event.stopPropagation (); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else { |
|
|
|
|
|
|
|
event.cancelBubble = true; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|