From 4b6abc7f09a13e472d43d59aa1c8c7f9be13e0e9 Mon Sep 17 00:00:00 2001 From: Jason Quense Date: Tue, 12 Jan 2016 17:09:23 -0500 Subject: [PATCH] [fixed] localizer dist files --- .eslintrc | 3 +- build/configure-shim.js | 4 +++ build/localizers.config.js | 55 +++++++++++++++++++++++++---- dist/react-widgets-globalize.js | 29 +++++++++++---- dist/react-widgets-moment.js | 22 +++++++++--- dist/react-widgets-simple-number.js | 36 +++++++++++++++---- src/localizers/moment.js | 2 +- test/browser-test.html | 10 +++--- 8 files changed, 130 insertions(+), 31 deletions(-) diff --git a/.eslintrc b/.eslintrc index 7b63fc653..7600bf4a8 100644 --- a/.eslintrc +++ b/.eslintrc @@ -21,7 +21,6 @@ "curly": 0, "eqeqeq": [2, "allow-null"], "no-undef": 2, - "no-unused-vars": 2, "quotes": [2, "single", "avoid-escape"], "no-trailing-spaces": 0, "no-underscore-dangle": 0, @@ -40,4 +39,4 @@ "react/react-in-jsx-scope": 1, "react/self-closing-comp": 1 } -} \ No newline at end of file +} diff --git a/build/configure-shim.js b/build/configure-shim.js index e69de29bb..5f89e2696 100644 --- a/build/configure-shim.js +++ b/build/configure-shim.js @@ -0,0 +1,4 @@ + +if (typeof module === 'function') { + module.apply(null, args || []) +} diff --git a/build/localizers.config.js b/build/localizers.config.js index bb2fb7b36..5a5506011 100644 --- a/build/localizers.config.js +++ b/build/localizers.config.js @@ -1,21 +1,38 @@ var path = require('path') , makeConfig = require('./make-config'); -module.exports = makeConfig({ + +var globalize = makeConfig({ noCompile: true, banner: true, minimize: false, production: true, - entry: { - 'react-widgets-globalize': './lib/localizers/globalize.js', - 'react-widgets-moment': './lib/localizers/moment.js', - 'react-widgets-simple-number': './lib/localizers/simple-number.js' + entry: 'imports-loader?module=../lib/localizers/globalize.js,args=>[Globalize]!./build/configure-shim.js', + + output: { + path: path.join(__dirname, '../dist'), + filename: 'react-widgets-globalize.js' }, + externals: { + '../configure': 'window.ReactWidgets', + react: 'window.React' + } +}) + + +var moment = makeConfig({ + noCompile: true, + banner: true, + minimize: false, + production: true, + + entry: 'imports-loader?module=../lib/localizers/moment.js,args=>[moment]!./build/configure-shim.js', + output: { path: path.join(__dirname, '../dist'), - filename: '[name].js' + filename: 'react-widgets-moment.js' }, externals: { @@ -23,3 +40,29 @@ module.exports = makeConfig({ react: 'window.React' } }) + + +var simpleNumber = makeConfig({ + noCompile: true, + banner: true, + minimize: false, + production: true, + + entry: 'imports-loader?module=../lib/localizers/simple-number.js,args=>[]!./build/configure-shim.js', + + output: { + path: path.join(__dirname, '../dist'), + filename: 'react-widgets-simple-number.js' + }, + + externals: { + '../configure': 'window.ReactWidgets', + react: 'window.React' + } +}) + +module.exports = [ + globalize, + moment, + simpleNumber +]; diff --git a/dist/react-widgets-globalize.js b/dist/react-widgets-globalize.js index 4aa9a709e..57ac49a08 100644 --- a/dist/react-widgets-globalize.js +++ b/dist/react-widgets-globalize.js @@ -1,4 +1,4 @@ -/*! (c) 2015 Jason Quense | https://github.com/jquense/react-widgets/blob/master/License.txt */ +/*! (c) 2016 Jason Quense | https://github.com/jquense/react-widgets/blob/master/License.txt */ /******/ (function(modules) { // webpackBootstrap /******/ // The module cache /******/ var installedModules = {}; @@ -43,18 +43,33 @@ /************************************************************************/ /******/ ([ /* 0 */ +/***/ function(module, exports, __webpack_require__) { + + /*** IMPORTS FROM imports-loader ***/ + var module = __webpack_require__(1); + var args = [Globalize]; + + + if (typeof module === 'function') { + module.apply(null, args || []) + } + + + +/***/ }, +/* 1 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; - var babelHelpers = __webpack_require__(1); + var babelHelpers = __webpack_require__(2); exports.__esModule = true; exports['default'] = globalizeLocalizers; - var _react = __webpack_require__(2); + var _react = __webpack_require__(3); - var _configure = __webpack_require__(3); + var _configure = __webpack_require__(4); var _configure2 = babelHelpers.interopRequireDefault(_configure); @@ -246,7 +261,7 @@ module.exports = exports['default']; /***/ }, -/* 1 */ +/* 2 */ /***/ function(module, exports, __webpack_require__) { var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;(function (root, factory) { @@ -346,13 +361,13 @@ }) /***/ }, -/* 2 */ +/* 3 */ /***/ function(module, exports) { module.exports = window.React; /***/ }, -/* 3 */ +/* 4 */ /***/ function(module, exports) { module.exports = window.ReactWidgets; diff --git a/dist/react-widgets-moment.js b/dist/react-widgets-moment.js index d226ede71..fb2bee242 100644 --- a/dist/react-widgets-moment.js +++ b/dist/react-widgets-moment.js @@ -1,4 +1,4 @@ -/*! (c) 2015 Jason Quense | https://github.com/jquense/react-widgets/blob/master/License.txt */ +/*! (c) 2016 Jason Quense | https://github.com/jquense/react-widgets/blob/master/License.txt */ /******/ (function(modules) { // webpackBootstrap /******/ // The module cache /******/ var installedModules = {}; @@ -43,11 +43,26 @@ /************************************************************************/ /******/ ([ /* 0 */ +/***/ function(module, exports, __webpack_require__) { + + /*** IMPORTS FROM imports-loader ***/ + var module = __webpack_require__(1); + var args = [moment]; + + + if (typeof module === 'function') { + module.apply(null, args || []) + } + + + +/***/ }, +/* 1 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; - var babelHelpers = __webpack_require__(1); + var babelHelpers = __webpack_require__(2); exports.__esModule = true; @@ -117,7 +132,7 @@ module.exports = exports['default']; /***/ }, -/* 1 */ +/* 2 */ /***/ function(module, exports, __webpack_require__) { var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;(function (root, factory) { @@ -217,7 +232,6 @@ }) /***/ }, -/* 2 */, /* 3 */ /***/ function(module, exports) { diff --git a/dist/react-widgets-simple-number.js b/dist/react-widgets-simple-number.js index 7e5184da6..4a8b5b636 100644 --- a/dist/react-widgets-simple-number.js +++ b/dist/react-widgets-simple-number.js @@ -1,4 +1,4 @@ -/*! (c) 2015 Jason Quense | https://github.com/jquense/react-widgets/blob/master/License.txt */ +/*! (c) 2016 Jason Quense | https://github.com/jquense/react-widgets/blob/master/License.txt */ /******/ (function(modules) { // webpackBootstrap /******/ // The module cache /******/ var installedModules = {}; @@ -43,11 +43,26 @@ /************************************************************************/ /******/ ([ /* 0 */ +/***/ function(module, exports, __webpack_require__) { + + /*** IMPORTS FROM imports-loader ***/ + var module = __webpack_require__(1); + var args = []; + + + if (typeof module === 'function') { + module.apply(null, args || []) + } + + + +/***/ }, +/* 1 */ /***/ function(module, exports, __webpack_require__) { 'use strict'; - var babelHelpers = __webpack_require__(1); + var babelHelpers = __webpack_require__(2); exports.__esModule = true; exports['default'] = simpleNumber; @@ -111,7 +126,7 @@ module.exports = exports['default']; /***/ }, -/* 1 */ +/* 2 */ /***/ function(module, exports, __webpack_require__) { var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;(function (root, factory) { @@ -211,7 +226,6 @@ }) /***/ }, -/* 2 */, /* 3 */ /***/ function(module, exports) { @@ -704,11 +718,19 @@ var decim = number[1].slice(0, places); //if next digit was >= 5 we need to round up if (+(number[1].substr(places, 1)) >= 5) { - decim = (+decim + 1) + '' + //But first count leading zeros as converting to a number will loose them + var leadingzeros = ""; + while (decim.charAt(0)==="0") { + leadingzeros = leadingzeros + "0"; + decim = decim.substr(1); + } + //Then we can change decim to a number and add 1 before replacing leading zeros + decim = (+decim + 1) + ''; + decim = leadingzeros + decim; if (decim.length > places) { //adding one has made it longer - decim = decim.substring(1); //ignore the 1 at the beginning which is the carry to the integer part - number[0] = (+number[0]+1) + '' //add 1 to the integer part + number[0] = (+number[0]+ +decim.charAt(0)) + ''; //add value of firstchar to the integer part + decim = decim.substring(1); //ignore the 1st char at the beginning which is the carry to the integer part } } number[1] = decim; diff --git a/src/localizers/moment.js b/src/localizers/moment.js index 7e8016816..7680a4e50 100644 --- a/src/localizers/moment.js +++ b/src/localizers/moment.js @@ -1,6 +1,6 @@ import configure from '../configure' -export default function(moment){ +export default function(moment) { if (typeof moment !== 'function') throw new TypeError('You must provide a valid moment object') diff --git a/test/browser-test.html b/test/browser-test.html index 8f0ac5fd4..3c8a136f9 100644 --- a/test/browser-test.html +++ b/test/browser-test.html @@ -8,10 +8,12 @@

loading...

- - + + + + - \ No newline at end of file +