d5e094e3f6afcf1cf01d46bd4a4c1ca581426cd0
[platform/framework/web/web-ui-fw.git] / libs / js / jquery-mobile-1.0.1pre / js / jquery.mobile.navbar.js
1 /*
2 * "navbar" plugin
3 */
4
5 (function( $, undefined ) {
6
7 $.widget( "mobile.navbar", $.mobile.widget, {
8         options: {
9                 iconpos: "top",
10                 grid: null,
11                 initSelector: ":jqmData(role='navbar')"
12         },
13
14         _create: function(){
15
16                 var $navbar = this.element,
17                         $navbtns = $navbar.find( "a" ),
18                         iconpos = $navbtns.filter( ":jqmData(icon)" ).length ?
19                                                                         this.options.iconpos : undefined;
20
21                 $navbar.addClass( "ui-navbar" )
22                         .attr( "role","navigation" )
23                         .find( "ul" )
24                                 .grid({ grid: this.options.grid });
25
26                 if ( !iconpos ) {
27                         $navbar.addClass( "ui-navbar-noicons" );
28                 }
29
30                 $navbtns.buttonMarkup({
31                         corners:        false,
32                         shadow:         false,
33                         iconpos:        iconpos
34                 });
35
36                 $navbar.delegate( "a", "vclick", function( event ) {
37                         $navbtns.not( ".ui-state-persist" ).removeClass( $.mobile.activeBtnClass );
38                         $( this ).addClass( $.mobile.activeBtnClass );
39                 });
40         }
41 });
42
43 //auto self-init widgets
44 $( document ).bind( "pagecreate create", function( e ){
45         $( $.mobile.navbar.prototype.options.initSelector, e.target ).navbar();
46 });
47
48 })( jQuery );