").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);
+ $("
").attr("checked",(data[i].blocks[j].state == "display")?((data[i].blocks[j].checked == "checked")?true:false):false).appendTo(text_block);
+ break;
+ case "img":
+ var img_block = $("
").insertBefore(imgs_container.find(".clear"));
+ $("
").appendTo(img_block);
+ $("
").attr("checked",(data[i].blocks[j].state == "display")?((data[i].blocks[j].checked == "checked")?true:false):false).appendTo(img_block)
+ $("
").appendTo(img_block);
+ break;
+ case "audio":
+ var img_tmp = $("
").insertBefore(imgs_container.find(".clear"));
+ var audio_block = $("
").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);
+ $(" ").attr("checked",(data[i].blocks[j].state == "display")?((data[i].blocks[j].checked == "checked")?true:false):false).appendTo(img_tmp)
+ break;
+ }
+ }
+ }
+
+ var block = $("input:checkbox").parent().parent();
+ block.each(function(){
+ var flag = true;
+ $(this).find(".text_block, .img_block, .audio_block").each(function(){
+ if($(this).find("input:checkbox").is(':checked') && $(this).find("input:hidden").val() == 0)
+ flag = false;
+ else if(!$(this).find("input:checkbox").is(':checked') && $(this).find("input:hidden").val() == 1)
+ flag = false;
+ });
+ if(flag)
+ $(this).addClass("right");
+ else
+ $(this).removeClass("right");
+ })
+}
+
+//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("#data")
+}
+
+//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;
+}
+
+//changing the style
+function changeStyle(val){
+ if(val == 1){
+ $(".b_top_left").removeClass("btl_pad");
+ $(".b_top_center").removeClass("btc_pad");
+ $(".b_top_right").removeClass("btr_pad");
+ $(".b_center_left").removeClass("bcl_pad");
+ $(".b_center_right").removeClass("bcr_pad");
+ $(".b_bottom_right").removeClass("bbr_pad");
+ $(".b_bottom_left").removeClass("bbl_pad");
+ $(".b_bottom_center").removeClass("bbc_pad");
+ $("#wgt_reload").removeClass("pad_color").removeClass("pad_reload");
+ $("#wgt_edit").removeClass("pad_color").removeClass("pad_edit");
+ $("#wgt_display").removeClass("pad_color").removeClass("pad_edit");
+ $("#wgt_name").removeClass("pad_color");
+ $(".style_select").removeClass("pad_select");
+ } else {
+ $(".b_top_left").addClass("btl_pad");
+ $(".b_top_center").addClass("btc_pad");
+ $(".b_top_right").addClass("btr_pad");
+ $(".b_center_left").addClass("bcl_pad");
+ $(".b_center_right").addClass("bcr_pad");
+ $(".b_bottom_right").addClass("bbr_pad");
+ $(".b_bottom_left").addClass("bbl_pad");
+ $(".b_bottom_center").addClass("bbc_pad");
+ $("#wgt_reload").addClass("pad_color").addClass("pad_reload");
+ $("#wgt_edit").addClass("pad_color").addClass("pad_edit");
+ $("#wgt_display").addClass("pad_color").addClass("pad_edit");
+ $("#wgt_name").addClass("pad_color");
+ $(".style_select").addClass("pad_select");
+ }
+}
+
+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;
+ 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;
+}
+
diff --git a/resources/library/interactivities/Selectionner.wgt/locales/fr/js/script.js b/resources/library/interactivities/Selectionner.wgt/locales/fr/js/script.js
new file mode 100644
index 00000000..4a9a4d99
--- /dev/null
+++ b/resources/library/interactivities/Selectionner.wgt/locales/fr/js/script.js
@@ -0,0 +1,480 @@
+var sankoreLang = {
+ display: "Afficher",
+ edit: "Modifier",
+ short_desc: "Sélectionner les animaux dans la liste suivante:",
+ add: "Nouveau bloc",
+ enter: "Saisir votre consigne ici ...",
+ cat: "chat",
+ ball: "balle",
+ shovel: "pelle",
+ dog: "chien",
+ tree: "arbre",
+ wgt_name: "Sélectionner",
+ reload: "Recharger",
+ slate: "Bois",
+ pad: "Pad"
+};
+
+//main function
+function start(){
+
+ $("#wgt_display").text(sankoreLang.display);
+ $("#wgt_edit").text(sankoreLang.edit);
+ $("#wgt_name").text(sankoreLang.wgt_name);
+ $("#wgt_reload").text(sankoreLang.reload);
+ $(".style_select option[value='1']").text(sankoreLang.slate);
+ $(".style_select option[value='2']").text(sankoreLang.pad);
+
+ if(window.sankore){
+ if(sankore.preference("selectionner","")){
+ var data = jQuery.parseJSON(sankore.preference("selectionner",""));
+ importData(data);
+ } else
+ showExample();
+ if(sankore.preference("sel_style","")){
+ changeStyle(sankore.preference("sel_style",""));
+ $(".style_select").val(sankore.preference("sel_style",""));
+ } else
+ changeStyle(1)
+ }
+ else
+ showExample();
+
+ //events
+ if (window.widget) {
+ window.widget.onleave = function(){
+ exportData();
+ sankore.setPreference("sel_style", $(".style_select").find("option:selected").val());
+ }
+ }
+
+ $("#wgt_reload").click(function(){
+ window.location.reload();
+ });
+
+ $(".style_select").change(function (event){
+ changeStyle($(this).find("option:selected").val());
+ })
+
+ $("#wgt_display, #wgt_edit").click(function(event){
+ if(this.id == "wgt_display"){
+ if(!$(this).hasClass("selected")){
+ if(window.sankore)
+ sankore.enableDropOnWidget(false);
+ $(this).addClass("selected");
+ $("#wgt_edit").removeClass("selected");
+ $(".style_select").css("display","none");
+ $(".add_block").remove();
+ $(".cont").each(function(){
+ var container = $(this);
+
+ container.find(".text_cont").removeAttr("contenteditable");
+ container.find(".add_img").remove();
+ container.find(".close_cont").remove();
+ container.find(".imgs_cont").removeAttr("ondragenter")
+ .removeAttr("ondragleave")
+ .removeAttr("ondragover")
+ .removeAttr("ondrop");
+ container.find(".img_block, .text_block").each(function(){
+ $(this).find(".close_img").remove();
+ $(this).find(".text_subblock").removeAttr("contenteditable");
+ $(this).find("input:checkbox").removeAttr("checked")
+ });
+
+ });
+ $(this).css("display", "none");
+ $("#wgt_edit").css("display", "block");
+ }
+ } else {
+ if(!$(this).hasClass("selected")){
+ if(window.sankore)
+ sankore.enableDropOnWidget(true);
+ $(this).addClass("selected");
+ $("#wgt_display").removeClass("selected");
+ $(".style_select").css("display","block");
+
+ $(".cont").each(function(){
+ var container = $(this);
+
+ $("
").appendTo(container);
+ container.find(".text_cont").attr("contenteditable","true");
+ container.find(".imgs_cont").removeClass("right")
+ .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);");
+
+ var add_img = $("
");
+ container.find(".img_block, .text_block").each(function(){
+ $("
").appendTo($(this));
+ if($(this).find("input:hidden").val() == 0)
+ $(this).find("input:checkbox").attr('checked', false);
+ else
+ $(this).find("input:checkbox").attr('checked', true);
+ $(this).find(".text_subblock").attr("contenteditable","true");
+ });
+ add_img.insertBefore(container.find(".clear"));
+ });
+
+ $("
" + sankoreLang.add + "
").appendTo("#data");
+ $(this).css("display", "none");
+ $("#wgt_display").css("display", "block");
+ }
+ }
+ });
+
+ //add new block
+ $(".add_block").live("click", function(){
+ addContainer();
+ });
+
+ //checkbox events
+ $("input:checkbox").live("click", function(){
+ if($("#wgt_display").hasClass("selected")){
+ var flag = true;
+ var block = $(this).parent().parent();
+ block.find(".text_block, .img_block, .audio_block").each(function(){
+ if($(this).find("input:checkbox").is(':checked') && $(this).find("input:hidden").val() == 0)
+ flag = false;
+ else if(!$(this).find("input:checkbox").is(':checked') && $(this).find("input:hidden").val() == 1)
+ flag = false;
+ });
+ if(flag)
+ block.addClass("right");
+ else
+ block.removeClass("right");
+ } else {
+ if($(this).is(":checked"))
+ $(this).parent().find("input:hidden").val(1);
+ else
+ $(this).parent().find("input:hidden").val(0);
+ }
+ });
+
+ //play/pause event
+ $(".play, .stop").live("click", function(){
+ var tmp_audio = $(this);
+ var audio = tmp_audio.parent().find("audio").get(0);
+ if($(this).hasClass("play")){
+ if(tmp_audio.parent().find("source").attr("src")){
+ tmp_audio.removeClass("play").addClass("stop");
+ var id = setInterval(function(){
+ if(audio.currentTime == audio.duration){
+ clearInterval(id);
+ tmp_audio.removeClass("stop").addClass("play");
+ }
+ }, 10);
+ tmp_audio.parent().find("input").val(id);
+ audio.play();
+ }
+ } else {
+ $(this).removeClass("stop").addClass("play");
+ clearInterval( tmp_audio.parent().find("input").val())
+ audio.pause();
+ }
+ });
+
+ $(".replay").live("click", function(){
+ var tmp_audio = $(this).prev();
+ var audio = $(this).parent().find("audio").get(0);
+ if(tmp_audio.parent().find("source").attr("src")){
+ $(this).prev().removeClass("play").addClass("stop");
+ clearInterval($(this).parent().find("input").val());
+ var id = setInterval(function(){
+ if(audio.currentTime == audio.duration){
+ clearInterval(id);
+ tmp_audio.removeClass("stop").addClass("play");
+ }
+ }, 10);
+ tmp_audio.parent().find("input").val(id);
+ audio.currentTime = 0;
+ audio.play();
+ }
+ });
+
+ //adding new img
+ $(".add_img").live("click", function(){
+ addTextBlock($(this));
+ });
+
+ //deleting a block
+ $(".close_cont").live("click",function(){
+ $(this).parent().remove();
+ refreshBlockNumbers();
+ });
+
+ //deleting the img block
+ $(".close_img").live("click", function(){
+ $(this).parent().remove();
+ });
+
+
+}
+
+//export
+function exportData(){
+ var array_to_export = [];
+ $(".cont").each(function(){
+ var cont_obj = new Object();
+ cont_obj.text = $(this).find(".text_cont").text();
+ cont_obj.blocks = [];
+ $(this).find(".img_block, .audio_block, .text_block").each(function(){
+ var tmp_block = new Object();
+ if($("#wgt_display").hasClass("selected"))
+ tmp_block.state = "display";
+ else
+ tmp_block.state = "edit";
+ if($(this).hasClass("img_block")){
+ if($(this).find(".audio_block").size() == 0){
+ tmp_block.src = $(this).find("img").attr("src").replace("../../","");
+ tmp_block.hidden = $(this).find("input:hidden").val();
+ tmp_block.h = $(this).find("img").height();
+ tmp_block.w = $(this).find("img").width();
+ tmp_block.type = "img";
+ tmp_block.checked = $(this).find("input:checkbox").attr("checked");
+ }
+ }
+ if($(this).hasClass("audio_block")){
+ tmp_block.src = $(this).find("source").attr("src").replace("../../","");
+ tmp_block.hidden = $(this).parent().find("input:hidden").val();
+ tmp_block.type = "audio";
+ tmp_block.checked = $(this).find("input:checkbox").attr("checked");
+ }
+ if($(this).hasClass("text_block")){
+ tmp_block.text = $(this).find(".text_subblock").text();
+ tmp_block.hidden = $(this).find("input:hidden").val();
+ tmp_block.type = "text";
+ tmp_block.checked = $(this).find("input:checkbox").attr("checked");
+ }
+ cont_obj.blocks.push(tmp_block);
+ });
+ array_to_export.push(cont_obj);
+ });
+
+ sankore.setPreference("selectionner", JSON.stringify(array_to_export));
+}
+
+//import
+function importData(data){
+
+ var tmp = 0;
+ for(var i in data){
+
+ var container = $("
").appendTo("#data");
+ var sub_container = $("
").appendTo(container);
+ var imgs_container = $("
").appendTo(container);
+ $("
").appendTo(imgs_container);
+
+ $("
" + (++tmp) + "
").appendTo(sub_container);
+ $("
" + data[i].text + "
").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);
+ $("
").attr("checked",(data[i].blocks[j].state == "display")?((data[i].blocks[j].checked == "checked")?true:false):false).appendTo(text_block);
+ break;
+ case "img":
+ var img_block = $("
").insertBefore(imgs_container.find(".clear"));
+ $("
").appendTo(img_block);
+ $("
").attr("checked",(data[i].blocks[j].state == "display")?((data[i].blocks[j].checked == "checked")?true:false):false).appendTo(img_block)
+ $("
").appendTo(img_block);
+ break;
+ case "audio":
+ var img_tmp = $("
").insertBefore(imgs_container.find(".clear"));
+ var audio_block = $("
").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);
+ $(" ").attr("checked",(data[i].blocks[j].state == "display")?((data[i].blocks[j].checked == "checked")?true:false):false).appendTo(img_tmp)
+ break;
+ }
+ }
+ }
+
+ var block = $("input:checkbox").parent().parent();
+ block.each(function(){
+ var flag = true;
+ $(this).find(".text_block, .img_block, .audio_block").each(function(){
+ if($(this).find("input:checkbox").is(':checked') && $(this).find("input:hidden").val() == 0)
+ flag = false;
+ else if(!$(this).find("input:checkbox").is(':checked') && $(this).find("input:hidden").val() == 1)
+ flag = false;
+ });
+ if(flag)
+ $(this).addClass("right");
+ else
+ $(this).removeClass("right");
+ })
+}
+
+//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("#data")
+}
+
+//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;
+}
+
+
+//changing the style
+function changeStyle(val){
+ if(val == 1){
+ $(".b_top_left").removeClass("btl_pad");
+ $(".b_top_center").removeClass("btc_pad");
+ $(".b_top_right").removeClass("btr_pad");
+ $(".b_center_left").removeClass("bcl_pad");
+ $(".b_center_right").removeClass("bcr_pad");
+ $(".b_bottom_right").removeClass("bbr_pad");
+ $(".b_bottom_left").removeClass("bbl_pad");
+ $(".b_bottom_center").removeClass("bbc_pad");
+ $("#wgt_reload").removeClass("pad_color").removeClass("pad_reload");
+ $("#wgt_edit").removeClass("pad_color").removeClass("pad_edit");
+ $("#wgt_display").removeClass("pad_color").removeClass("pad_edit");
+ $("#wgt_name").removeClass("pad_color");
+ $(".style_select").removeClass("pad_select");
+ } else {
+ $(".b_top_left").addClass("btl_pad");
+ $(".b_top_center").addClass("btc_pad");
+ $(".b_top_right").addClass("btr_pad");
+ $(".b_center_left").addClass("bcl_pad");
+ $(".b_center_right").addClass("bcr_pad");
+ $(".b_bottom_right").addClass("bbr_pad");
+ $(".b_bottom_left").addClass("bbl_pad");
+ $(".b_bottom_center").addClass("bbc_pad");
+ $("#wgt_reload").addClass("pad_color").addClass("pad_reload");
+ $("#wgt_edit").addClass("pad_color").addClass("pad_edit");
+ $("#wgt_display").addClass("pad_color").addClass("pad_edit");
+ $("#wgt_name").addClass("pad_color");
+ $(".style_select").addClass("pad_select");
+ }
+}
+
+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;
+ 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;
+}
diff --git a/resources/library/interactivities/Selectionner.wgt/locales/ru/js/script.js b/resources/library/interactivities/Selectionner.wgt/locales/ru/js/script.js
new file mode 100644
index 00000000..f4870852
--- /dev/null
+++ b/resources/library/interactivities/Selectionner.wgt/locales/ru/js/script.js
@@ -0,0 +1,478 @@
+var sankoreLang = {
+ display: "Показать",
+ edit: "Изменить",
+ short_desc: "Выберите животных из следующего списка:",
+ add: "Новый блок",
+ enter: "Введите текст ...",
+ cat: "кот",
+ ball: "мяч",
+ shovel: "лопата",
+ dog: "собака",
+ tree: "дерево",
+ wgt_name: "Выбрать верное",
+ reload: "Обновить",
+ slate: "Узор",
+ pad: "Планшет"
+};
+
+//main function
+function start(){
+
+ $("#wgt_display").text(sankoreLang.display);
+ $("#wgt_edit").text(sankoreLang.edit);
+ $("#wgt_name").text(sankoreLang.wgt_name);
+ $("#wgt_reload").text(sankoreLang.reload);
+ $(".style_select option[value='1']").text(sankoreLang.slate);
+ $(".style_select option[value='2']").text(sankoreLang.pad);
+
+ if(window.sankore){
+ if(sankore.preference("selectionner","")){
+ var data = jQuery.parseJSON(sankore.preference("selectionner",""));
+ importData(data);
+ } else
+ showExample();
+ if(sankore.preference("sel_style","")){
+ changeStyle(sankore.preference("sel_style",""));
+ $(".style_select").val(sankore.preference("sel_style",""));
+ } else
+ changeStyle(1)
+ }
+ else
+ showExample();
+
+ //events
+ if (window.widget) {
+ window.widget.onleave = function(){
+ exportData();
+ sankore.setPreference("sel_style", $(".style_select").find("option:selected").val());
+ }
+ }
+
+ $("#wgt_reload").click(function(){
+ window.location.reload();
+ });
+
+ $(".style_select").change(function (event){
+ changeStyle($(this).find("option:selected").val());
+ })
+
+ $("#wgt_display, #wgt_edit").click(function(event){
+ if(this.id == "wgt_display"){
+ if(!$(this).hasClass("selected")){
+ if(window.sankore)
+ sankore.enableDropOnWidget(false);
+ $(this).addClass("selected");
+ $("#wgt_edit").removeClass("selected");
+ $(".style_select").css("display","none");
+ $(".add_block").remove();
+ $(".cont").each(function(){
+ var container = $(this);
+
+ container.find(".text_cont").removeAttr("contenteditable");
+ container.find(".add_img").remove();
+ container.find(".close_cont").remove();
+ container.find(".imgs_cont").removeAttr("ondragenter")
+ .removeAttr("ondragleave")
+ .removeAttr("ondragover")
+ .removeAttr("ondrop");
+ container.find(".img_block, .text_block").each(function(){
+ $(this).find(".close_img").remove();
+ $(this).find(".text_subblock").removeAttr("contenteditable");
+ $(this).find("input:checkbox").removeAttr("checked")
+ });
+
+ });
+ $(this).css("display", "none");
+ $("#wgt_edit").css("display", "block");
+ }
+ } else {
+ if(!$(this).hasClass("selected")){
+ if(window.sankore)
+ sankore.enableDropOnWidget(true);
+ $(this).addClass("selected");
+ $("#wgt_display").removeClass("selected");
+ $(".style_select").css("display","block");
+
+ $(".cont").each(function(){
+ var container = $(this);
+
+ $("
").appendTo(container);
+ container.find(".text_cont").attr("contenteditable","true");
+ container.find(".imgs_cont").removeClass("right")
+ .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);");
+
+ var add_img = $("
");
+ container.find(".img_block, .text_block").each(function(){
+ $("
").appendTo($(this));
+ if($(this).find("input:hidden").val() == 0)
+ $(this).find("input:checkbox").attr('checked', false);
+ else
+ $(this).find("input:checkbox").attr('checked', true);
+ $(this).find(".text_subblock").attr("contenteditable","true");
+ });
+ add_img.insertBefore(container.find(".clear"));
+ });
+
+ $("
" + sankoreLang.add + "
").appendTo("#data");
+ $(this).css("display", "none");
+ $("#wgt_display").css("display", "block");
+ }
+ }
+ });
+
+ //add new block
+ $(".add_block").live("click", function(){
+ addContainer();
+ });
+
+ //checkbox events
+ $("input:checkbox").live("click", function(){
+ if($("#wgt_display").hasClass("selected")){
+ var flag = true;
+ var block = $(this).parent().parent();
+ block.find(".text_block, .img_block, .audio_block").each(function(){
+ if($(this).find("input:checkbox").is(':checked') && $(this).find("input:hidden").val() == 0)
+ flag = false;
+ else if(!$(this).find("input:checkbox").is(':checked') && $(this).find("input:hidden").val() == 1)
+ flag = false;
+ });
+ if(flag)
+ block.addClass("right");
+ else
+ block.removeClass("right");
+ } else {
+ if($(this).is(":checked"))
+ $(this).parent().find("input:hidden").val(1);
+ else
+ $(this).parent().find("input:hidden").val(0);
+ }
+ });
+
+ //play/pause event
+ $(".play, .stop").live("click", function(){
+ var tmp_audio = $(this);
+ var audio = tmp_audio.parent().find("audio").get(0);
+ if($(this).hasClass("play")){
+ if(tmp_audio.parent().find("source").attr("src")){
+ tmp_audio.removeClass("play").addClass("stop");
+ var id = setInterval(function(){
+ if(audio.currentTime == audio.duration){
+ clearInterval(id);
+ tmp_audio.removeClass("stop").addClass("play");
+ }
+ }, 10);
+ tmp_audio.parent().find("input").val(id);
+ audio.play();
+ }
+ } else {
+ $(this).removeClass("stop").addClass("play");
+ clearInterval( tmp_audio.parent().find("input").val())
+ audio.pause();
+ }
+ });
+
+ $(".replay").live("click", function(){
+ var tmp_audio = $(this).prev();
+ var audio = $(this).parent().find("audio").get(0);
+ if(tmp_audio.parent().find("source").attr("src")){
+ $(this).prev().removeClass("play").addClass("stop");
+ clearInterval($(this).parent().find("input").val());
+ var id = setInterval(function(){
+ if(audio.currentTime == audio.duration){
+ clearInterval(id);
+ tmp_audio.removeClass("stop").addClass("play");
+ }
+ }, 10);
+ tmp_audio.parent().find("input").val(id);
+ audio.currentTime = 0;
+ audio.play();
+ }
+ });
+
+ //adding new img
+ $(".add_img").live("click", function(){
+ addTextBlock($(this));
+ });
+
+ //deleting a block
+ $(".close_cont").live("click",function(){
+ $(this).parent().remove();
+ refreshBlockNumbers();
+ });
+
+ //deleting the img block
+ $(".close_img").live("click", function(){
+ $(this).parent().remove();
+ });
+}
+
+//export
+function exportData(){
+ var array_to_export = [];
+ $(".cont").each(function(){
+ var cont_obj = new Object();
+ cont_obj.text = $(this).find(".text_cont").text();
+ cont_obj.blocks = [];
+ $(this).find(".img_block, .audio_block, .text_block").each(function(){
+ var tmp_block = new Object();
+ if($("#wgt_display").hasClass("selected"))
+ tmp_block.state = "display";
+ else
+ tmp_block.state = "edit";
+ if($(this).hasClass("img_block")){
+ if($(this).find(".audio_block").size() == 0){
+ tmp_block.src = $(this).find("img").attr("src").replace("../../","");
+ tmp_block.hidden = $(this).find("input:hidden").val();
+ tmp_block.h = $(this).find("img").height();
+ tmp_block.w = $(this).find("img").width();
+ tmp_block.type = "img";
+ tmp_block.checked = $(this).find("input:checkbox").attr("checked");
+ }
+ }
+ if($(this).hasClass("audio_block")){
+ tmp_block.src = $(this).find("source").attr("src").replace("../../","");
+ tmp_block.hidden = $(this).parent().find("input:hidden").val();
+ tmp_block.type = "audio";
+ tmp_block.checked = $(this).find("input:checkbox").attr("checked");
+ }
+ if($(this).hasClass("text_block")){
+ tmp_block.text = $(this).find(".text_subblock").text();
+ tmp_block.hidden = $(this).find("input:hidden").val();
+ tmp_block.type = "text";
+ tmp_block.checked = $(this).find("input:checkbox").attr("checked");
+ }
+ cont_obj.blocks.push(tmp_block);
+ });
+ array_to_export.push(cont_obj);
+ });
+
+ sankore.setPreference("selectionner", JSON.stringify(array_to_export));
+}
+
+//import
+function importData(data){
+
+ var tmp = 0;
+ for(var i in data){
+
+ var container = $("
").appendTo("#data");
+ var sub_container = $("
").appendTo(container);
+ var imgs_container = $("
").appendTo(container);
+ $("
").appendTo(imgs_container);
+
+ $("
" + (++tmp) + "
").appendTo(sub_container);
+ $("
" + data[i].text + "
").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);
+ $("
").attr("checked",(data[i].blocks[j].state == "display")?((data[i].blocks[j].checked == "checked")?true:false):false).appendTo(text_block);
+ break;
+ case "img":
+ var img_block = $("
").insertBefore(imgs_container.find(".clear"));
+ $("
").appendTo(img_block);
+ $("
").attr("checked",(data[i].blocks[j].state == "display")?((data[i].blocks[j].checked == "checked")?true:false):false).appendTo(img_block)
+ $("
").appendTo(img_block);
+ break;
+ case "audio":
+ var img_tmp = $("
").insertBefore(imgs_container.find(".clear"));
+ var audio_block = $("
").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);
+ $(" ").attr("checked",(data[i].blocks[j].state == "display")?((data[i].blocks[j].checked == "checked")?true:false):false).appendTo(img_tmp)
+ break;
+ }
+ }
+ }
+
+ var block = $("input:checkbox").parent().parent();
+ block.each(function(){
+ var flag = true;
+ $(this).find(".text_block, .img_block, .audio_block").each(function(){
+ if($(this).find("input:checkbox").is(':checked') && $(this).find("input:hidden").val() == 0)
+ flag = false;
+ else if(!$(this).find("input:checkbox").is(':checked') && $(this).find("input:hidden").val() == 1)
+ flag = false;
+ });
+ if(flag)
+ $(this).addClass("right");
+ else
+ $(this).removeClass("right");
+ })
+}
+
+//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("#data")
+}
+
+//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;
+}
+
+
+//changing the style
+function changeStyle(val){
+ if(val == 1){
+ $(".b_top_left").removeClass("btl_pad");
+ $(".b_top_center").removeClass("btc_pad");
+ $(".b_top_right").removeClass("btr_pad");
+ $(".b_center_left").removeClass("bcl_pad");
+ $(".b_center_right").removeClass("bcr_pad");
+ $(".b_bottom_right").removeClass("bbr_pad");
+ $(".b_bottom_left").removeClass("bbl_pad");
+ $(".b_bottom_center").removeClass("bbc_pad");
+ $("#wgt_reload").removeClass("pad_color").removeClass("pad_reload");
+ $("#wgt_edit").removeClass("pad_color").removeClass("pad_edit");
+ $("#wgt_display").removeClass("pad_color").removeClass("pad_edit");
+ $("#wgt_name").removeClass("pad_color");
+ $(".style_select").removeClass("pad_select");
+ } else {
+ $(".b_top_left").addClass("btl_pad");
+ $(".b_top_center").addClass("btc_pad");
+ $(".b_top_right").addClass("btr_pad");
+ $(".b_center_left").addClass("bcl_pad");
+ $(".b_center_right").addClass("bcr_pad");
+ $(".b_bottom_right").addClass("bbr_pad");
+ $(".b_bottom_left").addClass("bbl_pad");
+ $(".b_bottom_center").addClass("bbc_pad");
+ $("#wgt_reload").addClass("pad_color").addClass("pad_reload");
+ $("#wgt_edit").addClass("pad_color").addClass("pad_edit");
+ $("#wgt_display").addClass("pad_color").addClass("pad_edit");
+ $("#wgt_name").addClass("pad_color");
+ $(".style_select").addClass("pad_select");
+ }
+}
+
+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;
+ 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;
+}
\ No newline at end of file
diff --git a/src/adaptors/UBSvgSubsetAdaptor.cpp b/src/adaptors/UBSvgSubsetAdaptor.cpp
index 39b1bd46..ce4cc401 100644
--- a/src/adaptors/UBSvgSubsetAdaptor.cpp
+++ b/src/adaptors/UBSvgSubsetAdaptor.cpp
@@ -2266,20 +2266,9 @@ void UBSvgSubsetAdaptor::UBSvgSubsetWriter::textItemToSvg(UBGraphicsTextItem* it
//for new documents from version 4.5.0
mXmlWriter.writeStartElement("itemTextContent");
- //TODO:
- // This is only a workaround that works quite well. The font sizes are expressed on
- // px instead of pt because px is less sensitive to the physicalDPI of the Os. The
- // main problem in fact appears when the file is used on another platform than the
- // one used to create it.
- // But a different solution has to be implemented to avoid some annoying case that
- // are already present with this hack.
- QString htmlString = item->toHtml();
- qDebug() << htmlString;
- QRegExp regExp("font-size:([0-9]{,3})pt");
- htmlString = htmlString.replace(regExp,"font-size:\\1px");
- qDebug() << htmlString;
- //mXmlWriter.writeCDATA(htmlString);
- mXmlWriter.writeCharacters(htmlString);
+ // Note: don't use mXmlWriter.writeCDATA(htmlString); because it doesn't escape characters sequences correctly.
+ // Texts copied from other programs like Open-Office can truncate the svg file.
+ mXmlWriter.writeCharacters(item->toHtml());
mXmlWriter.writeEndElement(); //itemTextContent
mXmlWriter.writeEndElement(); //foreignObject