/*********************************************************/ /* © 2014 DynamiX Web Design, LLC • http://dynamixwd.com */ /*********************************************************/ //****************************************************************************/ // Globals //****************************************************************************/ var mobile = (/Android|webOS|iPhone|iPad|iPod|BlackBerry/i.test(navigator.userAgent))? true : false; //****************************************************************************/ // MAIN window.load & document.ready //****************************************************************************/ // window.load() (function($){ jQuery( window ).load(function() { dynamix.onLoad(jQuery); dynamix.equalHeightColumns(jQuery); }); })(jQuery); // document.ready() (function($){ jQuery( document ).ready(function() { dynamix.onReady(jQuery); //dynamix.progressBlocker(); // ProgressBlocker - !!! REMOVE FOR PRODUCTION !!! dynamix.mobileButtons(jQuery); dynamix.bxSlider(jQuery); dynamix.splitIntoColumns(jQuery); dynamix.pagination(jQuery); dynamix.audioPlayer(jQuery); dynamix.calculatorControls(jQuery); dynamix.layoutArticle(jQuery); dynamix.layoutPosts(jQuery); //Categories Page dynamix.sidebarSwitch(jQuery); dynamix.travelDeals(jQuery); dynamix.bankrateCalculators(jQuery); dynamix.newsletter(jQuery); //dynamix.analyticsEvents(jQuery); dynamix.videoEvents(jQuery); dynamix.deals(jQuery); }); })(jQuery); //Create your custom functions within the dynamix object below var dynamix = { // window.load() onLoad: function($) { $('.fitvids').fitVids(); $('p.play').html(''); $('p.pause').html(''); setTimeout(function(){ $('.gsc-search-box input.gsc-input').attr('placeholder','What are you looking for?'); },300); // $('.gsc-results-wrapper-nooverlay').addClass('gsc-results-wrapper-overlay').removeClass('gsc-results-wrapper-nooverlay'); }, // document.ready() onReady: function($) { //*** Toggle Open Topics Menu *************************// $('.topics').clone().appendTo('.layout-featured-articles > .width-container'); //Clone Topics bar and added it to the bottom of the homepage featured articles section $('.nav-inner>a[href="/topics"]').attr('href' , '#topics'); function openTopics(){ $('.clarks-topics-toggle').toggleClass('open'); $('.topics').eq(0).toggleClass('maximized-topics'); //$('#menu-wrapper, #menu-icon').toggleClass('active'); $('#nav').hide(); } function closeTopics(){ $('.clarks-topics-toggle').removeClass('open'); $('.topics').eq(0).removeClass('maximized-topics'); $('#menu-wrapper, #menu-icon').removeClass('active'); } function showNavOnMobile(){ var $icon = $('.toggle-nav').find('i'); if($icon.hasClass('fa-navicon')){ $icon.removeClass('fa-navicon').addClass('fa-times'); }else{ $icon.removeClass('fa-times').addClass('fa-navicon'); } $('.navigation').toggleClass('visible'); } var $topicsToggle = $('.nav-inner>a[href="#topics"], .clarks-topics-toggle'); $topicsToggle.click(function(e) { e.preventDefault(); openTopics(); }); $('#header .mobile-buttons .toggle-nav').click(function(e){ e.preventDefault(); showNavOnMobile(); if($('.navigation').hasClass('visible')){ openTopics(); }else{ closeTopics(); } }); $('#menu-wrapper').click(function(){ if($(window).width() <= 800){ closeTopics(); } }); $('.layout-featured-articles .view-more-articles').click(function(e){ e.preventDefault(); showNavOnMobile(); if($(window).width() >= 940){ $('.topics').eq(1).toggleClass('maximized-topics'); }else{ $('.topics').eq(0).toggleClass('maximized-topics'); $('html,body').animate({ scrollTop : $('.navigation').eq(0).offset().top+'px' },300); $topicsToggle.toggleClass('open'); } }); //bold the first word of the travel deals link $('.travel-deal > h3 > a').each(function(){ var $p = $(this); $p.html($p.html().replace(/^(\w+)/, '$1')); }); //remove Redundant Howard Clark text from on-demand subpage $('.on-demand-content .recent-episodes ul li a strong').each(function(){ var original = $(this).html(); var result = original.substr(original.indexOf(" ") + 1); result = result.substr(result.indexOf(" ") + 1); $(this).html(result); }); $('.app-wrapper ul').splitIntoColumns(); //*** .mobile-info button to show additional info on mobile *************************// $('.mobile-info').click(function(e){ e.preventDefault(); if($(this).find('.fa').hasClass('fa-info-circle')){ $(this).find('.fa').removeClass('fa-info-circle').addClass('fa-chevron-up'); $('.publish-info, .breadcrumbs').show(); }else{ $(this).find('.fa').removeClass('fa-chevron-up').addClass('fa-info-circle'); $('.publish-info, .breadcrumbs').hide(); } }); }, progressBlocker: function($) { $.progressBlocker({ width: 1200, frontpage: 'show', responsive: 'hide', ie: 'hide' }); }, mobileButtons: function($){ $('#header .mobile-buttons .toggle-search').click(function(e){ e.preventDefault(); $(this).toggleClass('visible'); $('#header .search-col').toggleClass('visible').find('input[name="search"]').focus(); }); }, bxSlider: function($) { if ( $('.flash-gallery li').length > 1 ) { $('.flash-gallery').bxSlider({ mode: 'fade', controls: true, pager: true, auto: true, autoStart: true, pause: 6000, touchEnabled: false }); } else { $('.flash-gallery').bxSlider({ mode: 'fade', controls: false, pager: false, auto: false, pause: 6000, adaptiveHeight: true, touchEnabled: false }); } }, splitIntoColumns: function($){ $('.article-list-one-featured ul').splitIntoColumns({count: 2}); }, equalHeightColumns: function($){ $('.tools-callout > div').equalHeightColumns(); $('.layout-on-demand .on-demand-left, .layout-on-demand .on-demand-right').equalHeightColumns(); $('.on-demand-content .on-demand-left .recent-episodes ul li a').equalHeightColumns(); $('.additional-article-wrapper .article-title a').equalHeightColumns(); $('.announcements .col').equalHeightColumns(); }, pagination: function($){ //Check for pagination on load var checkPager = $('.pager'), theHash = parseInt(window.location.hash.substring(1)); if (window.location.hash != '' && checkPager.length && $.isNumeric(theHash)){ var pageindex = parseInt($('.pager-'+theHash+' a').attr('data-start')); var category = parseInt($('#category').attr('data-value')); var latest = $('#latest').attr('data-value'); getData(category,pageindex, latest); } var $pager = $('.pager'); var $pagerLinks = $pager.find('li').not('.prev,.next'); reconfigPagination(); //Pagination system for category article lists $('.pager a').click(function(e){ e.preventDefault(); var pageindex = parseInt($(this).attr('data-start')); var category = parseInt($('#category').attr('data-value')); var latest = $('#latest').attr('data-value'); var maxArticles = parseInt($('#maxArticles').attr('data-value')); $('.prev a').prop('disabled', false); $('.next a').prop('disabled', false); getData(category,pageindex, latest); var prevCount = parseInt(pageindex - 15), nextCount = parseInt(pageindex + 35), tabCount = parseInt((pageindex / 15) + 1); //Set the floor if (prevCount < 0){ prevCount = 0; //Disable the button $('.prev a').prop('disabled', true); } //Set the ceiling if ((nextCount * 15) > maxArticles){ nextCount = (nextCount - 15); //Disable the button $('.next a').prop('disabled', true); } //Set Previous $('.prev a').attr('data-start', prevCount); //Set Next $('.next a').attr('data-start', nextCount); //Remove Active status $('.pager .active').removeClass('active'); //Set New Active status //$(this).parent('li').addClass('active'); $('.pager-'+tabCount).addClass('active'); var newActive = $('.pager-'+tabCount+' a').data('hash'); window.location.hash = newActive; $('html, body').animate({scrollTop:$('.posts').offset().top - 20},800); reconfigPagination(); }); function getData(category,start, latest){ $.ajax({ //CHANGE THIS URL TO MATCH THE SITE url: '/sites/clarkhowardcom/more-articles.php', data: { "category" : category, "start" : start, "latest": latest }, error: function(error){ console.log(error); }, success: function(result){ $('.posts').html(result); }, dataType: 'html' }); } function reconfigPagination(){ $pager.find('li').show(); $pager.find('>span').remove(); var $activeLink = $pager.find('.active'); var $firstLink = $pager.find('.pager-1'); var $lastLink = $pager.find('.next').prev(); var $prevLink = $activeLink.prev(); var $nextLink = $activeLink.next(); var $extraLinks = $pager.find('li') .not($activeLink) .not('.prev') .not('.next') .not($firstLink) .not($lastLink) .not($prevLink) .not($nextLink); $extraLinks.hide(); $prevLink.not('.prev').not($firstLink).before('...'); $nextLink.not('.next').not($lastLink).after('...'); } }, audioPlayer: function($){ //Initilize the audio player for podcasts audiojs.events.ready(function() { audiojs.createAll(); }); $('.podcast-episode a:nth-child(2)').click(function(e){ e.preventDefault(); var newTitle = $(this).find('.podcast-episode-title').html(), newDescription = $(this).parents('li').data('full-description'), newSrc = $(this).parents('li').data('media-url'); $(".podcast-episode").removeClass("selected"); $(this).addClass("selected"); $('.podcast-player-title').html(newTitle); $('.podcast-player-description').html(newDescription); $('.podcast-player').attr('src', newSrc); $('.podcast-download').attr('href', newSrc); }); //*** scroll to up to the player *************************// $('.on-demand-content .recent-episodes a').click(function(){ $('html,body').scrollTop($('.listen-container').offset().top); }); }, calculatorControls: function($) { $('.calculator-tabs div').click(function() { $('.calculator-tabs div').removeClass('active'); $(this).addClass('active'); if ($(this).hasClass('tab-one')) { $('.calculator-two, .calculator-three').addClass('hide'); $('.calculator-one').removeClass('hide'); } else if ($(this).hasClass('tab-two')) { $('.calculator-one, .calculator-three').addClass('hide'); $('.calculator-two').removeClass('hide'); } else if ($(this).hasClass('tab-three')) { $('.calculator-one, .calculator-two').addClass('hide'); $('.calculator-three').removeClass('hide'); } }); }, layoutArticle: function($){ //*** Split Popular Articles into two columns *************************// $('.layout-article .small-latest-articles .articles-holder').splitIntoColumns(); //*** Toggle Open Comments *************************// $('.toggle-comments, .comments-link').click(function(){ $('.toggle-comments').toggleClass('open'); $('.comments').toggleClass('open'); if($('.toggle-comments').hasClass('open')){ $('.toggle-comments').find('.comment-title').html('Hide Comments'); }else{ $('.toggle-comments').find('.comment-title').html('Show Comments'); } }); $('.layout-article .content table, .layout-standard .content table').stacktable(); }, layoutPosts: function($){ //Remove First string from Subtopics links $('.subtopics-list li a').each(function(){ var text = $(this).html(); //get subtopic text var newText = ''; text = text.split(' / '); //split by / for(var i = 0; i < text.length; ++i){ if(i > 0){ if(i == 1){ newText = newText+text[i]; //create new text but skip the first one }else{ newText = newText+' / '+text[i]; } } } $(this).html(newText); }); $('.subtopics-wrapper h3').click(function(e){ e.preventDefault(); $(this).parent().find('.subtopics-list').toggleClass('open'); $(this).toggleClass('open'); }); $('.subtopics-list').splitIntoColumns({count:3}); $('.subtopics-list li a').equalHeightColumns(); }, sidebarSwitch: function($){ //use this to move the items at a specific point function moveElement(resolution,$itemToMove,$afterThisItem){ var size = $(window).width(); if(size <= resolution && !$itemToMove.hasClass('moved')){ //If less than 940 $itemToMove.insertAfter($afterThisItem); $itemToMove.addClass('moved'); // googletag.pubads().refresh([slotRP01]); }else if(size > resolution && $itemToMove.hasClass('moved')){ //if greater than 940 $itemToMove.insertBefore($afterThisItem); $itemToMove.removeClass('moved'); // googletag.pubads().refresh([slotRP01]); } } //Layout-featured-articles Move Sidebar if($('.layout-featured-articles').length > 0){ moveElement(940,$('.layout-featured-articles .sidebar-col'),$('.layout-featured-articles .articles-col')); $(window).resize(function(){ moveElement(940,$('.layout-featured-articles .sidebar-col'),$('.layout-featured-articles .articles-col')); }); } //Categories page if($('.post-list').length > 0){ moveElement(940,$('.post-list .sidebar-col'),$('.post-list .posts-col')); moveElement(940,$('.post-list .small-latest-articles'),$('.post-list .best-articles-wrapper')); $(window).resize(function(){ moveElement(940,$('.post-list .sidebar-col'),$('.post-list .posts-col')); moveElement(940,$('.post-list .small-latest-articles'),$('.post-list .best-articles-wrapper')); }); } //Cards pages if($('.cards-content').length > 0){ moveElement(940,$('.cards .sidebar'),$('.cards .content')); $(window).resize(function(){ moveElement(940,$('.cards .sidebar'),$('.cards .content')); }); } //*** Insert Ad Block placeholder in content On Articles Pages that sidebar ad will be moved too *************************// if($('.layout-article').length > 0){ var adBlock = '
'; if($('.layout-article .article-content-wrapper').text().length > 2000){ //if content somewhat long $('.layout-article .article-content-wrapper h2 + p + p').eq(0).after(adBlock); } } //Layout-article and layout-standard : move sidebar on mobile if($('.layout-article, .layout-standard').length > 0){ function moveArticleSidebar(){ var switchPoint = 940; var size = $(window).width(); if(size <= switchPoint && !$('.main-content-wrapper').hasClass('moved')){ //If less than 940 $('.main-content-wrapper .sidebar').insertAfter($('.main-content-wrapper .content')); $('.main-content-wrapper').addClass('moved'); $('.main-content-wrapper .sidebar .ad-holder').eq(0).appendTo($('.layout-article .ad-content-flow')); // googletag.pubads().refresh([slotRP01]); }else if(size > switchPoint && $('.main-content-wrapper').hasClass('moved')){ //if greater than 940 $('.main-content-wrapper .sidebar').insertBefore($('.main-content-wrapper .content')); $('.main-content-wrapper').removeClass('moved'); $('.layout-article .ad-content-flow .ad-holder').appendTo($('.main-content-wrapper .sidebar .ad-square-wrapper:eq(0)')); // googletag.pubads().refresh([slotRP01]); } } moveArticleSidebar(); $(window).resize(function(){ moveArticleSidebar(); }); } //*** Show Sidebar after page loads *************************// setTimeout(function(){ $('.sidebar,.sidebar-col').show(); },200); }, travelDeals: function($) { if ($('#wrapper').hasClass('page_3954') || $('#wrapper').hasClass('page_3706')) { $('hr').each(function(){ $(this).css({'display' : 'none'}) $(this).nextUntil('hr').wrapAll($('
').addClass('alternating-segments')); }); } }, bankrateCalculators: function($){ //This is js to help style the bankrate calculators var $calc = $('.BankrateFCC_calc-container-small'); $calc.each(function(){ $(this).find('.BankrateFCC_col1').each(function(){ $(this).nextUntil('.BankrateFCC_col1,.BankrateFCC_button-small').andSelf().wrapAll('
'); }); }); }, newsletter: function($){ $(document).on('focus','.newsletter-form input',function(){ $(this).parents('.newsletter-form').find('.form-line').show(); }); }, videoEvents: function($){ //Viewing Video Page if ($('#wrapper').hasClass('video-page')){ var title = $('h1.page-title').text(); _gaq.push(['_trackEvent', 'Video Page', 'loaded', title]); } }, deals: function($){ $('.show-more').click(function(){ $(".more-deals").slideToggle('medium', function() { $('.show-more').hide(); }); }); }, analyticsEvents: function($) { // $('selector').gaEvent(eventType, category, action, label); //article page events $('.at-svc-facebook').gaEvent('click', 'Article events', 'click', 'Facebook Share Button'); $('.at-svc-twitter').gaEvent('click', 'Article events', 'click', 'Twitter Share Button'); $('.at-svc-email').gaEvent('click', 'Article events', 'click', 'Email Share Button'); $('.at-svc-print').gaEvent('click', 'Article events', 'click', 'Print Button'); $('.post-actions .btn').gaEvent('click', 'Article events', 'click', 'Comment Submitted'); $('.comments-link, .toggle-commments').click(function() { var url = window.location.origin+window.location.pathname+'#disqus_thread'; _gaq.push(['_trackPageview', url]); }); //On Demand Section events $('.audiojs .play').gaEvent('click', 'On Demand events', 'click', 'Clicked Audio Player'); $('.podcast-episode').gaEvent('click', 'On Demand events', 'click', 'Changed Podcast Episode'); $('.radio-link').gaEvent('click', 'On Demand events', 'click', 'Listen Live'); $('.video-container iframe').gaEvent('click', 'On Demand events', 'click', 'Watched Youtube Video'); $('.featured-videos li').gaEvent('click', 'Article events', 'click', 'Print Button'); //header events $('#topics').gaEvent('click', 'Header events', 'click', 'Opened Topics List'); } }; //****************************************************************************/ // Standard DynamiX JS - USUALLY No Changes Requried //****************************************************************************/ (function($){ $(document).ready(function() { // Add href to category menu links that do not have an href and prevent click event. $('#nav a').each(function(){ if($(this).attr('href') === '#'){ $(this).css({'cursor':'default'}); var newHref = $(this).parents('li').find('ul li a').eq(0).attr('href'); $(this).attr('href',newHref); } }); // Add Phone number link if( !mobile ) { var telLink = $('a.tel'); telLink.css('cursor','default'); telLink.click(function(e){ e.preventDefault(); }); } //Mobile Nav $('#menu-wrapper').mobileNav({ breakPoint: 800, navBgColor: 'rgb(77, 76, 83)', navBgHover: 'rgb(80, 105, 53)', menuBgColor: 'rgb(255,255,255)', menuBgHover: 'rgb(74, 115, 105)', menuTextColor: 'rgb(49, 49, 49)', menuDividerColor: 'rgb(54, 84, 76)', subMenuBgColor: 'rgb(237, 237, 237)' }); $('.navigation').css('display','block'); // Form Sent Success msg=sent $('body').msgSent({ variable: 'sent', message : 'Thank you for contacting us! We look forward to helping you with your needs.

We will contact you soon to discuss how we can help!', bgColor: 'rgb(61, 80, 102)', bgColorAlpha: 'rgba(61, 80, 102,.9)', borderRadius: '50%' }); // Wrap youtube iframes in a fitvids wrapper automatically $('iframe[src*="youtube"],object').each(function() { $(this).wrap('
'); }); }); })(jQuery); //****************************************************************************/ // Embedded Scripts //****************************************************************************/ // DynamiX Analytics Events v1.0.0 (function(a){a(document).ready(function(){window.elapsed_time=0;setInterval(function(){window.elapsed_time+=1;var b=document.title;if(window.elapsed_time==180){trackThis("Reading Article","3 Minutes",b)}else{if(window.elapsed_time==300){trackThis("Reading Article","5 Minutes",b)}else{if(window.elapsed_time==420){trackThis("Reading Article","7 Minutes",b)}else{if(window.elapsed_time==540){trackThis("Reading Article","9 Minutes",b)}else{if(window.elapsed_time==660){trackThis("Reading Article","11 Minutes",b)}}}}}},1000);a("a").on("click",function(){try{href=a(this).attr("href");if(href.match(/https?\:\/\//).length===0){return false}if(href.match(/^tel\:/).length>0){trackThis("Click to Call",a(this).text(),href);return true}if(href.indexOf(window.location.host)<0){trackThis("External link",a(this).text(),href)}}catch(b){}});a(".phone").on("click",function(b){trackThis("Clicked phone number",a(this).text())});a(".tel").on("click",function(b){trackThis("Clicked phone number",a(this).text())});a(".sendit").on("click",function(b){trackThis("Form Submission",a(this).val())});a('a[href^="http://"]').not('[href*="'+document.domain+'"]').attr("target","_blank").on("click",function(g){var f=a(this),c=f.attr("href"),b=(f.attr("target")==="_blank"||g.metaKey||g.ctrlKey);window._gaq=window._gaq||[];try{if(!b){g.preventDefault();setTimeout(function(){document.location=c},100)}}catch(d){}})})})(jQuery);var googleAnalyticsVersion=0;(function(a){a(document).ready(function(){if(typeof ga==="function"){googleAnalyticsVersion=1;console.info("dx-ga: universal")}if(typeof _gaq!=="undefined"&&typeof _gaq.push==="function"){googleAnalyticsVersion=2;console.info("dx-ga: classic")}})})(jQuery);function trackThis(b,d,a,c){if(a===undefined){a=""}if(c===undefined){if(googleAnalyticsVersion==1){ga("send","event",b,d,a)}else{if(googleAnalyticsVersion==2){_gaq.push(["_trackEvent",b,d,a])}else{console.log("Google Analytics event error.")}}}else{if(googleAnalyticsVersion==1){ga("send","event",b,d,a,c)}else{if(googleAnalyticsVersion==2){_gaq.push(["_trackEvent",b,d,a,c])}else{console.log("Google Analytics event error.")}}}}; // FitVids v1.1 (function(a){a.fn.fitVids=function(b){var e={customSelector:null,ignore:null};if(!document.getElementById("fit-vids-style")){var d=document.head||document.getElementsByTagName("head")[0];var c=".fluid-width-video-wrapper{width:100%;position:relative;padding:0;}.fluid-width-video-wrapper iframe,.fluid-width-video-wrapper object,.fluid-width-video-wrapper embed {position:absolute;top:0;left:0;width:100%;height:100%;}";var f=document.createElement("div");f.innerHTML='

x

";d.appendChild(f.childNodes[1])}if(b){a.extend(e,b)}return this.each(function(){var g=["iframe[src*='player.vimeo.com']","iframe[src*='youtube.com']","iframe[src*='youtube-nocookie.com']","iframe[src*='kickstarter.com'][src*='video.html']","object","embed"];if(e.customSelector){g.push(e.customSelector)}var h=".fitvidsignore";if(e.ignore){h=h+", "+e.ignore}var i=a(this).find(g.join(","));i=i.not("object object");i=i.not(h);i.each(function(){var n=a(this);if(n.parents(h).length>0){return}if(this.tagName.toLowerCase()==="embed"&&n.parent("object").length||n.parent(".fluid-width-video-wrapper").length){return}if((!n.css("height")&&!n.css("width"))&&(isNaN(n.attr("height"))||isNaN(n.attr("width")))){n.attr("height",9);n.attr("width",16)}var j=(this.tagName.toLowerCase()==="object"||(n.attr("height")&&!isNaN(parseInt(n.attr("height"),10))))?parseInt(n.attr("height"),10):n.height(),k=!isNaN(parseInt(n.attr("width"),10))?parseInt(n.attr("width"),10):n.width(),l=j/k;if(!n.attr("id")){var m="fitvid"+Math.floor(Math.random()*999999);n.attr("id",m)}n.wrap('
').parent(".fluid-width-video-wrapper").css("padding-top",(l*100)+"%");n.removeAttr("height").removeAttr("width")})})}})(window.jQuery||window.Zepto); // BX-Slider v4.1.2 !function(t){var e={},s={mode:"horizontal",slideSelector:"",infiniteLoop:!0,hideControlOnEnd:!1,speed:500,easing:null,slideMargin:0,startSlide:0,randomStart:!1,captions:!1,ticker:!1,tickerHover:!1,adaptiveHeight:!1,adaptiveHeightSpeed:500,video:!1,useCSS:!0,preloadImages:"visible",responsive:!0,slideZIndex:50,touchEnabled:!0,swipeThreshold:50,oneToOneTouch:!0,preventDefaultSwipeX:!0,preventDefaultSwipeY:!1,pager:!0,pagerType:"full",pagerShortSeparator:" / ",pagerSelector:null,buildPager:null,pagerCustom:null,controls:!0,nextText:"Next",prevText:"Prev",nextSelector:null,prevSelector:null,autoControls:!1,startText:"Start",stopText:"Stop",autoControlsCombine:!1,autoControlsSelector:null,auto:!1,pause:4e3,autoStart:!0,autoDirection:"next",autoHover:!1,autoDelay:0,minSlides:1,maxSlides:1,moveSlides:0,slideWidth:0,onSliderLoad:function(){},onSlideBefore:function(){},onSlideAfter:function(){},onSlideNext:function(){},onSlidePrev:function(){},onSliderResize:function(){}};t.fn.bxSlider=function(n){if(0==this.length)return this;if(this.length>1)return this.each(function(){t(this).bxSlider(n)}),this;var o={},r=this;e.el=this;var a=t(window).width(),l=t(window).height(),d=function(){o.settings=t.extend({},s,n),o.settings.slideWidth=parseInt(o.settings.slideWidth),o.children=r.children(o.settings.slideSelector),o.children.length1||o.settings.maxSlides>1,o.carousel&&(o.settings.preloadImages="all"),o.minThreshold=o.settings.minSlides*o.settings.slideWidth+(o.settings.minSlides-1)*o.settings.slideMargin,o.maxThreshold=o.settings.maxSlides*o.settings.slideWidth+(o.settings.maxSlides-1)*o.settings.slideMargin,o.working=!1,o.controls={},o.interval=null,o.animProp="vertical"==o.settings.mode?"top":"left",o.usingCSS=o.settings.useCSS&&"fade"!=o.settings.mode&&function(){var t=document.createElement("div"),e=["WebkitPerspective","MozPerspective","OPerspective","msPerspective"];for(var i in e)if(void 0!==t.style[e[i]])return o.cssPrefix=e[i].replace("Perspective","").toLowerCase(),o.animProp="-"+o.cssPrefix+"-transform",!0;return!1}(),"vertical"==o.settings.mode&&(o.settings.maxSlides=o.settings.minSlides),r.data("origStyle",r.attr("style")),r.children(o.settings.slideSelector).each(function(){t(this).data("origStyle",t(this).attr("style"))}),c()},c=function(){r.wrap('
'),o.viewport=r.parent(),o.loader=t('
'),o.viewport.prepend(o.loader),r.css({width:"horizontal"==o.settings.mode?100*o.children.length+215+"%":"auto",position:"relative"}),o.usingCSS&&o.settings.easing?r.css("-"+o.cssPrefix+"-transition-timing-function",o.settings.easing):o.settings.easing||(o.settings.easing="swing"),f(),o.viewport.css({width:"100%",overflow:"hidden",position:"relative"}),o.viewport.parent().css({maxWidth:p()}),o.settings.pager||o.viewport.parent().css({margin:"0 auto 0px"}),o.children.css({"float":"horizontal"==o.settings.mode?"left":"none",listStyle:"none",position:"relative"}),o.children.css("width",u()),"horizontal"==o.settings.mode&&o.settings.slideMargin>0&&o.children.css("marginRight",o.settings.slideMargin),"vertical"==o.settings.mode&&o.settings.slideMargin>0&&o.children.css("marginBottom",o.settings.slideMargin),"fade"==o.settings.mode&&(o.children.css({position:"absolute",zIndex:0,display:"none"}),o.children.eq(o.settings.startSlide).css({zIndex:o.settings.slideZIndex,display:"block"})),o.controls.el=t('
'),o.settings.captions&&P(),o.active.last=o.settings.startSlide==x()-1,o.settings.video&&r.fitVids();var e=o.children.eq(o.settings.startSlide);"all"==o.settings.preloadImages&&(e=o.children),o.settings.ticker?o.settings.pager=!1:(o.settings.pager&&T(),o.settings.controls&&C(),o.settings.auto&&o.settings.autoControls&&E(),(o.settings.controls||o.settings.autoControls||o.settings.pager)&&o.viewport.after(o.controls.el)),g(e,h)},g=function(e,i){var s=e.find("img, iframe").length;if(0==s)return i(),void 0;var n=0;e.find("img, iframe").each(function(){t(this).one("load",function(){++n==s&&i()}).each(function(){this.complete&&t(this).load()})})},h=function(){if(o.settings.infiniteLoop&&"fade"!=o.settings.mode&&!o.settings.ticker){var e="vertical"==o.settings.mode?o.settings.minSlides:o.settings.maxSlides,i=o.children.slice(0,e).clone().addClass("bx-clone"),s=o.children.slice(-e).clone().addClass("bx-clone");r.append(i).prepend(s)}o.loader.remove(),S(),"vertical"==o.settings.mode&&(o.settings.adaptiveHeight=!0),o.viewport.height(v()),r.redrawSlider(),o.settings.onSliderLoad(o.active.index),o.initialized=!0,o.settings.responsive&&t(window).bind("resize",Z),o.settings.auto&&o.settings.autoStart&&H(),o.settings.ticker&&L(),o.settings.pager&&q(o.settings.startSlide),o.settings.controls&&W(),o.settings.touchEnabled&&!o.settings.ticker&&O()},v=function(){var e=0,s=t();if("vertical"==o.settings.mode||o.settings.adaptiveHeight)if(o.carousel){var n=1==o.settings.moveSlides?o.active.index:o.active.index*m();for(s=o.children.eq(n),i=1;i<=o.settings.maxSlides-1;i++)s=n+i>=o.children.length?s.add(o.children.eq(i-1)):s.add(o.children.eq(n+i))}else s=o.children.eq(o.active.index);else s=o.children;return"vertical"==o.settings.mode?(s.each(function(){e+=t(this).outerHeight()}),o.settings.slideMargin>0&&(e+=o.settings.slideMargin*(o.settings.minSlides-1))):e=Math.max.apply(Math,s.map(function(){return t(this).outerHeight(!1)}).get()),e},p=function(){var t="100%";return o.settings.slideWidth>0&&(t="horizontal"==o.settings.mode?o.settings.maxSlides*o.settings.slideWidth+(o.settings.maxSlides-1)*o.settings.slideMargin:o.settings.slideWidth),t},u=function(){var t=o.settings.slideWidth,e=o.viewport.width();return 0==o.settings.slideWidth||o.settings.slideWidth>e&&!o.carousel||"vertical"==o.settings.mode?t=e:o.settings.maxSlides>1&&"horizontal"==o.settings.mode&&(e>o.maxThreshold||e0)if(o.viewport.width()o.maxThreshold)t=o.settings.maxSlides;else{var e=o.children.first().width();t=Math.floor(o.viewport.width()/e)}else"vertical"==o.settings.mode&&(t=o.settings.minSlides);return t},x=function(){var t=0;if(o.settings.moveSlides>0)if(o.settings.infiniteLoop)t=o.children.length/m();else for(var e=0,i=0;e0&&o.settings.moveSlides<=f()?o.settings.moveSlides:f()},S=function(){if(o.children.length>o.settings.maxSlides&&o.active.last&&!o.settings.infiniteLoop){if("horizontal"==o.settings.mode){var t=o.children.last(),e=t.position();b(-(e.left-(o.viewport.width()-t.width())),"reset",0)}else if("vertical"==o.settings.mode){var i=o.children.length-o.settings.minSlides,e=o.children.eq(i).position();b(-e.top,"reset",0)}}else{var e=o.children.eq(o.active.index*m()).position();o.active.index==x()-1&&(o.active.last=!0),void 0!=e&&("horizontal"==o.settings.mode?b(-e.left,"reset",0):"vertical"==o.settings.mode&&b(-e.top,"reset",0))}},b=function(t,e,i,s){if(o.usingCSS){var n="vertical"==o.settings.mode?"translate3d(0, "+t+"px, 0)":"translate3d("+t+"px, 0, 0)";r.css("-"+o.cssPrefix+"-transition-duration",i/1e3+"s"),"slide"==e?(r.css(o.animProp,n),r.bind("transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd",function(){r.unbind("transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd"),D()})):"reset"==e?r.css(o.animProp,n):"ticker"==e&&(r.css("-"+o.cssPrefix+"-transition-timing-function","linear"),r.css(o.animProp,n),r.bind("transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd",function(){r.unbind("transitionend webkitTransitionEnd oTransitionEnd MSTransitionEnd"),b(s.resetValue,"reset",0),N()}))}else{var a={};a[o.animProp]=t,"slide"==e?r.animate(a,i,o.settings.easing,function(){D()}):"reset"==e?r.css(o.animProp,t):"ticker"==e&&r.animate(a,speed,"linear",function(){b(s.resetValue,"reset",0),N()})}},w=function(){for(var e="",i=x(),s=0;i>s;s++){var n="";o.settings.buildPager&&t.isFunction(o.settings.buildPager)?(n=o.settings.buildPager(s),o.pagerEl.addClass("bx-custom-pager")):(n=s+1,o.pagerEl.addClass("bx-default-pager")),e+='"}o.pagerEl.html(e)},T=function(){o.settings.pagerCustom?o.pagerEl=t(o.settings.pagerCustom):(o.pagerEl=t('
'),o.settings.pagerSelector?t(o.settings.pagerSelector).html(o.pagerEl):o.controls.el.addClass("bx-has-pager").append(o.pagerEl),w()),o.pagerEl.on("click","a",I)},C=function(){o.controls.next=t(''+o.settings.nextText+""),o.controls.prev=t(''+o.settings.prevText+""),o.controls.next.bind("click",y),o.controls.prev.bind("click",z),o.settings.nextSelector&&t(o.settings.nextSelector).append(o.controls.next),o.settings.prevSelector&&t(o.settings.prevSelector).append(o.controls.prev),o.settings.nextSelector||o.settings.prevSelector||(o.controls.directionEl=t('
'),o.controls.directionEl.append(o.controls.prev).append(o.controls.next),o.controls.el.addClass("bx-has-controls-direction").append(o.controls.directionEl))},E=function(){o.controls.start=t('"),o.controls.stop=t('"),o.controls.autoEl=t('
'),o.controls.autoEl.on("click",".bx-start",k),o.controls.autoEl.on("click",".bx-stop",M),o.settings.autoControlsCombine?o.controls.autoEl.append(o.controls.start):o.controls.autoEl.append(o.controls.start).append(o.controls.stop),o.settings.autoControlsSelector?t(o.settings.autoControlsSelector).html(o.controls.autoEl):o.controls.el.addClass("bx-has-controls-auto").append(o.controls.autoEl),A(o.settings.autoStart?"stop":"start")},P=function(){o.children.each(function(){var e=t(this).find("img:first").attr("title");void 0!=e&&(""+e).length&&t(this).append('
'+e+"
")})},y=function(t){o.settings.auto&&r.stopAuto(),r.goToNextSlide(),t.preventDefault()},z=function(t){o.settings.auto&&r.stopAuto(),r.goToPrevSlide(),t.preventDefault()},k=function(t){r.startAuto(),t.preventDefault()},M=function(t){r.stopAuto(),t.preventDefault()},I=function(e){o.settings.auto&&r.stopAuto();var i=t(e.currentTarget),s=parseInt(i.attr("data-slide-index"));s!=o.active.index&&r.goToSlide(s),e.preventDefault()},q=function(e){var i=o.children.length;return"short"==o.settings.pagerType?(o.settings.maxSlides>1&&(i=Math.ceil(o.children.length/o.settings.maxSlides)),o.pagerEl.html(e+1+o.settings.pagerShortSeparator+i),void 0):(o.pagerEl.find("a").removeClass("active"),o.pagerEl.each(function(i,s){t(s).find("a").eq(e).addClass("active")}),void 0)},D=function(){if(o.settings.infiniteLoop){var t="";0==o.active.index?t=o.children.eq(0).position():o.active.index==x()-1&&o.carousel?t=o.children.eq((x()-1)*m()).position():o.active.index==o.children.length-1&&(t=o.children.eq(o.children.length-1).position()),t&&("horizontal"==o.settings.mode?b(-t.left,"reset",0):"vertical"==o.settings.mode&&b(-t.top,"reset",0))}o.working=!1,o.settings.onSlideAfter(o.children.eq(o.active.index),o.oldIndex,o.active.index)},A=function(t){o.settings.autoControlsCombine?o.controls.autoEl.html(o.controls[t]):(o.controls.autoEl.find("a").removeClass("active"),o.controls.autoEl.find("a:not(.bx-"+t+")").addClass("active"))},W=function(){1==x()?(o.controls.prev.addClass("disabled"),o.controls.next.addClass("disabled")):!o.settings.infiniteLoop&&o.settings.hideControlOnEnd&&(0==o.active.index?(o.controls.prev.addClass("disabled"),o.controls.next.removeClass("disabled")):o.active.index==x()-1?(o.controls.next.addClass("disabled"),o.controls.prev.removeClass("disabled")):(o.controls.prev.removeClass("disabled"),o.controls.next.removeClass("disabled")))},H=function(){o.settings.autoDelay>0?setTimeout(r.startAuto,o.settings.autoDelay):r.startAuto(),o.settings.autoHover&&r.hover(function(){o.interval&&(r.stopAuto(!0),o.autoPaused=!0)},function(){o.autoPaused&&(r.startAuto(!0),o.autoPaused=null)})},L=function(){var e=0;if("next"==o.settings.autoDirection)r.append(o.children.clone().addClass("bx-clone"));else{r.prepend(o.children.clone().addClass("bx-clone"));var i=o.children.first().position();e="horizontal"==o.settings.mode?-i.left:-i.top}b(e,"reset",0),o.settings.pager=!1,o.settings.controls=!1,o.settings.autoControls=!1,o.settings.tickerHover&&!o.usingCSS&&o.viewport.hover(function(){r.stop()},function(){var e=0;o.children.each(function(){e+="horizontal"==o.settings.mode?t(this).outerWidth(!0):t(this).outerHeight(!0)});var i=o.settings.speed/e,s="horizontal"==o.settings.mode?"left":"top",n=i*(e-Math.abs(parseInt(r.css(s))));N(n)}),N()},N=function(t){speed=t?t:o.settings.speed;var e={left:0,top:0},i={left:0,top:0};"next"==o.settings.autoDirection?e=r.find(".bx-clone").first().position():i=o.children.first().position();var s="horizontal"==o.settings.mode?-e.left:-e.top,n="horizontal"==o.settings.mode?-i.left:-i.top,a={resetValue:n};b(s,"ticker",speed,a)},O=function(){o.touch={start:{x:0,y:0},end:{x:0,y:0}},o.viewport.bind("touchstart",X)},X=function(t){if(o.working)t.preventDefault();else{o.touch.originalPos=r.position();var e=t.originalEvent;o.touch.start.x=e.changedTouches[0].pageX,o.touch.start.y=e.changedTouches[0].pageY,o.viewport.bind("touchmove",Y),o.viewport.bind("touchend",V)}},Y=function(t){var e=t.originalEvent,i=Math.abs(e.changedTouches[0].pageX-o.touch.start.x),s=Math.abs(e.changedTouches[0].pageY-o.touch.start.y);if(3*i>s&&o.settings.preventDefaultSwipeX?t.preventDefault():3*s>i&&o.settings.preventDefaultSwipeY&&t.preventDefault(),"fade"!=o.settings.mode&&o.settings.oneToOneTouch){var n=0;if("horizontal"==o.settings.mode){var r=e.changedTouches[0].pageX-o.touch.start.x;n=o.touch.originalPos.left+r}else{var r=e.changedTouches[0].pageY-o.touch.start.y;n=o.touch.originalPos.top+r}b(n,"reset",0)}},V=function(t){o.viewport.unbind("touchmove",Y);var e=t.originalEvent,i=0;if(o.touch.end.x=e.changedTouches[0].pageX,o.touch.end.y=e.changedTouches[0].pageY,"fade"==o.settings.mode){var s=Math.abs(o.touch.start.x-o.touch.end.x);s>=o.settings.swipeThreshold&&(o.touch.start.x>o.touch.end.x?r.goToNextSlide():r.goToPrevSlide(),r.stopAuto())}else{var s=0;"horizontal"==o.settings.mode?(s=o.touch.end.x-o.touch.start.x,i=o.touch.originalPos.left):(s=o.touch.end.y-o.touch.start.y,i=o.touch.originalPos.top),!o.settings.infiniteLoop&&(0==o.active.index&&s>0||o.active.last&&0>s)?b(i,"reset",200):Math.abs(s)>=o.settings.swipeThreshold?(0>s?r.goToNextSlide():r.goToPrevSlide(),r.stopAuto()):b(i,"reset",200)}o.viewport.unbind("touchend",V)},Z=function(){var e=t(window).width(),i=t(window).height();(a!=e||l!=i)&&(a=e,l=i,r.redrawSlider(),o.settings.onSliderResize.call(r,o.active.index))};return r.goToSlide=function(e,i){if(!o.working&&o.active.index!=e)if(o.working=!0,o.oldIndex=o.active.index,o.active.index=0>e?x()-1:e>=x()?0:e,o.settings.onSlideBefore(o.children.eq(o.active.index),o.oldIndex,o.active.index),"next"==i?o.settings.onSlideNext(o.children.eq(o.active.index),o.oldIndex,o.active.index):"prev"==i&&o.settings.onSlidePrev(o.children.eq(o.active.index),o.oldIndex,o.active.index),o.active.last=o.active.index>=x()-1,o.settings.pager&&q(o.active.index),o.settings.controls&&W(),"fade"==o.settings.mode)o.settings.adaptiveHeight&&o.viewport.height()!=v()&&o.viewport.animate({height:v()},o.settings.adaptiveHeightSpeed),o.children.filter(":visible").fadeOut(o.settings.speed).css({zIndex:0}),o.children.eq(o.active.index).css("zIndex",o.settings.slideZIndex+1).fadeIn(o.settings.speed,function(){t(this).css("zIndex",o.settings.slideZIndex),D()});else{o.settings.adaptiveHeight&&o.viewport.height()!=v()&&o.viewport.animate({height:v()},o.settings.adaptiveHeightSpeed);var s=0,n={left:0,top:0};if(!o.settings.infiniteLoop&&o.carousel&&o.active.last)if("horizontal"==o.settings.mode){var a=o.children.eq(o.children.length-1);n=a.position(),s=o.viewport.width()-a.outerWidth()}else{var l=o.children.length-o.settings.minSlides;n=o.children.eq(l).position()}else if(o.carousel&&o.active.last&&"prev"==i){var d=1==o.settings.moveSlides?o.settings.maxSlides-m():(x()-1)*m()-(o.children.length-o.settings.maxSlides),a=r.children(".bx-clone").eq(d);n=a.position()}else if("next"==i&&0==o.active.index)n=r.find("> .bx-clone").eq(o.settings.maxSlides).position(),o.active.last=!1;else if(e>=0){var c=e*m();n=o.children.eq(c).position()}if("undefined"!=typeof n){var g="horizontal"==o.settings.mode?-(n.left-s):-n.top;b(g,"slide",o.settings.speed)}}},r.goToNextSlide=function(){if(o.settings.infiniteLoop||!o.active.last){var t=parseInt(o.active.index)+1;r.goToSlide(t,"next")}},r.goToPrevSlide=function(){if(o.settings.infiniteLoop||0!=o.active.index){var t=parseInt(o.active.index)-1;r.goToSlide(t,"prev")}},r.startAuto=function(t){o.interval||(o.interval=setInterval(function(){"next"==o.settings.autoDirection?r.goToNextSlide():r.goToPrevSlide()},o.settings.pause),o.settings.autoControls&&1!=t&&A("stop"))},r.stopAuto=function(t){o.interval&&(clearInterval(o.interval),o.interval=null,o.settings.autoControls&&1!=t&&A("start"))},r.getCurrentSlide=function(){return o.active.index},r.getCurrentSlideElement=function(){return o.children.eq(o.active.index)},r.getSlideCount=function(){return o.children.length},r.redrawSlider=function(){o.children.add(r.find(".bx-clone")).outerWidth(u()),o.viewport.css("height",v()),o.settings.ticker||S(),o.active.last&&(o.active.index=x()-1),o.active.index>=x()&&(o.active.last=!0),o.settings.pager&&!o.settings.pagerCustom&&(w(),q(o.active.index))},r.destroySlider=function(){o.initialized&&(o.initialized=!1,t(".bx-clone",this).remove(),o.children.each(function(){void 0!=t(this).data("origStyle")?t(this).attr("style",t(this).data("origStyle")):t(this).removeAttr("style")}),void 0!=t(this).data("origStyle")?this.attr("style",t(this).data("origStyle")):t(this).removeAttr("style"),t(this).unwrap().unwrap(),o.controls.el&&o.controls.el.remove(),o.controls.next&&o.controls.next.remove(),o.controls.prev&&o.controls.prev.remove(),o.pagerEl&&o.settings.controls&&o.pagerEl.remove(),t(".bx-caption",this).remove(),o.controls.autoEl&&o.controls.autoEl.remove(),clearInterval(o.interval),o.settings.responsive&&t(window).unbind("resize",Z))},r.reloadSlider=function(t){void 0!=t&&(n=t),r.destroySlider(),d()},d(),this}}(jQuery); //****************************************************************************/ // IE9 Console Fix //****************************************************************************/ if(!(window.console&&console.log)){console={log:function(){},debug:function(){},info:function(){},warn:function(){},error:function(){}}}; /** * stacktable.js * Author & copyright (c) 2012: John Polacek * CardTable by: Justin McNally (2015) * Dual MIT & GPL license * * Page: http://johnpolacek.github.com/stacktable.js * Repo: https://github.com/johnpolacek/stacktable.js/ * * jQuery plugin for stacking tables on small screens * */ ;(function($) { $.fn.cardtable = function(options) { var $tables = this, defaults = {id:'stacktable small-only',hideOriginal:true,headIndex:0}, settings = $.extend({}, defaults, options); // checking the "headIndex" option presence... or defaults it to 0 if(options && options.headIndex) headIndex = options.headIndex; else headIndex = 0; return $tables.each(function() { $table = $(this); if ($table.hasClass('stacktable')) { return; } var table_css = $(this).prop('class'); var $stacktable = $('
'); if (typeof settings.myClass !== 'undefined') $stacktable.addClass(settings.myClass); var markup = ''; $table.addClass('stacktable large-only'); $caption = $table.find("caption").clone(); $topRow = $table.find('tr').eq(0); // using rowIndex and cellIndex in order to reduce ambiguity $table.find('tbody tr').each(function(rowIndex,value) { // declaring headMarkup and bodyMarkup, to be used for separately head and body of single records headMarkup = ''; bodyMarkup = ''; tr_class = $(this).prop('class'); // for the first row, "headIndex" cell is the head of the table // for the other rows, put the "headIndex" cell as the head for that row // then iterate through the key/values $(this).find('td,th').each(function(cellIndex,value) { if ($(this).html() !== ''){ bodyMarkup += ''; if ($topRow.find('td,th').eq(cellIndex).html()){ bodyMarkup += ''+$table.find('thead th').eq(cellIndex).html()+''; } else { bodyMarkup += ''; } bodyMarkup += ''+$(this).html()+''; bodyMarkup += ''; } }); markup += '' + headMarkup + bodyMarkup + '
'; }); $table.find('tfoot tr td').each(function(rowIndex,value) { if ($.trim($(value).text()) !== '') { markup += '
' + $(value).html() + '
'; } }); $stacktable.prepend($caption); $stacktable.append($(markup)); $table.before($stacktable); if (!settings.hideOriginal) $table.show(); }); }; $.fn.stacktable = function(options) { var $tables = this, defaults = {id:'stacktable small-only',hideOriginal:true,headIndex:0}, settings = $.extend({}, defaults, options); // checking the "headIndex" option presence... or defaults it to 0 if(options && options.headIndex) headIndex = options.headIndex; else headIndex = 0; return $tables.each(function() { var table_css = $(this).prop('class'); var $stacktable = $('
'); if (typeof settings.myClass !== 'undefined') $stacktable.addClass(settings.myClass); var markup = ''; $table = $(this); $table.addClass('stacktable large-only'); $caption = $table.find("caption").clone(); $topRow = $table.find('tr').eq(0); // using rowIndex and cellIndex in order to reduce ambiguity $table.find('tr').each(function(rowIndex,value) { // declaring headMarkup and bodyMarkup, to be used for separately head and body of single records headMarkup = ''; bodyMarkup = ''; tr_class = $(this).prop('class'); // for the first row, "headIndex" cell is the head of the table if (rowIndex === 0) { // the main heading goes into the markup variable markup += ''+$(this).find('th,td').eq(headIndex).html()+''; } else { // for the other rows, put the "headIndex" cell as the head for that row // then iterate through the key/values $(this).find('td,th').each(function(cellIndex,value) { if (cellIndex === headIndex) { headMarkup = ''+$(this).html()+''; } else { if ($(this).html() !== ''){ bodyMarkup += ''; if ($topRow.find('td,th').eq(cellIndex).html()){ bodyMarkup += ''+$topRow.find('td,th').eq(cellIndex).html()+''; } else { bodyMarkup += ''; } bodyMarkup += ''+$(this).html()+''; bodyMarkup += ''; } } }); markup += headMarkup + bodyMarkup; } }); $stacktable.prepend($caption); $stacktable.append($(markup)); $table.before($stacktable); if (!settings.hideOriginal) $table.show(); }); }; $.fn.stackcolumns = function(options) { var $tables = this, defaults = {id:'stacktable small-only',hideOriginal:true}, settings = $.extend({}, defaults, options); return $tables.each(function() { $table = $(this); var num_cols = $table.find('tr').eq(0).find('td,th').length; //first table must not contain colspans, or add sum(colspan-1) here. if(num_cols<3) //stackcolumns has no effect on tables with less than 3 columns return; var $stackcolumns = $('
'); if (typeof settings.myClass !== 'undefined') $stackcolumns.addClass(settings.myClass); $table.addClass('stacktable large-only'); var tb = $(''); var col_i = 1; //col index starts at 0 -> start copy at second column. while (col_i < num_cols) { $table.find('tr').each(function(index,value) { var tem = $(''); // todo opt. copy styles of $this; todo check if parent is thead or tfoot to handle accordingly if(index === 0) tem.addClass("st-head-row st-head-row-main"); first = $(this).find('td,th').eq(0).clone().addClass("st-key"); var target = col_i; // if colspan apply, recompute target for second cell. if ($(this).find("*[colspan]").length) { var i =0; $(this).find('td,th').each(function(index,value) { var cs = $(this).attr("colspan"); if (cs) { cs = parseInt(cs, 10); target -= cs-1; if ((i+cs) > (col_i)) //out of current bounds target += i + cs - col_i -1; i += cs; } else i++; if (i > col_i) return false; //target is set; break. }); } second = $(this).find('td,th').eq(target).clone().addClass("st-val").removeAttr("colspan"); tem.append(first, second); tb.append(tem); }); ++col_i; } $stackcolumns.append($(tb)); $table.before($stackcolumns); if (!(settings.hideOriginal)) { $table.show(); } }); }; }(jQuery));