mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-05-09 07:14:44 +00:00
style(filter): Couple of missing spaces, semi-colons, add empty lines
This commit is contained in:
parent
4b1913c5ec
commit
fc2f188d4d
2 changed files with 12 additions and 9 deletions
|
|
@ -71,8 +71,8 @@ angularFilter.currency = function(amount, currencySymbol){
|
||||||
var formats = this.$service('$locale').NUMBER_FORMATS;
|
var formats = this.$service('$locale').NUMBER_FORMATS;
|
||||||
this.$element.toggleClass('ng-format-negative', amount < 0);
|
this.$element.toggleClass('ng-format-negative', amount < 0);
|
||||||
if (isUndefined(currencySymbol)) currencySymbol = formats.CURRENCY_SYM;
|
if (isUndefined(currencySymbol)) currencySymbol = formats.CURRENCY_SYM;
|
||||||
return formatNumber(amount, formats.PATTERNS[1], formats.GROUP_SEP, formats.DECIMAL_SEP, 2)
|
return formatNumber(amount, formats.PATTERNS[1], formats.GROUP_SEP, formats.DECIMAL_SEP, 2).
|
||||||
.replace(/\u00A4/g, currencySymbol);
|
replace(/\u00A4/g, currencySymbol);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -121,14 +121,14 @@ angularFilter.number = function(number, fractionSize) {
|
||||||
var formats = this.$service('$locale').NUMBER_FORMATS;
|
var formats = this.$service('$locale').NUMBER_FORMATS;
|
||||||
return formatNumber(number, formats.PATTERNS[0], formats.GROUP_SEP,
|
return formatNumber(number, formats.PATTERNS[0], formats.GROUP_SEP,
|
||||||
formats.DECIMAL_SEP, fractionSize);
|
formats.DECIMAL_SEP, fractionSize);
|
||||||
}
|
};
|
||||||
|
|
||||||
function formatNumber(number, pattern, groupSep, decimalSep, fractionSize) {
|
function formatNumber(number, pattern, groupSep, decimalSep, fractionSize) {
|
||||||
if (isNaN(number) || !isFinite(number)) return '';
|
if (isNaN(number) || !isFinite(number)) return '';
|
||||||
|
|
||||||
var isNegative = number < 0;
|
var isNegative = number < 0;
|
||||||
number = Math.abs(number);
|
number = Math.abs(number);
|
||||||
var numStr = number + '',
|
var numStr = number + '',
|
||||||
formatedText = '',
|
formatedText = '',
|
||||||
parts = [];
|
parts = [];
|
||||||
|
|
||||||
|
|
@ -137,7 +137,7 @@ function formatNumber(number, pattern, groupSep, decimalSep, fractionSize) {
|
||||||
} else {
|
} else {
|
||||||
var fractionLen = (numStr.split(DECIMAL_SEP)[1] || '').length;
|
var fractionLen = (numStr.split(DECIMAL_SEP)[1] || '').length;
|
||||||
|
|
||||||
//determine fractionSize if it is not specified
|
// determine fractionSize if it is not specified
|
||||||
if (isUndefined(fractionSize)) {
|
if (isUndefined(fractionSize)) {
|
||||||
fractionSize = Math.min(Math.max(pattern.minFrac, fractionLen), pattern.maxFrac);
|
fractionSize = Math.min(Math.max(pattern.minFrac, fractionLen), pattern.maxFrac);
|
||||||
}
|
}
|
||||||
|
|
@ -249,10 +249,10 @@ var DATE_FORMATS = {
|
||||||
Z: timeZoneGetter
|
Z: timeZoneGetter
|
||||||
};
|
};
|
||||||
|
|
||||||
var GET_TIME_ZONE = /[A-Z]{3}(?![+\-])/;
|
var GET_TIME_ZONE = /[A-Z]{3}(?![+\-])/,
|
||||||
var DATE_FORMATS_SPLIT = /((?:[^yMdHhmsaZE']+)|(?:'(?:[^']|'')*')|(?:E+|y+|M+|d+|H+|h+|m+|s+|a|Z))(.*)/
|
DATE_FORMATS_SPLIT = /((?:[^yMdHhmsaZE']+)|(?:'(?:[^']|'')*')|(?:E+|y+|M+|d+|H+|h+|m+|s+|a|Z))(.*)/,
|
||||||
var OPERA_TOSTRING_PATTERN = /^[\d].*Z$/;
|
OPERA_TOSTRING_PATTERN = /^[\d].*Z$/,
|
||||||
var NUMBER_STRING = /^\d+$/;
|
NUMBER_STRING = /^\d+$/;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -96,6 +96,7 @@ describe('filter', function() {
|
||||||
dealoc(context);
|
dealoc(context);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
it('should do basic currency filtering', function() {
|
it('should do basic currency filtering', function() {
|
||||||
expect(currency(0)).toEqual('$0.00');
|
expect(currency(0)).toEqual('$0.00');
|
||||||
expect(html.hasClass('ng-format-negative')).toBeFalsy();
|
expect(html.hasClass('ng-format-negative')).toBeFalsy();
|
||||||
|
|
@ -105,6 +106,7 @@ describe('filter', function() {
|
||||||
expect(html.hasClass('ng-format-negative')).toBeFalsy();
|
expect(html.hasClass('ng-format-negative')).toBeFalsy();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
it('should return empty string for non-numbers', function() {
|
it('should return empty string for non-numbers', function() {
|
||||||
expect(currency()).toBe('');
|
expect(currency()).toBe('');
|
||||||
expect(html.hasClass('ng-format-negative')).toBeFalsy();
|
expect(html.hasClass('ng-format-negative')).toBeFalsy();
|
||||||
|
|
@ -113,6 +115,7 @@ describe('filter', function() {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
describe('number', function() {
|
describe('number', function() {
|
||||||
var context, number;
|
var context, number;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue