formize 0.0.26 → 0.0.27

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.26
1
+ 0.0.27
@@ -309,17 +309,23 @@ $.behave('input[data-datepicker]', "load", function() {
309
309
  if (element.data("date-format") !== null) {
310
310
  options['dateFormat'] = element.data("date-format");
311
311
  }
312
- triggered = $('#'+element.data("datepicker"))
313
312
  options['altField'] = '#'+element.data("datepicker");
314
313
  options['altFormat'] = 'yy-mm-dd';
315
314
  options['defaultDate'] = element.val();
316
- options['onSelect'] = function (dateText) {
317
- triggered.trigger("emulated:change");
318
- };
315
+ // Check for dependents
316
+ triggered = $(options['altField']);
317
+ if (triggered.data('dependents') !== undefined && triggered.data('dependents') !== null) {
318
+ if (triggered.data('observe') === undefined || triggered.data('observe') === null) {
319
+ triggered.attr('data-observe', '1000');
320
+ }
321
+ }
322
+ /*options['onSelect'] = function (dateText, inst) {
323
+ triggered.trigger("emulated:change");
324
+ };*/
319
325
  element.datepicker(options);
320
- element.keyup(function() {
321
- triggered.trigger("emulated:change");
322
- });
326
+ /* element.keyup(function() {
327
+ triggered.trigger("emulated:change");
328
+ });*/
323
329
  });
324
330
 
325
331
 
@@ -394,6 +400,29 @@ $.behave("input[data-autocompletion]", "load", function () {
394
400
  });
395
401
  });
396
402
 
403
+ // Observes fields comparing its value with fixed intervals of time
404
+ // Compensates not quite sure "change" events.
405
+ $.behave("*[data-observe]", "load", function () {
406
+ var element = $(this);
407
+ var interval = parseInt(element.data("observe"));
408
+ if (interval === null || interval === undefined) {
409
+ interval = 1000;
410
+ }
411
+ if (element.get(0).nodeName.toLowerCase() !== "input") {
412
+ alert("data-observe attribute must be only used with <input>s.");
413
+ return false;
414
+ }
415
+ element.previousObservedValue = element.val();
416
+ window.setInterval(function () {
417
+ if (element.val() !== element.previousObservedValue) {
418
+ element.trigger("emulated:change");
419
+ element.previousObservedValue = element.val();
420
+ }
421
+ }, interval);
422
+ return true;
423
+ });
424
+
425
+
397
426
  // Refresh dependents on changes
398
427
  $.behave("*[data-dependents]", "change emulated:change", Formize.refreshDependents);
399
428
  // Compensate for changes made with keyboard
@@ -253,17 +253,23 @@ $.behave('input[data-datepicker]', "load", function() {
253
253
  if (element.data("date-format") !== null) {
254
254
  options['dateFormat'] = element.data("date-format");
255
255
  }
256
- triggered = $('#'+element.data("datepicker"))
257
256
  options['altField'] = '#'+element.data("datepicker");
258
257
  options['altFormat'] = 'yy-mm-dd';
259
258
  options['defaultDate'] = element.val();
260
- options['onSelect'] = function (dateText) {
261
- triggered.trigger("emulated:change");
262
- };
259
+ // Check for dependents
260
+ triggered = $(options['altField']);
261
+ if (triggered.data('dependents') !== undefined && triggered.data('dependents') !== null) {
262
+ if (triggered.data('observe') === undefined || triggered.data('observe') === null) {
263
+ triggered.attr('data-observe', '1000');
264
+ }
265
+ }
266
+ /*options['onSelect'] = function (dateText, inst) {
267
+ triggered.trigger("emulated:change");
268
+ };*/
263
269
  element.datepicker(options);
264
- element.keyup(function() {
265
- triggered.trigger("emulated:change");
266
- });
270
+ /* element.keyup(function() {
271
+ triggered.trigger("emulated:change");
272
+ });*/
267
273
  });
268
274
 
269
275
 
@@ -338,6 +344,29 @@ $.behave("input[data-autocompletion]", "load", function () {
338
344
  });
339
345
  });
340
346
 
347
+ // Observes fields comparing its value with fixed intervals of time
348
+ // Compensates not quite sure "change" events.
349
+ $.behave("*[data-observe]", "load", function () {
350
+ var element = $(this);
351
+ var interval = parseInt(element.data("observe"));
352
+ if (interval === null || interval === undefined) {
353
+ interval = 1000;
354
+ }
355
+ if (element.get(0).nodeName.toLowerCase() !== "input") {
356
+ alert("data-observe attribute must be only used with <input>s.");
357
+ return false;
358
+ }
359
+ element.previousObservedValue = element.val();
360
+ window.setInterval(function () {
361
+ if (element.val() !== element.previousObservedValue) {
362
+ element.trigger("emulated:change");
363
+ element.previousObservedValue = element.val();
364
+ }
365
+ }, interval);
366
+ return true;
367
+ });
368
+
369
+
341
370
  // Refresh dependents on changes
342
371
  $.behave("*[data-dependents]", "change emulated:change", Formize.refreshDependents);
343
372
  // Compensate for changes made with keyboard
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: formize
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.26
4
+ version: 0.0.27
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-03-09 00:00:00.000000000Z
12
+ date: 2012-03-12 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
16
- requirement: &25166340 !ruby/object:Gem::Requirement
16
+ requirement: &18826360 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '3'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *25166340
24
+ version_requirements: *18826360
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: jquery-rails
27
- requirement: &25165740 !ruby/object:Gem::Requirement
27
+ requirement: &18825380 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *25165740
35
+ version_requirements: *18825380
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: jeweler
38
- requirement: &25165140 !ruby/object:Gem::Requirement
38
+ requirement: &18824540 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *25165140
46
+ version_requirements: *18824540
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: rdoc
49
- requirement: &25164540 !ruby/object:Gem::Requirement
49
+ requirement: &18816840 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,7 +54,7 @@ dependencies:
54
54
  version: 2.4.2
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *25164540
57
+ version_requirements: *18816840
58
58
  description: Like simple_form or formtastic, it aims to handle easily forms but taking
59
59
  in account AJAX and HTML5 on depending fields mainly.
60
60
  email: brice.texier@ekylibre.org
@@ -187,7 +187,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
187
187
  version: '0'
188
188
  segments:
189
189
  - 0
190
- hash: 3583729754468145096
190
+ hash: -4207803932127150052
191
191
  required_rubygems_version: !ruby/object:Gem::Requirement
192
192
  none: false
193
193
  requirements:
@@ -196,7 +196,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
196
196
  version: '0'
197
197
  requirements: []
198
198
  rubyforge_project:
199
- rubygems_version: 1.8.10
199
+ rubygems_version: 1.8.11
200
200
  signing_key:
201
201
  specification_version: 3
202
202
  summary: Simple form DSL with dynamic interactions for Rails