nice-elements 1.8.7 → 1.8.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nice-elements",
3
- "version": "1.8.7",
3
+ "version": "1.8.8",
4
4
  "description": "Nice elements used in olaii angular 1.x webapps.",
5
5
  "main": "dist/nice.js",
6
6
  "license": "MIT",
@@ -33,7 +33,8 @@ angular.module('niceElements')
33
33
  tabIndex: '@',
34
34
  isFocused: '@',
35
35
  isInline: '=',
36
- onChange: '&?'
36
+ onChange: '&?',
37
+ numbersOnly: '=', // Allow only numbers in the input
37
38
  },
38
39
 
39
40
  link: function (scope, element, attrs) {
@@ -129,6 +130,15 @@ angular.module('niceElements')
129
130
  $scope.id = Math.random().toString(36).substring(7);
130
131
 
131
132
  $scope.keypress = function (event) {
133
+ if ($scope.numbersOnly) {
134
+ if ((event.charCode >= 48 && event.charCode <= 58) || event.charCode == 0) { // Allow only numbers
135
+ return true;
136
+ } else { // Prevent everything else
137
+ event.preventDefault();
138
+ return false;
139
+ }
140
+ }
141
+
132
142
  if ($scope.type == "number" || $scope.type == "integer") {
133
143
  if (event.charCode == 46 || event.charCode == 44) { // Handle "." and "," key (only one allowed)
134
144
  if ($scope.type == "number") {
@@ -10,7 +10,7 @@ angular.module('niceElements')
10
10
  .service('NiceService', function () {
11
11
  var service = {
12
12
  name: "Nice elements",
13
- version: "1.8.7",
13
+ version: "1.8.8",
14
14
  getHeader: function () {
15
15
  return {};
16
16
  }