style(*): jscs linter updates to nav improvements

This commit is contained in:
Adam Bradley
2014-11-11 23:04:33 -06:00
parent 2b23957558
commit 5d6a33c1db
19 changed files with 145 additions and 150 deletions

View File

@@ -54,7 +54,7 @@ function($scope, $element, $attrs, $q, $ionicConfig, $ionicHistory) {
self.titleTextWidth = function() {
if (!titleTextWidth) {
var bounds = ionic.DomUtil.getTextBounds( getEle(TITLE) );
var bounds = ionic.DomUtil.getTextBounds(getEle(TITLE));
titleTextWidth = Math.min(bounds && bounds.width || 30);
}
return titleTextWidth;
@@ -84,7 +84,7 @@ function($scope, $element, $attrs, $q, $ionicConfig, $ionicHistory) {
self.backButtonTextLeft = function() {
var offsetLeft = 0;
var ele = getEle(BACK_TEXT);
while(ele) {
while (ele) {
offsetLeft += ele.offsetLeft;
ele = ele.parentElement;
}
@@ -93,7 +93,7 @@ function($scope, $element, $attrs, $q, $ionicConfig, $ionicHistory) {
self.resetBackButton = function() {
if ( $ionicConfig.backButton.previousTitleText() ) {
if ($ionicConfig.backButton.previousTitleText()) {
var previousTitleEle = getEle(PREVIOUS_TITLE);
if (previousTitleEle) {
previousTitleEle.classList.remove(HIDE);
@@ -119,7 +119,7 @@ function($scope, $element, $attrs, $q, $ionicConfig, $ionicHistory) {
var widths = self.calcWidths(align, false);
if ( isBackShown && previousTitleText && $ionicConfig.backButton.previousTitleText() ) {
if (isBackShown && previousTitleText && $ionicConfig.backButton.previousTitleText()) {
var previousTitleWidths = self.calcWidths(align, true);
var availableTitleWidth = $element[0].offsetWidth - previousTitleWidths.titleLeft - previousTitleWidths.titleRight;
@@ -176,10 +176,10 @@ function($scope, $element, $attrs, $q, $ionicConfig, $ionicHistory) {
d = b.children[z];
if (isPreviousTitle) {
if ( d.classList.contains(DEFAULT_TITLE) ) continue;
if (d.classList.contains(DEFAULT_TITLE)) continue;
backButtonWidth += d.offsetWidth;
} else {
if ( d.classList.contains(PREVIOUS_TITLE) ) continue;
if (d.classList.contains(PREVIOUS_TITLE)) continue;
backButtonWidth += d.offsetWidth;
}
}
@@ -283,7 +283,7 @@ function($scope, $element, $attrs, $q, $ionicConfig, $ionicHistory) {
defaultTitle && defaultTitle.classList[ showPreviousTitle ? 'add' : 'remove'](HIDE);
}
ionic.requestAnimationFrame(function(){
ionic.requestAnimationFrame(function() {
if (titleEle && titleEle.offsetWidth + 10 < titleEle.scrollWidth) {
var minRight = buttonsRight + 5;
var testRight = $element[0].offsetWidth - titleLeft - self.titleTextWidth() - 20;
@@ -301,7 +301,7 @@ function($scope, $element, $attrs, $q, $ionicConfig, $ionicHistory) {
self.setCss = function(elementClassname, css) {
ionic.DomUtil.cachedStyles( getEle(elementClassname), css);
ionic.DomUtil.cachedStyles(getEle(elementClassname), css);
};
@@ -315,8 +315,7 @@ function($scope, $element, $attrs, $q, $ionicConfig, $ionicHistory) {
$scope.$on('$destroy', function() {
for(var n in eleCache) eleCache[n] = null;
for (var n in eleCache) eleCache[n] = null;
});
}]);

View File

@@ -44,10 +44,10 @@ function($scope, $element, $attrs, $compile, $timeout, $ionicNavBarDelegate, $io
self.createHeaderBar = function(isActive, navBarClass) {
var containerEle = jqLite( '<div class="nav-bar-block">' );
var containerEle = jqLite('<div class="nav-bar-block">');
ionic.DomUtil.cachedAttr(containerEle, 'nav-bar', isActive ? 'active' : 'cached');
var headerBarEle = jqLite( '<ion-header-bar>' ).addClass($attrs.class);
var headerBarEle = jqLite('<ion-header-bar>').addClass($attrs.class);
var titleEle = jqLite('<div class="title title-' + $ionicConfig.navBar.alignTitle() + '">');
var navEle = {};
var lastViewBtnsEle = {};
@@ -60,7 +60,7 @@ function($scope, $element, $attrs, $compile, $timeout, $ionicNavBarDelegate, $io
// append title in the header, this is the rock to where buttons append
headerBarEle.append(titleEle);
forEach(BUTTON_TYPES, function(buttonType){
forEach(BUTTON_TYPES, function(buttonType) {
// create default button elements
navEle[buttonType] = createNavElement(buttonType);
// append and position buttons
@@ -69,7 +69,7 @@ function($scope, $element, $attrs, $compile, $timeout, $ionicNavBarDelegate, $io
// compile header and append to the DOM
containerEle.append(headerBarEle);
$element.append( $compile(containerEle)($scope.$new()) );
$element.append($compile(containerEle)($scope.$new()));
var headerBarCtrl = headerBarEle.data('$ionHeaderBarController');
@@ -114,7 +114,7 @@ function($scope, $element, $attrs, $compile, $timeout, $ionicNavBarDelegate, $io
return headerBarEle;
},
afterLeave: function() {
forEach(BUTTON_TYPES, function(buttonType){
forEach(BUTTON_TYPES, function(buttonType) {
headerBarInstance.removeButtons(buttonType);
});
headerBarCtrl.resetBackButton();
@@ -123,7 +123,7 @@ function($scope, $element, $attrs, $compile, $timeout, $ionicNavBarDelegate, $io
return headerBarCtrl;
},
destroy: function() {
forEach(BUTTON_TYPES, function(buttonType){
forEach(BUTTON_TYPES, function(buttonType) {
headerBarInstance.removeButtons(buttonType);
});
containerEle.scope().$destroy();
@@ -187,7 +187,7 @@ function($scope, $element, $attrs, $compile, $timeout, $ionicNavBarDelegate, $io
self.navElement = function(type, html) {
if ( isDefined(html) ) {
if (isDefined(html)) {
navElementHtml[type] = html;
}
return navElementHtml[type];
@@ -214,7 +214,7 @@ function($scope, $element, $attrs, $compile, $timeout, $ionicNavBarDelegate, $io
// update the buttons, depending if the view has their own or not
if (viewData.buttons) {
forEach(BUTTON_TYPES, function(buttonType){
forEach(BUTTON_TYPES, function(buttonType) {
enteringHeaderBar.setButtons(viewData.buttons[buttonType], buttonType);
});
}
@@ -238,7 +238,7 @@ function($scope, $element, $attrs, $compile, $timeout, $ionicNavBarDelegate, $io
ionic.DomUtil.cachedAttr($element, 'nav-bar-transition', $ionicConfig.navBar.transition());
ionic.DomUtil.cachedAttr($element, 'nav-bar-direction', viewData.direction);
if(navBarTransition.shouldAnimate) {
if (navBarTransition.shouldAnimate) {
navBarAttr(enteringHeaderBar, 'stage');
} else {
navBarAttr(enteringHeaderBar, 'entering');
@@ -261,7 +261,7 @@ function($scope, $element, $attrs, $compile, $timeout, $ionicNavBarDelegate, $io
queuedTransitionEnd = function() {
if (latestTransitionId == transitionId || !navBarTransition.shouldAnimate) {
for (var x=0; x<headerBars.length; x++) {
for (var x = 0; x < headerBars.length; x++) {
headerBars[x].isActive = false;
}
enteringHeaderBar.isActive = true;
@@ -313,7 +313,7 @@ function($scope, $element, $attrs, $compile, $timeout, $ionicNavBarDelegate, $io
self.visibleBar(val);
// set non primary to hide second
for (var x=0; x<$ionicNavBarDelegate._instances.length; x++) {
for (var x = 0; x < $ionicNavBarDelegate._instances.length; x++) {
if ($ionicNavBarDelegate._instances[x] !== self) $ionicNavBarDelegate._instances[x].visibleBar(false);
}
};
@@ -338,21 +338,21 @@ function($scope, $element, $attrs, $compile, $timeout, $ionicNavBarDelegate, $io
function createNavElement(type) {
if ( navElementHtml[type] ) {
if (navElementHtml[type]) {
return jqLite(navElementHtml[type]);
}
}
function getOnScreenHeaderBar() {
for (var x=0; x<headerBars.length; x++) {
for (var x = 0; x < headerBars.length; x++) {
if (headerBars[x].isActive) return headerBars[x];
}
}
function getOffScreenHeaderBar() {
for (var x=0; x<headerBars.length; x++) {
for (var x = 0; x < headerBars.length; x++) {
if (!headerBars[x].isActive) return headerBars[x];
}
}
@@ -363,12 +363,12 @@ function($scope, $element, $attrs, $compile, $timeout, $ionicNavBarDelegate, $io
}
$scope.$on('ionHeaderBar.init', function(ev){
$scope.$on('ionHeaderBar.init', function(ev) {
ev.stopPropagation();
});
$scope.$on('$destroy', function(){
$scope.$on('$destroy', function() {
$scope.$parent.$hasHeader = false;
$element.parent().removeData(DATA_NAV_BAR_CTRL);
for (var x = 0; x < headerBars.length; x++) {
@@ -380,4 +380,3 @@ function($scope, $element, $attrs, $compile, $timeout, $ionicNavBarDelegate, $io
});
}]);

View File

@@ -84,11 +84,11 @@ function($scope, $element, $attrs, $ionicNavBarDelegate, $ionicHistory, $ionicVi
var switcher = $ionicViewSwitcher.create($scope, $element, viewLocals, enteringView);
// init the rendering of views for this navView directive
switcher.init(registerData, function(){
switcher.init(registerData, function() {
// the view is now compiled, in the dom and linked, now lets transition the views.
// this uses a callback incase THIS nav-view has a nested nav-view, and after the NESTED
// nav-view links, the NESTED nav-view would update which direction THIS nav-view should use
switcher.transition( self.direction(), registerData.showBack );
switcher.transition(self.direction(), registerData.showBack);
});
};
@@ -134,7 +134,7 @@ function($scope, $element, $attrs, $ionicNavBarDelegate, $ionicHistory, $ionicVi
function getAssociatedNavBarCtrl() {
if (navBarDelegate) {
for (var x=0; x<$ionicNavBarDelegate._instances.length; x++) {
for (var x=0; x < $ionicNavBarDelegate._instances.length; x++) {
if ($ionicNavBarDelegate._instances[x].$$delegateHandle == navBarDelegate) {
return $ionicNavBarDelegate._instances[x];
}

View File

@@ -15,7 +15,7 @@ function($scope, $ionicHistory, $attrs, $location, $state) {
) === 0;
};
this.srefMatchesState = function() {
return $attrs.uiSref && $state.includes( $attrs.uiSref.split('(')[0] );
return $attrs.uiSref && $state.includes($attrs.uiSref.split('(')[0]);
};
this.navNameMatchesState = function() {
return this.navViewName && $ionicHistory.isCurrentStateNavView(this.navViewName);

View File

@@ -52,7 +52,7 @@ function($scope, $ionicHistory, $element) {
var tabIndex;
if (angular.isNumber(tab)) {
tabIndex = tab;
if(tabIndex >= self.tabs.length) return;
if (tabIndex >= self.tabs.length) return;
tab = self.tabs[tabIndex];
} else {
tabIndex = self.tabs.indexOf(tab);
@@ -92,4 +92,3 @@ function($scope, $ionicHistory, $element) {
}
};
}]);