jQuery(function($) { "use strict"; var resizeid = 1; $.fn.hasParent=function(e){ return !$(this).parents(e).length } //Creation & changing Main menu $.fn.base_depot = { //Move to href one : function(href) { window.location = href; }, //Width top menu section top_menu_section : function() { return $.fn.base_depot.options.menu_section_width; }, //Width of full top menu top_menu_width : function() { return $($.fn.base_depot.options.menu_parent).width(); }, //Return max possible values for top menu max_line_number : function() { return $.fn.base_depot.options.max_line_number; }, //Show more link show_more_link : function() { $($.fn.base_depot.options.link_more).css('display', 'block'); }, //Hide more link hide_more_link : function() { $($.fn.base_depot.options.link_more).css('display', 'none'); }, //Window width window_clientarea_width : function() { return $('body')[0].clientWidth; }, //Window width with scrollbar window_clientarea_width_with_scrollbar : function() { return $('body')[0].clientWidth + $.fn.base_depot.scroll_bar_width() + 1; }, //Scroll bar width scroll_bar_width : function() { var $outer = $('
').css({visibility: 'hidden', width: 100, overflow: 'scroll'}).appendTo('body'), widthWithScroll = $('
').css({width: '100%'}).appendTo($outer).outerWidth(); $outer.remove(); return 100 - widthWithScroll; }, //Window height window_clientarea_height : function() { return $(window).height(); }, //Document height document_clientarea_height : function() { return $('body').height(); }, //Left position second menu hidden section change_top_hidden_section_left : function() { return $.fn.base_depot.window_clientarea_width() - $('.hidden_top_menu_elems').width(); }, //resize full top menu resize_top_level_of_menu : function() { $.fn.base_depot.correct_main_menu_settings('top', '.menu_second', '.dropdown_wrapper_bottom_more', '.dropdown_wrapper_top_more'); $.fn.base_depot.correct_main_menu_settings('bottom', '.menu_first', '.dropdown_wrapper_bottom_more', '.dropdown_wrapper_top_more'); }, //Check scroll bar check_scrollbar : function() { var body= $('body')[0] if ((body.scrollHeight>body.clientHeight)||(body.scrollWidth>body.clientWidth)) { return false; } return true; }, //Correct main menu positions correct_main_menu_settings : function(idnt, prnt, btm, tp) { var winwdth = $.fn.base_depot.window_clientarea_width(); var winwdth_css = $.fn.base_depot.window_clientarea_width_with_scrollbar(); var id = (idnt == '') ? $.fn.base_depot.options.ident : idnt; var child = (prnt == '') ? $.fn.base_depot.options.menu_parent : prnt; var par = $(child).parent(); var k, koef; switch (id) { case 'bottom': koef = (winwdth_css > 500) ? 0.3 : 0.3; var allw = Math.floor(winwdth*koef); $(child).width(allw); $(child).parent().width(allw); if (btm != '') { if ($(child).find(btm).css('display') != 'none') k=1; else k=2; $(child).children().width(Math.floor(allw/($(child).children().length-k))); } break; case 'top': koef = (winwdth_css > 500) ? 0.7 : 0.7; var seed = (winwdth_css <= 500) ? 30 : 114; var allw = Math.floor(winwdth*koef) - seed - 1; $(child).width(allw); $(child).parent().width(allw); if (tp != '') { if ($(child).find(tp).css('display') != 'none') k=1; else k=2; $(child).children().width(Math.floor(allw/($(child).children().length-k))); } break; } }, //Main function change_top_menu_items : function(options) { $.fn.base_depot.start(); $.fn.base_depot.options = options; $.fn.base_depot.correct_main_menu_settings('', '', '.dropdown_wrapper_bottom_more', '.dropdown_wrapper_top_more'); var w = Math.floor($.fn.base_depot.top_menu_width()/$.fn.base_depot.top_menu_section()); var items = $($.fn.base_depot.options.menu_parent).children().not($.fn.base_depot.options.hidden_section).not($.fn.base_depot.options.link_more); var hidden_items = $($.fn.base_depot.options.hidden_section).find($.fn.base_depot.options.menu_elems_wrapper); var l = 0; if ($.fn.base_depot.window_clientarea_width() < low_border_width) { w=0; l=1; } if (/*($.fn.base_depot.max_line_number() > w)||*/(w < items.length + hidden_items.length)) { w--; $.fn.base_depot.show_more_link(); l = 1; } else { $.fn.base_depot.hide_more_link(); } if (w != items.length) { $.fn.base_depot.rebuild_menu(w, items, hidden_items); } $.fn.base_depot.make_section_width(w,l, items.length, hidden_items.length); }, //Set width of section make_section_width : function(w, l, it, hit) { if (w+l > it + hit) { var wdth = Math.floor(($.fn.base_depot.top_menu_width()-1)/(it + hit)); $($.fn.base_depot.options.menu_elems_wrapper).width(wdth); $($.fn.base_depot.options.menu_elems_button_wrapper).width(wdth); } else { if ((w+l == 0)||(w==-1)) { var winwdth = $.fn.base_depot.window_clientarea_width(); var winwdth_css = $.fn.base_depot.window_clientarea_width_with_scrollbar(); var seed = (winwdth_css <= 500) ? 30 : 114; var wdth = ($.fn.base_depot.options.ident == "bottom") ? Math.floor(winwdth*0.3) : Math.floor(winwdth*0.7 - seed - 1); } else { var wdth = Math.floor(Math.floor($.fn.base_depot.top_menu_width()-1)/(w+l)); } $($.fn.base_depot.options.menu_elems_wrapper).width(wdth); $($.fn.base_depot.options.menu_elems_button_wrapper).width(wdth); $($.fn.base_depot.options.link_more).width(wdth); $.fn.base_depot.correct_main_menu_settings('', '', '', ''); } $.fn.base_depot.resize_logo(); $.fn.base_depot.for_submenu_links_prepare(); }, //rebuild menu after resize rebuild_menu : function(w, items, hidden_items) { if ($.fn.base_depot.window_clientarea_width() < low_border_width) { $.fn.base_depot.remove_element_from_active_menu(w, items, hidden_items); } else { if (w > items.length)$.fn.base_depot.add_element_to_active_menu(w, items, hidden_items); if (w < items.length)$.fn.base_depot.remove_element_from_active_menu(w, items, hidden_items); } }, //Change visible and hidden areas on screen reformate_visible_and_hidden_area : function(options) { $.fn.base_depot.options = options; var mover = function (){ set_mouseenter_params(); } var set_subarea = function() { if ($.fn.base_depot.options.ident == "top") { var elems = $($.fn.base_depot.options.hidden_section).children().css("float", "none").children().css("background", "none").children().children().children(); $.each(elems, function(i, v) { var sel = $(v).next(); var wdth = $(v).css({ visibility: "hidden", display: "block" }).width(); $(v).css({ visibility: "", display: "" }); if (wdth<160)wdth = 160; sel.css('margin-left', -1*wdth).css('top', 0+'px').css('width', wdth); }); } else { var ileft = $($.fn.base_depot.options.hidden_section).width(); var sel = $($.fn.base_depot.options.hidden_section).children().css("float", "none").children().css("background", "none").children().children().children().next(); sel.css('top', 0+'px').css('margin-left', ileft+'px'); } } //Hidden area menu correction var set_mouseenter_params = function() { $($.fn.base_depot.options.hidden_section).width($($.fn.base_depot.options.hidden_section).children().first().width()); var lower_width = $.fn.base_depot.window_clientarea_width()*0.7; $($.fn.base_depot.options.hidden_area_instead).width(lower_width); set_subarea(); if ($.fn.base_depot.options.ident == "top") { var hgt = ($($.fn.base_depot.options.menu_parent).height()/2 + $($.fn.base_depot.options.more_btn_class).height()/2 + $('#wpadminbar').height())+parseInt($('.head_part_three').css('margin-top'), 10); change_top_menu_hidden_left(); $($.fn.base_depot.options.hidden_area_instead).css('left', $.fn.base_depot.window_clientarea_width() - lower_width); } else { var hgt = $('.head').height() - (105/2 - $($.fn.base_depot.options.more_btn_class).height()/2) + $('#wpadminbar').height()+parseInt($('.head_part_two').css('margin-top'), 10); $($.fn.base_depot.options.hidden_section).css('left', $($.fn.base_depot.options.menu_parent).width() - $($.fn.base_depot.options.hidden_section).width()); $($.fn.base_depot.options.hidden_area_instead).css('left', $($.fn.base_depot.options.menu_parent).width() - $($.fn.base_depot.options.hidden_section).width()); } $($.fn.base_depot.options.hidden_section).css('top', hgt); $($.fn.base_depot.options.hidden_area_instead).css('top', hgt); $.fn.base_depot.set_lower_children_width($.fn.base_depot.options); } var change_top_menu_hidden_left = function() { $($.fn.base_depot.options.hidden_section).css('left', $.fn.base_depot.change_top_hidden_section_left()); } var back_menu_rebuild_top = function() { var ileft = ($.fn.base_depot.options.ident == "top") ? "0px" : "0px"; $($.fn.base_depot.options.menu_parent).children().not($.fn.base_depot.options.hidden_section).not($.fn.base_depot.options.more_btn_class_container). css("float", "left").children().css("background", "url("+local_options.path+"/"+local_options.style+"images/separator.jpg) no-repeat"). children().children().children().next().css('top', '').css('margin-left', ileft).css('width', ''); $.fn.base_depot.recalculate_css(); } $.when(mover()).then(back_menu_rebuild_top()); }, set_lower_children_width : function(options) { var parwidth = $(options.hidden_area_instead).width(); $(options.hidden_area_instead).find('a, .dropbox_btn_wrapper_top, .dropbox_btn_wrapper').width(parwidth); }, set_mouseenter_params_outter : function(options) { $.fn.base_depot.options = options; $($.fn.base_depot.options.hidden_section).width($($.fn.base_depot.options.hidden_section).children().first().width()); //set_subarea(); var lower_width = $.fn.base_depot.window_clientarea_width()*0.7; $($.fn.base_depot.options.hidden_area_instead).width(lower_width); if ($.fn.base_depot.options.ident == "top") { var hgt = ($($.fn.base_depot.options.menu_parent).height()/2 + $($.fn.base_depot.options.more_btn_class).height()/2 + $('#wpadminbar').height())+parseInt($('.head_part_three').css('margin-top'), 10); $($.fn.base_depot.options.hidden_section).css('left', $.fn.base_depot.change_top_hidden_section_left()); $($.fn.base_depot.options.hidden_area_instead).css('left', $.fn.base_depot.window_clientarea_width() - lower_width); } else { var hgt = $('.head').height() - (105/2 - $($.fn.base_depot.options.more_btn_class).height()/2) + $('#wpadminbar').height()+parseInt($('.head_part_two').css('margin-top'), 10); $($.fn.base_depot.options.hidden_section).css('left', $($.fn.base_depot.options.menu_parent).width() - $($.fn.base_depot.options.hidden_section).width()); $($.fn.base_depot.options.hidden_area_instead).css('left', $($.fn.base_depot.options.menu_parent).width() - $($.fn.base_depot.options.hidden_section).width()); } $($.fn.base_depot.options.hidden_section).css('top', hgt); $($.fn.base_depot.options.hidden_area_instead).css('top', hgt); $.fn.base_depot.set_lower_children_width(options); }, //Recalculate CSS rules recalculate_css : function() { document.body.style.zoom = 1.0000001; setTimeout(function(){document.body.style.zoom = 1;},50); }, //Z-index correction for needed menu output zindex_reformate : function(options) { if (options.ident == "bottom") { var di = $('.dropdown_wrapper'); var count = di.length+2; di.each(function(i,v){ $(v).css('z-index', count-i); }); } else { $('.dropdown_wrapper_top').css("z-index", $('.dropdown_wrapper').length+5); } }, move_more_to_bottom : function() { $($.fn.base_depot.options.menu_parent).append($($.fn.base_depot.options.link_more)); }, //Add menu element to visible part add_element_to_active_menu : function(w, items, hidden_items) { var i = items.length; var j = 0; while (i < w) { var swp = hidden_items.get(j); $($.fn.base_depot.options.menu_parent).append(swp); i++; j++; } $.fn.base_depot.move_more_to_bottom(); }, //Remove menu element from visible part remove_element_from_active_menu : function(w, items, hidden_items) { var i = items.length; var k = items.length; if (w<0)w=0; while (i > w) { var swp = items.get(k-1); $($.fn.base_depot.options.hidden_section).prepend(swp); i--; k--; } }, //Resize logo resize_logo : function() { if ($('img').is($.fn.base_depot.options.logo_image)) { var lw = $.fn.base_depot.options.lw; var hws = $.fn.base_depot.options.hws; $($.fn.base_depot.options.logo_image).hide(); var lpw = $($.fn.base_depot.options.logo_image).closest('div').width(); var hwp = $($.fn.base_depot.options.menu_delimiter).height() - $($.fn.base_depot.options.menu_bottom).height(); var hw = hws*lpw/lw; if (hwp < hw) { hw = hwp; lpw = lw*hwp/hws; } $($.fn.base_depot.options.logo_image).width(lpw); $($.fn.base_depot.options.logo_image).height(hw); $($.fn.base_depot.options.logo_image).show(); } $.fn.base_depot.finish(); }, for_submenu_links_prepare : function() { var dcs = $(".dropdown-content"); $.each(dcs, function(i,dc){ var dc_menu = $(dc).prev().children().first(); $(dc).css('top', $(dc_menu).position().top + $(dc_menu).height()); }); }, //Set duration for transitions set_duration : function(id_selector, duration) { $(id_selector).css({ '-webkit-transition': 'all '+duration+'ms ease', '-moz-transition': 'all '+duration+'ms ease', '-ms-transition': 'all '+duration+'ms ease', '-o-transition': 'all '+duration+'ms ease', 'transition': 'all '+duration+'ms ease' }); return $(id_selector); }, if_scroll_resize_top_level : function(){ if ((!$.fn.base_depot.check_scrollbar())) { $.fn.base_depot.resize_top_level_of_menu(); } }, //Finish finish : function() { $('.head').css('overflow', 'visible'); $('.head').removeClass('vhide'); setTimeout(function(){ $('.head').removeClass('head_init_transition'); }, 700); }, //Start start : function() { $('.head').addClass('vhide'); }, } var lw, hws; var settings_top, settings_bottom; var lower_width_menu = function(){ if ($.fn.base_depot.window_clientarea_width() < low_border_width) { } else { } } /**********Tabindex creation section (NOT USED)***********/ var cind=1; var reoder_tab_index = function(){ cind = reoder_tab_index_common('.menu_first .dropbtn', '.hidden_bottom_menu_elems', '.dropdown_wrapper_bottom_more .dropbtn', '.dropdown_wrapper_bottom_more', cind); cind = reoder_tab_index_common('.menu_second .dropbtn', '.hidden_top_menu_elems', '.dropdown_wrapper_top_more .dropbtn', '.dropdown_wrapper_top_more', cind); cind=1; } var reoder_tab_index_common = function(menubtn, hidden_layer, more_btn, not_count_parent, cind){ var topi; var res = []; res[0] = []; res[1] = []; $(document).find(menubtn).each(function(i,v){ topi = ($(v).hasParent(hidden_layer)) ? 0 : 1; if ($(v).hasParent(not_count_parent)){ if (res[topi] == undefined)res[topi] = []; if (v != undefined) res[topi].push(v); } }); $.each(res[0], function(o,r){ cind++; $(r).attr("tabIndex", cind); $(r).parent().next().find('a').each(function(j,w){ cind++; $(w).attr("tabIndex", cind); $(w).next().find('a').each(function(k,z){ cind++; $(z).attr("tabIndex", cind); }); }); }); cind++; $(more_btn).attr("tabIndex", cind); $.each(res[1], function(o,r){ cind++; $(r).attr("tabIndex", cind); $(r).parent().next().find('a').each(function(j,w){ cind++; $(w).attr("tabIndex", cind); $(w).next().find('a').each(function(k,z){ cind++; $(z).attr("tabIndex", cind); }); }); }); return cind; } /*************************************************/ var lower_res = false; var check_lower_res = function () { if ($.fn.base_depot.window_clientarea_width() < low_border_width) { $('.menu_first, .menu_second').find('.dropbtn, .dropdown-content a, .dropdown-subcontent a').attr('tabindex', "-1"); $('.lower_resolution_right, .lower_resolution_left').find('.dropbtn, .dropdown-content2 a, .dropdown-subcontent2 a').removeAttr('tabindex'); lower_res = true; } else { $('.menu_first, .menu_second').find('.dropbtn, .dropdown-content a, .dropdown-subcontent a').removeAttr('tabindex'); $('.lower_resolution_right, .lower_resolution_left').find('.dropbtn, .dropdown-content2 a, .dropdown-subcontent2 a').attr('tabindex', "-1"); lower_res = false; } } var append_mark_parent = function() { $.each($('.dropbtn'), function(i,v){ if ($(v).parent().parent().find('.dropdown-content').length != 0) $(v).find('span').html($(v).find('span').html()+' »'); }) $.each($('.menu_sublinks'), function(i,v){ if ($(v).next().hasClass('dropdown-subcontent')) $(v).html($(v).html()+' »'); }) } var low_border_width; //Creation main menu var loading = function(){ low_border_width = local_options['bluesquirrel_lower_resolution_start_width']; settings_top = {'menu_section_width':local_options['bluesquirrel_second_menu_section_width'], 'menu_parent':'.menu_second', 'link_more':'.dropdown_wrapper_top_more', 'hidden_section':'.hidden_top_menu_elems', 'menu_elems_wrapper':'.dropdown_wrapper_top', 'hidden_area_instead':'.lower_resolution_right', 'menu_elems_button_wrapper':'.dropbox_btn_wrapper_top', 'submenu_content':'.dropdown-content', 'logo_image':'.logo', 'max_line_number':local_options['bluesquirrel_number_second_menu'], 'ident':'top', 'menu_bottom' : '.menu_second', 'menu_delimiter' : '.head_part_two', 'lw':lw, 'hws':hws, 'more_btn_class': '.dropdown_wrapper_top_more .dropbtn', 'offset_left_all_hidden_block':'.dropdown_wrapper_top_more', 'more_btn_class_container': '.dropdown_wrapper_top_more'}; settings_bottom = {'menu_section_width':local_options['bluesquirrel_first_menu_section_width'], 'menu_parent':'.menu_first', 'link_more':'.dropdown_wrapper_bottom_more', 'hidden_section':'.hidden_bottom_menu_elems', 'menu_elems_wrapper':'.dropdown_wrapper', 'hidden_area_instead':'.lower_resolution_left', 'menu_elems_button_wrapper':'.dropbox_btn_wrapper', 'submenu_content':'.dropdown-content', 'logo_image':'.logo', 'max_line_number':local_options['bluesquirrel_number_first_menu'], 'ident':'bottom', 'menu_bottom' : '.menu_second', 'menu_delimiter' : '.head_part_two', 'lw':lw, 'hws':hws, 'more_btn_class': '.dropdown_wrapper_bottom_more .dropbtn', 'offset_left_all_hidden_block':'.dropdown_wrapper_bottom_more', 'more_btn_class_container': '.dropdown_wrapper_bottom_more'}; menu_resize(); $.when($.when($.when($.when($.when($.when($.when($.when($.fn.base_depot.change_top_menu_items(settings_top)).then($.fn.base_depot.change_top_menu_items(settings_bottom))). then($.when($.fn.base_depot.if_scroll_resize_top_level()).then(menu_resize()))).then(tb())).then( function (){ $.fn.base_depot.reformate_visible_and_hidden_area(settings_top); $.fn.base_depot.reformate_visible_and_hidden_area(settings_bottom); } )).then($.when(correct_menu_height()).then(correct_hidden_area_in_dom()))).then(lower_width_menu())).then(check_lower_res())).then($.when(append_mark_parent()).then(subsubmenu_positioned())); $.fn.base_depot.zindex_reformate(settings_top); $.fn.base_depot.zindex_reformate(settings_bottom); } //Correction in DOM hidden areas var correct_hidden_area_in_dom = function(){ $('.hidden_top_menu_elems').remove().insertAfter($('.dropdown_wrapper_top_more')); $('.hidden_bottom_menu_elems').remove().insertAfter($('.dropdown_wrapper_bottom_more')); } //Correction position for site-title record var tb = function(){} var correct_menu_height = function(){ $('.head_part_two').css('margin-top', ''); $('.head_part_three').css('margin-top', ''); if ($('.full_part').height() > $('.head').height()) { $('.head_part_two').css('margin-top', ($('.full_part').height()-$('.head_part_two').height())+'px'); $('.head_part_three').css('margin-top', ($('.full_part').height()-$('.head_part_three').height())+'px'); } $.fn.base_depot.set_mouseenter_params_outter(settings_top); $.fn.base_depot.set_mouseenter_params_outter(settings_bottom); } //After logo loading if ($('img').is('.logo')) { var tmpImg = new Image() ; tmpImg.src = $('.logo').attr('src') ; tmpImg.onload = function() { $('.logo').css({ visibility:'hidden', display:'block'}); lw = $('.logo').width(); hws = $('.logo').height(); $('.logo').css({ visibility:'visible', display:'none'}); loading(); } ; } else { loading(); } //Hidden section mouse reactions var init_menu_more_mouse_actions = function(options) { $(options.more_btn_class).bind('mouseenter focus', function(event){ hidden_menu_again = 2; if ($.fn.base_depot.window_clientarea_width() < low_border_width) $(options.hidden_area_instead).addClass("mshow"); else $(options.hidden_area).addClass("mshow"); }); $(options.more_btn_class).bind('mouseleave', function(event){ move_cursor_from_more(event, 'mouseleave'); }); $(options.more_btn_class).bind('focusout', function(event){ move_cursor_from_more(event, 'focusout'); }); var move_cursor_from_more = function(event, marker){ hidden_menu_again = 1; var remove_main_dd_menu = function(){ if (marker == 'mouseleave') { if ((mouse_on_hidden_menu_layer == 1)&&(hidden_menu_again == 1)) { if ($.fn.base_depot.window_clientarea_width() < low_border_width) $(options.hidden_area_instead).removeClass("mshow"); else $(options.hidden_area).removeClass("mshow"); } } else { if ($.fn.base_depot.window_clientarea_width() < low_border_width) { if (focus_menu_hidden_area_active == 1) $(options.hidden_area_instead).removeClass("mshow"); } else { if (focus_menu_hidden_area_active == 1) $(options.hidden_area).removeClass("mshow"); } } } setTimeout(remove_main_dd_menu, 50); } var mouse_on_hidden_menu_layer = 1; var hidden_menu_again = 1; $(options.hidden_area_instead).bind('mouseenter', function(event){ mouse_on_hidden_menu_layer = 2; $(options.hidden_area_instead).addClass("mshow"); }); $(options.hidden_area).bind('mouseenter', function(event){ mouse_on_hidden_menu_layer = 2; $(options.hidden_area).addClass("mshow"); }); var focus_menu_hidden_area_active = 1; if (!lower_res) { $(options.hidden_area).find(".dropbtn").bind('focus', function(event){ focus_menu_hidden_area_active = 2; $(options.hidden_area).addClass("mshow"); }); $(options.hidden_area).find(".dropdown-content a").bind('focus', function(event){ focus_menu_hidden_area_active = 2; $(options.hidden_area).addClass("mshow"); }); $(options.hidden_area).find(".dropdown-subcontent a").bind('focus', function(event){ focus_menu_hidden_area_active = 2; $(options.hidden_area).addClass("mshow"); }); } else { $(options.hidden_area_instead).find(".dropbtn").bind('focus', function(event){ focus_menu_hidden_area_active = 2; $(options.hidden_area_instead).addClass("mshow"); }); $(options.hidden_area_instead).find(".dropdown-content2 a").bind('focus', function(event){ focus_menu_hidden_area_active = 2; $(options.hidden_area_instead).addClass("mshow"); }); $(options.hidden_area_instead).find(".dropdown-subcontent2 a").bind('focus', function(event){ focus_menu_hidden_area_active = 2; $(options.hidden_area_instead).addClass("mshow"); }); } $(options.hidden_area).bind('mouseleave', function(event){ mouse_on_hidden_menu_layer = 1; $(options.hidden_area).removeClass("mshow"); }); $(options.hidden_area_instead).bind('mouseleave', function(event){ mouse_on_hidden_menu_layer = 1; $(options.hidden_area_instead).removeClass("mshow"); }); if (!lower_res) { $(options.hidden_area).find(".dropbtn").bind('focusout', function(event){ mouse_on_hidden_menu_layer = 1; focus_menu_hidden_area_active = 1; setTimeout(function(){ move_cursor_from_more(event, 'focusout'); }, 50); }); $(options.hidden_area).find(".dropdown-content a").bind('focusout', function(event){ mouse_on_hidden_menu_layer = 1; focus_menu_hidden_area_active = 1; setTimeout(function(){ move_cursor_from_more(event, 'focusout'); }, 50); }); $(options.hidden_area).find(".dropdown-subcontent a").bind('focusout', function(event){ mouse_on_hidden_menu_layer = 1; focus_menu_hidden_area_active = 1; setTimeout(function(){ move_cursor_from_more(event, 'focusout'); }, 50); }); } else { $(options.hidden_area_instead).find(".dropbtn").bind('focusout', function(event){ mouse_on_hidden_menu_layer = 1; focus_menu_hidden_area_active = 1; setTimeout(function(){ move_cursor_from_more(event, 'focusout'); }, 50); }); $(options.hidden_area_instead).find(".dropdown-content2 a").bind('focusout', function(event){ mouse_on_hidden_menu_layer = 1; focus_menu_hidden_area_active = 1; setTimeout(function(){ move_cursor_from_more(event, 'focusout'); }, 50); }); $(options.hidden_area_instead).find(".dropdown-subcontent2 a").bind('focusout', function(event){ mouse_on_hidden_menu_layer = 1; focus_menu_hidden_area_active = 1; setTimeout(function(){ move_cursor_from_more(event, 'focusout'); }, 50); }); } /* Common (visible area) mouse reactions */ $('.dropbtn').bind('click', function(event){ if (!(($(this).find("a").length == 0)||($(this).find("a").attr("href") == undefined))) window.location = $(this).find("a").attr("href"); }); if (!lower_res) $('.dropbtn').bind('mouseenter focus', function(event){ remove_sublinks(event); if ($(this).parent().next().hasClass("dropdown-content")) $(this).parent().next().addClass('show'); }); if (!lower_res) $('.dropbtn').bind('mouseleave focusout', function(event){ var remove_sublinks = function (event){ if ((mof == 1)&&( mofs == 1)) { var ev = ($(event.target).hasClass('dropbtn')) ? $(event.target) : $(event.target).closest('.dropbtn'); $(ev.parent().next()).removeClass('show'); if (event.type == "focusout") { remove_hidden_area(ev); } } } remove_sublinks(event); }); var mof = 1, mofs = 1; if (!lower_res) $('.dropdown-content').bind('mouseenter focus', function(event){ mof = 2; size_of_div_out_of_border($(this)); $(this).addClass('show'); }); if (!lower_res) $('.dropdown-content a').bind('focus', function(event){ mof = 2; size_of_div_out_of_border($(this)); $(this).parent().addClass('show'); $(this).parents('.mhide').addClass('mshow'); }); if (!lower_res) $('.dropdown-content a').bind('1focusout', function(event){ mof = 2; size_of_div_out_of_border($(this)); if (mofs == 1) $(this).parent().removeClass('show'); remove_hidden_area($(this)); }); if (!lower_res) $('.dropdown-content').bind('mouseleave focusout', function(event){ mof = 1; size_of_div_out_of_border($(this)); if ((mof == 1)&&(mofs == 1)) $(this).removeClass('show'); }); var icd = 0; var remove_hidden_area = function(elem){ icd++; if (elem.attr("tabIndex") != undefined) { var tI = parseInt(elem.attr("tabIndex"), 10); if ((!$('[tabIndex='+(tI+1)+']').length)||(!$('[tabIndex='+(tI+1)+']').parents(".hidden_top_menu_elems").length)) { $('.hidden_top_menu_elems').removeClass("mshow"); } if (!$('[tabIndex='+(tI+1)+']').parents(".hidden_bottom_menu_elems").length){ $(".hidden_bottom_menu_elems").removeClass("mshow"); } } } if (!lower_res) $('.menu_sublinks').bind('mouseenter focus', function(event){ $(this).next().addClass('show'); }); if (!lower_res) $('.menu_sublinks').bind('mouseleave focusout', function(event){ if (mofs == 1) $(this).next().removeClass('show'); }); if (!lower_res) $('.dropdown-subcontent').bind('mouseenter', function(event){ mofs = 2; $(this).addClass('show'); }); if (!lower_res) $('.dropdown-subcontent').bind('mouseleave', function(event){ mofs = 1; $(this).removeClass('show'); }); if (!lower_res) $('.dropdown-subcontent a').bind('focus', function(event){ mofs = 2; $(this).parent().addClass('show').parent().addClass('show'); }); if (!lower_res) $('.dropdown-subcontent a').bind('focusout', function(event){ mofs = 1; $(this).parent().removeClass('show'); remove_hidden_area($(this)); }); var size_of_div_out_of_border = function(elem) { } //Mozilla hover var moz_hover = function(pelem) { var elems = $(pelem).find('.menu_main_link'); if (elems.length > 0) $(elems).css('color', '#fff'); } var moz_hover_out = function(pelem) { var elems = $(pelem).find('.menu_main_link'); if (elems.length > 0) $(elems).css('color', ''); } // Mozilla end if (!lower_res) $('.head').bind('mouseleave focusout', function(event){ remove_sublinks(); }); } var back_menu_rebuild_top = []; var set_subarea = []; var set_mouseenter_params = []; var change_top_menu_hidden_left = []; function realWidth(obj){ var clone = obj.clone(); clone.css("visibility","hidden"); $('body').append(clone); var width = clone.outerWidth(); clone.remove(); return width; } var init_menu_more_mouse_actions_common = function(){ $('.head').unbind('mouseleave focusout'); $('.dropdown-subcontent a').unbind('focusout'); $('.dropdown-subcontent a').unbind('focus'); $('.dropdown-subcontent').unbind('mouseleave'); $('.dropdown-subcontent').unbind('mouseenter'); $('.menu_sublinks').unbind('mouseleave focusout'); $('.menu_sublinks').unbind('mouseenter focus'); $('.dropdown-content').unbind('mouseleave focusout'); $('.dropdown-content a').unbind('1focusout'); $('.dropdown-content a').unbind('focus'); $('.dropdown-content').unbind('mouseenter focus'); $('.dropbtn').unbind('mouseleave'); $('.dropbtn').unbind('mouseenter'); $('.dropbtn').unbind('focusout'); $('.dropbtn').unbind('focus'); $('.dropbtn').unbind('click'); $('.dropdown_wrapper_top_more .dropbtn').unbind('mouseenter focus'); $('.dropdown_wrapper_top_more .dropbtn').unbind('mouseleave'); $('.dropdown_wrapper_top_more .dropbtn').unbind('focusout'); $('.dropdown_wrapper_bottom_more .dropbtn').unbind('mouseenter focus'); $('.dropdown_wrapper_bottom_more .dropbtn').unbind('mouseleave'); $('.dropdown_wrapper_bottom_more .dropbtn').unbind('focusout'); $('.hidden_top_menu_elems').unbind('mouseenter'); $('.hidden_top_menu_elems').unbind('mouseleave'); $('.hidden_top_menu_elems').unbind('focus'); $('.hidden_top_menu_elems').unbind('focusout'); $('.hidden_bottom_menu_elems').unbind('mouseenter'); $('.hidden_bottom_menu_elems').unbind('mouseleave'); $('.hidden_bottom_menu_elems').unbind('focus'); $('.hidden_bottom_menu_elems').unbind('focusout'); $('.lower_resolution_right').unbind('mouseenter'); $('.lower_resolution_right').unbind('mouseleave'); $('.lower_resolution_right').unbind('focus'); $('.lower_resolution_right').unbind('focusout'); $('.lower_resolution_left').unbind('mouseenter'); $('.lower_resolution_left').unbind('mouseleave'); $('.lower_resolution_left').unbind('focus'); $('.lower_resolution_left').unbind('focusout'); $('.dropdown-subcontent2 a').unbind('focusout'); $('.dropdown-subcontent2 a').unbind('focus'); $('.dropdown-subcontent2').unbind('mouseleave'); $('.dropdown-subcontent2').unbind('mouseenter'); $('.dropdown-content2 a').unbind('focusout'); $('.dropdown-content2 a').unbind('focus'); $('.dropdown-content2').unbind('mouseleave'); $('.dropdown-content2').unbind('mouseenter'); init_menu_more_mouse_actions({'more_btn_class': '.dropdown_wrapper_top_more .dropbtn'/*'.dropbox_btn_wrapper_top'*/, 'hidden_area':'.hidden_top_menu_elems', 'hidden_area_instead':'.lower_resolution_right', 'link_more':'.dropdown_wrapper_top_more', 'func_prefix':1, 'offset_top_all_hidden_block':'65px', 'offset_left_all_hidden_block':'.dropdown_wrapper_top_more', 'submenu_elem_left':1, 'submenu_content':'.dropdown-content','menu_class': '.menu_second'}); init_menu_more_mouse_actions({'more_btn_class': '.dropdown_wrapper_bottom_more .dropbtn'/*'.dropbox_btn_wrapper'*/, 'hidden_area':'.hidden_bottom_menu_elems', 'hidden_area_instead':'.lower_resolution_left', 'link_more':'.dropdown_wrapper_bottom_more', 'func_prefix':2, 'offset_top_all_hidden_block':'190px', 'offset_left_all_hidden_block':'.dropdown_wrapper_bottom_more', 'submenu_elem_left':2, 'submenu_content':'.dropdown-content', 'menu_class': '.menu_first'}); } init_menu_more_mouse_actions_common(); $(document).bind('mouseover', function(event){ //console.log(event.target); }); window.onload = function() { } //Window resizing $( window ).bind('resize', function() { if (resizeid == 1) { //$('[tabIndex=2]').focus(); $('.head').css('width', $.fn.base_depot.window_clientarea_width()+'px'); resizeid = 2; menu_resize(); $.when($.when($.when($.when($.when($.when($.when($.fn.base_depot.change_top_menu_items(settings_top)).then($.fn.base_depot.change_top_menu_items(settings_bottom))). then($.when($.fn.base_depot.if_scroll_resize_top_level()).then(menu_resize()))).then(tb())).then( function (){ $.fn.base_depot.reformate_visible_and_hidden_area(settings_top); $.fn.base_depot.reformate_visible_and_hidden_area(settings_bottom); resizeid = 1; } )).then($.when(correct_menu_height()).then(correct_hidden_area_in_dom()))).then(lower_width_menu())).then($.when(check_lower_res()).then(subsubmenu_positioned())); init_menu_more_mouse_actions_common(); // $.fn.base_depot.zindex_reformate(); } }); //*********Tab index (NOT USED)**********/ var reoder_tab_index2 = function(){ } var cind=2; var reoder_tab_index = function(){ cind = reoder_tab_index_common('.menu_first .dropbtn', '.hidden_bottom_menu_elems', '.dropdown_wrapper_bottom_more .dropbtn', '.dropdown_wrapper_bottom_more', cind); cind = reoder_tab_index_common('.menu_second .dropbtn', '.hidden_top_menu_elems', '.dropdown_wrapper_top_more .dropbtn', '.dropdown_wrapper_top_more', cind); cind=2; } var reoder_tab_index_common = function(menubtn, hidden_layer, more_btn, not_count_parent, cind){ var topi; var res = []; res[0] = []; res[1] = []; $(document).find(menubtn).each(function(i,v){ topi = ($(v).hasParent(hidden_layer)) ? 0 : 1; if ($(v).hasParent(not_count_parent)){ if (res[topi] == undefined)res[topi] = []; if (v != undefined) res[topi].push(v); } }); $.each(res[0], function(o,r){ cind++; $(r).attr("tabIndex", cind); $(r).parent().next().find('a').each(function(j,w){ cind++; $(w).attr("tabIndex", cind); $(w).next().find('a').each(function(k,z){ cind++; $(z).attr("tabIndex", cind); }); }); }); cind++; $(more_btn).attr("tabIndex", cind); $.each(res[1], function(o,r){ cind++; $(r).attr("tabIndex", cind); $(r).parent().next().find('a').each(function(j,w){ cind++; $(w).attr("tabIndex", cind); $(w).next().find('a').each(function(k,z){ cind++; $(z).attr("tabIndex", cind); }); }); }); return cind; } /********Menu elements position corrections*************/ function correct_menu_position(elem) { if (($.fn.base_depot.window_clientarea_width() - elem.parent().offset().left < 160)&&(!elem.parents('.hidden_top_menu_elems').length)) elem.css('margin-left', -50); } function menu_resize() { $('.dropbox_btn_wrapper').css('width', $('.dropdown_wrapper').css('width')); $('.dropbox_btn_wrapper_top').css('width', $('.dropdown_wrapper_top').css('width')); } function subsubmenu_positioned() { (local_options.is_rtl == "1") ? $('.menu_first .dropdown-subcontent').each(function(i,v){ $(v).css('margin-left', $(v).parent().width()+'px'); }) : $('.menu_first .dropdown-subcontent').each(function(i,v){ $(v).css('margin-left', $(v).parent().width()+'px'); }); $('.menu_first .dropdown-subcontent').each(function(i,v){ $(v).css('margin-top', -1*($(v).prev().outerHeight(true))+'px'); }); (local_options.is_rtl == "1") ? $('.menu_second .dropdown-subcontent').each(function(i,v){ $(v).css('margin-left', -1*$(v).parent().width()+'px'); }) : $('.menu_second .dropdown-subcontent').each(function(i,v){ $(v).css('margin-left', -1*$(v).parent().width()+'px'); }); $('.menu_second .dropdown-subcontent').each(function(i,v){ $(v).css('margin-top', -1*($(v).prev().outerHeight(true))+'px'); }); } // Close the dropdown menu if the user clicks outside of it window.onfocus = function(event) { } var remove_sublinks = function (event, mof){ if (!mof) { $(".dropdown-content").removeClass("show"); } } });