/** * Go Pricing - WordPress Responsive Pricing Tables * * Description: The New Generation Pricing Tables. If you like traditional Pricing Tables, but you would like get much more out of it, then this rodded product is a useful tool for you. * Version: 3.3.8 * Author: Granth * License: http://codecanyon.net/licenses/ * * (C) 2017 Granth (http://granthweb.com) */ var gwGS = gwGS || {}; ;(function ($, TimelineLite, TweenLite, undefined ) { "use strict"; $(function() { /** * Initialize */ $.GoPricing = { /* Init function */ Init : function () { this.$wrap = $('.gw-go'); this.fixWidth(); this.equalize = this.$wrap.data('equalize'); this.InitMediaElementPlayer(); this.InitGoogleMap(); this.isIE = document.documentMode != undefined && document.documentMode >5 ? document.documentMode : false; if (this.isIE) { this.$wrap.addClass('gw-go-ie'); if (this.isIE < 9) this.$wrap.addClass('gw-go-oldie'); }; if ($.GoPricing!=undefined && $.GoPricing.equalize) { this.EqualizeRows(); }; this.InitAnim(); this.eventType = this.detectEvent(); this.timeout = []; }, InitAnim: function() { this.$wrap.each(function( i, obj ) { $(obj).css('opacity', 1); if ( !TimelineLite || !TweenLite) return; var $cols = $(".gw-go-col-wrap[data-col-anim]", this); if ($cols.length) { var tl = new TimelineLite({ paused: true, onStart: function() { var tw = this.getChildren(), i = tw.length; while (i--) if (tw[i].vars.onUpdate) tw[i].vars.onUpdate(); } }); $cols.each(function(i, col) { var anim = $(col).data('col-anim') || {}; if (anim.trans) { anim.css.opacity /= 100, anim.css.scaleX /= 100, anim.css.scaleY /= 100; tl.add( TweenLite.from(col, anim.trans.duration/1000, {css: anim.css, ease: anim.trans.ease}), anim.trans.delay/1000 ); } if (anim.count) { var $price = $('[data-id=price]', col), counter = { value : (anim.count.from || 0) }, $amount = $price.find('[data-id=amount]'), price = $price.data('price') || 0, currency = $price.data('currency') || {}, decimals = (price || '').toString().split('.')[1] || '', decCnt = decimals.length; if ($price.data('trailing-zero')) decCnt = $price.data('decimal-no'); tl.add( TweenLite.to(counter, anim.count.duration/1000, { value: price, ease: anim.count.ease, onUpdate: function() { var c = counter.value $amount.html(function() { var parts = parseFloat(c).toFixed(decCnt).split('.'); parts[0] = parts[0].replace(/(\d)(?=(\d{3})+(?!\d))/g, "$1"+(currency['thousand-sep'] || ' ')); parts[1] = parts[1] ? ( ( currency['decimal-sep'] || '.' ) + parts[1] ) : ''; return parts[0] + parts[1]; }); }, }), anim.count.delay/1000 ); } }); var $this = $(this).data('tl', tl); $this.tablespy({offset: $this.data('scroll-offset')}); TweenLite.set(this, {perspective: '1000px'}); } }); }, /* Show Tooltip */ showTooltip : function ($elem, content, top) { if ($elem === undefined) return; var $rowTooltip = $elem.find('.gw-go-tooltip-content'), rowTooltipContent = $rowTooltip.length ? $rowTooltip.prop('outerHTML') : '', $colWrap = $elem.closest('.gw-go-col-wrap'), $col = $colWrap.find('.gw-go-col'), $tooltip = $col.find('.gw-go-tooltip'), colIndex = $colWrap.data('col-index'), rIndex = $elem.data('row-index'); if (!$tooltip.length ) $tooltip = $('
').appendTo($col); if ($tooltip.data('index') != rIndex) { $tooltip.removeClass('gw-go-tooltip-visible'); } else { clearTimeout($.GoPricing.timeout[colIndex]); } if (rowTooltipContent != '') { $tooltip.html(rowTooltipContent).data('index', rIndex) var corr = $col.position().top; setTimeout(function() { $tooltip.addClass('gw-go-tooltip-visible').css('top', $elem.find('.gw-go-body-cell').offset().top - $col.closest('.gw-go-col-wrap').offset().top - $tooltip.outerHeight() - 16 - corr) }, 10); } }, /* Hide Tooltip */ hideTooltip : function ($elem) { if ($elem === undefined) return; if ($elem.hasClass('gw-go-tooltip')) { $elem.removeClass('gw-go-tooltip-visible'); } else { var $colWrap = $elem.closest('.gw-go-col-wrap'), $col = $colWrap.find('.gw-go-col'), $tooltip = $col.find('.gw-go-tooltip'), colIndex = $colWrap.data('col-index'); $.GoPricing.timeout[colIndex] = setTimeout(function() { $tooltip.removeClass('gw-go-tooltip-visible'); }, 10); } }, /* Mediaelement Player init */ InitMediaElementPlayer : function () { if (jQuery().mediaelementplayer && $.GoPricing.$wrap.find('audio, video').length) { $.GoPricing.$wrap.find('audio, video').mediaelementplayer({ audioWidth: '100%', videoWidth: '100%' }); }; }, /* Google map init */ InitGoogleMap : function () { if (jQuery().goMap && $.GoPricing.$wrap.find('.gw-go-gmap').length) { $.GoPricing.$wrap.find('.gw-go-gmap').each(function(index) { var $this=$(this); $this.goMap($this.data('map')); }); }; }, loadImages : function ( $pricingTable ) { if ( !$pricingTable.data('images') || $pricingTable.data('imagesLoaded')) return; var images = $pricingTable.data('images'), ready = true; for (var x = 0; x < images.length; x++) { var image = images[x]; if (image.el.naturalWidth == 0) ready = false; } if (ready) { $pricingTable.data('imagesLoaded', true) this.EqualizeRows(); return; } setTimeout($.proxy(function() { this.loadImages($pricingTable); }, this), 100); }, /* Fix width in webkit browsers */ fixWidth : function() { if ( 'WebkitAppearance' in document.documentElement.style === false || window.StyleMedia ) return; for (var x = 0; x < $.GoPricing.$wrap.length; x++) { var $pricingTable = $.GoPricing.$wrap.eq(x), $cols = $pricingTable.find('.gw-go-col-wrap'); if ($pricingTable.is(':hidden') || $pricingTable.offset().top>parseInt($(document).scrollTop()+window.innerHeight+500) || $pricingTable.data('fix-width') === true || $cols.length < 2 ) continue; for (var i = 0; i < $cols.length; i++) { var $col = $cols.eq(i), fixedMaxWidth = parseInt($pricingTable.data('mw')), maxWidth = Math.floor(parseFloat(window.getComputedStyle($col[0]).width)); if ( !fixedMaxWidth || maxWidth < fixedMaxWidth ) { $cols.css('max-width', 'none'); $cols.css('max-width', Math.floor(parseFloat(window.getComputedStyle($col[0]).width))); } } $pricingTable.data('fix-width', true); } }, /* Equalize rows */ EqualizeRows : function () { for (var x = 0; x < $.GoPricing.$wrap.length; x++) { if ($.GoPricing.$wrap.eq(x).is(':hidden') || $.GoPricing.$wrap.eq(x).offset().top>parseInt($(document).scrollTop()+window.innerHeight+500) || $.GoPricing.$wrap.eq(x).data('eq-ready') === true ) continue; var $pricingTable = $.GoPricing.$wrap.eq(x), $colWrap = $pricingTable.find('.gw-go-col-wrap:visible'), colCnt = $colWrap.length, equalizeCnt = colCnt, views = $pricingTable.data('views') !== undefined ? $pricingTable.data('views') : {}; /* Load images */ if ( !$pricingTable.data('images') && !$pricingTable.data('imagesLoaded') ) { var images = []; if ($pricingTable.data('equalize').body != undefined) { $pricingTable.find('.gw-go-body li .gw-go-body-cell:visible img').each(function(index, el){ images.push({'ready' : false, 'el' : el }) }); } if ($pricingTable.data('equalize').footer != undefined) { $pricingTable.find('.gw-go-footer .gw-go-footer-row-inner:visible img').each(function(index, el){ images.push({'ready' : false, 'el' : el }) }); } if ($pricingTable.data('equalize').column != undefined) { $pricingTable.find('.gw-go-header img').each(function(index, el){ images.push({'ready' : false, 'el' : el }) }); } if ( images.length ) $pricingTable.data( 'images', images ); } if ( $pricingTable.data('images') && !$pricingTable.data('imagesLoaded') ) { this.loadImages( $pricingTable ); continue; } for (var key in views) { var mqSizes = [], mq = ''; if (views[key].min !== undefined && views[key].min !== '') mqSizes.push('(min-width:'+views[key].min+'px)'); if (views[key].max !== undefined && views[key].max !== '') mqSizes.push('(max-width:'+views[key].max+'px)'); mq = mqSizes.join(' and '); if (mq != '') if (window.matchMedia && window.matchMedia(mq).matches) { equalizeCnt = views[key].cols !== undefined && views[key].cols !== '' && views[key].cols <= colCnt ? views[key].cols : colCnt; } } if (equalizeCnt == 1) { $pricingTable.find('.gw-go-body li .gw-go-body-cell').css('height', 'auto'); $pricingTable.find('.gw-go-col-wrap').css('height', 'auto'); $pricingTable.find('.gw-go-footer').css('height', 'auto'); continue; } for (var z = 0; z