jquery-mobile/js/jquery.mobile.navbar.js

57 lines
1.3 KiB
JavaScript
Raw Normal View History

/*
* "navbar" plugin
*/
//>>excludeStart("jqmBuildExclude", pragmas.jqmBuildExclude);
define( [ "jquery.mobile.widget", "jquery.mobile.buttonMarkup" ], function() {
//>>excludeEnd("jqmBuildExclude");
(function( $, undefined ) {
2010-10-28 01:58:00 +00:00
$.widget( "mobile.navbar", $.mobile.widget, {
options: {
2011-06-29 05:17:41 +00:00
iconpos: "top",
grid: null,
initSelector: ":jqmData(role='navbar')"
2010-10-28 01:58:00 +00:00
},
2010-10-28 01:58:00 +00:00
_create: function(){
2010-10-28 01:58:00 +00:00
var $navbar = this.element,
$navbtns = $navbar.find( "a" ),
iconpos = $navbtns.filter( ":jqmData(icon)" ).length ?
this.options.iconpos : undefined;
$navbar.addClass( "ui-navbar" )
2011-06-29 05:17:41 +00:00
.attr( "role","navigation" )
.find( "ul" )
.grid({ grid: this.options.grid });
if ( !iconpos ) {
$navbar.addClass( "ui-navbar-noicons" );
2010-10-28 01:58:00 +00:00
}
$navbtns.buttonMarkup({
corners: false,
shadow: false,
iconpos: iconpos
});
$navbar.delegate( "a", "vclick", function( event ) {
if( !$(event.target).hasClass("ui-disabled") ) {
$navbtns.not( ".ui-state-persist" ).removeClass( $.mobile.activeBtnClass );
$( this ).addClass( $.mobile.activeBtnClass );
}
});
2010-10-28 01:58:00 +00:00
}
});
//auto self-init widgets
$( document ).bind( "pagecreate create", function( e ){
$( $.mobile.navbar.prototype.options.initSelector, e.target ).navbar();
});
})( jQuery );
//>>excludeStart("jqmBuildExclude", pragmas.jqmBuildExclude);
2011-10-31 05:03:56 +00:00
});
//>>excludeEnd("jqmBuildExclude");