Skip to content
This repository has been archived by the owner on Oct 8, 2021. It is now read-only.

Commit

Permalink
Navbar: Add classes option
Browse files Browse the repository at this point in the history
Fixes gh-7705
  • Loading branch information
Gabriel Schulhof committed Oct 17, 2014
1 parent c290839 commit 8d4e8fd
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
5 changes: 4 additions & 1 deletion js/widgets/navbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ define( [ "jquery", "../widget", "../grid" ], function( jQuery ) {

$.widget( "mobile.navbar", {
options: {
classes: {
"ui-navbar": null
},
iconpos: "top",
grid: null
},
Expand All @@ -21,7 +24,7 @@ $.widget( "mobile.navbar", {
$navbtns = $navbar.find( "a, button" ),
iconpos = $navbtns.filter( ":jqmData(icon)" ).length ? this.options.iconpos : undefined;

$navbar.addClass( "ui-navbar" )
$navbar.addClass( this._classes( "ui-navbar" ) )
.attr( "role", "navigation" )
.find( "ul" )
.jqmEnhanceable()
Expand Down
1 change: 0 additions & 1 deletion tests/unit/navbar/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
$.testHelper.asyncLoad([
[ "widgets/page" ],
[
"buttonMarkup",
"widgets/navbar"
],
[ "init" ],
Expand Down
12 changes: 7 additions & 5 deletions tests/unit/navbar/navbar_core.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,15 @@
});

test( "classes are correctly assigned", function() {
var $ul = $('#enhanced-classes'),
r = $ul.find("li").eq(0).find("a"),
d = $ul.find("li").eq(1).find("a"),
u = $ul.find("li").eq(2).find("a");
var ul = $('#enhanced-classes'),
r = ul.find("li").eq(0).find("a"),
d = ul.find("li").eq(1).find("a"),
u = ul.find("li").eq(2).find("a");

deepEqual( ul.parent().hasClass( "ui-navbar" ), true, "navbar has class 'ui-navbar'" );

ok(r.hasClass("ui-icon-arrow-r") && !r.hasClass("ui-icon-arrow-d") && !r.hasClass("ui-icon-arrow-u"),"first item only has class of arrow-r");
ok(!d.hasClass("ui-icon-arrow-r") && d.hasClass("ui-icon-arrow-d") && !d.hasClass("ui-icon-arrow-u"),"second item only has class of arrow-d");
ok(!u.hasClass("ui-icon-arrow-r") && !u.hasClass("ui-icon-arrow-d") && u.hasClass("ui-icon-arrow-u"),"third item only has class of arrow-u");
});
})(jQuery);
})(jQuery);

0 comments on commit 8d4e8fd

Please sign in to comment.