jquery-disablewith 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -11,7 +11,35 @@ somewhere in your views:
11
11
 
12
12
  then in application.js you can write something like that:
13
13
 
14
- $("a").disableWith({ text: "Processing..." })
14
+ $("a").disableWith();
15
15
 
16
16
  It will replace "Send request" words with "Processing..." before the request start,
17
- and turn it back on complete.
17
+ and turn it back on complete. It will also disable the `click` event on the element
18
+ until the AJAX request complete.
19
+
20
+ You can change the text:
21
+
22
+ $("a").disableWith({ text: "Loading..." });
23
+
24
+
25
+ # Requirements
26
+
27
+ * jquery-rails
28
+
29
+ # Installation
30
+
31
+ Add to the `Gemfile`
32
+
33
+ gem jquery-disablewith
34
+
35
+ Then run
36
+
37
+ bundle install
38
+
39
+ # Usage
40
+
41
+ Add
42
+
43
+ //=require jquery.disablewith
44
+
45
+ into the `application.js`
data/TODO.md ADDED
@@ -0,0 +1,5 @@
1
+ # TODO
2
+
3
+ * Add details to gemspec
4
+ * Use data attributes
5
+ * `disable_with` option for `link_to ... remote: true`
@@ -7,7 +7,7 @@ Gem::Specification.new do |s|
7
7
  s.version = Jquery::Disablewith::VERSION
8
8
  s.authors = ["Alexander Glushkov"]
9
9
  s.email = ["cutalion@gmail.com"]
10
- s.homepage = ""
10
+ s.homepage = "https://github.com/cutalion/jquery-disablewith"
11
11
  s.summary = %q{Plugin for disabling remote links}
12
12
  s.description = %q{This plugin gives you an option to disable remote links during the AJAX request}
13
13
 
@@ -1,5 +1,5 @@
1
1
  module Jquery
2
2
  module Disablewith
3
- VERSION = "0.0.1"
3
+ VERSION = "0.0.2"
4
4
  end
5
5
  end
@@ -2,18 +2,23 @@
2
2
  $.fn.disableWith = function(options){
3
3
 
4
4
  var settings = $.extend({
5
- text: 'Processing...'
5
+ text : 'Processing...',
6
+ disable_event : function(e){
7
+ e.preventDefault();
8
+ return false;
9
+ }
6
10
  }, options);
7
11
 
8
12
  this.bind('ajax:beforeSend', function(){
9
13
  $(this)._previous_text = $(this).html();
10
- $(this).html(settings.text);
14
+ $(this).html(settings.text).click(settings.disable_event);
11
15
  });
12
16
 
13
17
  this.bind('ajax:complete', function(){
14
- $(this).html($(this)._previous_text);
18
+ $(this).html($(this)._previous_text).unbind(click, settings.disable_event);
15
19
  });
16
20
 
21
+
17
22
  return this;
18
23
  };
19
24
  })(jQuery);
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jquery-disablewith
3
3
  version: !ruby/object:Gem::Version
4
- hash: 29
4
+ hash: 27
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 1
10
- version: 0.0.1
9
+ - 2
10
+ version: 0.0.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Alexander Glushkov
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-12-10 00:00:00 Z
18
+ date: 2011-12-15 00:00:00 Z
19
19
  dependencies: []
20
20
 
21
21
  description: This plugin gives you an option to disable remote links during the AJAX request
@@ -32,12 +32,13 @@ files:
32
32
  - Gemfile
33
33
  - README.md
34
34
  - Rakefile
35
+ - TODO.md
35
36
  - jquery-disablewith.gemspec
36
37
  - lib/jquery-disablewith.rb
37
38
  - lib/jquery/disablewith.rb
38
39
  - lib/jquery/disablewith/version.rb
39
40
  - vendor/assets/javascripts/jquery.disablewith.js
40
- homepage: ""
41
+ homepage: https://github.com/cutalion/jquery-disablewith
41
42
  licenses: []
42
43
 
43
44
  post_install_message: