Skip to content

Commit 5d6a33c

Browse files
committed
style(*): jscs linter updates to nav improvements
1 parent 2b23957 commit 5d6a33c

19 files changed

Lines changed: 145 additions & 150 deletions

js/angular/controller/headerBarController.js

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ function($scope, $element, $attrs, $q, $ionicConfig, $ionicHistory) {
5454

5555
self.titleTextWidth = function() {
5656
if (!titleTextWidth) {
57-
var bounds = ionic.DomUtil.getTextBounds( getEle(TITLE) );
57+
var bounds = ionic.DomUtil.getTextBounds(getEle(TITLE));
5858
titleTextWidth = Math.min(bounds && bounds.width || 30);
5959
}
6060
return titleTextWidth;
@@ -84,7 +84,7 @@ function($scope, $element, $attrs, $q, $ionicConfig, $ionicHistory) {
8484
self.backButtonTextLeft = function() {
8585
var offsetLeft = 0;
8686
var ele = getEle(BACK_TEXT);
87-
while(ele) {
87+
while (ele) {
8888
offsetLeft += ele.offsetLeft;
8989
ele = ele.parentElement;
9090
}
@@ -93,7 +93,7 @@ function($scope, $element, $attrs, $q, $ionicConfig, $ionicHistory) {
9393

9494

9595
self.resetBackButton = function() {
96-
if ( $ionicConfig.backButton.previousTitleText() ) {
96+
if ($ionicConfig.backButton.previousTitleText()) {
9797
var previousTitleEle = getEle(PREVIOUS_TITLE);
9898
if (previousTitleEle) {
9999
previousTitleEle.classList.remove(HIDE);
@@ -119,7 +119,7 @@ function($scope, $element, $attrs, $q, $ionicConfig, $ionicHistory) {
119119

120120
var widths = self.calcWidths(align, false);
121121

122-
if ( isBackShown && previousTitleText && $ionicConfig.backButton.previousTitleText() ) {
122+
if (isBackShown && previousTitleText && $ionicConfig.backButton.previousTitleText()) {
123123
var previousTitleWidths = self.calcWidths(align, true);
124124

125125
var availableTitleWidth = $element[0].offsetWidth - previousTitleWidths.titleLeft - previousTitleWidths.titleRight;
@@ -176,10 +176,10 @@ function($scope, $element, $attrs, $q, $ionicConfig, $ionicHistory) {
176176
d = b.children[z];
177177

178178
if (isPreviousTitle) {
179-
if ( d.classList.contains(DEFAULT_TITLE) ) continue;
179+
if (d.classList.contains(DEFAULT_TITLE)) continue;
180180
backButtonWidth += d.offsetWidth;
181181
} else {
182-
if ( d.classList.contains(PREVIOUS_TITLE) ) continue;
182+
if (d.classList.contains(PREVIOUS_TITLE)) continue;
183183
backButtonWidth += d.offsetWidth;
184184
}
185185
}
@@ -283,7 +283,7 @@ function($scope, $element, $attrs, $q, $ionicConfig, $ionicHistory) {
283283
defaultTitle && defaultTitle.classList[ showPreviousTitle ? 'add' : 'remove'](HIDE);
284284
}
285285

286-
ionic.requestAnimationFrame(function(){
286+
ionic.requestAnimationFrame(function() {
287287
if (titleEle && titleEle.offsetWidth + 10 < titleEle.scrollWidth) {
288288
var minRight = buttonsRight + 5;
289289
var testRight = $element[0].offsetWidth - titleLeft - self.titleTextWidth() - 20;
@@ -301,7 +301,7 @@ function($scope, $element, $attrs, $q, $ionicConfig, $ionicHistory) {
301301

302302

303303
self.setCss = function(elementClassname, css) {
304-
ionic.DomUtil.cachedStyles( getEle(elementClassname), css);
304+
ionic.DomUtil.cachedStyles(getEle(elementClassname), css);
305305
};
306306

307307

@@ -315,8 +315,7 @@ function($scope, $element, $attrs, $q, $ionicConfig, $ionicHistory) {
315315

316316

317317
$scope.$on('$destroy', function() {
318-
for(var n in eleCache) eleCache[n] = null;
318+
for (var n in eleCache) eleCache[n] = null;
319319
});
320320

321321
}]);
322-

js/angular/controller/navBarController.js

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,10 @@ function($scope, $element, $attrs, $compile, $timeout, $ionicNavBarDelegate, $io
4444

4545

4646
self.createHeaderBar = function(isActive, navBarClass) {
47-
var containerEle = jqLite( '<div class="nav-bar-block">' );
47+
var containerEle = jqLite('<div class="nav-bar-block">');
4848
ionic.DomUtil.cachedAttr(containerEle, 'nav-bar', isActive ? 'active' : 'cached');
4949

50-
var headerBarEle = jqLite( '<ion-header-bar>' ).addClass($attrs.class);
50+
var headerBarEle = jqLite('<ion-header-bar>').addClass($attrs.class);
5151
var titleEle = jqLite('<div class="title title-' + $ionicConfig.navBar.alignTitle() + '">');
5252
var navEle = {};
5353
var lastViewBtnsEle = {};
@@ -60,7 +60,7 @@ function($scope, $element, $attrs, $compile, $timeout, $ionicNavBarDelegate, $io
6060
// append title in the header, this is the rock to where buttons append
6161
headerBarEle.append(titleEle);
6262

63-
forEach(BUTTON_TYPES, function(buttonType){
63+
forEach(BUTTON_TYPES, function(buttonType) {
6464
// create default button elements
6565
navEle[buttonType] = createNavElement(buttonType);
6666
// append and position buttons
@@ -69,7 +69,7 @@ function($scope, $element, $attrs, $compile, $timeout, $ionicNavBarDelegate, $io
6969

7070
// compile header and append to the DOM
7171
containerEle.append(headerBarEle);
72-
$element.append( $compile(containerEle)($scope.$new()) );
72+
$element.append($compile(containerEle)($scope.$new()));
7373

7474
var headerBarCtrl = headerBarEle.data('$ionHeaderBarController');
7575

@@ -114,7 +114,7 @@ function($scope, $element, $attrs, $compile, $timeout, $ionicNavBarDelegate, $io
114114
return headerBarEle;
115115
},
116116
afterLeave: function() {
117-
forEach(BUTTON_TYPES, function(buttonType){
117+
forEach(BUTTON_TYPES, function(buttonType) {
118118
headerBarInstance.removeButtons(buttonType);
119119
});
120120
headerBarCtrl.resetBackButton();
@@ -123,7 +123,7 @@ function($scope, $element, $attrs, $compile, $timeout, $ionicNavBarDelegate, $io
123123
return headerBarCtrl;
124124
},
125125
destroy: function() {
126-
forEach(BUTTON_TYPES, function(buttonType){
126+
forEach(BUTTON_TYPES, function(buttonType) {
127127
headerBarInstance.removeButtons(buttonType);
128128
});
129129
containerEle.scope().$destroy();
@@ -187,7 +187,7 @@ function($scope, $element, $attrs, $compile, $timeout, $ionicNavBarDelegate, $io
187187

188188

189189
self.navElement = function(type, html) {
190-
if ( isDefined(html) ) {
190+
if (isDefined(html)) {
191191
navElementHtml[type] = html;
192192
}
193193
return navElementHtml[type];
@@ -214,7 +214,7 @@ function($scope, $element, $attrs, $compile, $timeout, $ionicNavBarDelegate, $io
214214

215215
// update the buttons, depending if the view has their own or not
216216
if (viewData.buttons) {
217-
forEach(BUTTON_TYPES, function(buttonType){
217+
forEach(BUTTON_TYPES, function(buttonType) {
218218
enteringHeaderBar.setButtons(viewData.buttons[buttonType], buttonType);
219219
});
220220
}
@@ -238,7 +238,7 @@ function($scope, $element, $attrs, $compile, $timeout, $ionicNavBarDelegate, $io
238238
ionic.DomUtil.cachedAttr($element, 'nav-bar-transition', $ionicConfig.navBar.transition());
239239
ionic.DomUtil.cachedAttr($element, 'nav-bar-direction', viewData.direction);
240240

241-
if(navBarTransition.shouldAnimate) {
241+
if (navBarTransition.shouldAnimate) {
242242
navBarAttr(enteringHeaderBar, 'stage');
243243
} else {
244244
navBarAttr(enteringHeaderBar, 'entering');
@@ -261,7 +261,7 @@ function($scope, $element, $attrs, $compile, $timeout, $ionicNavBarDelegate, $io
261261

262262
queuedTransitionEnd = function() {
263263
if (latestTransitionId == transitionId || !navBarTransition.shouldAnimate) {
264-
for (var x=0; x<headerBars.length; x++) {
264+
for (var x = 0; x < headerBars.length; x++) {
265265
headerBars[x].isActive = false;
266266
}
267267
enteringHeaderBar.isActive = true;
@@ -313,7 +313,7 @@ function($scope, $element, $attrs, $compile, $timeout, $ionicNavBarDelegate, $io
313313
self.visibleBar(val);
314314

315315
// set non primary to hide second
316-
for (var x=0; x<$ionicNavBarDelegate._instances.length; x++) {
316+
for (var x = 0; x < $ionicNavBarDelegate._instances.length; x++) {
317317
if ($ionicNavBarDelegate._instances[x] !== self) $ionicNavBarDelegate._instances[x].visibleBar(false);
318318
}
319319
};
@@ -338,21 +338,21 @@ function($scope, $element, $attrs, $compile, $timeout, $ionicNavBarDelegate, $io
338338

339339

340340
function createNavElement(type) {
341-
if ( navElementHtml[type] ) {
341+
if (navElementHtml[type]) {
342342
return jqLite(navElementHtml[type]);
343343
}
344344
}
345345

346346

347347
function getOnScreenHeaderBar() {
348-
for (var x=0; x<headerBars.length; x++) {
348+
for (var x = 0; x < headerBars.length; x++) {
349349
if (headerBars[x].isActive) return headerBars[x];
350350
}
351351
}
352352

353353

354354
function getOffScreenHeaderBar() {
355-
for (var x=0; x<headerBars.length; x++) {
355+
for (var x = 0; x < headerBars.length; x++) {
356356
if (!headerBars[x].isActive) return headerBars[x];
357357
}
358358
}
@@ -363,12 +363,12 @@ function($scope, $element, $attrs, $compile, $timeout, $ionicNavBarDelegate, $io
363363
}
364364

365365

366-
$scope.$on('ionHeaderBar.init', function(ev){
366+
$scope.$on('ionHeaderBar.init', function(ev) {
367367
ev.stopPropagation();
368368
});
369369

370370

371-
$scope.$on('$destroy', function(){
371+
$scope.$on('$destroy', function() {
372372
$scope.$parent.$hasHeader = false;
373373
$element.parent().removeData(DATA_NAV_BAR_CTRL);
374374
for (var x = 0; x < headerBars.length; x++) {
@@ -380,4 +380,3 @@ function($scope, $element, $attrs, $compile, $timeout, $ionicNavBarDelegate, $io
380380
});
381381

382382
}]);
383-

js/angular/controller/navViewController.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,11 @@ function($scope, $element, $attrs, $ionicNavBarDelegate, $ionicHistory, $ionicVi
8484
var switcher = $ionicViewSwitcher.create($scope, $element, viewLocals, enteringView);
8585

8686
// init the rendering of views for this navView directive
87-
switcher.init(registerData, function(){
87+
switcher.init(registerData, function() {
8888
// the view is now compiled, in the dom and linked, now lets transition the views.
8989
// this uses a callback incase THIS nav-view has a nested nav-view, and after the NESTED
9090
// nav-view links, the NESTED nav-view would update which direction THIS nav-view should use
91-
switcher.transition( self.direction(), registerData.showBack );
91+
switcher.transition(self.direction(), registerData.showBack);
9292
});
9393

9494
};
@@ -134,7 +134,7 @@ function($scope, $element, $attrs, $ionicNavBarDelegate, $ionicHistory, $ionicVi
134134

135135
function getAssociatedNavBarCtrl() {
136136
if (navBarDelegate) {
137-
for (var x=0; x<$ionicNavBarDelegate._instances.length; x++) {
137+
for (var x=0; x < $ionicNavBarDelegate._instances.length; x++) {
138138
if ($ionicNavBarDelegate._instances[x].$$delegateHandle == navBarDelegate) {
139139
return $ionicNavBarDelegate._instances[x];
140140
}

js/angular/controller/tabController.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ function($scope, $ionicHistory, $attrs, $location, $state) {
1515
) === 0;
1616
};
1717
this.srefMatchesState = function() {
18-
return $attrs.uiSref && $state.includes( $attrs.uiSref.split('(')[0] );
18+
return $attrs.uiSref && $state.includes($attrs.uiSref.split('(')[0]);
1919
};
2020
this.navNameMatchesState = function() {
2121
return this.navViewName && $ionicHistory.isCurrentStateNavView(this.navViewName);

js/angular/controller/tabsController.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ function($scope, $ionicHistory, $element) {
5252
var tabIndex;
5353
if (angular.isNumber(tab)) {
5454
tabIndex = tab;
55-
if(tabIndex >= self.tabs.length) return;
55+
if (tabIndex >= self.tabs.length) return;
5656
tab = self.tabs[tabIndex];
5757
} else {
5858
tabIndex = self.tabs.indexOf(tab);
@@ -92,4 +92,3 @@ function($scope, $ionicHistory, $element) {
9292
}
9393
};
9494
}]);
95-

js/angular/directive/menuClose.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ IonicModule
2222
return {
2323
restrict: 'AC',
2424
link: function($scope, $element, $attr) {
25-
$element.bind('click', function(){
25+
$element.bind('click', function() {
2626
var sideMenuCtrl = $element.inheritedData('$ionSideMenusController');
2727
if (sideMenuCtrl) {
2828
// lower priority than navAnimation which allows navTransition

js/angular/directive/menuToggle.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,22 +25,21 @@ IonicModule
2525
return {
2626
restrict: 'AC',
2727
link: function($scope, $element, $attr) {
28-
$scope.$on('$ionicView.beforeEnter', function(ev, viewData){
28+
$scope.$on('$ionicView.beforeEnter', function(ev, viewData) {
2929
if (viewData.showBack) {
3030
var sideMenuCtrl = $element.inheritedData('$ionSideMenusController');
31-
if ( !sideMenuCtrl.enableMenuWithBackViews() ) {
31+
if (!sideMenuCtrl.enableMenuWithBackViews()) {
3232
$element.addClass('hide');
3333
}
3434
} else {
3535
$element.removeClass('hide');
3636
}
3737
});
3838

39-
$element.bind('click', function(){
39+
$element.bind('click', function() {
4040
var sideMenuCtrl = $element.inheritedData('$ionSideMenusController');
4141
sideMenuCtrl && sideMenuCtrl.toggle($attr.menuToggle);
4242
});
4343
}
4444
};
4545
});
46-

js/angular/directive/navDirection.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ IonicModule
2020
restrict: 'A',
2121
priority: 1000,
2222
link: function($scope, $element, $attr) {
23-
$element.bind('click', function(){
24-
$ionicViewSwitcher.nextDirection( $attr.navDirection );
23+
$element.bind('click', function() {
24+
$ionicViewSwitcher.nextDirection($attr.navDirection);
2525
});
2626
}
2727
};

js/angular/directive/navTransition.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ IonicModule
2020
restrict: 'A',
2121
priority: 1000,
2222
link: function($scope, $element, $attr) {
23-
$element.bind('click', function(){
24-
$ionicViewSwitcher.nextTransition( $attr.navTransition );
23+
$element.bind('click', function() {
24+
$ionicViewSwitcher.nextTransition($attr.navTransition);
2525
});
2626
}
2727
};

js/angular/directive/navView.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ function($state, $ionicConfig) {
9494
priority: 2000,
9595
transclude: true,
9696
controller: '$ionicNavView',
97-
compile: function (tElement, tAttrs, transclude) {
97+
compile: function(tElement, tAttrs, transclude) {
9898

9999
// a nav view element is a container for numerous views
100100
tElement.addClass('view-container');
@@ -104,8 +104,8 @@ function($state, $ionicConfig) {
104104
var latestLocals;
105105

106106
// Put in the compiled initial view
107-
transclude($scope, function(clone){
108-
$element.append( clone );
107+
transclude($scope, function(clone) {
108+
$element.append(clone);
109109
});
110110

111111
var viewData = navViewCtrl.init();
@@ -142,4 +142,3 @@ function($state, $ionicConfig) {
142142
}
143143
};
144144
}]);
145-

0 commit comments

Comments
 (0)