/**
* 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.13
* author: granth
* license: http://codecanyon.net/licenses/
*
* (c) 2018 granth (http://granthweb.com)
*/
var gwgs = gwgs || {};
;(function ($, timelinelite, tweenlite, undefined ) {
"use strict";
/**
* 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'),
loadedcount = $pricingtable.data('imagesloadedcnt') ? parseint($pricingtable.data('imagesloadedcnt')) : 0;
for (var x = 0; x < images.length; x++) {
var image = images[x];
if ($(image.el).data('loading')) continue;
$(image.el).data('loading', true);
var img = new image();
img.onerror = function(){
$pricingtable.data('imagesloadedcnt', ++loadedcount);
};
img.onload = function(e){
$pricingtable.data('imagesloadedcnt', ++loadedcount);
};
img.src = image.el.src;
}
if (loadedcount == images.length) {
$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= (z*equalizecnt) && i <= (z*equalizecnt)+equalizecnt-1) {
var $currentcol = $colwrap.eq(i),
$row = $currentcol.find('.gw-go-body li .gw-go-body-cell:visible');
for (var rindex = 0; rindex < $row.length; rindex++) {
var $currentrow = $row.eq(rindex);
$currentrow.css('height', 'auto');
if (typeof rowheights[rindex] !== 'undefined' ) {
if ($currentrow.height() > rowheights[rindex] ) {
rowheights[rindex] = $currentrow.height();
}
} else {
rowheights[rindex] = $currentrow.height();
}
}
}
}
for (var i = 0; i < colcnt; i++) {
var $currentcol = $colwrap.eq(i),
$row = $currentcol.find('.gw-go-body li .gw-go-body-cell:visible');
if (i >= (z*equalizecnt) && i <= (z*equalizecnt)+equalizecnt-1) {
for (var rindex = 0; rindex < $row.length; rindex++) {
var $currentrow = $row.eq(rindex);
$currentrow.css('height', rowheights[rindex]);
}
}
}
}
/* footer */
if ($pricingtable.data('equalize').footer != undefined) {
for (var i = 0; i < colcnt; i++) {
if (i >= (z*equalizecnt) && i <= (z*equalizecnt)+equalizecnt-1) {
var $currentcol = $colwrap.eq(i),
$row = $currentcol.find('.gw-go-footer .gw-go-footer-row-inner:visible');
for (var rindex = 0; rindex < $row.length; rindex++) {
var $currentrow = $row.eq(rindex);
$currentrow.css('height', 'auto');
if (typeof footerheights[rindex] !== 'undefined' ) {
if ($currentrow.height() > footerheights[rindex] ) {
footerheights[rindex] = $currentrow.height();
}
} else {
footerheights[rindex] = $currentrow.height();
}
}
}
}
for (var i = 0; i < colcnt; i++) {
var $currentcol = $colwrap.eq(i),
$row = $currentcol.find('.gw-go-footer .gw-go-footer-row-inner:visible');
if (i >= (z*equalizecnt) && i <= (z*equalizecnt)+equalizecnt-1) {
for (var rindex = 0; rindex < $row.length; rindex++) {
var $currentrow = $row.eq(rindex);
$currentrow.css('height', footerheights[rindex]);
}
}
}
}
/* column */
if ($pricingtable.data('equalize').column != undefined) {
for (var i = 0; i < colcnt; i++) {
var $currentcol = $colwrap.eq(i);
if (i >= (z*equalizecnt) && i <= (z*equalizecnt)+equalizecnt-1) {
$currentcol.css('height', 'auto');
if (typeof colheights[z] !== 'undefined' ) {
if ($currentcol.outerheight(true) > colheights[z] ) {
colheights[z] = $currentcol.outerheight(false);
}
} else {
colheights[z] = $currentcol.outerheight(false);
}
}
}
for (var i = 0; i < colcnt; i++) {
var $currentcol = $colwrap.eq(i);
if (i >= (z*equalizecnt) && i <= (z*equalizecnt)+equalizecnt-1) {
$currentcol.css('height', colheights[z]);
}
}
}
}
}
},
/* detect event type */
detectevent : function() {
var eventtype = 'mouseenter mouseleave';
if ('ontouchstart' in window) {
eventtype = 'touchstart';
} else if (window.navigator.pointerenabled && navigator.msmaxtouchpoints) {
eventtype = "pointerdown";
} else if (window.navigator.mspointerenabled && navigator.msmaxtouchpoints) {
eventtype = "mspointerdown";
}
return eventtype;
}
};
$(function() {
/* init */
$.gopricing.init();
$(window).on('scroll', function() {
$.gopricing.fixwidth();
$.gopricing.equalizerows();
});
/* submit button event if form found */
$.gopricing.$wrap.delegate('span.gw-go-btn', 'click', function(){
var $this=$(this);
if ($this.find('form').length) { $this.find('form').submit(); };
});
/* show & hide tooltip - event on tooltip */
$.gopricing.$wrap.on( 'mouseenter mouseleave', '.gw-go-tooltip', function(e) {
var $this=$(this),
$colwrap = $this.closest('.gw-go-col-wrap'),
colindex = $colwrap.data('col-index');
if (e.type == 'mouseenter') {
cleartimeout($.gopricing.timeout[colindex]);
} else {
$.gopricing.timeout[colindex] = settimeout(function() { $.gopricing.hidetooltip($this); }, 10);
}
});
/* show & hide tooltip - event on row */
$.gopricing.$wrap.on( 'mouseenter mouseleave', 'ul.gw-go-body > li', function(e) {
var $this=$(this);
if (e.type == 'mouseenter') {
$.gopricing.showtooltip($this);
} else {
$.gopricing.hidetooltip($this);
}
});
/* column hover / touch - supports mouse, touch and pointers */
// pointer enter event
function enterevent( $elem ) {
$elem.addclass('gw-go-curr');
$elem.siblings().data('leave-event', null).data('enter-event', null);
$elem.data('leave-event', null);
if ($elem.hasclass('gw-go-disable-hover')) {
$elem.siblings(':not(.gw-go-disable-hover)').removeclass('gw-go-hover');
} else {
$elem.addclass('gw-go-hover').siblings(':not(.gw-go-disable-hover)').removeclass('gw-go-hover');
$elem.closest('.gw-go').addclass('gw-go-hover');
}
};
// pointer leave event
function leaveevent( $elem ) {
$elem.siblings().data('leave-event', null).data('enter-event', null);
$elem.data('enter-event', null);
$elem.removeclass('gw-go-curr');
if ($elem.hasclass('gw-go-disable-hover')) {
$elem.closest('.gw-go').find('[data-current="1"]:not(.gw-go-disable-hover)').addclass('gw-go-hover');
} else {
$elem.removeclass('gw-go-hover');
$elem.closest('.gw-go').find('[data-current="1"]:not(.gw-go-disable-hover)').addclass('gw-go-hover');
$elem.closest('.gw-go').removeclass('gw-go-hover');
}
};
// enter event handling
$(document).on('pointerenter mouseenter pointerdown touchstart', '.gw-go-col-wrap', function(e) {
e.stoppropagation();
var $this = $(this);
$this.closest('.gw-go').find('.gw-go-col-wrap').removeclass('gw-go-curr');
if ($this.hasclass('gw-go-disable-hover')) {
$this.addclass('gw-go-curr');
return;
}
$this.data('leave-event', null);
if ($this.data('enter-event')) return;
var event = {
pointer : e.originalevent.pointertype == 'touch' || e.type == 'touchstart' ? 'touch' : 'mouse',
pagex : e.originalevent.changedtouches ? e.originalevent.changedtouches[0].pagex : e.originalevent.pagex,
pagey : e.originalevent.changedtouches ? e.originalevent.changedtouches[0].pagey : e.originalevent.pagey,
};
if (event.pointer == 'mouse') {
enterevent($this);
};
$this.data('enter-event', event);
});
// leave event handling
$(document).on('pointerleave mouseleave pointerup touchend', '.gw-go-col-wrap', function(e) {
e.stoppropagation();
var $this = $(this);
if ($this.hasclass('gw-go-disable-hover')) return;
if (!$this.data('enter-event') || $this.data('leave-event')) return;
var event = {
pointer : e.originalevent.pointertype == 'touch' || e.type == 'touchend' ? 'touch' : 'mouse',
pagex : e.originalevent.changedtouches ? e.originalevent.changedtouches[0].pagex : e.originalevent.pagex,
pagey : e.originalevent.changedtouches ? e.originalevent.changedtouches[0].pagey : e.originalevent.pagey,
};
if (event.pointer == 'mouse') {
$this.data('leave-event', event);
leaveevent($this);
} else {
if (!$this.data('leave-event')) {
if (math.abs($this.data('enter-event').pagex-event.pagex) > 20 || math.abs($this.data('enter-event').pagey-event.pagey) > 20) {
$this.data('enter-event', null);
return;
}
enterevent($this);
$this.data('leave-event', event);
$(document).on('touchstart.goprevent pointermove.goprevent mousemove.goprevent', function(e) {
if ( $(e.target).closest('.go-pricing').length ) return;
leaveevent($this);
$this.data('leave-event', null);
$this.data('enter-event', null);
$(document).off('.goprevent');
});
}
}
});
/**
* google map
*/
if (typeof jquery.gomap !== 'undefined' && $.gopricing.$wrap.find('.gw-go-gmap').length) {
var gopricing_mapresize=false;
$(window).on('resize', function(e) {
if (gopricing_mapresize) { cleartimeout(gopricing_mapresize); }
gopricing_mapresize = settimeout(function() {
$.gopricing.$wrap.find('.gw-go-gmap').each(function(index, element) {
//$(this).gomap();
//console.log($.gomap.getmarkers('markers')[0].position);
});
}, 400);
});
};
/* equalize heights on resize */
$(window).on('resize load', function(e) {
for (var x = 0; x < $.gopricing.$wrap.length; x++) {
$.gopricing.$wrap.eq(x).data('eq-ready', false);
$.gopricing.$wrap.eq(x).data('fix-width', false);
}
$.gopricing.fixwidth();
$.gopricing.equalizerows();
});
/* handle animations */
$(window).on("scrollenter scrollleave", function(e, spy) {
var $target = $(e.target);
if ($target.data('anim') == 'off' || typeof spy === 'undefined') return;
var repeat = $target.data("anim-repeat") || infinity;
if (e.type == "scrollenter") {
if (spy.enters <= repeat) $target.data("tl").play();
} else {
if (spy.enters < repeat) $target.data("tl").stop().seek(0);
}
});
});
})(jquery, gwgs.timelinelite, gwgs.tweenlite );
;(function($, window, undefined) {
var $elems = $();
var $cont = $(window)
.on("resize.tablespy", onresize)
.on("load.tablespy", onresize)
.on("scroll.tablespy load.tablespy", onscroll);
if ( window.frameelement ) {
window.parent.onload = function() { onscroll(); }
}
function onscroll() {
if (!$elems.length) return;
var height = $cont.height();
var y = $cont.scrolltop();
$elems.each(function() {
var $elem = $(this);
var o = $elem.data('tablespy');
if (typeof o === "undefined") return;
var offset = o.rowheight * o.offset / 100;
if (math.floor((o.rowheight+height)/2) < offset) offset = math.floor((o.rowheight+height)/2)-20;
if (height + y-offset >= o.min && y+offset <= o.max){
if (!o.inside) {
o.inside = true;
o.enters++;
$elem.trigger("scrollenter", {scrolltop: y, enters: o.enters, leaves: o.leaves});
}
$elem.trigger("scrolltick", {scrolltop: y, enters: o.enters, leaves: o.leaves});
}
if (o.inside && !(height + y >= o.min && y <= o.max)) {
o.inside = false;
o.leaves++;
$elem.trigger("scrollleave", {scrolltop: y, enters: o.enters, leaves: o.leaves});
}
});
}
function onresize() {
$elems.each(function() {
var $elem = $(this);
var o = $elem.data("tablespy");
if (typeof o === "undefined") return;
o.min = $elem.offset().top;
o.max = $elem.outerheight() + o.min;
o.rowheight = $elem.children(":visible:first").outerheight();
});
}
$.fn.tablespy = function(options) {
var defaults = {
offset: 0,
enters: 0,
leaves: 0,
inside: false
};
return this.each(function() {
var $elem = $(this);
var top = $elem.offset().top;
$elem.data("tablespy", $.extend({
min: top,
max: top + $elem.outerheight(),
rowheight: $elem.children(":visible:first").outerheight()
}, defaults, options));
$elems.push(this);
});
};
/* disable animation */
$.gopricing.disableanim = function() {
this.$wrap.each(function (index, element) {
$(element).addclass('test');
$(element).data('anim', 'off');
$(element).css('opacity', 1);
if ( typeof $(element).data("tl") === 'undefined' ) {
return;
}
if ( $(element).data("tl").progress() == 1 ) return;
$(element).data("tl").progress(1);
});
};
})(jquery, window);