$(function(){ // Create counters - pass in max var counter = function (max) { "use strict"; var index = 0, /* maxIndex = max, */ getIndex = function () { return index; }, setIndex = function (val) { index = val; return index; }, increment = function () { return index++; }, decrement = function () { return index--; }; return { 'increment' : increment, 'decrement' : decrement, 'getIndex' : getIndex, 'setIndex' : setIndex }; }; function l(o){ console.log(o); } // Splitski $(function(){ var splitski = (function(){ var transitionTime = 300, slideClass = 'splitski-slide', navClass = 'splitski-nav', activeNavClass = 'activeNav', // Do not update below this line // elem = '', delimeter = '', splitPoints = [], slides = [], index = '', getSplitPoints = function(){ splitPoints = $(elem+', '+elem+' *').contents().filter(function(){ if(this.nodeType==8 && (delimeter == this.data.replace(/^\s+|\s+$/g,""))){ return this; } }); }, bubbleSplitPoints = function(){ $(splitPoints).each(function(){ parent = $(this).parent(), i = 0; while($(parent).attr('class')!==$(elem).attr('class') && i<=1000){ i++; $(this).insertAfter(parent); parent = $(this).parent(); } }); }, createSlides = function(){ var slide = $('
').css('display','none').addClass(slideClass); var that = ''; $(elem).contents().each(function(){ that = this; if(this.nodeType==8){ if($(slide).text()){ slides.push(slide); } slide = $('
').css('display','none').addClass(slideClass); } else{ $(that).appendTo(slide); } }); $(that).appendTo(slide); if($(slide).text()){ slides.push(slide); } }, updateNav = function(i){ i++; // accomodate for zero index $('.'+activeNavClass).removeClass(activeNavClass); $('.'+navClass).each(function(){ $('li:nth-child('+ i +')',this).addClass(activeNavClass); }); }, updateSlide = function(e){ if(!e){ updateNav(0); $(slides[0]).fadeIn(transitionTime); } else { var curIndex = $(e.currentTarget).attr('data-index'); if(index.getIndex() != curIndex){ $(slides[index.getIndex()]).stop(1,1).fadeOut(transitionTime,function(){ index.setIndex(curIndex); $(slides[curIndex]).stop(1,1).fadeIn(transitionTime); updateNav(index.getIndex()); }); } } }, // Function to create the navigation createNav = function(){ nav = $('').addClass(navClass); for(var i=0; i').text(i+1).attr('data-index',i).appendTo(nav); } }, populateWrapper = function(){ $(nav).clone().appendTo(elem); $(slides).each(function(){ $(this).appendTo(elem) }); $(nav).clone().appendTo(elem); }, // init function init = function(selector,commentText){ elem = selector; delimeter = commentText; getSplitPoints(); bubbleSplitPoints(); if(splitPoints.length){ createSlides(); index = new counter(slides.length); createNav(); populateWrapper(); updateSlide(); $(elem).on('click','.'+navClass+' li',updateSlide); } } // splitski function returns init which triggers init function return { init : init } }()); // call splitski init function splitski.init('.paginate-me', 'PageSplit'); }); $.easing.customEasing = function (x, t, b, c, d) { return c*((t=t/d-1)*t*t*t*t + 1) + b; }; // consolidate multiple intel forms into one var submissions = (function(){ var hiddenForm = '#intelForm'; var checklist = $('#intelCheckList'); var checkbox = '#intelCheckList input'; var hiddenCheckboxes = '.checkOption:checked'; var optionsBtn = '.OptionsBtn'; var submitCheckboxes = '#submitCheckboxes'; var emailClass = '.emailAddress'; var emailId = '#emailAddress'; var nameClass = '.firstName'; var nameId = '#name'; var partnerId = '#partner'; var sourceId = '#source'; var dataAttr = 'data-optionId'; var submitBtn = '.SubscribeBtn'; var loadChecklist = function(){ $(checklist).css('display','block'); modalWindow(checklist); }; var updateCheckboxes = function(){ $(checkbox).each(function(){ var optionId = $(this).attr(dataAttr); var isChecked = (($(this).attr('checked')=='checked')?true:false); $('#'+optionId).prop("checked", isChecked); }); }; var updateEmail = function(){ var newVal = $(this).val(); $(emailId).val(newVal); } var updateName = function(){ var newVal = $(this).val(); $(nameId).val(newVal); } var hideChecklist = function(){ $(checklist).css('display','none').appendTo('body') } var submitForm = function(){ updateCheckboxes(); var categoryArray = []; $(hiddenCheckboxes).each(function(){ categoryArray.push($(this).val()); }); var params = { "name":$(nameId).val(), "emailAddress":$(emailId).val(), "Partner":$(partnerId).val(), "Source":$(sourceId).val(), "Category[]":categoryArray, "spamCheck":1 } $.ajax({ url:"http://www.digitalinnovationgazette.com/includes/yesmail.php", type:"post", dataType:"json", data:params, success: function (response) { if (response.success) { modalWindow('
Thank you. Your request will be processed shortly.
'); } else { modalWindow('
'+response.errors+'
'); } }, error: function (response) { modalWindow('
'+response.errors+'
'); } }); }; var init = (function(){ $(submitCheckboxes).click(hideChecklist); $(submitBtn).click(submitForm); $(optionsBtn).click(loadChecklist); $(nameClass).change(updateName); $(emailClass).change(updateEmail); })(); })(); // Will return 1 if is using 600 stylesheet and 0 if using 1024 var windowStatus = (function(){ var isNarrow = 0; function getUpdatedIsNarrow(val){ isNarrow = val || ((window.innerWidth<1024)?1:0); return isNarrow; } function getIsNarrow(){ return isNarrow; } return { getStatus:getIsNarrow, updatedAndGetStatus: getUpdatedIsNarrow }; })(); window.onresize = function(){ if(windowStatus.getStatus()!=windowStatus.updatedAndGetStatus()){ resetSlider(windowStatus.getStatus()); $('#accordionText').stop(1,1).css('opacity','1'); resizeChannelPages(); } }; window.onload = function(){ resetSlider(windowStatus.updatedAndGetStatus()); resizeChannelPages(); }; /* Resize the channel page blocks */ var resizeChannelPages = function(){ var firstColumn = '.channelbox'; var textBox = '.articleText'; function greatestHeight(elem1,elem2){ var elem1Height = $(elem1).outerHeight(); var elem2Height = $(elem2).outerHeight(); return ((elem1Height>elem2Height)?elem1Height:elem2Height); } var elem1 = ''; var elem2 = ''; var i = 0; $(firstColumn).each(function(){ if(++i%2){ elem1h2 = $('h2',this); elem1Text = $(textBox,this); }else{ elem2h2 = $('h2',this); elem2Text = $(textBox,this); var h2Height = greatestHeight(elem1h2,elem2h2)+'px'; var textHeight = greatestHeight(elem1Text,elem2Text)+'px'; $(elem1h2).css('height',h2Height); $(elem2h2).css('height',h2Height); $(elem1Text).css('minHeight',textHeight); $(elem2Text).css('minHeight',textHeight); } }); }; // Accordion on the home page function resetSlider(isNarrow){ var accordionId = "#accordion"; var wrapperId = "#accordionWrapper"; var textId = "#accordionText"; var milliseconds = 500; var halfMilliseconds = milliseconds/2; var smallWidth = ((isNarrow)?48:90); var largeWidth = ((isNarrow)?245:455); var activeClass = 'active'; $('.'+activeClass,accordionId).removeClass(activeClass); $('li',accordionId).css({'width':smallWidth}); $(wrapperId).css({'minHeight':0}); var clickSlide = function(e){ if(!$(e).hasClass(activeClass)){ $('.'+activeClass,accordionId).removeClass(activeClass).stop(1,1).animate({ 'width':smallWidth },milliseconds,'customEasing'); $(e).addClass(activeClass).stop(1,1).animate({ 'width':largeWidth },milliseconds,'customEasing'); $(textId).fadeOut(halfMilliseconds,'customEasing',function(){ $(this).html($(e).html()).stop(1,1).fadeIn(halfMilliseconds,'customEasing',function(){ var textHeight = $(wrapperId).outerHeight(); if(textHeight>$(wrapperId).css('minHeight').replace('px','')){ // set a min-height so the text area doesn't bounce up and down $(wrapperId).css({'minHeight':textHeight}); } }); }); } }; var init = (function(){ $('li',accordionId).unbind('click'); $('li',accordionId).click(function(e){ clickSlide(e.target); }); resetHeight(); clickSlide($('li:first',accordionId)); })(); } // Resize home page boxes to all have the same height text function resetHeight(){ var channelBlockId = '#channelBlock'; var maxHeight = 0; $('a',channelBlockId).each(function(){ if(maxHeight<$(this).outerHeight()){ maxHeight = $(this).outerHeight(); } }); $('a',channelBlockId).css({ 'height':maxHeight+'px' }); } }); function ClearText(Elem,DefaultText) { if(Elem) { if(typeof(Elem.value) != 'undefined') { if (Elem.value == DefaultText) { Elem.value = ''; } } else if(typeof(Elem.innerHTML) != 'undefined') { if (Elem.value == DefaultText) { Elem.innerHTML = ''; } } } } function DefaultText(Elem,DefaultText) { if(Elem) { if(typeof(Elem.value) != 'undefined') { if (Elem.value == '') { Elem.value = DefaultText; } } else if(typeof(Elem.innerHTML) != 'undefined') { if (Elem.innerHTML == '') { Elem.innerHTML = DefaultText; } } } } // ******** Modal Window ******** // function modalWindow(content) { var transitionTime = 300; if(!$('#modalScreen').length) { var modalScreen = $('
').css({ 'opacity' : 0, 'background' : '#000', 'position' : 'absolute', 'width' : $(document).width(), 'height' : $(document).height(), 'zIndex' : '999999', 'top' : 0, 'left' : 0 }).attr('id', 'modalScreen').appendTo($('body')).animate({ 'opacity' : .90 }, transitionTime); } if(content != undefined && !$('#modalWindow').length) { var modalWindow = $('
').html(content).css({ 'boxShadow' : '0 0 15px #000', 'position' : 'absolute', 'width' : '300px', 'zIndex' : '999999' }).attr('id', 'modalWindow').appendTo($('body')).css({ 'top' : Math.floor($(window).height() / 2 - ($('#modalWindow').outerHeight() / 2)) + $(window).scrollTop(), 'left' : Math.floor($(window).width() / 2 - ($('#modalWindow').outerWidth() / 2)) }); } updateModal = function() { $('#modalWindow').css({ 'top' : Math.floor($(window).height() / 2 - ($('#modalWindow').outerHeight() / 2)) + $(window).scrollTop(), 'left' : Math.floor($(window).width() / 2 - ($('#modalWindow').outerWidth() / 2)) }); $('#modalScreen').css({ 'width' : $(document).width(), 'height' : $(document).height() }); } closeModal = function() { $('#modalScreen').fadeOut(transitionTime, function() { $(this).remove() }); $('#modalWindow').fadeOut(transitionTime, function() { $(this).remove() }); } $('#modalScreen, .closeModal').click(closeModal); $(window).resize(updateModal); $(document).scroll(updateModal); } // Integrate Sidebox Code, not to be confused with intel subscription // /* Bind form submission [click] events to fire submitForm(). * * Param 1: Object of pertinent form fields * Param 2: CSS selector of content to hide/show for error messages * Param 3: CSS selector of content to hide after a successful form submission * */ $("#SON #SBIntegrate #emailButton").click( function () { submitForm( { "name":'', "emailAddress":$("#SON #SBIntegrate #emailAddress2").val(), "Partner":$("#SON #SBIntegrate #Partner").val(), "spamCheck":1 }, "#SON div#IntegrateMessages", "#SON #SBIntegrate .FormContainer, #SON #SBIntegrate p", false ); } ); // Intel Subscribe $(function() { /* * Bind form submission [click] events to fire submitForm(). * Param 1: Object of pertinent form fields * Param 2: CSS selector of content to hide/show for error messages * Param 3: CSS selector of content to hide after a successful form submission * Param 4: handleIntel param (currently not used) * */ /* Probably a better way to do this, but dupicate code as there are two forms going to the same processor If there was some voodoo to make them both update eachother, dup code wouldn't be necessary. */ $("#SON #SubscriptionForm #SubscribeBtn").click( function () { submitIntelForm( { "name":$("#SON #SubscriptionForm #firstName").val(), "emailAddress":$("#SON #SubscriptionForm #emailAddress").val(), "Partner":$("#SON #SubscriptionForm #Partner").val(), "Source":$("#SON #SubscriptionForm #Source").val(), //"Category":$("#SON #SubscriptionForm .formfields #Category").val(), "Category":$("#SON #intelCheckList #Category").val(), "spamCheck":1 }, "#SON #SponsorUnitMessages", "#SON #SubscriptionForm .formfields, #SON #SubscriptionForm p", true ); } ); $("#SON #PageSubscriptionForm #SubscribeBtn").click( function () { submitIntelForm( { "name":$("#SON #PageSubscriptionForm #firstName").val(), "emailAddress":$("#SON #PageSubscriptionForm #emailAddress").val(), "Partner":$("#SON #PageSubscriptionForm #Partner").val(), "Source":$("#SON #PageSubscriptionForm #Source").val(), //"Category":$("#SON PageSubscriptionForm .formfields #Category").val(), "Category":$("#SON #intelCheckList #Category").val(), "spamCheck":1 }, "#SON #SponsorUnitMessages", "#SON #PageSubscriptionForm .formfields, #SON #PageSubscriptionForm p", true ); } ); } ); function submitForm (formObj, swap, success, blnIntelSubmission) { $(swap).fadeOut(500, function () { $.ajax({ url:"/includes/processforms.php", type:"post", dataType:"json", data:formObj, success: function (response) { $(swap).empty(); if (response.success) { $(success).fadeOut(500, function () { $(swap) .html("

Thank you. Your request will be processed shortly.

") .fadeIn(500); } ); // Intel hook: Successful submission- send data to Intel if (blnIntelSubmission) handleIntel(formObj); } else { $(swap) .html(response.errors) .fadeIn(500); } }, error: function (response) { } }); } ); } // Submit sidebox forms function submitIntelForm (formObj, swap, success, blnIntelSubmission) { $(swap).fadeOut(500, function () { $.ajax({ url:"/includes/processIntelforms.php", type:"post", dataType:"json", data:formObj, success: function (response) { $(swap).empty(); if (response.success) { $(success).fadeOut(500, function () { $(swap) .html("

Thank you. Your request will be processed shortly.

") .fadeIn(500); } ); // Intel hook: Successful submission- send data to Intel if (blnIntelSubmission) handleIntel(formObj); } else { $(swap) .html(response.errors) .fadeIn(500); } }, error: function (response) { } }); } ); }