diff --git a/dist/ng-currency.js b/dist/ng-currency.js new file mode 100644 index 0000000..d50592e --- /dev/null +++ b/dist/ng-currency.js @@ -0,0 +1,2 @@ +!function(e,n){"object"==typeof exports&&"object"==typeof module?module.exports=n(require("angular")):"function"==typeof define&&define.amd?define("ng-currency",["angular"],n):"object"==typeof exports?exports["ng-currency"]=n(require("angular")):e["ng-currency"]=n(e.angular)}(this,function(e){return function(e){function n(t){if(r[t])return r[t].exports;var u=r[t]={i:t,l:!1,exports:{}};return e[t].call(u.exports,u,u.exports,n),u.l=!0,u.exports}var r={};return n.m=e,n.c=r,n.i=function(e){return e},n.d=function(e,r,t){n.o(e,r)||Object.defineProperty(e,r,{configurable:!1,enumerable:!0,get:t})},n.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(r,"a",r),r},n.o=function(e,n){return Object.prototype.hasOwnProperty.call(e,n)},n.p="",n(n.s=3)}([function(e,n,r){"use strict";function t(e,n){if(!(e instanceof n))throw new TypeError("Cannot call a class as a function")}Object.defineProperty(n,"__esModule",{value:!0});var u=function(){function e(e,n){for(var r=0;r=0;t--)e=a.$parsers[t](e)}else e=a.$$rawModelValue;for(var u=a.$formatters.length-1;u>=0;u--)e=a.$formatters[u](e);a.$viewValue=e,a.$render()}}function f(){if(a.$validate(),M){var e=l(a.$$rawModelValue);e!==a.$$rawModelValue&&(a.$setViewValue(e.toFixed(x)),a.$commitViewValue(),c())}}function l(e){return g&&(void 0!==y&&e>y?e=y:void 0!==b&&e1&&void 0!==arguments[1])||arguments[1];r=String(r);var u=n.NUMBER_FORMATS.DECIMAL_SEP,o=null;-1===r.indexOf(n.NUMBER_FORMATS.DECIMAL_SEP)&&-1!==r.indexOf(".")&&x>0&&(u=".");var i=e("currency")("-1",p(),x),a=RegExp("[0-9."+n.NUMBER_FORMATS.DECIMAL_SEP+n.NUMBER_FORMATS.GROUP_SEP+"]+");return i.replace(a.exec(i),"")===r.replace(a.exec(r),"")&&(r="-"+a.exec(r)),RegExp("^-[\\s]*$","g").test(r)&&(r="-0"),d(u).test(r)&&(o=r.match(d(u)).join("").match(s(u))||[""],o=o[0],o=t?o.replace(u,"."):o),o||null}function p(){return void 0===m?n.NUMBER_FORMATS.CURRENCY_SYM:m}var $=t.defaults,g=$.hardCap,b=$.min,y=$.max,m=$.currencySymbol,x=$.fraction,O=i.required,M=!0;i.$observe("ngCurrency",function(e){M="false"!==e,M?c():(a.$viewValue=a.$$rawModelValue,a.$render())}),i.$observe("hardCap",function(e){g="true"===e,f()}),i.$observe("min",function(e){b=e?Number(e):void 0,f()}),i.$observe("max",function(e){y=e?Number(e):void 0,f()}),i.$observe("currencySymbol",function(e){m=e,c()}),i.$observe("required",function(e){O=e,f()}),i.$observe("fraction",function(e){x=e||2,c(),f()}),r(function(){u.$emit("currencyRedraw")}),a.$parsers.push(function(e){return M&&-1===[void 0,null,""].indexOf(e)?(e=v(e),e=l(Number(e))):e}),a.$formatters.push(function(n){return M&&-1===[void 0,null,""].indexOf(n)?e("currency")(n,p(),x):n}),a.$validators.min=function(e){return!(O||-1===[void 0,null,""].indexOf(e)&&!isNaN(e))||(!M||-1!==[void 0,null].indexOf(b)||isNaN(b)||e>=b)},a.$validators.max=function(e){return!(O||-1===[void 0,null,""].indexOf(e)&&!isNaN(e))||(!M||-1!==[void 0,null].indexOf(y)||isNaN(y)||e<=y)},a.$validators.fraction=function(e){return!M||!e||!isNaN(e)},u.$on("currencyRedraw",function(){f(),c()}),o.bind("focus",function(){if(M){var e=v(a.$viewValue,!1);a.$viewValue!==e&&(a.$viewValue=e,a.$render(),o.triggerHandler("focus"))}}),o.bind("blur",c)}}}Object.defineProperty(n,"__esModule",{value:!0}),n.default=t,t.$inject=["$filter","$locale","$timeout","ngCurrencySettings"]},function(n,r){n.exports=e},function(e,n,r){"use strict";function t(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(n,"__esModule",{value:!0});var u=r(2),o=t(u),i=r(0),a=t(i),c=r(1),f=t(c),l=o.default.module("ng-currency",[]);l.provider("ngCurrencySettings",a.default),l.directive("ngCurrency",f.default),n.default=l.name}])}); +//# sourceMappingURL=ng-currency.js.map \ No newline at end of file diff --git a/dist/ng-currency.js.map b/dist/ng-currency.js.map new file mode 100644 index 0000000..2922e98 --- /dev/null +++ b/dist/ng-currency.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["webpack:///webpack/universalModuleDefinition","webpack:///ng-currency.js","webpack:///webpack/bootstrap c718f19f3bcaf2f01996","webpack:///./ng-currency-settings.provider.js","webpack:///./ng-currency.directive.js","webpack:///external \"angular\"","webpack:///./ng-currency.module.js"],"names":["root","factory","exports","module","require","define","amd","this","__WEBPACK_EXTERNAL_MODULE_2__","modules","__webpack_require__","moduleId","installedModules","i","l","call","m","c","value","d","name","getter","o","Object","defineProperty","configurable","enumerable","get","n","__esModule","object","property","prototype","hasOwnProperty","p","s","_classCallCheck","instance","Constructor","TypeError","_createClass","defineProperties","target","props","length","descriptor","writable","key","protoProps","staticProps","ngCurrencySettings","_defaults","fraction","hardCap","min","undefined","max","currencySymbol","provider","defaults","set","default","ngCurrency","$filter","$locale","$timeout","link","scope","element","attrs","controller","reformat","active","updateOn","debounce","$options","getOption","$viewValue","$parsers","$$rawModelValue","$formatters","$render","revalidate","$validate","keepInRange","$setViewValue","toFixed","$commitViewValue","decimalRex","dChar","RegExp","clearRex","clearValue","replaceSeparator","arguments","String","dSeparator","NUMBER_FORMATS","DECIMAL_SEP","cleared","indexOf","neg_dummy","getCurrencySymbol","neg_regexp","GROUP_SEP","replace","exec","test","match","join","CURRENCY_SYM","_ngCurrencySettings$d","ngRequired","required","$observe","Number","$emit","push","$validators","isNaN","$on","bind","triggerHandler","$inject","_interopRequireDefault","obj","_angular","_angular2","_ngCurrencySettingsProvider","_ngCurrencySettingsProvider2","_ngCurrencyDirective","_ngCurrencyDirective2","directive"],"mappings":"CAAA,SAAAA,EAAAC,GACA,gBAAAC,UAAA,gBAAAC,QACAA,OAAAD,QAAAD,EAAAG,QAAA,YACA,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AA+BL,EAAuBI,GKpY1DE,EAAAxH,EAAA,GLwYIyH,EAAwBP,EAAuBM,GKtY7C/H,EAAS4H,EAAAlE,QAAQ1D,OAAO,iBAE9BA,GAAOuD,SAAS,qBAAhBuE,EAAApE,SACA1D,EAAOiI,UAAU,aAAjBD,EAAAtE,SL4YA3D,EAAQ2D,QK1YO1D,EAAOiB","file":"ng-currency.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory(require(\"angular\"));\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine(\"ng-currency\", [\"angular\"], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"ng-currency\"] = factory(require(\"angular\"));\n\telse\n\t\troot[\"ng-currency\"] = factory(root[\"angular\"]);\n})(this, function(__WEBPACK_EXTERNAL_MODULE_2__) {\nreturn \n\n\n// WEBPACK FOOTER //\n// webpack/universalModuleDefinition","(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory(require(\"angular\"));\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine(\"ng-currency\", [\"angular\"], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"ng-currency\"] = factory(require(\"angular\"));\n\telse\n\t\troot[\"ng-currency\"] = factory(root[\"angular\"]);\n})(this, function(__WEBPACK_EXTERNAL_MODULE_2__) {\nreturn /******/ (function(modules) { // webpackBootstrap\n/******/ \t// The module cache\n/******/ \tvar installedModules = {};\n/******/\n/******/ \t// The require function\n/******/ \tfunction __webpack_require__(moduleId) {\n/******/\n/******/ \t\t// Check if module is in cache\n/******/ \t\tif(installedModules[moduleId]) {\n/******/ \t\t\treturn installedModules[moduleId].exports;\n/******/ \t\t}\n/******/ \t\t// Create a new module (and put it into the cache)\n/******/ \t\tvar module = installedModules[moduleId] = {\n/******/ \t\t\ti: moduleId,\n/******/ \t\t\tl: false,\n/******/ \t\t\texports: {}\n/******/ \t\t};\n/******/\n/******/ \t\t// Execute the module function\n/******/ \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n/******/\n/******/ \t\t// Flag the module as loaded\n/******/ \t\tmodule.l = true;\n/******/\n/******/ \t\t// Return the exports of the module\n/******/ \t\treturn module.exports;\n/******/ \t}\n/******/\n/******/\n/******/ \t// expose the modules object (__webpack_modules__)\n/******/ \t__webpack_require__.m = modules;\n/******/\n/******/ \t// expose the module cache\n/******/ \t__webpack_require__.c = installedModules;\n/******/\n/******/ \t// identity function for calling harmony imports with the correct context\n/******/ \t__webpack_require__.i = function(value) { return value; };\n/******/\n/******/ \t// define getter function for harmony exports\n/******/ \t__webpack_require__.d = function(exports, name, getter) {\n/******/ \t\tif(!__webpack_require__.o(exports, name)) {\n/******/ \t\t\tObject.defineProperty(exports, name, {\n/******/ \t\t\t\tconfigurable: false,\n/******/ \t\t\t\tenumerable: true,\n/******/ \t\t\t\tget: getter\n/******/ \t\t\t});\n/******/ \t\t}\n/******/ \t};\n/******/\n/******/ \t// getDefaultExport function for compatibility with non-harmony modules\n/******/ \t__webpack_require__.n = function(module) {\n/******/ \t\tvar getter = module && module.__esModule ?\n/******/ \t\t\tfunction getDefault() { return module['default']; } :\n/******/ \t\t\tfunction getModuleExports() { return module; };\n/******/ \t\t__webpack_require__.d(getter, 'a', getter);\n/******/ \t\treturn getter;\n/******/ \t};\n/******/\n/******/ \t// Object.prototype.hasOwnProperty.call\n/******/ \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n/******/\n/******/ \t// __webpack_public_path__\n/******/ \t__webpack_require__.p = \"\";\n/******/\n/******/ \t// Load entry module and return exports\n/******/ \treturn __webpack_require__(__webpack_require__.s = 3);\n/******/ })\n/************************************************************************/\n/******/ ([\n/* 0 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\n\nvar _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; }; }();\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nvar ngCurrencySettings = function () {\n function ngCurrencySettings() {\n _classCallCheck(this, ngCurrencySettings);\n\n this._defaults = {\n fraction: 2,\n hardCap: false,\n min: undefined,\n max: undefined,\n currencySymbol: undefined\n };\n }\n\n /**\n * The default property values for 'ng-currency'\n */\n\n\n _createClass(ngCurrencySettings, [{\n key: \"$get\",\n value: function $get() {\n var provider = this;\n return {\n /**\n * The default property values for 'ng-currency'\n */\n get defaults() {\n return provider.defaults;\n }\n };\n }\n }, {\n key: \"defaults\",\n get: function get() {\n return this._defaults;\n },\n set: function set(defaults) {\n this._defaults = defaults;\n }\n }]);\n\n return ngCurrencySettings;\n}();\n\nexports.default = ngCurrencySettings;\n\n/***/ }),\n/* 1 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.default = ngCurrency;\nfunction ngCurrency($filter, $locale, $timeout, ngCurrencySettings) {\n return {\n require: 'ngModel',\n link: function link(scope, element, attrs, controller) {\n var _ngCurrencySettings$d = ngCurrencySettings.defaults,\n hardCap = _ngCurrencySettings$d.hardCap,\n min = _ngCurrencySettings$d.min,\n max = _ngCurrencySettings$d.max,\n currencySymbol = _ngCurrencySettings$d.currencySymbol,\n fraction = _ngCurrencySettings$d.fraction;\n\n var ngRequired = attrs.required;\n var active = true;\n\n attrs.$observe('ngCurrency', function (value) {\n active = value !== 'false';\n if (active) {\n reformat();\n } else {\n controller.$viewValue = controller.$$rawModelValue;\n controller.$render();\n }\n });\n attrs.$observe('hardCap', function (value) {\n hardCap = value === 'true';\n revalidate();\n });\n attrs.$observe('min', function (value) {\n min = value ? Number(value) : undefined;\n revalidate();\n });\n attrs.$observe('max', function (value) {\n max = value ? Number(value) : undefined;\n revalidate();\n });\n attrs.$observe('currencySymbol', function (value) {\n currencySymbol = value;\n reformat();\n });\n attrs.$observe('required', function (value) {\n ngRequired = value;\n revalidate();\n });\n attrs.$observe('fraction', function (value) {\n fraction = value || 2;\n reformat();\n revalidate();\n });\n\n // HACK(cecilia-sanare): Seriously angular?\n $timeout(function () {\n scope.$emit('currencyRedraw');\n });\n\n controller.$parsers.push(function (value) {\n if (active && [undefined, null, ''].indexOf(value) === -1) {\n value = clearValue(value);\n value = keepInRange(Number(value));\n return value;\n }\n return value;\n });\n\n controller.$formatters.push(function (value) {\n if (active && [undefined, null, ''].indexOf(value) === -1) {\n return $filter('currency')(value, getCurrencySymbol(), fraction);\n }\n return value;\n });\n\n controller.$validators.min = function (value) {\n if (!ngRequired && ([undefined, null, ''].indexOf(value) !== -1 || isNaN(value))) {\n return true;\n }\n return !active || [undefined, null].indexOf(min) !== -1 || isNaN(min) || value >= min;\n };\n\n controller.$validators.max = function (value) {\n if (!ngRequired && ([undefined, null, ''].indexOf(value) !== -1 || isNaN(value))) {\n return true;\n }\n return !active || [undefined, null].indexOf(max) !== -1 || isNaN(max) || value <= max;\n };\n\n controller.$validators.fraction = function (value) {\n return !active || !value || !isNaN(value);\n };\n\n function reformat() {\n if (active) {\n var value = void 0;\n var updateOn = void 0,\n debounce = void 0;\n if (controller.$options) {\n // HACK(cecilia-sanare): this is to maintain backwards compatability with Angular 1.5.9 and lower.\n // TODO(cecilia-sanare): This should be removed when ngCurrency does a 2.0.0 release\n // Reference: https://github.com/angular/angular.js/commit/296cfce40c25e9438bfa46a0eb27240707a10ffa\n if (controller.$options.getOption) {\n updateOn = controller.$options.getOption('updateOn');\n debounce = controller.$options.getOption('debounce');\n } else {\n updateOn = controller.$options.updateOn;\n debounce = controller.$options.debounce;\n }\n }\n if (updateOn === 'blur' || debounce) {\n value = controller.$viewValue;\n for (var i = controller.$parsers.length - 1; i >= 0; i--) {\n value = controller.$parsers[i](value);\n }\n } else {\n value = controller.$$rawModelValue;\n }\n for (var _i = controller.$formatters.length - 1; _i >= 0; _i--) {\n value = controller.$formatters[_i](value);\n }\n controller.$viewValue = value;\n controller.$render();\n }\n }\n\n function revalidate() {\n controller.$validate();\n if (active) {\n var value = keepInRange(controller.$$rawModelValue);\n if (value !== controller.$$rawModelValue) {\n controller.$setViewValue(value.toFixed(fraction));\n controller.$commitViewValue();\n reformat();\n }\n }\n }\n\n function keepInRange(value) {\n if (hardCap) {\n if (max !== undefined && value > max) {\n value = max;\n } else if (min !== undefined && value < min) {\n value = min;\n }\n }\n return value;\n }\n\n scope.$on('currencyRedraw', function () {\n revalidate();\n reformat();\n });\n\n element.bind('focus', function () {\n if (active) {\n var value = clearValue(controller.$viewValue, false);\n\n if (controller.$viewValue !== value) {\n controller.$viewValue = value;\n controller.$render();\n element.triggerHandler('focus');\n }\n }\n });\n\n element.bind('blur', reformat);\n\n // TODO: Rewrite this parsing logic to more readable.\n\n function decimalRex(dChar) {\n return RegExp('\\\\d|\\\\-|\\\\' + dChar, 'g');\n }\n\n function clearRex(dChar) {\n return RegExp('\\\\-{0,1}((\\\\' + dChar + ')|([0-9]{1,}\\\\' + dChar + '?))&?[0-9]{0,' + fraction + '}', 'g');\n }\n\n function clearValue(value) {\n var replaceSeparator = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;\n\n value = String(value);\n var dSeparator = $locale.NUMBER_FORMATS.DECIMAL_SEP;\n var cleared = null;\n\n if (value.indexOf($locale.NUMBER_FORMATS.DECIMAL_SEP) === -1 && value.indexOf('.') !== -1 && fraction > 0) {\n dSeparator = '.';\n }\n\n // Replace negative pattern to minus sign (-)\n var neg_dummy = $filter('currency')('-1', getCurrencySymbol(), fraction);\n var neg_regexp = RegExp('[0-9.' + $locale.NUMBER_FORMATS.DECIMAL_SEP + $locale.NUMBER_FORMATS.GROUP_SEP + ']+');\n var neg_dummy_txt = neg_dummy.replace(neg_regexp.exec(neg_dummy), '');\n var value_dummy_txt = value.replace(neg_regexp.exec(value), '');\n\n // If is negative\n if (neg_dummy_txt === value_dummy_txt) {\n value = '-' + neg_regexp.exec(value);\n }\n\n if (RegExp('^-[\\\\s]*$', 'g').test(value)) {\n value = '-0';\n }\n\n if (decimalRex(dSeparator).test(value)) {\n cleared = value.match(decimalRex(dSeparator)).join('').match(clearRex(dSeparator)) || [''];\n\n cleared = cleared[0];\n cleared = replaceSeparator ? cleared.replace(dSeparator, '.') : cleared;\n }\n\n return cleared || null;\n }\n\n function getCurrencySymbol() {\n return currencySymbol === undefined ? $locale.NUMBER_FORMATS.CURRENCY_SYM : currencySymbol;\n }\n }\n };\n}\nngCurrency.$inject = ['$filter', '$locale', '$timeout', 'ngCurrencySettings'];\n\n/***/ }),\n/* 2 */\n/***/ (function(module, exports) {\n\nmodule.exports = __WEBPACK_EXTERNAL_MODULE_2__;\n\n/***/ }),\n/* 3 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\n\nvar _angular = __webpack_require__(2);\n\nvar _angular2 = _interopRequireDefault(_angular);\n\nvar _ngCurrencySettingsProvider = __webpack_require__(0);\n\nvar _ngCurrencySettingsProvider2 = _interopRequireDefault(_ngCurrencySettingsProvider);\n\nvar _ngCurrencyDirective = __webpack_require__(1);\n\nvar _ngCurrencyDirective2 = _interopRequireDefault(_ngCurrencyDirective);\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\nvar _module = _angular2.default.module('ng-currency', []);\n\n_module.provider('ngCurrencySettings', _ngCurrencySettingsProvider2.default);\n_module.directive('ngCurrency', _ngCurrencyDirective2.default);\n\nexports.default = _module.name;\n\n/***/ })\n/******/ ]);\n});\n\n\n// WEBPACK FOOTER //\n// ng-currency.js"," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// identity function for calling harmony imports with the correct context\n \t__webpack_require__.i = function(value) { return value; };\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, {\n \t\t\t\tconfigurable: false,\n \t\t\t\tenumerable: true,\n \t\t\t\tget: getter\n \t\t\t});\n \t\t}\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 3);\n\n\n\n// WEBPACK FOOTER //\n// webpack/bootstrap c718f19f3bcaf2f01996","export default class ngCurrencySettings {\n constructor() {\n this._defaults = {\n fraction: 2,\n hardCap: false,\n min: undefined,\n max: undefined,\n currencySymbol: undefined\n };\n }\n\n /**\n * The default property values for 'ng-currency'\n */\n get defaults() {\n return this._defaults;\n }\n\n set defaults(defaults) {\n this._defaults = defaults;\n }\n\n $get() {\n const provider = this;\n return {\n /**\n * The default property values for 'ng-currency'\n */\n get defaults() {\n return provider.defaults;\n }\n };\n }\n}\n\n\n\n// WEBPACK FOOTER //\n// ./ng-currency-settings.provider.js","export default function ngCurrency($filter, $locale, $timeout, ngCurrencySettings) {\n return {\n require: 'ngModel',\n link: (scope, element, attrs, controller) => {\n let { hardCap, min, max, currencySymbol, fraction } = ngCurrencySettings.defaults;\n let ngRequired = attrs.required;\n let active = true;\n\n attrs.$observe('ngCurrency', (value) => {\n active = (value !== 'false');\n if (active) {\n reformat();\n } else {\n controller.$viewValue = controller.$$rawModelValue;\n controller.$render();\n }\n });\n attrs.$observe('hardCap', (value) => {\n hardCap = (value === 'true');\n revalidate();\n });\n attrs.$observe('min', (value) => {\n min = value ? Number(value) : undefined;\n revalidate();\n });\n attrs.$observe('max', (value) => {\n max = value ? Number(value) : undefined;\n revalidate();\n });\n attrs.$observe('currencySymbol', (value) => {\n currencySymbol = value;\n reformat();\n });\n attrs.$observe('required', (value) => {\n ngRequired = value;\n revalidate();\n });\n attrs.$observe('fraction', (value) => {\n fraction = value || 2;\n reformat();\n revalidate();\n });\n\n // HACK(cecilia-sanare): Seriously angular?\n $timeout(() => {\n scope.$emit('currencyRedraw');\n });\n\n controller.$parsers.push((value) => {\n if (active && [undefined, null, ''].indexOf(value) === -1) {\n value = clearValue(value);\n value = keepInRange(Number(value));\n return value;\n }\n return value;\n });\n\n controller.$formatters.push((value) => {\n if (active && [undefined, null, ''].indexOf(value) === -1) {\n return $filter('currency')(value, getCurrencySymbol(), fraction);\n }\n return value;\n });\n\n controller.$validators.min = (value) => {\n if (!ngRequired && ([undefined, null, ''].indexOf(value) !== -1 || isNaN(value))) {\n return true;\n }\n return !active ||\n [undefined, null].indexOf(min) !== -1 || isNaN(min) ||\n value >= min;\n };\n\n controller.$validators.max = (value) => {\n if (!ngRequired && ([undefined, null, ''].indexOf(value) !== -1 || isNaN(value))) {\n return true;\n }\n return !active ||\n [undefined, null].indexOf(max) !== -1 || isNaN(max) ||\n value <= max;\n };\n\n controller.$validators.fraction = (value) => {\n return !active || !value || !isNaN(value);\n };\n\n function reformat() {\n if (active) {\n let value;\n let updateOn, debounce;\n if (controller.$options) {\n // HACK(cecilia-sanare): this is to maintain backwards compatability with Angular 1.5.9 and lower.\n // TODO(cecilia-sanare): This should be removed when ngCurrency does a 2.0.0 release\n // Reference: https://github.com/angular/angular.js/commit/296cfce40c25e9438bfa46a0eb27240707a10ffa\n if (controller.$options.getOption) {\n updateOn = controller.$options.getOption('updateOn');\n debounce = controller.$options.getOption('debounce');\n } else {\n updateOn = controller.$options.updateOn;\n debounce = controller.$options.debounce;\n }\n }\n if (updateOn === 'blur' || debounce) {\n value = controller.$viewValue;\n for (let i = controller.$parsers.length - 1; i >= 0; i--) {\n value = controller.$parsers[i](value);\n }\n } else {\n value = controller.$$rawModelValue;\n }\n for (let i = controller.$formatters.length - 1; i >= 0; i--) {\n value = controller.$formatters[i](value);\n }\n controller.$viewValue = value;\n controller.$render();\n }\n }\n\n function revalidate() {\n controller.$validate();\n if (active) {\n const value = keepInRange(controller.$$rawModelValue);\n if (value !== controller.$$rawModelValue) {\n controller.$setViewValue(value.toFixed(fraction));\n controller.$commitViewValue();\n reformat();\n }\n }\n }\n\n function keepInRange(value) {\n if (hardCap) {\n if (max !== undefined && value > max) {\n value = max;\n } else if (min !== undefined && value < min) {\n value = min;\n }\n }\n return value;\n }\n\n scope.$on('currencyRedraw', () => {\n revalidate();\n reformat();\n });\n\n element.bind('focus', () => {\n if (active) {\n const value = clearValue(controller.$viewValue, false);\n\n if (controller.$viewValue !== value) {\n controller.$viewValue = value;\n controller.$render();\n element.triggerHandler('focus');\n }\n }\n });\n\n element.bind('blur', reformat);\n\n // TODO: Rewrite this parsing logic to more readable.\n\n function decimalRex(dChar) {\n return RegExp('\\\\d|\\\\-|\\\\' + dChar, 'g');\n }\n\n function clearRex(dChar) {\n return RegExp('\\\\-{0,1}((\\\\' + dChar + ')|([0-9]{1,}\\\\' + dChar + '?))&?[0-9]{0,' + fraction + '}', 'g');\n }\n\n function clearValue(value, replaceSeparator = true) {\n value = String(value);\n let dSeparator = $locale.NUMBER_FORMATS.DECIMAL_SEP;\n let cleared = null;\n\n if (value.indexOf($locale.NUMBER_FORMATS.DECIMAL_SEP) === -1 &&\n value.indexOf('.') !== -1 &&\n fraction > 0) {\n dSeparator = '.';\n }\n\n // Replace negative pattern to minus sign (-)\n const neg_dummy = $filter('currency')('-1', getCurrencySymbol(), fraction);\n const neg_regexp = RegExp('[0-9.' + $locale.NUMBER_FORMATS.DECIMAL_SEP + $locale.NUMBER_FORMATS.GROUP_SEP + ']+');\n const neg_dummy_txt = neg_dummy.replace(neg_regexp.exec(neg_dummy), '');\n const value_dummy_txt = value.replace(neg_regexp.exec(value), '');\n\n // If is negative\n if (neg_dummy_txt === value_dummy_txt) {\n value = '-' + neg_regexp.exec(value);\n }\n\n if (RegExp('^-[\\\\s]*$', 'g').test(value)) {\n value = '-0';\n }\n\n if (decimalRex(dSeparator).test(value)) {\n cleared = value.match(decimalRex(dSeparator))\n .join('').match(clearRex(dSeparator)) || [''];\n\n cleared = cleared[0];\n cleared = replaceSeparator ? cleared.replace(dSeparator, '.') : cleared;\n }\n\n return cleared || null;\n }\n\n function getCurrencySymbol() {\n return currencySymbol === undefined ? $locale.NUMBER_FORMATS.CURRENCY_SYM : currencySymbol;\n }\n }\n };\n}\nngCurrency.$inject = ['$filter', '$locale', '$timeout', 'ngCurrencySettings'];\n\n\n\n// WEBPACK FOOTER //\n// ./ng-currency.directive.js","module.exports = __WEBPACK_EXTERNAL_MODULE_2__;\n\n\n//////////////////\n// WEBPACK FOOTER\n// external \"angular\"\n// module id = 2\n// module chunks = 0","import angular from 'angular';\nimport ngCurrencySettings from './ng-currency-settings.provider.js';\nimport ngCurrency from './ng-currency.directive.js';\n\nconst module = angular.module('ng-currency', []);\n\nmodule.provider('ngCurrencySettings', ngCurrencySettings);\nmodule.directive('ngCurrency', ngCurrency);\n\nexport default module.name;\n\n\n\n// WEBPACK FOOTER //\n// ./ng-currency.module.js"],"sourceRoot":""} \ No newline at end of file diff --git a/package.json b/package.json index af58616..c85acdd 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ng-currency", - "version": "0.0.0-semantically-released.0", + "version": "1.2.2", "main": "dist/ng-currency.js", "description": "Directive that works in conjunction with currency filter.", "homepage": "http://alaguirre.com", @@ -63,4 +63,4 @@ "path": "./node_modules/cz-conventional-changelog" } } -} +} \ No newline at end of file