1$(function uil_init_menu_embed() { 2 3 var MENU_HTML_CACHE = {}; 4 5 function update_active($root) { 6 $root.find('.uil-menu-embed__current__title, .uil-menu-embed__current__children__item, .uil-menu-embed__children__item').each(function () { 7 var $item = $(this), 8 $a = $item.children('a'); 9 if ($a.attr('href') === location.pathname) 10 $item.addClass('active'); 11 else 12 $item.removeClass('active'); 13 }); 14 } 15 16 function jump(elem) { 17 var $elem = $(elem), 18 $parent = $elem.closest('*[data-id]'), 19 direction = $parent.prop('tagName').toLowerCase() === 'li' ? 'right' : 'left', 20 current_id = parseInt($parent.attr('data-id')), 21 $menu = $elem.closest('.uil-menu-embed'), 22 $body = $menu.children('.uil-menu-embed__body'), 23 data = window['MENU_EMBED_DATA_' + $menu.attr('id').toUpperCase()], 24 current, parent, sub_children = [], key_children = []; 25 26 var top = $menu.offset().top; 27 if (window.pageYOffset > top) 28 $.smoothScroll(top); 29 // $('html, body').stop(true, true).animate({scrollTop: top}, 500, 'easeInOutCirc'); 30 // window.scrollTo(window.pageXOffset, top); 31 32 $body.css({ 33 'pointer-events': 'none', 34 'width': $body.width(), 35 'height': $body.height() 36 }); 37 $body.children('.uil-menu-embed__menu').addClass('old').addClass('center'); 38 39 $.each(data, function () { 40 if (!current && parseInt(this.id) === current_id) 41 current = this; 42 else if (parseInt(this.pid) === current_id) 43 if (this.is_key === true) 44 key_children.push(this); 45 else 46 sub_children.push(this); 47 }); 48 $.each(data, function () { 49 if (parseInt(this.id) === parseInt(current.pid)) { 50 parent = this; 51 return false; 52 } 53 }); 54 55 var html = ''; 56 57 if (current_id in MENU_HTML_CACHE) { 58 html = MENU_HTML_CACHE[current_id]; 59 } else { 60 html = '<div class="uil-menu-embed__menu new">'; 61 if (parent) 62 html += '<div class="uil-menu-embed__menu__section">' + 63 '<div class="uil-menu-embed__parent ' + (parent.ext || '') + '" data-id="' + parent.id + '">' + 64 '<a href="#" class="uil-menu-embed__parent__arrow"></a>' + 65 '<a href="' + parent.url + '">' + parent.title + '</a>' + 66 '</div>' + 67 '</div>'; 68 if (current) 69 html += '<div class="uil-menu-embed__menu__section">' + 70 '<div class="uil-menu-embed__current ' + (current.ext || '') + '">' + 71 '<div class="uil-menu-embed__current__title">' + 72 '<a href="' + current.url + '">' + current.title + '</a>' + 73 '</div>'; 74 if (sub_children.length > 0) { 75 html += '<ul class="uil-menu-embed__current__children">'; 76 $.each(sub_children, function () { 77 var child = this; 78 html += '<li class="uil-menu-embed__current__children__item ' + (child.ext || '') + '" data-id="' + child.id + '">' + 79 '<a href="' + child.url + '">' + child.title + '</a>'; 80 html += '</li>'; 81 }); 82 html += '</ul>'; 83 } 84 html += '</div>' + 85 '</div>'; 86 if (key_children.length > 0) { 87 html += '<div class="uil-menu-embed__menu__section">' + 88 '<ul class="uil-menu-embed__children">'; 89 $.each(key_children, function () { 90 var child = this, is_arrow = false; 91 $.each(data, function () { 92 if (parseInt(this.pid) === parseInt(child.id)) { 93 is_arrow = true; 94 return false;
95 } 96 }); 97 html += '<li class="uil-menu-embed__children__item ' + (child.ext || '') + '" data-id="' + child.id + '">' + 98 '<a href="' + child.url + '">' + child.title + '</a>'; 99 if (is_arrow) 100 html += '<a href="#" class="uil-menu-embed__children__item__arrow"></a>'; 101 html += '</li>'; 102 }); 103 html += '</ul>' + 104 '</div>'; 105 } 106 html += '</div>'; 107 MENU_HTML_CACHE[current_id] = html; 108 } 109 110 var cls1 = 'right', 111 cls2 = 'left'; 112 if (direction === 'right') { 113 cls1 = 'left'; 114 cls2 = 'right'; 115 } 116 117 $body.append(html); 118 var $old = $body.children('.uil-menu-embed__menu.old'), 119 $new = $body.children('.uil-menu-embed__menu.new'); 120 $new.addClass(cls2); 121 $body.children('.uil-menu-embed__menu').addClass('center'); 122 setTimeout(function () { 123 $new.removeClass('right left'); 124 $body.css({ 125 'width': $new.width(), 126 'height': $new.height() 127 }); 128 }, 20); 129 $old.addClass(cls1).removeClass('center'); 130 setTimeout(function () { 131 $new.removeClass('new center right left'); 132 $old.remove(); 133 $body.css({ 134 'pointer-events': '', 135 'width': '', 136 'height': '' 137 }); 138 update_active($menu); 139 }, 333); 140 141 } 142 143 var $menu_embed_list = $('.uil-menu-embed'); 144 $menu_embed_list 145 .on('click touchend', '.uil-menu-embed__children__item__arrow, .uil-menu-embed__parent__arrow', function (e) { 146 e.stopPropagation(); 147 e.preventDefault(); 148 jump(this); 149 }); 150 151 update_active($menu_embed_list); 152 153});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.