quince 0.2.0 → 0.2.1

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
  SHA256:
3
- metadata.gz: dcc2582bba48ffba3d17a6bd6efe972db91c70d3680348334342e01ad8506158
4
- data.tar.gz: af1dccbf8ea37419b4eb4936ea8f4fa20e60509d5c78a460d21df08ded15698d
3
+ metadata.gz: 1b5c0ef933d95f7026239bcfc5685e4aeb1582382056725b245cd37838540bf4
4
+ data.tar.gz: c790f0bc40602888167f46bf9636c55a739d5191645fd43e3614c78e381c6d1f
5
5
  SHA512:
6
- metadata.gz: 7d16ca52523b06dddb32cd22aac945690836c0b094051248394f823d56d35933a0bc163b2250e57fb6ccbcbdbe956db12865da486e16b5024148d83566059d46
7
- data.tar.gz: 8550f7c684a827e2c3b714e6e00c6e2b37bfdb2f54f1daf7dfe6f3dde46e4a17859fe0f5a887d3bcd54877db400728acb08037156a0032561f327a42a9e3910f
6
+ metadata.gz: d7f561f03a959ed9fb221d0462f8901fe9f0cb20bda9e80ede4757a6a5cf89c979da5f80c135054454ef64ad5ddec09751a23088fe08762084b13c097c56db3c
7
+ data.tar.gz: 47f28845aad32b4ba53f76acf4fab7695c903cb8d94197b6ac0096f16a2f048684f5677d35edeaa0c06554ae19d32152294f878e5ef5e8cbd9eccd581671389a
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- quince (0.2.0)
4
+ quince (0.2.1)
5
5
  oj (~> 3.13)
6
6
  typed_struct (>= 0.1.4)
7
7
 
@@ -470,6 +470,11 @@ module Quince
470
470
  DOM_EVENTS = {
471
471
  onclick: opt_method,
472
472
  onsubmit: opt_method,
473
+ onblur: opt_method,
474
+ onchange: opt_method,
475
+ onsearch: opt_method,
476
+ onkeyup: opt_method,
477
+ onselect: opt_method,
473
478
  }.freeze
474
479
  end
475
480
  end
@@ -45,10 +45,13 @@ module Quince
45
45
  CGI.escape_html(
46
46
  "callRemoteEndpoint(`/api/#{owner}/#{name}`,`#{payload}`,`#{selector}`)"
47
47
  )
48
- when :onsubmit
49
- CGI.escape_html(
50
- "const p = #{payload}; callRemoteEndpoint( `/api/#{owner}/#{name}`, JSON.stringify({...p, params: getFormValues(this)}), `#{selector}`); return false"
51
- )
48
+ when :onsubmit, :onchange, :onblur, :onsearch, :onkeyup, :onselect
49
+ ev = "const p = #{payload}; callRemoteEndpoint( `/api/#{owner}/#{name}`, JSON.stringify({...p, params: getFormValues(this)}), `#{selector}`)"
50
+ case key
51
+ when :onsubmit
52
+ ev += "; return false"
53
+ end
54
+ CGI.escape_html(ev)
52
55
  end
53
56
  when true
54
57
  return key
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Quince
4
- VERSION = "0.2.0"
4
+ VERSION = "0.2.1"
5
5
  end
data/scripts.js CHANGED
@@ -18,7 +18,11 @@ const callRemoteEndpoint = (endpoint, payload, selector) => {
18
18
  })
19
19
  }
20
20
 
21
- const getFormValues = (form) => {
21
+ const getFormValues = (elem) => {
22
+ let form = elem.localName === "form" ? elem : elem.form;
23
+ if (!form) {
24
+ throw `element ${elem} should belong to a form`;
25
+ }
22
26
  const fd = new FormData(form);
23
27
  return Object.fromEntries(fd.entries());
24
28
  }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: quince
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joseph Johansen
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-09-13 00:00:00.000000000 Z
11
+ date: 2021-09-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: typed_struct