button_link_to 0.0.2 → 0.0.3

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: ec700768bf132c1138738e049471ecfe712f06ad
4
- data.tar.gz: 4fd622ecc4844fe5770fc340fe6b2e42e3b5da87
3
+ metadata.gz: 16125ebbfdf806e9861579cc672ce88d642caa7d
4
+ data.tar.gz: d5eecf5357f923488d910774d089052ac81f808c
5
5
  SHA512:
6
- metadata.gz: c8bd903df8db0cd04f08ce161265f5c1518daf4ecc53b339aea18bc4ef449c7fb0f2595e91b7c4b99c11274d5839e4416c2ed7be8cbab31a48e286d939a17cb0
7
- data.tar.gz: 093cab5d34c65b4e3a945e98e80a204527ec22161986e74dfdc5a83444b440c9aca0dc6cfa1dae0d0972585eb69692fa07d8384b2812a91d6a1d8e4077c955fb
6
+ metadata.gz: 28ea45f6ccdaa2a1cfe53eca6cd4b3d867744b3ab9ee4f8347990fe810364faf740f6569dceeb8783cfb4cdd993c260ecabf3d9b610bcd89b638a0860b71e47f
7
+ data.tar.gz: 2b02fb7f6da9ecd7519270f59d9f4a359c0017cee44f4119120ff5e54b8ee1b880230c8201572c967642a7471fe1fcdb34d8b11807ebb8b85f2c03d994fadd44
@@ -1,5 +1,6 @@
1
1
  (function() {
2
- // jquery ujs hack for remote ajax button
2
+ $document = $(document)
3
+
3
4
  $(document).on("mouseup", "button[data-remote]", function(e) {
4
5
  // middle button click
5
6
  if(e.which == 2) {
@@ -7,14 +8,28 @@
7
8
  }
8
9
  });
9
10
 
10
- $(document).on("click.rails", "button[data-method]", function(e) {
11
- if (!$.rails.allowAction($(e.currentTarget))) return $.rails.stopEverything(e);
12
- });
13
11
 
14
- // jquery ujs hack for form restful button
15
- $(document).on("click.rails", "button[data-method]", function(e) {
12
+ $document.on("click.rails", "button[data-method]", function(e) {
16
13
  button = $(e.currentTarget)
17
14
 
15
+ if (button.data('disable-with')) $.rails.disableElement(button);
16
+
17
+ if (button.data('method') && button.data('remote') === undefined) {
18
+ if (!$.rails.allowAction(button)) return $.rails.stopEverything(e);
19
+
20
+ handleMethod(button)
21
+ }
22
+
23
+ });
24
+
25
+
26
+ $document.on("ajax:complete", "button[data-disable-with]", function() {
27
+ $.rails.enableElement($(this));
28
+ });
29
+
30
+
31
+ var handleMethod = function(button) {
32
+
18
33
  var url = button.data("url"),
19
34
  method = button.data('method'),
20
35
  target = button.data('target'),
@@ -31,6 +46,8 @@
31
46
 
32
47
  form.hide().append(metadata_input).appendTo('body');
33
48
  form.submit();
49
+ }
50
+
51
+
34
52
 
35
- });
36
53
  })();
@@ -1,3 +1,3 @@
1
1
  module ButtonLinkTo
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: button_link_to
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - tonilin
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-10-04 00:00:00.000000000 Z
11
+ date: 2013-10-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler