jquery-mobile/js/jQuery.globalnav.js
2010-09-14 12:57:03 -04:00

34 lines
No EOL
1.2 KiB
JavaScript
Executable file

/*
* jQuery Mobile Framework : prototype for "globalnav" plugin
* Copyright (c) jQuery Project
* Dual licensed under the MIT (MIT-LICENSE.txt) and GPL (GPL-LICENSE.txt) licenses.
* Note: Code is in draft form and is subject to change
*/
(function($){
$.fn.globalnav = function(settings){
return $(this).each(function(){ //there should only ever be one of these... is each necessary?
var o = $.extend({
fixedAs: 'footer'
},settings);
//wrap it with footer classes
var globalnav = $(this).wrap('<div class="ui-bar-a"></div>').parent().addClass(o.fixedAs == 'footer' ? 'ui-footer' : 'ui-header');
//apply fixed footer markup to ui-footer
$(document).fixHeaderFooter();
//set up the nav tabs widths (currently evenly divided widths, to be improved later)
var navtabs = globalnav.find('li');
navtabs.width(100/navtabs.length+'%');
//apply state on click and at load
//NOTE: we'll need to find a way to highlight an active tab at load as well
navtabs.find('a')
.buttonMarkup({corners: false, iconPos: 'top', icon: 'arrow-u'})
.bind('tap',function(){
navtabs.find('.ui-btn-active').removeClass('ui-btn-active');
$(this).addClass('ui-btn-active');
});
});
};
})(jQuery);