/* * ---------------------------------------------------------------- * Renown Core JavaScript * ---------------------------------------------------------------- */ (function($) { "use strict"; var VcChart = function(element, options) { this.el = element; this.$el = $(this.el); this.options = $.extend({ color: 'wpb_button', units: '', label_selector: '.vntd-pie-chart-value', back_selector: '.vntd-pie-chart-back', responsive: true }, options); this.init(); }; VcChart.prototype = { constructor: VcChart, _progress_v: 0, animated: false, colors: { 'blue': '#79C5F8', 'turquoise': '#50DACC', 'green': '#A2DF80', 'orange': '#FFAE35', 'dark': '#555', 'grey': '#BBB', 'red': '#FF5E5E' }, init: function() { this.setupColor(); this.value = this.$el.data('pie-value')/100; this.label_value = this.$el.data('pie-label-value') || this.$el.data('pie-value'); this.$wrapper = $('.vntd-pie-wrapper', this.$el); this.$label = $(this.options.label_selector, this.$el); this.$back = $(this.options.back_selector, this.$el); this.$canvas = this.$el.find('canvas'); this.draw(); this.setWayPoint(); if(this.options.responsive === true) this.setResponsive(); }, setupColor: function() { if(typeof this.colors[this.options.color] !== 'undefined') { this.color = this.colors[this.options.color]; } else if(typeof this.options.color === 'string' && this.options.color.match(/^rgb(a?)\([^\)]\)/)) { this.color = this.options.color; } else { this.color = '#cccccc'; } }, setResponsive: function() { var that = this; $(window).resize(function(){ if(that.animated === true) that.circle.stop(); that.draw(true); }); }, draw: function(redraw) { var w = this.$el.width()/100*80, border_w = 4, radius = w/2 - border_w - 1; this.$wrapper.css({"width" : w + "px"}); this.$label.css({"width" : w, "height" : w, "line-height" : w+"px"}); this.$back.css({"width" : w, "height" : w}); this.$canvas.attr({"width" : w + "px", "height" : w + "px"}); this.circle = new ProgressCircle({ canvas: this.$canvas.get(0), minRadius: radius, arcWidth: border_w }); if(redraw === true && this.animated === true) { this._progress_v = this.value; this.circle.addEntry({ fillColor: this.color, progressListener: $.proxy(this.setProgress, this) }).start(); } }, setProgress: function() { if (this._progress_v >= this.value) { this.circle.stop(); this.$label.text(this.label_value + this.options.units); return this._progress_v; } this._progress_v += 0.005; var label_value = this._progress_v/this.value*this.label_value; var val; if(this.label_value === parseInt(this.label_value)) { val = Math.round(label_value) + this.options.units } else { val = this.label_value; } this.$label.text(val); return this._progress_v; }, animate: function() { if(this.animated !== true) { this.animated = true; this.circle.addEntry({ fillColor: this.color, progressListener: $.proxy(this.setProgress, this) }).start(5); } }, setWayPoint: function() { if (typeof $.fn.waypoint !== 'undefined') { this.$el.waypoint($.proxy(this.animate, this), { offset: '85%' }); } else { this.animate(); } } }; /** * jQuery plugin * @param option - object with settings * @return {*} */ $.fn.vcChat = function(option) { return this.each(function () { var $this = $(this), data = $this.data('vc_chart'), options = typeof option === 'object' ? option : { color: $this.data('pie-color'), units: $this.data('pie-units') }; if (!data) $this.data('vc_chart', (data = new VcChart(this, options))); if (typeof option == 'string') data[option](); }); }; if ( typeof window['vndtPieChart'] !== 'function' ) { window.vndtPieChart = function() { $('.vntd-pie-chart').vcChat(); } } $(window).load(function() { // Launch scripts on page load vndtPieChart(); /* * ---------------------------------------------------------------- * Toggles * ---------------------------------------------------------------- */ function vntdToggles() { jQuery(".vntd-toggle-title").click(function(e) { if ( jQuery(this).hasClass('vntd-toggle-title-active') ) { jQuery(this).removeClass('vntd-toggle-title-active').next().slideUp(500); } else { jQuery(this).addClass('vntd-toggle-title-active').next().slideDown(500); } }); jQuery('.vntd-toggle').each(function(index) { if ( jQuery(this).next().is('.vntd-toggle') == false ) { jQuery(this).addClass("vntd-toggle-last"); } }); } vntdToggles(); /* * ---------------------------------------------------------------- * Accordions * ---------------------------------------------------------------- */ function vntdAccordions() { var accordionContent = $('.vntd-accordions .vntd-accordion-content'); var accordionTitle = $('.vntd-accordions .vntd-accordion-title'); var activeClass = 'vntd-accordion-title-active'; $('.vntd-accordions .vntd-accordion:nth-of-type(1) h4').addClass(activeClass); $(accordionTitle).click(function() { $(this).closest('.vntd-accordions').find(accordionContent).slideUp(); $(this).closest('.vntd-accordions').find(accordionTitle).removeClass(activeClass); $(this).addClass(activeClass); $(this).next().slideDown(); return false; }); } vntdAccordions(); /* * ---------------------------------------------------------------- * Tabs * ---------------------------------------------------------------- */ function vntdTabs() { var activeClass = "vntd-tab-active"; $('.vntd-tabs-nav li:first-child').addClass(activeClass); $('.vntd-tabs-content > div:nth-of-type(1)').show(); $('.vntd-tabs-nav li').click(function(){ $(this).addClass(activeClass).siblings().removeClass(activeClass); $(this).closest('div').find('.vntd-tabs-content > div:eq(' + jQuery(this).index() + ')').fadeIn().siblings().hide(); }); } vntdTabs(); /* * ---------------------------------------------------------------- * Progress Bars * ---------------------------------------------------------------- */ function vntdProgressBar() { $('.vntd-pbar').each(function(indexInArray){ var thisBar = $(this); var barValue = thisBar.data("progress"); setTimeout( function () { thisBar.appear(function() { thisBar.find('.vntd-pbar-cover').animate({ width: barValue+"%"}, 500).closest('.vntd-pbar').find('.vntd-pbar-value').fadeIn(); }); }, indexInArray * 200); }); } vntdProgressBar(); /* * ---------------------------------------------------------------- * Animated Images * ---------------------------------------------------------------- */ function vntdAnimatedImg() { $('.vntd-image-animated').appear(function() { $(this).delay(100).addClass('vntd_start_animation'); }); } vntdAnimatedImg(); /* * ---------------------------------------------------------------- * Carousels * ---------------------------------------------------------------- */ var carousel = $('.vntd-carousel'); carousel.on('dragstart', function() { return false; // Fix for browser default drag event }); function posts_carousel() { carousel.each(function() { // Defaults var current = $(this), effect = 'slide', easing = 'easeInOutExpo', duration = 900, cols = 3, auto = false; // Effect & Easing effect = current.data('fx'); if(effect == "crossfade") { easing = 'linear'; duration = 450; } // Autostart if(current.data('autostart') == "yes") auto = true; // Columns cols = current.data('cols'); $(this).find('ul').trigger("destroy"); var item_width = $(this).find('li').width(); if(item_width < 190) { //var round = carousel.width()/cols; //round = Math.floor(round/item_width); cols = cols-1; } if(jQuery(window).width() <= 767) { cols = 1; } var settings = { responsive: true, prev: current.closest('.vntd-carousel').find('.carousel-nav-left'), next: current.closest('.vntd-carousel').find('.carousel-nav-right'), //height: "auto", scroll: { //items: cols, items: 1, pauseOnHover: true, easing: easing, duration: duration, fx: effect, }, auto: { play: auto }, swipe: { //onMouse: true, onTouch: true, options: { excludedElements:".noSwipe" }, onBefore : function(){ //hover effect fix current.find('a').trigger('mouseleave'); current.find('a').trigger('mouseup'); } }, onCreate: function () { $('.carousel-overflow').css({"opacity": 1, "max-height": 900}); }, items: { visible: { min: 1, max: cols }, height: "variable", width: item_width+30 }, //width: "100%" }; $(this).find('ul').carouFredSel(settings); }); }; if(carousel.length!==0) { posts_carousel(); $(window).resize(function() { waitForFinalEvent(function(){ if(carousel){ posts_carousel(); } },100,"resize"); }); } var waitForFinalEvent = (function () { var timers = {}; return function (callback, ms, uniqueId) { if (!uniqueId) { uniqueId = "Don't call this twice without a uniqueId"; } if (timers[uniqueId]) { clearTimeout (timers[uniqueId]); } timers[uniqueId] = setTimeout(callback, ms); }; })(); /* * ---------------------------------------------------------------- * Portfolio Equal Height * ---------------------------------------------------------------- */ function vntd_equal_height() { var items = jQuery('.portfolio-container .vntd-grid li'); var max = 100; var change = false items.each(function() { jQuery(this).css('height',''); }); items.each(function() { var el = jQuery(this); if(el.height() > max) { max = el.height(); change = true; } }); if(change == true) { items.each(function() { jQuery(this).css('height',max+'px'); }); } } if(jQuery('.portfolio-container.portfolio-style-alt').length > 0) { jQuery(window).resize(function () { vntd_equal_height(); }); } /* * ---------------------------------------------------------------- * Isotope Config * ---------------------------------------------------------------- */ var $container = $('.vntd-grid'); // Initialize Isotope // if($container.length) { if(jQuery('.portfolio-container.portfolio-style-alt').length > 0) { vntd_equal_height(); } $container.isotope({ itemSelector: '.sortable-item', resizable: false, }); $container.animate({ 'opacity': 1 }, 400); $('.grid-item').each(function (i) { $(this).delay(i * 150).animate({ 'opacity': 1 }, 350); }); // reLayout on window resize // $('.blog-grid-holder .flexslider').flexslider({ animation: "slide", start: function () { $container.isotope('reLayout'); } }); $(window).smartresize(function () { //$($container).isotope('reLayout'); //var $cols = $container.data("cols"); var $element_width = $container.find('.post-grid').width(); var $columns = Math.round($container.width() / $element_width); $container.isotope({ itemSelector: '.sortable-item', resizable: false, // masonry: { // columnWidth: $element_width // }, }); }); // Filtering Menu // var $optionSets = $container.closest('.portfolio-container').find('.portfolio-filters .option-set'), $optionLinks = $optionSets.find('a'); $optionLinks.click(function () { var $this = $(this); //don't proceed if already selected if ($this.hasClass('selected')) { return false; } var $optionSet = $this.parents('.option-set'); $optionSet.find('.selected').removeClass('selected'); $this.addClass('selected'); //make option object dynamically, i.e. { filter: '.my-filter-class' } var options = {}, key = $optionSet.attr('data-option-key'), value = $this.attr('data-option-value'); //parse 'false' as false boolean value = value === 'false' ? false : value; options[key] = value; if (key === 'layoutMode' && typeof changeLayoutMode === 'function') { //changes in layout modes need extra logic changeLayoutMode($this, options); } else { //otherwise, apply new options $container.isotope(options); } return false; }); } }); // End $(window).load })(jQuery);