aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNavan Chauhan <navanchauhan@gmail.com>2018-01-21 17:46:04 +0530
committerGitHub <noreply@github.com>2018-01-21 17:46:04 +0530
commit9c208362c8b269ebfa73de2eec0e7ff49d44b1fb (patch)
tree8e3093850f54dc3789461915eddc1848ea4f82bc
parentd2e209dacd368dcc7914793cc7ea1cbc52bab545 (diff)
Update menu.js
-rw-r--r--js/menu.js155
1 files changed, 1 insertions, 154 deletions
diff --git a/js/menu.js b/js/menu.js
index 44da6b7..34c5a21 100644
--- a/js/menu.js
+++ b/js/menu.js
@@ -1,154 +1 @@
-(function($) {
-
- /*
- Responsive Flat Menu
- http://cssmenumaker.com/menu/responsive-flat-menu
- */
-
- $.fn.menumaker = function(options) {
-
- var cssmenu = $(this),
- settings = $.extend({
- title: "Menu",
- format: "dropdown",
- sticky: false
- }, options);
-
- return this.each(function() {
- cssmenu.prepend('<div id="menu-button">' + settings.title + '</div>');
- $(this).find("#menu-button").on('click', function() {
- $(this).toggleClass('menu-opened');
- var mainmenu = $(this).next('ul');
- if (mainmenu.hasClass('open')) {
- mainmenu.hide().removeClass('open');
- } else {
- mainmenu.show().addClass('open');
- if (settings.format === "dropdown") {
- mainmenu.find('ul').show();
- }
- }
- });
-
- cssmenu.find('li ul').parent().addClass('has-sub');
-
- multiTg = function() {
- cssmenu.find(".has-sub").prepend('<span class="submenu-button"></span>');
- cssmenu.find('.submenu-button').on('click', function() {
- $(this).toggleClass('submenu-opened');
- if ($(this).siblings('ul').hasClass('open')) {
- $(this).siblings('ul').removeClass('open').hide();
- } else {
- $(this).siblings('ul').addClass('open').show();
- }
- });
- };
-
- if (settings.format === 'multitoggle') multiTg();
- else cssmenu.addClass('dropdown');
-
- if (settings.sticky === true) cssmenu.css('position', 'fixed');
-
- resizeFix = function() {
- if ($(window).width() > 768) {
- cssmenu.find('ul').show();
- }
-
- if ($(window).width() <= 768) {
- cssmenu.find('ul').hide().removeClass('open');
- }
- };
- resizeFix();
- return $(window).on('resize', resizeFix);
-
- });
- };
-})(jQuery);
-
-/*
- By Osvaldas Valutis, www.osvaldas.info
- Available for use under the MIT License
-*/
-
-;
-(function($, window, document, undefined) {
- $.fn.doubleTapToGo = function(params) {
- if (!('ontouchstart' in window) &&
- !navigator.msMaxTouchPoints &&
- !navigator.userAgent.toLowerCase().match(/windows phone os 7/i)) return false;
-
- this.each(function() {
- var curItem = false;
-
- $(this).on('click', function(e) {
- var item = $(this);
- if (item[0] != curItem[0]) {
- e.preventDefault();
- curItem = item;
- }
- });
-
- $(document).on('click touchstart MSPointerDown', function(e) {
- var resetItem = true,
- parents = $(e.target).parents();
-
- for (var i = 0; i < parents.length; i++)
- if (parents[i] == curItem[0])
- resetItem = false;
-
- if (resetItem)
- curItem = false;
- });
- });
- return this;
- };
-})(jQuery, window, document);
-
-/**
- * doubleTapToGoDecorator
- * Adds the ability to remove the need for a second tap
- * when in the mobile view
- *
- * @param {function} f - doubleTapToGo
- */
-function doubleTapToGoDecorator(f) {
- return function() {
-
- this.each(function() {
- $(this).on('click', function(e) {
-
- // If mobile menu view
- if ($('#menu-button').css('display') == 'block') {
-
- // If this is not a submenu button
- if (!$(e.target).hasClass('submenu-button')) {
-
- // Remove the need for a second tap
- window.location.href = $(e.target).attr('href');
- }
- }
-
- });
- });
-
- return f.apply(this);
- }
-}
-
-// Add decorator to the doubleTapToGo plugin
-jQuery.fn.doubleTapToGo = doubleTapToGoDecorator(jQuery.fn.doubleTapToGo);
-
-/**
- * jQuery
- */
-(function($) {
- $(document).ready(function() {
-
- $("#cssmenu").menumaker({
- title: "Menu",
- format: "multitoggle"
- });
-
- $('#cssmenu li:has(ul)').doubleTapToGo();
-
- });
-})(jQuery);
+function doubleTapToGoDecorator(n){return function(){return this.each(function(){$(this).on("click",function(n){"block"==$("#menu-button").css("display")&&($(n.target).hasClass("submenu-button")||(window.location.href=$(n.target).attr("href")))})}),n.apply(this)}}!function(n){n.fn.menumaker=function(o){var t=n(this),e=n.extend({title:"Menu",format:"dropdown",sticky:!1},o);return this.each(function(){return t.prepend('<div id="menu-button">'+e.title+"</div>"),n(this).find("#menu-button").on("click",function(){n(this).toggleClass("menu-opened");var o=n(this).next("ul");o.hasClass("open")?o.hide().removeClass("open"):(o.show().addClass("open"),"dropdown"===e.format&&o.find("ul").show())}),t.find("li ul").parent().addClass("has-sub"),multiTg=function(){t.find(".has-sub").prepend('<span class="submenu-button"></span>'),t.find(".submenu-button").on("click",function(){n(this).toggleClass("submenu-opened"),n(this).siblings("ul").hasClass("open")?n(this).siblings("ul").removeClass("open").hide():n(this).siblings("ul").addClass("open").show()})},"multitoggle"===e.format?multiTg():t.addClass("dropdown"),!0===e.sticky&&t.css("position","fixed"),resizeFix=function(){n(window).width()>768&&t.find("ul").show(),n(window).width()<=768&&t.find("ul").hide().removeClass("open")},resizeFix(),n(window).on("resize",resizeFix)})}}(jQuery),function(n,o,t,e){n.fn.doubleTapToGo=function(e){return!!("ontouchstart"in o||navigator.msMaxTouchPoints||navigator.userAgent.toLowerCase().match(/windows phone os 7/i))&&(this.each(function(){var o=!1;n(this).on("click",function(t){var e=n(this);e[0]!=o[0]&&(t.preventDefault(),o=e)}),n(t).on("click touchstart MSPointerDown",function(t){for(var e=!0,i=n(t.target).parents(),s=0;s<i.length;s++)i[s]==o[0]&&(e=!1);e&&(o=!1)})}),this)}}(jQuery,window,document),jQuery.fn.doubleTapToGo=doubleTapToGoDecorator(jQuery.fn.doubleTapToGo),function(n){n(document).ready(function(){n("#cssmenu").menumaker({title:"Menu",format:"multitoggle"}),n("#cssmenu li:has(ul)").doubleTapToGo()})}(jQuery);