X-Git-Url: http://git.euphorik.ch/?p=euphorik.git;a=blobdiff_plain;f=js%2Futil.js;fp=js%2Futil.js;h=5feacb5fb09db4f9cb9712d468f86704593c06a5;hp=7ca57609c5204129de0108c7b0a60c0f34152099;hb=81393a74d648e4830dc8c7c562fa203f50a105f6;hpb=828daf607fdce322ea17c1786dff84f712aa1632
diff --git a/js/util.js b/js/util.js
index 7ca5760..5feacb5 100644
--- a/js/util.js
+++ b/js/util.js
@@ -29,9 +29,9 @@ euphorik.Util = function (formater) {
$("#info .close").click(function() {
$("#info").slideUp(50);
});
-
+
$("body").append('
').append('');
-
+
this.formater = formater;
this.bulleActive = true;
};
@@ -45,7 +45,7 @@ euphorik.Util.messageType = {informatif: 0, question: 1, erreur: 2};
* @buttons An object where the properties are the labels and the values are functions which will be executed when a button is clicked.
* @format [bool] The message should be formated. (see 'formater.js')
* @time The time while the message is displayed. -1 for infinity.
- */
+ */
euphorik.Util.prototype.messageDialog = function(message, type, buttons, format, time) {
var thisUtil = this;
@@ -55,26 +55,26 @@ euphorik.Util.prototype.messageDialog = function(message, type, buttons, format,
if (this.timeoutMessageDialog) {
clearTimeout(this.timeoutMessageDialog);
}
-
+
var close = function() { $("#info").slideUp(100); };
close();
$("#info .message").html(!thisUtil.formater || !format ? message : thisUtil.formater.completeProcessing(message));
-
+
switch(type) {
case euphorik.Util.messageType.informatif : $("#info #icone").attr("class", "information"); break;
case euphorik.Util.messageType.question : $("#info #icone").attr("class", "interrogation"); break;
case euphorik.Util.messageType.erreur : $("#info #icone").attr("class", "exclamation"); break;
}
-
+
$("#info .buttons").html("");
objectEach(buttons, function(name, bouton) {
$("#info .buttons").append("" + name + "
").find("div:last").click(bouton).click(close);
});
-
- $("#info").slideDown(200);
+
+ $("#info").slideDown(200);
if (time !== -1) {
- this.timeoutMessageDialog = setTimeout(close, time || euphorik.conf.tooltipDisplayDefaultTime);
+ this.timeoutMessageDialog = setTimeout(close, time || euphorik.conf.tooltipDisplayDefaultTime);
}
};
@@ -93,38 +93,38 @@ euphorik.Util.prototype.afficherBoite = function(boite, cible, positionX, positi
var positionCible = cible.offset();
var positionBoite = {
left : positionX === euphorik.Util.positionTypeX.gauche ? positionCible.left - boite.width() :
- (positionX === euphorik.Util.positionTypeX.gaucheRecouvrement ? positionCible.left - boite.width() + cible.width() :
+ (positionX === euphorik.Util.positionTypeX.gaucheRecouvrement ? positionCible.left - boite.width() + cible.width() :
(positionX === euphorik.Util.positionTypeX.droitelsRecouvrement ? positionCible.left :
(positionX === euphorik.Util.positionTypeX.droite ? positionCible.left + cible.width() :
positionCible.left + cible.width() / 2 - boite.width() / 2 ))), // centre
top : positionY === euphorik.Util.positionTypeY.haut ? positionCible.top - boite.height() :
- (positionY === euphorik.Util.positionTypeY.hautRecouvrement ? positionCible.top - boite.height() + cible.height() :
+ (positionY === euphorik.Util.positionTypeY.hautRecouvrement ? positionCible.top - boite.height() + cible.height() :
(positionY === euphorik.Util.positionTypeY.basRecouvrement ? positionCible.top :
(positionY === euphorik.Util.positionTypeY.bas ? positionCible.top + cible.height() :
positionCible.top + cible.height() / 2 - boite.height() / 2 ))) // centre
};
-
+
// calcul les décalages en x et en y pour éviter que la boite ne sorte de la fenêtre, tient compte de la position des barres de défilement
- var marge = 10;
+ var marge = 10;
positionBoite.left = positionBoite.left < marge + window.pageXOffset ? marge + window.pageXOffset :
(boite.width() - $(window).width() + (positionBoite.left - window.pageXOffset) + marge > 0 ? $(window).width() - boite.width() - marge + window.pageXOffset : positionBoite.left);
positionBoite.top = positionBoite.top < marge + window.pageYOffset ? marge + window.pageYOffset :
(boite.height() - $(window).height() + (positionBoite.top - window.pageYOffset) + marge > 0 ? $(window).height() - boite.height() - marge + window.pageYOffset : positionBoite.top);
-
+
boite.css("top", positionBoite.top).css("left", positionBoite.left).show();
};
euphorik.Util.positionBulleType = {haut : 0, droite : 1, bas : 2, gauche : 3};
-
-/**
- * Affiche ou cache la barre d'attente.
- */
-euphorik.Util.prototype.showWaitBar = function() {
- $("#waitbar").show();
-};
-euphorik.Util.prototype.hideWaitBar = function() {
- $("#waitbar").hide();
-};
+
+/**
+ * Affiche ou cache la barre d'attente.
+ */
+euphorik.Util.prototype.showWaitBar = function() {
+ $("#waitbar").show();
+};
+euphorik.Util.prototype.hideWaitBar = function() {
+ $("#waitbar").hide();
+};
/**
* Affiche un info bulle lorsque le curseur survole l'élément donné.
@@ -134,11 +134,11 @@ euphorik.Util.prototype.hideWaitBar = function() {
*/
euphorik.Util.prototype.infoBulle = function(message, element, position) {
var thisUtil = this;
- var cacherBulle = function() {
+ var cacherBulle = function() {
$("#tooltipArrow").hide();
$("#tooltipMessage").hide();
};
-
+
position = position || euphorik.Util.positionBulleType.haut;
element.hover(
@@ -150,16 +150,16 @@ euphorik.Util.prototype.infoBulle = function(message, element, position) {
var m = $("#tooltipMessage");
var f = $("#tooltipArrow");
f.removeClass().addClass(position === euphorik.Util.positionBulleType.haut ? "tooltipArrowTop" :
- (position === euphorik.Util.positionBulleType.droite ? "tooltipArrowRight" :
+ (position === euphorik.Util.positionBulleType.droite ? "tooltipArrowRight" :
(position === euphorik.Util.positionBulleType.bas ? "tooltipArrowBottom" : "tooltipArrowLeft" )));
-
+
// remplie le paragraphe de la bulle avec le message
$("p", m).html(message);
-
+
// réinitialise la position, évite le cas ou la boite est collé à droite et remplie avec un texte la faisant dépassé
// dans ce cas la hauteur n'est pas calculé correctement
m.css("top", 0).css("left", 0);
-
+
var positionFleche = {
left : position === euphorik.Util.positionBulleType.haut || position === euphorik.Util.positionBulleType.bas ?
element.offset().left + element.outerWidth() / 2 - f.width() / 2 :
@@ -182,7 +182,7 @@ euphorik.Util.prototype.infoBulle = function(message, element, position) {
} else if (positionMessage.left < 0) {
positionMessage.left = 0;
}
-
+
m.css("top", positionMessage.top).css("left", positionMessage.left).show();
f.css("top", positionFleche.top).css("left", positionFleche.left).show();
},
@@ -233,7 +233,7 @@ euphorik.Util.prototype.replaceSelection = function(input, replaceString) {
var selectionStart = input.selectionStart;
var selectionEnd = input.selectionEnd;
input.value = input.value.substring(0, selectionStart) + replaceString + input.value.substring(selectionEnd);
-
+
if (selectionStart != selectionEnd) { // has there been a selection
this.setSelectionRange(input, selectionStart, selectionStart + replaceString.length);
} else { // set caret
@@ -253,7 +253,7 @@ euphorik.Util.prototype.replaceSelection = function(input, replaceString) {
};
/**
- * Applies rot13 to a given string. See : http://en.wikipedia.org/wiki/ROT13.
+ * Applies rot13 to a given string. See : http://en.wikipedia.org/wiki/ROT13.
* @param str the string.
*/
euphorik.Util.prototype.rot13 = function(str) {
@@ -268,7 +268,7 @@ euphorik.Util.prototype.rot13 = function(str) {
if (pos === ch.length) {
return "";
}
-
+
var c = ch.charCodeAt(pos);
return String.fromCharCode(
c +