(function($){ $.fn.UItoTop = function(options) { var defaults = { text: 'To Top', min: 200, inDelay:600, outDelay:400, containerID: 'toTop', containerHoverID: 'toTopHover', scrollSpeed: 1200, easingType: 'linear' }, settings = $.extend(defaults, options), containerIDhash = '#' + settings.containerID, containerHoverIDHash = '#'+settings.containerHoverID; $('body').append(''+settings.text+''); $(containerIDhash).hide().on('click.UItoTop',function(){ $('html, body').animate({scrollTop:0}, settings.scrollSpeed, settings.easingType); $('#'+settings.containerHoverID, this).stop().animate({'opacity': 0 }, settings.inDelay, settings.easingType); return false; }) .prepend('') .hover(function() { $(containerHoverIDHash, this).stop().animate({ 'opacity': 1 }, 300, 'linear'); }, function() { $(containerHoverIDHash, this).stop().animate({ 'opacity': 0 }, 700, 'linear'); }); $(window).scroll(function() { var sd = $(window).scrollTop(); if(typeof document.body.style.maxHeight === "undefined") { $(containerIDhash).css({ 'position': 'absolute', 'top': sd + $(window).height() - 50 }); } if ( sd > settings.min ) $(containerIDhash).fadeIn(settings.inDelay); else $(containerIDhash).fadeOut(settings.Outdelay); }); }; })(jQuery); $(document).ready( function () { $(document).on('click', 'a.scrollto[href*="#"]:not([href="#"],[href="#sidr"])', function () { if (location.pathname.replace(/^\//, '') === this.pathname.replace(/^\//, '') && location.hostname === this.hostname) { var target = $(this.hash); var pos = target.offset().top - 40; target = target.length ? target : $('[name=' + this.hash.slice(1) + ']'); if (target.length) { $('html,body').animate({ scrollTop: pos }, 600, 'easeOutExpo'); return false; } } }); $.fn.verticalCenter = function( onAttribute ) { return this.each(function(){ var $this = $(this); var attribute = onAttribute || 'margin-top'; var resizer = function () { $this.css( attribute, ( ( $this.parent().height() - $this.height() ) / 2 ) ); }; resizer(); $(window).resize(resizer); }); }; $().UItoTop({ easingType: 'easeOutExpo' }); var $navopen = false; var $thebtn = $('header h1 a'); $("nav > ul > li > a").not('.direct').click(function (e) { e.stopPropagation(); var $btn = $(this); var $target = $('.row').eq(0); if ($thebtn.is($btn)) { $btn.blur(); $('.navchild').animate({ opacity: 0, height: 0 }, 250, function() { $('.navchild').remove(); $thebtn = $('header h1 a'); $navopen = false; }); } else { $('.navchild').remove(); var $menu = $btn.parent('li').find('div').clone().addClass('navchild').prependTo($target); var $height = $menu.height(); $menu.click(function(e) { e.stopPropagation(); }); $menu.css('height', 0); $menu.animate({ opacity: 1, height: $height }, 350, function() { $thebtn = $btn; $navopen = true; $menu.find('ul, form').animate({ opacity: 1 }, 300); var $attr = $btn.attr('id'); if ($attr === 'srch') { $('.navchild input').focus(); } }); } }); $(document).keyup(function(e) { if (e.keyCode === 27) { if ($navopen) { $('.navchild').animate({ opacity: 0, height: 0 }, 250, function() { $('.navchild').remove(); $navopen = false; $thebtn = $('header h1 a'); }); $('nav > ul > li > a').blur(); } } }); $(document).click(function () { if ($navopen) { $('.navchild').animate({ opacity: 0, height: 0 }, 250, function() { $('.navchild').remove(); $navopen = false; $thebtn = $('header h1 a'); }); $('nav > ul > li > a').blur(); } }); $('#menu-btn').sidr({ name: 'sidr-main', source: '#nav', side: 'right', displace: true, onOpen: function () { if (!$('.sidr-inner #msrch').length) { $('.sidr-inner').prepend('
'); } $('#menu-btn').html(''); }, onClose: function () { $('#menu-btn').html(''); } }); $(window).resize(function () { $.sidr('close', 'sidr'); }); $('#sidr-main a').click(function() { $.sidr('close', 'sidr-main'); }); $('[data-bg]').each(function () { var bg = $(this).data('bg').replace(/ /g, '%20'); $(this).css({ "background-image": "url(" + bg + ")" }); }); $('#ctlist li a').click(function(){ $('html, body').animate({ scrollTop: $( $(this).attr('href') ).offset().top - 30 }, 800, 'easeOutExpo'); return false; }); $('.article').columnize({ columns: 2 }); if (typeof $lg !== 'undefined') { $lg.on('onBeforeOpen.lg',function(event){ $('.navchild').remove(); }); $lg.on('onAfterOpen.lg',function(event){ $('.lg-toolbar').append(''); $('#lg-print').click(function() { var $text = 'Trinity Furniture - ' + $('.lg-sub-html').html(); var $html = '' + $text + '
'; $('.lg-current').print({ title: null, append: $html }); }); }); $lg.on('onCloseAfter.lg',function(event){ $('#lg-print').remove(); }); $lg.on('onBeforeSlide.lg',function(event){ $('.lg-caption').remove(); }); $lg.on('onAfterAppendSubHtml.lg',function(event){ var $caption = $('.lg-sub-html').html(); setTimeout(function(){ $('' + $caption + '
').insertAfter('.lg-current .lg-img-wrap img'); $('.lg-caption').animate({opacity:1}, 250); }, 150); }); } });