Skip to content

Commit 0427587

Browse files
committed
Build: Include distribution files
1 parent 7cbfe07 commit 0427587

File tree

17 files changed

+10145
-0
lines changed

17 files changed

+10145
-0
lines changed

dist/globalize-runtime.js

Lines changed: 236 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,236 @@
1+
/**
2+
* Globalize Runtime v1.2.3
3+
*
4+
* http://github.com/jquery/globalize
5+
*
6+
* Copyright jQuery Foundation and other contributors
7+
* Released under the MIT license
8+
* http://jquery.org/license
9+
*
10+
* Date: 2017-03-17T01:41Z
11+
*/
12+
/*!
13+
* Globalize Runtime v1.2.3 2017-03-17T01:41Z Released under the MIT license
14+
* http://git.io/TrdQbw
15+
*/
16+
(function( root, factory ) {
17+
18+
// UMD returnExports
19+
if ( typeof define === "function" && define.amd ) {
20+
21+
// AMD
22+
define( factory );
23+
} else if ( typeof exports === "object" ) {
24+
25+
// Node, CommonJS
26+
module.exports = factory();
27+
} else {
28+
29+
// Globalize
30+
root.Globalize = factory();
31+
}
32+
}( this, function() {
33+
34+
35+
/**
36+
* A toString method that outputs meaningful values for objects or arrays and
37+
* still performs as fast as a plain string in case variable is string, or as
38+
* fast as `"" + number` in case variable is a number.
39+
* Ref: http://jsperf.com/my-stringify
40+
*/
41+
var toString = function( variable ) {
42+
return typeof variable === "string" ? variable : ( typeof variable === "number" ? "" +
43+
variable : JSON.stringify( variable ) );
44+
};
45+
46+
47+
48+
49+
/**
50+
* formatMessage( message, data )
51+
*
52+
* @message [String] A message with optional {vars} to be replaced.
53+
*
54+
* @data [Array or JSON] Object with replacing-variables content.
55+
*
56+
* Return the formatted message. For example:
57+
*
58+
* - formatMessage( "{0} second", [ 1 ] ); // 1 second
59+
*
60+
* - formatMessage( "{0}/{1}", ["m", "s"] ); // m/s
61+
*
62+
* - formatMessage( "{name} <{email}>", {
63+
* name: "Foo",
64+
* email: "bar@baz.qux"
65+
* }); // Foo <[email protected]>
66+
*/
67+
var formatMessage = function( message, data ) {
68+
69+
// Replace {attribute}'s
70+
message = message.replace( /{[0-9a-zA-Z-_. ]+}/g, function( name ) {
71+
name = name.replace( /^{([^}]*)}$/, "$1" );
72+
return toString( data[ name ] );
73+
});
74+
75+
return message;
76+
};
77+
78+
79+
80+
81+
var objectExtend = function() {
82+
var destination = arguments[ 0 ],
83+
sources = [].slice.call( arguments, 1 );
84+
85+
sources.forEach(function( source ) {
86+
var prop;
87+
for ( prop in source ) {
88+
destination[ prop ] = source[ prop ];
89+
}
90+
});
91+
92+
return destination;
93+
};
94+
95+
96+
97+
98+
var createError = function( code, message, attributes ) {
99+
var error;
100+
101+
message = code + ( message ? ": " + formatMessage( message, attributes ) : "" );
102+
error = new Error( message );
103+
error.code = code;
104+
105+
objectExtend( error, attributes );
106+
107+
return error;
108+
};
109+
110+
111+
112+
113+
// Based on http://stackoverflow.com/questions/7616461/generate-a-hash-from-string-in-javascript-jquery
114+
var stringHash = function( str ) {
115+
return [].reduce.call( str, function( hash, i ) {
116+
var chr = i.charCodeAt( 0 );
117+
hash = ( ( hash << 5 ) - hash ) + chr;
118+
return hash | 0;
119+
}, 0 );
120+
};
121+
122+
123+
124+
125+
var runtimeKey = function( fnName, locale, args, argsStr ) {
126+
var hash;
127+
argsStr = argsStr || JSON.stringify( args );
128+
hash = stringHash( fnName + locale + argsStr );
129+
return hash > 0 ? "a" + hash : "b" + Math.abs( hash );
130+
};
131+
132+
133+
134+
135+
var validate = function( code, message, check, attributes ) {
136+
if ( !check ) {
137+
throw createError( code, message, attributes );
138+
}
139+
};
140+
141+
142+
143+
144+
var validateParameterPresence = function( value, name ) {
145+
validate( "E_MISSING_PARAMETER", "Missing required parameter `{name}`.",
146+
value !== undefined, { name: name });
147+
};
148+
149+
150+
151+
152+
var validateParameterType = function( value, name, check, expected ) {
153+
validate(
154+
"E_INVALID_PAR_TYPE",
155+
"Invalid `{name}` parameter ({value}). {expected} expected.",
156+
check,
157+
{
158+
expected: expected,
159+
name: name,
160+
value: value
161+
}
162+
);
163+
};
164+
165+
166+
167+
168+
var validateParameterTypeString = function( value, name ) {
169+
validateParameterType(
170+
value,
171+
name,
172+
value === undefined || typeof value === "string",
173+
"a string"
174+
);
175+
};
176+
177+
178+
179+
180+
// ref: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions?redirectlocale=en-US&redirectslug=JavaScript%2FGuide%2FRegular_Expressions
181+
var regexpEscape = function( string ) {
182+
return string.replace( /([.*+?^=!:${}()|\[\]\/\\])/g, "\\$1" );
183+
};
184+
185+
186+
187+
188+
var stringPad = function( str, count, right ) {
189+
var length;
190+
if ( typeof str !== "string" ) {
191+
str = String( str );
192+
}
193+
for ( length = str.length; length < count; length += 1 ) {
194+
str = ( right ? ( str + "0" ) : ( "0" + str ) );
195+
}
196+
return str;
197+
};
198+
199+
200+
201+
202+
function Globalize( locale ) {
203+
if ( !( this instanceof Globalize ) ) {
204+
return new Globalize( locale );
205+
}
206+
207+
validateParameterPresence( locale, "locale" );
208+
validateParameterTypeString( locale, "locale" );
209+
210+
this._locale = locale;
211+
}
212+
213+
Globalize.locale = function( locale ) {
214+
validateParameterTypeString( locale, "locale" );
215+
216+
if ( arguments.length ) {
217+
this._locale = locale;
218+
}
219+
return this._locale;
220+
};
221+
222+
Globalize._createError = createError;
223+
Globalize._formatMessage = formatMessage;
224+
Globalize._regexpEscape = regexpEscape;
225+
Globalize._runtimeKey = runtimeKey;
226+
Globalize._stringPad = stringPad;
227+
Globalize._validateParameterPresence = validateParameterPresence;
228+
Globalize._validateParameterTypeString = validateParameterTypeString;
229+
Globalize._validateParameterType = validateParameterType;
230+
231+
return Globalize;
232+
233+
234+
235+
236+
}));

dist/globalize-runtime/currency.js

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
/**
2+
* Globalize Runtime v1.2.3
3+
*
4+
* http://github.com/jquery/globalize
5+
*
6+
* Copyright jQuery Foundation and other contributors
7+
* Released under the MIT license
8+
* http://jquery.org/license
9+
*
10+
* Date: 2017-03-17T01:41Z
11+
*/
12+
/*!
13+
* Globalize Runtime v1.2.3 2017-03-17T01:41Z Released under the MIT license
14+
* http://git.io/TrdQbw
15+
*/
16+
(function( root, factory ) {
17+
18+
// UMD returnExports
19+
if ( typeof define === "function" && define.amd ) {
20+
21+
// AMD
22+
define([
23+
"../globalize-runtime",
24+
"./number"
25+
], factory );
26+
} else if ( typeof exports === "object" ) {
27+
28+
// Node, CommonJS
29+
module.exports = factory(
30+
require( "../globalize-runtime" ),
31+
require( "./number" )
32+
);
33+
} else {
34+
35+
// Extend global
36+
factory( root.Globalize );
37+
}
38+
}(this, function( Globalize ) {
39+
40+
var formatMessage = Globalize._formatMessage,
41+
runtimeKey = Globalize._runtimeKey,
42+
validateParameterPresence = Globalize._validateParameterPresence,
43+
validateParameterTypeNumber = Globalize._validateParameterTypeNumber;
44+
45+
46+
/**
47+
* nameFormat( formattedNumber, pluralForm, properties )
48+
*
49+
* Return the appropriate name form currency format.
50+
*/
51+
var currencyNameFormat = function( formattedNumber, pluralForm, properties ) {
52+
var displayName, unitPattern,
53+
displayNames = properties.displayNames || {},
54+
unitPatterns = properties.unitPatterns;
55+
56+
displayName = displayNames[ "displayName-count-" + pluralForm ] ||
57+
displayNames[ "displayName-count-other" ] ||
58+
displayNames.displayName ||
59+
properties.currency;
60+
unitPattern = unitPatterns[ "unitPattern-count-" + pluralForm ] ||
61+
unitPatterns[ "unitPattern-count-other" ];
62+
63+
return formatMessage( unitPattern, [ formattedNumber, displayName ]);
64+
};
65+
66+
67+
68+
69+
var currencyFormatterFn = function( numberFormatter, pluralGenerator, properties ) {
70+
var fn;
71+
72+
// Return formatter when style is "code" or "name".
73+
if ( pluralGenerator && properties ) {
74+
fn = function currencyFormatter( value ) {
75+
validateParameterPresence( value, "value" );
76+
validateParameterTypeNumber( value, "value" );
77+
return currencyNameFormat(
78+
numberFormatter( value ),
79+
pluralGenerator( value ),
80+
properties
81+
);
82+
};
83+
84+
// Return formatter when style is "symbol" or "accounting".
85+
} else {
86+
fn = function currencyFormatter( value ) {
87+
return numberFormatter( value );
88+
};
89+
}
90+
91+
return fn;
92+
};
93+
94+
95+
96+
97+
Globalize._currencyFormatterFn = currencyFormatterFn;
98+
Globalize._currencyNameFormat = currencyNameFormat;
99+
100+
Globalize.currencyFormatter =
101+
Globalize.prototype.currencyFormatter = function( currency, options ) {
102+
options = options || {};
103+
return Globalize[ runtimeKey( "currencyFormatter", this._locale, [ currency, options ] ) ];
104+
};
105+
106+
Globalize.formatCurrency =
107+
Globalize.prototype.formatCurrency = function( value, currency, options ) {
108+
validateParameterPresence( value, "value" );
109+
validateParameterTypeNumber( value, "value" );
110+
111+
return this.currencyFormatter( currency, options )( value );
112+
};
113+
114+
return Globalize;
115+
116+
117+
118+
119+
}));

0 commit comments

Comments
 (0)