| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182 |
- <script language="javascript">
- $(document).ready(function () {
- bx_activate_anim_icons('#283C50');
- var aSidebars = ['site', 'account'];
- for(var i in aSidebars) {
- if(typeof(aSidebars[i]) != 'string')
- continue;
- var oSidebar = bx_sidebar_get(aSidebars[i]);
- $('.bx-sidebar-' + aSidebars[i] + '-trigger').on('click', function(event) {
- event.preventDefault();
- var aMatches = $(this).attr('class').match(/bx-sidebar-(.*)-trigger/);
- if(!aMatches || aMatches.length != 2)
- return;
- bx_sidebar_toggle(aMatches[1]);
- });
- $('.bx-sidebar .bx-sidebar-' + aSidebars[i] + '-bg').on('click', function(event){
- event.preventDefault();
- var aMatches = $(this).attr('class').match(/bx-sidebar-(.*)-bg/);
- if(!aMatches || aMatches.length != 2)
- return;
-
- bx_sidebar_toggle(aMatches[1]);
- });
- $('.bx-sidebar .bx-sidebar-' + aSidebars[i] + '-close').on('click', function(event){
- event.preventDefault();
- var aMatches = $(this).attr('class').match(/bx-sidebar-(.*)-close/);
- if(!aMatches || aMatches.length != 2)
- return;
- bx_sidebar_toggle(aMatches[1]);
- });
- $('.bx-sidebar.bx-sidebar-' + aSidebars[i] + ' .bx-focus-trap').bind('focus', function() {
- var aFocusable = bx_get_focusable(oSidebar.get(0));
- if(aFocusable && aFocusable.length > 0)
- $(aFocusable[0]).focus();
- });
- }
- //--- Escape closes whichever sidebar is open; bx_sidebar_toggle returns focus to its trigger.
- $(document).on('keydown.bx-sidebar', function(event) {
- if(event.which != 27 && event.key != 'Escape')
- return;
- for(var j in aSidebars) {
- if(typeof(aSidebars[j]) != 'string' || !bx_sidebar_active(aSidebars[j]))
- continue;
- event.preventDefault();
- bx_sidebar_toggle(aSidebars[j]);
- }
- });
- });
- function bx_sidebar_get(sType) {
- return $('.bx-sidebar.bx-sidebar-' + sType);
- }
- function bx_sidebar_active(sType) {
- var oSidebar = bx_sidebar_get(sType);
- if(!oSidebar || oSidebar.length == 0)
- return false;
- return oSidebar.hasClass('bx-sidebar-active');
- }
- function bx_sidebar_toggle(sType) {
- var oSidebar = bx_sidebar_get(sType);
- var bSidebarActive = bx_sidebar_active(sType);
- // A drawer opening or closing (interface sounds, see bx_sound).
- if(typeof(bx_sound) == 'function')
- bx_sound(bSidebarActive ? 'close' : 'open');
- oSidebar.toggleClass('bx-sidebar-active', !bSidebarActive);
- var oTrigger = $('.bx-sidebar-' + sType + '-trigger');
- oTrigger.attr('aria-expanded', !bSidebarActive ? 'true' : 'false');
- if(!bSidebarActive) {
- var aFocusable = bx_get_focusable(oSidebar.get(0));
- if(aFocusable && aFocusable.length > 0)
- $(aFocusable[0]).focus();
- }
- else {
- var oReturnTo = bx_clicked_stack_pop();
- $(oReturnTo || oTrigger.filter(':visible').get(0)).focus();
- }
- }
- function bx_sidebar_dropdown_toggle(oLink) {
- var oItem = $(oLink).parents('.bx-sidebar-item:first');
- oItem.toggleClass('bx-si-dropdown-open').find('.bx-si-dropdown-icon').toggleClass('rotate-0 rotate-90');
- $(oLink).attr('aria-expanded', oItem.hasClass('bx-si-dropdown-open') ? 'true' : 'false');
- return false;
- }
- /**
- * The 'search' item of the member toolbar opens the floating search bar (#bx-ti-search-box), which takes the item's place until a click outside or Escape.
- */
- function bx_site_search_show(oLink) {
- var oBox = $('#bx-ti-search-box');
- if(!oBox.length)
- return;
- $(oLink).attr('aria-expanded', 'true').parents('.bx-menu-toolbar-item:first').addClass('bx-tis-button-hidden');
- oBox.addClass('bx-tis-box-shown');
- oBox.find('.bx-form-input-text').focus();
- setTimeout(function () {
- $(document).on('click.bx-site-search-box touchend.bx-site-search-box', function (event) {
- if(!$(event.target).closest('.sys-search-results-quick,.bx-ti-search-box').length)
- bx_site_search_hide();
- });
- }, 10);
- }
- function bx_site_search_hide() {
- var oBox = $('#bx-ti-search-box');
- if(!oBox.hasClass('bx-tis-box-shown'))
- return;
- $(document).off('.bx-site-search-box');
- bx_site_search_close_all_opened();
- oBox.removeClass('bx-tis-box-shown');
- $('.bx-tis-button-hidden').removeClass('bx-tis-button-hidden').find('a[aria-controls="bx-ti-search-box"]').attr('aria-expanded', 'false').focus();
- }
- function bx_site_search_complete(oContainer, oData) {
- if(!oData) {
- if(oContainer.is(':visible'))
- oContainer.hide();
- return;
- }
- oContainer.show();
- setTimeout(function () {
- var iWidthPrev = $(window).width();
- $(window).on('resize.bx-site-search', function () {
- if($(this).width() == iWidthPrev)
- return;
- iWidthPrev = $(this).width();
- bx_site_search_close_all_opened();
- });
-
- $(document).on('click.bx-site-search touchend.bx-site-search', function (event) {
- if ($(event.target).parents('.sys-search-results-quick').length || $(event.target).filter('.sys-search-results-quick').length || e === event.target)
- event.stopPropagation();
- else
- bx_site_search_close_all_opened();
- });
- }, 10);
- }
- function bx_site_search_cancel(oForm)
- {
- if($(oForm).parents('#bx-ti-search-box').length)
- bx_site_search_hide();
- }
- function bx_site_search_close_all_opened() {
- $('.sys-search-results-quick:visible').each(function () {
- $(this).hide();
- });
- }
- </script>
|