1function UCFullscreenMenu(menuWrapperID){ 2 3 var g_menuWrapper, g_isCloseOnOpen = false, g_isCurrentParentItemOpened = false; 4 var g_menuWrapperID = menuWrapperID; 5 var g_currentLocation = window.location.href; 6 var isIconClicked = false; 7 8 /** 9 * collapse inner section 10 */ 11 function collapseInnerSection(element, link){ 12 13 var sectionHeight = element.scrollHeight; 14 15 var elementTransition = element.style.transition; 16 element.style.transition = ''; 17 18 requestAnimationFrame(function() { 19 element.style.height = sectionHeight + 'px'; 20 element.style.transition = elementTransition; 21 22 23 requestAnimationFrame(function() { 24 element.style.height = 0 + 'px'; 25 26 }); 27 }); 28 29 element.setAttribute('data-collapsed', 'true'); 30 } 31 32 /** 33 * expand the inner of the section 34 */ 35 function expandSectionInner(element){ 36 var sectionHeight = element.scrollHeight; 37 38 element.style.height = sectionHeight + 'px'; 39 40 element.addEventListener('transitionend', function(e) { 41 element.removeEventListener('transitionend', arguments.callee); 42 element.style.height = null; 43 }); 44 45 element.setAttribute('data-collapsed', 'false'); 46 47 } 48 49 /** 50 * expand section 51 */ 52 function expandSection(section, objLink){ 53 54 expandSectionInner(section); 55 56 section.setAttribute('data-collapsed', 'false') 57 objLink.removeClass("collapsed"); 58 objLink.addClass("expanded"); 59 60 } 61 62 /** 63 * collapse the section 64 */ 65 function collapseSection(section, objLink){ 66 67 collapseInnerSection(section, objLink); 68 69 objLink.addClass("collapsed"); 70 objLink.removeClass("expanded"); 71 } 72 73 /** 74 * collapse all expanded sections 75 */ 76 function collapseAllExpanded(clickedItem){ 77 78 var clickedParentExpanded = jQuery(clickedItem).parents('.sub-menu').prev(); 79 var clickedChildrenExpanded = jQuery(clickedItem).next().find('.expanded'); 80 81 var objAllExpanded = g_menuWrapper.find(".expanded").not(clickedChildrenExpanded).not(clickedParentExpanded); 82 83 if(objAllExpanded.length == false) 84 return(false); 85 86 jQuery.each(objAllExpanded, function(index, link){ 87 var objLink = jQuery(link); 88 var section = link.nextElementSibling; 89 90 collapseSection(section, objLink); 91 }); 92 } 93 94 /** 95 * close or open link 96 */ 97 function toggleSection(objLink){ 98 99 var link = objLink[0]; 100 var section = link.nextElementSibling; 101 102 var isCollapsed = section.getAttribute('data-collapsed') === 'true'; 103 104 if (isCollapsed) { //expend current 105 106 if(g_isCloseOnOpen == true) 107 collapseAllExpanded(link); 108 109 expandSection(section, objLink); 110 111 } else { //collapse current 112 113 collapseSection(section,objLink); 114 } 115 116 } 117 118 /** 119 * open or close some item 120 */ 121 function openCloseItem(link, event){ 122 123 var section = link.nextElementSibling; 124 125 if(!section) 126 return(true); 127 128 var objSection = jQuery(section); 129 if(objSection.hasClass("sub-menu") == false) 130 return(true); 131 132 if(event) 133 event.preventDefault(); 134 135 var objLink = jQuery(link); 136 137 var isCollapsed = section.getAttribute('data-collapsed') === 'true'; 138 139 if (isCollapsed) { //expend current 140 141 if(g_isCloseOnOpen == true) 142 collapseAllExpanded(link); 143 144 expandSection(section, objLink); 145 146 } else { //collapse current 147 148 collapseSection(section,objLink); 149 } 150 151 } 152 153 /** 154 * on menu item click, if sub menu, open or close 155 */ 156 function onMenuItemClick(event){ 157 openCloseItem(this, event); 158 } 159 160 /** 161 * console log shorcut 162 */ 163 function trace(str){ 164 console.log(str); 165 } 166 167 /** 168 * init from popups 169 */ 170 function checkInitFromPopups(){ 171 jQuery( document ).on( 'elementor/popup/show', (event) => { 172 runMenu(); 173 }); 174 } 175 176 /** 177 * expand current item tree 178 */ 179 function expandCurrentItemTree(){ 180 181 //disable transition 182 183 var objCurrentItem = g_menuWrapper.find(".uc-list-menu ul .current-menu-item"); 184 185 if(objCurrentItem.length == 0) 186 return(false); 187 188 g_menuWrapper.addClass("uc-no-transition"); 189 190 setTimeout(function(){ 191 g_menuWrapper.removeClass("uc-no-transition"); 192 },300); 193 194 var objParents = objCurrentItem.parents("li"); 195 196 if(objParents.length == 0) 197 return(false); 198 199 jQuery.each(objParents, function(index, parent){ 200 var objParent = jQuery(parent); 201 var objLink = objParent.children("a"); 202 203 var link = objLink[0]; 204 205 openCloseItem(link); 206 }); 207 } 208 209 // collapse all except the current 210 this.collapseAll = function(){ 211 g_menuWrapper.find("ul.uc-list-menu li a").each((i, item) => { 212 var objLink = jQuery(item); 213 214 collapseAllExpanded(objLink[0]); 215 }); 216 } 217 218 /* 219 * open current page menu item 220 */ 221 this.openCurrentPageMenuItem = function(){ 222 223 g_menuWrapper.find("ul.uc-list-menu li a").each((i, item) => { 224 225 var objLink = jQuery(item); 226 var section = item.nextElementSibling; 227 var objLinkItemHref = objLink.attr('href'); 228 229 if(g_currentLocation == objLinkItemHref){ 230 231 if(jQuery(section) && jQuery(section).length > 0) 232 expandSection(section, objLink); 233 234 var objParentSection = objLink.parents(".sub-menu"); 235 236 if(!objParentSection) 237 return(true) 238 239 var objParentLink = objParentSection.prev(); 240 241 if(!objParentLink) 242 return(true) 243 244 if(objParentSection && objParentSection.length > 0) 245 expandSection(objParentSection[0], objParentLink); 246 } 247 }); 248 } 249 250
251 /* 252 * position fixed protection from parents transform rules 253 */ 254 function protectForFixed(){ 255 256 //find element with position fixed css rule 257 var objFixedElement = g_menuWrapper.parents('.ue_menu'); 258 259 //find all parents and look at each one 260 var objFixedParents = objFixedElement.parents(); 261 262 objFixedParents.each(function(){ 263 264 var objFixedParent = jQuery(this); 265 266 //check if parent has one of issued css rules 267 var transformRule = objFixedParent.css('transform'); 268 269 //if transform is epsent then skip and move to another css rule 270 if(transformRule == 'none') 271 return(true); 272 273 //if finds transform then remove it 274 objFixedParent.css('transform', ''); 275 276 //animation-fill-mode 277 var fillmodeRule = objFixedParent.css('animation-fill-mode'); 278 279 if(fillmodeRule == 'none') 280 return(true); 281 282 objFixedParent.css('animation-fill-mode', 'none'); 283 284 //perspective 285 var perspectiveRule = objFixedParent.css('perspective'); 286 287 if(perspectiveRule == 'none') 288 return(true); 289 290 objFixedParent.css('perspective', 'none'); 291 292 //filter 293 var filterRule = objFixedParent.css('filter'); 294 295 if(filterRule == 'none') 296 return(true); 297 298 objFixedParent.css('filter', 'none'); 299 300 }); 301 302 } 303 304 305 /** 306 * run the menu, init 307 */ 308 this.runMenu = function(){ 309 310 //init globals 311 g_menuWrapper = jQuery("#"+g_menuWrapperID); 312 313 g_isCloseOnOpen = g_menuWrapper.data("closeothers"); 314 g_isCloseOnOpen = (g_isCloseOnOpen == "yes"); 315 316 var isClickable = g_menuWrapper.data("clickable"); 317 318 if(g_menuWrapper.length == 0){ 319 console.log("menu with ID: "+g_menuWrapperID+" not found!"); 320 321 checkInitFromPopups(); 322 323 return(false); 324 } 325 326 //collapse all except the current 327 328 g_menuWrapper.find("ul.uc-list-menu li a").each((i, item) => { 329 330 if(item.nextElementSibling){ 331 332 var objItem = jQuery(item); 333 var iconPosition = g_menuWrapper.data('icon-position'); 334 335 if(iconPosition == 'start') 336 objItem.prepend("<span class='uc-menu-item-pointer'></span>"); 337 338 if(iconPosition == 'end') 339 objItem.append("<span class='uc-menu-item-pointer'></span>"); 340 341 collapseInnerSection(item.nextElementSibling, item); 342 343 item.nextElementSibling.style.display = "block"; 344 345 jQuery(item).addClass("collapsed"); 346 jQuery(item).removeClass("expanded"); 347 } 348 349 }); 350 351 //init events 352 353 if(isClickable == false){ 354 355 g_menuWrapper.find("ul.uc-list-menu li a").on("click", onMenuItemClick); 356 357 }else{ 358 359 //pointer click - toggle section 360 g_menuWrapper.find("ul.uc-list-menu li .uc-menu-item-pointer").on("click", function(event){ 361 isIconClicked = true; 362 363 var objLink = jQuery(this).parent(); 364 toggleSection(objLink); 365 }); 366 367 g_menuWrapper.find("ul.uc-list-menu li a").on("click", function(e){ 368 //check if icon was clicked if not make sure that no icon found in clicked link 369 if(isIconClicked == true){ 370 var objIcon = jQuery(this).find(".uc-menu-item-pointer"); 371 372 if(objIcon && objIcon.length > 0){ 373 e.preventDefault(); 374 isIconClicked = false; 375 } 376 } 377 }); 378 } 379 380 //open the section with current item 381 382 setTimeout(expandCurrentItemTree,100); 383 384 //protection for elements with position fixed rule 385 386 setTimeout(protectForFixed,2000); 387 388 } 389 390 391}
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.