Изменение размера браузера добавить ширину события min-max с Js / Javascript - PullRequest
1 голос
/ 26 марта 2019

/*Add Click show To Menu*/
    (function ($) {
    	$.fn.openActive = function (activeSel) {
    		activeSel = activeSel || ".active";
    		var c = this.attr("class");
    		this.find(activeSel).each(function () {
    			var el = $(this).parent();
    			while (el.attr("class") !== c) {
    				if (el.prop("tagName") === 'UL') {
    					el.show();
    				} else if (el.prop("tagName") === 'LI') {
    					el.removeClass('tree-closed');
    					el.addClass("tree-opened");
    				}
    				el = el.parent();
    			}
    		});
    		return this;
    	}
    	$.fn.treemenu = function (options) {
    		options = options || {};
    		options.delay = options.delay || 0;
    		options.openActive = options.openActive || false;
    		options.activeSelector = options.activeSelector || "";
    		this.find("> li").each(function () {
    			e = $(this);
    			var subtree = e.find('> ul');
    			var toggler = $('<span>');
    			toggler.addClass('toggler');
    			e.prepend(toggler);
    			if (subtree.length > 0) {
    				subtree.hide();
    				e.addClass('tree-closed');
    				e.find(toggler).click(function () {
    					var li = $(this).parent('li');
    					li.find('> ul').toggle(options.delay);
    					li.toggleClass('tree-opened');
    					li.toggleClass('tree-closed');
    				});
    				$(this).find('> ul').treemenu(options);
    			} else {
    				$(this).addClass('tree-empty');
    			}
    		});
    		if (options.openActive) {
    			this.openActive(options.activeSelector);
    		}
    		return this;
    	}
    })(jQuery);




    function viewport() {
        var e = window, a = 'inner';
        if (!('innerWidth' in window )) {
            a = 'client';
            e = document.documentElement || document.body;
        }
        return { width : e[ a+'Width' ] , height : e[ a+'Height' ] };

    }
    jQuery(document).ready(function ($) {

         var dcwidth=$(window).width();
         if(dcwidth <= 1024) {
             $("#nav_menu ul.menu").treemenu({}).openActive();
         }   
    });

У меня есть Добавить клик-шоу в ширину меню дерева jQuery.

Мой jQuery работает на> 1024px и добавить Активное дерево меню на <= 102px. </p>

Но когда мой браузер> 1024px, я изменяю размер до <= 1024px, мой jQuery не добавляет событие Active treemenu.Как изменить размер браузера до <= 1024px, добавить активное древовидное меню и изменить размер до> 1024px очистить активное древовидное меню.

Спасибо!

...