jquery-textchange-rails 0.0.1 → 0.0.2

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: ff3a6301829a408423246c359ffec34392a4b538
4
- data.tar.gz: f267bf4fa4b8e1eabf301e73912ed61b82fd05c2
3
+ metadata.gz: 6ab064edff0a9406822885072ec190518a060788
4
+ data.tar.gz: 47b5a2ef2a60f92d8e093c863be430df339f628b
5
5
  SHA512:
6
- metadata.gz: 5f8d63a9c36c78cbff8f4f60c11110a820d2a0c0662f4979ca728400b0bf717ee0d770039c691dcb6546b46a1885e7c8cdef23ec1151ef8bd73e0428d3b8e2cd
7
- data.tar.gz: 0485424b8747f1be9fec99e2b6f401d89f76957be8a58e5b628c3933f44d2cf5a7fadb3c82260591fde1ccc69063945f49440aec765d545b7af18392c76e9fac
6
+ metadata.gz: 89204ab4f6b874da518207e5646060ce8d4f75431ed244ace74b4659e6dc70d6b843f7156298daad2b8cd7c7252c5ee9c20c4114c7737aa2b8b3ae026239b763
7
+ data.tar.gz: d0616c41caabe76d9bfb7b3ae74dac9d1859b1e19b8f27a82e79d4d3bf033aa356841c914b272e9080f4de1b6e29d93c73337f15efe7a6cbeca292a9ec304366
@@ -16,6 +16,8 @@ Gem::Specification.new do |spec|
16
16
  spec.files = `git ls-files`.split($/)
17
17
  spec.require_paths = ["lib"]
18
18
 
19
+ spec.add_dependency "jquery-rails", ">= 2.0.0"
20
+
19
21
  spec.add_development_dependency "bundler", "~> 1.3"
20
22
  spec.add_development_dependency "rake"
21
23
  spec.add_development_dependency "railties", ">= 3.2.0", "< 5.0"
@@ -3,7 +3,7 @@
3
3
  module Jquery
4
4
  module Textchange
5
5
  module Rails
6
- VERSION = '0.0.1'
6
+ VERSION = '0.0.2'
7
7
  end
8
8
  end
9
9
  end
@@ -6,30 +6,38 @@
6
6
  * Released under the MIT License
7
7
  */
8
8
  (function ($) {
9
-
9
+
10
10
  $.event.special.textchange = {
11
-
12
- setup: function (data, namespaces) {
13
- $(this).data('lastValue', this.contentEditable === 'true' ? $(this).html() : $(this).val());
14
- $(this).bind('keyup.textchange', $.event.special.textchange.handler);
15
- $(this).bind('cut.textchange paste.textchange input.textchange', $.event.special.textchange.delayedHandler);
16
- },
17
-
18
- teardown: function (namespaces) {
19
- $(this).unbind('.textchange');
20
- },
21
-
11
+
12
+ add: function (handleObj) {
13
+ var elem = $(this);
14
+ if (handleObj.selector != undefined) {
15
+ elem = elem.find(handleObj.selector);
16
+ }
17
+ elem.data('lastValue', elem[0].contentEditable === 'true' ? elem.html() : elem.val());
18
+ elem.bind('keyup.textchange', $.event.special.textchange.handler);
19
+ elem.bind('cut.textchange paste.textchange input.textchange', $.event.special.textchange.delayedHandler);
20
+ },
21
+
22
+ remove: function (handleObj) {
23
+ var elem = $(this);
24
+ if (handleObj.selector != undefined) {
25
+ elem = elem.find(handleObj.selector);
26
+ }
27
+ elem.unbind('.textchange');
28
+ },
29
+
22
30
  handler: function (event) {
23
31
  $.event.special.textchange.triggerIfChanged($(this));
24
32
  },
25
-
33
+
26
34
  delayedHandler: function (event) {
27
35
  var element = $(this);
28
36
  setTimeout(function () {
29
37
  $.event.special.textchange.triggerIfChanged(element);
30
38
  }, 25);
31
39
  },
32
-
40
+
33
41
  triggerIfChanged: function (element) {
34
42
  var current = element[0].contentEditable === 'true' ? element.html() : element.val();
35
43
  if (current !== element.data('lastValue')) {
@@ -38,39 +46,55 @@
38
46
  }
39
47
  }
40
48
  };
41
-
49
+
42
50
  $.event.special.hastext = {
43
-
44
- setup: function (data, namespaces) {
45
- $(this).bind('textchange', $.event.special.hastext.handler);
51
+
52
+ add: function (handleObj) {
53
+ var elem = $(this);
54
+ if (handleObj.selector != undefined) {
55
+ elem = elem.find(handleObj.selector);
56
+ }
57
+ elem.bind('textchange', $.event.special.hastext.handler);
46
58
  },
47
-
48
- teardown: function (namespaces) {
49
- $(this).unbind('textchange', $.event.special.hastext.handler);
59
+
60
+ remove: function (handleObj) {
61
+ var elem = $(this);
62
+ if (handleObj.selector != undefined) {
63
+ elem = elem.find(handleObj.selector);
64
+ }
65
+ elem.unbind('textchange', $.event.special.hastext.handler);
50
66
  },
51
-
67
+
52
68
  handler: function (event, lastValue) {
53
69
  if ((lastValue === '') && lastValue !== $(this).val()) {
54
70
  $(this).trigger('hastext');
55
71
  }
56
72
  }
57
73
  };
58
-
74
+
59
75
  $.event.special.notext = {
60
-
61
- setup: function (data, namespaces) {
62
- $(this).bind('textchange', $.event.special.notext.handler);
76
+
77
+ add: function (handleObj) {
78
+ var elem = $(this);
79
+ if (handleObj.selector != undefined) {
80
+ elem = elem.find(handleObj.selector);
81
+ }
82
+ elem.bind('textchange', $.event.special.notext.handler);
63
83
  },
64
-
65
- teardown: function (namespaces) {
66
- $(this).unbind('textchange', $.event.special.notext.handler);
84
+
85
+ remove: function (handleObj) {
86
+ var elem = $(this);
87
+ if (handleObj.selector != undefined) {
88
+ elem = elem.find(handleObj.selector);
89
+ }
90
+ elem.unbind('textchange', $.event.special.notext.handler);
67
91
  },
68
-
92
+
69
93
  handler: function (event, lastValue) {
70
94
  if ($(this).val() === '' && $(this).val() !== lastValue) {
71
95
  $(this).trigger('notext');
72
96
  }
73
97
  }
74
- };
98
+ };
75
99
 
76
- })(jQuery);
100
+ })(jQuery);
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jquery-textchange-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Kelly
@@ -9,8 +9,22 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-09-08 00:00:00.000000000 Z
12
+ date: 2013-09-22 00:00:00.000000000 Z
13
13
  dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: jquery-rails
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - '>='
19
+ - !ruby/object:Gem::Version
20
+ version: 2.0.0
21
+ type: :runtime
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - '>='
26
+ - !ruby/object:Gem::Version
27
+ version: 2.0.0
14
28
  - !ruby/object:Gem::Dependency
15
29
  name: bundler
16
30
  requirement: !ruby/object:Gem::Requirement