Browse Source

update data-inputmask-numericinput handling

Robin Herbots 8 years ago
parent
commit
f9ed9225d1
5 changed files with 117 additions and 13 deletions
  1. 1 0
      CHANGELOG.md
  2. 3 1
      Gruntfile.js
  3. 12 10
      js/inputmask.js
  4. 2 2
      webpack.config.js
  5. 99 0
      webpackbuild.config.js

+ 1 - 0
CHANGELOG.md

@@ -14,6 +14,7 @@ All notable changes to this project will be documented in this file.
 - TODO rewrite datatime alias
 
 ### Fixes
+- Usage of numericInput in data-inputmask causes reversed value #1640
 - Numeric suffix makes radixPoint disappear on preset value #1638
 - Cannot delete after fill up all the mask Android Chrome browser Jsfiddle #1637
 

+ 3 - 1
Gruntfile.js

@@ -1,4 +1,5 @@
 const webpackConfig = require('./webpack.config');
+const buildWebpackConfig = require('./webpackbuild.config');
 const qunitWebpackConfig = require('./qunit/webpack.config');
 
 module.exports = function (grunt) {
@@ -153,7 +154,8 @@ module.exports = function (grunt) {
             }
         },
         webpack: {
-            build: webpackConfig,
+            main: webpackConfig,
+            build: buildWebpackConfig,
             qunit: qunitWebpackConfig
         }
     });

+ 12 - 10
js/inputmask.js

@@ -143,16 +143,6 @@
                 var that = this;
 
                 function importAttributeOptions(npt, opts, userOptions, dataAttribute) {
-                    //handle dir=rtl
-                    if (npt.dir === "rtl" || opts.rightAlign) {
-                        npt.style.textAlign = "right";
-                    }
-
-                    if (npt.dir === "rtl" || opts.numericInput) {
-                        npt.dir = "ltr";
-                        npt.removeAttribute("dir");
-                        opts.isRTL = true;
-                    }
                     if (opts.importDataAttributes === true) {
                         var attrOptions = npt.getAttribute(dataAttribute),
                             option, dataoptions, optionData, p;
@@ -203,6 +193,18 @@
                         }
                     }
                     $.extend(true, opts, userOptions);
+
+                    //handle dir=rtl
+                    if (npt.dir === "rtl" || opts.rightAlign) {
+                        npt.style.textAlign = "right";
+                    }
+
+                    if (npt.dir === "rtl" || opts.numericInput) {
+                        npt.dir = "ltr";
+                        npt.removeAttribute("dir");
+                        opts.isRTL = true;
+                    }
+
                     return opts;
                 }
 

+ 2 - 2
webpack.config.js

@@ -66,8 +66,8 @@ module.exports = {
     },
     resolve: {
         alias: {
-            "./js/dependencyLibs/inputmask.dependencyLib": "./js/dependencyLibs/inputmask.dependencyLib.jquery",
-            "./dependencyLibs/inputmask.dependencyLib": "./dependencyLibs/inputmask.dependencyLib.jquery"
+            // "./js/dependencyLibs/inputmask.dependencyLib": "./js/dependencyLibs/inputmask.dependencyLib.jquery",
+            // "./dependencyLibs/inputmask.dependencyLib": "./dependencyLibs/inputmask.dependencyLib.jquery"
             //"./js/dependencyLibs/inputmask.dependencyLib": "./js/dependencyLibs/inputmask.dependencyLib.jqlite",
             // "./dependencyLibs/inputmask.dependencyLib": "./dependencyLibs/inputmask.dependencyLib.jqlite"
         }

+ 99 - 0
webpackbuild.config.js

@@ -0,0 +1,99 @@
+'use strict';
+
+let webpack = require('webpack');
+let path = require('path');
+
+function _path(p) {
+    return path.join(__dirname, p);
+}
+
+const rules = {
+    sourceMap: {
+        enforce: 'pre',
+        test: /\.js$/,
+        loader: 'source-map-loader',
+    },
+    js: {
+        test: /\.js$/,
+        loader: 'babel-loader',
+        exclude: /(node_modules)/,
+        options: {
+            presets: [
+                'env'
+            ],
+            passPerPreset: true,
+        },
+    },
+    styles: {
+        test: /\.css$/,
+        use: [
+            'style-loader',
+            {
+                loader: 'css-loader',
+                options: {
+                    importLoaders: 1
+                }
+            },
+            {
+                loader: 'postcss-loader',
+                options: {
+                    plugins: function () {
+                        return [
+                            require('postcss-cssnext')
+                        ];
+                    }
+                }
+            }
+        ]
+    }
+}
+
+module.exports = {
+    entry: "./bundle.js",
+    output: {
+        path: __dirname,
+        filename: "build/bundle.js"
+    },
+    externals: {
+        "jquery": "jQuery"
+    },
+    module: {
+        rules: [
+            rules.sourceMap,
+            rules.js,
+            rules.styles
+        ]
+    },
+    resolve: {
+        alias: {
+            "./js/dependencyLibs/inputmask.dependencyLib": "./js/dependencyLibs/inputmask.dependencyLib.jquery",
+            "./dependencyLibs/inputmask.dependencyLib": "./dependencyLibs/inputmask.dependencyLib.jquery"
+            //"./js/dependencyLibs/inputmask.dependencyLib": "./js/dependencyLibs/inputmask.dependencyLib.jqlite",
+            // "./dependencyLibs/inputmask.dependencyLib": "./dependencyLibs/inputmask.dependencyLib.jqlite"
+        }
+    },
+    plugins: [
+        new webpack.SourceMapDevToolPlugin({
+            // file and reference
+            filename: '[file].map',
+            // sources naming
+            moduleFilenameTemplate: '[absolute-resource-path]',
+            fallbackModuleFilenameTemplate: '[absolute-resource-path]',
+        }),
+        new webpack.LoaderOptionsPlugin({
+            debug: true
+        })
+    ],
+    bail: true,
+    // devServer: {
+    // 	publicPath: '/',
+    // 	stats: {
+    // 		colors: true
+    // 	},
+    // 	host: '0.0.0.0',
+    // 	inline: true,
+    // 	port: '8080',
+    // 	quiet: false,
+    // 	noInfo: false,
+    // },
+};