Skip to content

Commit

Permalink
[fixed] localizer dist files
Browse files Browse the repository at this point in the history
  • Loading branch information
jquense committed Jan 12, 2016
1 parent 6819833 commit 4b6abc7
Show file tree
Hide file tree
Showing 8 changed files with 130 additions and 31 deletions.
3 changes: 1 addition & 2 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -40,4 +39,4 @@
"react/react-in-jsx-scope": 1,
"react/self-closing-comp": 1
}
}
}
4 changes: 4 additions & 0 deletions build/configure-shim.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

if (typeof module === 'function') {
module.apply(null, args || [])
}
55 changes: 49 additions & 6 deletions build/localizers.config.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,68 @@
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: {
'../configure': 'window.ReactWidgets',
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
];
29 changes: 22 additions & 7 deletions dist/react-widgets-globalize.js
Original file line number Diff line number Diff line change
@@ -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 = {};
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -346,13 +361,13 @@
})

/***/ },
/* 2 */
/* 3 */
/***/ function(module, exports) {

module.exports = window.React;

/***/ },
/* 3 */
/* 4 */
/***/ function(module, exports) {

module.exports = window.ReactWidgets;
Expand Down
22 changes: 18 additions & 4 deletions dist/react-widgets-moment.js
Original file line number Diff line number Diff line change
@@ -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 = {};
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -217,7 +232,6 @@
})

/***/ },
/* 2 */,
/* 3 */
/***/ function(module, exports) {

Expand Down
36 changes: 29 additions & 7 deletions dist/react-widgets-simple-number.js
Original file line number Diff line number Diff line change
@@ -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 = {};
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -211,7 +226,6 @@
})

/***/ },
/* 2 */,
/* 3 */
/***/ function(module, exports) {

Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/localizers/moment.js
Original file line number Diff line number Diff line change
@@ -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')

Expand Down
10 changes: 6 additions & 4 deletions test/browser-test.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@
<h4>loading...</h4>
</body>

<script src="http://cdnjs.cloudflare.com/ajax/libs/react/0.12.0/react.js" type="text/javascript"></script>
<script src="http:////cdnjs.cloudflare.com/ajax/libs/globalize/0.1.1/globalize.min.js" type="text/javascript"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/react/0.13.0/react.js" type="text/javascript"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/moment.js/2.11.1/moment.min.js" type="text/javascript"></script>

<script src="../dist/react-widgets.js" type="text/javascript"></script>
<script src="../dist/react-widgets-moment.js" type="text/javascript"></script>
<script src="../dist/react-widgets-simple-number.js" type="text/javascript"></script>
<script>
var App = React.createClass({

Expand All @@ -20,11 +22,11 @@ <h4>loading...</h4>
return React.createElement('div', null, [
React.createElement(ReactWidgets.Calendar),
React.createElement(ReactWidgets.DropdownList),
React.createElement(ReactWidgets.Combobox),
React.createElement(ReactWidgets.NumberPicker),
])
}
})

React.render(React.createElement(App), document.body)
</script>
</html>
</html>

0 comments on commit 4b6abc7

Please sign in to comment.