From 05f8c68d7a962f5948a2f4027b8eb5ea5ef93f6e Mon Sep 17 00:00:00 2001 From: "stephen@cubedesigners.com" Date: Mon, 19 Jan 2015 14:16:07 +0000 Subject: [PATCH] - Remove old realisations.js code that is no longer used (from previous version) - Modify fermer link on realisations to improve performance in Chrome (uses history.back() when a valid referrer is set) - Important security update to .htaccess to block access to .ini and framework files - Turn off dev mode for production site in application.ini --- .htaccess | 5 + framework/application/configs/application.ini | 2 +- .../application/views/helpers/Realisation.php | 4 +- js/realisations.js | 309 +----------------- 4 files changed, 17 insertions(+), 303 deletions(-) diff --git a/.htaccess b/.htaccess index 88807f0..ae0ab6c 100644 --- a/.htaccess +++ b/.htaccess @@ -21,6 +21,11 @@ RewriteCond %{HTTP_HOST} =cubedesigners.com [OR] RewriteCond %{HTTP_HOST} =www.cubedesigners.com RewriteRule ^(.*)$ http://www.cubedesigners.fr/$1 [R=301,L] + + # Block browser access to the framework folder and sensitive files + RewriteRule ^framework/.*$ - [F] + RewriteRule ^.*\.ini$ - [F] + # Redirect auth header to env RewriteRule ^.*$ - [E=REMOTE_USER:%{HTTP:Authorization}] # Skip static files diff --git a/framework/application/configs/application.ini b/framework/application/configs/application.ini index e063696..e65f934 100644 --- a/framework/application/configs/application.ini +++ b/framework/application/configs/application.ini @@ -1,5 +1,5 @@ [production] -dev = true +dev = false minify.js = true minify.css = true diff --git a/framework/application/views/helpers/Realisation.php b/framework/application/views/helpers/Realisation.php index 12eaeaa..84b5969 100644 --- a/framework/application/views/helpers/Realisation.php +++ b/framework/application/views/helpers/Realisation.php @@ -12,8 +12,8 @@ class Cubedesigners_View_Helper_Realisation extends CubeIT_View_Helper_Abstract $res .= '
'; $res .= '

' . $r->titre . '

'; $res .= '

' . Cubedesigners_Util::getCategoryById($r->categories) . '

'; - $res .= $this->view->link(__('Fermer'), $this->currentPage->getParent()->getHref(), array('class' => 'close')); - $res.='
'; + $res .= $this->view->link(__('Fermer'), $this->currentPage->getParent()->getHref(), array('class' => 'close', 'id' => 'closeButton')); + $res.=''; $slides = array(); foreach ($r->visuel_detail as $s) { diff --git a/js/realisations.js b/js/realisations.js index b459321..2fb3828 100644 --- a/js/realisations.js +++ b/js/realisations.js @@ -1,304 +1,13 @@ -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 += '
'; - detail += '
'; - detail += '
' + rea.titre + '
'; - - if (rea.legende != '') { - detail += '
' + rea.legende + '
'; - } - - if (rea.agence != '') { - detail += '
Agence : ' + rea.agence + '
'; - } - - - detail += '
    '; - detail += '
  • ' + rea.annee + '
  • '; - - for (var i = 0; i < rea.tags_secondaires.length; i++) { - detail += '
  • ' + rea.tags_secondaires[i] + '
  • '; - } - - detail += '
'; - - - detail += '
' + rea.description + '
'; - detail += 'Voir le site'; - detail += '
'; - detail += '
    '; - - 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 += '
  • '; - } - - detail += '
'; - detail += '
'; - - 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 -- 2.39.5