-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Navbar: Implement Classes Option #8297
Changes from 1 commit
d9c6393
f46af75
bc0fae8
456d16a
f697f36
8213082
05fbffd
8f167b1
e54e44b
6a59139
fc4122b
772b899
99efd56
1dd3ca9
0ec8ddb
b29deef
9b05c1f
7ee5fde
1653dcc
d67668a
105c938
0fa56f3
acec5d7
5ffbe72
245f827
c53fefc
33ff362
408fe86
f4d2dc8
fa686ad
346b5d0
d8a71bf
7d3b026
6da2904
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
jscs Fixes gh-7705
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,15 +22,14 @@ | |
| "./navbar", | ||
| "./popup", | ||
| "./listview", | ||
| "../widget"], factory ); | ||
| "../widget" ], factory ); | ||
| } else { | ||
|
|
||
| // Browser globals | ||
| factory( jQuery ); | ||
| } | ||
| } )( function( $ ) { | ||
|
|
||
|
|
||
| return $.widget( "mobile.navbar", $.mobile.navbar, { | ||
|
|
||
| options: { | ||
|
|
@@ -43,7 +42,7 @@ return $.widget( "mobile.navbar", $.mobile.navbar, { | |
| _create: function() { | ||
|
|
||
| this._super(); | ||
| if ( this.options.morebutton && this.numButtons > this.maxButton) { | ||
| if ( this.options.morebutton && this.numButtons > this.maxButton ) { | ||
| this._createNavPopup(); | ||
| } | ||
| }, | ||
|
|
@@ -52,22 +51,21 @@ return $.widget( "mobile.navbar", $.mobile.navbar, { | |
| return ( this.element.attr( "id" ) || ( this.widgetName + this.uuid ) ); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove unneeded parens |
||
| }, | ||
|
|
||
| _createNavRows: function () { | ||
| _createNavRows: function() { | ||
| if ( this.options.morebutton ) { | ||
| return; | ||
| } | ||
|
|
||
| this._super(); | ||
| }, | ||
|
|
||
| _createNavPopup: function(){ | ||
| _createNavPopup: function() { | ||
| var popupDiv, popupNav, moreButton, pos, buttonItem, id, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. onevar
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. with onevar gone declare pos in the for loop directly |
||
| navItems = this.navbar.find( "li" ), | ||
| buttonCount = navItems.length, | ||
| maxButton = this.maxButton, | ||
| iconpos = this.iconpos, | ||
| icon = this.options.morebuttonicon, | ||
| classes = "ui-button"; | ||
| icon = this.options.morebuttonicon; | ||
|
|
||
| id = this._id() + "-popup"; | ||
|
|
||
|
|
@@ -76,13 +74,13 @@ return $.widget( "mobile.navbar", $.mobile.navbar, { | |
| .appendTo( popupDiv ); | ||
|
|
||
| // enhance buttons and move to new rows | ||
| for( pos = 0; pos < buttonCount; pos++ ) { | ||
| buttonItem = navItems.eq(pos); | ||
| this._makeNavButton(buttonItem.find("a"), iconpos); | ||
| if (pos + 1 === maxButton) { | ||
| for ( pos = 0; pos < buttonCount; pos++ ) { | ||
| buttonItem = navItems.eq( pos ); | ||
| this._makeNavButton( buttonItem.find( "a" ), iconpos ); | ||
| if ( pos + 1 === maxButton ) { | ||
|
|
||
| moreButton = $( "<li></li>" ).append( $( "<a></a>" ) | ||
| .attr( "href", "#" + id) | ||
| .attr( "href", "#" + id ) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this should not go through nav you should do
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. also make this a |
||
| .attr( "data-rel", "popup" ) | ||
| .button( { | ||
| icon: icon, | ||
|
|
@@ -102,63 +100,62 @@ return $.widget( "mobile.navbar", $.mobile.navbar, { | |
| popupDiv.appendTo( this.navbar ); | ||
| popupDiv.popup(); | ||
|
|
||
| $.extend(this, { | ||
| $.extend( this, { | ||
| moreButton: moreButton, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. just do |
||
| popupDiv: popupDiv | ||
| }); | ||
| } ); | ||
| }, | ||
|
|
||
| refresh: function() { | ||
| var newitems, | ||
| var newitems, | ||
| self = this, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. dont use self |
||
| iconpos = self.iconpos; | ||
| if (!self.options.morebutton) { | ||
| self._super(); | ||
| return; | ||
| } | ||
| iconpos = self.iconpos; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. onevar |
||
| if ( !self.options.morebutton ) { | ||
| self._super(); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. use |
||
| return; | ||
| } | ||
|
|
||
| if ( self.popupDiv ) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. use |
||
| newitems = self.moreButton.parent().nextAll(); | ||
| newitems.find("a").each(function() { | ||
| self._makeNavButton(this, iconpos); | ||
| }); | ||
| newitems.appendTo(self.popupDiv.find("ul")); | ||
| } | ||
| newitems = self.moreButton.parent().nextAll(); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. use |
||
| newitems.find( "a" ).each( function() { | ||
| self._makeNavButton( this, iconpos ); | ||
| } ); | ||
| newitems.appendTo( self.popupDiv.find( "ul" ) ); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. use |
||
| } | ||
| self._createNavPopup(); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. use |
||
| }, | ||
|
|
||
| _destroy: function() { | ||
| var navitems, | ||
| self = this; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. dont use self
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. no context switches here remove completely |
||
|
|
||
|
|
||
| if (!self.options.morebutton) { | ||
| if ( !self.options.morebutton ) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. use |
||
| self._super(); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. use |
||
| return; | ||
| } | ||
|
|
||
| if ( self.popupDiv ) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. use |
||
| navitems = self.popupDiv.find("li").detach(); | ||
| navitems = self.popupDiv.find( "li" ).detach(); | ||
| self.popupDiv.remove(); | ||
| self.moreButton.parent().remove(); | ||
| self.navbar.find("ul").append(navitems); | ||
| self.navbar.find( "ul" ).append( navitems ); | ||
| self.navbar.removeClass( "ui-navbar" ); | ||
| self.navButtons = self.navbar.find("a"); | ||
| self.navButtons.each(function() { | ||
| self.navButtons = self.navbar.find( "a" ); | ||
| self.navButtons.each( function() { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. all of the above should be |
||
| var icon = $.mobile.getAttribute( this, "icon" ), | ||
| theme = $.mobile.getAttribute( this, "theme" ), | ||
| classes = "ui-btn"; | ||
| classes = "ui-button"; | ||
|
|
||
| if ( theme ) { | ||
| classes += " ui-btn-" + theme; | ||
| classes += " ui-button-" + theme; | ||
| } | ||
| if ( icon ) { | ||
| classes += " ui-icon-" + icon + " ui-btn-icon-" + self.iconpos; | ||
| classes += " ui-icon-" + icon + " ui-button-icon-" + self.iconpos; | ||
| } | ||
| $( this ).removeClass( classes ); | ||
| }); | ||
| } ); | ||
| } | ||
| } | ||
| }); | ||
| }); | ||
| } ); | ||
|
|
||
| } ); | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove blank line