Optimize dropdown global naviagtion script

git-svn-id: http://xe-core.googlecode.com/svn/branches/1.5.0@9155 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
taggon 2011-09-15 08:11:47 +00:00
parent ea20e214ba
commit 11ef717017
4 changed files with 89 additions and 100 deletions

View file

@ -53,50 +53,6 @@ jQuery(function($){
.trigger('update.checkbox', [name, this.checked]);
});
// Global Navigation Bar
var $menuitems = $('div.gnb')
.removeClass('jx')
.attr('role', 'navigation') // WAI-ARIA role
.find('li')
.attr('role', 'menuitem') // WAI-ARIA role
.filter(':has(>ul)')
.attr('aria-haspopup', 'true') // WAI-ARIA
.find('>ul').hide().end()
.mouseover(function(){
var $this = $(this);
if($this.css('float') == 'left') $this.find('>ul:hidden').prev('a').click();
})
.mouseleave(function(){
var $this = $(this);
if($this.css('float') == 'left') $this.find('>ul:visible').slideUp(100);
})
.find('>a')
.focus(function(){ $(this).click() })
.click(function(){
$menuitems.removeClass('active');
$(this)
.next('ul').slideToggle(100).end()
.parent().addClass('active');
return false;
})
.end()
.end()
.find('>a')
.blur(function(){
var anchor = this;
setTimeout(function(){
var $a = $(anchor), $ul = $a.closest('ul'), $focus = $ul.find('a:focus');
if(!$focus.length || $focus.closest('ul').parent('div.gnb').length) {
if($ul.parent('div.gnb').length) $ul = $a.next('ul');
$ul.filter(':visible').slideUp(100);
}
}, 10);
})
.end()
// pagination
$.fn.xePagination = function(){
this
@ -180,6 +136,54 @@ jQuery(function($){
$('.masked').xeMask();
});
// Global Navigation Bar
jQuery(function($){
$.fn.xeMenu = function(){
this
.removeClass('jx')
.attr('role', 'navigation') // WAI-ARIA role
.find('li')
.attr('role', 'menuitem') // WAI-ARIA role
.find('>ul').hide().end()
.filter(':has(>ul)')
.attr('aria-haspopup', 'true') // WAI-ARIA
.end()
.end()
.delegate('li', {
mouseover : function(){
$(this)
.addClass('active')
.find('>ul').show().end()
.parentsUntil('.gnb')
.filter('li').addClass('active').end()
.end()
},
mouseleave : function(){
$(this)
.removeClass('active')
.find('>ul').hide();
},
focusout : function(){
var $this = $(this);
setTimeout(function(){
if(!$this.find(':focus').length) {
$this.removeClass('active').find('>ul').hide();
}
}, 1);
}
})
.delegate('a', {
focus : function(){
$(this).parent('li').mouseover();
}
});
};
$('div.gnb').xeMenu();
});
// Modal Window
jQuery(function($){