(function($) { $.fn.pluginName = function(options) { var defaults = { type: "hover", }; var settings = $.extend({}, defaults, options); if (this.length > 1) { this.each(function() { $(this).pluginName(options) }); return this; } // public methods this.initialize = function() { $('.xldtab ul.tabs').addClass('active').find('> li:eq(0)').addClass('current'); if (settings.type==='hover'){ $('.xldtab ul.tabs li a').hover(function (g) { var tab = $(this).closest('.xldtab'), index = $(this).closest('li').index(); tab.find('ul.tabs > li').removeClass('current'); $(this).closest('li').addClass('current'); tab.find('.tab_content').find('div.tabs_item').not('div.tabs_item:eq(' + index + ')').slideUp(); tab.find('.tab_content').find('div.tabs_item:eq(' + index + ')').slideDown(); g.preventDefault(); } ); } else { $('.xldtab ul.tabs li a').click(function (g) { var tab = $(this).closest('.xldtab'), index = $(this).closest('li').index(); tab.find('ul.tabs > li').removeClass('current'); $(this).closest('li').addClass('current'); tab.find('.tab_content').find('div.tabs_item').not('div.tabs_item:eq(' + index + ')').slideUp(); tab.find('.tab_content').find('div.tabs_item:eq(' + index + ')').slideDown(); g.preventDefault(); } ); } return this; }; return this.initialize(); } })(jQuery); /** * debounce * @param {integer} milliseconds This param indicates the number of milliseconds * to wait after the last call before calling the original function. * @param {object} What "this" refers to in the returned function. * @return {function} This returns a function that when called will wait the * indicated number of milliseconds after the last call before * calling the original function. */ Function.prototype.debounce = function (milliseconds, context) { var baseFunction = this, timer = null, wait = milliseconds; return function () { var self = context || this, args = arguments; function complete() { baseFunction.apply(self, args); timer = null; } if (timer) { clearTimeout(timer); } timer = setTimeout(complete, wait); }; }; /** * throttle * @param {integer} milliseconds This param indicates the number of milliseconds * to wait between calls before calling the original function. * @param {object} What "this" refers to in the returned function. * @return {function} This returns a function that when called will wait the * indicated number of milliseconds between calls before * calling the original function. */ Function.prototype.throttle = function (milliseconds, context) { var baseFunction = this, lastEventTimestamp = null, limit = milliseconds; return function () { var self = context || this, args = arguments, now = Date.now(); if (!lastEventTimestamp || now - lastEventTimestamp >= limit) { lastEventTimestamp = now; baseFunction.apply(self, args); } }; }; function searchFunction() { var input, filter, ul, li, a, i, txtValue; input = document.getElementById('myInput'); filter = input.value.toUpperCase(); ul = document.getElementById("myUL"); li = ul.getElementsByTagName('li'); // Loop through all list items, and hide those who don't match the search query for (i = 0; i < li.length; i++) { a = li[i].getElementsByTagName("a")[0]; txtValue = a.textContent || a.innerText; if (txtValue.toUpperCase().indexOf(filter) > -1) { li[i].style.display = ""; } else { li[i].style.display = "none"; } } } filterSelection("all") function filterSelection(c) { var x, i; x = document.getElementsByClassName("filterDiv"); if (c == "all") c = ""; // Add the "show" class (display:block) to the filtered elements, and remove the "show" class from the elements that are not selected for (i = 0; i < x.length; i++) { faqRemoveClass(x[i], "show"); if (x[i].className.indexOf(c) > -1) faqAddClass(x[i], "show"); } } // Show filtered elements function faqAddClass(element, name) { var i, arr1, arr2; arr1 = element.className.split(" "); arr2 = name.split(" "); for (i = 0; i < arr2.length; i++) { if (arr1.indexOf(arr2[i]) == -1) { element.className += " " + arr2[i]; } } } // Hide elements that are not selected function faqRemoveClass(element, name) { var i, arr1, arr2; arr1 = element.className.split(" "); arr2 = name.split(" "); for (i = 0; i < arr2.length; i++) { while (arr1.indexOf(arr2[i]) > -1) { arr1.splice(arr1.indexOf(arr2[i]), 1); } } element.className = arr1.join(" "); } function XlisEmpty(value) { return typeof value == 'string' && !value.trim() || typeof value == 'undefined' || value === null; } // Add active class to the current control button (highlight it) var btnContainer = document.getElementById("myBtnContainer"); if (!XlisEmpty(btnContainer)){ var btns = btnContainer.getElementsByClassName("btn"); for (var i = 0; i < btns.length; i++) { btns[i].addEventListener("click", function() { var current = document.getElementsByClassName("active"); current[0].className = current[0].className.replace(" active", ""); this.className += " active"; }); } }