/** * Custom plugin for cemara theme */ (function($){ $.fn.cemara = function( opt ){ var obj = this, /*** Default options ***/ defaults = { startDate : new Date(), endDate : new Date(), titleDays : 'days', titleHours : 'hours', titleMinutes : 'minutes', titleSeconds : 'seconds', theme: 'custome', videoID: '' }; obj.options = $.extend(defaults, opt); obj.init = function(){ // Activate nav animation $(".nav-wrap", obj).hover( function(){ $(this).addClass('hover'); $('.menu', obj).stop().animate( { dist: 300 }, { step: function(now, twin){ $(this).css('clip', 'rect(0px '+ now +'px auto 0px)'); } } ); }, function(){ $(this).removeClass('hover'); $('.menu', obj).stop().animate( { dist: 0 }, { step: function(now, twin){ $(this).css('clip', 'rect(0px '+ now +'px auto 0px)'); } } ); } ); // Activate page animation $('.menu a', obj).bind('click', function(event){ event.preventDefault(); var width = $(window).width(); var thePage = $($(this).attr('href'), obj); if(thePage.size()){ obj.addClass('popup'); if(obj.currentPage || obj.activePage){ (obj.currentPage ? obj.currentPage : obj.activePage).stop().animate( { dist: 0 }, { duration: 2000, step: function(now, twin){ $(this).css('clip', 'rect(0px '+ now +'px auto 0px)'); }, complete: function(){ obj.currentPage = thePage; obj.openCurrentPage(500); } } ); }else{ obj.currentPage = thePage; obj.openCurrentPage(); } } }); // Activate page close animation $('.close-this').bind('click', function(event){ event.preventDefault(); if(obj.currentPage || obj.activePage){ (obj.currentPage ? obj.currentPage : obj.activePage).stop().animate( { dist: 0 }, { duration: 2000, step: function(now, twin){ $(this).css('clip', 'rect(0px '+ now +'px auto 0px)'); }, complete: function(){ obj.currentPage = null; obj.activePage = null; obj.removeClass('popup'); } } ); } }); // Activate count down $("#countdown", obj).dsCountDown( obj.options ); // Activate placeholder for old browser $(":input[placeholder]", obj).placeholder(); // Activate newsletter popup $('.popup-trigger', obj).cemaraClipBottom(); // Activate ajax form $('form', obj).submit(function(event){ event.preventDefault(); var form = $(this); if(form.hasClass('processing')){ return false; } var send_destination = form.attr('action') + '?ajax=1'; var send_data = form.serialize(); form.addClass('processing'); $.ajax({ type: 'POST', url: send_destination, dataType: 'json', data: send_data, success: function(result){ if(result.error){ form.find('.message').html(result.message); }else if(result.success){ form.find('.message').html(result.message); form.find('input[type="text"]').val(''); form.find('textarea').val(''); } form.removeClass('processing'); } }); }); //Activate Nav Clicked $('.btn-trigger', obj).bind('click', function(event){ event.preventDefault(); }); $('#preloader', obj).fadeOut('slow', function(){ obj.removeClass('still-loading'); }); // Activate background if( obj.options.videoId ){ // Nothing todo since it's done by on ready state }else{ var bg = $('#background img', obj); if( bg.size() == 1){ var imageSrc = bg.attr('src'); $.vegas({ src: imageSrc, fade: 1500 }); }else if(bg.size() > 1){ var theBackgrounds = []; bg.each(function(){ theBackgrounds[theBackgrounds.length] = { src: $(this).attr('src'), fade: 1500 }; }); $.vegas('slideshow', { delay: 7000, backgrounds: theBackgrounds })('overlay', { src: 'images/slider-overlay.png' }); } } } // Open current Page obj.openCurrentPage = function(delay){ var width = $(window).width(); obj.currentPage.delay(delay).animate( { dist: width }, { duration: 1500, step: function(now, twin){ $(this).css('clip', 'rect(0px '+ now +'px auto 0px)'); }, complete: function(){ obj.activePage = obj.currentPage; obj.currentPage = null; $(this).css('clip', 'rect(0px auto auto 0px)'); } } ); } // Do preloader obj.preloading = function(){ obj.addClass('still-loading'); var preloader = $('