Current Path : /var/www/html/birthday/wp-content/plugins/strong-testimonials/public/js/ |
Current File : /var/www/html/birthday/wp-content/plugins/strong-testimonials/public/js/controller.min.js |
"use strict";var debugit=false;var strongController={grids:{},defaults:{method:"",universalTimer:500,observerTimer:500,containerId:"page",addedNodeId:"content",event:"",script:"",debug:false},config:{},setup:function(settings){settings.universalTimer=parseInt(settings.universalTimer);settings.observerTimer=parseInt(settings.observerTimer);settings.debug=!!settings.debug;debugit=settings.debug;this.config=jQuery.extend({},this.defaults,settings)},mutationObserver:window.MutationObserver||window.WebKitMutationObserver,eventListenerSupported:window.addEventListener,checkInit:function(){return jQuery(".strong-view[data-state='idle']").length},initSliders:function(){var sliders=jQuery(".strong-view.slider-container[data-state='idle']");if(debugit)console.log("sliders found:",sliders.length);if(sliders.length){sliders.each(function(){jQuery(this).strongSlider()})}},initPagers:function(){var pagers=jQuery(".strong-pager[data-state='idle']");if(debugit)console.log("pagers found:",pagers.length);if(pagers.length){pagers.each(function(){jQuery(this).strongPager()})}},initLayouts:function(){this.grids=jQuery(".strong-view[data-state='idle'] .strong-masonry");if(debugit)console.log("Masonry found:",this.grids.length);if(this.grids.length){this.grids.prepend('<div class="grid-sizer"></div><div class="gutter-sizer"></div>');this.grids.imagesLoaded(function(){strongController.grids.masonry({columnWidth:".grid-sizer",gutter:".gutter-sizer",itemSelector:".testimonial",percentPosition:true});strongController.grids.closest(".strong-view").attr("data-state","init")})}},initForm:function(){var forms=jQuery(".strong-form[data-state='idle']");if(debugit)console.log("forms found:",forms.length);if(forms.length){strongValidation.init()}},observer:function(obj,callback){if(this.mutationObserver){var obs=new this.mutationObserver(function(mutations){for(var i=0;i<mutations.length;i++){if(mutations[i].addedNodes.length){if(debugit)console.log("mutation observed",mutations);for(var j=0;j<mutations[i].addedNodes.length;j++){if(mutations[i].addedNodes[j].id===strongController.config.containerId){if(debugit)console.log("+",strongController.config.containerId);callback();return}}}}});obs.observe(obj,{childList:true,subtree:true})}else if(this.eventListenerSupported){obj.addEventListener("DOMNodeInserted",function(e){if(e.currentTarget.id===obj.id){if(debugit)console.log("DOMNodeInserted:",e.currentTarget.id);callback()}},false)}},intervalId:null,timeoutId:null,newInterval:function(){strongController.intervalId=setInterval(function tick(){if(debugit)console.log("tick > checkInit",strongController.checkInit());if(strongController.checkInit()){strongController.start()}},strongController.config.universalTimer)},newTimeout:function(){strongController.timeoutId=setTimeout(function tick(){if(debugit)console.log("tick > checkInit",strongController.checkInit());if(strongController.checkInit()){strongController.start()}},strongController.config.observerTimer)},init:function(){jQuery(document).focus();if(debugit)console.log("strongController init");var settings={};if(typeof window.strongControllerParms!=="undefined"){settings=window.strongControllerParms}else{if(debugit)console.log("settings not found")}this.setup(settings);if(debugit)console.log("config",this.config)},start:function(){if(debugit)console.log("start");strongController.initSliders();strongController.initPagers();strongController.initLayouts();strongController.initForm()},listen:function(){if(debugit)console.log("listen");switch(this.config.method){case"universal":this.newInterval();break;case"observer":this.observer(document.getElementById(this.config.containerId),this.newTimeout);break;case"event":document.addEventListener(this.config.event,this.start);break;case"script":switch(this.config.script){case"barba":if(typeof Barba==="object"&&Barba.hasOwnProperty("Dispatcher")){Barba.Dispatcher.on("transitionCompleted",this.start)}break;default:}break;default:}},listenForIframeReady:function(){if(debugit)console.log("listenForIframeReady");jQuery(window).on("load",function(){var $iframes=jQuery("iframe");if($iframes.length&&strongController.grids.length){$iframes.ready(function(){setTimeout(function(){strongController.grids.masonry()},500);setTimeout(function(){strongController.grids.masonry()},2e3)})}})}};jQuery(document).ready(function($){strongController.init();strongController.start();strongController.listen();strongController.listenForIframeReady()});