").appendTo(sub_container);
for(var j in data[i].blocks){
switch(data[i].blocks[j].type){
case "text":
var text_block = $("
").insertBefore(imgs_container.find(".clear"));
$("
" + data[i].blocks[j].text + "
").appendTo(text_block);
$("
").appendTo(text_block);
$("
").appendTo(text_block);
break;
case "img":
var img_block = $("
").insertBefore(imgs_container.find(".clear"));
$("
").appendTo(img_block);
$("
").appendTo(img_block)
$("
").appendTo(img_block);
break;
case "audio":
var img_tmp = $("
").insertBefore(imgs_container.find(".clear"));
var audio_block = $("
").appendTo(img_tmp);
$("
").appendTo(img_tmp);
$("
").appendTo(audio_block);
$("
").appendTo(audio_block);
var source = $("
").attr("src", "../../" + data[i].blocks[j].src);
var audio = $("
").appendTo(audio_block);
audio.append(source);
$(" ").appendTo(img_tmp);
$(" ").appendTo(img_tmp)
break;
}
}
}
}
//example
function showExample(){
var container = $("");
var sub_container = $("
").appendTo(container);
var imgs_container = $("
").appendTo(container);
$("
1
").appendTo(sub_container);
$("
" + sankoreLang.short_desc + "
").appendTo(sub_container);
var tmp1 = $("
").appendTo(imgs_container);
$("
" + sankoreLang.cat + "
").appendTo(tmp1);
$("
").appendTo(tmp1);
$("
").appendTo(tmp1)
var tmp2 = $("
").appendTo(imgs_container);
$("
" + sankoreLang.ball + "
").appendTo(tmp2);
$("
").appendTo(tmp2);
$("
").appendTo(tmp2)
var tmp3 = $("
").appendTo(imgs_container);
$("
" + sankoreLang.shovel + "
").appendTo(tmp3);
$("
").appendTo(tmp3);
$("
").appendTo(tmp3)
var tmp4 = $("
").appendTo(imgs_container);
$("
" + sankoreLang.dog + "
").appendTo(tmp4);
$("
").appendTo(tmp4);
$("
").appendTo(tmp4)
var tmp5 = $("
").appendTo(imgs_container);
$("
" + sankoreLang.tree + "
").appendTo(tmp5);
$("
").appendTo(tmp5);
$("
").appendTo(tmp5)
$("
").appendTo(imgs_container);
container.appendTo("body")
}
//add new container
function addContainer(){
var container = $("
");
var sub_container = $("
").appendTo(container);
var imgs_container = $("
").appendTo(container);
imgs_container.attr("ondragenter", "return false;")
.attr("ondragleave", "$(this).removeClass('over'); return false;")
.attr("ondragover", "$(this).addClass('over'); return false;")
.attr("ondrop", "$(this).removeClass('over'); return onDropTarget(this,event);");
$("
").appendTo(container);
$("
"+ ($(".cont").size() + 1) +"
").appendTo(sub_container);
var text = $("
" + sankoreLang.enter + "
").appendTo(sub_container);
$("
").appendTo(imgs_container);
$("
").appendTo(imgs_container);
container.insertBefore($(".add_block"));
}
//add new img block
function addTextBlock(dest){
var tmp = $("
").insertBefore(dest)
$("
" + sankoreLang.enter + "
").appendTo(tmp);
$("
").appendTo(tmp);
$("
").appendTo(tmp);
$("
").appendTo(tmp);
}
function refreshBlockNumbers(){
var i = 0;
$(".cont").each(function(){
$(this).find(".number_cont").text(++i);
})
}
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;
}
function onDropTarget(obj, event) {
if (event.dataTransfer) {
var format = "text/plain";
var textData = event.dataTransfer.getData(format);
if (!textData) {
alert(":(");
}
textData = stringToXML(textData);
var tmp = textData.getElementsByTagName("path")[0].firstChild.textContent;
var tmp_type = textData.getElementsByTagName("type")[0].firstChild.textContent;
tmp = tmp.substr(1, tmp.length);
if(tmp_type.substr(0, 5) == "audio"){
var img_tmp = $("
").insertBefore($(obj).find(".add_img"));
var audio_block = $("
").appendTo(img_tmp)
$("
").appendTo(img_tmp);
$("
").appendTo(audio_block);
$("
").appendTo(audio_block);
var source = $("
").attr("src", "../../" + tmp);
var audio = $("
").appendTo(audio_block);
audio.append(source);
$(" ").appendTo(img_tmp);
$(" ").appendTo(img_tmp)
} else {
var img_block = $("
").insertBefore($(obj).find(".add_img"));
$("").appendTo(img_block);
$("
").appendTo(img_block);
$("
").appendTo(img_block)
var tmp_img = $("
").appendTo(img_block);
setTimeout(function(){
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");
}
}, 6);
}
}
else {
alert ("Your browser does not support the dataTransfer object.");
}
if (event.stopPropagation) {
event.stopPropagation ();
}
else {
event.cancelBubble = true;
}
return false;
}