From de2f2fe211445874f46e20e07ce93c205e7423ee Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 14 Feb 2012 13:06:51 +0200 Subject: [PATCH 1/6] fixed blackyellow widget --- .../BlackYellow.wgt/index.html | 27 +- .../BlackYellow.wgt/locales/fr/index.html | 25 ++ .../locales/fr/scripts/blackYellow.js | 408 ++++++++++++++++++ .../BlackYellow.wgt/locales/ru/index.html | 25 ++ .../locales/ru/scripts/blackYellow.js | 408 ++++++++++++++++++ .../BlackYellow.wgt/scripts/blackYellow.js | 57 ++- .../BlackYellow.wgt/scripts/languages.js | 30 -- 7 files changed, 919 insertions(+), 61 deletions(-) create mode 100644 resources/library/interactivities/BlackYellow.wgt/locales/fr/index.html create mode 100644 resources/library/interactivities/BlackYellow.wgt/locales/fr/scripts/blackYellow.js create mode 100644 resources/library/interactivities/BlackYellow.wgt/locales/ru/index.html create mode 100644 resources/library/interactivities/BlackYellow.wgt/locales/ru/scripts/blackYellow.js delete mode 100644 resources/library/interactivities/BlackYellow.wgt/scripts/languages.js diff --git a/resources/library/interactivities/BlackYellow.wgt/index.html b/resources/library/interactivities/BlackYellow.wgt/index.html index a77d4cfd..1701164b 100644 --- a/resources/library/interactivities/BlackYellow.wgt/index.html +++ b/resources/library/interactivities/BlackYellow.wgt/index.html @@ -10,12 +10,35 @@ and open the template in the editor. - diff --git a/resources/library/interactivities/BlackYellow.wgt/locales/fr/index.html b/resources/library/interactivities/BlackYellow.wgt/locales/fr/index.html new file mode 100644 index 00000000..5e41fc07 --- /dev/null +++ b/resources/library/interactivities/BlackYellow.wgt/locales/fr/index.html @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + diff --git a/resources/library/interactivities/BlackYellow.wgt/locales/fr/scripts/blackYellow.js b/resources/library/interactivities/BlackYellow.wgt/locales/fr/scripts/blackYellow.js new file mode 100644 index 00000000..47b56c09 --- /dev/null +++ b/resources/library/interactivities/BlackYellow.wgt/locales/fr/scripts/blackYellow.js @@ -0,0 +1,408 @@ +/* + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +var sankoreLang = {display: "Afficher", edit: "Modifier", add: "Ajouter", enter_data: "Entrer les données:", enter_result: "Entrez le résultat:", ok: "Ок", cancel: "Annuler"}; + +function init(){ + + //variables + var toggleFlag = false; // detects toggling in toggle button + var endFlag = false; // ending of toggling in toggle button + var addToggleStart = false; // detects toggling in add button + var addToggleEnd = false; // ending of toggling in add button + var shadowOver = false; + var mode = false; + var popupFlag = false + var flagForSelect = false; + var dragElement = null; //the element that must be dragging + var lang = ""; //locale language + var coords = { + left:0, + top:0 + } + + var resizeObj = { + y:false, + x:false, + width:0, + height:0 + } + + var opacityChanged = false; + + if(window.sankore){ + if(sankore.preference("blackYellowData","")){ + var importArray = jQuery.parseJSON(sankore.preference("blackYellowData","")); + for(var i in importArray){ + var tmpReadyTask = $("
"); + var exprContainer = $("
" + importArray[i].data1 + "
").appendTo(tmpReadyTask); + var resContainer = $("
"+ importArray[i].data2 + "
").appendTo(tmpReadyTask); + tmpReadyTask.width(importArray[i].width) + .height(importArray[i].height) + .css("position","absolute") + .css("top",importArray[i].top) + .css("left",importArray[i].left); + tmpReadyTask.appendTo("body"); + } + } + $(document).disableTextSelect(); + } + + /* ------------- BUTTONS -------------*/ + + // toggle button + var buttonDiv = $("
").appendTo("body"); + var toggleButton = $("").appendTo("#buttonDiv"); + buttonDiv.css({ + top:"10px", + right:0 + }); + + //toggle mode + toggleButton.click(function(){ + if(!shadowOver){ + if(mode){ + mode = false; + addButtonDiv.css("display","none"); + $(".leftDiv, .rightDiv").animate({ + "opacity":"1" + },"slow",function(){ + if(opacityChanged){ + if($(".editContainer").size() != 0){ + $(".editContainer").each(function(index, domElem){ + var tmpReadyTask = $(domElem).find(".readyTask"); + tmpReadyTask.width($(domElem).width()) + .height($(domElem).height()) + .css("position","absolute") + .css("top",$(domElem).position().top) + .css("left",$(domElem).position().left) + .find(".taskContainer").removeAttr("contenteditable"); + + $(domElem).remove(); + tmpReadyTask.appendTo("body"); + }); + } + opacityChanged = false; + } + }); + $(document).disableTextSelect(); + } else { + mode = true; + addButtonDiv.css("display","block"); + $(document).enableTextSelect(); + $(".leftDiv, .rightDiv").animate({ + "opacity":"0.4" + },"slow",function(){ + if(!opacityChanged){ + if($(".readyTask").size() != 0){ + $(".readyTask").each(function(index, domElem){ + var editContent = $("
").width($(domElem).width() + 10).height($(domElem) + 10).appendTo("body"); + var closeItem = $("
").appendTo(editContent); + var rightResize = $("
").appendTo(editContent); + var bottomResize = $("
").appendTo(editContent); + editContent.css("top", $(domElem).position().top).css("left", $(domElem).position().left); + $(domElem).css("position","static") + .width("100%") + .height("100%") + .find(".taskContainer").attr("contenteditable", "true"); + $(domElem).appendTo(editContent); + }); + } + opacityChanged = true; + } + }); + + } + toggleButton.trigger("mouseout"); + } + }); + + // toggle button events + toggleButton.mouseover(function(){ + if(!shadowOver){ + if(!toggleFlag && !endFlag){ + endFlag = true; + toggleButton.animate({ + width:"115px" + },"fast",function(){ + toggleFlag = true; + if(!mode) + toggleButton.text(sankoreLang.edit); + else + toggleButton.text(sankoreLang.display); + }); + } + } + }); + + toggleButton.mouseout(function(){ + if(!shadowOver){ + if(toggleFlag && endFlag){ + endFlag = false; + toggleButton.animate({ + width:"20px" + },"fast", function(){ + toggleButton.text("<"); + toggleFlag = false; + }); + } + } + }); + + //add button + var addButtonDiv = $("
").appendTo("body"); + var addButton = $("").appendTo("#addButtonDiv"); + addButtonDiv.css({ + top:"47px", + right:0 + }); + + // add button events + addButton.click(function(){ + shadowDiv.show("fast", function(){ + shadowOver = true; + popupBack.show("slow"); + }); + $(document).disableTextSelect(); + addButton.trigger("mouseout"); + }); + + addButton.mouseover(function(){ + if(!shadowOver){ + if(!addToggleStart && !addToggleEnd){ + addToggleEnd = true; + addButton.animate({ + width:"115px" + },"fast",function(){ + addToggleStart = true; + addButton.text(sankoreLang.add); + }); + } + } + }); + + addButton.mouseout(function(){ + if(!shadowOver){ + if(addToggleStart && addToggleEnd){ + addToggleEnd = false; + addButton.animate({ + width:"20px" + },"fast", function(){ + addButton.text("+"); + addToggleStart = false; + }); + } + } + }); + + /* -------------- END OF WORK WITH BUTTONS ---------------*/ + + //basic divs + var leftDiv = $("
").appendTo("body"); + var rightDiv = $("
").appendTo("body"); + + //divs for adding a new item + var shadowDiv = $("
").appendTo("body"); + var popupBack = $("
").appendTo("body"); + + //input fields and buttons for a popup window + var expressionDiv = $("
").appendTo(popupBack); + var experssionLabel = $("" + sankoreLang.enter_data + "").appendTo(expressionDiv); + var expresionText = $("").appendTo(expressionDiv); + + var resultDiv = $("
").appendTo(popupBack); + var resultLabel = $("" + sankoreLang.enter_result + "").appendTo(resultDiv); + var resultText = $("").appendTo(resultDiv); + + var popupButtonsDiv= $("
").appendTo(popupBack); + var cancelButton = $("").appendTo(popupButtonsDiv); + var okButton = $("").appendTo(popupButtonsDiv); + + /* -------------- A WORK WITH POPUP BUTTONS AND FIELDS ---------------*/ + + $("#resultText, #expresionText").keyup(function(){ + if($(this).val()){ + $(this).css("background-color", "#ff9"); + } + }); + + cancelButton.click(function(){ + $(document).enableTextSelect(); + popupBack.hide("slow", function(){ + $("#resultText, #expresionText").val("") + .css("background-color", "#ffc"); + shadowDiv.hide("fast"); + shadowOver = false; + }); + }); + + okButton.click(function(){ + $(document).enableTextSelect(); + if(checkEmptyFields(expresionText) && checkEmptyFields(resultText)){ + popupBack.hide("slow", function(){ + shadowDiv.hide("fast"); + shadowOver = false; + addTask(expresionText.val(), resultText.val()); + $("#resultText, #expresionText").val("") + .css("background-color", "#ffc"); + }) + } + }); + + /* -------------- THE END OF WORK WITH POPUP BUTTONS AND FIELDS ---------------*/ + + // a work with dragging possibility + $("input:text").mouseover(function(){ + $(document).enableTextSelect(); + }); + + $("input:text").mouseout(function(){ + $(document).disableTextSelect(); + }); + + $(".readyTask, .editContainer").live("mousedown",function(event){ + if(!shadowOver){ + dragElement = $(this); + coords.left = event.pageX - $(this).position().left; + coords.top = event.pageY - $(this).position().top; + resizeObj.width = $(this).width(); + resizeObj.height = $(this).height(); + } + }); + + $(".rightResize").live("mousedown",function(event){ + if(!shadowOver){ + resizeObj.x = true; + } + }); + + $(".bottomResize").live("mousedown",function(event){ + if(!shadowOver){ + resizeObj.y = true; + } + }); + + $("body").mouseup(function(event){ + if(!shadowOver){ + dragElement = null; + resizeObj.x = false; + resizeObj.y = false; + } + }); + + $("body").mousemove(function(event){ + if(dragElement && !shadowOver){ + if(resizeObj.x) + dragElement.width(event.pageX - dragElement.position().left); + else if(resizeObj.y) + dragElement.height(event.pageY - dragElement.position().top); + else + dragElement.css("top",event.pageY - coords.top).css("left", event.pageX - coords.left); + } + }); + + //closing item + $(".closeItem").live("click", function(){ + if(!shadowOver){ + $(this).parent().remove(); + } + }); + + $("#leftDiv,#rightDiv,#shadowDiv").css("height", $(window).height()); + popupBack.css("top", ($(window).height() - 138)*50/$(window).height() + "%"); + popupBack.css("left", ($(window).width() - 360)*50/$(window).width() + "%"); + + $(window).resize(function(){ + $("#leftDiv,#rightDiv,#shadowDiv").css("height", $(window).height()); + popupBack.css("top", ($(window).height() - 138)*50/$(window).height() + "%"); + popupBack.css("left", ($(window).width() - 360)*50/$(window).width() + "%"); + }); + + $("html").mouseout(function(){ + if(window.sankore) + exportToSankore(); + }); + + // export data + function exportToSankore(){ + + var arrayToExport = new Array(); + if(mode){ + if($(".editContainer").size() != 0){ + $(".editContainer").each(function(index, domElem){ + var objToExport = { + data1:"", + data2:"", + width:0, + height:0, + top:0, + left:0 + } + objToExport.data1 = $(domElem).find(".readyTask").find(":first-child").text(); + objToExport.data2 = $(domElem).find(".readyTask").find(":last-child").text(); + objToExport.width = $(domElem).width(); + objToExport.height = $(domElem).height(); + objToExport.top = $(domElem).position().top; + objToExport.left = $(domElem).position().left; + arrayToExport.push(objToExport); + }); + } + } else { + if($(".readyTask").size() != 0){ + $(".readyTask").each(function(index, domElem){ + var objToExport = { + data1:"", + data2:"", + width:0, + height:0, + top:0, + left:0 + } + objToExport.data1 = $(domElem).find(":first-child").text(); + objToExport.data2 = $(domElem).find(":last-child").text(); + objToExport.width = $(domElem).width(); + objToExport.height = $(domElem).height(); + objToExport.top = $(domElem).position().top; + objToExport.left = $(domElem).position().left; + arrayToExport.push(objToExport); + }); + } + } + sankore.setPreference("blackYellowData", JSON.stringify(arrayToExport)); + } +} + +//checking empty fields +function checkEmptyFields(field){ + if(field.val() == ""){ + field.css("background-color", "red"); + return false; + } else { + field.css("background-color", "#ff9"); + return true; + } +} + +//adding a new task to the page +function addTask(expression, result){ + var editContent = $("
").width(240).height(70).appendTo("body"); + var closeItem = $("
").appendTo(editContent); + var rightResize = $("
").appendTo(editContent); + var bottomResize = $("
").appendTo(editContent); + var main = $("
"); + var exprContainer = $("
" + expression + "
").appendTo(main); + var resContainer = $("
"+ result + "
").appendTo(main); + main.appendTo(editContent); +} \ No newline at end of file diff --git a/resources/library/interactivities/BlackYellow.wgt/locales/ru/index.html b/resources/library/interactivities/BlackYellow.wgt/locales/ru/index.html new file mode 100644 index 00000000..5e41fc07 --- /dev/null +++ b/resources/library/interactivities/BlackYellow.wgt/locales/ru/index.html @@ -0,0 +1,25 @@ + + + + + + + + + + + + + + + + diff --git a/resources/library/interactivities/BlackYellow.wgt/locales/ru/scripts/blackYellow.js b/resources/library/interactivities/BlackYellow.wgt/locales/ru/scripts/blackYellow.js new file mode 100644 index 00000000..8d9c5269 --- /dev/null +++ b/resources/library/interactivities/BlackYellow.wgt/locales/ru/scripts/blackYellow.js @@ -0,0 +1,408 @@ +/* + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +var sankoreLang = {display: "Показать", edit: "Изменить", add: "Добавить", enter_data: "Введите вопрос:", enter_result: "Введите ответ:", ok: "Ок", cancel: "Отмена"}; + +function init(){ + + //variables + var toggleFlag = false; // detects toggling in toggle button + var endFlag = false; // ending of toggling in toggle button + var addToggleStart = false; // detects toggling in add button + var addToggleEnd = false; // ending of toggling in add button + var shadowOver = false; + var mode = false; + var popupFlag = false + var flagForSelect = false; + var dragElement = null; //the element that must be dragging + var lang = ""; //locale language + var coords = { + left:0, + top:0 + } + + var resizeObj = { + y:false, + x:false, + width:0, + height:0 + } + + var opacityChanged = false; + + if(window.sankore){ + if(sankore.preference("blackYellowData","")){ + var importArray = jQuery.parseJSON(sankore.preference("blackYellowData","")); + for(var i in importArray){ + var tmpReadyTask = $("
"); + var exprContainer = $("
" + importArray[i].data1 + "
").appendTo(tmpReadyTask); + var resContainer = $("
"+ importArray[i].data2 + "
").appendTo(tmpReadyTask); + tmpReadyTask.width(importArray[i].width) + .height(importArray[i].height) + .css("position","absolute") + .css("top",importArray[i].top) + .css("left",importArray[i].left); + tmpReadyTask.appendTo("body"); + } + } + $(document).disableTextSelect(); + } + + /* ------------- BUTTONS -------------*/ + + // toggle button + var buttonDiv = $("
").appendTo("body"); + var toggleButton = $("").appendTo("#buttonDiv"); + buttonDiv.css({ + top:"10px", + right:0 + }); + + //toggle mode + toggleButton.click(function(){ + if(!shadowOver){ + if(mode){ + mode = false; + addButtonDiv.css("display","none"); + $(".leftDiv, .rightDiv").animate({ + "opacity":"1" + },"slow",function(){ + if(opacityChanged){ + if($(".editContainer").size() != 0){ + $(".editContainer").each(function(index, domElem){ + var tmpReadyTask = $(domElem).find(".readyTask"); + tmpReadyTask.width($(domElem).width()) + .height($(domElem).height()) + .css("position","absolute") + .css("top",$(domElem).position().top) + .css("left",$(domElem).position().left) + .find(".taskContainer").removeAttr("contenteditable"); + + $(domElem).remove(); + tmpReadyTask.appendTo("body"); + }); + } + opacityChanged = false; + } + }); + $(document).disableTextSelect(); + } else { + mode = true; + addButtonDiv.css("display","block"); + $(document).enableTextSelect(); + $(".leftDiv, .rightDiv").animate({ + "opacity":"0.4" + },"slow",function(){ + if(!opacityChanged){ + if($(".readyTask").size() != 0){ + $(".readyTask").each(function(index, domElem){ + var editContent = $("
").width($(domElem).width() + 10).height($(domElem) + 10).appendTo("body"); + var closeItem = $("
").appendTo(editContent); + var rightResize = $("
").appendTo(editContent); + var bottomResize = $("
").appendTo(editContent); + editContent.css("top", $(domElem).position().top).css("left", $(domElem).position().left); + $(domElem).css("position","static") + .width("100%") + .height("100%") + .find(".taskContainer").attr("contenteditable", "true"); + $(domElem).appendTo(editContent); + }); + } + opacityChanged = true; + } + }); + + } + toggleButton.trigger("mouseout"); + } + }); + + // toggle button events + toggleButton.mouseover(function(){ + if(!shadowOver){ + if(!toggleFlag && !endFlag){ + endFlag = true; + toggleButton.animate({ + width:"115px" + },"fast",function(){ + toggleFlag = true; + if(!mode) + toggleButton.text(sankoreLang.edit); + else + toggleButton.text(sankoreLang.display); + }); + } + } + }); + + toggleButton.mouseout(function(){ + if(!shadowOver){ + if(toggleFlag && endFlag){ + endFlag = false; + toggleButton.animate({ + width:"20px" + },"fast", function(){ + toggleButton.text("<"); + toggleFlag = false; + }); + } + } + }); + + //add button + var addButtonDiv = $("
").appendTo("body"); + var addButton = $("").appendTo("#addButtonDiv"); + addButtonDiv.css({ + top:"47px", + right:0 + }); + + // add button events + addButton.click(function(){ + shadowDiv.show("fast", function(){ + shadowOver = true; + popupBack.show("slow"); + }); + $(document).disableTextSelect(); + addButton.trigger("mouseout"); + }); + + addButton.mouseover(function(){ + if(!shadowOver){ + if(!addToggleStart && !addToggleEnd){ + addToggleEnd = true; + addButton.animate({ + width:"115px" + },"fast",function(){ + addToggleStart = true; + addButton.text(sankoreLang.add); + }); + } + } + }); + + addButton.mouseout(function(){ + if(!shadowOver){ + if(addToggleStart && addToggleEnd){ + addToggleEnd = false; + addButton.animate({ + width:"20px" + },"fast", function(){ + addButton.text("+"); + addToggleStart = false; + }); + } + } + }); + + /* -------------- END OF WORK WITH BUTTONS ---------------*/ + + //basic divs + var leftDiv = $("
").appendTo("body"); + var rightDiv = $("
").appendTo("body"); + + //divs for adding a new item + var shadowDiv = $("
").appendTo("body"); + var popupBack = $("
").appendTo("body"); + + //input fields and buttons for a popup window + var expressionDiv = $("
").appendTo(popupBack); + var experssionLabel = $("" + sankoreLang.enter_data + "").appendTo(expressionDiv); + var expresionText = $("").appendTo(expressionDiv); + + var resultDiv = $("
").appendTo(popupBack); + var resultLabel = $("" + sankoreLang.enter_result + "").appendTo(resultDiv); + var resultText = $("").appendTo(resultDiv); + + var popupButtonsDiv= $("
").appendTo(popupBack); + var cancelButton = $("").appendTo(popupButtonsDiv); + var okButton = $("").appendTo(popupButtonsDiv); + + /* -------------- A WORK WITH POPUP BUTTONS AND FIELDS ---------------*/ + + $("#resultText, #expresionText").keyup(function(){ + if($(this).val()){ + $(this).css("background-color", "#ff9"); + } + }); + + cancelButton.click(function(){ + $(document).enableTextSelect(); + popupBack.hide("slow", function(){ + $("#resultText, #expresionText").val("") + .css("background-color", "#ffc"); + shadowDiv.hide("fast"); + shadowOver = false; + }); + }); + + okButton.click(function(){ + $(document).enableTextSelect(); + if(checkEmptyFields(expresionText) && checkEmptyFields(resultText)){ + popupBack.hide("slow", function(){ + shadowDiv.hide("fast"); + shadowOver = false; + addTask(expresionText.val(), resultText.val()); + $("#resultText, #expresionText").val("") + .css("background-color", "#ffc"); + }) + } + }); + + /* -------------- THE END OF WORK WITH POPUP BUTTONS AND FIELDS ---------------*/ + + // a work with dragging possibility + $("input:text").mouseover(function(){ + $(document).enableTextSelect(); + }); + + $("input:text").mouseout(function(){ + $(document).disableTextSelect(); + }); + + $(".readyTask, .editContainer").live("mousedown",function(event){ + if(!shadowOver){ + dragElement = $(this); + coords.left = event.pageX - $(this).position().left; + coords.top = event.pageY - $(this).position().top; + resizeObj.width = $(this).width(); + resizeObj.height = $(this).height(); + } + }); + + $(".rightResize").live("mousedown",function(event){ + if(!shadowOver){ + resizeObj.x = true; + } + }); + + $(".bottomResize").live("mousedown",function(event){ + if(!shadowOver){ + resizeObj.y = true; + } + }); + + $("body").mouseup(function(event){ + if(!shadowOver){ + dragElement = null; + resizeObj.x = false; + resizeObj.y = false; + } + }); + + $("body").mousemove(function(event){ + if(dragElement && !shadowOver){ + if(resizeObj.x) + dragElement.width(event.pageX - dragElement.position().left); + else if(resizeObj.y) + dragElement.height(event.pageY - dragElement.position().top); + else + dragElement.css("top",event.pageY - coords.top).css("left", event.pageX - coords.left); + } + }); + + //closing item + $(".closeItem").live("click", function(){ + if(!shadowOver){ + $(this).parent().remove(); + } + }); + + $("#leftDiv,#rightDiv,#shadowDiv").css("height", $(window).height()); + popupBack.css("top", ($(window).height() - 138)*50/$(window).height() + "%"); + popupBack.css("left", ($(window).width() - 360)*50/$(window).width() + "%"); + + $(window).resize(function(){ + $("#leftDiv,#rightDiv,#shadowDiv").css("height", $(window).height()); + popupBack.css("top", ($(window).height() - 138)*50/$(window).height() + "%"); + popupBack.css("left", ($(window).width() - 360)*50/$(window).width() + "%"); + }); + + $("html").mouseout(function(){ + if(window.sankore) + exportToSankore(); + }); + + // export data + function exportToSankore(){ + + var arrayToExport = new Array(); + if(mode){ + if($(".editContainer").size() != 0){ + $(".editContainer").each(function(index, domElem){ + var objToExport = { + data1:"", + data2:"", + width:0, + height:0, + top:0, + left:0 + } + objToExport.data1 = $(domElem).find(".readyTask").find(":first-child").text(); + objToExport.data2 = $(domElem).find(".readyTask").find(":last-child").text(); + objToExport.width = $(domElem).width(); + objToExport.height = $(domElem).height(); + objToExport.top = $(domElem).position().top; + objToExport.left = $(domElem).position().left; + arrayToExport.push(objToExport); + }); + } + } else { + if($(".readyTask").size() != 0){ + $(".readyTask").each(function(index, domElem){ + var objToExport = { + data1:"", + data2:"", + width:0, + height:0, + top:0, + left:0 + } + objToExport.data1 = $(domElem).find(":first-child").text(); + objToExport.data2 = $(domElem).find(":last-child").text(); + objToExport.width = $(domElem).width(); + objToExport.height = $(domElem).height(); + objToExport.top = $(domElem).position().top; + objToExport.left = $(domElem).position().left; + arrayToExport.push(objToExport); + }); + } + } + sankore.setPreference("blackYellowData", JSON.stringify(arrayToExport)); + } +} + +//checking empty fields +function checkEmptyFields(field){ + if(field.val() == ""){ + field.css("background-color", "red"); + return false; + } else { + field.css("background-color", "#ff9"); + return true; + } +} + +//adding a new task to the page +function addTask(expression, result){ + var editContent = $("
").width(240).height(70).appendTo("body"); + var closeItem = $("
").appendTo(editContent); + var rightResize = $("
").appendTo(editContent); + var bottomResize = $("
").appendTo(editContent); + var main = $("
"); + var exprContainer = $("
" + expression + "
").appendTo(main); + var resContainer = $("
"+ result + "
").appendTo(main); + main.appendTo(editContent); +} \ No newline at end of file diff --git a/resources/library/interactivities/BlackYellow.wgt/scripts/blackYellow.js b/resources/library/interactivities/BlackYellow.wgt/scripts/blackYellow.js index 3ce21a15..15cf2f97 100644 --- a/resources/library/interactivities/BlackYellow.wgt/scripts/blackYellow.js +++ b/resources/library/interactivities/BlackYellow.wgt/scripts/blackYellow.js @@ -13,6 +13,7 @@ * along with this program. If not, see . */ +var sankoreLang = {display: "Display", edit: "Edit", add: "Add", enter_data: "Enter data:", enter_result: "Enter result:", ok: "Ok", cancel: "Cancel"}; function init(){ @@ -37,17 +38,7 @@ function init(){ x:false, width:0, height:0 - } - - if(window.sankore){ - try{ - lang = sankore.locale().substr(0,2); - sankoreLang[lang].edit; - } catch(e){ - lang = "en"; - } - } else - lang = "en"; + } var opacityChanged = false; @@ -148,9 +139,9 @@ function init(){ },"fast",function(){ toggleFlag = true; if(!mode) - toggleButton.text(sankoreLang[lang].edit); + toggleButton.text(sankoreLang.edit); else - toggleButton.text(sankoreLang[lang].display); + toggleButton.text(sankoreLang.display); }); } } @@ -196,7 +187,7 @@ function init(){ width:"115px" },"fast",function(){ addToggleStart = true; - addButton.text(sankoreLang[lang].add); + addButton.text(sankoreLang.add); }); } } @@ -228,16 +219,16 @@ function init(){ //input fields and buttons for a popup window var expressionDiv = $("
").appendTo(popupBack); - var experssionLabel = $("" + sankoreLang[lang].enter_data + "").appendTo(expressionDiv); + var experssionLabel = $("" + sankoreLang.enter_data + "").appendTo(expressionDiv); var expresionText = $("").appendTo(expressionDiv); var resultDiv = $("
").appendTo(popupBack); - var resultLabel = $("" + sankoreLang[lang].enter_result + "").appendTo(resultDiv); + var resultLabel = $("" + sankoreLang.enter_result + "").appendTo(resultDiv); var resultText = $("").appendTo(resultDiv); var popupButtonsDiv= $("
").appendTo(popupBack); - var cancelButton = $("").appendTo(popupButtonsDiv); - var okButton = $("").appendTo(popupButtonsDiv); + var cancelButton = $("").appendTo(popupButtonsDiv); + var okButton = $("").appendTo(popupButtonsDiv); /* -------------- A WORK WITH POPUP BUTTONS AND FIELDS ---------------*/ @@ -345,20 +336,20 @@ function init(){ }); // export data - function exportToSankore(){ - - var objToExport = { - data1:"", - data2:"", - width:0, - height:0, - top:0, - left:0 - } + function exportToSankore(){ + var arrayToExport = new Array(); if(mode){ if($(".editContainer").size() != 0){ - $(".editContainer").each(function(index, domElem){ + $(".editContainer").each(function(index, domElem){ + var objToExport = { + data1:"", + data2:"", + width:0, + height:0, + top:0, + left:0 + } objToExport.data1 = $(domElem).find(".readyTask").find(":first-child").text(); objToExport.data2 = $(domElem).find(".readyTask").find(":last-child").text(); objToExport.width = $(domElem).width(); @@ -371,6 +362,14 @@ function init(){ } else { if($(".readyTask").size() != 0){ $(".readyTask").each(function(index, domElem){ + var objToExport = { + data1:"", + data2:"", + width:0, + height:0, + top:0, + left:0 + } objToExport.data1 = $(domElem).find(":first-child").text(); objToExport.data2 = $(domElem).find(":last-child").text(); objToExport.width = $(domElem).width(); diff --git a/resources/library/interactivities/BlackYellow.wgt/scripts/languages.js b/resources/library/interactivities/BlackYellow.wgt/scripts/languages.js deleted file mode 100644 index fceb7e64..00000000 --- a/resources/library/interactivities/BlackYellow.wgt/scripts/languages.js +++ /dev/null @@ -1,30 +0,0 @@ -var sankoreLang = { - "en":{ - "edit": "Edit", - "display":"Display", - "add":"Add", - "enter_data":"Enter data:", - "enter_result":"Enter result:", - "ok":"Ok", - "cancel":"Cancel" - }, - "ru":{ - "edit": "Изменить", - "display":"Показать", - "add":"Добавить", - "enter_data":"Введите вопрос:", - "enter_result":"Введите ответ:", - "ok":"Ок", - "cancel":"Отмена" - }, - "fr":{ - "edit": "Modifier", - "display":"Afficher", - "add":"Ajouter", - "enter_data":"Entrer les données:", - "enter_result":"Entrez le résultat:", - "ok":"Ok", - "cancel":"Annuler" - } -}; - From e2b47126f981aeac5d14980a01742f3b2ada0e91 Mon Sep 17 00:00:00 2001 From: Claudio Valerio Date: Tue, 14 Feb 2012 11:36:11 +0100 Subject: [PATCH 2/6] fixed package on i386 --- buildDebianPackage | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/buildDebianPackage b/buildDebianPackage index 7056a1d7..89c2189c 100755 --- a/buildDebianPackage +++ b/buildDebianPackage @@ -196,6 +196,10 @@ if [ "$ARCHITECTURE" == "x86_64" ]; then ARCHITECTURE="amd64" fi +if [ "$ARCHITECTURE" == "i686" ]; then + ARCHITECTURE="i386" +fi + echo "Open-Sankore ($VERSION) $ARCHITECTURE; urgency=low" > "$CHANGE_LOG_FILE" echo >> "$CHANGE_LOG_FILE" cat $CHANGE_LOG_TEXT >> "$CHANGE_LOG_FILE" From 18925ab001a9d7181e9b30f0e451f92da463bc2a Mon Sep 17 00:00:00 2001 From: Claudio Valerio Date: Tue, 14 Feb 2012 14:33:50 +0100 Subject: [PATCH 3/6] fixed working issue --- .../BlackYellow.wgt/locales/fr/scripts/blackYellow.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/resources/library/interactivities/BlackYellow.wgt/locales/fr/scripts/blackYellow.js b/resources/library/interactivities/BlackYellow.wgt/locales/fr/scripts/blackYellow.js index 47b56c09..91ed67d0 100644 --- a/resources/library/interactivities/BlackYellow.wgt/locales/fr/scripts/blackYellow.js +++ b/resources/library/interactivities/BlackYellow.wgt/locales/fr/scripts/blackYellow.js @@ -13,7 +13,7 @@ * along with this program. If not, see . */ -var sankoreLang = {display: "Afficher", edit: "Modifier", add: "Ajouter", enter_data: "Entrer les données:", enter_result: "Entrez le résultat:", ok: "Ок", cancel: "Annuler"}; +var sankoreLang = {display: "Afficher", edit: "Modifier", add: "Ajouter", enter_data: "Entrer la donnée:", enter_result: "Entrer le résultat:", ok: "Accepter", cancel: "Annuler"}; function init(){ @@ -405,4 +405,4 @@ function addTask(expression, result){ var exprContainer = $("
" + expression + "
").appendTo(main); var resContainer = $("
"+ result + "
").appendTo(main); main.appendTo(editContent); -} \ No newline at end of file +} From e34e50f1299bd951a5611ae4c0560f9e51e06e96 Mon Sep 17 00:00:00 2001 From: Claudio Valerio Date: Tue, 14 Feb 2012 16:22:06 +0100 Subject: [PATCH 4/6] french wording problem --- resources/i18n/sankore_fr.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/i18n/sankore_fr.ts b/resources/i18n/sankore_fr.ts index 278bf04a..252aa674 100644 --- a/resources/i18n/sankore_fr.ts +++ b/resources/i18n/sankore_fr.ts @@ -2511,7 +2511,7 @@ p, li { white-space: pre-wrap; } Stylus Palette - Barre d'outil du stylet + Barre d'outils du stylet Horizontal From 2fd15cc0276882e14941b46c057406c2bcb3751c Mon Sep 17 00:00:00 2001 From: Anatoly Mihalchenko Date: Tue, 14 Feb 2012 20:14:40 +0300 Subject: [PATCH 5/6] Improved document navigation for the ticket 382. --- src/adaptors/UBThumbnailAdaptor.cpp | 79 ++++++++++++++++++++++------- src/adaptors/UBThumbnailAdaptor.h | 15 ++---- src/board/UBBoardController.cpp | 5 +- src/gui/UBDocumentNavigator.cpp | 37 +++++++------- src/gui/UBDocumentNavigator.h | 2 +- 5 files changed, 88 insertions(+), 50 deletions(-) diff --git a/src/adaptors/UBThumbnailAdaptor.cpp b/src/adaptors/UBThumbnailAdaptor.cpp index b6087094..bb3b469f 100644 --- a/src/adaptors/UBThumbnailAdaptor.cpp +++ b/src/adaptors/UBThumbnailAdaptor.cpp @@ -31,22 +31,8 @@ #include "core/memcheck.h" -UBThumbnailAdaptor::UBThumbnailAdaptor(QObject *parent) - : QObject(parent) -{ - // NOOP -} - - -UBThumbnailAdaptor::~UBThumbnailAdaptor() -{ - // NOOP -} - - QList UBThumbnailAdaptor::load(UBDocumentProxy* proxy) { - QList thumbnails; if (!proxy || proxy->persistencePath().size() == 0) @@ -76,14 +62,14 @@ QList UBThumbnailAdaptor::load(UBDocumentProxy* proxy) thumbCount++; if (displayMessage && thumbCount == 1) - UBApplication::showMessage(tr("Generating preview thumbnails ...")); + UBApplication::showMessage(QObject::tr("Generating preview thumbnails ...")); persistScene(proxy->persistencePath(), scene, i); } } if (displayMessage && thumbCount > 0) - UBApplication::showMessage(tr("%1 thumbnails generated ...").arg(thumbCount)); + UBApplication::showMessage(QObject::tr("%1 thumbnails generated ...").arg(thumbCount)); } @@ -114,8 +100,65 @@ QList UBThumbnailAdaptor::load(UBDocumentProxy* proxy) return thumbnails; } +QPixmap UBThumbnailAdaptor::load(UBDocumentProxy* proxy, int index) +{ + int existingPageCount = proxy->pageCount(); + + if (!proxy || proxy->persistencePath().size() == 0 || index < 0 || index >= existingPageCount) + return QPixmap(); + //compatibility with older formats (<= 4.0.b.2.0) : generate missing thumbnails + + QString thumbFileName = proxy->persistencePath() + + UBFileSystemUtils::digitFileFormat("/page%1.thumbnail.jpg", existingPageCount); + + QFile thumbFile(thumbFileName); + + if (!thumbFile.exists()) + { + bool displayMessage = (existingPageCount > 5); + + int thumbCount = 0; + + for(int i = 0 ; i < existingPageCount; i++) + { + UBGraphicsScene* scene = UBSvgSubsetAdaptor::loadScene(proxy, i); + + if (scene) + { + thumbCount++; + + if (displayMessage && thumbCount == 1) + UBApplication::showMessage(QObject::tr("Generating preview thumbnails ...")); + + persistScene(proxy->persistencePath(), scene, i); + } + } + + if (displayMessage && thumbCount > 0) + UBApplication::showMessage(QObject::tr("%1 thumbnails generated ...").arg(thumbCount)); + + } + + //end compatibility with older format + QString fileName = proxy->persistencePath() + + UBFileSystemUtils::digitFileFormat("/page%1.thumbnail.jpg", index + 1); + + QFile file(fileName); + if (file.exists()) + { + QPixmap pix; + //Warning. Works only with modified Qt +#ifdef Q_WS_X11 + pix.load(fileName, 0, Qt::AutoColor); +#else + pix.load(fileName, 0, Qt::AutoColor, false); +#endif + return pix; + } + return QPixmap(); +} -void UBThumbnailAdaptor::persistScene(const QString& pDocPath, UBGraphicsScene* pScene, const int pageIndex, const bool overrideModified) +void UBThumbnailAdaptor::persistScene(const QString& pDocPath, UBGraphicsScene* pScene, int pageIndex, bool overrideModified) { QString fileName = pDocPath + UBFileSystemUtils::digitFileFormat("/page%1.thumbnail.jpg", pageIndex + 1); @@ -161,7 +204,7 @@ void UBThumbnailAdaptor::persistScene(const QString& pDocPath, UBGraphicsScene* } -QUrl UBThumbnailAdaptor::thumbnailUrl(UBDocumentProxy* proxy, const int pageIndex) +QUrl UBThumbnailAdaptor::thumbnailUrl(UBDocumentProxy* proxy, int pageIndex) { QString fileName = proxy->persistencePath() + UBFileSystemUtils::digitFileFormat("/page%1.thumbnail.jpg", pageIndex + 1); diff --git a/src/adaptors/UBThumbnailAdaptor.h b/src/adaptors/UBThumbnailAdaptor.h index f3fc2b08..aa7ea361 100644 --- a/src/adaptors/UBThumbnailAdaptor.h +++ b/src/adaptors/UBThumbnailAdaptor.h @@ -21,21 +21,16 @@ class UBDocument; class UBDocumentProxy; class UBGraphicsScene; -class UBThumbnailAdaptor : public QObject +class UBThumbnailAdaptor //static class { - Q_OBJECT; - +private: UBThumbnailAdaptor() {} public: - - UBThumbnailAdaptor(QObject *parent = 0); - ~UBThumbnailAdaptor(); - - static void persistScene(const QString& pDocPath, UBGraphicsScene* pScene, const int pageIndex, const bool overrideModified = false); + static void persistScene(const QString& pDocPath, UBGraphicsScene* pScene, int pageIndex, bool overrideModified = false); static QList load(UBDocumentProxy* proxy); + static QPixmap load(UBDocumentProxy* proxy, int index); - static QUrl thumbnailUrl(UBDocumentProxy* proxy, const int pageIndex); - + static QUrl thumbnailUrl(UBDocumentProxy* proxy, int pageIndex); }; #endif // UBTHUMBNAILADAPTOR_H diff --git a/src/board/UBBoardController.cpp b/src/board/UBBoardController.cpp index 72967adc..4ca6aecb 100644 --- a/src/board/UBBoardController.cpp +++ b/src/board/UBBoardController.cpp @@ -1166,11 +1166,10 @@ void UBBoardController::setActiveDocumentScene(UBDocumentProxy* pDocumentProxy, { emit activeDocumentChanged(); UBGraphicsTextItem::lastUsedTextColor = QColor(); + // Notify the navigator palette that the document has changed + emit setDocOnPageNavigator(pDocumentProxy); } - // Notify the navigator palette that the document has changed - emit setDocOnPageNavigator(pDocumentProxy); - if (sceneChange) { emit activeSceneChanged(); diff --git a/src/gui/UBDocumentNavigator.cpp b/src/gui/UBDocumentNavigator.cpp index 592e870a..7abf129b 100644 --- a/src/gui/UBDocumentNavigator.cpp +++ b/src/gui/UBDocumentNavigator.cpp @@ -99,7 +99,7 @@ void UBDocumentNavigator::setDocument(UBDocumentProxy *document) */ void UBDocumentNavigator::generateThumbnails() { - // Get the thumbnails + // Get the thumbnails QList thumbs = UBThumbnailAdaptor::load(mCrntDoc); mThumbsWithLabels.clear(); @@ -155,9 +155,8 @@ void UBDocumentNavigator::updateSpecificThumbnail(int iPage) UBThumbnailAdaptor::persistScene(mCrntDoc->persistencePath(), pScene, iPage); // Load it - QList thumbs = UBThumbnailAdaptor::load(mCrntDoc); - QPixmap pix = thumbs.at(iPage); - QGraphicsPixmapItem* pixmapItem = new UBSceneThumbnailNavigPixmap(pix, mCrntDoc, iPage); + QPixmap pix = UBThumbnailAdaptor::load(mCrntDoc, iPage); + UBSceneThumbnailNavigPixmap* pixmapItem = new UBSceneThumbnailNavigPixmap(pix, mCrntDoc, iPage); if(pixmapItem) { // Get the old thumbnail @@ -307,27 +306,29 @@ void UBDocumentNavigator::mousePressEvent(QMouseEvent *event) } } } - else - { - if(NULL != mCrntItem && mCrntItem != pCrntItem) - { - // Unselect the previous item - int iOldPage = -1; + else + { + if(NULL != mCrntItem && mCrntItem != pCrntItem) + { + // Unselect the previous item + mCrntItem->setSelected(false); + int iOldPage = -1; for(int i = 0; i < mThumbsWithLabels.size(); i++) if (mThumbsWithLabels.at(i).getThumbnail() == mCrntItem) { iOldPage = i; break; } - updateSpecificThumbnail(iOldPage); - mCrntItem = pCrntItem; - } + updateSpecificThumbnail(iOldPage); + mCrntItem = pCrntItem; + } - // Then display the related page - emit changeCurrentPage(); - refreshScene(); - } - bNavig = false; + // Then display the related page + emit changeCurrentPage(); + refreshScene(); + } + + bNavig = false; } QGraphicsView::mousePressEvent(event); } diff --git a/src/gui/UBDocumentNavigator.h b/src/gui/UBDocumentNavigator.h index 1d8c6796..5f322355 100644 --- a/src/gui/UBDocumentNavigator.h +++ b/src/gui/UBDocumentNavigator.h @@ -58,7 +58,7 @@ private slots: private: void refreshScene(); - void updateSpecificThumbnail(int iPage); + void updateSpecificThumbnail(int iPage); int border(); From a409f852d7b02fc2d29cd933866346bd97f70321 Mon Sep 17 00:00:00 2001 From: Anatoly Mihalchenko Date: Wed, 15 Feb 2012 17:19:26 +0300 Subject: [PATCH 6/6] small correction in thumbnail adapter --- src/adaptors/UBThumbnailAdaptor.cpp | 8 ++++---- src/adaptors/UBThumbnailAdaptor.h | 2 ++ 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/adaptors/UBThumbnailAdaptor.cpp b/src/adaptors/UBThumbnailAdaptor.cpp index bb3b469f..e45cf725 100644 --- a/src/adaptors/UBThumbnailAdaptor.cpp +++ b/src/adaptors/UBThumbnailAdaptor.cpp @@ -62,14 +62,14 @@ QList UBThumbnailAdaptor::load(UBDocumentProxy* proxy) thumbCount++; if (displayMessage && thumbCount == 1) - UBApplication::showMessage(QObject::tr("Generating preview thumbnails ...")); + UBApplication::showMessage(tr("Generating preview thumbnails ...")); persistScene(proxy->persistencePath(), scene, i); } } if (displayMessage && thumbCount > 0) - UBApplication::showMessage(QObject::tr("%1 thumbnails generated ...").arg(thumbCount)); + UBApplication::showMessage(tr("%1 thumbnails generated ...").arg(thumbCount)); } @@ -128,14 +128,14 @@ QPixmap UBThumbnailAdaptor::load(UBDocumentProxy* proxy, int index) thumbCount++; if (displayMessage && thumbCount == 1) - UBApplication::showMessage(QObject::tr("Generating preview thumbnails ...")); + UBApplication::showMessage(tr("Generating preview thumbnails ...")); persistScene(proxy->persistencePath(), scene, i); } } if (displayMessage && thumbCount > 0) - UBApplication::showMessage(QObject::tr("%1 thumbnails generated ...").arg(thumbCount)); + UBApplication::showMessage(tr("%1 thumbnails generated ...").arg(thumbCount)); } diff --git a/src/adaptors/UBThumbnailAdaptor.h b/src/adaptors/UBThumbnailAdaptor.h index aa7ea361..68352102 100644 --- a/src/adaptors/UBThumbnailAdaptor.h +++ b/src/adaptors/UBThumbnailAdaptor.h @@ -23,6 +23,8 @@ class UBGraphicsScene; class UBThumbnailAdaptor //static class { + Q_DECLARE_TR_FUNCTIONS(UBThumbnailAdaptor) + private: UBThumbnailAdaptor() {} public: static void persistScene(const QString& pDocPath, UBGraphicsScene* pScene, int pageIndex, bool overrideModified = false);