thecore_dataentry_commons 1.4.3 → 1.4.4

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8bb332df4b98b683ab72c56b59be16efbe494245e09e7a0c730d1b31789add1b
4
- data.tar.gz: b7453f45f60439c38863bd9a895c40056faecfe9d2fed5c9ad01fecb12b9405c
3
+ metadata.gz: 8c9f5bd42e30742cb9feb550b009a01f50d212ee93c2e84ed97174dbc5bf5166
4
+ data.tar.gz: 91f383330d944dc003c5c3971a7f1bf526e6245f98a4f924a724f1aaf9f94ddc
5
5
  SHA512:
6
- metadata.gz: d0fb92c51bbbce005f0dc2e0a19fd19f0150093e9ae3165ea3c00a7f1d615161c6fa2b1545ca5c3241da2a23e2781b4a1d919739912be9e5b8f7dcd3396a9b66
7
- data.tar.gz: 940a1fb9a6ae8f9f912ad00ca1783ef0da3b1ea328c60968b08845a00fc41150c53f3073758d9ed0d117bfc3083f9257cc32324339d2275be2ec13b948ca5c9e
6
+ metadata.gz: 0cdd4f0d034c8c07a46241ac40b0f220fe991f36c5236633858e31c6fae80fcaf85632b6e4c9afee3ebe7de46382f79a42d41bbc6db0799133b3279a1d1efbaf
7
+ data.tar.gz: 7fae1272b45730a34725b7c1ef9f6d4698c6be0f04b4eb5644613c1aef84fadc5045530446c80a86de2b7ec473f55a78226b003df5e3e037dded5c3e3f0724f2
@@ -1,14 +1,14 @@
1
1
  <script>
2
- function keypressAndReturn(event) {
3
- // Capture all the keypresses and if they are a return,
4
- // then "click" the send button
5
- var keycode = (event.keyCode ? event.keyCode : event.which);
6
- if (keycode == '13') {
7
- $("#send").click();
8
- return true;
9
- }
10
- return false;
11
- }
2
+ // function keypressAndReturn(event) {
3
+ // // Capture all the keypresses and if they are a return,
4
+ // // then "click" the send button
5
+ // var keycode = (event.keyCode ? event.keyCode : event.which);
6
+ // if (keycode == '13') {
7
+ // $("#send").click();
8
+ // return true;
9
+ // }
10
+ // return false;
11
+ // }
12
12
  var kpMode = "<%= Settings.datawedge_kp_mode %>";
13
13
  // var clickedBtn; var code; Gestisco il keypress sull'input
14
14
  // $("#barcode").on(kpMode, keypressAndReturn);
@@ -21,44 +21,61 @@
21
21
  }
22
22
  // var clickedBtn; var code; Gestisco il keypress sull'input
23
23
  function manageScannedKeystrokes(event) {
24
- var keycode = (event.keyCode ? event.keyCode : event.which);
25
- console.log(`Keycode: ${keycode} && Is ctrlKey pressed? ${event.ctrlKey}`);
24
+ const keycode = (event.keyCode ? event.keyCode : event.which);
25
+ const valid = !event.ctrlKey && !event.altKey &&
26
+ ((keycode > 47 && keycode < 58) || // number keys
27
+ keycode == 32 || // spacebar
28
+ (keycode > 64 && keycode < 91) || // letter keys
29
+ (keycode > 95 && keycode < 112) || // numpad keys
30
+ (keycode > 185 && keycode < 193) || // ;=,-./` (in order)
31
+ (keycode > 218 && keycode < 223)); // [\]' (in order)
32
+ let prevent = false;
26
33
  if (event.ctrlKey && keycode == '32') {
34
+ // Invia il form secondario
35
+ console.log("Send secondary form");
27
36
  $("#data-action").click();
37
+ prevent = true;
28
38
  //return true;
29
- } else if(!keypressAndReturn(event) && event.target.id != "barcode") {
30
- // $("#send").focus();
39
+ } else if (keycode == '13') {
40
+ // Invia il form principale
41
+ console.log("Send main form");
42
+ $("#send").click();
43
+ prevent = true;
44
+ } else if (valid) { // if (event.target.id != "barcode")
31
45
  // Scrivilo nell'input field (accumulando)
32
- // Only if target.id is different from "barcode"
33
- // Otherwise well get duplicate keystrokes
46
+ console.log("Write to the field");
34
47
  $("#barcode").val(function (index, val) {
35
48
  // Write
36
49
  return val + event.key;
37
50
  });
51
+ prevent = true;
52
+ }
53
+
54
+ if (prevent) {
55
+ event.stopPropagation();
56
+ event.preventDefault();
38
57
  }
39
- event.stopPropagation();
40
- event.preventDefault();
41
58
  }
42
59
 
43
- function enableKSCapture(){
44
- console.log("Enabling keypress capture");
45
- $(document).off(kpMode, manageScannedKeystrokes);
46
- $(document).on(kpMode, manageScannedKeystrokes);
47
- $("#barcode").off(kpMode, manageScannedKeystrokes);
48
- }
49
- function disableKSCapture(){
50
- console.log("Disabling keypress capture");
51
- $(document).off(kpMode, manageScannedKeystrokes);
52
- $("#barcode").off(kpMode, manageScannedKeystrokes);
53
- $("#barcode").on(kpMode, manageScannedKeystrokes);
54
- }
60
+ // function enableKSCapture(){
61
+ // console.log("Enabling keypress capture");
62
+ // $(document).off(kpMode, manageScannedKeystrokes);
63
+ // $(document).on(kpMode, manageScannedKeystrokes);
64
+ // $("#barcode").off(kpMode, manageScannedKeystrokes);
65
+ // }
66
+ // function disableKSCapture(){
67
+ // console.log("Disabling keypress capture");
68
+ // $(document).off(kpMode, manageScannedKeystrokes);
69
+ // $("#barcode").off(kpMode, manageScannedKeystrokes);
70
+ // $("#barcode").on(kpMode, manageScannedKeystrokes);
71
+ // }
55
72
 
56
- function startKSCapture() {
57
- enableKSCapture();
58
- // Se $("#barcode") si becca il focus, elimino il keypress
59
- $("#barcode").focusin(disableKSCapture);
60
- $("#barcode").focusout(enableKSCapture);
61
- }
73
+ // function startKSCapture() {
74
+ // enableKSCapture();
75
+ // // Se $("#barcode") si becca il focus, elimino il keypress
76
+ // // $("#barcode").focusin(disableKSCapture);
77
+ // // $("#barcode").focusout(enableKSCapture);
78
+ // }
62
79
 
63
80
  // $("#send").focus();
64
81
  // Init
@@ -70,6 +87,7 @@
70
87
  <%-if (start_disabled rescue false)%>
71
88
  disableKSCapture();
72
89
  <%-else%>
73
- startKSCapture();
90
+ $(window).on('keydown', manageScannedKeystrokes);
91
+ // startKSCapture();
74
92
  <%-end%>
75
93
  </script>
@@ -16,4 +16,4 @@ en:
16
16
  barcode:
17
17
  action:
18
18
  name:
19
- Send (space)
19
+ Send (CTRL + space)
@@ -16,4 +16,4 @@ it:
16
16
  barcode:
17
17
  action:
18
18
  name:
19
- Invia (spazio)
19
+ Invia (CTRL + spazio)
@@ -1,3 +1,3 @@
1
1
  module ThecoreDataentryCommons
2
- VERSION = '1.4.3'.freeze
2
+ VERSION = '1.4.4'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: thecore_dataentry_commons
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.3
4
+ version: 1.4.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gabriele Tassoni
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-04-16 00:00:00.000000000 Z
11
+ date: 2019-04-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: thecore_settings