formize 0.0.18 → 0.0.19

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.18
1
+ 0.0.19
@@ -72,7 +72,7 @@ $.datepicker.regional['zh-TW'] = { closeText: '關閉', prevText: '<上月'
72
72
  }
73
73
  }
74
74
  // Rebinds unbound elements on each ajax request.
75
- $(document).ajaxStop(function () {
75
+ $(document).ajaxComplete(function () {
76
76
  for (var behaviour in $.behaviours) {
77
77
  behaviour = $.behaviours[behaviour];
78
78
  $(behaviour.selector).each(function(index, element){
@@ -107,7 +107,8 @@ $.datepicker.regional['zh-TW'] = { closeText: '關閉', prevText: '<上月'
107
107
  show: 'fade',
108
108
  modal: true,
109
109
  width: 'auto',
110
- height: 'auto'
110
+ // height: 'auto',
111
+ height: $(document).height()*0.8
111
112
  });
112
113
  $.ajaxDialogInitialize(frame);
113
114
  frame.dialog("open");
@@ -224,12 +225,13 @@ Formize.refreshDependents = function (event) {
224
225
  Formize.Toggles = {
225
226
 
226
227
  ifChecked: function () {
227
- if (this.checked) {
228
- $($(this).attr('data-show')).slideDown();
229
- $($(this).attr('data-hide')).slideUp();
228
+ var check_box = $(this);
229
+ if (check_box.prop("checked")) {
230
+ $(check_box.attr('data-show')).slideDown();
231
+ $(check_box.attr('data-hide')).slideUp();
230
232
  } else {
231
- $($(this).attr('data-show')).slideUp();
232
- $($(this).attr('data-hide')).slideDown();
233
+ $(check_box.attr('data-show')).slideUp();
234
+ $(check_box.attr('data-hide')).slideDown();
233
235
  }
234
236
  }
235
237
 
@@ -343,6 +345,14 @@ $.behave("a[data-add-item]", "click", function() {
343
345
  return false;
344
346
  });
345
347
 
348
+ $.behave("input[data-autocomplete]", "load", function () {
349
+ var element = $(this);
350
+ element.autocomplete({
351
+ source: element.attr("data-autocomplete"),
352
+ minLength: parseInt(element.attr("data-min-length") || 1)
353
+ });
354
+ });
355
+
346
356
  // Refresh dependents on changes
347
357
  $.behave("*[data-dependents]", "change", Formize.refreshDependents);
348
358
  $.behave("*[data-dependents]", "emulated:change", Formize.refreshDependents);
@@ -16,7 +16,7 @@
16
16
  }
17
17
  }
18
18
  // Rebinds unbound elements on each ajax request.
19
- $(document).ajaxStop(function () {
19
+ $(document).ajaxComplete(function () {
20
20
  for (var behaviour in $.behaviours) {
21
21
  behaviour = $.behaviours[behaviour];
22
22
  $(behaviour.selector).each(function(index, element){
@@ -51,7 +51,8 @@
51
51
  show: 'fade',
52
52
  modal: true,
53
53
  width: 'auto',
54
- height: 'auto'
54
+ // height: 'auto',
55
+ height: $(document).height()*0.8
55
56
  });
56
57
  $.ajaxDialogInitialize(frame);
57
58
  frame.dialog("open");
@@ -168,12 +169,13 @@ Formize.refreshDependents = function (event) {
168
169
  Formize.Toggles = {
169
170
 
170
171
  ifChecked: function () {
171
- if (this.checked) {
172
- $($(this).attr('data-show')).slideDown();
173
- $($(this).attr('data-hide')).slideUp();
172
+ var check_box = $(this);
173
+ if (check_box.prop("checked")) {
174
+ $(check_box.attr('data-show')).slideDown();
175
+ $(check_box.attr('data-hide')).slideUp();
174
176
  } else {
175
- $($(this).attr('data-show')).slideUp();
176
- $($(this).attr('data-hide')).slideDown();
177
+ $(check_box.attr('data-show')).slideUp();
178
+ $(check_box.attr('data-hide')).slideDown();
177
179
  }
178
180
  }
179
181
 
@@ -287,6 +289,14 @@ $.behave("a[data-add-item]", "click", function() {
287
289
  return false;
288
290
  });
289
291
 
292
+ $.behave("input[data-autocomplete]", "load", function () {
293
+ var element = $(this);
294
+ element.autocomplete({
295
+ source: element.attr("data-autocomplete"),
296
+ minLength: parseInt(element.attr("data-min-length") || 1)
297
+ });
298
+ });
299
+
290
300
  // Refresh dependents on changes
291
301
  $.behave("*[data-dependents]", "change", Formize.refreshDependents);
292
302
  $.behave("*[data-dependents]", "emulated:change", Formize.refreshDependents);
@@ -18,6 +18,7 @@ module Formize
18
18
  @unique_name = @options.delete(:unique_name) unless @options[:unique_name].blank?
19
19
  @unique_name ||= "_formize#{@id}"
20
20
  @record_name = @model.name.underscore
21
+ @elements_count = 0
21
22
  end
22
23
 
23
24
  def field_set(name=nil, options={}, &block)
@@ -91,6 +92,11 @@ module Formize
91
92
 
92
93
  private
93
94
 
95
+ def new_id
96
+ @elements_count += 1
97
+ return @elements_count.to_s(36)
98
+ end
99
+
94
100
  def new_element(klass, *args)
95
101
  raise ArgumentError.new("Bad child type: #{klass.name} (#{klass.ancestors.inspect}). Must be an Formize::Definition::FormElement") unless klass < Formize::Definition::FormElement # klass.ancestors.include? Formize::FormElement
96
102
  element = klass.new(self, nil, *args)
@@ -5,7 +5,6 @@ module Formize
5
5
  # Main class for form elements
6
6
  class FormElement
7
7
  attr_reader :children, :depend_on, :form, :html_id, :id, :options, :parent, :unique_name
8
- @@count = 0 # unless defined? @@count
9
8
 
10
9
  def initialize(form, parent = nil, options={})
11
10
  raise ArgumentError.new("Bad form (#{form.class.name}). Must be an Formize::Definition::Form") unless form.is_a? Formize::Definition::Form
@@ -14,8 +13,7 @@ module Formize
14
13
  @options = (options.is_a?(Hash) ? options : {})
15
14
  @depend_on = nil
16
15
  @children = []
17
- @@count += 1
18
- @id = @@count.to_s(36)
16
+ @id = form.send(:new_id)
19
17
  if Rails.env == "development"
20
18
  @html_id = "fz_#{@form.options[:best_name]}_#{@id}"
21
19
  else
@@ -31,8 +31,8 @@ module Formize
31
31
  if options[:monolithic]
32
32
  html << javascript_include_tag('formize')
33
33
  else
34
- html << javascript_include_tag('jquery.ui.formize')
35
34
  html << javascript_include_tag('locales/jquery.ui.datepicker-' + locale.to_s)
35
+ html << javascript_include_tag('jquery.ui.formize')
36
36
  end
37
37
  unless options[:skip_stylesheet]
38
38
  html << stylesheet_link_tag('jquery-ui')
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.18
4
+ version: 0.0.19
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: 2011-09-18 00:00:00.000000000Z
12
+ date: 2011-09-19 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
16
- requirement: &14170620 !ruby/object:Gem::Requirement
16
+ requirement: &12364680 !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: *14170620
24
+ version_requirements: *12364680
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: jquery-rails
27
- requirement: &14169920 !ruby/object:Gem::Requirement
27
+ requirement: &12362020 !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: *14169920
35
+ version_requirements: *12362020
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: fastercsv
38
- requirement: &14169240 !ruby/object:Gem::Requirement
38
+ requirement: &12359700 !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: :runtime
45
45
  prerelease: false
46
- version_requirements: *14169240
46
+ version_requirements: *12359700
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: jeweler
49
- requirement: &14168460 !ruby/object:Gem::Requirement
49
+ requirement: &12086380 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ~>
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: 1.6.4
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *14168460
57
+ version_requirements: *12086380
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: rcov
60
- requirement: &14167860 !ruby/object:Gem::Requirement
60
+ requirement: &12083820 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: '0'
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *14167860
68
+ version_requirements: *12083820
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rdoc
71
- requirement: &14167300 !ruby/object:Gem::Requirement
71
+ requirement: &12060320 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ! '>='
@@ -76,7 +76,7 @@ dependencies:
76
76
  version: 2.4.2
77
77
  type: :development
78
78
  prerelease: false
79
- version_requirements: *14167300
79
+ version_requirements: *12060320
80
80
  description: Like simple_form or formtastic, it aims to handle easily forms but taking
81
81
  in account AJAX and HTML5 on depending fields mainly.
82
82
  email: brice.texier@ekylibre.org
@@ -209,7 +209,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
209
209
  version: '0'
210
210
  segments:
211
211
  - 0
212
- hash: -2578488485569496795
212
+ hash: 1687169217529318085
213
213
  required_rubygems_version: !ruby/object:Gem::Requirement
214
214
  none: false
215
215
  requirements:
@@ -218,7 +218,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
218
218
  version: '0'
219
219
  requirements: []
220
220
  rubyforge_project:
221
- rubygems_version: 1.8.10
221
+ rubygems_version: 1.8.7
222
222
  signing_key:
223
223
  specification_version: 3
224
224
  summary: Simple form DSL with dynamic interactions for Rails