-TO_LOAD_ONCE[TO_LOAD_ONCE.length] = 'load_realisations();';
+registerLoader(loadRealisations);
-var showIds = new Array();
-var isAnim = false;
-var currentOpen = 0;
-var currentOpenValues;
-var detail = "";
-var currentSlide = 1;
-var autoSlide = false;
-var totalWidth;
-var lastWidth;
-var showIds = new Array();
+function loadRealisations() {
-function load_realisations() {
- initTagsLink();
-
- $(".bloc").click(function () {
-
- var currentRea = $(this).attr("data-pos");
-
- if (!isAnim && currentRea != currentOpen) {
-
- isAnim = true;
-
- var reaWidth = $(this).width() + parseInt($(this).css("margin-right").split("px")[0]);
- var reaId = $(this).parent().attr("data-id");
- var reaPerRow = $(this).parent().parent().width() / reaWidth;
-
- var nbReas = $('.project-photo').length;
-
- var nbRow = Math.ceil(nbReas / reaPerRow);
-
- var reaPos = 1;
- var count = 0;
-
- var cible = $("#realisations-list").find("[data-pos='1']");
-
- while (count < currentRea) {
- count++;
- if ((count % (reaPerRow + 1)) == 0) {
- reaPos++;
- cible = $("#realisations-list").find("[data-pos='" + count + "']");
- }
- }
-
- detail = "";
-
- $.ajax({
- url: '/ajax/displayrealisation',
- type: 'GET',
- data: 'realisation_id=' + reaId,
- complete: function (ret) {
-
- var response = JSON.parse(ret.responseText);
- var rea = response.vars.rea;
-
- currentOpenValues = rea;
-
- detail += '<div id="detailContent"><div id="detail">';
- detail += '<div class="detailLeft">';
- detail += '<div class="titre">' + rea.titre + '</div>';
-
- if (rea.legende != '') {
- detail += '<div class="legende">' + rea.legende + '</div>';
- }
-
- if (rea.agence != '') {
- detail += '<div class="agence">Agence : ' + rea.agence + '</div>';
- }
-
-
- detail += '<ul class="taglist">';
- detail += '<li>' + rea.annee + '</li>';
-
- for (var i = 0; i < rea.tags_secondaires.length; i++) {
- detail += '<li>' + rea.tags_secondaires[i] + '</li>';
- }
-
- detail += '</ul>';
-
-
- detail += '<div class="description">' + rea.description + '</div>';
- detail += '<a class="link" href="' + rea.url + '">Voir le site</a>';
- detail += '</div>';
- detail += '<div class="detailRight"><div class="slides"><ul>';
-
- totalWidth = 0;
- for (var i = 0; i < rea.visuel_detail.length; i++) {
-
- var image = new Image();
- image.src = rea.visuel_detail[i];
- totalWidth += image.width;
-
- if (i == (rea.visuel_detail.length - 1)) {
- lastWidth = image.width;
- }
-
- detail += '<li><img id="visuel_detail" src="' + rea.visuel_detail[i] + '" /></li>';
- }
-
- detail += '</ul></div></div>';
- detail += '</div><div class="close"></div></div>';
-
- if ($("#detail").length > 0) {
- $("#detail").slideUp(500, function () {
-
- $('#detailContent').remove();
-
- $(cible.parent()).before(detail);
-
- $("html, body").animate({scrollTop: $('#detailContent').offset().top - 100}, 1000);
- $('.close').css("top", $('#detailContent').offset().top);
-
- $("#detail").slideDown("slow", function () {
- isAnim = false;
- addCloseAction();
- currentSlide = 1;
- autoSlide = true;
- initSlideShow();
-
- }).animate(
- {opacity: 1},
- {queue: true, duration: 'slow'}
- );
-
- }).animate(
- {opacity: 1},
- {queue: true, duration: 'slow'}
- );
- } else {
- $(cible.parent()).before(detail);
-
- $("html, body").animate({scrollTop: $('#detailContent').offset().top - 100}, 1000);
- $('.close').css("top", $('#detailContent').offset().top);
- /*
- $( "#detail" ).slideDown( "slow", function() {
-
- isAnim = false;
- addCloseAction();
- currentSlide = 1;
- autoSlide = true;
- initSlideShow();
-
- }).animate(
- { opacity: 1 },
- { queue: true, duration: 'slow' }
- );*/
-
-
- $("#detail").addClass("showDown");
- $('#detail').one("webkitTransitionEnd transitionend oTransitionEnd msTransitionEnd transitionEnd", function (e) {
- isAnim = false;
- addCloseAction();
- currentSlide = 1;
- autoSlide = true;
- initSlideShow();
- });
-
- }
-
- /*$(".project-photo").each( function() {
- var id = $(this).parent().attr("data-pos");
- if( id != currentRea ) {
- $(this).addClass("gray");
- }else{
- $(this).removeClass("gray");
- }
- });*/
- }
-
- });
-
-
- }
-
- currentOpen = currentRea;
- });
-}
-
-function addCloseAction() {
- $(".close").click(function () {
- $("html, body").animate({scrollTop: 0}, 1000);
-
- /* $( "#detail" ).slideUp( "slow", function() {
- $('#detailContent').remove();
- currentOpen = 0;
- $(".project-photo").each( function() {
- $(this).removeClass("gray");
- });
- }).animate(
- { opacity: 1 },
- { queue: false, duration: 'slow' }
- );*/
-
- $("#detail").addClass("showUp");
- $('#detail').one("webkitTransitionEnd transitionend oTransitionEnd msTransitionEnd transitionEnd", function (e) {
- currentOpen = 0;
- $(".project-photo").each(function () {
- $(this).removeClass("gray");
- });
- });
-
- });
-}
-
-function initTagsLink() {
-
- $(".tag").click(function () {
-
- $(".close").click();
-
- $(this).toggleClass('active');
-
- if ($(this).hasClass('active')) {
- if ($(this).attr("data-id") != 0) {
- showIds.push($(this).attr("data-id"));
- } else {
- showIds = new Array();
- $(".tag").removeClass('active');
- }
- } else {
- var index = $.inArray($(this).attr("data-id"), showIds);
- showIds.splice(index, 1);
- }
-
- if (showIds.length > 0) {
- $(".tag:first").removeClass('active');
- } else {
- $(".tag:first").addClass('active');
- }
-
- displayRealisations();
- });
-
-}
-
-function displayRealisations() {
-
- if (showIds.length) {
- $('#realisations-list .bloc').each(function () {
- var categories = $(this).attr("data-categories");
- if ($.inArray(categories, showIds) == -1) {
- $(this).parent().fadeOut(500, function () {
- });
- } else {
- $(this).parent().fadeIn(500, function () {
- });
- }
- });
- } else {
- $('#realisations-list .bloc').parent().fadeIn(500, function () {
- });
- }
-
-}
-
-function initSlideShow() {
-
- var mouse_move = false;
- function move(e) {
- if (mouse_move) {
- if (document.documentElement.clientWidth > 0) {
-
- position = e.pageX - document.documentElement.scrollLeft;
- } else {
- position = e.pageX - document.body.scrollLeft;
- }
- }
- }
- document.onmousemove = move;
-
- $(".slides").mouseover(function (e) {
-
- mouse_move = true;
- le_div = '.' + 'slides';
-
- if ($(le_div + " ul li").length > 1) {
-
- var total_lenght = totalWidth;
-
- var t = setInterval(function () {
-
- var offset = $(le_div).offset();
-
- if ((position - offset.left) < ($("#detailContent").width() / 2)) {
- if ($(le_div + " ul").css('marginLeft').replace("px", "") > -(total_lenght - lastWidth)) {
- $(le_div + " ul").animate({marginLeft: "-=2px"}, 0);
- }
- } else {
- if ($(le_div + " ul").css('marginLeft').replace("px", "") <= 0) {
- $(le_div + " ul").animate({marginLeft: "+=2px"}, 0);
- }
- }
-
- }, 5);
-
- $(le_div).mouseout(function () {
- clearInterval(t);
- mouse_move = false;
- });
- }
- });
+ // Check referrer and if it is a cubedesigners page, switch to a history.back() link instead of a standard link to speed things up
+ if(document.referrer.indexOf("cubedesigners.") > -1) {
+ $("#closeButton").on('click',function(){
+ history.back();
+ return false;
+ });
+ }
}
\ No newline at end of file