From cb6112718c1d18e869a41e6daba7e2c1a02c16c2 Mon Sep 17 00:00:00 2001 From: Olga Brani Date: Mon, 16 Dec 2013 15:27:37 +0200 Subject: [PATCH] Fixed-positioned left sidebar bug fix --- cloudcms/static/cloudcms/js/common.js | 712 ++++++++++++++++----------------- 1 file changed, 337 insertions(+), 375 deletions(-) diff --git a/cloudcms/static/cloudcms/js/common.js b/cloudcms/static/cloudcms/js/common.js index ec562b1..5eedd03 100644 --- a/cloudcms/static/cloudcms/js/common.js +++ b/cloudcms/static/cloudcms/js/common.js @@ -1,375 +1,337 @@ -function isIpadIphone(){ - var flag = false; - var isiPhone = navigator.userAgent.toLowerCase().indexOf("iphone"); - var isiPad = navigator.userAgent.toLowerCase().indexOf("ipad"); - if(isiPhone > -1) { flag = true; } - if(isiPad > -1) { flag = true; } - return flag; -} - -function setContainerMinHeight( applicableDiv){ - - if ( $(applicableDiv).length > 0 ) { - //var h = $('.header').height(); div.header is not found - var f = $('.footer').height(); - var w = $(window).height(); - var pTop = parseInt (($(applicableDiv).css('padding-top').replace("px", "")) ); - var pBottom = parseInt (($(applicableDiv).css('padding-bottom').replace("px", ""))); - - var c = w - ( f+pTop+pBottom+36);//36 is header's height. - $(applicableDiv).css('min-height', c); - } - -} - -function tableFixedCols(table, firstColWidth ){ - ColsNum = $('table th').size(); - var ColWidth = parseFloat( (100 - firstColWidth)/ColsNum ).toFixed(0); - var ColWidthPercentage = ColWidth+'%'; - var firstColWidthPercentage = firstColWidth+'%'; - $('.projects table th, .projects table td').attr('width',ColWidthPercentage ); - $('.projects table tr td:first-child,.projects table tr th:first-child').attr('width',firstColWidthPercentage ); - -} - -function addClassHover(hoverEl, applicableEl){ - $(hoverEl).hover( - function () { - - $(applicableEl).addClass('red-border') - }, - function () { - $(applicableEl).removeClass('red-border'); - - }); -} -//equal heights - -(function($) { - $.fn.equalHeights = function(minHeight, maxHeight) { - tallest = (minHeight) ? minHeight : 0; - this.each(function() { - if($(this).height() > tallest) { - tallest = $(this).height(); - } - }); - if((maxHeight) && tallest > maxHeight) tallest = maxHeight; - return this.each(function() { - $(this).height(tallest); - }); - } -})(jQuery); - - - -// fix for iPhone - iPad orientation bug -var metas = document.getElementsByTagName('meta'); -function resetViewport() { - var i; - if (navigator.userAgent.match(/iPhone/i)) { - for (i=0; i 0) { - // $('.mainlogo img').bind('load', fixTopMessageHeight) - // } else { - // fixTopMessageHeight(); - // } - - $('.top-msg a.close').click(function(e) { - e.preventDefault(); - $('.top-msg').animate({ - paddingTop:'0', - paddingBottom:'0', - height:'0' - }, 1000, function (){ - $('.top-msg').removeClass('active') - }); - $('.mainlogo').animate({ - marginTop:'0' - }, 1000, function (){ - //todo - }); - }); - - - $('select.dropkicked').dropkick({ - change: function (value, label) { - $(this).parents('form').submit(); - - } - }); - - $('.with-info select').attr('tabindex','1'); - $('.with-info select').dropkick(); - - $('.top-msg .success').parents('.top-msg').addClass('success'); - $('.top-msg .error').parents('.top-msg').addClass('error'); - $('.top-msg .warning').parents('.top-msg').addClass('warning'); - $('.top-msg .info').parents('.top-msg').addClass('info'); - - // clouds homepage animation - $('#animation a').hover( - function () { - - $(this).animate({ - top: '+=-5' - }, 300, function() { - if ($(this).find('img').attr('src').indexOf("_top") == -1) { - var src = $(this).find('img').attr('src').replace('.png', '_top.png') - $(this).find('img').attr("src", src); - } - - }); - $(this).siblings('p').find('img').animate({ - width: '60%' - }, 300); - }, - function () { - - $(this).animate({top: '0'}, 300, function() { - var src = $(this).find('img').attr('src').replace('_top.png', '.png') - $(this).find('img').attr("src", src); - }); - $(this).siblings('p').find('img').animate({ - width: '65%' - },300); - } - ); - - - - - $(function() { - $( "#id_start_date" ).datepicker({ - minDate: 0, - defaultDate: "+0", - dateFormat: "yy-mm-dd", - onSelect: function( selectedDate ) { - $( "#id_end_date" ).datepicker( "option", "minDate", selectedDate ); - } - }); - - $( "#id_end_date" ).datepicker({ - defaultDate: "+3w", - dateFormat: "yy-mm-dd", - onSelect: function( selectedDate ) { - $( "#id_start_date" ).datepicker( "option", "maxDate", selectedDate ); - } - }); - }); - - - - $('table .more-info').click(function(e){ - e.preventDefault(); - $(this).toggleClass('open'); - if ($(this).hasClass('open')){ - $(this).html('- less info ') - } else { - $(this).html('+ more info ') - } - $(this).parents('tr').next('tr').toggle(); - - }); - - $('.projects .details .edit').click( function(e){ - e.preventDefault(); - $(this).parents('.details').children('.data').hide(); - $(this).parents('.details').children('.editable').slideDown(500, 'linear'); - $(this).hide(); - }); - - $('.editable .form-row').each(function() { - if ( $(this).hasClass('with-errors') ){ - $('.editable').show(); - $('.projects .details a.edit, .projects .details .data').hide(); - - } - }); - - - $("input.leave, input.join").click(function () { - $('dialog').hide(); - $(this).parents('.msg-wrap').find('.dialog').show(); - return false; - - }); - - $('.msg-wrap .no').click( function(e){ - e.preventDefault(); - $(this).parents('.dialog').hide(); - }) - - $('.msg-wrap .yes').click( function(e){ - e.preventDefault(); - $(this).parents('.dialog').siblings('form').submit(); - }) - - $('.hidden-submit input[readonly!="True"]').focus(function () { - $('.hidden-submit .form-row.submit').slideDown(500); - }); - - - - - - - setTimeout(function() { - if ($('input#id_username').val()){ - $('input#id_username').siblings('label').css('opacity','0'); - }; - if ($('input#id_password').val()){ - $('input#id_password').siblings('label').css('opacity','0'); - } - }, 100); - - - - - $('.landing-page .cms').hover( - function () { - el = $('.cloudbar ul.services li').first(); - var offset = el.offset(); - positionX = offset.left; - $('#hand').css('left',positionX); - $('#hand').show(); - }, - function () { - $('#hand').hide(); - - }); - - $('.landing-page .pithos').hover( - function () { - el = $('.cloudbar ul.services li:nth-child(3)'); - var offset = el.offset(); - positionX = offset.left; - left = parseInt(positionX) +20; - $('#hand').css('left',left+'px'); - $('#hand').show(); - }, - function () { - $('#hand').hide(); - - }); - - $('.landing-page .cyclades').hover( - function () { - el = $('.cloudbar ul.services li:nth-child(2)').first(); - var offset = el.offset(); - positionX = offset.left; - left = parseInt(positionX) +20; - $('#hand').css('left',left+'px'); - $('#hand').show(); - }, - function () { - $('#hand').hide(); - - }); - - - $('.landing-page .dashboard').hover( - function () { - el = $('.cloudbar .profile'); - var offset = el.offset(); - positionX = offset.left +50; - $('#hand').css('left',positionX); - $('#hand').show(); - }, - function () { - $('#hand').hide(); - - }); - - $('.pagination a.disabled').click(function(e){ - e.preventDefault(); - }); - - // fix for recaptcha fields - $('#okeanos_recaptcha').parents('.form-row').find('.extra-img').hide(); - - fixEl = $('.details .lt'); - if (fixEl.length){ window.fixEloffsetTop = fixEl.offset().top;} - - - $(".stats-block li em").equalHeights(); - - -}); - -$(window).resize(function() { - - setContainerMinHeight('.container .wrapper'); - $(".stats-block li em").equalHeights(); - - -}); - - -/* js for fixed faq/userguide side nav */ -$(window).scroll(function () { - - if ( $('.details .lt').height() < $('.details .rt').height() ) { - if ($(window).scrollTop() > window.fixEloffsetTop){ - fixEl.addClass('fixed'); - } else { - fixEl.removeClass('fixed'); - } - } - - - -}); +function isIpadIphone(){ + var flag = false; + var isiPhone = navigator.userAgent.toLowerCase().indexOf("iphone"); + var isiPad = navigator.userAgent.toLowerCase().indexOf("ipad"); + if(isiPhone > -1) { flag = true; } + if(isiPad > -1) { flag = true; } + return flag; +} + +function setContainerMinHeight( applicableDiv){ + + if ( $(applicableDiv).length > 0 ) { + //var h = $('.header').height(); div.header is not found + var f = $('.footer').height(); + var w = $(window).height(); + var pTop = parseInt (($(applicableDiv).css('padding-top').replace("px", "")) ); + var pBottom = parseInt (($(applicableDiv).css('padding-bottom').replace("px", ""))); + var c = w - ( f+pTop+pBottom+36);//36 is header's height. + $(applicableDiv).css('min-height', c); + } +} + +function tableFixedCols(table, firstColWidth ){ + ColsNum = $('table th').size(); + var ColWidth = parseFloat( (100 - firstColWidth)/ColsNum ).toFixed(0); + var ColWidthPercentage = ColWidth+'%'; + var firstColWidthPercentage = firstColWidth+'%'; + $('.projects table th, .projects table td').attr('width',ColWidthPercentage ); + $('.projects table tr td:first-child,.projects table tr th:first-child').attr('width',firstColWidthPercentage ); +} + +function addClassHover(hoverEl, applicableEl){ + $(hoverEl).hover( + function () { + $(applicableEl).addClass('red-border') + }, + function () { + $(applicableEl).removeClass('red-border'); + }); +} + +//equal heights +(function($) { + $.fn.equalHeights = function(minHeight, maxHeight) { + tallest = (minHeight) ? minHeight : 0; + this.each(function() { + if($(this).height() > tallest) { + tallest = $(this).height(); + } + }); + if((maxHeight) && tallest > maxHeight) tallest = maxHeight; + return this.each(function() { + $(this).height(tallest); + }); + } +})(jQuery); + + + +// fix for iPhone - iPad orientation bug +var metas = document.getElementsByTagName('meta'); +function resetViewport() { + var i; + if (navigator.userAgent.match(/iPhone/i)) { + for (i=0; i window.fixEloffsetTop) && diff>0 ) { + fixEl.addClass('fixed'); + } else { + fixEl.removeClass('fixed'); + } + } + console.log(diff,'diff'); +} + +$(document).ready(function() { + + + setContainerMinHeight('.container .wrapper'); + tableFixedCols('my-projects', 25); + + $('.show-extra').click(function(e) { + e.preventDefault(); + $(this).parents('.bg-wrap').find('.extra').slideToggle(600); + }); + $('.hide-extra').click(function(e) { + e.preventDefault(); + $(this).parents('.bg-wrap').find('.extra').slideUp(600); + }); + + $('.box-more p').click(function(e) { + $(this).siblings('.clearfix').toggle('slow'); + $(this).parents('.box-more').toggleClass('border'); + }); + + var fixTopMessageHeight = function() { + var topMargin = parseInt($('.mainlogo img').height())+parseInt($('.top-msg').css('marginBottom')); + $('.mainlogo').css('marginTop','-'+topMargin+'px'); + } + + // Uncomment to hide logo upon top message appearance + + // if ($('.mainlogo img').length > 0) { + // $('.mainlogo img').bind('load', fixTopMessageHeight) + // } else { + // fixTopMessageHeight(); + // } + + $('.top-msg a.close').click(function(e) { + e.preventDefault(); + $('.top-msg').animate({ + paddingTop:'0', + paddingBottom:'0', + height:'0' + }, 1000, function (){ + $('.top-msg').removeClass('active') + }); + $('.mainlogo').animate({ + marginTop:'0' + }, 1000, function (){ + //todo + }); + }); + + $('select.dropkicked').dropkick({ + change: function (value, label) { + $(this).parents('form').submit(); + } + }); + + $('.with-info select').attr('tabindex','1'); + $('.with-info select').dropkick(); + $('.top-msg .success').parents('.top-msg').addClass('success'); + $('.top-msg .error').parents('.top-msg').addClass('error'); + $('.top-msg .warning').parents('.top-msg').addClass('warning'); + $('.top-msg .info').parents('.top-msg').addClass('info'); + + // clouds homepage animation + $('#animation a').hover( + function () { + $(this).animate({ + top: '+=-5' + }, 300, function() { + if ($(this).find('img').attr('src').indexOf("_top") == -1) { + var src = $(this).find('img').attr('src').replace('.png', '_top.png') + $(this).find('img').attr("src", src); + } + }); + $(this).siblings('p').find('img').animate({ + width: '60%' + }, 300); + }, + function () { + $(this).animate({top: '0'}, 300, function() { + var src = $(this).find('img').attr('src').replace('_top.png', '.png') + $(this).find('img').attr("src", src); + }); + $(this).siblings('p').find('img').animate({ + width: '65%' + },300); + } + ); + + $(function() { + $( "#id_start_date" ).datepicker({ + minDate: 0, + defaultDate: "+0", + dateFormat: "yy-mm-dd", + onSelect: function( selectedDate ) { + $( "#id_end_date" ).datepicker( "option", "minDate", selectedDate ); + } + }); + $( "#id_end_date" ).datepicker({ + defaultDate: "+3w", + dateFormat: "yy-mm-dd", + onSelect: function( selectedDate ) { + $( "#id_start_date" ).datepicker( "option", "maxDate", selectedDate ); + } + }); + }); + + $('table .more-info').click(function(e){ + e.preventDefault(); + $(this).toggleClass('open'); + if ($(this).hasClass('open')){ + $(this).html('- less info ') + } else { + $(this).html('+ more info ') + } + $(this).parents('tr').next('tr').toggle(); + }); + + $('.projects .details .edit').click( function(e){ + e.preventDefault(); + $(this).parents('.details').children('.data').hide(); + $(this).parents('.details').children('.editable').slideDown(500, 'linear'); + $(this).hide(); + }); + + $('.editable .form-row').each(function() { + if ( $(this).hasClass('with-errors') ){ + $('.editable').show(); + $('.projects .details a.edit, .projects .details .data').hide(); + } + }); + + $("input.leave, input.join").click(function () { + $('dialog').hide(); + $(this).parents('.msg-wrap').find('.dialog').show(); + return false; + }); + + $('.msg-wrap .no').click( function(e){ + e.preventDefault(); + $(this).parents('.dialog').hide(); + }); + + $('.msg-wrap .yes').click( function(e){ + e.preventDefault(); + $(this).parents('.dialog').siblings('form').submit(); + }); + + $('.hidden-submit input[readonly!="True"]').focus(function () { + $('.hidden-submit .form-row.submit').slideDown(500); + }); + + setTimeout(function() { + if ($('input#id_username').val()){ + $('input#id_username').siblings('label').css('opacity','0'); + }; + if ($('input#id_password').val()){ + $('input#id_password').siblings('label').css('opacity','0'); + } + }, 100); + + $('.landing-page .cms').hover( + function () { + el = $('.cloudbar ul.services li').first(); + var offset = el.offset(); + positionX = offset.left; + $('#hand').css('left',positionX); + $('#hand').show(); + }, + function () { + $('#hand').hide(); + } + ); + + $('.landing-page .pithos').hover( + function () { + el = $('.cloudbar ul.services li:nth-child(3)'); + var offset = el.offset(); + positionX = offset.left; + left = parseInt(positionX) +20; + $('#hand').css('left',left+'px'); + $('#hand').show(); + }, + function () { + $('#hand').hide(); + } + ); + + $('.landing-page .cyclades').hover( + function () { + el = $('.cloudbar ul.services li:nth-child(2)').first(); + var offset = el.offset(); + positionX = offset.left; + left = parseInt(positionX) +20; + $('#hand').css('left',left+'px'); + $('#hand').show(); + }, + function () { + $('#hand').hide(); + } + ); + $('.landing-page .dashboard').hover( + function () { + el = $('.cloudbar .profile'); + var offset = el.offset(); + positionX = offset.left +50; + $('#hand').css('left',positionX); + $('#hand').show(); + }, + function () { + $('#hand').hide(); + } + ); + $('.pagination a.disabled').click(function(e){ + e.preventDefault(); + }); + + // fix for recaptcha fields + $('#okeanos_recaptcha').parents('.form-row').find('.extra-img').hide(); + + fixEl = $('.details .lt'); + if (fixEl.length){ window.fixEloffsetTop = fixEl.offset().top;} + + $(".stats-block li em").equalHeights(); + +}); + +$(window).resize(function() { + setContainerMinHeight('.container .wrapper'); + $(".stats-block li em").equalHeights(); +}); + +/* js for fixed faq/userguide side nav */ +$(window).scroll(function () { + setFixedLtBar(); +}); \ No newline at end of file -- 1.7.10.4