| //>>excludeStart("jqmBuildExclude", pragmas.jqmBuildExclude); |
| //>>description: Formats groups of links as horizontal navigation bars. |
| //>>label: Navbars |
| //>>group: Widgets |
| //>>css.structure: ../css/structure/jquery.mobile.navbar.css |
| //>>css.theme: ../css/themes/default/jquery.mobile.theme.css |
| |
| |
| define( [ "jquery", "../jquery.mobile.widget", "../jquery.mobile.buttonMarkup", "../jquery.mobile.grid" ], function( jQuery ) { |
| //>>excludeEnd("jqmBuildExclude"); |
| (function( $, undefined ) { |
| |
| $.widget( "mobile.navbar", $.mobile.widget, { |
| options: { |
| iconpos: "top", |
| grid: null, |
| initSelector: ":jqmData(role='navbar')" |
| }, |
| |
| _create: function() { |
| |
| var $navbar = this.element, |
| $navbtns = $navbar.find( "a" ), |
| iconpos = $navbtns.filter( ":jqmData(icon)" ).length ? |
| this.options.iconpos : undefined; |
| |
| $navbar.addClass( "ui-navbar ui-mini" ) |
| .attr( "role", "navigation" ) |
| .find( "ul" ) |
| .jqmEnhanceable() |
| .grid({ grid: this.options.grid }); |
| |
| $navbtns.buttonMarkup({ |
| corners: false, |
| shadow: false, |
| inline: true, |
| iconpos: iconpos |
| }); |
| |
| $navbar.delegate( "a", "vclick", function( event ) { |
| if ( !$(event.target).hasClass( "ui-disabled" ) ) { |
| $navbtns.removeClass( $.mobile.activeBtnClass ); |
| $( this ).addClass( $.mobile.activeBtnClass ); |
| } |
| }); |
| |
| // Buttons in the navbar with ui-state-persist class should regain their active state before page show |
| $navbar.closest( ".ui-page" ).bind( "pagebeforeshow", function() { |
| $navbtns.filter( ".ui-state-persist" ).addClass( $.mobile.activeBtnClass ); |
| }); |
| } |
| }); |
| |
| //delegate auto self-init widgets |
| $.delegateSelfInitWithSingleSelector( $.mobile.navbar ); |
| |
| })( jQuery ); |
| //>>excludeStart("jqmBuildExclude", pragmas.jqmBuildExclude); |
| }); |
| //>>excludeEnd("jqmBuildExclude"); |