function disconnect (){ u = escape (document.location.href); document.location.href="/profile/disconnect?u="+u; } /* initialize tools */ window.inlineEditor = { destroy: function (objType, objId) { if (confirm ("Do you really want to delete this ?")) { jQuery.getJSON ("/main/inlineEditor/delete", {o: objType, oid: objId}, function(data){ if (data.status == 'OK') { $("*[inlineItemEditor="+data.o+"] > *[oid="+data.oid+"]").slideUp ("slow"); } }); } } }; function updateProfileField(f,v,callback) { jQuery.getJSON("/profile/ajax/updater:field", {f: f, v: v}, callback); } function highlightTheRow (e) { elt = $(this); p = elt.parent (); c = p.attr("class"); p.attr("oldklass", c); p.attr("class", c+" highlightedRow"); } function unhighlightTheRow (e) { elt = $(this); p = elt.parent (); c = p.attr("class", p.attr("oldklass")); } function initComments() { $(".commentForm").ajaxForm ({ dataType: 'json', success: function (data) { if (data.status == 'NC') { } else { comList = $(".commentsList[oid="+data.oid+"]"); comList.html(comList.html()+data.html); $(".commentForm[oid="+data.oid+"] textarea").each(function(k){this.value='';}); //if (console) console.log ("ok"); } } }); $(".commentForm > textarea").click (function(e) { if ($(this).hasClass("commentTextareaActive")) return false; t = $(this).parent(); $("img", t).css ("display", "block"); $("input[type=submit]", t).css ("display","inline"); $(this).attr("class", "commentTextareaActive").val(""); $(this).attr("oldval", $(this).html()); }); $(".commentForm > textarea").blur (function(e) { if ($(this).val() != '') return; t = $(this).parent(); $("img", t).css ("display", "none"); $("input[type=submit]", t).css ("display","none"); $(this).attr("class", "commentTextarea").val($(this).attr("oldval")); }); $(".commentsRemainsLink").click (function(e) { e.preventDefault(); e.stopPropagation(); oid = $(this).parent().parent().attr("oid"); jQuery.getJSON ("/community/ajax/comment:expand?oid="+escape(oid),{},function(data) { comList = $(".commentsList[oid="+data.oid+"]"); comList.html(data.html); }); }); $(".flashThisLink").click(function(e) { oid = $(this).parent().attr("oid"); jQuery.getJSON ("/community/ajax/flash?oid="+escape(oid), function (data) { fls = $(".flashThisObject[oid="+data.oid+"]"); if (data.status == 'OK') { if (data.text != '') data.text += " - "; $("span", fls).html(data.text); $("a", fls).html(data.link); } else { if (data.status == 'NC') { fls.one ("connect", {oid: data.oid}, function(e) { fls = $(".flashThisObject[oid="+e.data.oid+"]"); $("a", fls).click(); }); $("#connectMe").click (); } } }); }); } $(function() { jQuery.each($('*[fancybox]'), function(i, e) { elt = $(e) h = parseInt (elt.attr("fancyHeight")); h = (h > 392) ? h : 392; w = parseInt(elt.attr("fancyWidth")); w = (w > 500) ? w : 500; elt.fancybox ({ hideOnContentClick: false, hideOnOverlayClick: false, frameWidth: w, frameHeight: h, overlayOpacity: 0.65 }); }); $(".fieldRow textarea").focus (highlightTheRow); $(".fieldRow textarea").blur (unhighlightTheRow); $(".fieldRow input[type=text]").focus (highlightTheRow); $(".fieldRow input[type=text]").blur (unhighlightTheRow); $(".fieldRow select").focus (highlightTheRow); $(".fieldRow select").blur (unhighlightTheRow); initComments(); }); /* tabbed box */ /* MS */ jQuery(function(){ $.fn.tabboxinit = function () { tabs = $("#"+this.attr('id')+" div[tab]"); for (i=0; i < tabs.length; i++) { tab = $(tabs.get(i)); tab.css("display", (tab.attr("activetab") == 1)?"block":"none"); $("li[href="+tab.attr('tab')+"]").tabboxsetlink(this.attr('id')); } }; $.fn.tabboxsetlink = function (forTabbox) { thisObj = $(this); thisObj.attr("tabboxid", forTabbox); thisObj.css("cursor","default"); if (thisObj.attr("class") == '') thisObj.attr("class","inactivetab"); thisObj.click(function(){ forTabbox = $(this).attr("tabboxid"); active = $("#"+forTabbox+" div[activetab=1]"); active.attr("activetab", 0); $("li[href="+active.attr("tab")+"]").attr("class", "inactivetab"); target = $("#"+forTabbox+" div[tab='"+$(this).attr('href')+"']"); if (target.attr('activetab') == 1) return; target.attr("activetab", 1); target.show(); active.hide(); $(this).attr("class", "activetab"); }); }; $("*[editzone]").each(function(i,zone) { z = $(zone); z.css("position", "relative"); z.css("min-height","40px"); btn = $("
").attr("id", "ezMSCALID"+i).css("display","none").attr("class","editbutton").html("Modifier").appendTo(z); btn.attr("editzone", z.attr("editzone")); btn.click (function(){ document.location.href="/"+$(this).attr("editzone")+"_edit.php"; }); z.attr("editzonehandleid",btn.attr("id")); z.hover( function(){ $("#"+$(this).attr("editzonehandleid")).show(); }, function(){ $("#"+$(this).attr("editzonehandleid")).hide(); } ); }); }); function dataFormManage (frmName, options) { if (!options) options = {}; successCallbackReal = (options.successCallback) ? options.successCallback : stdDataFormSuccessCallback; if (!options.messageDivName) options.messageDivName = "#waitingMessage"; $(frmName).ajaxForm ({ target: $(options.messageDivName), dataType: "json", beforeSubmitCallback: options.beforeSubmitCallback, beforeSubmit: function(data) { if (this.beforeSubmitCallback) this.beforeSubmitCallback(data, this); $(this.messageDiv).html("Enregistrement en cours, veuillez patienter").show(); return true; }, messageDiv: options.messageDivName, successCallback: successCallbackReal, success: function(json, status, form) { if (json.status == "OK") { this.successCallback(json); } else { jQuery.facebox(json.message); $(this.messageDiv).html(json.message).show(); } }}); } function stdDataFormSuccessCallback(jsonData) { $('#waitingMessage').hide(); $('#statusOk').show (); } // Timers /** * jQuery.timers - Timer abstractions for jQuery * Written by Blair Mitchelmore (blair DOT mitchelmore AT gmail DOT com) * Licensed under the WTFPL (http://sam.zoy.org/wtfpl/). * Date: 2009/02/08 * * @author Blair Mitchelmore * @version 1.1.2 * **/ jQuery.fn.extend({ everyTime: function(interval, label, fn, times, belay) { return this.each(function() { jQuery.timer.add(this, interval, label, fn, times, belay); }); }, oneTime: function(interval, label, fn) { return this.each(function() { jQuery.timer.add(this, interval, label, fn, 1); }); }, stopTime: function(label, fn) { return this.each(function() { jQuery.timer.remove(this, label, fn); }); } }); function formSavedHandler(json, status, form) { switch(json.status) { case "NC" : return openConnectBox(); case "OK" :break; case "KO" : triggerError(json.message); break; } } function openBox (elt) { b = new Boxy (elt, {title: elt.attr("title"), closeText:"[fermer]",modal: elt.attr("modal")}); return b; } function openConnectBox () { openBox ($("#greetBox")).show(); return true; } function triggerError (message) { b = openBox ($("#errorBox")); $("#errorBox .errorMessage").html(message); b.show(); return true; } jQuery.extend({ timer: { global: [], guid: 1, dataKey: "jQuery.timer", regex: /^([0-9]+(?:\.[0-9]*)?)\s*(.*s)?$/, powers: { // Yeah this is major overkill... 'ms': 1, 'cs': 10, 'ds': 100, 's': 1000, 'das': 10000, 'hs': 100000, 'ks': 1000000 }, timeParse: function(value) { if (value == undefined || value == null) return null; var result = this.regex.exec(jQuery.trim(value.toString())); if (result[2]) { var num = parseFloat(result[1]); var mult = this.powers[result[2]] || 1; return num * mult; } else { return value; } }, add: function(element, interval, label, fn, times, belay) { var counter = 0; if (jQuery.isFunction(label)) { if (!times) times = fn; fn = label; label = interval; } interval = jQuery.timer.timeParse(interval); if (typeof interval != 'number' || isNaN(interval) || interval <= 0) return; if (times && times.constructor != Number) { belay = !!times; times = 0; } times = times || 0; belay = belay || false; var timers = jQuery.data(element, this.dataKey) || jQuery.data(element, this.dataKey, {}); if (!timers[label]) timers[label] = {}; fn.timerID = fn.timerID || this.guid++; var handler = function() { if (belay && this.inProgress) return; this.inProgress = true; if ((++counter > times && times !== 0) || fn.call(element, counter) === false) jQuery.timer.remove(element, label, fn); this.inProgress = false; }; handler.timerID = fn.timerID; if (!timers[label][fn.timerID]) timers[label][fn.timerID] = window.setInterval(handler,interval); this.global.push( element ); }, remove: function(element, label, fn) { var timers = jQuery.data(element, this.dataKey), ret; if ( timers ) { if (!label) { for ( label in timers ) this.remove(element, label, fn); } else if ( timers[label] ) { if ( fn ) { if ( fn.timerID ) { window.clearInterval(timers[label][fn.timerID]); delete timers[label][fn.timerID]; } } else { for ( var fn in timers[label] ) { window.clearInterval(timers[label][fn]); delete timers[label][fn]; } } for ( ret in timers[label] ) break; if ( !ret ) { ret = null; delete timers[label]; } } for ( ret in timers ) break; if ( !ret ) jQuery.removeData(element, this.dataKey); } } } }); jQuery(window).bind("unload", function() { jQuery.each(jQuery.timer.global, function(index, item) { jQuery.timer.remove(item); }); }); function pageOverlay (callback,data) { $("#pageOverlay").show(); $("#pageOverlay").one ("click",function(e){ e.stopPropagation(); e.preventDefault(); callback(data); $("#pageOverlay").hide(); }); } $(function() { $("
").attr("id","pageOverlay").prependTo($("body")); $(".profileShoutBox").hover (function() { $(".shoutboxChange").show(); }, function() { $(".shoutboxChange").hide(); }); $.fn.flashstar = function () { this.each (function (i, e) { fs = $(e); if (parseInt(fs.attr("flashed")) > 0) { fs.css ("background-position","-17px 0"); } fs.attr("flashed", parseInt(fs.attr("flashed"))); }); this.hover (function () { fs = $(this); if (fs.attr("flashed") > 0) { fs.css ("background-position", "0 0"); } else { fs.css ("background-position", "-17px 0"); } }, function () { fs = $(this); if (fs.attr("flashed") > 0) { fs.css ("background-position", "-17px 0"); } else { fs.css ("background-position", "0 0"); } }); this.click (function () { fs = $(this); jQuery.getJSON ("/community/ajax/flash?o="+escape(fs.attr("object")), function (data) { fs.attr("flashed", data.fls_id); fs.css ("background-position", "-17px 0"); }); }); }; $(".flashstar").flashstar(); }); function goToAnchor(elementClick) { var destination = $(elementClick).offset().top; $("html:not(:animated),body:not(:animated)").animate({ scrollTop: destination}, 600, function() { window.location.hash = elementClick }); }