protected_form 0.0.3 → 0.0.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
  SHA1:
3
- metadata.gz: 5f0828c20800b13489a8df038b9930d19eaa227e
4
- data.tar.gz: 45a2a4457f71224bda512b3a6d8891b37751dc6f
3
+ metadata.gz: cbb991da2f99fcd155f75db22fb8b5f7d7ac1f34
4
+ data.tar.gz: b137e156dd439b9113c4271d48521c1c6ad41ad7
5
5
  SHA512:
6
- metadata.gz: 9b9636d0d8a014b0875129cbac922f6d468d58f5925e777c6767dfde07645989931393835031d1074b0426d12b59a83ba21b2d374b0a6d856dd8fa545676e079
7
- data.tar.gz: 459e0f142c977be7a79b9899ceeca942b96000c6c069db24ab3e2769026c7bd220680f0ebef8179e86a96b451ca4f4ca26f3030392316ce4de4579de6973c4dd
6
+ metadata.gz: d85e3d57e903a3e4cc1622f0cf3bd769d3bb4d1de5209b904501776463c52b21a3d5c58bb77961329e7f3ab02a7ef2def1427188a70b324b3f0f122cb011d617
7
+ data.tar.gz: 4c55dd12960c0408cb2e4869a5d11b96a6c22ff62ea81866dd836120b3bf6511358889367bf1ad10a9ef291cd07a75589a414d8360f084d5a5a6653e400f4b3a
@@ -1,3 +1,3 @@
1
1
  module ProtectedForm
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
@@ -3,15 +3,15 @@
3
3
  var matches;
4
4
 
5
5
  (function(doc) {
6
- matches =
7
- doc.matchesSelector ||
8
- doc.webkitMatchesSelector ||
9
- doc.mozMatchesSelector ||
10
- doc.oMatchesSelector ||
11
- doc.msMatchesSelector;
6
+ matches =
7
+ doc.matchesSelector ||
8
+ doc.webkitMatchesSelector ||
9
+ doc.mozMatchesSelector ||
10
+ doc.oMatchesSelector ||
11
+ doc.msMatchesSelector;
12
12
  })(document.documentElement);
13
13
 
14
- // simple implementation of $(document).delegate
14
+ // Simple implementation of $(document).delegate
15
15
  function delegate(event, selector, callback) {
16
16
  document.addEventListener(event, function(e){
17
17
  if (matches.call(e.target, selector)) {
@@ -21,29 +21,22 @@
21
21
  }
22
22
 
23
23
  //Form Submit
24
- function sendProtectedForm(event) {
25
- // looking for closest .js-protected-form block
24
+ function sendProtectedForm() {
25
+ // Looking for closest .js-protected-form block
26
26
  var container = this;
27
27
  do {
28
28
  container = container.parentNode;
29
29
  }
30
30
  while (!container.className.match('js-protected-form'));
31
31
  var form = document.getElementById(container.id + '_form').firstChild;
32
- var submitEvent = new Event('submit', {
33
- 'bubbles' : true,
34
- 'cancelable' : true
35
- });
36
32
 
37
- // change html structure: return content into form
38
- container.parentNode.insertBefore(form, container[0]);
33
+ // Change html structure: return content into form
34
+ container.parentNode.insertBefore(form, container);
39
35
  form.firstChild.appendChild(container);
40
36
 
41
- // and than trigger submit for this form
42
- form.dispatchEvent(submitEvent);
43
- if (event) {
44
- // Prevent double submit event
45
- event.preventDefault();
46
- }
37
+ // Fix for IE when using certain versions of pjax libraries and losing focus
38
+ document.body.focus();
39
+
47
40
  return false;
48
41
  }
49
42
 
@@ -53,4 +46,4 @@
53
46
  sendProtectedForm.call(e.target);
54
47
  }
55
48
  });
56
- }(this));
49
+ }(this));
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: protected_form
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexandr Subbotin
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-05-27 00:00:00.000000000 Z
11
+ date: 2016-02-15 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Simple anti-spam wrapper for `form_for` with javascript form submission
14
14
  with changing html structure of form.
@@ -54,3 +54,4 @@ signing_key:
54
54
  specification_version: 4
55
55
  summary: Spam protection for rails forms
56
56
  test_files: []
57
+ has_rdoc: