will_filter 3.1.11 → 5.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (99) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +1 -0
  3. data/Gemfile +8 -3
  4. data/Gemfile.lock +182 -127
  5. data/README.rdoc +1 -10
  6. data/app/assets/images/will_filter/loading.gif +0 -0
  7. data/app/assets/javascripts/will_filter/filter.js +526 -517
  8. data/app/assets/stylesheets/will_filter/filter.css.scss +405 -108
  9. data/app/controllers/will_filter/calendar_controller.rb +10 -1
  10. data/app/controllers/will_filter/exporter_controller.rb +12 -3
  11. data/app/controllers/will_filter/filter_controller.rb +19 -10
  12. data/app/models/will_filter/filter.rb +254 -203
  13. data/app/views/will_filter/calendar/index.html.erb +55 -43
  14. data/app/views/will_filter/common/_actions_bar.html.erb +3 -3
  15. data/app/views/will_filter/common/_results_table.html.erb +55 -39
  16. data/app/views/will_filter/common/_scripts.html.erb +2 -12
  17. data/app/views/will_filter/exporter/index.html.erb +26 -22
  18. data/app/views/will_filter/filter/_condition.html.erb +25 -9
  19. data/app/views/will_filter/filter/_conditions.html.erb +12 -9
  20. data/app/views/will_filter/filter/_conditions_footer.html.erb +25 -10
  21. data/app/views/will_filter/filter/_conditions_header.html.erb +38 -24
  22. data/app/views/will_filter/filter/_container.html.erb +10 -9
  23. data/app/views/will_filter/filter/containers/_date.html.erb +8 -10
  24. data/app/views/will_filter/filter/containers/_date_range.html.erb +21 -13
  25. data/app/views/will_filter/filter/containers/_date_time.html.erb +8 -10
  26. data/app/views/will_filter/filter/containers/_date_time_range.html.erb +21 -13
  27. data/app/views/will_filter/filter/containers/_list.html.erb +16 -6
  28. data/config/routes.rb +26 -16
  29. data/deploy +63 -0
  30. data/lib/generators/will_filter/templates/config.yml +18 -5
  31. data/lib/generators/will_filter/templates/create_will_filter_filters.rb +12 -1
  32. data/lib/generators/will_filter/will_filter_generator.rb +10 -1
  33. data/lib/tasks/will_filter_tasks.rake +10 -2
  34. data/lib/will_filter.rb +10 -1
  35. data/lib/will_filter/calendar.rb +10 -1
  36. data/lib/will_filter/config.rb +31 -4
  37. data/lib/will_filter/containers/boolean.rb +10 -1
  38. data/lib/will_filter/containers/date.rb +10 -1
  39. data/lib/will_filter/containers/date_range.rb +10 -1
  40. data/lib/will_filter/containers/date_time.rb +10 -1
  41. data/lib/will_filter/containers/date_time_range.rb +10 -1
  42. data/lib/will_filter/containers/double.rb +10 -1
  43. data/lib/will_filter/containers/double_delimited.rb +10 -1
  44. data/lib/will_filter/containers/double_range.rb +10 -1
  45. data/lib/will_filter/containers/filter_list.rb +21 -7
  46. data/lib/will_filter/containers/list.rb +10 -1
  47. data/lib/will_filter/containers/nil.rb +10 -1
  48. data/lib/will_filter/containers/numeric.rb +10 -1
  49. data/lib/will_filter/containers/numeric_delimited.rb +10 -1
  50. data/lib/will_filter/containers/numeric_range.rb +10 -1
  51. data/lib/will_filter/containers/single_date.rb +12 -1
  52. data/lib/will_filter/containers/text.rb +10 -1
  53. data/lib/will_filter/containers/text_delimited.rb +11 -2
  54. data/lib/will_filter/engine.rb +10 -1
  55. data/lib/will_filter/extensions/action_controller_extension.rb +34 -10
  56. data/lib/will_filter/extensions/action_view_extension.rb +12 -3
  57. data/lib/will_filter/extensions/active_record_extension.rb +11 -1
  58. data/lib/will_filter/extensions/active_record_relation_extension.rb +51 -0
  59. data/lib/will_filter/extensions/array_extension.rb +10 -1
  60. data/lib/will_filter/filter_condition.rb +11 -7
  61. data/lib/will_filter/filter_container.rb +10 -1
  62. data/lib/will_filter/filter_exception.rb +10 -1
  63. data/lib/will_filter/railtie.rb +14 -4
  64. data/lib/will_filter/version.rb +11 -2
  65. data/spec/config/config_spec.rb +5 -5
  66. data/spec/models/will_filter/filter_spec.rb +130 -131
  67. data/test/dummy/app/assets/javascripts/application.js +3 -0
  68. data/test/dummy/app/assets/javascripts/bootstrap.js +1951 -0
  69. data/test/dummy/app/assets/javascripts/jquery-2.1.3.min.js +4 -0
  70. data/test/dummy/app/assets/javascripts/select2.min.js +3 -0
  71. data/test/dummy/app/assets/stylesheets/{application.css → application.css.sass} +5 -2
  72. data/test/dummy/app/assets/stylesheets/bootstrap.min.css +7 -0
  73. data/test/dummy/app/assets/stylesheets/select2.min.css +1 -0
  74. data/test/dummy/app/controllers/advanced_controller.rb +4 -4
  75. data/test/dummy/app/controllers/orders_controller.rb +2 -2
  76. data/test/dummy/app/controllers/simple_controller.rb +3 -3
  77. data/test/dummy/app/models/event.rb +1 -1
  78. data/test/dummy/app/models/user.rb +1 -1
  79. data/test/dummy/app/views/common/_events.html.erb +7 -13
  80. data/test/dummy/app/views/common/_menu.html.erb +25 -27
  81. data/test/dummy/app/views/layouts/application.html.erb +3 -5
  82. data/test/dummy/config/environments/development.rb +2 -0
  83. data/test/dummy/config/environments/production.rb +2 -0
  84. data/test/dummy/config/environments/test.rb +2 -0
  85. data/test/dummy/config/initializers/assets.rb +12 -0
  86. data/test/dummy/config/routes.rb +10 -10
  87. data/test/dummy/db/schema.rb +46 -50
  88. data/will_filter.gemspec +3 -3
  89. metadata +39 -44
  90. data/.rvmrc +0 -1
  91. data/app/assets/javascripts/will_filter/filter_prototype_effects.js +0 -38
  92. data/app/assets/stylesheets/will_filter/actions.css.scss +0 -27
  93. data/app/assets/stylesheets/will_filter/buttons.css.scss +0 -24
  94. data/app/assets/stylesheets/will_filter/calendar.css.scss +0 -102
  95. data/app/assets/stylesheets/will_filter/exporter.css.scss +0 -89
  96. data/app/assets/stylesheets/will_filter/results.css.scss +0 -63
  97. data/app/views/layouts/will_filter/application.html.erb +0 -14
  98. data/test/dummy/app/assets/javascripts/orders.js +0 -2
  99. data/test/dummy/app/assets/stylesheets/orders.css +0 -4
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 3792795c59de11d775d37d03afb2d497d9e845d2
4
+ data.tar.gz: 743f32488e08caf6d106f197132e7af9427b8c8f
5
+ SHA512:
6
+ metadata.gz: e53d62aa1a2dc8211b65a0bc41b77c9b35cc6935121621be0e8a5a56fd90786a376cffbed1566e9dac432c9e8301e03d1fe9a124319e76157f1fb767e515a084
7
+ data.tar.gz: '092323c5f9888b9f1878c56652917284594fbfaf2a248665ab71fbab769a3831aba1e9d21340708613f8f79edae16b77fd43cda807f249bfb42b8b2768a73997'
data/.gitignore CHANGED
@@ -17,3 +17,4 @@ log/*
17
17
  .dotest*
18
18
  Thumbs.db
19
19
  .tmp*
20
+ *.gem
data/Gemfile CHANGED
@@ -1,5 +1,8 @@
1
1
  source "http://rubygems.org"
2
2
 
3
+ gem 'rails', '5.1.4'
4
+ gem 'puma', '~> 3.7'
5
+
3
6
  # Declare your gem's dependencies in will_filter.gemspec.
4
7
  gemspec
5
8
 
@@ -10,6 +13,8 @@ gem 'jquery-ui-rails'
10
13
  gem 'bootstrap-sass'
11
14
  gem 'kaminari'
12
15
 
16
+ gem 'bootstrap-sass'
17
+
13
18
  group :development do
14
19
  gem 'rspec'
15
20
  gem 'rspec-rails'
@@ -21,8 +26,8 @@ group :development do
21
26
  end
22
27
 
23
28
  group :assets do
24
- gem 'sass-rails', '~> 3.2.3'
25
- gem 'coffee-rails', '~> 3.2.1'
26
- gem 'uglifier', '>= 1.0.3'
29
+ gem 'sass-rails'
30
+ gem 'coffee-rails'
31
+ gem 'uglifier'
27
32
  end
28
33
 
data/Gemfile.lock CHANGED
@@ -1,143 +1,193 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- will_filter (3.1.9)
5
- kaminari
6
- rails (>= 3.2.3)
7
- sass
4
+ will_filter (5.1.0)
5
+ kaminari (~> 1.1)
6
+ rails (~> 5.1)
7
+ sass (~> 3.5)
8
8
 
9
9
  GEM
10
10
  remote: http://rubygems.org/
11
11
  specs:
12
- actionmailer (3.2.3)
13
- actionpack (= 3.2.3)
14
- mail (~> 2.4.4)
15
- actionpack (3.2.3)
16
- activemodel (= 3.2.3)
17
- activesupport (= 3.2.3)
18
- builder (~> 3.0.0)
19
- erubis (~> 2.7.0)
20
- journey (~> 1.0.1)
21
- rack (~> 1.4.0)
22
- rack-cache (~> 1.2)
23
- rack-test (~> 0.6.1)
24
- sprockets (~> 2.1.2)
25
- activemodel (3.2.3)
26
- activesupport (= 3.2.3)
27
- builder (~> 3.0.0)
28
- activerecord (3.2.3)
29
- activemodel (= 3.2.3)
30
- activesupport (= 3.2.3)
31
- arel (~> 3.0.2)
32
- tzinfo (~> 0.3.29)
33
- activeresource (3.2.3)
34
- activemodel (= 3.2.3)
35
- activesupport (= 3.2.3)
36
- activesupport (3.2.3)
37
- i18n (~> 0.6)
38
- multi_json (~> 1.0)
39
- arel (3.0.2)
40
- bootstrap-sass (2.1.1.0)
41
- builder (3.0.0)
42
- coderay (1.0.6)
43
- coffee-rails (3.2.2)
12
+ actioncable (5.1.4)
13
+ actionpack (= 5.1.4)
14
+ nio4r (~> 2.0)
15
+ websocket-driver (~> 0.6.1)
16
+ actionmailer (5.1.4)
17
+ actionpack (= 5.1.4)
18
+ actionview (= 5.1.4)
19
+ activejob (= 5.1.4)
20
+ mail (~> 2.5, >= 2.5.4)
21
+ rails-dom-testing (~> 2.0)
22
+ actionpack (5.1.4)
23
+ actionview (= 5.1.4)
24
+ activesupport (= 5.1.4)
25
+ rack (~> 2.0)
26
+ rack-test (>= 0.6.3)
27
+ rails-dom-testing (~> 2.0)
28
+ rails-html-sanitizer (~> 1.0, >= 1.0.2)
29
+ actionview (5.1.4)
30
+ activesupport (= 5.1.4)
31
+ builder (~> 3.1)
32
+ erubi (~> 1.4)
33
+ rails-dom-testing (~> 2.0)
34
+ rails-html-sanitizer (~> 1.0, >= 1.0.3)
35
+ activejob (5.1.4)
36
+ activesupport (= 5.1.4)
37
+ globalid (>= 0.3.6)
38
+ activemodel (5.1.4)
39
+ activesupport (= 5.1.4)
40
+ activerecord (5.1.4)
41
+ activemodel (= 5.1.4)
42
+ activesupport (= 5.1.4)
43
+ arel (~> 8.0)
44
+ activesupport (5.1.4)
45
+ concurrent-ruby (~> 1.0, >= 1.0.2)
46
+ i18n (~> 0.7)
47
+ minitest (~> 5.1)
48
+ tzinfo (~> 1.1)
49
+ arel (8.0.0)
50
+ autoprefixer-rails (7.1.6)
51
+ execjs
52
+ bootstrap-sass (3.3.7)
53
+ autoprefixer-rails (>= 5.2.1)
54
+ sass (>= 3.3.4)
55
+ builder (3.2.3)
56
+ coderay (1.1.2)
57
+ coffee-rails (4.2.2)
44
58
  coffee-script (>= 2.2.0)
45
- railties (~> 3.2.0)
46
- coffee-script (2.2.0)
59
+ railties (>= 4.0.0)
60
+ coffee-script (2.4.1)
47
61
  coffee-script-source
48
62
  execjs
49
- coffee-script-source (1.6.3)
50
- diff-lcs (1.1.3)
51
- erubis (2.7.0)
52
- execjs (1.4.0)
53
- multi_json (~> 1.0)
54
- hike (1.2.1)
55
- i18n (0.6.0)
56
- journey (1.0.3)
57
- jquery-rails (3.0.4)
58
- railties (>= 3.0, < 5.0)
63
+ coffee-script-source (1.12.2)
64
+ concurrent-ruby (1.0.5)
65
+ crass (1.0.2)
66
+ diff-lcs (1.3)
67
+ erubi (1.7.0)
68
+ execjs (2.7.0)
69
+ ffi (1.9.18)
70
+ globalid (0.4.1)
71
+ activesupport (>= 4.2.0)
72
+ i18n (0.9.1)
73
+ concurrent-ruby (~> 1.0)
74
+ jquery-rails (4.3.1)
75
+ rails-dom-testing (>= 1, < 3)
76
+ railties (>= 4.2.0)
59
77
  thor (>= 0.14, < 2.0)
60
- jquery-ui-rails (4.0.2)
61
- jquery-rails
62
- railties (>= 3.1.0)
63
- json (1.6.6)
64
- kaminari (0.13.0)
65
- actionpack (>= 3.0.0)
66
- activesupport (>= 3.0.0)
67
- railties (>= 3.0.0)
68
- mail (2.4.4)
69
- i18n (>= 0.4.0)
70
- mime-types (~> 1.16)
71
- treetop (~> 1.4.8)
72
- method_source (0.7.1)
73
- mime-types (1.18)
74
- multi_json (1.3.2)
75
- polyglot (0.3.3)
76
- pry (0.9.9)
77
- coderay (~> 1.0.5)
78
- method_source (~> 0.7.1)
79
- slop (>= 2.4.4, < 3)
80
- rack (1.4.1)
81
- rack-cache (1.2)
82
- rack (>= 0.4)
83
- rack-ssl (1.3.2)
84
- rack
85
- rack-test (0.6.1)
86
- rack (>= 1.0)
87
- rails (3.2.3)
88
- actionmailer (= 3.2.3)
89
- actionpack (= 3.2.3)
90
- activerecord (= 3.2.3)
91
- activeresource (= 3.2.3)
92
- activesupport (= 3.2.3)
93
- bundler (~> 1.0)
94
- railties (= 3.2.3)
95
- railties (3.2.3)
96
- actionpack (= 3.2.3)
97
- activesupport (= 3.2.3)
98
- rack-ssl (~> 1.3.2)
78
+ jquery-ui-rails (6.0.1)
79
+ railties (>= 3.2.16)
80
+ kaminari (1.1.1)
81
+ activesupport (>= 4.1.0)
82
+ kaminari-actionview (= 1.1.1)
83
+ kaminari-activerecord (= 1.1.1)
84
+ kaminari-core (= 1.1.1)
85
+ kaminari-actionview (1.1.1)
86
+ actionview
87
+ kaminari-core (= 1.1.1)
88
+ kaminari-activerecord (1.1.1)
89
+ activerecord
90
+ kaminari-core (= 1.1.1)
91
+ kaminari-core (1.1.1)
92
+ loofah (2.1.1)
93
+ crass (~> 1.0.2)
94
+ nokogiri (>= 1.5.9)
95
+ mail (2.7.0)
96
+ mini_mime (>= 0.1.1)
97
+ method_source (0.9.0)
98
+ mini_mime (0.1.4)
99
+ mini_portile2 (2.3.0)
100
+ minitest (5.10.3)
101
+ nio4r (2.1.0)
102
+ nokogiri (1.8.1)
103
+ mini_portile2 (~> 2.3.0)
104
+ pry (0.11.2)
105
+ coderay (~> 1.1.0)
106
+ method_source (~> 0.9.0)
107
+ puma (3.10.0)
108
+ rack (2.0.3)
109
+ rack-test (0.7.0)
110
+ rack (>= 1.0, < 3)
111
+ rails (5.1.4)
112
+ actioncable (= 5.1.4)
113
+ actionmailer (= 5.1.4)
114
+ actionpack (= 5.1.4)
115
+ actionview (= 5.1.4)
116
+ activejob (= 5.1.4)
117
+ activemodel (= 5.1.4)
118
+ activerecord (= 5.1.4)
119
+ activesupport (= 5.1.4)
120
+ bundler (>= 1.3.0)
121
+ railties (= 5.1.4)
122
+ sprockets-rails (>= 2.0.0)
123
+ rails-dom-testing (2.0.3)
124
+ activesupport (>= 4.2.0)
125
+ nokogiri (>= 1.6)
126
+ rails-html-sanitizer (1.0.3)
127
+ loofah (~> 2.0)
128
+ railties (5.1.4)
129
+ actionpack (= 5.1.4)
130
+ activesupport (= 5.1.4)
131
+ method_source
99
132
  rake (>= 0.8.7)
100
- rdoc (~> 3.4)
101
- thor (~> 0.14.6)
102
- rake (0.9.2.2)
103
- rdoc (3.12)
104
- json (~> 1.4)
105
- rr (1.0.4)
106
- rspec (2.9.0)
107
- rspec-core (~> 2.9.0)
108
- rspec-expectations (~> 2.9.0)
109
- rspec-mocks (~> 2.9.0)
110
- rspec-core (2.9.0)
111
- rspec-expectations (2.9.1)
112
- diff-lcs (~> 1.1.3)
113
- rspec-mocks (2.9.0)
114
- rspec-rails (2.9.0)
133
+ thor (>= 0.18.1, < 2.0)
134
+ rake (12.2.1)
135
+ rb-fsevent (0.10.2)
136
+ rb-inotify (0.9.10)
137
+ ffi (>= 0.5.0, < 2)
138
+ rr (1.2.1)
139
+ rspec (3.7.0)
140
+ rspec-core (~> 3.7.0)
141
+ rspec-expectations (~> 3.7.0)
142
+ rspec-mocks (~> 3.7.0)
143
+ rspec-core (3.7.0)
144
+ rspec-support (~> 3.7.0)
145
+ rspec-expectations (3.7.0)
146
+ diff-lcs (>= 1.2.0, < 2.0)
147
+ rspec-support (~> 3.7.0)
148
+ rspec-mocks (3.7.0)
149
+ diff-lcs (>= 1.2.0, < 2.0)
150
+ rspec-support (~> 3.7.0)
151
+ rspec-rails (3.7.1)
115
152
  actionpack (>= 3.0)
116
153
  activesupport (>= 3.0)
117
154
  railties (>= 3.0)
118
- rspec (~> 2.9.0)
119
- sass (3.1.15)
120
- sass-rails (3.2.6)
121
- railties (~> 3.2.0)
122
- sass (>= 3.1.10)
123
- tilt (~> 1.3)
124
- slop (2.4.4)
125
- spork (0.9.0)
126
- sprockets (2.1.2)
127
- hike (~> 1.2)
128
- rack (~> 1.0)
129
- tilt (~> 1.1, != 1.3.0)
130
- sqlite3 (1.3.6)
131
- thor (0.14.6)
132
- tilt (1.3.3)
133
- treetop (1.4.10)
134
- polyglot
135
- polyglot (>= 0.3.1)
136
- tzinfo (0.3.33)
137
- uglifier (2.1.2)
138
- execjs (>= 0.3.0)
139
- multi_json (~> 1.0, >= 1.0.2)
155
+ rspec-core (~> 3.7.0)
156
+ rspec-expectations (~> 3.7.0)
157
+ rspec-mocks (~> 3.7.0)
158
+ rspec-support (~> 3.7.0)
159
+ rspec-support (3.7.0)
160
+ sass (3.5.3)
161
+ sass-listen (~> 4.0.0)
162
+ sass-listen (4.0.0)
163
+ rb-fsevent (~> 0.9, >= 0.9.4)
164
+ rb-inotify (~> 0.9, >= 0.9.7)
165
+ sass-rails (5.0.6)
166
+ railties (>= 4.0.0, < 6)
167
+ sass (~> 3.1)
168
+ sprockets (>= 2.8, < 4.0)
169
+ sprockets-rails (>= 2.0, < 4.0)
170
+ tilt (>= 1.1, < 3)
171
+ spork (0.9.2)
172
+ sprockets (3.7.1)
173
+ concurrent-ruby (~> 1.0)
174
+ rack (> 1, < 3)
175
+ sprockets-rails (3.2.1)
176
+ actionpack (>= 4.0)
177
+ activesupport (>= 4.0)
178
+ sprockets (>= 3.0.0)
179
+ sqlite3 (1.3.13)
180
+ thor (0.20.0)
181
+ thread_safe (0.3.6)
182
+ tilt (2.0.8)
183
+ tzinfo (1.2.4)
184
+ thread_safe (~> 0.1)
185
+ uglifier (3.2.0)
186
+ execjs (>= 0.3.0, < 3)
140
187
  watchr (0.7)
188
+ websocket-driver (0.6.5)
189
+ websocket-extensions (>= 0.1.0)
190
+ websocket-extensions (0.1.2)
141
191
 
142
192
  PLATFORMS
143
193
  ruby
@@ -145,17 +195,22 @@ PLATFORMS
145
195
  DEPENDENCIES
146
196
  bootstrap-sass
147
197
  bundler (>= 1.0.0)
148
- coffee-rails (~> 3.2.1)
198
+ coffee-rails
149
199
  jquery-rails
150
200
  jquery-ui-rails
151
201
  kaminari
152
202
  pry
203
+ puma (~> 3.7)
204
+ rails (= 5.1.4)
153
205
  rr
154
206
  rspec
155
207
  rspec-rails
156
- sass-rails (~> 3.2.3)
208
+ sass-rails
157
209
  spork
158
210
  sqlite3
159
- uglifier (>= 1.0.3)
211
+ uglifier
160
212
  watchr
161
213
  will_filter!
214
+
215
+ BUNDLED WITH
216
+ 1.15.3
data/README.rdoc CHANGED
@@ -12,7 +12,7 @@ a matter of adding two lines of code - one to your controller and one to your vi
12
12
 
13
13
  Add the following gems to your Gemfile:
14
14
 
15
- gem 'will_filter', "~> 3.1.0"
15
+ gem 'will_filter'
16
16
  gem 'kaminari'
17
17
 
18
18
  And run:
@@ -65,15 +65,6 @@ Please read the following document to learn more about table tag customization:
65
65
  https://github.com/berk/will_filter/wiki/Customizing-Table-View
66
66
 
67
67
 
68
- = Screenshots
69
-
70
- Below are a couple of screenshot of what the filter looks like when it is rendered on a page:
71
-
72
- http://wiki.tr8n.org/images/e/e1/Wf1.png
73
-
74
- http://wiki.tr8n.org/images/5/50/Wf2.png
75
-
76
-
77
68
  = Dummy Application
78
69
 
79
70
  This plugin comes with a dummy test project. To try out some of the examples, run the following commands:
@@ -1,568 +1,577 @@
1
1
  /****************************************************************************
2
- # Copyright (c) 2010-2012 Michael Berkovich
3
-
4
- Permission is hereby granted, free of charge, to any person obtaining
5
- a copy of this software and associated documentation files (the
6
- "Software"), to deal in the Software without restriction, including
7
- without limitation the rights to use, copy, modify, merge, publish,
8
- distribute, sublicense, and/or sell copies of the Software, and to
9
- permit persons to whom the Software is furnished to do so, subject to
10
- the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be
13
- included in all copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
- ****************************************************************************/
2
+ # Copyright (c) 2010-2012 Michael Berkovich
3
+
4
+ Permission is hereby granted, free of charge, to any person obtaining
5
+ a copy of this software and associated documentation files (the
6
+ "Software"), to deal in the Software without restriction, including
7
+ without limitation the rights to use, copy, modify, merge, publish,
8
+ distribute, sublicense, and/or sell copies of the Software, and to
9
+ permit persons to whom the Software is furnished to do so, subject to
10
+ the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be
13
+ included in all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
+ ****************************************************************************/
23
23
 
24
24
  /****************************************************************************
25
- **** Generic Helper Functions
26
- ****************************************************************************/
25
+ **** Generic Helper Functions
26
+ ****************************************************************************/
27
27
 
28
28
  var Wf = Wf || {
29
- element:function(element_id) {
30
- if (typeof element_id == 'string') return document.getElementById(element_id);
31
- return element_id;
32
- },
33
- value:function(element_id) {
34
- return Wf.element(element_id).value;
35
- },
36
- hide: function(element_id) {
37
- Wf.element(element_id).style.display = "none";
38
- },
39
- visible: function(element_id) {
40
- return (Wf.element(element_id).style.display != "none");
41
- },
42
- hidden: function(element_id) {
43
- return (!Wf.visible(element_id));
44
- },
45
- show: function(element_id) {
46
- var style = (Wf.element(element_id).tagName == "SPAN") ? "inline" : "block";
47
- Wf.element(element_id).style.display = style;
48
- },
49
- submit: function(element_id) {
50
- Wf.element(element_id).submit();
51
- },
52
- focus: function(element_id) {
53
- Wf.element(element_id).focus();
54
- },
55
- scrollTo: function(element_id) {
56
- var theElement = Wf.element(element_id);
57
- var selectedPosX = 0;
58
- var selectedPosY = 0;
59
- while(theElement != null){
60
- selectedPosX += theElement.offsetLeft;
61
- selectedPosY += theElement.offsetTop;
62
- theElement = theElement.offsetParent;
63
- }
64
- window.scrollTo(selectedPosX,selectedPosY);
65
- }
66
- };
29
+ element: function (element_id) {
30
+ if (typeof element_id == 'string') return document.getElementById(element_id);
31
+ return element_id;
32
+ },
33
+ value: function (element_id) {
34
+ return Wf.element(element_id).value;
35
+ },
36
+ hide: function (element_id) {
37
+ Wf.element(element_id).style.display = "none";
38
+ },
39
+ visible: function (element_id) {
40
+ return (Wf.element(element_id).style.display != "none");
41
+ },
42
+ hidden: function (element_id) {
43
+ return (!Wf.visible(element_id));
44
+ },
45
+ show: function (element_id) {
46
+ var style = (Wf.element(element_id).tagName == "SPAN") ? "inline" : "block";
47
+ Wf.element(element_id).style.display = style;
48
+ },
49
+ submit: function (element_id) {
50
+ Wf.element(element_id).submit();
51
+ },
52
+ focus: function (element_id) {
53
+ Wf.element(element_id).focus();
54
+ },
55
+ scrollTo: function (element_id) {
56
+ var theElement = Wf.element(element_id);
57
+ var selectedPosX = 0;
58
+ var selectedPosY = 0;
59
+ while (theElement != null) {
60
+ selectedPosX += theElement.offsetLeft;
61
+ selectedPosY += theElement.offsetTop;
62
+ theElement = theElement.offsetParent;
63
+ }
64
+ window.scrollTo(selectedPosX, selectedPosY);
65
+ }
66
+ };
67
67
 
68
68
  /****************************************************************************
69
- **** Effects Functions
70
- **** The functions can be overloaded using a specific framework
71
- ****************************************************************************/
69
+ **** Effects Functions
70
+ **** The functions can be overloaded using a specific framework
71
+ ****************************************************************************/
72
72
  Wf.Effects = {
73
- blindUp: function(element_id) {
74
- Wf.hide(element_id);
75
- },
76
- blindDown: function(element_id) {
77
- Wf.show(element_id);
78
- },
79
- appear: function(element_id) {
80
- Wf.show(element_id);
81
- },
82
- fade: function(element_id) {
83
- Wf.hide(element_id);
84
- },
73
+ blindUp: function (element_id) {
74
+ Wf.hide(element_id);
75
+ },
76
+ blindDown: function (element_id) {
77
+ Wf.show(element_id);
78
+ },
79
+ appear: function (element_id) {
80
+ Wf.show(element_id);
81
+ },
82
+ fade: function (element_id) {
83
+ Wf.hide(element_id);
84
+ },
85
85
  };
86
86
 
87
87
  /****************************************************************************
88
- **** Filter Container
89
- ****************************************************************************/
88
+ **** Filter Container
89
+ ****************************************************************************/
90
90
 
91
- Wf.Filter = function(options){
92
- var self = this;
93
- this.original_form_action = null;
91
+ Wf.Filter = function (options) {
92
+ var self = this;
93
+ this.original_form_action = "";
94
94
  }
95
95
 
96
96
  Wf.Filter.prototype = {
97
- showSpinner: function() {
98
- Wf.show("wf_loader");
99
- },
100
- hideSpinner: function() {
101
- Wf.hide("wf_loader");
102
- },
103
- toggleDebugger: function() {
104
- if (Wf.visible("wf_debugger")) {
105
- new Wf.Effects.blindUp("wf_debugger");
106
- } else {
107
- new Wf.Effects.blindDown("wf_debugger");
108
- }
109
- },
110
- markDirty: function() {
111
- if (Wf.element("wf_key") && Wf.value("wf_id") == "") {
112
- Wf.element("wf_key").value = "";
113
- }
114
- },
115
- fieldChanged: function(fld) {
116
- Wf.element(fld).style.border = "1px solid red";
117
- this.markDirty();
118
- },
119
- saveFilter: function() {
120
- var filter_name = prompt("Please provide a name for the new filter:", "");
121
- if (filter_name == null) return;
122
- Wf.element("wf_name").value = filter_name;
123
- this.showSpinner();
124
- this.updateFilterConditions('save_filter', Wf.Utils.serializeForm('wf_form'));
125
- },
126
- updateFilter: function() {
127
- var filter_name = prompt("Please provide a name for this filter:", Wf.value("wf_name"));
128
- if (filter_name == null) return;
129
- Wf.element("wf_name").value = filter_name;
130
- this.showSpinner();
131
- this.updateFilterConditions('update_filter', Wf.Utils.serializeForm('wf_form'));
132
- },
133
- deleteFilter: function() {
134
- if (!confirm("Are you sure you want to delete this filter?")) return;
135
- this.showSpinner();
136
- this.updateFilterConditions('delete_filter', Wf.Utils.serializeForm('wf_form'));
137
- },
138
- updateConditionAt: function(index) {
139
- this.showSpinner();
140
- this.markDirty();
141
- var data_hash = Wf.Utils.serializeForm('wf_form');
142
- data_hash["at_index"] = index;
143
- this.updateFilterConditions('update_condition', data_hash);
144
- },
145
- removeConditionAt: function(index) {
146
- this.showSpinner();
147
- this.markDirty();
148
- var data_hash = Wf.Utils.serializeForm('wf_form');
149
- data_hash["at_index"] = index;
150
- this.updateFilterConditions('remove_condition', data_hash);
151
- },
152
- removeAllConditions: function() {
153
- this.showSpinner();
154
- this.markDirty();
155
- this.updateFilterConditions('remove_all_conditions', Wf.Utils.serializeForm('wf_form'));
156
- },
157
- addCondition: function() {
158
- this.addConditionAfter(-1);
159
- },
160
- addConditionAfter: function(index) {
161
- this.showSpinner();
162
- this.markDirty();
163
- var data_hash = Wf.Utils.serializeForm('wf_form');
164
- data_hash["after_index"] = index;
165
- this.updateFilterConditions('add_condition', data_hash);
166
- },
167
- updateFilterConditions: function(action, data_hash) {
168
- Wf.Utils.update('wf_filter_conditions', '/will_filter/filter/' + action, {
169
- parameters: data_hash,
170
- evalScripts: true,
171
- onComplete: function(transport) {
172
- wfFilter.hideSpinner();
173
- }
174
- });
175
- },
176
- loadSavedFilter: function() {
177
- if (Wf.value("wf_key") == "-1" || Wf.value("wf_key") == "-2")
178
- return;
179
-
180
- this.showSpinner();
181
- var data_hash = Wf.Utils.serializeForm('wf_form');
182
-
183
- Wf.Utils.update('wf_filter_conditions', '/will_filter/filter/load_filter', {
184
- parameters: data_hash,
185
- evalScripts: true,
186
- onComplete: function(transport) {
187
- wfFilter.submit();
188
- }
189
- });
190
- },
191
- submit: function() {
192
- if (this.original_form_action != "")
193
- Wf.element('wf_form').action = this.original_form_action;
194
-
195
- Wf.element('wf_submitted').value = 'true';
196
- Wf.submit('wf_form');
197
- }
97
+ showSpinner: function () {
98
+ Wf.show("wf_loader");
99
+ },
100
+ hideSpinner: function () {
101
+ Wf.hide("wf_loader");
102
+ },
103
+ toggleDebugger: function () {
104
+ if (Wf.visible("wf_debugger")) {
105
+ new Wf.Effects.blindUp("wf_debugger");
106
+ } else {
107
+ new Wf.Effects.blindDown("wf_debugger");
108
+ }
109
+ },
110
+ markDirty: function () {
111
+ if (Wf.element("wf_key") && Wf.value("wf_id") == "") {
112
+ Wf.element("wf_key").value = "";
113
+ }
114
+ },
115
+ fieldChanged: function (fld) {
116
+ Wf.element(fld).style.border = "1px solid red";
117
+ this.markDirty();
118
+ },
119
+ saveFilter: function () {
120
+ var filter_name = prompt("Please provide a name for the new filter:", "");
121
+ if (filter_name == null) return;
122
+ Wf.element("wf_name").value = filter_name;
123
+ this.showSpinner();
124
+ this.updateFilterConditions('save_filter', Wf.Utils.serializeForm('wf_form'));
125
+ },
126
+ updateFilter: function () {
127
+ var filter_name = prompt("Please provide a name for this filter:", Wf.value("wf_name"));
128
+ if (filter_name == null) return;
129
+ Wf.element("wf_name").value = filter_name;
130
+ this.showSpinner();
131
+ this.updateFilterConditions('update_filter', Wf.Utils.serializeForm('wf_form'));
132
+ },
133
+ deleteFilter: function () {
134
+ if (!confirm("Are you sure you want to delete this filter?")) return;
135
+ this.showSpinner();
136
+ this.updateFilterConditions('delete_filter', Wf.Utils.serializeForm('wf_form'));
137
+ },
138
+ updateConditionAt: function (index) {
139
+ this.showSpinner();
140
+ this.markDirty();
141
+ var data_hash = Wf.Utils.serializeForm('wf_form');
142
+ data_hash["at_index"] = index;
143
+ this.updateFilterConditions('update_condition', data_hash);
144
+ },
145
+ removeConditionAt: function (index) {
146
+ this.showSpinner();
147
+ this.markDirty();
148
+ var data_hash = Wf.Utils.serializeForm('wf_form');
149
+ data_hash["at_index"] = index;
150
+ this.updateFilterConditions('remove_condition', data_hash);
151
+ },
152
+ removeAllConditions: function () {
153
+ this.showSpinner();
154
+ this.markDirty();
155
+ this.updateFilterConditions('remove_all_conditions', Wf.Utils.serializeForm('wf_form'));
156
+ },
157
+ addCondition: function () {
158
+ this.addConditionAfter(-1);
159
+ },
160
+ addConditionAfter: function (index) {
161
+ this.showSpinner();
162
+ this.markDirty();
163
+ var data_hash = Wf.Utils.serializeForm('wf_form');
164
+ data_hash["after_index"] = index;
165
+ this.updateFilterConditions('add_condition', data_hash);
166
+ },
167
+ updateFilterConditions: function (action, data_hash) {
168
+ Wf.Utils.update('wf_filter_conditions', '/will_filter/filter/' + action, {
169
+ parameters: data_hash,
170
+ evalScripts: true,
171
+ onComplete: function (transport) {
172
+ wfFilter.hideSpinner();
173
+ }
174
+ });
175
+ },
176
+ loadSavedFilter: function () {
177
+ if (Wf.value("wf_key") == "-1" || Wf.value("wf_key") == "-2")
178
+ return;
179
+
180
+ this.showSpinner();
181
+ var data_hash = Wf.Utils.serializeForm('wf_form');
182
+
183
+ Wf.Utils.update('wf_filter_conditions', '/will_filter/filter/load_filter', {
184
+ parameters: data_hash,
185
+ evalScripts: true,
186
+ onComplete: function (transport) {
187
+ wfFilter.submit();
188
+ }
189
+ });
190
+ },
191
+ submit: function () {
192
+ this.showSpinner();
193
+
194
+ if (this.original_form_action != "")
195
+ Wf.element('wf_form').action = this.original_form_action;
196
+
197
+ Wf.element('wf_submitted').value = 'true';
198
+ Wf.submit('wf_form');
199
+ }
198
200
  };
199
201
 
200
202
  /****************************************************************************
201
- **** Filter Calendar
202
- ****************************************************************************/
203
+ **** Filter Calendar
204
+ ****************************************************************************/
203
205
 
204
- Wf.Calendar = function(options) {
205
- this.options = options || {};
206
- this.trigger = null;
207
- this.last_selected_cell = null;
208
- this.selected_field_id = null;
206
+ Wf.Calendar = function (options) {
207
+ this.options = options || {};
208
+ this.trigger = null;
209
+ this.last_selected_cell = null;
210
+ this.selected_field_id = null;
209
211
 
210
- this.container = document.createElement('div');
211
- this.container.className = 'wf_calendar';
212
- this.container.id = 'wf_calendar';
213
- this.container.style.display = "none";
212
+ this.container = document.createElement('div');
213
+ this.container.className = 'wf_calendar';
214
+ this.container.id = 'wf_calendar';
215
+ this.container.style.display = "none";
214
216
 
215
- document.body.appendChild(this.container);
216
- }
217
+ document.body.appendChild(this.container);
218
+ };
217
219
 
218
220
  Wf.Calendar.prototype = {
219
- show: function(fld_id, trigger, show_time) {
220
- if (this.selected_field_id == fld_id) {
221
- this.hide();
222
- return;
223
- }
221
+ show: function (fld_id, trigger, show_time) {
222
+ if (this.selected_field_id == fld_id) {
223
+ this.hide();
224
+ return;
225
+ }
224
226
 
225
- this.trigger = trigger;
226
-
227
- var form_hash = {};
228
- form_hash["wf_calendar_selected_date"] = Wf.value(fld_id);
229
- form_hash["wf_calendar_show_time"] = show_time;
230
-
231
- this.selected_field_id = fld_id;
232
- Wf.Utils.update('wf_calendar', '/will_filter/calendar', {
233
- parameters: form_hash,
234
- onComplete: function(transport) {
235
- var trigger_position = Wf.Utils.cumulativeOffset(wfCalendar.trigger);
236
- var calendar_container = Wf.element("wf_calendar");
237
- calendar_container.style.left = (trigger_position[0] - 273) + "px";
238
- calendar_container.style.top = trigger_position[1] - 38 + "px";
239
- calendar_container.style.width = "260px";
240
- Wf.Effects.appear("wf_calendar");
241
- }
242
- });
243
- },
244
- selectDate: function(fld_id, trigger){
245
- this.show(fld_id, trigger, false);
246
- },
247
- selectDateTime: function(fld_id, trigger){
248
- this.show(fld_id, trigger, true);
249
- },
250
- changeMode: function(mode) {
251
- var form_hash = Wf.Utils.serializeForm('wf_calendar_form');
252
- form_hash["wf_calendar_mode"] = mode;
253
-
254
- if (mode == 'annual')
255
- form_hash["wf_calendar_start_date"] = Wf.value("wf_calendar_year") + "-01-01";
256
-
257
- Wf.Utils.update('wf_calendar', '/will_filter/calendar', {
258
- parameters: form_hash,
259
- onComplete: function(transport) {
260
- var trigger_position = Wf.Utils.cumulativeOffset(wfCalendar.trigger);
261
- var width = (mode=='annual' ? 760 : 400);
262
- var calendar_container = Wf.element("wf_calendar");
263
- calendar_container.style.left = (trigger_position[0] - width - 13) + "px";
264
- calendar_container.style.top = trigger_position[1] - 38 + "px";
265
- calendar_container.style.width = width + "px";
266
- }
267
- });
268
- },
269
- goToStartDate: function(start_date) {
270
- var form_hash = Wf.Utils.serializeForm('wf_calendar_form');
271
- if (start_date == '')
272
- form_hash["wf_calendar_start_date"] = Wf.value("wf_calendar_year") + "-" + Wf.value("wf_calendar_month") + "-01";
273
- else
274
- form_hash["wf_calendar_start_date"] = start_date;
275
-
276
- Wf.Utils.update('wf_calendar', '/will_filter/calendar', {
277
- parameters: form_hash
278
- });
279
- },
280
- setSelectedFieldValue: function(value) {
281
- if (this.selected_field_id==null || Wf.element(this.selected_field_id)==null)
282
- return;
283
- Wf.element(this.selected_field_id).value = value;
284
- wfFilter.fieldChanged(this.selected_field_id);
285
- this.selected_field_id = null;
286
- },
287
- selectDateValue: function(elem_id, date) {
288
- if (this.last_selected_cell)
289
- Wf.Utils.removeClassName(Wf.element(this.last_selected_cell), "selected");
290
-
291
- Wf.Utils.addClassName(Wf.element(elem_id), 'selected');
292
- this.last_selected_cell = elem_id;
293
-
294
- Wf.element("wf_calendar_selected_date").value = date;
295
- },
296
- setDate: function() {
297
- this.setSelectedFieldValue(Wf.value("wf_calendar_selected_date"));
298
- this.hide();
299
- },
300
- prepandZero: function(val) {
301
- if (parseInt(val) >= 10)
302
- return val;
303
-
304
- return ("0" + val);
305
- },
306
- setDateTime: function() {
307
- var val = Wf.value("wf_calendar_selected_date");
308
- val += " " + this.prepandZero(Wf.value("wf_calendar_hour"));
309
- val += ":" + this.prepandZero(Wf.value("wf_calendar_minute"));
310
- val += ":" + this.prepandZero(Wf.value("wf_calendar_second"));
311
-
312
- this.setSelectedFieldValue(val);
313
- this.hide();
314
- },
315
- hide: function() {
316
- this.selected_field_id = null;
317
- Wf.Effects.fade("wf_calendar");
318
- }
227
+ this.trigger = trigger;
228
+
229
+ var form_hash = {};
230
+ form_hash["wf_calendar_selected_date"] = Wf.value(fld_id);
231
+ form_hash["wf_calendar_show_time"] = show_time;
232
+
233
+ this.selected_field_id = fld_id;
234
+ Wf.Utils.update('wf_calendar', '/will_filter/calendar', {
235
+ parameters: form_hash,
236
+ onComplete: function (transport) {
237
+ var trigger_position = Wf.Utils.cumulativeOffset(wfCalendar.trigger);
238
+ var calendar_container = Wf.element("wf_calendar");
239
+ calendar_container.style.left = (trigger_position[0] - 273) + "px";
240
+ calendar_container.style.top = trigger_position[1] - 38 + "px";
241
+ calendar_container.style.width = "260px";
242
+ Wf.Effects.appear("wf_calendar");
243
+ }
244
+ });
245
+ },
246
+ selectDate: function (fld_id, trigger) {
247
+ this.show(fld_id, trigger, false);
248
+ },
249
+ selectDateTime: function (fld_id, trigger) {
250
+ this.show(fld_id, trigger, true);
251
+ },
252
+ changeMode: function (mode) {
253
+ var form_hash = Wf.Utils.serializeForm('wf_calendar_form');
254
+ form_hash["wf_calendar_mode"] = mode;
255
+
256
+ if (mode == 'annual')
257
+ form_hash["wf_calendar_start_date"] = Wf.value("wf_calendar_year") + "-01-01";
258
+
259
+ Wf.Utils.update('wf_calendar', '/will_filter/calendar', {
260
+ parameters: form_hash,
261
+ onComplete: function (transport) {
262
+ var trigger_position = Wf.Utils.cumulativeOffset(wfCalendar.trigger);
263
+ var width = (mode == 'annual' ? 900 : 500);
264
+ var calendar_container = Wf.element("wf_calendar");
265
+ calendar_container.style.left = (trigger_position[0] - width - 13) + "px";
266
+ calendar_container.style.top = trigger_position[1] - 38 + "px";
267
+ calendar_container.style.width = width + "px";
268
+ }
269
+ });
270
+ },
271
+ goToStartDate: function (start_date) {
272
+ var form_hash = Wf.Utils.serializeForm('wf_calendar_form');
273
+ if (start_date == '')
274
+ form_hash["wf_calendar_start_date"] = Wf.value("wf_calendar_year") + "-" + Wf.value("wf_calendar_month") + "-01";
275
+ else
276
+ form_hash["wf_calendar_start_date"] = start_date;
277
+
278
+ Wf.Utils.update('wf_calendar', '/will_filter/calendar', {
279
+ parameters: form_hash
280
+ });
281
+ },
282
+ setSelectedFieldValue: function (value) {
283
+ if (this.selected_field_id == null || Wf.element(this.selected_field_id) == null)
284
+ return;
285
+ Wf.element(this.selected_field_id).value = value;
286
+ wfFilter.fieldChanged(this.selected_field_id);
287
+ this.selected_field_id = null;
288
+ },
289
+ selectDateValue: function (elem_id, date) {
290
+ if (this.last_selected_cell)
291
+ Wf.Utils.removeClassName(Wf.element(this.last_selected_cell), "selected");
292
+
293
+ Wf.Utils.addClassName(Wf.element(elem_id), 'selected');
294
+ this.last_selected_cell = elem_id;
295
+
296
+ Wf.element("wf_calendar_selected_date").value = date;
297
+ },
298
+ setDate: function () {
299
+ this.setSelectedFieldValue(Wf.value("wf_calendar_selected_date"));
300
+ this.hide();
301
+ },
302
+ prepandZero: function (val) {
303
+ if (parseInt(val) >= 10)
304
+ return val;
305
+
306
+ return ("0" + val);
307
+ },
308
+ setDateTime: function () {
309
+ var val = Wf.value("wf_calendar_selected_date");
310
+ val += " " + this.prepandZero(Wf.value("wf_calendar_hour"));
311
+ val += ":" + this.prepandZero(Wf.value("wf_calendar_minute"));
312
+ val += ":" + this.prepandZero(Wf.value("wf_calendar_second"));
313
+
314
+ this.setSelectedFieldValue(val);
315
+ this.hide();
316
+ },
317
+ hide: function () {
318
+ this.selected_field_id = null;
319
+ Wf.Effects.fade("wf_calendar");
320
+ }
319
321
  };
320
322
 
321
323
  /****************************************************************************
322
- **** Filter Exporter
323
- ****************************************************************************/
324
-
325
- Wf.Exporter = function(options) {
326
- this.options = options || {};
327
-
328
- this.container = document.createElement('div');
329
- this.container.className = 'wf_exporter';
330
- this.container.id = 'wf_exporter';
331
- this.container.style.display = "none";
332
-
333
- document.body.appendChild(this.container);
334
- }
324
+ **** Filter Exporter
325
+ ****************************************************************************/
335
326
 
336
- Wf.Exporter.prototype = {
337
- show: function (trigger) {
338
- Wf.Utils.update('wf_exporter', '/will_filter/exporter', {
339
- parameters: Wf.Utils.serializeForm('wf_form'),
340
- onComplete: function(transport) {
341
- var trigger_position = Wf.Utils.cumulativeOffset(trigger);
342
- var exporter_container = Wf.element("wf_exporter");
343
- exporter_container.style.left = (trigger_position[0] - 240) + "px";
344
- exporter_container.style.top = (trigger_position[1] - 32) + "px";
345
- Wf.Effects.appear("wf_exporter");
346
- }
347
- });
348
- },
349
- hide: function() {
350
- Wf.Effects.fade("wf_exporter");
351
- },
352
- selectAllFields: function (fld) {
353
- var i = 0;
354
- var chkFld = Wf.element("wf_fld_chk_" + i);
355
- while (chkFld != null) {
356
- chkFld.checked = fld.checked;
357
- i++;
358
- chkFld = Wf.element("wf_fld_chk_" + i);
359
- }
360
- this.updateExportFields();
361
- },
362
- selectField: function (fld) {
363
- if (!fld.checked) {
364
- Wf.element("wf_fld_all").checked = false;
365
- }
366
- this.updateExportFields();
367
- },
368
- updateExportFields: function () {
369
- var i = 0;
370
- var chkFld = Wf.element("wf_fld_chk_" + i);
371
- var fields = "";
372
- while (chkFld != null) {
373
- if (chkFld.checked) {
374
- if (fields != "") fields += ",";
375
- fields += Wf.value("wf_fld_name_" + i);
376
- }
377
- i++;
378
- chkFld = Wf.element("wf_fld_chk_" + i);
379
- }
380
-
381
- Wf.element("wf_export_fields").value = fields;
382
- },
383
- exportFilter: function() {
384
- if (wfFilter.original_form_action == "")
385
- wfFilter.original_form_action = Wf.element('wf_form').action;
386
-
387
- this.updateExportFields();
388
-
389
- if (Wf.value("wf_export_fields") == "") {
390
- alert("Please select st least one field to export");
391
- return;
392
- }
327
+ Wf.Exporter = function (options) {
328
+ this.options = options || {};
393
329
 
394
- if (Wf.value('wf_export_format_selector') == "-1") {
395
- alert("Please select an export format");
396
- return;
397
- }
330
+ this.container = document.createElement('div');
331
+ this.container.className = 'wf_exporter';
332
+ this.container.id = 'wf_exporter';
333
+ this.container.style.display = "none";
398
334
 
399
- Wf.element('wf_export_format').value = Wf.value('wf_export_format_selector');
400
- Wf.element('wf_form').action = '/will_filter/exporter/export';
401
- Wf.submit('wf_form');
402
- }
335
+ document.body.appendChild(this.container);
403
336
  };
404
337
 
338
+ Wf.Exporter.prototype = {
339
+ show: function (trigger) {
340
+ Wf.Utils.update('wf_exporter', '/will_filter/exporter', {
341
+ parameters: Wf.Utils.serializeForm('wf_form'),
342
+ onComplete: function (transport) {
343
+ var trigger_position = Wf.Utils.cumulativeOffset(trigger);
344
+ var exporter_container = Wf.element("wf_exporter");
345
+ exporter_container.style.left = (trigger_position[0] - 240) + "px";
346
+ exporter_container.style.top = (trigger_position[1] - 32) + "px";
347
+ Wf.Effects.appear("wf_exporter");
348
+ }
349
+ });
350
+ },
351
+ hide: function () {
352
+ Wf.Effects.fade("wf_exporter");
353
+ },
354
+ selectAllFields: function (fld) {
355
+ var i = 0;
356
+ var chkFld = Wf.element("wf_fld_chk_" + i);
357
+ while (chkFld != null) {
358
+ chkFld.checked = fld.checked;
359
+ i++;
360
+ chkFld = Wf.element("wf_fld_chk_" + i);
361
+ }
362
+ this.updateExportFields();
363
+ },
364
+ selectField: function (fld) {
365
+ if (!fld.checked) {
366
+ Wf.element("wf_fld_all").checked = false;
367
+ }
368
+ this.updateExportFields();
369
+ },
370
+ updateExportFields: function () {
371
+ var i = 0;
372
+ var chkFld = Wf.element("wf_fld_chk_" + i);
373
+ var fields = "";
374
+ while (chkFld != null) {
375
+ if (chkFld.checked) {
376
+ if (fields != "") fields += ",";
377
+ fields += Wf.value("wf_fld_name_" + i);
378
+ }
379
+ i++;
380
+ chkFld = Wf.element("wf_fld_chk_" + i);
381
+ }
382
+
383
+ Wf.element("wf_export_fields").value = fields;
384
+ },
385
+ exportFilter: function () {
386
+ if (wfFilter.original_form_action == "")
387
+ wfFilter.original_form_action = Wf.element('wf_form').action;
388
+
389
+ this.updateExportFields();
390
+
391
+ if (Wf.value("wf_export_fields") == "") {
392
+ alert("Please select st least one field to export");
393
+ return;
394
+ }
395
+
396
+ if (Wf.value('wf_export_format_selector') == "-1") {
397
+ alert("Please select an export format");
398
+ return;
399
+ }
400
+
401
+ Wf.element('wf_export_format').value = Wf.value('wf_export_format_selector');
402
+ Wf.element('wf_form').action = '/will_filter/exporter/export';
403
+ Wf.submit('wf_form');
404
+ }
405
+ };
405
406
 
406
407
 
407
408
  /****************************************************************************
408
- **** Utilities
409
- ****************************************************************************/
409
+ **** Utilities
410
+ ****************************************************************************/
410
411
 
411
412
  Wf.Utils = {
412
413
 
413
- addEvent: function(elm, evType, fn, useCapture) {
414
- useCapture = useCapture || false;
415
- if (elm.addEventListener) {
416
- elm.addEventListener(evType, fn, useCapture);
417
- return true;
418
- } else if (elm.attachEvent) {
419
- var r = elm.attachEvent('on' + evType, fn);
420
- return r;
421
- } else {
422
- elm['on' + evType] = fn;
423
- }
424
- },
425
-
426
- toQueryParams: function (obj) {
427
- if (typeof obj == 'undefined' || obj == null) return "";
428
- if (typeof obj == 'string') return obj;
429
-
430
- var qs = [];
431
- for(p in obj) {
432
- qs.push(p + "=" + encodeURIComponent(obj[p]))
433
- }
434
- return qs.join("&")
435
- },
436
-
437
- serializeForm: function(form) {
438
- var els = Wf.element(form).elements;
439
- var form_obj = {}
440
- for(i=0; i < els.length; i++) {
441
- if (els[i].type == 'checkbox' && !els[i].checked) continue;
442
- if (els[i].type == 'radio' && !els[i].checked) continue;
443
- form_obj[els[i].name] = els[i].value;
444
- }
445
- return form_obj;
446
- },
447
-
448
- getRequest: function() {
449
- var factories = [
450
- function() { return new ActiveXObject("Msxml2.XMLHTTP"); },
451
- function() { return new XMLHttpRequest(); },
452
- function() { return new ActiveXObject("Microsoft.XMLHTTP"); }
453
- ];
454
- for(var i = 0; i < factories.length; i++) {
455
- try {
456
- var request = factories[i]();
457
- if (request != null) return request;
458
- } catch(e) {continue;}
459
- }
460
- },
414
+ addEvent: function (elm, evType, fn, useCapture) {
415
+ useCapture = useCapture || false;
416
+ if (elm.addEventListener) {
417
+ elm.addEventListener(evType, fn, useCapture);
418
+ return true;
419
+ } else if (elm.attachEvent) {
420
+ var r = elm.attachEvent('on' + evType, fn);
421
+ return r;
422
+ } else {
423
+ elm['on' + evType] = fn;
424
+ }
425
+ },
461
426
 
462
- ajax: function(url, options) {
463
- options = options || {};
464
- options.parameters = Wf.Utils.toQueryParams(options.parameters);
465
- options.method = options.method || 'get';
427
+ toQueryParams: function (obj) {
428
+ if (typeof obj == 'undefined' || obj == null) return "";
429
+ if (typeof obj == 'string') return obj;
466
430
 
467
- var self=this;
468
- if (options.method == 'get' && options.parameters != '') {
469
- url = url + (url.indexOf('?') == -1 ? '?' : '&') + options.parameters;
470
- }
471
- var request = this.getRequest();
472
-
473
- request.onreadystatechange = function() {
474
- if(request.readyState == 4) {
475
- if (request.status == 200) {
476
- if(options.onSuccess) options.onSuccess(request);
477
- if(options.onComplete) options.onComplete(request);
478
- if(options.evalScripts) self.evalScripts(request.responseText);
431
+ var qs = [];
432
+ for (p in obj) {
433
+ qs.push(p + "=" + encodeURIComponent(obj[p]))
434
+ }
435
+ return qs.join("&")
436
+ },
437
+
438
+ serializeForm: function (form) {
439
+ var els = Wf.element(form).elements;
440
+ var form_obj = {}
441
+ for (i = 0; i < els.length; i++) {
442
+ if (els[i].type == 'checkbox' && !els[i].checked) continue;
443
+ if (els[i].type == 'radio' && !els[i].checked) continue;
444
+ form_obj[els[i].name] = els[i].value;
445
+ }
446
+ return form_obj;
447
+ },
448
+
449
+ getRequest: function () {
450
+ var factories = [
451
+ function () {
452
+ return new ActiveXObject("Msxml2.XMLHTTP");
453
+ },
454
+ function () {
455
+ return new XMLHttpRequest();
456
+ },
457
+ function () {
458
+ return new ActiveXObject("Microsoft.XMLHTTP");
459
+ }
460
+ ];
461
+ for (var i = 0; i < factories.length; i++) {
462
+ try {
463
+ var request = factories[i]();
464
+ if (request != null) return request;
465
+ } catch (e) {
466
+ continue;
467
+ }
468
+ }
469
+ },
470
+
471
+ ajax: function (url, options) {
472
+ options = options || {};
473
+ options.parameters = Wf.Utils.toQueryParams(options.parameters);
474
+ options.method = options.method || 'get';
475
+
476
+ var self = this;
477
+ if (options.method == 'get' && options.parameters != '') {
478
+ url = url + (url.indexOf('?') == -1 ? '?' : '&') + options.parameters;
479
+ }
480
+ var request = this.getRequest();
481
+
482
+ request.onreadystatechange = function () {
483
+ if (request.readyState == 4) {
484
+ if (request.status == 200) {
485
+ if (options.onSuccess) options.onSuccess(request);
486
+ if (options.onComplete) options.onComplete(request);
487
+ if (options.evalScripts) self.evalScripts(request.responseText);
488
+ } else {
489
+ if (options.onFailure) options.onFailure(request)
490
+ if (options.onComplete) options.onComplete(request)
491
+ }
492
+ }
493
+ }
494
+
495
+ request.open(options.method, url, true);
496
+ request.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
497
+ request.setRequestHeader('Accept', 'text/javascript, text/html, application/xml, text/xml, */*');
498
+ request.send(options.parameters);
499
+ },
500
+
501
+ update: function (element_id, url, options) {
502
+ options.onSuccess = function (response) {
503
+ Wf.element(element_id).innerHTML = response.responseText;
504
+ };
505
+ Wf.Utils.ajax(url, options);
506
+ },
507
+
508
+ evalScripts: function (html) {
509
+ var script_re = '<script[^>]*>([\\S\\s]*?)<\/script>';
510
+ var matchAll = new RegExp(script_re, 'img');
511
+ var matchOne = new RegExp(script_re, 'im');
512
+ var matches = html.match(matchAll) || [];
513
+ for (var i = 0, l = matches.length; i < l; i++) {
514
+ var script = (matches[i].match(matchOne) || ['', ''])[1];
515
+ // console.info(script)
516
+ // alert(script);
517
+ eval(script);
518
+ }
519
+ },
520
+
521
+ hasClassName: function (el, cls) {
522
+ var exp = new RegExp("(^|\\s)" + cls + "($|\\s)");
523
+ return (el.className && exp.test(el.className)) ? true : false;
524
+ },
525
+
526
+ addClassName: function (el, cls) {
527
+ if (!Wf.Utils.hasClassName(el, cls)) el.className += " " + cls;
528
+ },
529
+
530
+ removeClassName: function (el, cls) {
531
+ if (Wf.Utils.hasClassName(el, cls)) {
532
+ var reg = new RegExp('(\\s|^)' + cls + '(\\s|$)');
533
+ el.className = el.className.replace(reg, ' ');
534
+ }
535
+ },
536
+
537
+ findElement: function (e, selector, el) {
538
+ var event = e || window.event;
539
+ var target = el || event.target || event.srcElement;
540
+ if (target == document.body) return null;
541
+ var condition = (selector.match(/^\./)) ? this.hasClassName(target, selector.replace(/^\./, '')) : (target.tagName.toLowerCase() == selector.toLowerCase());
542
+ if (condition) {
543
+ return target;
479
544
  } else {
480
- if(options.onFailure) options.onFailure(request)
481
- if(options.onComplete) options.onComplete(request)
545
+ return this.findElement(e, selector, target.parentNode);
482
546
  }
483
- }
484
- }
485
-
486
- request.open(options.method, url, true);
487
- request.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
488
- request.setRequestHeader('Accept', 'text/javascript, text/html, application/xml, text/xml, */*');
489
- request.send(options.parameters);
490
- },
491
-
492
- update: function(element_id, url, options) {
493
- options.onSuccess = function(response) {
494
- Wf.element(element_id).innerHTML = response.responseText;
495
- };
496
- Wf.Utils.ajax(url, options);
497
- },
498
-
499
- evalScripts: function(html){
500
- var script_re = '<script[^>]*>([\\S\\s]*?)<\/script>';
501
- var matchAll = new RegExp(script_re, 'img');
502
- var matchOne = new RegExp(script_re, 'im');
503
- var matches = html.match(matchAll) || [];
504
- for(var i=0,l=matches.length;i<l;i++){
505
- var script = (matches[i].match(matchOne) || ['', ''])[1];
506
- // console.info(script)
507
- // alert(script);
508
- eval(script);
547
+ },
548
+
549
+ cumulativeOffset: function (element) {
550
+ var valueT = 0, valueL = 0;
551
+ do {
552
+ valueT += element.offsetTop || 0;
553
+ valueL += element.offsetLeft || 0;
554
+ element = element.offsetParent;
555
+ } while (element);
556
+ return [valueL, valueT];
509
557
  }
510
- },
511
-
512
- hasClassName: function(el, cls){
513
- var exp = new RegExp("(^|\\s)"+cls+"($|\\s)");
514
- return (el.className && exp.test(el.className))?true:false;
515
- },
516
-
517
- addClassName: function(el, cls) {
518
- if (!Wf.Utils.hasClassName(el,cls)) el.className += " " + cls;
519
- },
520
-
521
- removeClassName: function(el,cls) {
522
- if (Wf.Utils.hasClassName(el,cls)) {
523
- var reg = new RegExp('(\\s|^)'+cls+'(\\s|$)');
524
- el.className=el.className.replace(reg, ' ');
525
- }
526
- },
527
-
528
- findElement: function(e,selector,el) {
529
- var event = e || window.event;
530
- var target = el || event.target || event.srcElement;
531
- if(target == document.body) return null;
532
- var condition = (selector.match(/^\./)) ? this.hasClassName(target,selector.replace(/^\./,'')) : (target.tagName.toLowerCase() == selector.toLowerCase());
533
- if(condition) {
534
- return target;
535
- } else {
536
- return this.findElement(e,selector,target.parentNode);
537
- }
538
- },
539
-
540
- cumulativeOffset: function(element) {
541
- var valueT = 0, valueL = 0;
542
- do {
543
- valueT += element.offsetTop || 0;
544
- valueL += element.offsetLeft || 0;
545
- element = element.offsetParent;
546
- } while (element);
547
- return [valueL, valueT];
548
- }
549
-
550
- }
558
+
559
+ };
551
560
 
552
561
  /****************************************************************************
553
- **** Initialization
554
- ****************************************************************************/
562
+ **** Initialization
563
+ ****************************************************************************/
555
564
 
556
565
  var wfFilter = null;
557
566
  var wfCalendar = null;
558
567
  var wfExporter = null;
559
568
 
560
- function initializeWillFilter() {
561
- var setup = function() {
562
- wfFilter = new Wf.Filter();
563
- wfCalendar = new Wf.Calendar();
564
- wfExporter = new Wf.Exporter();
565
- }
566
-
567
- Wf.Utils.addEvent(window,'load',setup);
569
+ function initializeWillFilter() {
570
+ var setup = function () {
571
+ wfFilter = new Wf.Filter();
572
+ wfCalendar = new Wf.Calendar();
573
+ wfExporter = new Wf.Exporter();
574
+ };
575
+
576
+ Wf.Utils.addEvent(window, 'load', setup);
568
577
  }