You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

ui-number-input

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ui-number-input - npm Package Compare versions

Comparing version

to
0.0.13

14

app/components/ui-number-array-input.js

@@ -119,15 +119,3 @@ import Ember from 'ember';

});
}.observes('arrayElements.@each.value'),
// // ACTIONS
// actions: {
// elementDidChange: function() {
// console.log("element did change");
// this.set('value', this.get('arrayElements').map(function(item,index){
// return item.value;
// }));
// }
// }
}.observes('arrayElements.@each.value')
});

79

app/mixins/input-correction.js

@@ -5,2 +5,9 @@ import Ember from 'ember';

// Array Remove - By John Resig (MIT Licensed)
Array.prototype.remove = function(from, to) {
var rest = this.slice((to || from) + 1 || this.length);
this.length = from < 0 ? this.length + from : from;
return this.push.apply(this, rest);
};
export default Ember.Mixin.create({

@@ -32,7 +39,14 @@ processCorrections: function(eventType, evt, options) {

var adding = self.get('correctionRules') || [];
var defaultCorrectionRules = self.get('defaultCorrectionRules');
var _activeCorrections = self.get('_activeCorrections');
adding = typeOf(adding) === 'string' ? adding.split(',') : adding;
if(!isEmpty(this.get('defaultCorrectionRules'))) {
adding = adding.concat(this.get('defaultCorrectionRules'));
// since integerOnly is superset of numericOnly and clipboard functionality is tricky with both in place
// we will remove "numericOnly" if "intergerOnly" exists ... TODO: find a more graceful way of handling this
if(adding.contains('integerOnly')) {
defaultCorrectionRules.remove(defaultCorrectionRules.indexOf('numericOnly'));
self.set('defaultCorrectionRules',defaultCorrectionRules);
}
if(!isEmpty(defaultCorrectionRules)) {
adding = adding.concat(defaultCorrectionRules);
}
adding.forEach(function(correction) {

@@ -76,4 +90,60 @@ // correction is either an object which means it's really an external rule definition

var numericKeys = context.get('_KEYBOARD.numericKeys');
var decimalPlace = context.get('_KEYBOARD.decimalPlace');
var keyCombos = context.get('_KEYBOARD.keyCombos');
if(numericKeys.concat(validControlCodes).concat(decimalPlace).contains(keyCode) || keyCombos(event)) {
if(keyCombos(event) && keyCode === 86) {
// Ensure clipboard content is number
var contentBefore = context.get('value');
context.$().on('paste',function(e) {
e.preventDefault();
var text = (e.originalEvent || e).clipboardData.getData('text/plain') || prompt('Paste something..');
if (Number(text) !== NaN) {
context.set('value',Number(text));
} else {
console.log('re-instating context: %s', contentBefore);
context.set('value',contentBefore);
context.addMessageQueue('Attempt to paste non-numeric content was blocked.', {expiry: 2000, type: 'info'});
}
context.$().off('paste');
});
}
return true;
} else {
context.addMessageQueue('Only numeric characters are allowed.', {expiry: 2000, type: 'warning'});
return false;
}
}
},
{
id:'integerOnly',
event: 'keyDown',
emphasis: null,
rule: function(context,event) {
var keyCode = event.keyCode;
var validControlCodes = context.get('_KEYBOARD.controlKeys');
var numericKeys = context.get('_KEYBOARD.numericKeys');
var keyCombos = context.get('_KEYBOARD.keyCombos');
if(numericKeys.concat(validControlCodes).contains(keyCode) || keyCombos(event)) {
if(keyCombos(event) && keyCode === 86) {
// Ensure clipboard content is number
var contentBefore = context.get('value');
context.$().on('paste',function(e) {
e.preventDefault();
var text = (e.originalEvent || e).clipboardData.getData('text/plain') || prompt('Paste something..');
if (Number(text) !== NaN ) {
if (Number(text) % 1 === 0) {
context.set('value',Number(text));
} else {
// strip off the non integer component
context.set('value',Math.floor(Number(text)));
context.addMessageQueue('Value pasted was numeric but not an integer. Only integer component kept.', {expiry: 2000, type: 'info'});
}
} else {
context.set('value',contentBefore);
context.addMessageQueue('Attempt to paste non-numeric content was blocked.', {expiry: 2000, type: 'info'});
}
context.$().off('paste');
});
}
return true;

@@ -210,2 +280,3 @@ } else {

modifierKeys: [16,17,18], // 16: shift, 17: cntrl, 18: alt
decimalPlace: [190],
// allows checking of key combinations; by default just checks

@@ -217,5 +288,5 @@ // for ctrl-A/cmd-A but options array allows setting what is allowed

var config = [
{ id: 'ctrlKey', value: options.ctrlKey || [65] }, // ctrl-A
{ id: 'ctrlKey', value: options.ctrlKey || [65,86] }, // ctrl-A, ctrl-v
{ id: 'shiftKey', value: options.shiftKey || [] },
{ id: 'metaKey', value: options.metaKey || [65,82] }, // 65: cmd/win-A, cmd/win-R
{ id: 'metaKey', value: options.metaKey || [65,82,86] }, // 65: cmd/win-A, cmd/win-R, cmd-v
{ id: 'altKey', value: options.altKey || [] },

@@ -222,0 +293,0 @@ ];

{
"name": "ui-number-input",
"version": "0.0.12",
"version": "0.0.13",
"description": "HTML Number input with Bootstrap and mobile friendly features",

@@ -5,0 +5,0 @@ "directories": {

Sorry, the diff of this file is not supported yet