/* Copyright © 2011, PINT, Inc. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ if(typeof this.PINT=="undefined"){var PINT={}; } PINT.modalOverlay = false; PINT.calendarInfo = []; if ( !$.cookie('ZINGcalendar') ) { $.cookie('ZINGcalendar', '', { path:'/', expires:60 }); } else { PINT.calendarInfo = $.cookie('ZINGcalendar').split(','); } /** FUNCTIONS **********/ (function ($) { /** CALENDAR ACTION **********/ // Sets Action on calendar click // Example with default overrides: $('ul.component-calendar').PINT_calendar({ date:12 }); $.fn.PINT_calendar = function(options) { /** USER ADDED SETTINGS ( Pass into function/method call init ) **/ var settings = $.extend( { // Defaults date:1, //new Date().getDate(); Set Limit Day ( all days before this selectable ) month:12, //new Date().getMonth()+1; Sets which month to set this up for (i.e. December) fadeTiming:300, // When you hover on a calendar day, this is the 'fade' animation speed daySlideDuration:500 // When you click a calendar day, this is the 'slide' animation speed }, options); return this.each(function() { var calendar = $(this); calendar.find('li').each(function(){ if ( settings.month == 12 && settings.date >= parseInt( $(this).find('.day').text(), 10) ) { $(this).addClass('active'); } else { $(this).removeClass('active'); } }); // SET OFFSET VALUE var offset = '-' + $(this).children(':first-child').width(); /** FIND EACH A TAG *****/ // Find each A tag inside our calendar list calendar.find('a').each(function() { /* Mouse Enter *****/ $(this).mouseenter(function() { currentThis = $(this); /** IF 'Active' link **/ if ( currentThis.parent().hasClass('active') ) { currentThis // Fade in hover .children('.day') .addClass('hover') .children('span') .stop() .css('opacity','.3') .animate({ opacity:'1' }, settings.fadeTiming, function() {}) ; } /** ELSE 'Non-Active' link **/ else { currentThis // Fade in hover .children('.day').addClass('hover') .children('span') .stop() .css('opacity','0') .animate({ opacity:'.14' }, settings.fadeTiming, function() {}) .end() .children('strong') .stop() .css('opacity','1') .animate({ opacity:'.5' }, settings.fadeTiming, function() {}) ; } }); /* Mouse Leave *****/ $(this).mouseleave(function() { $(this) .children('.day') .children('span') .stop() .animate({ opacity:'0' }, settings.fadeTiming, function() {}) ; }); }); // SET 'ALLOWABLE' DAYS function PINT_calendarActivateDay(aObj, bRaiseOverlay) { if ($(aObj).length == 0) return; var sDay = $(aObj).attr('href').replace('#day', ''); if ($.inArray(sDay, PINT.calendarInfo) == -1) { PINT.calendarInfo.push(sDay); $.cookie('ZINGcalendar', PINT.calendarInfo.join(','), { path : '/', expires : 60 }); } $(aObj) .stop() .animate({ opacity:'1' }, 800, function() {}) // Add class to remove CSS shadow once active A clicked .parent() .addClass('remove-css') .end() // Find '.day' element to slide 'out' .children('.day') // Add '.day-active' so background gradient stays if you hover off .addClass('day-active') .animate({ left:offset }, settings.daySlideDuration, function() { // Remove class when anim finishes to remove solid-state class for normal hover functionality $(this).removeClass('day-active'); if (bRaiseOverlay) { var ordinal = $(this).find('strong').text(); var selectedDay = '#day'+ordinal; var selectedDayCode = $(selectedDay).html(); $(this).PINT_showOverlay(selectedDayCode); } }) // Return focus back to 'this' (.active a) .end() // Then find the 'current' .content box .children('.content') // slide 'in' .content while .day slides 'out' .animate({ marginLeft:'0' }, settings.daySlideDuration, function() {}) ; } $.each(PINT.calendarInfo, function() { PINT_calendarActivateDay($('a[href="#day' + this.toString() + '"]'), false); }); /** FIND EACH 'ACTIVE' A TAG *****/ // Find each A tag inside our calendar list $(this).find('.active a').each(function() { var currentThis = $(this); currentThis // Mouse Down .mousedown(function() { $(this) .animate({ opacity:'.7' }, 600, function() {}) .parent().addClass('remove-css'); }) // Mouse Up .mouseup(function() { $(this) .animate({ opacity:'1' }, 600, function() {}) .parent().removeClass('remove-css'); }) // Click .click(function() { // Actions PINT_calendarActivateDay(this, true); // Return false on the first click since we don't want to run the A tag HREF yet return false; }) ; }); }) }; /** HEADLINE ANIMATION **********/ // Fades in Headlines (H1,H2) $.fn.PINT_headlineFade = function() { this.each(function() { // Setup Elements var el1 = $(this); var el2 = el1.next(); var el3 = el2.next(); // Set Initial Element CSS el1.css({ opacity:0, marginLeft:'-200px' }) el2.css({ opacity:0, marginLeft:'-5px' }); el3.css({ opacity:0, marginLeft:'95px' }); // Set Constants var animDuration = 450; var timeOutDuration = 250; el1.animate({ opacity:'1', marginLeft:'0' }, animDuration, function() { el3.animate({ opacity:'1', marginLeft:'-55px' }, animDuration, function() { window.setTimeout(function() { el3.animate({ opacity:'1', marginLeft:'0' }, animDuration, function() { el2.animate({ opacity:'1' }, animDuration, function() {}) }); }, timeOutDuration); }) }) }) }; /** OVERLAY: INITIALIZE **********/ // Fades in Overlay $.fn.PINT_showOverlay = function(content) { this.each(function() { if( !$('#overlay-main').length ) { $('body').prepend($('