You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
628 lines
26 KiB
628 lines
26 KiB
13 years ago
|
/*
|
||
|
* 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 <http://www.gnu.org/licenses/>.
|
||
|
*/
|
||
|
|
||
|
var sankoreLang = {
|
||
12 years ago
|
display: "Afficher",
|
||
13 years ago
|
edit: "Modifier",
|
||
|
add: "Ajouter",
|
||
|
enter_data: "Saisir la donnée:",
|
||
|
enter_result: "Saisir le résultat:",
|
||
13 years ago
|
ok: "Ok",
|
||
13 years ago
|
cancel: "Annuler",
|
||
13 years ago
|
wgt_name: "Contraste",
|
||
13 years ago
|
reload: "Recharger",
|
||
13 years ago
|
slate: "ardoise",
|
||
13 years ago
|
pad: "tablette",
|
||
12 years ago
|
none: "aucun",
|
||
12 years ago
|
help: "Aide",
|
||
|
help_content: "<p><h2>Contraste</h2></p>"+
|
||
12 years ago
|
"<p><h3>Jeu de couleurs.</h3></p>"+
|
||
12 years ago
|
|
||
|
|
||
12 years ago
|
"<p>Cette activité permet de masquer et d’afficher du texte en jouant sur la couleur de fond (jaune ou noir). Le but est de pouvoir faire apparaître des données en passant d’une couleur à l’autre.</p>"+
|
||
12 years ago
|
|
||
12 years ago
|
"<p>Le bouton “Recharger” réinitialise les exercices.</p>"+
|
||
12 years ago
|
|
||
12 years ago
|
"<p>Le bouton “Modifier” vous permet :</p>"+
|
||
|
"<ul><li>de choisir le thème de l’interactivité : tablette, ardoise ou aucun (par défaut aucun),</li>"+
|
||
|
"<li>de modifier un exercice ou d’en créer de nouveaux dans la même activité.</li></ul>"+
|
||
12 years ago
|
|
||
12 years ago
|
"<p>En mode édition, pour créer un nouvel exercice, cliquez sur “+ Ajouter” en haut, puis</p>"+
|
||
|
"<ul><li>saisissez la donnée par exemple “3x15”,</li>"+
|
||
|
"<li>saisissez le résultat, par exemple “15” et cliquez sur “OK”.</li></ul>"+
|
||
|
"<p>Pour modifier les données ou les résultats, cliquez directement sur l’exercice.</p>"+
|
||
|
"<p>Pour supprimer un exercice, cliquez sur la croix en haut à droite de l’exercice.</p>"+
|
||
12 years ago
|
|
||
12 years ago
|
"<p>Le bouton “Afficher” vous permet d’utiliser l’activité.</p>",
|
||
|
theme: "Thème"
|
||
13 years ago
|
};
|
||
13 years ago
|
|
||
13 years ago
|
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
|
||
12 years ago
|
var resizeFlag = true;
|
||
|
|
||
13 years ago
|
var coords = {
|
||
|
left:0,
|
||
|
top:0
|
||
|
}
|
||
|
|
||
|
var resizeObj = {
|
||
|
y:false,
|
||
|
x:false,
|
||
|
width:0,
|
||
|
height:0
|
||
|
}
|
||
|
|
||
|
var opacityChanged = false;
|
||
|
|
||
|
$("#wgt_display").text(sankoreLang.display);
|
||
|
$("#wgt_edit").text(sankoreLang.edit);
|
||
|
$("#wgt_add").text(sankoreLang.add);
|
||
|
$("#wgt_name").text(sankoreLang.wgt_name);
|
||
|
$("#wgt_reload").text(sankoreLang.reload);
|
||
12 years ago
|
$("#wgt_help").text(sankoreLang.help);
|
||
|
$("#help").html(sankoreLang.help_content);
|
||
12 years ago
|
$("#style_select option[value='1']").text(sankoreLang.slate);
|
||
|
$("#style_select option[value='2']").text(sankoreLang.pad);
|
||
|
$("#style_select option[value='3']").text(sankoreLang.none);
|
||
|
var tmpl = $("div.inline label").html();
|
||
|
$("div.inline label").html(sankoreLang.theme + tmpl)
|
||
13 years ago
|
|
||
|
if(window.sankore){
|
||
|
if(sankore.preference("blackYellowData","")){
|
||
|
var importArray = jQuery.parseJSON(sankore.preference("blackYellowData",""));
|
||
|
for(var i in importArray){
|
||
|
var tmpReadyTask = $("<div class='readyTask'>");
|
||
|
var exprContainer = $("<div class='taskContainer' style='color: yellow;'>" + importArray[i].data1 + "</div>").appendTo(tmpReadyTask);
|
||
|
var resContainer = $("<div class='taskContainer' style='color: black;'>"+ importArray[i].data2 + "</div>").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("#data");
|
||
12 years ago
|
}
|
||
|
}
|
||
|
$(document).disableTextSelect();
|
||
13 years ago
|
}
|
||
|
|
||
|
/* ------------- BUTTONS -------------*/
|
||
|
|
||
12 years ago
|
if(window.sankore){
|
||
|
if(sankore.preference("by_style","")){
|
||
|
changeStyle(sankore.preference("by_style",""));
|
||
12 years ago
|
$("#style_select").val(sankore.preference("by_style",""));
|
||
12 years ago
|
} else
|
||
|
changeStyle("3")
|
||
13 years ago
|
} else
|
||
13 years ago
|
changeStyle("3")
|
||
13 years ago
|
|
||
|
$("#wgt_display, #wgt_edit").click(function(event){
|
||
|
if(this.id == "wgt_display"){
|
||
|
if(!$(this).hasClass("selected")){
|
||
|
$(this).addClass("selected");
|
||
|
$("#wgt_edit").removeClass("selected");
|
||
12 years ago
|
$("#parameters").css("display","none");
|
||
|
var tmpwh = $(window).height();
|
||
|
var tmpww = $(window).width();
|
||
|
resizeFlag = true;
|
||
|
window.resizeTo(tmpww, tmpwh - 44)
|
||
|
$("#data").css("padding-bottom","");
|
||
|
$("#leftDiv").css("border-top-left-radius","7px");
|
||
|
$("#rightDiv").css("border-top-right-radius","7px");
|
||
13 years ago
|
$(this).css("display", "none");
|
||
|
$("#wgt_edit").css("display", "block");
|
||
|
mode = false;
|
||
|
$(".leftDiv, .rightDiv").animate({
|
||
|
"opacity":"1"
|
||
12 years ago
|
},"fast",function(){
|
||
13 years ago
|
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")
|
||
12 years ago
|
.css("top",$(domElem).position().top - 40)
|
||
13 years ago
|
.css("left",$(domElem).position().left)
|
||
|
.find(".taskContainer").removeAttr("contenteditable");
|
||
|
|
||
|
$(domElem).remove();
|
||
|
tmpReadyTask.appendTo("#data");
|
||
|
});
|
||
|
}
|
||
|
opacityChanged = false;
|
||
|
}
|
||
|
});
|
||
12 years ago
|
|
||
13 years ago
|
$(document).disableTextSelect();
|
||
|
}
|
||
|
} else {
|
||
|
if(!$(this).hasClass("selected")){
|
||
|
$(this).addClass("selected");
|
||
|
$("#wgt_display").removeClass("selected");
|
||
12 years ago
|
$("#parameters").css("display","block");
|
||
|
tmpwh = $(window).height();
|
||
|
tmpww = $(window).width();
|
||
|
resizeFlag = true;
|
||
|
window.resizeTo(tmpww, tmpwh + 44)
|
||
|
$("#data").css("padding-bottom","42px");
|
||
|
$("#leftDiv").css("border-top-left-radius","0px");
|
||
|
$("#rightDiv").css("border-top-right-radius","0px");
|
||
13 years ago
|
$(this).css("display", "none");
|
||
|
$("#wgt_display").css("display", "block");
|
||
|
mode = true;
|
||
|
$(document).enableTextSelect();
|
||
|
$(".leftDiv, .rightDiv").animate({
|
||
|
"opacity":"0.4"
|
||
12 years ago
|
},"fast",function(){
|
||
13 years ago
|
if(!opacityChanged){
|
||
|
if($(".readyTask").size() != 0){
|
||
12 years ago
|
var tmp_arr = [];
|
||
|
$(".readyTask").each(function(){
|
||
|
tmp_arr.push($(this));
|
||
|
})
|
||
|
orderItems(tmp_arr);
|
||
13 years ago
|
$(".readyTask").each(function(index, domElem){
|
||
|
var editContent = $("<div class='editContainer'>").width($(domElem).width() + 10).height($(domElem) + 10).appendTo("#data");
|
||
|
var closeItem = $("<div class='closeItem'>").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;
|
||
|
}
|
||
|
});
|
||
|
}
|
||
|
}
|
||
|
});
|
||
12 years ago
|
|
||
12 years ago
|
$("#wgt_help").click(function(){
|
||
|
var tmp = $(this);
|
||
|
if($(this).hasClass("open")){
|
||
12 years ago
|
$(this).removeClass("help_pad").removeClass("help_wood")
|
||
12 years ago
|
$("#help").slideUp("100", function(){
|
||
|
tmp.removeClass("open");
|
||
|
$("#data").show();
|
||
12 years ago
|
($("#wgt_edit").hasClass("selected"))?$("#parameters").show():'';
|
||
12 years ago
|
});
|
||
|
} else {
|
||
12 years ago
|
($("#style_select").val() == 1)?$(this).removeClass("help_pad").addClass("help_wood"):$(this).removeClass("help_wood").addClass("help_pad");
|
||
|
$("#data, #parameters").hide();
|
||
12 years ago
|
$("#help").slideDown("100", function(){
|
||
|
tmp.addClass("open");
|
||
|
});
|
||
|
}
|
||
|
});
|
||
13 years ago
|
|
||
|
$("#wgt_reload").click(function(){
|
||
12 years ago
|
reloadItems();
|
||
13 years ago
|
});
|
||
|
|
||
|
$("#wgt_add").click(function(){
|
||
12 years ago
|
if($("#wgt_help").hasClass("open")){
|
||
|
$("#help").slideUp("100", function(){
|
||
|
$("#wgt_help").removeClass("open");
|
||
|
$("#data").show();
|
||
|
});
|
||
|
}
|
||
12 years ago
|
shadowDiv.show();
|
||
12 years ago
|
shadowOver = true;
|
||
12 years ago
|
popupBack.show("slow");
|
||
13 years ago
|
$(document).disableTextSelect();
|
||
|
});
|
||
|
|
||
12 years ago
|
$("#style_select option[value='1']").text(sankoreLang.slate);
|
||
|
$("#style_select option[value='2']").text(sankoreLang.pad);
|
||
13 years ago
|
|
||
12 years ago
|
$("#style_select").change(function (event){
|
||
13 years ago
|
changeStyle($(this).find("option:selected").val());
|
||
|
})
|
||
|
|
||
|
/* -------------- END OF WORK WITH BUTTONS ---------------*/
|
||
|
|
||
|
//basic divs
|
||
|
var leftDiv = $("<div id='leftDiv' class='leftDiv'>").appendTo("#data");
|
||
|
var rightDiv = $("<div id='rightDiv' class='rightDiv'>").appendTo("#data");
|
||
|
|
||
|
//divs for adding a new item
|
||
12 years ago
|
var shadowDiv = $("<div id='shadowDiv' class='shadowDiv'>").appendTo("html");
|
||
13 years ago
|
var popupBack = $("<div id='popupBack' class='popupBack'>").appendTo("#data");
|
||
|
|
||
|
//input fields and buttons for a popup window
|
||
|
var expressionDiv = $("<div id='expressionDiv' class='popupContainers'>").appendTo(popupBack);
|
||
|
var experssionLabel = $("<span id='experssionLabel' class='popupLabels'><b>" + sankoreLang.enter_data + "</b></span>").appendTo(expressionDiv);
|
||
|
var expresionText = $("<input type='text' id='expresionText' class='expresionInput'/>").appendTo(expressionDiv);
|
||
|
|
||
|
var resultDiv = $("<div id='resultDiv' class='popupContainers'>").appendTo(popupBack);
|
||
|
var resultLabel = $("<span id='resultLabel' class='popupLabels'><b>" + sankoreLang.enter_result + "</b></span>").appendTo(resultDiv);
|
||
|
var resultText = $("<input type='text' id='resultText' class='expresionInput'/>").appendTo(resultDiv);
|
||
|
|
||
|
var popupButtonsDiv= $("<div id='popupButtonsDiv' class='popupContainers'>").appendTo(popupBack);
|
||
|
var cancelButton = $("<input type='button' id='cancelButton' class='popupButtons' value='" + sankoreLang.cancel + "'/>").appendTo(popupButtonsDiv);
|
||
|
var okButton = $("<input type='button' id='okButton' class='popupButtons' value='" + sankoreLang.ok + "'/>").appendTo(popupButtonsDiv);
|
||
|
|
||
|
/* -------------- A WORK WITH POPUP BUTTONS AND FIELDS ---------------*/
|
||
|
|
||
|
$("#resultText, #expresionText").keyup(function(){
|
||
|
if($(this).val()){
|
||
|
$(this).css("background-color", "#ff9");
|
||
|
}
|
||
|
});
|
||
|
|
||
|
cancelButton.click(function(){
|
||
|
popupBack.hide("slow", function(){
|
||
|
$("#resultText, #expresionText").val("")
|
||
|
.css("background-color", "#ffc");
|
||
12 years ago
|
shadowDiv.hide();
|
||
13 years ago
|
shadowOver = false;
|
||
12 years ago
|
$(document).enableTextSelect();
|
||
13 years ago
|
});
|
||
|
});
|
||
|
|
||
|
okButton.click(function(){
|
||
|
if(checkEmptyFields(expresionText) && checkEmptyFields(resultText)){
|
||
|
popupBack.hide("slow", function(){
|
||
12 years ago
|
shadowDiv.hide();
|
||
13 years ago
|
shadowOver = false;
|
||
|
addTask(expresionText.val(), resultText.val());
|
||
13 years ago
|
exportToSankore();
|
||
13 years ago
|
$("#resultText, #expresionText").val("")
|
||
|
.css("background-color", "#ffc");
|
||
12 years ago
|
$(document).enableTextSelect();
|
||
13 years ago
|
})
|
||
|
}
|
||
|
});
|
||
|
|
||
|
/* -------------- THE END OF WORK WITH POPUP BUTTONS AND FIELDS ---------------*/
|
||
|
|
||
|
// a work with dragging possibility
|
||
12 years ago
|
$("input:text").mouseover(function(){
|
||
13 years ago
|
$(document).enableTextSelect();
|
||
|
});
|
||
|
|
||
12 years ago
|
$("input:text").mouseout(function(){
|
||
13 years ago
|
$(document).disableTextSelect();
|
||
|
});
|
||
|
|
||
|
$(".readyTask, .editContainer").live("mousedown",function(event){
|
||
12 years ago
|
if($("#wgt_display").hasClass("selected")){
|
||
|
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();
|
||
|
}
|
||
12 years ago
|
$(document).disableTextSelect();
|
||
13 years ago
|
}
|
||
|
});
|
||
|
|
||
|
$("body").mouseup(function(event){
|
||
12 years ago
|
if($("#wgt_display").hasClass("selected")){
|
||
|
if(!shadowOver){
|
||
|
if (dragElement) {
|
||
|
exportToSankore();
|
||
|
}
|
||
|
dragElement = null;
|
||
|
resizeObj.x = false;
|
||
|
resizeObj.y = false;
|
||
13 years ago
|
}
|
||
13 years ago
|
}
|
||
|
});
|
||
|
|
||
|
$("body").mousemove(function(event){
|
||
12 years ago
|
if(dragElement && !shadowOver && $("#wgt_display").hasClass("selected")){
|
||
12 years ago
|
var top = event.pageY - coords.top;
|
||
|
var left = event.pageX - coords.left;
|
||
|
var bottom = top + dragElement.height();
|
||
|
var right = left + dragElement.width();
|
||
|
if(resizeObj.x){
|
||
|
if(right < ($(window).width() - 54))
|
||
|
dragElement.width(event.pageX - dragElement.position().left);
|
||
|
}
|
||
|
else if(resizeObj.y){
|
||
|
if(bottom < ($(window).height() - 54))
|
||
|
dragElement.height(event.pageY - dragElement.position().top);
|
||
|
}
|
||
|
else {
|
||
|
if((top > 54) && (bottom < ($(window).height() - 54)))
|
||
|
dragElement.css("top",event.pageY - coords.top);
|
||
|
if((left >= 54) && (right < ($(window).width() - 54)))
|
||
|
dragElement.css("left", event.pageX - coords.left);
|
||
|
}
|
||
13 years ago
|
}
|
||
|
});
|
||
|
|
||
|
//closing item
|
||
|
$(".closeItem").live("click", function(){
|
||
|
if(!shadowOver){
|
||
|
$(this).parent().remove();
|
||
12 years ago
|
if($(".editContainer").size() > 0){
|
||
|
var prev = $(".editContainer:first");
|
||
|
if((prev.position().left == 54) && (prev.position().top != 60))
|
||
|
prev.css("top", "60px");
|
||
|
var prevBottom = prev.position().top + prev.height(),
|
||
|
prevLeft = prev.position().left;
|
||
|
if(prev.next().length)
|
||
|
recursionCall(prevBottom, prevLeft, prev.next());
|
||
|
}
|
||
13 years ago
|
}
|
||
|
});
|
||
|
|
||
12 years ago
|
$(".taskContainer").live("keyup", function(){
|
||
|
if($(".editContainer").size() > 1){
|
||
|
var prev = $(".editContainer:first"),
|
||
|
prevBottom = prev.position().top + prev.height(),
|
||
|
prevLeft = prev.position().left;
|
||
|
recursionCall(prevBottom, prevLeft, prev.next());
|
||
|
}
|
||
|
})
|
||
|
|
||
|
function recursionCall(prevBottom, prevLeft, curr){
|
||
12 years ago
|
var curHeight = curr.height(),
|
||
12 years ago
|
curLeft = curr.position().left;
|
||
|
if(prevLeft == curLeft){
|
||
|
if((prevBottom + 15 + curHeight) < ($(window).height() - 54))
|
||
|
curr.css("top", prevBottom + 15 + "px");
|
||
|
else
|
||
12 years ago
|
curr.css("top", "100px").css("left", prevLeft + 255 + "px");
|
||
12 years ago
|
} else {
|
||
|
if((prevBottom + 15 + curHeight) < ($(window).height() - 54))
|
||
|
curr.css("top", prevBottom + 15 + "px").css("left", prevLeft + "px");
|
||
|
else
|
||
12 years ago
|
curr.css("top", "100px").css("left", prevLeft + 255 + "px");
|
||
12 years ago
|
}
|
||
|
prevBottom = curr.position().top + curr.height(),
|
||
|
prevLeft = curr.position().left;
|
||
|
if(curr.next().length)
|
||
|
recursionCall(prevBottom, prevLeft, curr.next());
|
||
|
}
|
||
|
|
||
13 years ago
|
//$("#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(){
|
||
12 years ago
|
if(!resizeFlag){
|
||
|
if($("#wgt_edit").hasClass("selected")){
|
||
|
if($(".editContainer").size() > 1){
|
||
|
var prev = $(".editContainer:first"),
|
||
|
prevBottom = prev.position().top + prev.height(),
|
||
|
prevLeft = prev.position().left;
|
||
|
recursionCall(prevBottom, prevLeft, prev.next());
|
||
|
}
|
||
|
} else {
|
||
|
var tmp_array = [];
|
||
|
$(".readyTask").each(function(){
|
||
|
tmp_array.push($(this));
|
||
|
});
|
||
|
orderItems(tmp_array);
|
||
12 years ago
|
}
|
||
12 years ago
|
popupBack.css("top", ($(window).height() - 138)*50/$(window).height() + "%");
|
||
|
popupBack.css("left", ($(window).width() - 360)*50/$(window).width() + "%");
|
||
|
} else
|
||
|
resizeFlag = false;
|
||
13 years ago
|
});
|
||
|
|
||
|
if (window.widget) {
|
||
|
window.widget.onleave = function(){
|
||
12 years ago
|
exportToSankore();
|
||
12 years ago
|
sankore.setPreference("by_style", $("#style_select").find("option:selected").val());
|
||
13 years ago
|
}
|
||
|
}
|
||
|
|
||
|
// 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();
|
||
12 years ago
|
objToExport.top = $(domElem).position().top - 40;
|
||
13 years ago
|
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);
|
||
|
});
|
||
|
}
|
||
|
}
|
||
12 years ago
|
if(window.sankore)
|
||
|
sankore.setPreference("blackYellowData", JSON.stringify(arrayToExport));
|
||
13 years ago
|
}
|
||
|
}
|
||
|
|
||
|
//checking empty fields
|
||
|
function checkEmptyFields(field){
|
||
|
if(field.val() == ""){
|
||
|
field.css("background-color", "red");
|
||
|
return false;
|
||
|
} else {
|
||
|
field.css("background-color", "#ff9");
|
||
|
return true;
|
||
|
}
|
||
|
}
|
||
|
|
||
12 years ago
|
//reload
|
||
|
function reloadItems(){
|
||
|
if($("#wgt_edit").hasClass("selected"))
|
||
|
$("#wgt_display").trigger("click");
|
||
|
else{
|
||
|
var tmp_array = [];
|
||
|
$(".readyTask").each(function(){
|
||
|
tmp_array.push($(this));
|
||
|
});
|
||
|
tmp_array = shuffle(tmp_array);
|
||
|
orderItems(tmp_array);
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
|
//order items
|
||
|
function orderItems(items){
|
||
12 years ago
|
var bottom = ($("#wgt_edit").hasClass("selected"))?85:45,
|
||
12 years ago
|
lastItemLeft = 54;
|
||
|
for (var i in items){
|
||
|
if((bottom + items[i].height()) < ($(window).height() - 54)){
|
||
|
items[i].css("top", bottom + 15 + "px").css("left", lastItemLeft + "px").appendTo("#data");
|
||
|
bottom += items[i].height() + 15;
|
||
|
} else {
|
||
12 years ago
|
bottom = 100;
|
||
12 years ago
|
lastItemLeft += 255;
|
||
|
items[i].css("top", bottom + "px").css("left", lastItemLeft + "px").appendTo("#data");
|
||
|
bottom += items[i].height();
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
//shuffles an array
|
||
|
function shuffle( arr )
|
||
|
{
|
||
|
var pos, tmp;
|
||
|
for( var i = 0; i < arr.length; i++ )
|
||
|
{
|
||
|
pos = Math.round( Math.random() * ( arr.length - 1 ) );
|
||
|
tmp = arr[pos];
|
||
|
arr[pos] = arr[i];
|
||
|
arr[i] = tmp;
|
||
|
}
|
||
|
return arr;
|
||
|
}
|
||
|
|
||
13 years ago
|
//adding a new task to the page
|
||
|
function addTask(expression, result){
|
||
13 years ago
|
var lastItem = $(".editContainer:last"),
|
||
12 years ago
|
lastItemPos = lastItem.length ? lastItem.position().top : 85,
|
||
12 years ago
|
lastItemHeight = lastItem.length ? lastItem.height() : 0,
|
||
|
lastItemLeft = lastItem.length ? lastItem.position().left : 54;
|
||
|
var bottom = lastItemPos + lastItemHeight + 85;
|
||
|
var editContent = $("<div class='editContainer'>");
|
||
|
$("<div class='closeItem'>").appendTo(editContent);
|
||
13 years ago
|
var main = $("<div class='readyTask'>");
|
||
12 years ago
|
$("<div class='taskContainer' style='color: yellow;' contenteditable='true'>" + expression + "</div>").appendTo(main);
|
||
|
$("<div class='taskContainer' style='color: black;' contenteditable='true'>"+ result + "</div>").appendTo(main);
|
||
|
if(bottom < ($(window).height() - 54)){
|
||
|
editContent.css("top", lastItemPos + lastItemHeight + 15 + "px").css("left", lastItemLeft + "px").appendTo("#data");
|
||
|
} else {
|
||
12 years ago
|
lastItemPos = 85;
|
||
12 years ago
|
editContent.css("top", lastItemPos + 15 + "px").css("left", lastItemLeft + 255 + "px").appendTo("#data");
|
||
|
}
|
||
13 years ago
|
main.appendTo(editContent);
|
||
|
}
|
||
|
|
||
|
//changing the style
|
||
|
function changeStyle(val){
|
||
13 years ago
|
switch(val){
|
||
|
case "1":
|
||
|
$(".b_top_left").removeClass("btl_pad").removeClass("without_back");
|
||
|
$(".b_top_center").removeClass("btc_pad").removeClass("without_back");
|
||
|
$(".b_top_right").removeClass("btr_pad").removeClass("without_back");
|
||
|
$(".b_center_left").removeClass("bcl_pad").removeClass("without_back");
|
||
|
$(".b_center_right").removeClass("bcr_pad").removeClass("without_back");
|
||
|
$(".b_bottom_right").removeClass("bbr_pad").removeClass("without_back");
|
||
|
$(".b_bottom_left").removeClass("bbl_pad").removeClass("without_back");
|
||
|
$(".b_bottom_center").removeClass("bbc_pad").removeClass("without_back");
|
||
|
$("#wgt_reload").removeClass("pad_color").removeClass("pad_reload");
|
||
12 years ago
|
$("#wgt_help").removeClass("pad_color").removeClass("pad_help");
|
||
12 years ago
|
$("#wgt_edit").removeClass("pad_color").removeClass("pad_edit");
|
||
13 years ago
|
$("#wgt_name").removeClass("pad_color");
|
||
12 years ago
|
$("#wgt_display").addClass("display_wood");
|
||
|
$("#style_select").val(val);
|
||
|
$("body, html").removeClass("without_radius").addClass("radius_ft");
|
||
13 years ago
|
break;
|
||
|
case "2":
|
||
|
$(".b_top_left").addClass("btl_pad").removeClass("without_back");
|
||
|
$(".b_top_center").addClass("btc_pad").removeClass("without_back");
|
||
|
$(".b_top_right").addClass("btr_pad").removeClass("without_back");
|
||
|
$(".b_center_left").addClass("bcl_pad").removeClass("without_back");
|
||
|
$(".b_center_right").addClass("bcr_pad").removeClass("without_back");
|
||
|
$(".b_bottom_right").addClass("bbr_pad").removeClass("without_back");
|
||
|
$(".b_bottom_left").addClass("bbl_pad").removeClass("without_back");
|
||
|
$(".b_bottom_center").addClass("bbc_pad").removeClass("without_back");
|
||
|
$("#wgt_reload").addClass("pad_color").addClass("pad_reload");
|
||
12 years ago
|
$("#wgt_help").addClass("pad_color").addClass("pad_help");
|
||
12 years ago
|
$("#wgt_edit").addClass("pad_color").addClass("pad_edit");
|
||
13 years ago
|
$("#wgt_name").addClass("pad_color");
|
||
12 years ago
|
$("#wgt_display").removeClass("display_wood");
|
||
|
$("#style_select").val(val);
|
||
|
$("body, html").removeClass("without_radius").removeClass("radius_ft");
|
||
13 years ago
|
break;
|
||
|
case "3":
|
||
|
$(".b_top_left").addClass("without_back").removeClass("btl_pad");
|
||
|
$(".b_top_center").addClass("without_back").removeClass("btc_pad");
|
||
|
$(".b_top_right").addClass("without_back").removeClass("btr_pad");
|
||
|
$(".b_center_left").addClass("without_back").removeClass("bcl_pad");
|
||
|
$(".b_center_right").addClass("without_back").removeClass("bcr_pad");
|
||
|
$(".b_bottom_right").addClass("without_back").removeClass("bbr_pad");
|
||
|
$(".b_bottom_left").addClass("without_back").removeClass("bbl_pad");
|
||
|
$(".b_bottom_center").addClass("without_back").removeClass("bbc_pad");
|
||
12 years ago
|
$("#wgt_help").addClass("pad_color").addClass("pad_help");
|
||
13 years ago
|
$("#wgt_reload").addClass("pad_color").addClass("pad_reload");
|
||
|
$("#wgt_edit").addClass("pad_color").addClass("pad_edit");
|
||
|
$("#wgt_name").addClass("pad_color");
|
||
12 years ago
|
$("#wgt_display").removeClass("display_wood");
|
||
|
$("#style_select").val(val);
|
||
|
$("body, html").addClass("without_radius").removeClass("radius_ft");
|
||
13 years ago
|
break;
|
||
13 years ago
|
}
|
||
12 years ago
|
if($("#wgt_edit").hasClass("selected"))
|
||
|
$(document).enableTextSelect();
|
||
12 years ago
|
}
|