* cldr.js:
* Web.config: * ListItem.cs: * styles.json: * globalize.js: * event.js: * Auth.aspx: * Book.aspx: * Login.aspx: * jquery-2.1.4.js: * map-load.gif: * Book.aspx: * Circle.cs: * Auth.aspx: * mapstyle.css: * date.js: * Login.aspx: * mdd_help.htm: * BlogHelper.cs: * fit-bounds.png: * unresolved.js: * jquery-2.1.4.min.js: * mapstyle-ie.css: * FreeDate.cs: * BookEdit.cs: * number.js: * BlogManager.cs: * plural.js: * jquery-2.1.4.min.map: * jquery.googlemaps.js: * supplemental.js: * BlogProvider.cs: * mapstyle.min.css: * pin-pink.png: * message.js: * ChooseADate.aspx: * pin-azure.png: * currency.js: * jquery-2.1.4-vsdoc.js: * pin-green.png: * MarkdownDeepLib.min.js: * flag-azure.png: * flag-green.png: * needle-pink.png: * ChooseADate.aspx: * niddle-green.png: * ChooseCalendar.aspx: * current-location.png: * jquery.googlemaps.min.js: * ErrorMessage.aspx: * ChooseCalendar.aspx: * relative-time.js: * GoogleErrorMessage.aspx: * popup-template-marker.html: * popup-template-circle.html: * popup-template-polygon.html: * popup-template-polyline.html: * popup-template-rectangle.html: * Web.csproj: * YavscModel.csproj: * YavscClient.csproj: * fortune.csproj: * WebControls.csproj: * SalesCatalog.csproj: * ITContentProvider.csproj: * NpgsqlMRPProviders.csproj: * NpgsqlBlogProvider.csproj: * NpgsqlContentProvider.csproj: Moves to Mono framework * NpgsqlCircleProvider.cs: Makes Circles private, or not * OAuth2.cs: * CircleController.cs: * AccountController.cs: * NpgsqlContentProvider.cs: Impacts htmldoc * NpgsqlMembershipProvider.cs: Makes possible to change the UserName * NpgsqlRoleProvider.cs: Drops this SQL code, which is actually maintained in Web/instdbws.sql * PeopleApi.cs: * GoogleController.cs: * PaypalController.cs: Refactoring * Global.asax.cs: Dropped an useless url mapping * MarkdownHelper.cs: Package update * App.master: * NoLogin.master: Site's favicon update * Circles.aspx: TO BE FIXED :-D * UserPost.aspx: Comment only when logged in * instdbws.sql: Circle public * packages.config: package update
This commit is contained in:
parent
cb2d9c5813
commit
87edbaffe5
91 changed files with 496 additions and 26262 deletions
|
|
@ -1,413 +0,0 @@
|
|||
/*!
|
||||
* Globalize v1.0.0
|
||||
*
|
||||
* http://github.com/jquery/globalize
|
||||
*
|
||||
* Copyright jQuery Foundation and other contributors
|
||||
* Released under the MIT license
|
||||
* http://jquery.org/license
|
||||
*
|
||||
* Date: 2015-04-23T12:02Z
|
||||
*/
|
||||
(function( root, factory ) {
|
||||
|
||||
// UMD returnExports
|
||||
if ( typeof define === "function" && define.amd ) {
|
||||
|
||||
// AMD
|
||||
define([
|
||||
"cldr",
|
||||
"../globalize",
|
||||
"./number",
|
||||
"cldr/event",
|
||||
"cldr/supplemental"
|
||||
], factory );
|
||||
} else if ( typeof exports === "object" ) {
|
||||
|
||||
// Node, CommonJS
|
||||
module.exports = factory( require( "cldrjs" ), require( "globalize" ) );
|
||||
} else {
|
||||
|
||||
// Global
|
||||
factory( root.Cldr, root.Globalize );
|
||||
}
|
||||
}(this, function( Cldr, Globalize ) {
|
||||
|
||||
var alwaysArray = Globalize._alwaysArray,
|
||||
formatMessage = Globalize._formatMessage,
|
||||
numberNumberingSystem = Globalize._numberNumberingSystem,
|
||||
numberPattern = Globalize._numberPattern,
|
||||
stringPad = Globalize._stringPad,
|
||||
validate = Globalize._validate,
|
||||
validateCldr = Globalize._validateCldr,
|
||||
validateDefaultLocale = Globalize._validateDefaultLocale,
|
||||
validateParameterPresence = Globalize._validateParameterPresence,
|
||||
validateParameterType = Globalize._validateParameterType,
|
||||
validateParameterTypeNumber = Globalize._validateParameterTypeNumber,
|
||||
validateParameterTypePlainObject = Globalize._validateParameterTypePlainObject;
|
||||
|
||||
|
||||
var validateParameterTypeCurrency = function( value, name ) {
|
||||
validateParameterType(
|
||||
value,
|
||||
name,
|
||||
value === undefined || typeof value === "string" && ( /^[A-Za-z]{3}$/ ).test( value ),
|
||||
"3-letter currency code string as defined by ISO 4217"
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
var validatePluralModulePresence = function() {
|
||||
validate( "E_MISSING_PLURAL_MODULE", "Plural module not loaded.",
|
||||
Globalize.plural !== undefined, {} );
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* supplementalOverride( currency, pattern, cldr )
|
||||
*
|
||||
* Return pattern with fraction digits overriden by supplemental currency data.
|
||||
*/
|
||||
var currencySupplementalOverride = function( currency, pattern, cldr ) {
|
||||
var digits,
|
||||
fraction = cldr.supplemental([ "currencyData/fractions", currency ]) ||
|
||||
cldr.supplemental( "currencyData/fractions/DEFAULT" );
|
||||
|
||||
digits = +fraction._digits;
|
||||
|
||||
if ( digits ) {
|
||||
fraction = "." + stringPad( "0", digits ).slice( 0, -1 ) + fraction._rounding;
|
||||
} else {
|
||||
fraction = "";
|
||||
}
|
||||
|
||||
return pattern.replace( /\.(#+|0*[0-9]|0+[0-9]?)/g, fraction );
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
var objectFilter = function( object, testRe ) {
|
||||
var key,
|
||||
copy = {};
|
||||
|
||||
for ( key in object ) {
|
||||
if ( testRe.test( key ) ) {
|
||||
copy[ key ] = object[ key ];
|
||||
}
|
||||
}
|
||||
|
||||
return copy;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
var currencyUnitPatterns = function( cldr ) {
|
||||
return objectFilter( cldr.main([
|
||||
"numbers",
|
||||
"currencyFormats-numberSystem-" + numberNumberingSystem( cldr )
|
||||
]), /^unitPattern/ );
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* codeProperties( currency, cldr )
|
||||
*
|
||||
* Return number pattern with the appropriate currency code in as literal.
|
||||
*/
|
||||
var currencyCodeProperties = function( currency, cldr ) {
|
||||
var pattern = numberPattern( "decimal", cldr );
|
||||
|
||||
// The number of decimal places and the rounding for each currency is not locale-specific. Those
|
||||
// values overridden by Supplemental Currency Data.
|
||||
pattern = currencySupplementalOverride( currency, pattern, cldr );
|
||||
|
||||
return {
|
||||
currency: currency,
|
||||
pattern: pattern,
|
||||
unitPatterns: currencyUnitPatterns( cldr )
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* nameFormat( formattedNumber, pluralForm, properties )
|
||||
*
|
||||
* Return the appropriate name form currency format.
|
||||
*/
|
||||
var currencyNameFormat = function( formattedNumber, pluralForm, properties ) {
|
||||
var displayName, unitPattern,
|
||||
displayNames = properties.displayNames || {},
|
||||
unitPatterns = properties.unitPatterns;
|
||||
|
||||
displayName = displayNames[ "displayName-count-" + pluralForm ] ||
|
||||
displayNames[ "displayName-count-other" ] ||
|
||||
displayNames.displayName ||
|
||||
properties.currency;
|
||||
unitPattern = unitPatterns[ "unitPattern-count-" + pluralForm ] ||
|
||||
unitPatterns[ "unitPattern-count-other" ];
|
||||
|
||||
return formatMessage( unitPattern, [ formattedNumber, displayName ]);
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* nameProperties( currency, cldr )
|
||||
*
|
||||
* Return number pattern with the appropriate currency code in as literal.
|
||||
*/
|
||||
var currencyNameProperties = function( currency, cldr ) {
|
||||
var properties = currencyCodeProperties( currency, cldr );
|
||||
|
||||
properties.displayNames = objectFilter( cldr.main([
|
||||
"numbers/currencies",
|
||||
currency
|
||||
]), /^displayName/ );
|
||||
|
||||
return properties;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Unicode regular expression for: everything except math symbols, currency signs, dingbats, and
|
||||
* box-drawing characters.
|
||||
*
|
||||
* Generated by:
|
||||
*
|
||||
* regenerate()
|
||||
* .addRange( 0x0, 0x10FFFF )
|
||||
* .remove( require( "unicode-7.0.0/categories/S/symbols" ) ).toString();
|
||||
*
|
||||
* https://github.com/mathiasbynens/regenerate
|
||||
* https://github.com/mathiasbynens/unicode-7.0.0
|
||||
*/
|
||||
var regexpNotS = /[\0-#%-\*,-;\?-\]_a-\{\}\x7F-\xA1\xA7\xAA\xAB\xAD\xB2\xB3\xB5-\xB7\xB9-\xD6\xD8-\xF6\xF8-\u02C1\u02C6-\u02D1\u02E0-\u02E4\u02EC\u02EE\u0300-\u0374\u0376-\u0383\u0386-\u03F5\u03F7-\u0481\u0483-\u058C\u0590-\u0605\u0609\u060A\u060C\u060D\u0610-\u06DD\u06DF-\u06E8\u06EA-\u06FC\u06FF-\u07F5\u07F7-\u09F1\u09F4-\u09F9\u09FC-\u0AF0\u0AF2-\u0B6F\u0B71-\u0BF2\u0BFB-\u0C7E\u0C80-\u0D78\u0D7A-\u0E3E\u0E40-\u0F00\u0F04-\u0F12\u0F14\u0F18\u0F19\u0F20-\u0F33\u0F35\u0F37\u0F39-\u0FBD\u0FC6\u0FCD\u0FD0-\u0FD4\u0FD9-\u109D\u10A0-\u138F\u139A-\u17DA\u17DC-\u193F\u1941-\u19DD\u1A00-\u1B60\u1B6B-\u1B73\u1B7D-\u1FBC\u1FBE\u1FC2-\u1FCC\u1FD0-\u1FDC\u1FE0-\u1FEC\u1FF0-\u1FFC\u1FFF-\u2043\u2045-\u2051\u2053-\u2079\u207D-\u2089\u208D-\u209F\u20BE-\u20FF\u2102\u2107\u210A-\u2113\u2115\u2119-\u211D\u2124\u2126\u2128\u212A-\u212D\u212F-\u2139\u213C-\u213F\u2145-\u2149\u214E\u2150-\u218F\u2308-\u230B\u2329\u232A\u23FB-\u23FF\u2427-\u243F\u244B-\u249B\u24EA-\u24FF\u2768-\u2793\u27C5\u27C6\u27E6-\u27EF\u2983-\u2998\u29D8-\u29DB\u29FC\u29FD\u2B74\u2B75\u2B96\u2B97\u2BBA-\u2BBC\u2BC9\u2BD2-\u2CE4\u2CEB-\u2E7F\u2E9A\u2EF4-\u2EFF\u2FD6-\u2FEF\u2FFC-\u3003\u3005-\u3011\u3014-\u301F\u3021-\u3035\u3038-\u303D\u3040-\u309A\u309D-\u318F\u3192-\u3195\u31A0-\u31BF\u31E4-\u31FF\u321F-\u3229\u3248-\u324F\u3251-\u325F\u3280-\u3289\u32B1-\u32BF\u32FF\u3400-\u4DBF\u4E00-\uA48F\uA4C7-\uA6FF\uA717-\uA71F\uA722-\uA788\uA78B-\uA827\uA82C-\uA835\uA83A-\uAA76\uAA7A-\uAB5A\uAB5C-\uD7FF\uDC00-\uFB28\uFB2A-\uFBB1\uFBC2-\uFDFB\uFDFE-\uFE61\uFE63\uFE67\uFE68\uFE6A-\uFF03\uFF05-\uFF0A\uFF0C-\uFF1B\uFF1F-\uFF3D\uFF3F\uFF41-\uFF5B\uFF5D\uFF5F-\uFFDF\uFFE7\uFFEF-\uFFFB\uFFFE\uFFFF]|\uD800[\uDC00-\uDD36\uDD40-\uDD78\uDD8A\uDD8B\uDD8D-\uDD8F\uDD9C-\uDD9F\uDDA1-\uDDCF\uDDFD-\uDFFF]|[\uD801\uD803-\uD819\uD81B-\uD82E\uD830-\uD833\uD836-\uD83A\uD83F-\uDBFF][\uDC00-\uDFFF]|\uD802[\uDC00-\uDC76\uDC79-\uDEC7\uDEC9-\uDFFF]|\uD81A[\uDC00-\uDF3B\uDF40-\uDF44\uDF46-\uDFFF]|\uD82F[\uDC00-\uDC9B\uDC9D-\uDFFF]|\uD834[\uDCF6-\uDCFF\uDD27\uDD28\uDD65-\uDD69\uDD6D-\uDD82\uDD85-\uDD8B\uDDAA-\uDDAD\uDDDE-\uDDFF\uDE42-\uDE44\uDE46-\uDEFF\uDF57-\uDFFF]|\uD835[\uDC00-\uDEC0\uDEC2-\uDEDA\uDEDC-\uDEFA\uDEFC-\uDF14\uDF16-\uDF34\uDF36-\uDF4E\uDF50-\uDF6E\uDF70-\uDF88\uDF8A-\uDFA8\uDFAA-\uDFC2\uDFC4-\uDFFF]|\uD83B[\uDC00-\uDEEF\uDEF2-\uDFFF]|\uD83C[\uDC2C-\uDC2F\uDC94-\uDC9F\uDCAF\uDCB0\uDCC0\uDCD0\uDCF6-\uDD0F\uDD2F\uDD6C-\uDD6F\uDD9B-\uDDE5\uDE03-\uDE0F\uDE3B-\uDE3F\uDE49-\uDE4F\uDE52-\uDEFF\uDF2D-\uDF2F\uDF7E\uDF7F\uDFCF-\uDFD3\uDFF8-\uDFFF]|\uD83D[\uDCFF\uDD4B-\uDD4F\uDD7A\uDDA4\uDE43\uDE44\uDED0-\uDEDF\uDEED-\uDEEF\uDEF4-\uDEFF\uDF74-\uDF7F\uDFD5-\uDFFF]|\uD83E[\uDC0C-\uDC0F\uDC48-\uDC4F\uDC5A-\uDC5F\uDC88-\uDC8F\uDCAE-\uDFFF]|[\uD800-\uDBFF]/;
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* symbolProperties( currency, cldr )
|
||||
*
|
||||
* Return pattern replacing `¤` with the appropriate currency symbol literal.
|
||||
*/
|
||||
var currencySymbolProperties = function( currency, cldr, options ) {
|
||||
var currencySpacing, pattern,
|
||||
regexp = {
|
||||
"[:digit:]": /\d/,
|
||||
"[:^S:]": regexpNotS
|
||||
},
|
||||
symbol = cldr.main([
|
||||
"numbers/currencies",
|
||||
currency,
|
||||
"symbol"
|
||||
]);
|
||||
|
||||
currencySpacing = [ "beforeCurrency", "afterCurrency" ].map(function( position ) {
|
||||
return cldr.main([
|
||||
"numbers",
|
||||
"currencyFormats-numberSystem-" + numberNumberingSystem( cldr ),
|
||||
"currencySpacing",
|
||||
position
|
||||
]);
|
||||
});
|
||||
|
||||
pattern = cldr.main([
|
||||
"numbers",
|
||||
"currencyFormats-numberSystem-" + numberNumberingSystem( cldr ),
|
||||
options.style === "accounting" ? "accounting" : "standard"
|
||||
]);
|
||||
|
||||
pattern =
|
||||
|
||||
// The number of decimal places and the rounding for each currency is not locale-specific.
|
||||
// Those values are overridden by Supplemental Currency Data.
|
||||
currencySupplementalOverride( currency, pattern, cldr )
|
||||
|
||||
// Replace "¤" (\u00A4) with the appropriate symbol literal.
|
||||
.split( ";" ).map(function( pattern ) {
|
||||
|
||||
return pattern.split( "\u00A4" ).map(function( part, i ) {
|
||||
var currencyMatch = regexp[ currencySpacing[ i ].currencyMatch ],
|
||||
surroundingMatch = regexp[ currencySpacing[ i ].surroundingMatch ],
|
||||
insertBetween = "";
|
||||
|
||||
// For currencyMatch and surroundingMatch definitions, read [1].
|
||||
// When i === 0, beforeCurrency is being handled. Otherwise, afterCurrency.
|
||||
// 1: http://www.unicode.org/reports/tr35/tr35-numbers.html#Currencies
|
||||
currencyMatch = currencyMatch.test( symbol.charAt( i ? symbol.length - 1 : 0 ) );
|
||||
surroundingMatch = surroundingMatch.test(
|
||||
part.charAt( i ? 0 : part.length - 1 ).replace( /[#@,.]/g, "0" )
|
||||
);
|
||||
|
||||
if ( currencyMatch && part && surroundingMatch ) {
|
||||
insertBetween = currencySpacing[ i ].insertBetween;
|
||||
}
|
||||
|
||||
return ( i ? insertBetween : "" ) + part + ( i ? "" : insertBetween );
|
||||
}).join( "'" + symbol + "'" );
|
||||
}).join( ";" );
|
||||
|
||||
return {
|
||||
pattern: pattern
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* objectOmit( object, keys )
|
||||
*
|
||||
* Return a copy of the object, filtered to omit the blacklisted key or array of keys.
|
||||
*/
|
||||
var objectOmit = function( object, keys ) {
|
||||
var key,
|
||||
copy = {};
|
||||
|
||||
keys = alwaysArray( keys );
|
||||
|
||||
for ( key in object ) {
|
||||
if ( keys.indexOf( key ) === -1 ) {
|
||||
copy[ key ] = object[ key ];
|
||||
}
|
||||
}
|
||||
|
||||
return copy;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
function validateRequiredCldr( path, value ) {
|
||||
validateCldr( path, value, {
|
||||
skip: [ /supplemental\/currencyData\/fractions\/[A-Za-z]{3}$/ ]
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* .currencyFormatter( currency [, options] )
|
||||
*
|
||||
* @currency [String] 3-letter currency code as defined by ISO 4217.
|
||||
*
|
||||
* @options [Object]:
|
||||
* - style: [String] "symbol" (default), "accounting", "code" or "name".
|
||||
* - see also number/format options.
|
||||
*
|
||||
* Return a function that formats a currency according to the given options and default/instance
|
||||
* locale.
|
||||
*/
|
||||
Globalize.currencyFormatter =
|
||||
Globalize.prototype.currencyFormatter = function( currency, options ) {
|
||||
var cldr, numberFormatter, plural, properties, style;
|
||||
|
||||
validateParameterPresence( currency, "currency" );
|
||||
validateParameterTypeCurrency( currency, "currency" );
|
||||
|
||||
validateParameterTypePlainObject( options, "options" );
|
||||
|
||||
options = options || {};
|
||||
style = options.style || "symbol";
|
||||
cldr = this.cldr;
|
||||
|
||||
validateDefaultLocale( cldr );
|
||||
|
||||
// Get properties given style ("symbol" default, "code" or "name").
|
||||
cldr.on( "get", validateRequiredCldr );
|
||||
properties = ({
|
||||
accounting: currencySymbolProperties,
|
||||
code: currencyCodeProperties,
|
||||
name: currencyNameProperties,
|
||||
symbol: currencySymbolProperties
|
||||
}[ style ] )( currency, cldr, options );
|
||||
cldr.off( "get", validateRequiredCldr );
|
||||
|
||||
// options = options minus style, plus raw pattern.
|
||||
options = objectOmit( options, "style" );
|
||||
options.raw = properties.pattern;
|
||||
|
||||
// Return formatter when style is "symbol" or "accounting".
|
||||
if ( style === "symbol" || style === "accounting" ) {
|
||||
return this.numberFormatter( options );
|
||||
}
|
||||
|
||||
// Return formatter when style is "code" or "name".
|
||||
validatePluralModulePresence();
|
||||
numberFormatter = this.numberFormatter( options );
|
||||
plural = this.pluralGenerator();
|
||||
return function( value ) {
|
||||
validateParameterPresence( value, "value" );
|
||||
validateParameterTypeNumber( value, "value" );
|
||||
return currencyNameFormat( numberFormatter( value ), plural( value ), properties );
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* .currencyParser( currency [, options] )
|
||||
*
|
||||
* @currency [String] 3-letter currency code as defined by ISO 4217.
|
||||
*
|
||||
* @options [Object] see currencyFormatter.
|
||||
*
|
||||
* Return the currency parser according to the given options and the default/instance locale.
|
||||
*/
|
||||
Globalize.currencyParser =
|
||||
Globalize.prototype.currencyParser = function( /* currency, options */ ) {
|
||||
|
||||
// TODO implement parser.
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* .formatCurrency( value, currency [, options] )
|
||||
*
|
||||
* @value [Number] number to be formatted.
|
||||
*
|
||||
* @currency [String] 3-letter currency code as defined by ISO 4217.
|
||||
*
|
||||
* @options [Object] see currencyFormatter.
|
||||
*
|
||||
* Format a currency according to the given options and the default/instance locale.
|
||||
*/
|
||||
Globalize.formatCurrency =
|
||||
Globalize.prototype.formatCurrency = function( value, currency, options ) {
|
||||
validateParameterPresence( value, "value" );
|
||||
validateParameterTypeNumber( value, "value" );
|
||||
|
||||
return this.currencyFormatter( currency, options )( value );
|
||||
};
|
||||
|
||||
/**
|
||||
* .parseCurrency( value, currency [, options] )
|
||||
*
|
||||
* @value [String]
|
||||
*
|
||||
* @currency [String] 3-letter currency code as defined by ISO 4217.
|
||||
*
|
||||
* @options [Object]: See currencyFormatter.
|
||||
*
|
||||
* Return the parsed currency or NaN when value is invalid.
|
||||
*/
|
||||
Globalize.parseCurrency =
|
||||
Globalize.prototype.parseCurrency = function( /* value, currency, options */ ) {
|
||||
};
|
||||
|
||||
return Globalize;
|
||||
|
||||
|
||||
|
||||
|
||||
}));
|
||||
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
|
@ -1,359 +0,0 @@
|
|||
/**
|
||||
* Globalize v1.0.0
|
||||
*
|
||||
* http://github.com/jquery/globalize
|
||||
*
|
||||
* Copyright jQuery Foundation and other contributors
|
||||
* Released under the MIT license
|
||||
* http://jquery.org/license
|
||||
*
|
||||
* Date: 2015-04-23T12:02Z
|
||||
*/
|
||||
/*!
|
||||
* Globalize v1.0.0 2015-04-23T12:02Z Released under the MIT license
|
||||
* http://git.io/TrdQbw
|
||||
*/
|
||||
(function( root, factory ) {
|
||||
|
||||
// UMD returnExports
|
||||
if ( typeof define === "function" && define.amd ) {
|
||||
|
||||
// AMD
|
||||
define([
|
||||
"cldr",
|
||||
"../globalize",
|
||||
"cldr/event",
|
||||
"cldr/supplemental"
|
||||
], factory );
|
||||
} else if ( typeof exports === "object" ) {
|
||||
|
||||
// Node, CommonJS
|
||||
module.exports = factory( require( "cldrjs" ), require( "globalize" ) );
|
||||
} else {
|
||||
|
||||
// Global
|
||||
factory( root.Cldr, root.Globalize );
|
||||
}
|
||||
}(this, function( Cldr, Globalize ) {
|
||||
|
||||
var validateCldr = Globalize._validateCldr,
|
||||
validateDefaultLocale = Globalize._validateDefaultLocale,
|
||||
validateParameterPresence = Globalize._validateParameterPresence,
|
||||
validateParameterType = Globalize._validateParameterType,
|
||||
validateParameterTypePlainObject = Globalize._validateParameterTypePlainObject;
|
||||
var MakePlural;
|
||||
/* jshint ignore:start */
|
||||
MakePlural = (function() {
|
||||
|
||||
|
||||
var _toArray = function (arr) { return Array.isArray(arr) ? arr : Array.from(arr); };
|
||||
|
||||
var _toConsumableArray = function (arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) arr2[i] = arr[i]; return arr2; } else { return Array.from(arr); } };
|
||||
|
||||
var _classCallCheck = function (instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } };
|
||||
|
||||
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
|
||||
|
||||
|
||||
/**
|
||||
* make-plural.js -- https://github.com/eemeli/make-plural.js/
|
||||
* Copyright (c) 2014-2015 by Eemeli Aro <eemeli@gmail.com>
|
||||
*
|
||||
* Permission to use, copy, modify, and/or distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* The software is provided "as is" and the author disclaims all warranties
|
||||
* with regard to this software including all implied warranties of
|
||||
* merchantability and fitness. In no event shall the author be liable for
|
||||
* any special, direct, indirect, or consequential damages or any damages
|
||||
* whatsoever resulting from loss of use, data or profits, whether in an
|
||||
* action of contract, negligence or other tortious action, arising out of
|
||||
* or in connection with the use or performance of this software.
|
||||
*/
|
||||
|
||||
var Parser = (function () {
|
||||
function Parser() {
|
||||
_classCallCheck(this, Parser);
|
||||
}
|
||||
|
||||
_createClass(Parser, [{
|
||||
key: 'parse',
|
||||
value: function parse(cond) {
|
||||
var _this = this;
|
||||
|
||||
if (cond === 'i = 0 or n = 1') {
|
||||
return 'n >= 0 && n <= 1';
|
||||
}if (cond === 'i = 0,1') {
|
||||
return 'n >= 0 && n < 2';
|
||||
}if (cond === 'i = 1 and v = 0') {
|
||||
this.v0 = 1;
|
||||
return 'n == 1 && v0';
|
||||
}
|
||||
return cond.replace(/([tv]) (!?)= 0/g, function (m, sym, noteq) {
|
||||
var sn = sym + '0';
|
||||
_this[sn] = 1;
|
||||
return noteq ? '!' + sn : sn;
|
||||
}).replace(/\b[fintv]\b/g, function (m) {
|
||||
_this[m] = 1;
|
||||
return m;
|
||||
}).replace(/([fin]) % (10+)/g, function (m, sym, num) {
|
||||
var sn = sym + num;
|
||||
_this[sn] = 1;
|
||||
return sn;
|
||||
}).replace(/n10+ = 0/g, 't0 && $&').replace(/(\w+ (!?)= )([0-9.]+,[0-9.,]+)/g, function (m, se, noteq, x) {
|
||||
if (m === 'n = 0,1') return '(n == 0 || n == 1)';
|
||||
if (noteq) return se + x.split(',').join(' && ' + se);
|
||||
return '(' + se + x.split(',').join(' || ' + se) + ')';
|
||||
}).replace(/(\w+) (!?)= ([0-9]+)\.\.([0-9]+)/g, function (m, sym, noteq, x0, x1) {
|
||||
if (Number(x0) + 1 === Number(x1)) {
|
||||
if (noteq) return '' + sym + ' != ' + x0 + ' && ' + sym + ' != ' + x1;
|
||||
return '(' + sym + ' == ' + x0 + ' || ' + sym + ' == ' + x1 + ')';
|
||||
}
|
||||
if (noteq) return '(' + sym + ' < ' + x0 + ' || ' + sym + ' > ' + x1 + ')';
|
||||
if (sym === 'n') {
|
||||
_this.t0 = 1;return '(t0 && n >= ' + x0 + ' && n <= ' + x1 + ')';
|
||||
}
|
||||
return '(' + sym + ' >= ' + x0 + ' && ' + sym + ' <= ' + x1 + ')';
|
||||
}).replace(/ and /g, ' && ').replace(/ or /g, ' || ').replace(/ = /g, ' == ');
|
||||
}
|
||||
}, {
|
||||
key: 'vars',
|
||||
value: (function (_vars) {
|
||||
function vars() {
|
||||
return _vars.apply(this, arguments);
|
||||
}
|
||||
|
||||
vars.toString = function () {
|
||||
return _vars.toString();
|
||||
};
|
||||
|
||||
return vars;
|
||||
})(function () {
|
||||
var vars = [];
|
||||
if (this.i) vars.push('i = s[0]');
|
||||
if (this.f || this.v) vars.push('f = s[1] || \'\'');
|
||||
if (this.t) vars.push('t = (s[1] || \'\').replace(/0+$/, \'\')');
|
||||
if (this.v) vars.push('v = f.length');
|
||||
if (this.v0) vars.push('v0 = !s[1]');
|
||||
if (this.t0 || this.n10 || this.n100) vars.push('t0 = Number(s[0]) == n');
|
||||
for (var k in this) {
|
||||
if (/^.10+$/.test(k)) {
|
||||
var k0 = k[0] === 'n' ? 't0 && s[0]' : k[0];
|
||||
vars.push('' + k + ' = ' + k0 + '.slice(-' + k.substr(2).length + ')');
|
||||
}
|
||||
}if (!vars.length) return '';
|
||||
return 'var ' + ['s = String(n).split(\'.\')'].concat(vars).join(', ');
|
||||
})
|
||||
}]);
|
||||
|
||||
return Parser;
|
||||
})();
|
||||
|
||||
|
||||
|
||||
var MakePlural = (function () {
|
||||
function MakePlural(lc) {
|
||||
var _ref = arguments[1] === undefined ? MakePlural : arguments[1];
|
||||
|
||||
var cardinals = _ref.cardinals;
|
||||
var ordinals = _ref.ordinals;
|
||||
|
||||
_classCallCheck(this, MakePlural);
|
||||
|
||||
if (!cardinals && !ordinals) throw new Error('At least one type of plural is required');
|
||||
this.lc = lc;
|
||||
this.categories = { cardinal: [], ordinal: [] };
|
||||
this.parser = new Parser();
|
||||
|
||||
this.fn = this.buildFunction(cardinals, ordinals);
|
||||
this.fn._obj = this;
|
||||
this.fn.categories = this.categories;
|
||||
|
||||
this.fn.toString = this.fnToString.bind(this);
|
||||
return this.fn;
|
||||
}
|
||||
|
||||
_createClass(MakePlural, [{
|
||||
key: 'compile',
|
||||
value: function compile(type, req) {
|
||||
var cases = [];
|
||||
var rules = MakePlural.rules[type][this.lc];
|
||||
if (!rules) {
|
||||
if (req) throw new Error('Locale "' + this.lc + '" ' + type + ' rules not found');
|
||||
this.categories[type] = ['other'];
|
||||
return '\'other\'';
|
||||
}
|
||||
for (var r in rules) {
|
||||
var _rules$r$trim$split = rules[r].trim().split(/\s*@\w*/);
|
||||
|
||||
var _rules$r$trim$split2 = _toArray(_rules$r$trim$split);
|
||||
|
||||
var cond = _rules$r$trim$split2[0];
|
||||
var examples = _rules$r$trim$split2.slice(1);
|
||||
var cat = r.replace('pluralRule-count-', '');
|
||||
if (cond) cases.push([this.parser.parse(cond), cat]);
|
||||
|
||||
}
|
||||
this.categories[type] = cases.map(function (c) {
|
||||
return c[1];
|
||||
}).concat('other');
|
||||
if (cases.length === 1) {
|
||||
return '(' + cases[0][0] + ') ? \'' + cases[0][1] + '\' : \'other\'';
|
||||
} else {
|
||||
return [].concat(_toConsumableArray(cases.map(function (c) {
|
||||
return '(' + c[0] + ') ? \'' + c[1] + '\'';
|
||||
})), ['\'other\'']).join('\n : ');
|
||||
}
|
||||
}
|
||||
}, {
|
||||
key: 'buildFunction',
|
||||
value: function buildFunction(cardinals, ordinals) {
|
||||
var _this3 = this;
|
||||
|
||||
var compile = function compile(c) {
|
||||
return c ? (c[1] ? 'return ' : 'if (ord) return ') + _this3.compile.apply(_this3, _toConsumableArray(c)) : '';
|
||||
},
|
||||
fold = { vars: function vars(str) {
|
||||
return (' ' + str + ';').replace(/(.{1,78})(,|$) ?/g, '$1$2\n ');
|
||||
},
|
||||
cond: function cond(str) {
|
||||
return (' ' + str + ';').replace(/(.{1,78}) (\|\| |$) ?/gm, '$1\n $2');
|
||||
} },
|
||||
cond = [ordinals && ['ordinal', !cardinals], cardinals && ['cardinal', true]].map(compile).map(fold.cond),
|
||||
body = [fold.vars(this.parser.vars())].concat(_toConsumableArray(cond)).join('\n').replace(/\s+$/gm, '').replace(/^[\s;]*[\r\n]+/gm, ''),
|
||||
args = ordinals && cardinals ? 'n, ord' : 'n';
|
||||
return new Function(args, body);
|
||||
}
|
||||
}, {
|
||||
key: 'fnToString',
|
||||
value: function fnToString(name) {
|
||||
return Function.prototype.toString.call(this.fn).replace(/^function( \w+)?/, name ? 'function ' + name : 'function').replace('\n/**/', '');
|
||||
}
|
||||
}], [{
|
||||
key: 'load',
|
||||
value: function load() {
|
||||
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
|
||||
args[_key] = arguments[_key];
|
||||
}
|
||||
|
||||
args.forEach(function (cldr) {
|
||||
var data = cldr && cldr.supplemental || null;
|
||||
if (!data) throw new Error('Data does not appear to be CLDR data');
|
||||
MakePlural.rules = {
|
||||
cardinal: data['plurals-type-cardinal'] || MakePlural.rules.cardinal,
|
||||
ordinal: data['plurals-type-ordinal'] || MakePlural.rules.ordinal
|
||||
};
|
||||
});
|
||||
return MakePlural;
|
||||
}
|
||||
}]);
|
||||
|
||||
return MakePlural;
|
||||
})();
|
||||
|
||||
|
||||
|
||||
MakePlural.cardinals = true;
|
||||
MakePlural.ordinals = false;
|
||||
MakePlural.rules = { cardinal: {}, ordinal: {} };
|
||||
|
||||
|
||||
return MakePlural;
|
||||
}());
|
||||
/* jshint ignore:end */
|
||||
|
||||
|
||||
var validateParameterTypeNumber = function( value, name ) {
|
||||
validateParameterType(
|
||||
value,
|
||||
name,
|
||||
value === undefined || typeof value === "number",
|
||||
"Number"
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
var validateParameterTypePluralType = function( value, name ) {
|
||||
validateParameterType(
|
||||
value,
|
||||
name,
|
||||
value === undefined || value === "cardinal" || value === "ordinal",
|
||||
"String \"cardinal\" or \"ordinal\""
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* .plural( value )
|
||||
*
|
||||
* @value [Number]
|
||||
*
|
||||
* Return the corresponding form (zero | one | two | few | many | other) of a
|
||||
* value given locale.
|
||||
*/
|
||||
Globalize.plural =
|
||||
Globalize.prototype.plural = function( value, options ) {
|
||||
validateParameterPresence( value, "value" );
|
||||
validateParameterTypeNumber( value, "value" );
|
||||
return this.pluralGenerator( options )( value );
|
||||
};
|
||||
|
||||
/**
|
||||
* .pluralGenerator( [options] )
|
||||
*
|
||||
* Return a plural function (of the form below).
|
||||
*
|
||||
* fn( value )
|
||||
*
|
||||
* @value [Number]
|
||||
*
|
||||
* Return the corresponding form (zero | one | two | few | many | other) of a value given the
|
||||
* default/instance locale.
|
||||
*/
|
||||
Globalize.pluralGenerator =
|
||||
Globalize.prototype.pluralGenerator = function( options ) {
|
||||
var cldr, isOrdinal, plural, type;
|
||||
|
||||
validateParameterTypePlainObject( options, "options" );
|
||||
|
||||
options = options || {};
|
||||
type = options.type || "cardinal";
|
||||
cldr = this.cldr;
|
||||
|
||||
validateParameterTypePluralType( options.type, "options.type" );
|
||||
|
||||
validateDefaultLocale( cldr );
|
||||
|
||||
isOrdinal = type === "ordinal";
|
||||
|
||||
cldr.on( "get", validateCldr );
|
||||
cldr.supplemental([ "plurals-type-" + type, "{language}" ]);
|
||||
cldr.off( "get", validateCldr );
|
||||
|
||||
MakePlural.rules = {};
|
||||
MakePlural.rules[ type ] = cldr.supplemental( "plurals-type-" + type );
|
||||
|
||||
plural = new MakePlural( cldr.attributes.language, {
|
||||
"ordinals": isOrdinal,
|
||||
"cardinals": !isOrdinal
|
||||
});
|
||||
|
||||
return function( value ) {
|
||||
validateParameterPresence( value, "value" );
|
||||
validateParameterTypeNumber( value, "value" );
|
||||
|
||||
return plural( value );
|
||||
};
|
||||
};
|
||||
|
||||
return Globalize;
|
||||
|
||||
|
||||
|
||||
|
||||
}));
|
||||
|
|
@ -1,187 +0,0 @@
|
|||
/**
|
||||
* Globalize v1.0.0
|
||||
*
|
||||
* http://github.com/jquery/globalize
|
||||
*
|
||||
* Copyright 2010, 2014 jQuery Foundation, Inc. and other contributors
|
||||
* Released under the MIT license
|
||||
* http://jquery.org/license
|
||||
*
|
||||
* Date: 2015-04-23T12:02Z
|
||||
*/
|
||||
/*!
|
||||
* Globalize v1.0.0 2015-04-23T12:02Z Released under the MIT license
|
||||
* http://git.io/TrdQbw
|
||||
*/
|
||||
(function( root, factory ) {
|
||||
|
||||
// UMD returnExports
|
||||
if ( typeof define === "function" && define.amd ) {
|
||||
|
||||
// AMD
|
||||
define([
|
||||
"cldr",
|
||||
"../globalize",
|
||||
"./number",
|
||||
"./plural",
|
||||
"cldr/event",
|
||||
"cldr/supplemental"
|
||||
], factory );
|
||||
} else if ( typeof exports === "object" ) {
|
||||
|
||||
// Node, CommonJS
|
||||
module.exports = factory( require( "cldrjs" ), require( "globalize" ) );
|
||||
} else {
|
||||
|
||||
// Extend global
|
||||
factory( root.Cldr, root.Globalize );
|
||||
}
|
||||
}(this, function( Cldr, Globalize ) {
|
||||
|
||||
var formatMessage = Globalize._formatMessage,
|
||||
validateCldr = Globalize._validateCldr,
|
||||
validateDefaultLocale = Globalize._validateDefaultLocale,
|
||||
validateParameterPresence = Globalize._validateParameterPresence,
|
||||
validateParameterTypeString = Globalize._validateParameterTypeString,
|
||||
validateParameterTypeNumber = Globalize._validateParameterTypeNumber;
|
||||
|
||||
|
||||
/**
|
||||
* format( value, numberFormatter, pluralGenerator, properties )
|
||||
*
|
||||
* @value [Number] The number to format
|
||||
*
|
||||
* @numberFormatter [String] A numberFormatter from Globalize.numberFormatter
|
||||
*
|
||||
* @pluralGenerator [String] A pluralGenerator from Globalize.pluralGenerator
|
||||
*
|
||||
* @properties [Object] containing relative time plural message.
|
||||
*
|
||||
* Format relative time.
|
||||
*/
|
||||
var relativeTimeFormat = function( value, numberFormatter, pluralGenerator, properties ) {
|
||||
|
||||
var relativeTime,
|
||||
message = properties[ "relative-type-" + value ];
|
||||
|
||||
if ( message ) {
|
||||
return message;
|
||||
}
|
||||
|
||||
relativeTime = value <= 0 ? properties[ "relativeTime-type-past" ]
|
||||
: properties[ "relativeTime-type-future" ];
|
||||
|
||||
value = Math.abs( value );
|
||||
|
||||
message = relativeTime[ "relativeTimePattern-count-" + pluralGenerator( value ) ];
|
||||
return formatMessage( message, [ numberFormatter( value ) ] );
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* properties( unit, cldr, options )
|
||||
*
|
||||
* @unit [String] eg. "day", "week", "month", etc.
|
||||
*
|
||||
* @cldr [Cldr instance].
|
||||
*
|
||||
* @options [Object]
|
||||
* - form: [String] eg. "short" or "narrow". Or falsy for default long form.
|
||||
*
|
||||
* Return relative time properties.
|
||||
*/
|
||||
var relativeTimeProperties = function( unit, cldr, options ) {
|
||||
|
||||
var form = options.form,
|
||||
raw, properties, key, match;
|
||||
|
||||
if ( form ) {
|
||||
unit = unit + "-" + form;
|
||||
}
|
||||
|
||||
raw = cldr.main( [ "dates", "fields", unit ] );
|
||||
properties = {
|
||||
"relativeTime-type-future": raw[ "relativeTime-type-future" ],
|
||||
"relativeTime-type-past": raw[ "relativeTime-type-past" ]
|
||||
};
|
||||
for ( key in raw ) {
|
||||
if ( raw.hasOwnProperty( key ) ) {
|
||||
match = /relative-type-(-?[0-9]+)/.exec( key );
|
||||
if ( match ) {
|
||||
properties[ key ] = raw[ key ];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return properties;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* .formatRelativeTime( value, unit [, options] )
|
||||
*
|
||||
* @value [Number] The number of unit to format.
|
||||
*
|
||||
* @unit [String] see .relativeTimeFormatter() for details.
|
||||
*
|
||||
* @options [Object] see .relativeTimeFormatter() for details.
|
||||
*
|
||||
* Formats a relative time according to the given unit, options, and the default/instance locale.
|
||||
*/
|
||||
Globalize.formatRelativeTime =
|
||||
Globalize.prototype.formatRelativeTime = function( value, unit, options ) {
|
||||
|
||||
validateParameterPresence( value, "value" );
|
||||
validateParameterTypeNumber( value, "value" );
|
||||
|
||||
return this.relativeTimeFormatter( unit, options )( value );
|
||||
};
|
||||
|
||||
/**
|
||||
* .relativeTimeFormatter( unit [, options ])
|
||||
*
|
||||
* @unit [String] String value indicating the unit to be formatted. eg. "day", "week", "month", etc.
|
||||
*
|
||||
* @options [Object]
|
||||
* - form: [String] eg. "short" or "narrow". Or falsy for default long form.
|
||||
*
|
||||
* Returns a function that formats a relative time according to the given unit, options, and the
|
||||
* default/instance locale.
|
||||
*/
|
||||
Globalize.relativeTimeFormatter =
|
||||
Globalize.prototype.relativeTimeFormatter = function( unit, options ) {
|
||||
var cldr, numberFormatter, pluralGenerator, properties;
|
||||
|
||||
validateParameterPresence( unit, "unit" );
|
||||
validateParameterTypeString( unit, "unit" );
|
||||
|
||||
cldr = this.cldr;
|
||||
options = options || {};
|
||||
|
||||
validateDefaultLocale( cldr );
|
||||
|
||||
cldr.on( "get", validateCldr );
|
||||
properties = relativeTimeProperties( unit, cldr, options );
|
||||
cldr.off( "get", validateCldr );
|
||||
|
||||
numberFormatter = this.numberFormatter( options );
|
||||
pluralGenerator = this.pluralGenerator();
|
||||
|
||||
return function( value ) {
|
||||
validateParameterPresence( value, "value" );
|
||||
validateParameterTypeNumber( value, "value" );
|
||||
|
||||
return relativeTimeFormat( value, numberFormatter, pluralGenerator, properties );
|
||||
};
|
||||
};
|
||||
|
||||
return Globalize;
|
||||
|
||||
|
||||
|
||||
|
||||
}));
|
||||
Loading…
Add table
Add a link
Reference in a new issue