/* * Copyright 2009 * AESGE - Pole Informatique * informatique@aesge.fr * www.aesge.fr * -- remote edit -- */ var $jQ = jQuery.noConflict(); var _sliding = false; var currentAnchor = null; var page = ""; var UI = new Object(); UI.btn_ready = true; var first_run = true; var all_pages = ["homepage_" , "aesge_","projets_","partenaires_","ressources_","evenements_"]; var menu_pages = ["aesge_","projets_","partenaires_","ressources_","evenements_"]; var cached_pages = new Object(); var title = $jQ("title").text() || document.title; var shared_url = "http://www.aesge.fr/v2"; var prevent_shadow_remove = false; var remote_data = null; var FormBuffer = new Object(); $jQ().ready(function(){ // source : http://css-tricks.com/learning-jquery-fading-menu-replacing-content/ fade_them_out(); // all menu items are faded out first ! /* * ANCHOR NAV * init the timer which check if the there are anchor changes each 300 ms */ setInterval("checkAnchor()", 300); $jQ(".wibiyaToolbar_wiwi_close_a").html("[close]"); }); // -- ready function fade_them_out(){ $jQ(".menu_item_ > img").css({ opacity: 0.7 }); } var process_login = function(e){ var username = $jQ("#login_in").val(); var password = $jQ("#password_in").val(); if (!valid_username(username)){ $jQ("#login_in").parent(".input_holder").addClass("input_error"); } if(password == ""){ $jQ("#password_in").parent(".input_holder").addClass("input_error"); }else{ log_user_in(username,password); } e.preventDefault(); } var close_fancy = function(e){ $jQ("#fancy_close").click(); e.preventDefault(); } function setup_ui_interactions(){ $jQ("#contacter_pan_body #pt4").click(function(e){ e.preventDefault(); var names = $jQ("#contact_name").val(), email = $jQ("#contact_email").val(), message = $jQ("#contact_message").val(); var error = false; if(!valid_email(email)){ $jQ("#-email").show(); error = true; } if(names == ""){ $jQ("#-name").show(); error = true; } if(message == ""){ $jQ("#-message").show(); error = true; } if(error){return;} // send message to server : begin_notify(); query = {q : "contact", n : names, e : email, m : message} server_request(query); alert("sending q:"+query.q+" n:"+query.n+" e:"+query.e+" m:"+query.m); }); $jQ(".close_fancy").click(close_fancy); // Currently handled by WP //$jQ("#login_form").submit(process_login); $jQ("#contact_name").click(function (){$jQ("#-name").hide();}); $jQ("#contact_email").click(function (){$jQ("#-email").hide();}); $jQ("#contact_message").click(function (){$jQ("#-message").hide();}); /*$jQ(".elastro").click(function(){ if(!$jQ(this).hasClass("_open")){ $jQ(this).addClass("_open"); $jQ(this).siblings("._body").children(".mp_blue_layer").children("._body").slideDown("slow"); }else{ $jQ(this).removeClass("_open"); $jQ(this).siblings("._body").children(".mp_blue_layer").children("._body").slideUp("slow"); } });*/ $jQ(".content_plus").click(function(){ if (!$jQ(this).siblings(".content_more").is(":visible")){ $jQ(this).siblings(".content_more").slideDown(); $jQ(this).text() == "[+]" ? $jQ(this).text("[-]") : null; $jQ(this).text() == "Lire la suite." ? $jQ(this).text("Réduire.") : null; } else { $jQ(this).siblings(".content_more").slideUp(); $jQ(this).text() == "[-]" ? $jQ(this).text("[+]") : null; $jQ(this).text() == "Réduire." ? $jQ(this).text("Lire la suite.") : null; }; }); /*$jQ(".content_lire_plus").click(function(){ if (!$jQ(this).prev().is(":visible")){ $jQ(this).siblings(".content_more").slideDown(); $jQ(this).text("Réduire"); } else { $jQ(this).siblings(".content_more").slideUp(); $jQ(this).text("Lire la suite."); }; });*/ $jQ(".elastro").click(function(){ if (!$jQ(this).next().is(":visible")){ $jQ(this).siblings(".content_more").slideDown(); } else { $jQ(this).siblings(".content_more").slideUp(); }; }); $jQ("span.email").each(function(){ var ae = $jQ(this).html().replace(/ pt /g, '.').replace(/ at /g, '@'); $jQ(this).html('' + ae + ''); $jQ(this).removeClass("email"); }); // $jQ(".accordeon>.item_>.arrow_link").click(function(){ if(!$jQ(this).hasClass("open_")){ $jQ(this).siblings(".content_").slideDown(function(){$jQ(this).addClass("open_")}); $jQ(this).parent().siblings().children(".content_").slideUp(function(){$jQ(this).removeClass("open_")}); } }); $jQ(".accordeon>.mp_item>._head").click(function(){ if(!$jQ(this).hasClass("open_")){ $jQ(this).siblings("_body").children(".mp_blue_layer").children("._body").slideDown();//function(){$jQ(this).addClass("open_")}); //$jQ(this).parent().siblings().children(".content_").slideUp(function(){$jQ(this).removeClass("open_")}); } }); // if(!$jQ("#head_presentation_aesge").children(".editor_").size() > 0){ $jQ("#head_presentation_aesge").append($jQ(".editor_")); } // $jQ(".popup_profile_pan").click(function(e){ popup_profile_pan(); }); // $jQ("#logout_btn").click(function(e){ log_user_out(); }); // $jQ(".simple_input").click(function(){ if($jQ(this).parent().hasClass("input_error")){ $jQ(this).parent().removeClass("input_error"); } }); // $jQ(".dragsharable").mouseenter(function(){ !_sliding ? draggable_add_shadow($jQ(this)) : null; }); // $jQ(".share_btn").click(function(e){ e.preventDefault(); }); /* $jQ("#fb_share").click(function(){ }); $jQ("#twitter_share").click(function(){ }); $jQ("#delicious_share").click(function(){ }); */ // strip-replace share pan content var temp = '
'; temp += ''; temp += '
'; temp += 'En savoir plus'; temp += '
'; temp += '
'; temp += ''; temp += ''; temp += ''; temp += '
'; $jQ(".share_pan_holder").after(temp).remove(); // drag to share (1) : // -- drop manage ... $jQ("#targets li").droppable({ tolerance: "pointer", //show info when over target over: function() { $jQ(".dts_share", "#targets").remove(); $jQ("").addClass("dts_share").text("Partager sur " + $jQ(this).attr("id")).addClass("active").appendTo($jQ(this)).fadeIn(); }, drop: function() { var id = $jQ(this).attr("id"), baseUrl = $jQ(this).find("a").attr("href"); if (id.indexOf("twitter") != -1) { target = "/home?status=" + title + ": " + shared_url; width = 900; height = 500; } else if (id.indexOf("delicious") != -1) { target = "/save?url=" + shared_url+ "&title=" + title; width = 600; height = 550; } else if (id.indexOf("facebook") != -1) { target = "/sharer.php?u=" + shared_url+ "&t=" + title; width = 550; height = 400; } window.open(baseUrl+target,'{AESGE - Association des Étudiants Sénégalais des Grandes Écoles}','width='+width+',height='+height+',resizable=no,directories=no,menubar=no') } }); // ---- /end drag-to-share // ---- fancy $jQ("a.fancy_ajax").fancybox({ 'hideOnContentClick': false, 'zoomSpeedIn' : 600, 'zoomSpeedOut' : 500, 'easingIn' : 'easeOutBack', 'easingOut' : 'easeInBack' }); $jQ("#a_liens_utiles").fancybox({ 'frameWidth' : 600, 'frameHeight' : 500, 'hideOnContentClick': false, 'zoomSpeedIn' : 600, 'zoomSpeedOut' : 700, }); $jQ("a#lostPwd_link").fancybox({ 'hideOnContentClick': false, 'zoomSpeedIn' : 600, 'zoomSpeedOut' : 500, 'easingIn' : 'easeOutBack', 'easingOut' : 'easeInBack' }); $jQ("a#editor_link").fancybox({ 'hideOnContentClick': false, 'hideOnOverlayClick': false, 'zoomSpeedIn' : 600, 'zoomSpeedOut' : 500, 'easingIn' : 'easeOutBack', 'easingOut' : 'easeInBack', 'frameWidth' : 540, 'frameHeight' : 600 }); $jQ("a#a_aesge_sur_facebook,a#a_plaquette_09").fancybox({ 'frameWidth' : 1120, 'frameHeight' : 700 }); $jQ("a.a_user_profile").fancybox({ 'hideOnContentClick': false, 'hideOnOverlayClick': false, 'frameWidth' : 1090, 'frameHeight' : 700, 'zoomSpeedOut' : 500 }); $jQ("a#a_nous_contacter").fancybox({ 'hideOnContentClick': false, 'hideOnOverlayClick': false, 'frameWidth' : 800, 'frameHeight' : 700, 'zoomSpeedOut' : 500 }); $jQ("a#a_rejoindre").fancybox({ 'hideOnContentClick': false, 'hideOnOverlayClick': false, 'frameWidth' : 1000, 'frameHeight' : 500, 'zoomSpeedOut' : 500 }); $jQ("a#a_generateur_carte_visite").fancybox({ 'hideOnContentClick': false, 'frameWidth' : 800, 'frameHeight' : 640 }); $jQ("a#fancy_notify_link").fancybox({ 'frameWidth' : 700, 'frameHeight' : 200, 'hideOnContentClick': false, 'zoomSpeedIn' : 600, 'zoomSpeedOut' : 500, 'easingIn' : 'easeOutBack', 'easingOut' : 'easeInBack' }); // ---- fancy $jQ("#fb_connect_large_pan").fadeOut(); $jQ("#fb_connect_dbrp").mouseenter(function(){ $jQ("#fb_connect_large_pan").fadeIn(); }); $jQ("#fb_connect_dbrp").mouseleave(function(){ $jQ("#fb_connect_large_pan").fadeOut(); }); $jQ(".rp_profile_disp").mouseenter(function(){ $jQ(this).children(".profile_tooltip").fadeIn("fast"); }).mouseleave(function(){ $jQ(this).children(".profile_tooltip").fadeOut("fast"); }); // hide map ! $jQ("#map_bubble").addClass("map_hider"); // Btn Interaction // "Hover - Hover" model $jQ(".button_wrapper").mouseenter(function (e){ if(!$jQ(this).children(".bande").is(":visible")){ // .bande not visible : $jQ(".bande:visible").slideUp("normal").css("z-index",1000); $jQ(this).children(".bande").slideDown("normal").css("z-index",1010); } e.preventDefault(); }); $jQ(".button_wrapper").mouseleave(function (e){ if($jQ(this).children(".bande").is(":visible")){ // .bande not visible : $jQ(".bande:visible").slideUp("normal").css("z-index",1000); } e.preventDefault(); }); $jQ(".partner_entry").mouseenter(function(e){ // $jQ(this).children(".cover").fadeOut(); e.stopPropagation(); }); $jQ(".partner_entry").mouseleave(function(e){ // $jQ(this).children(".cover").fadeIn(); e.stopPropagation(); }); $jQ("#recuppp_icon").click(function(e){ load_project("Recup ++"); e.preventDefault(); }); $jQ("#network_icon").click(function(e){ load_project("Network !!"); e.preventDefault(); }); $jQ("#parrainage_icon").click(function(e){ load_project("Parrainage Education"); e.preventDefault(); }); $jQ("#idees_project").click(function(e){ load_idees(); }); $jQ(".gohome").click(function(e){ }); // MAPS $jQ("#show_map").click(function(e){ handle_map_display("map_link"); e.preventDefault(); e.stopPropagation(); }); $jQ("body").click(function(){ handle_map_display("body"); }); //-- maps $jQ(".featured_project_menu_link").click(function(e){ e.preventDefault(); }); } function reveal(target){ target.animate({ // width : "22.2em" }, 1500); } function get_ID(jQObj){ return jQObj.attr("id"); } function fancy_notify(html_){ $jQ("#fancy_notify_content").html(html_); $jQ("#fancy_notify_link").click(); } // anchor nav more : //Function which chek if there are anchor changes, if there are, sends the ajax petition function checkAnchor(){ // Check if it has changes if(currentAnchor != document.location.hash){ currentAnchor = document.location.hash; // if there is not anchor, the loads the default section if(currentAnchor){ // Creates the string callback. This converts the url URL/#main&id=2 in URL/?section=main&id=2 var splits = currentAnchor.substring(1).split('&'); // Get the section page= splits[0]; delete splits[0]; // Create the params string var params = splits.join('&'); }else{ // !currentAnchor query = "p=homepage"; var params = ""; page = "homepage"; } if(is_action(page)){ handle_action(page); return; } // check if the anchor requests a page if(is_page(page)){ if( ! (page in cached_pages) ){ begin_notify("Chargement en cours ..."); cached_pages[page] = ""; // mark the page as cached ! var query = "p=" + page + params; $jQ.get("page_loader.php",query, function(data){ $jQ("#"+page+"_").html(data); end_notify(); $jQ().ready(function(){setup_ui_interactions();}); toggle_page(page); }); }else{ toggle_page(page); } // and highlights the menu items ... if(is_menu_page(page)){ $jQ("#menu_"+page+"_ > img").animate({ opacity: 1 }, 600 ); // and fades others ... $jQ("#menu_"+page+"_").siblings(".menu_item_").children("img").animate({ opacity: 0.5 }, 600 ); }else{ fade_them_out(); } }// end if is page else { // neither action nor page fade_them_out(); toggle_page("404"); } } } /* Horizontal Slide *--------------------------------------- * jQ_obj neads to be abluste-positioned with left set to some value *{ * position: absolute; * left: xx; *} *---------------------------------------*/ function h_slide(jQ_obj, duration){ var _left = parseInt(jQ_obj.css('left'),10); jQ_obj.animate({ left: _left == 0 ? -jQ_obj.outerWidth() : 0 }, duration); } function handle_map_display(source){ if($jQ("#map_bubble").hasClass("map_hider") && source == "map_link"){ $jQ("#map_bubble").removeClass("map_hider"); $jQ("#map_bubble").addClass("map_shower"); $jQ("#show_map").text("Masquer GMaps"); }else{ $jQ("#map_bubble").removeClass("map_shower"); $jQ("#map_bubble").addClass("map_hider"); $jQ("#show_map").text("Voir dans GMaps"); } } function is_page(anchor){ return (jQuery.inArray(anchor+"_", all_pages)!= -1); } function is_menu_page(anchor){ return (jQuery.inArray(anchor+"_", menu_pages)!= -1); } function is_action(anchor){ // action anchor format : a_[action to do] return (anchor.length >2 && anchor.substring(0,2) == "a_"); } function handle_action(anchor){ switch(anchor){ case "a_aesge_facebook" : fade_them_out(); toggle_page("aesge_facebook"); break; deafault : break; } } function toggle_page(target_page){ $jQ("#"+ target_page+"_").slideDown("slow"); $jQ("#"+ target_page+"_").siblings(".page").slideUp("slow", function (){_sliding = false;}); } // drag to share (2) var draggable_shadower = '
'; function draggable_add_shadow(target){ if(!target.hasClass("shaded")){ target.addClass("shaded"); var x_= target.offset().left, y_ = target.offset().top, h_ = target.height(), w_ = target.width(); $jQ(draggable_shadower).css({"margin-left" : x_, "margin-top" : y_, "width" : w_, "height" : h_}).appendTo("body"); var clonee = target.clone(); make_draggable(clonee); clonee.addClass("draggable").appendTo("#shadower_content"); } } function draggable_remove_shadow(){ if(!prevent_shadow_remove){ $jQ("#draggable_shadower").remove(); $jQ(".dragsharable").removeClass("shaded"); } } function make_draggable(target){ target.draggable({ //create draggable helper helper: function() { return $jQ("
").attr("id", "helper").html("" + title + "").appendTo("body"); }, cursor: "pointer", cursorAt: { left: -10, top: 20 }, zIndex: 99999, //show overlay and targets start: function() { prevent_shadow_remove = true; if($jQ(this).attr("shared_url")) shared_url = $jQ(this).attr("shared_url"); $jQ("
").attr("id", "overlay").css("opacity", 0.7).appendTo("body"); $jQ("#tip").remove(); $jQ(this).unbind("mouseenter"); $jQ("#targets").css("left", ($jQ("body").width() / 2) - $jQ("#targets").width() / 2).slideDown(); }, //remove targets and overlay stop: function() { $jQ("#targets").slideUp(); $jQ(".dts_share", "#targets").remove(); $jQ("#overlay").remove(); $jQ(this).bind("mouseenter", createTip); prevent_shadow_remove = false; draggable_remove_shadow(); } }); target.bind("mouseenter", createTip).mousemove(function(e) { $jQ("#tip").css({ left:e.pageX + 30, top:e.pageY - 16 }); }).mouseleave(function() { $jQ("#tip").fadeOut(300, function(){$jQ("#tip").remove()}); draggable_remove_shadow(); }); } function createTip(e){ //create tool tip if it doesn't exist ($jQ("#tip").length === 0) ? $jQ("
").html("Drag this image to share the page<\/span><\/span>").attr("id", "tip").css({ left:e.pageX + 30, top:e.pageY - 16 }).appendTo("body").fadeIn(500) : null; } // server comm : function server_request(data_){ alert(data_); $jQ.ajax({ type: "POST", url: "handle_request.php", dataType : "json", data: data_, success: handle_server_response }); } function handle_server_response(data_){ console.log(data_);alert(data_); end_notify(); // server responses are assumed to be JSOn formated switch(data_.q){ case "login": if(data_.s == "success"){ UserData = new Object(); UserData.status = "in"; UserData.server_data = data_.data; parse_infos_widget(); $jQ("#connexion_assets").slideUp(); $jQ("#profile_assets").slideDown(); }else{ var alert_msg = '
'; alert_msg += 'Vérifiez les informations fournies
'; alert_msg += 'Si vous n\'avez pas de compte c\'est le moment d\'en créer un ! ;-)
'; alert_msg += 'Cliquer ici pour ouvrir un compte'; alert_msg += '
'; fancy_notify(alert_msg); } break; case "logout": if(data_.s == "success"){ UserData = new Object(); UserData.status = "out"; $jQ("#password_in").val(""); $jQ("#connexion_assets").slideDown(); $jQ("#profile_assets").slideUp(); }else{ var alert_msg = 'Veuillez réessayer'; fancy_notify(alert_msg); } break; case "contact": if(data_.s == "success"){ begin_notify("Message envoyé avec succès !
Merci."); }else if(data_.s == "fail"){ begin_notify("Erreur lors de la transmission de votre message
Merci d'ecrire à contact@aesge.fr"); } break; default : break; } } // function log_user_out(){ begin_notify(); server_request({q : "logout", l : UserData.login}); } function log_user_in(username,password){ begin_notify("Connexion en cours ..."); $jQ.ajax({ type: "POST", url: "handle_request.php", dataType : "json", data: {q : "login", l : username, p : password }, success: handle_server_response }); } function popup_profile_pan(){ $jQ("#popup_profile_pan").click(); } function begin_notify(text){ $jQ("#notifyer").html(text); $jQ("#notify_pan").slideDown(); } function end_notify(text){ setInterval('$jQ("#notify_pan").slideUp()', 3000); } function more(target){ // console.log(target); } function valid_username(username_){ return username_.match(/^[a-zA-Z0-9_]{3,16}$/); } function valid_email(email_){ return email_.match(/([a-z0-9._-]+@[a-z0-9._-]+.[a-z]+)/gi) ; } //------widget parsing : function parse_infos_widget(){ var pid = "#profile_assets"; $jQ("#profile_assets ._widget_surname").html(firstCharUp(UserData.server_data.surname)); $jQ("#profile_assets ._widget_name").html(firstCharUp(UserData.server_data.name)); $jQ("#profile_assets ._widget_lastschool").html(UserData.server_data.studies[0].school); $jQ("#profile_assets ._widget_email").html(UserData.server_data.email); /* sample -- $jQ("#profile_assets ._widget_").html(UserData.server_data....); */ } function firstCharUp(str){ return str = str.slice(0,1).toUpperCase() + str.slice(1); }