1//Variable globale qui permet de gérer l'affichage ou non des div d'administration 2var isOnDragGlobal=false; 3 4/* MOBILE ADAPTED */ 5function buildMail(elID, strAddress, strUrl, strClass, strNom , strOption) //strOption doit commencer par le ? ex: "?subject=contact" 6{ 7 if(!strNom) 8 strNom = strAddress +'@' + strUrl; 9 10 if(!strClass) 11 strClass = ""; 12 13 if(!strOption) 14 strOption = ""; 15 16 //Change for mobile compatibility 17 //document.write('<a class="' + strClass + '" hre' + 'f="mai' + 'lto:' + strAddress +'@' + strUrl + strOption + '">' + strNom +'</a>') ; 18 var span = document.getElementById(elID); 19 if(span) //si toruve pas fais rien 20 span.innerHTML = '<a class="' + strClass + '" hre' + 'f="mai' + 'lto:' + strAddress +'@' + strUrl + strOption + '">' + strNom +'</a>'; 21} 22 23function checkEmailFormat(email) 24{ 25 var goodYourEmail = email.match(/\b(^(\S+@).+((\.com)|(\.net)|(\.edu)|(\.mil)|(\.biz)|(\.info)|(\.gov)|(\.org)|(\..{2,2}))$)\b/gi); 26 if(!goodYourEmail) 27 return false; 28 return true ; 29} 30 31/*Check si extension est une image, renvoi true si ok, false sinon*/ 32function checkImageExtension(ps_filename) 33{ 34 var a_tmp = ps_filename.trim().split(/\./gi); 35 var ext = a_tmp[a_tmp.length-1]; 36 ext = ext.toLowerCase(); 37 if(ext == "jpg" || ext == "jpeg" || ext == "png" || ext == "gif") 38 return true; 39 else 40 return false; 41} 42 43 44/******** Ajoute la fonction trim comme méthode de l'objet String. ***************/ 45String.prototype.trim = function() 46{ return this.replace(/(^\s*)|(\s*$)/g, ""); } 47 48/******************** AJAX *****************************/ 49//Retourne la requete ajax 50function getAjaxRequest() 51{ 52 var request = false; 53 try { 54 request = new ActiveXObject('Msxml2.XMLHTTP'); 55 } 56 catch (err2) { 57 try { 58 request = new ActiveXObject('Microsoft.XMLHTTP'); 59 } 60 catch (err3) { 61 try { 62 request = new XMLHttpRequest(); 63 } 64 catch (err1) 65 { 66 request = false; 67 } 68 } 69 } 70 return request; 71} 72//Retourne l'image d'attente lors du chargement en ajax 73function getAjaxWait() 74{ 75 return "<img src=\"/template/image/loading.gif\"/>"; 76} 77 78//Fonction qui permet de créer une popup 79var newWin = null; 80 81function closeWin() 82{ 83 if (newWin != null) 84 { 85 if(!newWin.closed) 86 newWin.close(); 87 } 88} 89 90function popUp(strURL,strType,strWidth,strHeight) 91{ 92 closeWin(); 93 94 var strOptions=""; 95 if (strType=="console") 96 strOptions="resizable,height="+strHeight+",width="+strWidth; 97 98 if (strType=="fixed") 99 strOptions="status,height="+strHeight+",width="+strWidth; 100 101 if (strType=="elastic") 102 strOptions="toolbar,menubar,scrollbars,resizable,location,height="+strHeight+",width="+strWidth; 103 104 if (strType=="scroll") 105 strOptions="scrollbars,resizable,height="+strHeight+",width="+strWidth; 106 107 newWin = window.open(strURL, 'newWin', strOptions); 108 109 newWin.focus(); 110} 111 112function addLoadListener(func) 113{ 114 //Previous Version 115 /*if (window.addEventListener) 116 { 117 window.addEventListener("load", func, false); 118 } 119 else if (document.addEventListener) 120 { 121 document.addEventListener("load", func, false); 122 } 123 else if (window.attachEvent) 124 { 125 window.attachEvent("onload", func); 126 }*/ 127 128 //Nouvelle version EV: pour lancer le "toRun" au onDOMContentLoaded au lieu du onload 129 var loadListenerFlag = false; //Flag pour s'assurer que la fonction est pas lancée 2 fois 130 var loadListenerFunction = function(){if(!loadListenerFlag){loadListenerFlag=true;func();}}; //Fonction appelé par les évents ci-dessous, elle appelle la fct recu en paramètre en fonction du flag. Attention mettre le loadListenerFlag=true en premier 131 132 if(document.addEventListener) //Firefox, safari, opera support l'event DOMContentLoaded 133 document.addEventListener("DOMContentLoaded", loadListenerFunction, false); 134 else if(document.attachEvent) //IE support pas DOMContentLoaded 135 { 136 //Sur IE, si j'ai un imitDivPopup, je met que le onload pour éviter tous conflit de chargement 137 if(func.toString().indexOf("imitDivPopup")<0) 138 { 139 //Essayé avec document.attachEvent("onreadystatechange",...), mais marche pas lors du premier chargement, IE passe pas par l'etat "interactive" et le "complete" est trop long à venir 140 //Lance un timeout pour tester le document.readyState, comme ca je passe par "interactive" si le doc est lent à charger. Test quand même si le loadListenerFlag est déjà à true pour pas relance le timeOut et la fonction inutilement 141 setTimeout(function(){if(loadListenerFlag==true)return;if(document.readyState=="interactive" || document.readyState=="complete")loadListenerFunction();else setTimeout(arguments.callee,50);},50); 142 } 143 } 144 145 //Fallback: On laisse l'événement onload, au cas ou un navigateur supporte pas les events du dessus 146 if (window.addEventListener) 147 window.addEventListener("load", loadListenerFunction, false); 148 else if (window.attachEvent) 149 window.attachEvent("onload", loadListenerFunction); 150} 151 152function getConfirm(ps_msg, ps_url) 153{ 154 if(confirm(ps_msg)) 155 { 156 waitOnEndPopup(); 157 window.location.href = ps_url; 158 } 159} 160 161//Redefinition de la fonction window.open pour le chikita (permet de faire les divPopup sur les images) 162window.openChikita = function(url,target,attributes) 163{
164 if(target == "divPopup") 165 { 166 //Seulement si c'est une image 167 if(checkImageExtension(url)) 168 { 169 divPopupImage(url); 170 return null; 171 } 172 } 173 return openStandard(url,target,attributes); 174} 175 176window.openStandard = window.open; 177window.open = window.openChikita; 178 179 180/* FONCTION EN JQUERY */ 181//Lance le recadrage en fonction du $selector. Si $selector est pas défini alors il prend tous le document 182function valignAll($selector) 183{ 184 $(".valign", $selector).each(function() 185 { 186 valign($(this)); 187 }); 188} 189//Recadre et Centre un element en particulier basé sur la taille du parent ou centre un element dans le parent si pas une image 190function valign($obj) 191{ 192 if($obj.hasClass("done")) 193 return; 194 195 if($obj.is("img")) 196 { 197 if(!$obj.get()[0].complete) 198 { 199 $obj.load( function(){ valign($obj); }); 200 $(window).load( function(){ valign($obj);}); //Pour éviter problème IE10 sur load img 201 return; 202 } 203 else 204 { 205 $parent = $obj.parent(); 206 $parent.css("overflow", "hidden"); 207 var w = $obj.width(); 208 var h = $obj.height(); 209 if($obj.width()==0) //traitement image cachée 210 { 211 var img = new Image(); 212 img.src = $obj.attr("src"); 213 w = img.width; 214 h = img.height; 215 } 216 217 var newH = Math.floor($parent.width()*h/w); 218 var newW = Math.floor($parent.height()*w/h); 219 if(newH>=$parent.height()) { 220 $obj.css("width","100%").css("margin-top", Math.ceil((newH-$parent.height())/2)*(-1)); 221 } 222 else 223 $obj.css("height","100%").css("margin-left", Math.ceil((newW-$parent.width())/2)*(-1)); 224 } 225 } 226 else 227 $obj.css("position", "relative").css("top", "50%").css("margin-top", Math.ceil($obj.height()/2)*(-1)); 228 229 //Pour éviter de refaire plusieurs fois sur un meme element 230 $obj.addClass("done"); 231} 232//Recadre et Centre un element en particulier basé sur la taille du parent ou centre un element dans le parent si pas une image 233function halign($obj) 234{ 235 if($obj.hasClass("done")) 236 return; 237 238 if($obj.is("img")) 239 { 240 if(!$obj.get()[0].complete) 241 { 242 $obj.load( function(){ valign($obj); }); 243 $(window).load( function(){ valign($obj);}); //Pour éviter problème IE10 sur load img 244 return; 245 } 246 else 247 { 248 $parent = $obj.parent(); 249 $parent.css("overflow", "hidden"); 250 var w = $obj.width(); 251 var h = $obj.height(); 252 if($obj.width()==0) //traitement image cachée 253 { 254 var img = new Image(); 255 img.src = $obj.attr("src"); 256 w = img.width; 257 h = img.height; 258 } 259 260 var newH = Math.floor($parent.width()*h/w); 261 var newW = Math.floor($parent.height()*w/h); 262 if(newW>=$parent.width()) { 263 $obj.css("width","100%").css("margin-top", Math.ceil((newH-$parent.height())/2)*(-1)); 264 } 265 else 266 $obj.css("height","100%").css("margin-left", Math.ceil((newW-$parent.width())/2)*(-1)); 267 } 268 } 269 else 270 $obj.css("position", "relative").css("top", "50%").css("margin-top", Math.ceil($obj.height()/2)*(-1)); 271 272 //Pour éviter de refaire plusieurs fois sur un meme element 273 $obj.addClass("done"); 274} 275 276function charEffect() 277{ 278 $(".chareffect a").each(function(){ 279 280 var timer = null; 281 var $a = $(this).wrapInner("<span/>").find("span"); 282 var $b = $("<span/>").prependTo(this).addClass("chareffecthover"); 283 var me = $(this); 284 var f = function(){ 285 var txt = $a.text(); 286 if(txt!="") 287 { 288 $b.text( $b.text() + txt.charAt(0) + txt.charAt(1)); 289 $a.text( txt.slice(2) ); 290 timer = setTimeout(f,50); 291 } 292 }; 293 var revf = function(){ 294 var txt = $b.text(); 295 if(txt!="") 296 { 297 $a.text( txt.charAt(txt.length-2) + txt.charAt(txt.length-1) + $a.text()); 298 $b.text( txt.slice(0,-2) ); 299 timer = setTimeout(revf,50); 300 } 301 }; 302 303 $(this).hover(function(){ 304 clearTimeout(timer); 305 f(); 306 }, function(){ 307 clearTimeout(timer); 308 revf(); 309 }); 310 311 }); 312} 313function swipe(pCtn, pRTLcallback, pLTRcallback) 314{ 315 //Avoid swipe on input type=text 316 $("input[type=text]", $(pCtn)).bind("mousedown.swipe touchstart.swipe", function(evt){ evt.stopImmediatePropagation(); }); 317 318 /** Ajout du Swipe **/ 319 var xDown;var xUp; var tolerance=100; 320 $(pCtn).bind("mousedown.swipe", function(evt){ evt.preventDefault(); } ); 321 $(pCtn).bind('mousedown.swipe touchstart.swipe', function (evt) { 322 if(evt.originalEvent.targetTouches) 323 xDown = evt.originalEvent.targetTouches[0].pageX; 324 else 325 xDown = evt.pageX; 326 327 xUp = xDown; 328 }).bind('mousemove.swipe touchmove.swipe', function (evt) { 329 if(evt.originalEvent.targetTouches) 330 xUp = evt.originalEvent.targetTouches[0].pageX; 331 else 332 xUp = evt.pageX; 333 334 }) 335 .bind('mouseup.swipe touchend.swipe',function (evt) { 336 if(Math.abs(xDown-xUp)>tolerance) 337 { 338 if (xDown > xUp) 339 { 340 if(pRTLcallback) 341 pRTLcallback(); 342 } 343 else if (xDown < xUp) 344 { 345 if(pLTRcallback) 346 pLTRcallback(); 347 } 348 349 if(!('ontouchstart' in window)) 350 { 351 $(this).one('click',function(evt){ evt.preventDefault(); evt.stopPropagation(); }); 352 } 353 } 354 }); 355} 356function unswipe(pCtn ) 357{ 358 $(pCtn).unbind("mousedown.swipe touchstart.swipe mousemove.swipe touchmove.swipe mouseup.swipe touchend.swipe"); 359 $("input[type=text]", $(pCtn)).unbind("mousedown.swipe touchstart.swipe"); 360} 361/* RESPONSIVE: Fonction pour responsivé les tables */ 362function responsiveTable(ps_ctn) 363{ 364 $(".right table:not(.noresponsive)", ps_ctn).each(function(){ 365 var $table = $(this); 366
367 if($table.hasClass("tblContextMenu") || $table.hasClass("tblContextMenuTitle")) 368 return; 369 370 //Verifie si table déjà responsivée 371 if($table.hasClass("responsived")) 372 return; 373 374 //lance la responsivation 375 $table.addClass("responsived"); 376 var $original = $("tbody", $table).addClass("originaltbody"); 377 378 var $tbod = $("<tbody class=\"responsivedtbody\"><tr><td></td></tr></tbody>"); 379 var $tdctn = $("td", $tbod); 380 381 if($("th", $table).length==0 || $table.hasClass("asline")) //table sans TH, je met une cellule sous l'autre 382 { 383 var myctn = $("<div class=\"tr noth\"></div>"); 384 $("tr", $table).each(function(){ 385 $(this).children().each(function(idx){ 386 var mydiv = $("<div class=\"td\"></div>"); 387 if($(this).prop("tagName")=="TH")//version pour matrice 388 mydiv.append($("<div class=\"tdlabel asline\"></div>").text($.trim($(this).text()))); 389 else 390 mydiv.append($("<div class=\"tddata\"></div>").html($(this).html())); 391 mydiv.appendTo(myctn); 392 }); 393 }); 394 myctn.appendTo($tdctn); 395 } 396 else 397 { 398 $trFirst = $("tr:first", $table); 399 if($("> th", $trFirst).length>1) //table avec TH sur la premiere ligne 400 { 401 $("tr", $table).slice(1).each(function(){ 402 var myctn = $("<div class=\"tr\"></div>"); 403 $(this).children().each(function(idx){ 404 var mydiv = $("<div class=\"td\"></div>"); 405 if($(this).prop("tagName")=="TH")//version pour matrice 406 { 407 mydiv.append($("<div class=\"tdlabel firstlevel\"></div>").text($.trim($trFirst.children().eq(idx).text()))); 408 mydiv.append($("<div class=\"tdlabel\"></div>").text($.trim($(this).text()))); 409 } 410 else 411 { 412 mydiv.append($("<div class=\"tdlabel\"></div>").text($.trim($trFirst.children().eq(idx).text()))); 413 mydiv.append($("<div class=\"tddata\"></div>").html($(this).html())); 414 } 415 mydiv.appendTo(myctn); 416 }); 417 myctn.appendTo($tdctn); 418 }); 419 } 420 else //table avec TH sur la premiere colonne 421 { 422 var colCount = $trFirst.children().length; //nbre de colonne 423 //var rowCount = $("> tr", $table).length(); 424 for(var i=1;i<colCount;i++) 425 { 426 var myctn = $("<div class=\"tr\"></div>"); 427 $("tr", $table).each(function(){ 428 var lbl = $.trim($(this).children().eq(0).text()); 429 $(this).children().eq(i).each(function(){ 430 var mydiv = $("<div class=\"td\"></div>"); 431 mydiv.append($("<div class=\"tdlabel\"></div>").text(lbl)) 432 mydiv.append($("<div class=\"tddata\"></div>").html($(this).html())); 433 mydiv.appendTo(myctn); 434 }); 435 }); 436 myctn.appendTo($tdctn); 437 } 438 } 439 } 440 441 //Fonction pour afficher le bon tbody et remover l'autre pour éviter conflit d'id ou de champs de formulaire 442 var curDisplayed = "original"; 443 var doDisplay = function(){ 444 445 if(curDisplayed=="original" && $original.css("display")!="table-row-group") 446 { 447 $original.detach(); //attention detach before appendTo for radioButton 448 $tbod.appendTo($table); 449 copyFieldValue($original, $tbod); 450 curDisplayed = "responsived"; 451 $(document).trigger("refreshTable"); //event to refresh event on table (use in captcha for example) 452 } 453 else if(curDisplayed=="responsived" && $tbod.css("display")=="none") 454 { 455 $tbod.detach(); //attention detach before appendTo for radioButton 456 $original.appendTo($table); 457 copyFieldValue($tbod, $original); 458 curDisplayed = "original"; 459 $(document).trigger("refreshTable"); //event to refresh event on table (use in captcha for example) 460 } 461 462 } 463 464 //Fonction pour copier les valeurs des champs entre les 2 tbody (original et responsived) 465 var copyFieldValue = function($from, $to){ 466 $("input, select, textarea", $from).each(function(){ 467 if($(this).attr("type") && $(this).attr("type").toLowerCase() == "checkbox") 468 $($(this).prop("tagName") + "[name=\"" + $(this).attr("name") + "\"]", $to).prop("checked", $(this).prop("checked")); 469 else if($(this).attr("type") && $(this).attr("type").toLowerCase() == "radio") 470 $($(this).prop("tagName") + "[name=\"" + $(this).attr("name") + "\"][value=\"" + $(this).val() + "\"]", $to).prop("checked", $(this).prop("checked")); 471 else 472 $($(this).prop("tagName") + "[name=\"" + $(this).attr("name") + "\"]", $to).val($(this).val()); 473 }); 474 }; 475
476 doDisplay(); 477 $(window).resize(function(){ 478 doDisplay(); 479 }); 480 481 }); 482} 483 484//Déclenche la fonction sur .htmlcontent 485$(document).ready( function(){responsiveTable(".htmlcontent");});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.