john_hancock 0.1.2 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e5c86cd0cd56dacbaa94c80c2f621242b064de68
4
- data.tar.gz: 8ed3c9db346b544dd7f6521e5ca07c4985ccd925
3
+ metadata.gz: a6b2efb8eec6688d0a899f3d59cf96dd427440e7
4
+ data.tar.gz: ce62088e18addcb0e011fcaed97d63f8671422c1
5
5
  SHA512:
6
- metadata.gz: c1d5f61fe79c6eff9f06b1c66a9a9c8053230eac95a1d32546358541c12e515792ae230fa0eacbac03163893623688b02721eed93ba012b15624d406b5433b4e
7
- data.tar.gz: e545eff5ac35058a39ea8fdeba264df105fd0a69e882b4782e4ec78f38a7e7106041a1ec56add779e9eeb6df830ce63af70b08faf6ceaaff6b56d279d13b02a6
6
+ metadata.gz: ac0d36706deb77b63d8920a1ecb192aeee9faba63354e2be7c20d972c82aa930249b6cb489c8fe06372b5b2971534b817f79f284a94aa54d6cc5bc033b58e196
7
+ data.tar.gz: 2e55078a49f2151a6e54b9c081173323c3fb59aea0f1972dd6741880ae1d130aade5f8b0b8303a5d6dddb86b0ae4c8abcf39a0c68145eafa0afa82d2e9a0fd22
@@ -1,26 +1,26 @@
1
1
  //= require signature_pad
2
- $( document ).ready(function() {
3
- if(document.getElementById("JohnHancock-canvas")){
4
- var canvas = document.getElementById("JohnHancock-canvas"),
5
- hidden_field = document.getElementById("JohnHancock-hidden"),
6
- parent_form = $(canvas).closest("form"),
7
- signaturePad;
8
2
 
9
- signaturePad = new SignaturePad(canvas);
3
+ document.addEventListener('DOMContentLoaded', function(){
4
+ const canvas = document.getElementById("JohnHancock-canvas");
5
+ const hidden_field = document.getElementById("JohnHancock-hidden");
10
6
 
11
- $(parent_form).submit(function(e) {
12
- $(hidden_field).val(signaturePad.toDataURL());
13
- });
7
+ if (canvas && hidden_field) {
8
+ const parent_form = canvas.closest("form");
9
+ const signaturePad = new SignaturePad(canvas);
10
+
11
+ parent_form.onsubmit = function() {
12
+ hidden_field.value = signaturePad.toDataURL()
13
+ }
14
14
 
15
15
  function resizeCanvas() {
16
- var ratio = Math.max(window.devicePixelRatio || 1, 1);
17
- canvas.width = canvas.offsetWidth * ratio;
18
- canvas.height = canvas.offsetHeight * ratio;
19
- canvas.getContext("2d").scale(ratio, ratio);
20
- signaturePad.clear(); // otherwise isEmpty() might return incorrect value
21
- }
16
+ var ratio = Math.max(window.devicePixelRatio || 1, 1);
17
+ canvas.width = canvas.offsetWidth * ratio;
18
+ canvas.height = canvas.offsetHeight * ratio;
19
+ canvas.getContext("2d").scale(ratio, ratio);
20
+ signaturePad.clear();
21
+ }
22
22
 
23
- window.addEventListener("resize", resizeCanvas);
23
+ window.addEventListener("resize", resizeCanvas, true);
24
24
  resizeCanvas();
25
25
  }
26
- })
26
+ }, false)
@@ -1,3 +1,9 @@
1
+ var passiveIfSupported = false;
2
+
3
+ try {
4
+ window.addEventListener("test", null, Object.defineProperty({}, "passive", { get: function() { passiveIfSupported = { passive: true }; } }));
5
+ } catch(err) {}
6
+
1
7
  function Point(x, y, time) {
2
8
  this.x = x;
3
9
  this.y = y;
@@ -242,8 +248,8 @@ SignaturePad.prototype._handleTouchEvents = function () {
242
248
  this._canvas.style.msTouchAction = 'none';
243
249
  this._canvas.style.touchAction = 'none';
244
250
 
245
- this._canvas.addEventListener('touchstart', this._handleTouchStart);
246
- this._canvas.addEventListener('touchmove', this._handleTouchMove);
251
+ this._canvas.addEventListener('touchstart', this._handleTouchStart, passiveIfSupported);
252
+ this._canvas.addEventListener('touchmove', this._handleTouchMove, passiveIfSupported);
247
253
  this._canvas.addEventListener('touchend', this._handleTouchEnd);
248
254
  };
249
255
 
@@ -1,7 +1,6 @@
1
1
  module JohnHancock
2
2
  module Rails
3
3
  class Engine < ::Rails::Engine
4
- require 'jquery-rails'
5
4
  initializer 'john_hancock.form_helpers' do |_app|
6
5
  ActiveSupport.on_load(:action_view) { require 'john_hancock/rails/form_helper' }
7
6
  end
@@ -1,3 +1,3 @@
1
1
  module JohnHancock
2
- VERSION = '0.1.2'.freeze
2
+ VERSION = '0.2.0'.freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: john_hancock
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brandon Lawrence
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2017-02-06 00:00:00.000000000 Z
12
+ date: 2018-10-13 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: sqlite3
@@ -39,20 +39,6 @@ dependencies:
39
39
  - - ">="
40
40
  - !ruby/object:Gem::Version
41
41
  version: '0'
42
- - !ruby/object:Gem::Dependency
43
- name: jquery-rails
44
- requirement: !ruby/object:Gem::Requirement
45
- requirements:
46
- - - ">="
47
- - !ruby/object:Gem::Version
48
- version: '0'
49
- type: :development
50
- prerelease: false
51
- version_requirements: !ruby/object:Gem::Requirement
52
- requirements:
53
- - - ">="
54
- - !ruby/object:Gem::Version
55
- version: '0'
56
42
  - !ruby/object:Gem::Dependency
57
43
  name: test-unit
58
44
  requirement: !ruby/object:Gem::Requirement
@@ -81,20 +67,6 @@ dependencies:
81
67
  - - ">="
82
68
  - !ruby/object:Gem::Version
83
69
  version: '0'
84
- - !ruby/object:Gem::Dependency
85
- name: poltergeist
86
- requirement: !ruby/object:Gem::Requirement
87
- requirements:
88
- - - ">="
89
- - !ruby/object:Gem::Version
90
- version: '0'
91
- type: :development
92
- prerelease: false
93
- version_requirements: !ruby/object:Gem::Requirement
94
- requirements:
95
- - - ">="
96
- - !ruby/object:Gem::Version
97
- version: '0'
98
70
  - !ruby/object:Gem::Dependency
99
71
  name: launchy
100
72
  requirement: !ruby/object:Gem::Requirement