Skip to content
This repository was archived by the owner on Oct 8, 2021. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
d9c6393
navbar: factor out grid start smart stacking
cgack May 23, 2014
f46af75
navbar: add morebutton extension and new demos
cgack May 23, 2014
bc0fae8
navbar: add morebutton icon, formatting
cgack May 23, 2014
456d16a
navbar: morebutton icon demo added
cgack May 23, 2014
f697f36
navbar: replace delegate with _on + formatting
cgack May 23, 2014
8213082
navbar: morebuttonicon as option
cgack Sep 30, 2015
05fbffd
navbar: css formatting
cgack May 27, 2014
8f167b1
navbar: add refresh method
cgack May 27, 2014
e54e44b
navbar: add _destroy and refactoring
cgack May 28, 2014
6a59139
navbar: remove grid tests - fix depracated ui-disabled test
cgack Sep 30, 2015
fc4122b
navbar: remove unused grid test
cgack May 29, 2014
772b899
navbar: update refresh method
cgack Jun 5, 2014
99efd56
navbar: add tests for maxbutton, refresh, and destroy
cgack Jun 5, 2014
1dd3ca9
navbar: tests and listview dependency
cgack Jun 13, 2014
0ec8ddb
Navbar: css update
cgack Jun 18, 2014
b29deef
Navbar: grid css cleanup and tuning
cgack Jul 3, 2014
9b05c1f
navbar: demo page updates
cgack Jul 3, 2014
7ee5fde
Navbar: Fix spacing on multiple rows and footers
cgack Jul 10, 2014
1653dcc
Navbar: Implement Classes and Review
cgack Aug 27, 2015
d67668a
Navbar: Classes Option
cgack Sep 10, 2015
105c938
Navbar: Classes Option
cgack Sep 10, 2015
0fa56f3
Navbar: Classes Option
cgack Sep 10, 2015
acec5d7
Navbar: Implement Classes Option
cgack Sep 30, 2015
5ffbe72
Navbar: Implement Classes Option
cgack Sep 30, 2015
245f827
Navbar: Implement Classes Option
cgack Oct 16, 2015
c53fefc
Navbar: Implement Classes Option
cgack Oct 16, 2015
33ff362
Navbar: Implement Classes Option
cgack Oct 16, 2015
408fe86
Navbar: Implement Classes Option
cgack Oct 16, 2015
f4d2dc8
Navbar: Implement Classes Option
cgack Oct 16, 2015
fa686ad
Navbar: Implement Classes Option
cgack Oct 17, 2015
346b5d0
Navbar: Implement Classes Option
cgack Oct 18, 2015
d8a71bf
Navbar: Implement Classes Option
cgack Oct 18, 2015
7d3b026
Navbar: Implement Classes Option
cgack Oct 18, 2015
6da2904
Navbar: Implement Classes Option
cgack Oct 18, 2015
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Navbar: Classes Option
jscs

Fixes gh-7705
  • Loading branch information
cgack committed Oct 29, 2015
commit 0fa56f3c92667e1b5a24f1ed422f623e888235a6
2 changes: 2 additions & 0 deletions build/tasks/options/jscs.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ module.exports = {
"js/widgets/listview.backcompat.js",
"js/widgets/listview.hidedividers.js",
"js/widgets/listview.js",
"js/widgets/navbar.js",
"js/widgets/navbar.morebutton.js",

// Tests
"tests/integration/listview/autodividers_core.js",
Expand Down
77 changes: 37 additions & 40 deletions js/widgets/navbar.morebutton.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,14 @@
"./navbar",
"./popup",
"./listview",
"../widget"], factory );
"../widget" ], factory );
} else {

// Browser globals
factory( jQuery );
}
} )( function( $ ) {


return $.widget( "mobile.navbar", $.mobile.navbar, {

options: {
Expand All @@ -43,7 +42,7 @@ return $.widget( "mobile.navbar", $.mobile.navbar, {
_create: function() {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove blank line

this._super();
if ( this.options.morebutton && this.numButtons > this.maxButton) {
if ( this.options.morebutton && this.numButtons > this.maxButton ) {
this._createNavPopup();
}
},
Expand All @@ -52,22 +51,21 @@ return $.widget( "mobile.navbar", $.mobile.navbar, {
return ( this.element.attr( "id" ) || ( this.widgetName + this.uuid ) );
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The 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,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

onevar

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The 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";

Expand All @@ -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 )
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should not go through nav you should do .popup( "open" )

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also make this a button

.attr( "data-rel", "popup" )
.button( {
icon: icon,
Expand All @@ -102,63 +100,62 @@ return $.widget( "mobile.navbar", $.mobile.navbar, {
popupDiv.appendTo( this.navbar );
popupDiv.popup();

$.extend(this, {
$.extend( this, {
moreButton: moreButton,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just do this.moreButton = moreButton; etc

popupDiv: popupDiv
});
} );
},

refresh: function() {
var newitems,
var newitems,
self = this,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The 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;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

onevar

if ( !self.options.morebutton ) {
self._super();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use this

return;
}

if ( self.popupDiv ) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use this

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();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use this

newitems.find( "a" ).each( function() {
self._makeNavButton( this, iconpos );
} );
newitems.appendTo( self.popupDiv.find( "ul" ) );
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use this

}
self._createNavPopup();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use this

},

_destroy: function() {
var navitems,
self = this;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dont use self

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The 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 ) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use this

self._super();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use this

return;
}

if ( self.popupDiv ) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use this

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() {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

all of the above should be this

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 );
});
} );
}
}
});
});
} );

} );