bebeboutik/themes/site_mobile/js/mobile_tools.js

88 lines
2.0 KiB
JavaScript
Raw Normal View History

2016-01-04 12:48:08 +01:00
(function( $ ) {
$.fn.getDeviceSize = function(params)
{
if(params == 'w')
{
return $(window).width();
}
else if(params == 'h')
{
return $(window).height();
}
else
{
var deviceSize = new Array();
deviceSize['width'] = $(window).width()
deviceSize['height'] = $(window).height();
return deviceSize;
}
}
/**
* Get To Top Button if content height is enought
* Use it in setTimeOut to get real content height
*/
$.fn.getToTopButton = function()
{
$('#totop').hide();
var docHeight = $(document).height();
var winHeight = $(window).getDeviceSize('h');
var headHeight = $('#header').height();
var contentHeight = $('#page #columns .content #center_column').height();
if(contentHeight > (winHeight + headHeight))
{
$('#totop').fadeIn();
}
}
/**
* Display Small or Big Logo depends on device width
* Not used but TODO
*/
$.fn.resizeLogo = function()
{
var logo ='';
var img_src= this.attr('src');
var img_path = img_src.substr(0,img_src.lastIndexOf('/'))+'/';
var img_ext = img_src.substr(img_src.lastIndexOf('.'));
if($(window).getDeviceSize('w') < 1200)
{
logo = 'logo_logged';
}
else if($('#header div.logo_block').width() < 330)
{
logo = 'logo_logged';
}
else
{
logo = 'logo'
}
this.attr('src', img_path+logo+img_ext);
}
}(jQuery));
/* Run all */
$(document).ready(function(){
//document.body.scrollWidth, document.body.scrollHeight //pour la taille complète du document
//document.body.offsetWidth, document.body.offsetHeight //pour la taille affichée
//document.body.clientWidth, document.body.clientHeight //pour la taille client affichée (ie sans les scrollbars & co).
$('.footer_hook > div.multi_links_block_left ul').hide();
$('.footer_hook > div.multi_links_block_left h4').click(function(){
$(this).parent().toggleClass('opened');
$(this).next('ul').slideToggle();
});
//Apparition du to top
setTimeout(function(){ $(window).getToTopButton() }, 1);
//$('.logo_block a img').resizeLogo();
});