1/** 2 * @copyright Commercial License By LeoTheme.Com 3 * @email leotheme.com 4 * @visit http://www.leotheme.com 5 */ 6$(document).ready(function() { 7 8 $.each(list_menu,function(index,value){ 9 // console.log(value.type); 10 if (value.type == "horizontal") 11 { 12 var megamenu_element = $('.cavas_menu[data-megamenu-id='+value.id+']'); 13 // console.log(megamenu_element); 14 //type horizontal menu 15 //check active link 16 if($("body").attr("id")=="index") isHomeMenu = 1; 17 megamenu_element.find(".megamenu > li > a").each(function() { 18 menuURL = $(this).attr("href").replace("https://","").replace("http://","").replace("www.","").replace( /#\w*/, "" ); 19 if( (currentURL == menuURL) || (currentURL.replace(current_link,"") == menuURL) || isHomeMenu){ 20 $(this).parent().addClass("active"); 21 return false; 22 } 23 }); 24 25 //check target 26 // console.log($(window).width()); 27 if($(window).width() <= 767){ 28 set_target_blank(false, megamenu_element); // set cavas NO 29 }else{ 30 set_target_blank(true, megamenu_element); // set cavas Yes 31 } 32 33 // console.log('test'); 34 // console.log(show_cavas); 35 36 //off canvas menu 37 if(value.show_cavas == 1) 38 { 39 // console.log('test'); 40 $.fn.OffCavasmenu = function(opts) { 41 // default configuration 42 var config = $.extend({}, { 43 opt1: null, 44 text_warning_select: text_warning_select_txt, 45 text_confirm_remove: text_confirm_remove_txt, 46 JSON: null 47 }, opts); 48 // main function 49 // initialize every element 50 this.each(function() { 51 // console.log('test'); 52 var $btn = megamenu_element.find('.navbar-toggler'); 53 // console.log($btn); 54 var $nav = null; 55 if (!$btn.length) 56 return; 57 var $nav = $("<section class='off-canvas-nav-megamenu' data-megamenu-id="+value.id+"><nav class='offcanvas-mainnav' ><div class='off-canvas-button-megamenu'><span class='off-canvas-nav'></span>"+close_bt_txt+"</div></nav></section>"); 58 // console.log($($btn.data('target')).find('.megamenu')); 59 var $menucontent = $($btn.data('target')).find('.megamenu').clone(); 60 $("body").append($nav); 61 62 $('body #page').append("<div class='megamenu-overlay' data-megamenu-id="+value.id+"></div>"); 63 64 $(".megamenu-overlay[data-megamenu-id="+value.id+"]").click(function(){ 65 $btn.trigger('click'); 66 }); 67 // console.log('test'); 68 $(".off-canvas-nav-megamenu[data-megamenu-id="+value.id+"] .offcanvas-mainnav").append($menucontent); 69 $("html").addClass ("off-canvas"); 70 $(".off-canvas-nav-megamenu[data-megamenu-id="+value.id+"]").find(".off-canvas-button-megamenu").click( function(){ 71 off_canvas_active(); 72 } ); 73 74 if($btn.is(':visible')) { 75 $("body").removeClass("off-canvas-active").addClass("off-canvas-inactive"); 76 } 77 78 $btn.click(function(){ 79 // if (!$(".off-canvas-megamenu[data-megamenu-id="+value.id+"]").hasClass('off-canvas-nav-megamenu')) 80 // { 81 // $(".off-canvas-megamenu[data-megamenu-id="+value.id+"]").addClass('off-canvas-nav-megamenu'); 82 // } 83 // console.log($(window).height()); 84 // console.log($('.offcanvas-mainnav').height()); 85 // if($(window).height() > $(".off-canvas-nav-megamenu[data-megamenu-id="+value.id+"] .offcanvas-mainnav").height()) 86 // { 87 // $(".off-canvas-nav-megamenu[data-megamenu-id="+value.id+"] .offcanvas-mainnav").height($(window).height()); 88 // } 89 // else 90 // { 91 // $(".off-canvas-nav-megamenu[data-megamenu-id="+value.id+"] .offcanvas-mainnav").height('auto'); 92 // } 93 off_canvas_active(); 94 $('.off-canvas-nav-megamenu').removeClass('active'); 95 if (!$(".off-canvas-nav-megamenu[data-megamenu-id="+value.id+"]").hasClass('active') && $('body').hasClass('off-canvas-active')) 96 { 97 $(".off-canvas-nav-megamenu[data-megamenu-id="+value.id+"]").addClass('active'); 98 auto_height(value.id); 99 } 100 101 // $(".off-canvas-megamenu[data-megamenu-id!="+value.id+"]").removeClass('off-canvas-nav-megamenu'); 102 103 });
104 105 106 }); 107 return this; 108 } 109 // console.log(megamenu_element); 110 megamenu_element.OffCavasmenu(); 111 megamenu_element.find('.navbar-toggler').click(function() { 112 return false; 113 }); 114 115 $(".off-canvas-nav-megamenu[data-megamenu-id="+value.id+"]").find('.offcanvas-mainnav .caret').click(function(){ 116 117 if($(this).parent('li').hasClass('open-sub')) 118 { 119 $(this).parent('li').find('.dropdown-menu').first().slideUp('fast',function (){ 120 // console.log($(window).height()); 121 // console.log($(".off-canvas-nav-megamenu[data-megamenu-id="+value.id+"] .offcanvas-mainnav").height()); 122 // $(".off-canvas-nav-megamenu[data-megamenu-id="+value.id+"] .offcanvas-mainnav").height('auto'); 123 // if($(window).height() > $(".off-canvas-nav-megamenu[data-megamenu-id="+value.id+"] .offcanvas-mainnav").height()) 124 // { 125 // $(".off-canvas-nav-megamenu[data-megamenu-id="+value.id+"] .offcanvas-mainnav").height($(window).height()); 126 // } 127 auto_height(value.id); 128 }); 129 $(this).parent('li').removeClass('open-sub'); 130 } 131 else 132 { 133 // $('.offcanvas-mainnav li.open-sub').find('.dropdown-menu').first().slideUp('fast'); 134 $(this).parent('li').siblings('.open-sub').find('.dropdown-menu').first().slideUp('fast'); 135 $(this).parent('li').siblings().removeClass('open-sub'); 136 $(this).parent('li').find('.dropdown-menu').first().slideDown('fast',function (){ 137 // console.log($(window).height()); 138 // console.log($(".off-canvas-nav-megamenu[data-megamenu-id="+value.id+"] .offcanvas-mainnav").height()); 139 // $(".off-canvas-nav-megamenu[data-megamenu-id="+value.id+"] .offcanvas-mainnav").height('auto'); 140 // if($(window).height() > $(".off-canvas-nav-megamenu[data-megamenu-id="+value.id+"] .offcanvas-mainnav").height()) 141 // { 142 // $(".off-canvas-nav-megamenu[data-megamenu-id="+value.id+"] .offcanvas-mainnav").height($(window).height()); 143 // } 144 auto_height(value.id); 145 }); 146 $(this).parent('li').addClass('open-sub'); 147 } 148 149 150 }); 151 152 $(window).resize(function() { 153 154 // console.log($(window).width()); 155 // if( $(window).width() > 523 ){ 156 if( $(window).width() > 991 ){ 157 $("body").removeClass("off-canvas-active").addClass("off-canvas-inactive"); 158 } 159 else 160 { 161 auto_height(value.id); 162 } 163 }); 164 } 165 else 166 { 167 var $bt = megamenu_element.find('.navbar-toggler'); 168 var $menu = megamenu_element.find('.leo-top-menu'); 169 //add class for menu element when click button to show menu at mobile, tablet 170 $bt.click(function(){ 171 if ($menu.hasClass('in')) 172 { 173 megamenu_element.removeClass('active'); 174 } 175 else 176 { 177 if (!megamenu_element.hasClass('active')) 178 { 179 megamenu_element.addClass('active'); 180 } 181 } 182 }); 183 megamenu_element.find('.leo-top-menu .dropdown-toggle').removeAttr("disabled"); 184 megamenu_element.find(".dropdown-toggle").click(function() { 185 if($(window).width() <= 767){ 186 if($(this).parent("li").find("div:first").hasClass("level2")) 187 return false; 188 else 189 return true; 190 } 191 }); 192 megamenu_element.find(".leo-top-menu li a").each(function(){ 193 // console.log($(this)); 194 // console.log((this).hasAttribute('data-toggle')); 195 if((this).hasAttribute('data-toggle')){ 196 197 $(this).removeAttr('data-toggle'); 198 199 } 200 }); 201 megamenu_element.find(".leo-top-menu li a.dropdown-toggle").click(function(){ 202 if(!$(this).parent().hasClass('open') && this.href && this.href != '#'){ 203 window.location.href = this.href; 204 } 205 }) 206 // console.log('aaa'); 207 megamenu_element.find(".leo-top-menu .caret").click(function(){ 208 // console.log('test'); 209 if($(this).parent('li').hasClass('open-sub')) 210 { 211 $(this).parent('li').find('.dropdown-menu').first().slideUp('fast', function(){ 212 auto_height_off(megamenu_element); 213 });
214 $(this).parent('li').removeClass('open-sub'); 215 } 216 else 217 { 218 // $('.offcanvas-mainnav li.open-sub').find('.dropdown-menu').first().slideUp('fast'); 219 $(this).parent('li').siblings('.open-sub').find('.dropdown-menu').first().slideUp('fast'); 220 $(this).parent('li').siblings().removeClass('open-sub'); 221 $(this).parent('li').find('.dropdown-menu').first().slideDown('fast', function(){ 222 auto_height_off(megamenu_element); 223 }); 224 $(this).parent('li').addClass('open-sub'); 225 } 226 }); 227 228 if ($(document).width() >543) 229 { 230 megamenu_element.find('.leo-top-menu .dropdown-menu').css('display', ''); 231 } 232 auto_height_off(megamenu_element); 233 $(window).resize(function(){ 234 auto_height_off(megamenu_element); 235 if ($(document).width() >543) 236 { 237 megamenu_element.find('.leo-top-menu .dropdown').removeClass('open-sub'); 238 megamenu_element.find('.leo-top-menu .dropdown-submenu').removeClass('open-sub'); 239 megamenu_element.find('.leo-top-menu .dropdown-menu').css('display', ''); 240 } 241 }); 242 } 243 } 244 else 245 { 246 //type vertical menu 247 var megamenu_element = $('.leo-verticalmenu[data-megamenu-id='+value.id+']'); 248 megamenu_element.find('.verticalmenu .dropdown-toggle').removeAttr("disabled"); 249 megamenu_element.find(".verticalmenu .dropdown-toggle").click(function() { 250 if($(window).width() <= 767){ 251 if($(this).parent("li").find("div:first").hasClass("level2")) 252 return false; 253 else 254 return true; 255 } 256 }); 257 // megamenu_element.find('.verticalmenu .dropdown-toggle').prop('disabled', true); 258 // megamenu_element.find('.verticalmenu .dropdown-toggle').data('toggle', ''); 259 megamenu_element.find('.verticalmenu .dropdown-toggle').removeAttr('data-toggle'); 260 megamenu_element.find(".verticalmenu .caret").click(function(){ 261 if($(this).parents('.verticalmenu').hasClass('active-button')) 262 { 263 // console.log('test'); 264 var $parent = $(this).parent('li'); 265 // console.log($parent.hasClass('open-sub')); 266 // $parent.toggleClass('open-sub'); 267 if($parent.hasClass('open-sub')) 268 { 269 // console.log('test'); 270 $parent.find('.dropdown-menu').first().slideUp('fast',function(){ 271 $parent.removeClass('open-sub'); 272 }); 273 274 } 275 else 276 { 277 278 if($parent.siblings('.open-sub').length > 0) 279 { 280 $parent.siblings('.open-sub').find('.dropdown-menu').first().slideUp('fast',function(){ 281 $parent.siblings('.open-sub').removeClass('open-sub'); 282 }); 283 $parent.find('.dropdown-menu').first().slideDown('fast',function(){ 284 $parent.addClass('open-sub'); 285 }); 286 } 287 else 288 { 289 $parent.find('.dropdown-menu').first().slideDown('fast',function(){ 290 $parent.addClass('open-sub'); 291 }); 292 } 293 294 295 296 } 297 return false; 298 } 299 300 }); 301 if ($(window).width() >991) 302 { 303 megamenu_element.find('.verticalmenu').addClass('active-hover'); 304 megamenu_element.find('.verticalmenu').removeClass('active-button'); 305 megamenu_element.find('.verticalmenu .dropdown-menu').css('display', ''); 306 megamenu_element.find('.leo-verticalmenu').removeClass('active'); 307 308 } 309 else 310 { 311 megamenu_element.find('.verticalmenu').removeClass('active-hover'); 312 megamenu_element.find('.verticalmenu').addClass('active-button'); 313 } 314 $(window).resize(function(){ 315 if ($(window).width() >991) 316 { 317 megamenu_element.find('.verticalmenu .dropdown').removeClass('open-sub'); 318 megamenu_element.find('.verticalmenu .dropdown-submenu').removeClass('open-sub'); 319 megamenu_element.find('.verticalmenu').addClass('active-hover'); 320 megamenu_element.find('.verticalmenu').removeClass('active-button'); 321 megamenu_element.find('.verticalmenu .dropdown-menu').css('display', ''); 322 megamenu_element.removeClass('active'); 323 }else{ 324 megamenu_element.find('.verticalmenu').removeClass('active-hover'); 325 megamenu_element.find('.verticalmenu').addClass('active-button'); 326 } 327 }); 328 scrollSliderBarMenu(megamenu_element); 329 } 330 331 //js for tab html 332 if ( typeof value.list_tab !== 'undefined' && value.list_tab.length > 0) 333 { 334 $.each(value.list_tab,function(key,val){ 335 megamenu_element.find('#tabhtml'+val+' .nav a').hover(function (e) { 336 $(this).tab('show'); 337 }) 338 megamenu_element.find('#tabhtml'+val+' .nav a').click(function (e) { 339 e.preventDefault(); 340 if(screen.width > 576){ 341 $(this).tab('show'); 342 window.location.href = $(this).data('href'); 343 }else{ 344 $(this).tab('show'); 345 } 346 }) 347 348 //fix for widget tab of off canvas menu on mobile 349 $(".off-canvas-nav-megamenu[data-megamenu-id="+value.id+"]").find('#tabhtml'+val+' .nav a').click(function (e) { 350 e.preventDefault(); 351 if (!$(e.target).hasClass('nav-link') && !$(this).hasClass('active')){ 352 var wrapper_tab = $(this).closest('.panel-group'); 353 var tab_href = $(this).attr('href'); 354 wrapper_tab.find('.nav-link').removeClass('active'); 355 wrapper_tab.find('.nav-item').removeClass('active'); 356 wrapper_tab.find('.tab-pane').removeClass('active'); 357 $(this).addClass('active'); 358 $(this).parents('.nav-item').addClass('active'); 359 wrapper_tab.find(tab_href).addClass('active'); 360 }else { 361 window.location.href = $(this).data('href'); 362 } 363 }) 364 }); 365 } 366 367 //js for widget image gallery category 368 if ( typeof value.level !== 'undefined' && typeof value.limit !== 'undefined') 369 { 370 megamenu_element.find('.widget-category_image ul.level0').each(function(){ 371 $(this).find('ul').removeClass('dropdown-sub dropdown-menu'); 372 }); 373 374 megamenu_element.find(".widget-category_image ul.level0").each(function() { 375 var check_level = $(this).parents('.widget-category_image').data('level'); 376 var check_limit = $(this).parents('.widget-category_image').data('limit'); 377 378 //remove .caret by check level 379 $(this).find("ul.level" + check_level).parent().find('.caret').remove(); 380 //remove ul by check level 381 $(this).find("ul.level" + check_level + " li").remove(); 382 383 var element = $(this).find("ul.level" + (check_level - 1) + " li").length; 384 var count = 0; 385 if(check_level > 0) { 386 $(this).find("ul.level" + (check_level - 1) + " >li").each(function(){ 387 count = count + 1; 388 if(count > check_limit){ 389 $(this).remove(); 390 } 391 });
392 } 393 }); 394 395 //add for off canvas menu 396 $(".off-canvas-nav-megamenu[data-megamenu-id="+value.id+"] .offcanvas-mainnav").find(".widget-category_image ul.level0").each(function() { 397 var check_level = $(this).parents('.widget-category_image').data('level'); 398 var check_limit = $(this).parents('.widget-category_image').data('limit'); 399 //remove .caret by check level 400 $(this).find("ul.level" + check_level).parent().find('.caret').remove(); 401 //remove ul by check level 402 $(this).find("ul.level" + check_level + " li").remove(); 403 var element = $(this).find("ul.level" + (check_level - 1) + " li").length; 404 var count = 0; 405 if(check_level > 0) { 406 $(this).find("ul.level" + (check_level - 1) + " >li").each(function(){ 407 count = count + 1; 408 if(count > check_limit){ 409 $(this).remove(); 410 } 411 }); 412 } 413 }); 414 } 415 416 if (value.type == "horizontal") 417 { 418 $(window).resize(function() { 419 // console.log($(window).width()); 420 if( $(window).width() <= 767 ){ 421 set_target_blank(false, megamenu_element); // set cavas NO 422 } 423 else { 424 set_target_blank(true, megamenu_element); // set cavas Yes 425 } 426 }); 427 } 428 429 //if (value.type == "horizontal" && value.show_cavas == 1) 430 if (value.type == "horizontal" && value.show_cavas == 1) 431 { 432 $(document.body).on('click', '[data-toggle="dropdown"]' ,function(){ 433 if(!$(this).parent().hasClass('open') && this.href && this.href != '#'){ 434 window.location.href = this.href; 435 } 436 }); 437 } 438 }) 439 $('.dropdown-menu.level1').parent().removeClass('aligned-fullwidth'); 440 //js for widget image gallery product 441 $(".fancybox").fancybox({ 442 openEffect : 'none', 443 closeEffect : 'none' 444 }); 445 446}) 447 448//auto calculate height of off canvas menu off 449function auto_height_off(menu_object) 450{ 451 wrapper_height = $("#page").innerHeight(); 452 ul_height = menu_object.find(".leo-top-menu ul").innerHeight(); 453 ul_offset_top = menu_object.find(".leo-top-menu ul").offset().top; 454 // console.log('test1'); 455 // console.log(megamenu_element.find(".leo-top-menu ul").height()); 456 // console.log(megamenu_element.find(".leo-top-menu ul").offset().top); 457 // console.log($("#page").height()); 458 // $(".off-canvas-nav-megamenu[data-megamenu-id="+menu_id+"] .offcanvas-mainnav").css('min-height', windowHeight); 459 if (ul_offset_top + ul_height > wrapper_height) 460 { 461 if (!$("#page").hasClass('megamenu-autoheight')) 462 { 463 $("#page").addClass('megamenu-autoheight'); 464 } 465 } 466 else 467 { 468 $("#page").removeClass('megamenu-autoheight'); 469 } 470} 471 472//auto calculate height of off canvas menu 473function auto_height(menu_id) 474{ 475 windowHeight = $(window).innerHeight(); 476 $(".off-canvas-nav-megamenu[data-megamenu-id="+menu_id+"] .offcanvas-mainnav").css('min-height', windowHeight); 477} 478 479function off_canvas_active() 480{ 481 // console.log($(window).height()); 482 if($('body').hasClass('off-canvas-active')) 483 { 484 $("body").removeClass("off-canvas-active").addClass("off-canvas-inactive"); 485 } 486 else if($('body').hasClass('off-canvas-inactive')) 487 { 488 $("body").removeClass("off-canvas-inactive").addClass("off-canvas-active"); 489 } 490 else 491 { 492 $("body").addClass("off-canvas-active"); 493 } 494 495} 496 497function set_target_blank( show, megamenu_element) 498{ 499 if (show) 500 { 501 502 megamenu_element.find(".leo-top-menu li a").each(function(){ 503 if( $(this).hasClass('has-category') && (this).hasAttribute('data-toggle') && $(this).attr('target')== '_blank' ){ 504 var value = $(this).attr('data-toggle'); 505 $(this).removeAttr('data-toggle'); 506 $(this).attr('remove-data-toggle', value); 507 } 508 }) 509 }else 510 { 511 // console.log('test'); 512 megamenu_element.find(".leo-top-menu li a").each(function(){ 513 if( $(this).hasClass('has-category') && (this).hasAttribute('remove-data-toggle') && $(this).attr('target')== '_blank' ){ 514 var value = $(this).attr('remove-data-toggle'); 515 $(this).removeAttr('remove-data-toggle'); 516 $(this).attr('data-toggle', value); 517 } 518 }) 519 } 520 521} 522 523function scrollSliderBarMenu(megamenu_element){ 524 var menuElement = megamenu_element; 525 var columnElement = null; 526 var maxWindowSize = 991; 527 528 // if($(menuElement).hasClass('float-vertical-right')) 529 // columnElement = $("#right_column"); 530 // else if($(menuElement).hasClass('float-vertical-left')) 531 // columnElement = $("#left_column"); 532 //auto display slider bar menu when have left or right column 533 if($(columnElement).length && $(window).width()>=maxWindowSize) showOrHideSliderBarMenu(columnElement, menuElement, 1); 534 megamenu_element.find(".verticalmenu-button").click(function(){ 535 if($(menuElement).hasClass('active')) 536 { 537 showOrHideSliderBarMenu(columnElement, menuElement, 0); 538 } 539 else 540 { 541 showOrHideSliderBarMenu(columnElement, menuElement, 1); 542 } 543 }); 544 545 var lastWidth = $(window).width(); 546 $(window).resize(function() { 547 if($(window).width()!=lastWidth){ 548 if($(window).width()<maxWindowSize) { 549 if($(menuElement).hasClass('active')) showOrHideSliderBarMenu(columnElement, menuElement, 0); 550 }else{ 551 if($(columnElement).length && !$(menuElement).hasClass('active')) showOrHideSliderBarMenu(columnElement, menuElement, 1); 552 } 553 lastWidth = $(window).width(); 554 } 555 }); 556} 557 558function showOrHideSliderBarMenu(columnElement, menuElement, active){ 559 if(active){ 560 $(menuElement).addClass('active'); 561 if($(columnElement).length && $(window).width()>=991) 562 columnElement.css('padding-top',($('.block_content',$(menuElement)).height())+'px'); 563 }else{ 564 $(menuElement).removeClass('active'); 565 if($(columnElement).length) columnElement.css('padding-top',''); 566 } 567} 568
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.