Skip to content

Commit

Permalink
chore(rating): unify code style
Browse files Browse the repository at this point in the history
  • Loading branch information
wesleycho committed Aug 10, 2015
1 parent e7761b4 commit ed236b3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
11 changes: 6 additions & 5 deletions src/rating/rating.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@ angular.module('ui.bootstrap.rating', [])
this.titles = angular.isArray(tmpTitles) && tmpTitles.length > 0 ?
tmpTitles : ratingConfig.titles;

var ratingStates = angular.isDefined($attrs.ratingStates) ? $scope.$parent.$eval($attrs.ratingStates) :
new Array( angular.isDefined($attrs.max) ? $scope.$parent.$eval($attrs.max) : ratingConfig.max );
var ratingStates = angular.isDefined($attrs.ratingStates) ?
$scope.$parent.$eval($attrs.ratingStates) :
new Array(angular.isDefined($attrs.max) ? $scope.$parent.$eval($attrs.max) : ratingConfig.max);
$scope.range = this.buildTemplateObjects(ratingStates);
};

Expand All @@ -48,14 +49,14 @@ angular.module('ui.bootstrap.rating', [])
};

$scope.rate = function(value) {
if ( !$scope.readonly && value >= 0 && value <= $scope.range.length ) {
if (!$scope.readonly && value >= 0 && value <= $scope.range.length) {
ngModelCtrl.$setViewValue(ngModelCtrl.$viewValue === value ? 0 : value);
ngModelCtrl.$render();
}
};

$scope.enter = function(value) {
if ( !$scope.readonly ) {
if (!$scope.readonly) {
$scope.value = value;
}
$scope.onHover({value: value});
Expand All @@ -70,7 +71,7 @@ angular.module('ui.bootstrap.rating', [])
if (/(37|38|39|40)/.test(evt.which)) {
evt.preventDefault();
evt.stopPropagation();
$scope.rate( $scope.value + (evt.which === 38 || evt.which === 39 ? 1 : -1) );
$scope.rate($scope.value + (evt.which === 38 || evt.which === 39 ? 1 : -1));
}
};

Expand Down
9 changes: 4 additions & 5 deletions src/rating/test/rating.spec.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
describe('rating directive', function () {
describe('rating directive', function() {
var $rootScope, $compile, element;
beforeEach(module('ui.bootstrap.rating'));
beforeEach(module('template/rating/rating.html'));
Expand Down Expand Up @@ -237,7 +237,7 @@ describe('rating directive', function () {
$rootScope.$digest();
}));

it('should define number of icon elements', function () {
it('should define number of icon elements', function() {
expect(getStars().length).toBe(4);
expect(element.attr('aria-valuemax')).toBe('4');
});
Expand Down Expand Up @@ -272,11 +272,11 @@ describe('rating directive', function () {
angular.extend(ratingConfig, originalConfig);
}));

it('should change number of icon elements', function () {
it('should change number of icon elements', function() {
expect(getStars().length).toBe(10);
});

it('should change icon states', function () {
it('should change icon states', function() {
expect(getState('on', 'off')).toEqual([true, true, true, true, true, false, false, false, false, false]);
});
});
Expand Down Expand Up @@ -325,5 +325,4 @@ describe('rating directive', function () {
expect(getTitles()).toEqual(['one', 'two', 'three', 'four', 'five']);
});
});

});

0 comments on commit ed236b3

Please sign in to comment.