├── .gitattributes
├── .gitignore
├── .travis.yml
├── LICENCE
├── README.md
├── bower.json
├── example
├── app.js
└── index.html
├── package-lock.json
├── package.json
├── src
└── numeric-directive.js
└── test
├── numeric-test.js
└── numeric.conf.js
/.gitattributes:
--------------------------------------------------------------------------------
1 | # Auto detect text files and perform LF normalization
2 | * text=auto
3 |
4 | # Custom for Visual Studio
5 | *.cs diff=csharp
6 |
7 | # Standard to msysgit
8 | *.doc diff=astextplain
9 | *.DOC diff=astextplain
10 | *.docx diff=astextplain
11 | *.DOCX diff=astextplain
12 | *.dot diff=astextplain
13 | *.DOT diff=astextplain
14 | *.pdf diff=astextplain
15 | *.PDF diff=astextplain
16 | *.rtf diff=astextplain
17 | *.RTF diff=astextplain
18 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | test/coverage/
2 | src/*.html
3 | /node_modules
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: node_js
2 |
3 | node_js:
4 | - "node"
5 |
6 | env:
7 | global:
8 | CC_TEST_REPORTER_ID=f6086c3920602d6e039ca0a214e2b9696059a68ef8272c68f57c33dd8466940d
9 |
10 | before_install:
11 | - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
12 | - chmod +x ./cc-test-reporter
13 | - export DISPLAY=:99.0 # Display number for xvfb (for headless browser testing)
14 | - sh -e /etc/init.d/xvfb start # Start xvfb (for headless browser testing)
15 | - ./cc-test-reporter before-build
16 |
17 | install:
18 | - npm install # Install npm dependencies
19 | - npm install -qg grunt-cli karma-cli istanbul codeclimate-test-reporter
20 |
21 | script:
22 | - npm test
23 |
24 | after_script:
25 | - ./cc-test-reporter format-coverage -t lcov test/coverage/lcov.info
26 | - ./cc-test-reporter upload-coverage
--------------------------------------------------------------------------------
/LICENCE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2013-2017 The angular-translate team and Pascal Precht
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in
13 | all copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 | THE SOFTWARE.
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # angular-numeric-directive
2 |
3 | [](https://nodei.co/npm/angular-numeric-directive/)
4 |
5 | [](http://travis-ci.org/epeschier/angular-numeric-directive)
6 | [](https://codeclimate.com/github/epeschier/angular-numeric-directive)
7 | [](https://codeclimate.com/github/epeschier/angular-numeric-directive)
8 | [](https://www.npmjs.com/package/angular-numeric-directive)
9 |
10 | This angular directive prevents the user from entering non-numeric values.
11 |
12 | - There are checks on min and max values. When the value falls below the minumum the value is set to the minumum value. When the value exceeds the maxiumum, the value is set to the maximum. If the limit-min or limit-max attributes are set to false, the min or max values remain untouched.
13 | - Formatting is done on the blur event; thousand separator and decimal are based on the current Angular locale.
14 | - The number of decimals can be set.
15 |
16 | ## Install:
17 | bower install angular-numeric-directive --save
18 |
19 | npm install angular-numeric-directive --save
20 |
21 | ## Usage:
22 |
23 | 1. Include the numeric-directive as a dependency for your app.
24 |
25 | ```js
26 | angular.module('myApp', ['purplefox.numeric'])
27 | ```
28 |
29 | 2. Use the directive in your view:
30 |
31 | ```html
32 |
33 | ```
34 |
35 | ## Attributes
36 |
37 | **`max`**: maximum input value. Default undefined (no max)
38 |
39 | **`min`**: minimum input value. Default 0.
40 |
41 | **`decimals`**: number of decimals. Default 2.
42 |
43 | **`formatting`**: apply thousand separator formatting. Default true.
44 |
45 | **`limit-max`**: limit input to max value (value is capped). Default true. If set to false, the angular validations can be done like normal.
46 |
47 | **`limit-min`**: limit input to min value (value is capped). Default true. If set to false, the angular validations can be done like normal.
--------------------------------------------------------------------------------
/bower.json:
--------------------------------------------------------------------------------
1 | {
2 | "author": "Erik Peschier",
3 | "name": "angular-numeric-directive",
4 | "description": "Angular numeric directive",
5 | "version": "1.2.1",
6 | "homepage": "http://github.com/epeschier/angular-numeric-directive",
7 | "repository": {
8 | "type": "git",
9 | "url": "git://github.com/epeschier/angular-numeric-directive"
10 | },
11 | "main": "./src/numeric-directive.js",
12 | "ignore": [
13 | "**/.*",
14 | "node_modules",
15 | "components"
16 | ],
17 | "devDependencies": {
18 | "angular": "~1.6.9",
19 | "angular-mocks": "~1.6.9"
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/example/app.js:
--------------------------------------------------------------------------------
1 | angular
2 | .module('NumericExample', ['purplefox.numeric'])
3 |
4 | .controller('NumericCtrl', function () {
5 | var vm = this;
6 |
7 | vm.value = 12.34;
8 | });
--------------------------------------------------------------------------------
/example/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
A numeric directive. Capable of minimizing and maximizing values, formatting to decimal precision and thousand separators and limiting number of characters.