Skip to content

Commit

Permalink
Tabs -> 4 spaces
Browse files Browse the repository at this point in the history
  • Loading branch information
Jason Mitchell committed Jan 28, 2015
1 parent 1753908 commit 5463051
Show file tree
Hide file tree
Showing 40 changed files with 1,162 additions and 1,168 deletions.
20 changes: 10 additions & 10 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,24 @@ end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
indent_style = tab
indent_size = 2
indent_style = space
indent_size = 4

[*.js]
indent_style = tab
indent_size = 2
indent_style = space
indent_size = 4

[*.hbs]
indent_style = tab
indent_size = 2
indent_style = space
indent_size = 4

[*.css]
indent_style = tab
indent_size = 2
indent_style = space
indent_size = 4

[*.html]
indent_style = tab
indent_size = 2
indent_style = space
indent_size = 4

[*.md]
trim_trailing_whitespace = false
30 changes: 15 additions & 15 deletions addon/formatter-base.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,28 @@
import Ember from 'ember';

var FormatBase = Ember.Object.extend({
filterFormatOptions: function (hash) {
hash = hash || {};
filterFormatOptions: function (hash) {
hash = hash || {};

var match = false;
var match = false;

var options = this.constructor.formatOptions.reduce(function (opts, name) {
if (hash.hasOwnProperty(name)) {
match = true;
opts[name] = hash[name];
}
var options = this.constructor.formatOptions.reduce(function (opts, name) {
if (hash.hasOwnProperty(name)) {
match = true;
opts[name] = hash[name];
}

return opts;
}, {});
return opts;
}, {});

if (match) {
return options;
}
}
if (match) {
return options;
}
}
});

FormatBase.reopenClass({
formatOptions: Ember.A()
formatOptions: Ember.A()
});

export default FormatBase;
28 changes: 14 additions & 14 deletions addon/formatters/format-date.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,25 @@ import Ember from 'ember';
import Formatter from '../formatter-base';

var FormatDate = Formatter.extend({
format: function (value, hash) {
var formatOptions = {
formats: hash.format || this.filterFormatOptions(hash)
};
format: function (value, hash) {
var formatOptions = {
formats: hash.format || this.filterFormatOptions(hash)
};

if (hash.locales) {
formatOptions.locales = hash.locales;
}
if (hash.locales) {
formatOptions.locales = hash.locales;
}

return this.intl.formatDate(value, formatOptions);
}
return this.intl.formatDate(value, formatOptions);
}
});

FormatDate.reopenClass({
formatOptions: [
'localeMatcher', 'timeZone', 'hour12', 'formatMatcher', 'weekday',
'era', 'year', 'month', 'day', 'hour', 'minute', 'second',
'timeZoneName'
]
formatOptions: [
'localeMatcher', 'timeZone', 'hour12', 'formatMatcher', 'weekday',
'era', 'year', 'month', 'day', 'hour', 'minute', 'second',
'timeZoneName'
]
});

export default FormatDate;
66 changes: 33 additions & 33 deletions addon/formatters/format-html-message.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,39 +7,39 @@ import Ember from 'ember';
import FormatterMessage from './format-message';

var FormatHtmlMessage = FormatterMessage.extend({
escapeProps: function (props) {
return Object.keys(props).reduce(function (escapedProps, name) {
var value = props[name];

// TODO: Can we force string coersion here? Or would that not be needed
// and possible mess with IntlMessageFormat?
if (typeof value === 'string') {
value = Ember.Handlebars.Utils.escapeExpression(value);
}

escapedProps[name] = value;
return escapedProps;
}, {});
},

format: function (value, hash, context) {
var icuKeys = this.extractICUKeys(value);
var model = {};

if (icuKeys && icuKeys.length) {
model = Ember.$.extend(Ember.getProperties(context, icuKeys), hash);
}

var formatOptions = {
formats: hash.format || this.filterFormatOptions(hash)
};

if (hash.locales) {
formatOptions.locales = hash.locales;
}

return Ember.String.htmlSafe(this.intl.formatMessage(value, this.escapeProps(model), formatOptions));
}
escapeProps: function (props) {
return Object.keys(props).reduce(function (escapedProps, name) {
var value = props[name];

// TODO: Can we force string coersion here? Or would that not be needed
// and possible mess with IntlMessageFormat?
if (typeof value === 'string') {
value = Ember.Handlebars.Utils.escapeExpression(value);
}

escapedProps[name] = value;
return escapedProps;
}, {});
},

format: function (value, hash, context) {
var icuKeys = this.extractICUKeys(value);
var model = {};

if (icuKeys && icuKeys.length) {
model = Ember.$.extend(Ember.getProperties(context, icuKeys), hash);
}

var formatOptions = {
formats: hash.format || this.filterFormatOptions(hash)
};

if (hash.locales) {
formatOptions.locales = hash.locales;
}

return Ember.String.htmlSafe(this.intl.formatMessage(value, this.escapeProps(model), formatOptions));
}
});

export default FormatHtmlMessage;
92 changes: 46 additions & 46 deletions addon/formatters/format-message.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,65 +9,65 @@ import Formatter from '../formatter-base';
var validKey = /[\w|.]/;

var FormatMessage = Formatter.extend({
extractICUKeys: function (msg) {
var length = msg.length;
var buf = [], out = Ember.A();
var i = 0;
var char, key;
extractICUKeys: function (msg) {
var length = msg.length;
var buf = [], out = Ember.A();
var i = 0;
var char, key;

for (; i < length; i++) {
char = msg[i];
for (; i < length; i++) {
char = msg[i];

if (buf.length && !validKey.test(char)) {
buf.shift();
key = buf.join('');
if (buf.length && !validKey.test(char)) {
buf.shift();
key = buf.join('');

// do not include empty strings: {}
if (key) { out.addObject(key); }
// do not include empty strings: {}
if (key) { out.addObject(key); }

buf = [];
}
else if (
// does not include escaped curly braces
// and double curly braces does not mistake the first
// as the starting point of the key {{foo}} should return `foo`
(char === '{' && msg[i-1] !== "\\" && msg[i+1] !== '{') ||
buf.length
)
{
buf.push(char);
}
}
buf = [];
}
else if (
// does not include escaped curly braces
// and double curly braces does not mistake the first
// as the starting point of the key {{foo}} should return `foo`
(char === '{' && msg[i-1] !== "\\" && msg[i+1] !== '{') ||
buf.length
)
{
buf.push(char);
}
}

return out;
},
return out;
},

format: function (value, hash, context) {
var icuKeys = this.extractICUKeys(value);
var model;
format: function (value, hash, context) {
var icuKeys = this.extractICUKeys(value);
var model;

if (icuKeys && icuKeys.length) {
model = Ember.$.extend(Ember.getProperties(context, icuKeys), hash);
}
if (icuKeys && icuKeys.length) {
model = Ember.$.extend(Ember.getProperties(context, icuKeys), hash);
}

var formatOptions = {
formats: hash.format || this.filterFormatOptions(hash)
};
var formatOptions = {
formats: hash.format || this.filterFormatOptions(hash)
};

if (hash.locales) {
formatOptions.locales = hash.locales;
}
if (hash.locales) {
formatOptions.locales = hash.locales;
}

return this.intl.formatMessage(value, model, formatOptions);
}
return this.intl.formatMessage(value, model, formatOptions);
}
});

FormatMessage.reopenClass({
formatOptions: [
'localeMatcher', 'timeZone', 'hour12', 'formatMatcher', 'weekday',
'era', 'year', 'month', 'day', 'hour', 'minute', 'second',
'timeZoneName'
]
formatOptions: [
'localeMatcher', 'timeZone', 'hour12', 'formatMatcher', 'weekday',
'era', 'year', 'month', 'day', 'hour', 'minute', 'second',
'timeZoneName'
]
});

export default FormatMessage;
30 changes: 15 additions & 15 deletions addon/formatters/format-number.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,26 @@ import Ember from 'ember';
import Formatter from '../formatter-base';

var FormatNumber = Formatter.extend({
format: function (value, hash) {
var formatOptions = {
formats: hash.format || this.filterFormatOptions(hash)
};
format: function (value, hash) {
var formatOptions = {
formats: hash.format || this.filterFormatOptions(hash)
};

if (hash.locales) {
formatOptions.locales = hash.locales;
}
if (hash.locales) {
formatOptions.locales = hash.locales;
}

return this.intl.formatNumber(value, formatOptions);
}
return this.intl.formatNumber(value, formatOptions);
}
});

FormatNumber.reopenClass({
formatOptions: [
'localeMatcher', 'style', 'currency', 'currencyDisplay',
'useGrouping', 'minimumIntegerDigits', 'minimumFractionDigits',
'maximumFractionDigits', 'minimumSignificantDigits',
'maximumSignificantDigits'
]
formatOptions: [
'localeMatcher', 'style', 'currency', 'currencyDisplay',
'useGrouping', 'minimumIntegerDigits', 'minimumFractionDigits',
'maximumFractionDigits', 'minimumSignificantDigits',
'maximumSignificantDigits'
]
});

export default FormatNumber;
20 changes: 10 additions & 10 deletions addon/formatters/format-relative.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,21 @@ import Ember from 'ember';
import Formatter from '../formatter-base';

var FormatRelative = Formatter.extend({
format: function (value, hash) {
var formatOptions = {
formats: hash.format || this.filterFormatOptions(hash)
};
format: function (value, hash) {
var formatOptions = {
formats: hash.format || this.filterFormatOptions(hash)
};

if (hash.locales) {
formatOptions.locales = hash.locales;
}
if (hash.locales) {
formatOptions.locales = hash.locales;
}

return this.intl.formatRelative(value, formatOptions);
}
return this.intl.formatRelative(value, formatOptions);
}
});

FormatRelative.reopenClass({
formatOptions: ['style', 'units']
formatOptions: ['style', 'units']
});

export default FormatRelative;
Loading

0 comments on commit 5463051

Please sign in to comment.