bootstrap_form_extensions 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/Rakefile +34 -0
- data/app/assets/javascripts/bootstrap_form_extensions/arrayed_field.js +70 -0
- data/app/assets/javascripts/bootstrap_form_extensions/bootstrap-timepicker.min.js +5 -0
- data/app/assets/javascripts/bootstrap_form_extensions/index.js +2 -0
- data/app/assets/javascripts/bootstrap_form_extensions/jquery.html5data.min.js +7 -0
- data/app/assets/javascripts/bootstrap_form_extensions/scheduler.js +226 -0
- data/app/assets/javascripts/bootstrap_form_extensions/select_or_new.js +76 -0
- data/app/assets/javascripts/bootstrap_form_extensions/time_picker.js +61 -0
- data/app/assets/javascripts/bootstrap_form_extensions/timespan.js +60 -0
- data/app/assets/stylesheets/bootstrap_form_extensions/bootstrap-timepicker.min.css +10 -0
- data/app/assets/stylesheets/bootstrap_form_extensions/common.css +11 -0
- data/app/assets/stylesheets/bootstrap_form_extensions/index.css +4 -0
- data/app/assets/stylesheets/bootstrap_form_extensions/scheduler.css +31 -0
- data/app/assets/stylesheets/bootstrap_form_extensions/submit_bar.css +4 -0
- data/app/views/bootstrap_form_extensions/_submit_bar.html.erb +36 -0
- data/lib/bootstrap_form_extensions.rb +22 -0
- data/lib/bootstrap_form_extensions/arrayed_field.rb +107 -0
- data/lib/bootstrap_form_extensions/date_time_pickers.rb +71 -0
- data/lib/bootstrap_form_extensions/helpers.rb +18 -0
- data/lib/bootstrap_form_extensions/scheduler.rb +72 -0
- data/lib/bootstrap_form_extensions/select_or_new.rb +36 -0
- data/lib/bootstrap_form_extensions/submit_bar.rb +65 -0
- data/lib/bootstrap_form_extensions/timespan.rb +55 -0
- data/lib/bootstrap_form_extensions/version.rb +3 -0
- data/lib/tasks/rails_bootstrap_form_extensions_tasks.rake +4 -0
- data/test/arrayed_field_test.rb +63 -0
- data/test/bootstrap_form_extensions_test.rb +7 -0
- data/test/date_time_pickers_test.rb +50 -0
- data/test/dummy/README.rdoc +28 -0
- data/test/dummy/Rakefile +6 -0
- data/test/dummy/app/assets/javascripts/application.js +13 -0
- data/test/dummy/app/assets/stylesheets/application.css +15 -0
- data/test/dummy/app/controllers/application_controller.rb +5 -0
- data/test/dummy/app/helpers/application_helper.rb +2 -0
- data/test/dummy/app/models/category.rb +7 -0
- data/test/dummy/app/models/thing.rb +46 -0
- data/test/dummy/app/views/layouts/application.html.erb +14 -0
- data/test/dummy/bin/bundle +3 -0
- data/test/dummy/bin/rails +4 -0
- data/test/dummy/bin/rake +4 -0
- data/test/dummy/bin/setup +29 -0
- data/test/dummy/config.ru +4 -0
- data/test/dummy/config/application.rb +26 -0
- data/test/dummy/config/boot.rb +5 -0
- data/test/dummy/config/database.yml +25 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/environments/development.rb +41 -0
- data/test/dummy/config/environments/production.rb +79 -0
- data/test/dummy/config/environments/test.rb +42 -0
- data/test/dummy/config/initializers/assets.rb +11 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/dummy/config/initializers/cookies_serializer.rb +3 -0
- data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/test/dummy/config/initializers/inflections.rb +16 -0
- data/test/dummy/config/initializers/mime_types.rb +4 -0
- data/test/dummy/config/initializers/session_store.rb +3 -0
- data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/test/dummy/config/locales/en.yml +23 -0
- data/test/dummy/config/routes.rb +3 -0
- data/test/dummy/config/secrets.yml +22 -0
- data/test/dummy/db/migrate/20150918185031_create_things.rb +9 -0
- data/test/dummy/db/migrate/20150924203053_add_timespan.rb +7 -0
- data/test/dummy/db/migrate/20150929213249_add_arrayed_field.rb +7 -0
- data/test/dummy/db/migrate/20151006171627_add_another_arrayed_field.rb +7 -0
- data/test/dummy/db/migrate/20151006181943_add_json_field.rb +7 -0
- data/test/dummy/db/migrate/20151007213131_add_scheduler_field.rb +7 -0
- data/test/dummy/db/migrate/20151030194330_add_date_time.rb +7 -0
- data/test/dummy/db/migrate/20151106165522_add_category.rb +10 -0
- data/test/dummy/db/schema.rb +31 -0
- data/test/dummy/db/test.sqlite3 +0 -0
- data/test/dummy/log/development.log +0 -0
- data/test/dummy/log/test.log +1997 -0
- data/test/dummy/public/404.html +67 -0
- data/test/dummy/public/422.html +67 -0
- data/test/dummy/public/500.html +66 -0
- data/test/dummy/public/favicon.ico +0 -0
- data/test/dummy/test/fixtures/things.yml +8 -0
- data/test/javascripts/arrayed_field_spec.js +101 -0
- data/test/javascripts/helpers/function_bind_polyfill_for_phantomjs.js +32 -0
- data/test/javascripts/helpers/jasmine-jquery.js +838 -0
- data/test/javascripts/scheduler_spec.js +354 -0
- data/test/javascripts/select_or_new_spec.js +113 -0
- data/test/javascripts/support/jasmine.yml +127 -0
- data/test/javascripts/support/jasmine_helper.rb +19 -0
- data/test/javascripts/time_picker_spec.js +42 -0
- data/test/javascripts/timespan_spec.js +81 -0
- data/test/javascripts/vendor/bootstrap.min.js +7 -0
- data/test/javascripts/vendor/jquery-2.1.4.min.js +4 -0
- data/test/scheduler_serializer_test.rb +200 -0
- data/test/scheduler_test.rb +15 -0
- data/test/select_or_new_test.rb +37 -0
- data/test/submit_bar_test.rb +112 -0
- data/test/test_helper.rb +37 -0
- data/test/timespan_test.rb +47 -0
- metadata +291 -0
@@ -0,0 +1,354 @@
|
|
1
|
+
describe("Scheduler", function() {
|
2
|
+
|
3
|
+
describe("Plugin", function() {
|
4
|
+
|
5
|
+
it("should be defined on jQuery object", function() {
|
6
|
+
expect($(document.body).scheduler).not.toThrow()
|
7
|
+
})
|
8
|
+
|
9
|
+
})
|
10
|
+
|
11
|
+
describe("Run tests in noConflict mode -- it's the only way to ensure that the plugin works in noConflict mode", function() {
|
12
|
+
|
13
|
+
beforeEach(function() {
|
14
|
+
$.fn.bootstrapScheduler = $.fn.scheduler.noConflict()
|
15
|
+
})
|
16
|
+
|
17
|
+
afterEach(function() {
|
18
|
+
$.fn.scheduler = $.fn.bootstrapScheduler
|
19
|
+
delete $.fn.bootstrapScheduler
|
20
|
+
})
|
21
|
+
|
22
|
+
describe("initialization", function() {
|
23
|
+
|
24
|
+
it("should provide no conflict - scheduler was set back to undefined (orig value)", function() {
|
25
|
+
expect($.fn.scheduler).toBeUndefined()
|
26
|
+
})
|
27
|
+
|
28
|
+
it("should return jquery collection containing the element", function() {
|
29
|
+
var $el = $('<div/>')
|
30
|
+
var $scheduler = $el.bootstrapScheduler()
|
31
|
+
expect($scheduler).toEqual(jasmine.any($))
|
32
|
+
expect($scheduler[0]).toBe($el[0])
|
33
|
+
})
|
34
|
+
|
35
|
+
})
|
36
|
+
|
37
|
+
describe("behaviour", function() {
|
38
|
+
|
39
|
+
var $element
|
40
|
+
var fixture = function() {
|
41
|
+
return '<div class="form-group" data-scheduler="true">'
|
42
|
+
+' <label class="control-label col-sm-2" for="thing_schedule">Schedule</label>'
|
43
|
+
+' <div class="col-sm-10">'
|
44
|
+
+' <input class="scheduler-hidden-field" id="thing_schedule" name="thing[schedule]" type="hidden" value="[[false,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true],[false,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true],[false,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true],[false,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true],[false,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true],[false,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true],[false,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true]]">'
|
45
|
+
+' <table class="scheduler-badge">'
|
46
|
+
+' <tbody>'
|
47
|
+
+' <tr>'
|
48
|
+
+' <td class="off" data-day="0" data-hour="0"> </td>'
|
49
|
+
+' <td class="on" data-day="0" data-hour="1"> </td>'
|
50
|
+
+' <td class="on" data-day="0" data-hour="2"> </td>'
|
51
|
+
+' <td class="on" data-day="0" data-hour="3"> </td>'
|
52
|
+
+' <td class="on" data-day="0" data-hour="4"> </td>'
|
53
|
+
+' <td class="on" data-day="0" data-hour="5"> </td>'
|
54
|
+
+' <td class="on" data-day="0" data-hour="6"> </td>'
|
55
|
+
+' <td class="on" data-day="0" data-hour="7"> </td>'
|
56
|
+
+' <td class="on" data-day="0" data-hour="8"> </td>'
|
57
|
+
+' <td class="on" data-day="0" data-hour="9"> </td>'
|
58
|
+
+' <td class="on" data-day="0" data-hour="10"> </td>'
|
59
|
+
+' <td class="on" data-day="0" data-hour="11"> </td>'
|
60
|
+
+' <td class="on" data-day="0" data-hour="12"> </td>'
|
61
|
+
+' <td class="on" data-day="0" data-hour="13"> </td>'
|
62
|
+
+' <td class="on" data-day="0" data-hour="14"> </td>'
|
63
|
+
+' <td class="on" data-day="0" data-hour="15"> </td>'
|
64
|
+
+' <td class="on" data-day="0" data-hour="16"> </td>'
|
65
|
+
+' <td class="on" data-day="0" data-hour="17"> </td>'
|
66
|
+
+' <td class="on" data-day="0" data-hour="18"> </td>'
|
67
|
+
+' <td class="on" data-day="0" data-hour="19"> </td>'
|
68
|
+
+' <td class="on" data-day="0" data-hour="20"> </td>'
|
69
|
+
+' <td class="on" data-day="0" data-hour="21"> </td>'
|
70
|
+
+' <td class="on" data-day="0" data-hour="22"> </td>'
|
71
|
+
+' <td class="on" data-day="0" data-hour="23"> </td>'
|
72
|
+
+' </tr>'
|
73
|
+
+' <tr>'
|
74
|
+
+' <td class="off" data-day="1" data-hour="0"> </td>'
|
75
|
+
+' <td class="on" data-day="1" data-hour="1"> </td>'
|
76
|
+
+' <td class="on" data-day="1" data-hour="2"> </td>'
|
77
|
+
+' <td class="on" data-day="1" data-hour="3"> </td>'
|
78
|
+
+' <td class="on" data-day="1" data-hour="4"> </td>'
|
79
|
+
+' <td class="on" data-day="1" data-hour="5"> </td>'
|
80
|
+
+' <td class="on" data-day="1" data-hour="6"> </td>'
|
81
|
+
+' <td class="on" data-day="1" data-hour="7"> </td>'
|
82
|
+
+' <td class="on" data-day="1" data-hour="8"> </td>'
|
83
|
+
+' <td class="on" data-day="1" data-hour="9"> </td>'
|
84
|
+
+' <td class="on" data-day="1" data-hour="10"> </td>'
|
85
|
+
+' <td class="on" data-day="1" data-hour="11"> </td>'
|
86
|
+
+' <td class="on" data-day="1" data-hour="12"> </td>'
|
87
|
+
+' <td class="on" data-day="1" data-hour="13"> </td>'
|
88
|
+
+' <td class="on" data-day="1" data-hour="14"> </td>'
|
89
|
+
+' <td class="on" data-day="1" data-hour="15"> </td>'
|
90
|
+
+' <td class="on" data-day="1" data-hour="16"> </td>'
|
91
|
+
+' <td class="on" data-day="1" data-hour="17"> </td>'
|
92
|
+
+' <td class="on" data-day="1" data-hour="18"> </td>'
|
93
|
+
+' <td class="on" data-day="1" data-hour="19"> </td>'
|
94
|
+
+' <td class="on" data-day="1" data-hour="20"> </td>'
|
95
|
+
+' <td class="on" data-day="1" data-hour="21"> </td>'
|
96
|
+
+' <td class="on" data-day="1" data-hour="22"> </td>'
|
97
|
+
+' <td class="on" data-day="1" data-hour="23"> </td>'
|
98
|
+
+' </tr>'
|
99
|
+
+' <tr>'
|
100
|
+
+' <td class="off" data-day="2" data-hour="0"> </td>'
|
101
|
+
+' <td class="on" data-day="2" data-hour="1"> </td>'
|
102
|
+
+' <td class="on" data-day="2" data-hour="2"> </td>'
|
103
|
+
+' <td class="on" data-day="2" data-hour="3"> </td>'
|
104
|
+
+' <td class="on" data-day="2" data-hour="4"> </td>'
|
105
|
+
+' <td class="on" data-day="2" data-hour="5"> </td>'
|
106
|
+
+' <td class="on" data-day="2" data-hour="6"> </td>'
|
107
|
+
+' <td class="on" data-day="2" data-hour="7"> </td>'
|
108
|
+
+' <td class="on" data-day="2" data-hour="8"> </td>'
|
109
|
+
+' <td class="on" data-day="2" data-hour="9"> </td>'
|
110
|
+
+' <td class="on" data-day="2" data-hour="10"> </td>'
|
111
|
+
+' <td class="on" data-day="2" data-hour="11"> </td>'
|
112
|
+
+' <td class="on" data-day="2" data-hour="12"> </td>'
|
113
|
+
+' <td class="on" data-day="2" data-hour="13"> </td>'
|
114
|
+
+' <td class="on" data-day="2" data-hour="14"> </td>'
|
115
|
+
+' <td class="on" data-day="2" data-hour="15"> </td>'
|
116
|
+
+' <td class="on" data-day="2" data-hour="16"> </td>'
|
117
|
+
+' <td class="on" data-day="2" data-hour="17"> </td>'
|
118
|
+
+' <td class="on" data-day="2" data-hour="18"> </td>'
|
119
|
+
+' <td class="on" data-day="2" data-hour="19"> </td>'
|
120
|
+
+' <td class="on" data-day="2" data-hour="20"> </td>'
|
121
|
+
+' <td class="on" data-day="2" data-hour="21"> </td>'
|
122
|
+
+' <td class="on" data-day="2" data-hour="22"> </td>'
|
123
|
+
+' <td class="on" data-day="2" data-hour="23"> </td>'
|
124
|
+
+' </tr>'
|
125
|
+
+' <tr>'
|
126
|
+
+' <td class="off" data-day="3" data-hour="0"> </td>'
|
127
|
+
+' <td class="on" data-day="3" data-hour="1"> </td>'
|
128
|
+
+' <td class="on" data-day="3" data-hour="2"> </td>'
|
129
|
+
+' <td class="on" data-day="3" data-hour="3"> </td>'
|
130
|
+
+' <td class="on" data-day="3" data-hour="4"> </td>'
|
131
|
+
+' <td class="on" data-day="3" data-hour="5"> </td>'
|
132
|
+
+' <td class="on" data-day="3" data-hour="6"> </td>'
|
133
|
+
+' <td class="on" data-day="3" data-hour="7"> </td>'
|
134
|
+
+' <td class="on" data-day="3" data-hour="8"> </td>'
|
135
|
+
+' <td class="on" data-day="3" data-hour="9"> </td>'
|
136
|
+
+' <td class="on" data-day="3" data-hour="10"> </td>'
|
137
|
+
+' <td class="on" data-day="3" data-hour="11"> </td>'
|
138
|
+
+' <td class="on" data-day="3" data-hour="12"> </td>'
|
139
|
+
+' <td class="on" data-day="3" data-hour="13"> </td>'
|
140
|
+
+' <td class="on" data-day="3" data-hour="14"> </td>'
|
141
|
+
+' <td class="on" data-day="3" data-hour="15"> </td>'
|
142
|
+
+' <td class="on" data-day="3" data-hour="16"> </td>'
|
143
|
+
+' <td class="on" data-day="3" data-hour="17"> </td>'
|
144
|
+
+' <td class="on" data-day="3" data-hour="18"> </td>'
|
145
|
+
+' <td class="on" data-day="3" data-hour="19"> </td>'
|
146
|
+
+' <td class="on" data-day="3" data-hour="20"> </td>'
|
147
|
+
+' <td class="on" data-day="3" data-hour="21"> </td>'
|
148
|
+
+' <td class="on" data-day="3" data-hour="22"> </td>'
|
149
|
+
+' <td class="on" data-day="3" data-hour="23"> </td>'
|
150
|
+
+' </tr>'
|
151
|
+
+' <tr>'
|
152
|
+
+' <td class="off" data-day="4" data-hour="0"> </td>'
|
153
|
+
+' <td class="on" data-day="4" data-hour="1"> </td>'
|
154
|
+
+' <td class="on" data-day="4" data-hour="2"> </td>'
|
155
|
+
+' <td class="on" data-day="4" data-hour="3"> </td>'
|
156
|
+
+' <td class="on" data-day="4" data-hour="4"> </td>'
|
157
|
+
+' <td class="on" data-day="4" data-hour="5"> </td>'
|
158
|
+
+' <td class="on" data-day="4" data-hour="6"> </td>'
|
159
|
+
+' <td class="on" data-day="4" data-hour="7"> </td>'
|
160
|
+
+' <td class="on" data-day="4" data-hour="8"> </td>'
|
161
|
+
+' <td class="on" data-day="4" data-hour="9"> </td>'
|
162
|
+
+' <td class="on" data-day="4" data-hour="10"> </td>'
|
163
|
+
+' <td class="on" data-day="4" data-hour="11"> </td>'
|
164
|
+
+' <td class="on" data-day="4" data-hour="12"> </td>'
|
165
|
+
+' <td class="on" data-day="4" data-hour="13"> </td>'
|
166
|
+
+' <td class="on" data-day="4" data-hour="14"> </td>'
|
167
|
+
+' <td class="on" data-day="4" data-hour="15"> </td>'
|
168
|
+
+' <td class="on" data-day="4" data-hour="16"> </td>'
|
169
|
+
+' <td class="on" data-day="4" data-hour="17"> </td>'
|
170
|
+
+' <td class="on" data-day="4" data-hour="18"> </td>'
|
171
|
+
+' <td class="on" data-day="4" data-hour="19"> </td>'
|
172
|
+
+' <td class="on" data-day="4" data-hour="20"> </td>'
|
173
|
+
+' <td class="on" data-day="4" data-hour="21"> </td>'
|
174
|
+
+' <td class="on" data-day="4" data-hour="22"> </td>'
|
175
|
+
+' <td class="on" data-day="4" data-hour="23"> </td>'
|
176
|
+
+' </tr>'
|
177
|
+
+' <tr>'
|
178
|
+
+' <td class="off" data-day="5" data-hour="0"> </td>'
|
179
|
+
+' <td class="on" data-day="5" data-hour="1"> </td>'
|
180
|
+
+' <td class="on" data-day="5" data-hour="2"> </td>'
|
181
|
+
+' <td class="on" data-day="5" data-hour="3"> </td>'
|
182
|
+
+' <td class="on" data-day="5" data-hour="4"> </td>'
|
183
|
+
+' <td class="on" data-day="5" data-hour="5"> </td>'
|
184
|
+
+' <td class="on" data-day="5" data-hour="6"> </td>'
|
185
|
+
+' <td class="on" data-day="5" data-hour="7"> </td>'
|
186
|
+
+' <td class="on" data-day="5" data-hour="8"> </td>'
|
187
|
+
+' <td class="on" data-day="5" data-hour="9"> </td>'
|
188
|
+
+' <td class="on" data-day="5" data-hour="10"> </td>'
|
189
|
+
+' <td class="on" data-day="5" data-hour="11"> </td>'
|
190
|
+
+' <td class="on" data-day="5" data-hour="12"> </td>'
|
191
|
+
+' <td class="on" data-day="5" data-hour="13"> </td>'
|
192
|
+
+' <td class="on" data-day="5" data-hour="14"> </td>'
|
193
|
+
+' <td class="on" data-day="5" data-hour="15"> </td>'
|
194
|
+
+' <td class="on" data-day="5" data-hour="16"> </td>'
|
195
|
+
+' <td class="on" data-day="5" data-hour="17"> </td>'
|
196
|
+
+' <td class="on" data-day="5" data-hour="18"> </td>'
|
197
|
+
+' <td class="on" data-day="5" data-hour="19"> </td>'
|
198
|
+
+' <td class="on" data-day="5" data-hour="20"> </td>'
|
199
|
+
+' <td class="on" data-day="5" data-hour="21"> </td>'
|
200
|
+
+' <td class="on" data-day="5" data-hour="22"> </td>'
|
201
|
+
+' <td class="on" data-day="5" data-hour="23"> </td>'
|
202
|
+
+' </tr>'
|
203
|
+
+' <tr>'
|
204
|
+
+' <td class="off" data-day="6" data-hour="0"> </td>'
|
205
|
+
+' <td class="on" data-day="6" data-hour="1"> </td>'
|
206
|
+
+' <td class="on" data-day="6" data-hour="2"> </td>'
|
207
|
+
+' <td class="on" data-day="6" data-hour="3"> </td>'
|
208
|
+
+' <td class="on" data-day="6" data-hour="4"> </td>'
|
209
|
+
+' <td class="on" data-day="6" data-hour="5"> </td>'
|
210
|
+
+' <td class="on" data-day="6" data-hour="6"> </td>'
|
211
|
+
+' <td class="on" data-day="6" data-hour="7"> </td>'
|
212
|
+
+' <td class="on" data-day="6" data-hour="8"> </td>'
|
213
|
+
+' <td class="on" data-day="6" data-hour="9"> </td>'
|
214
|
+
+' <td class="on" data-day="6" data-hour="10"> </td>'
|
215
|
+
+' <td class="on" data-day="6" data-hour="11"> </td>'
|
216
|
+
+' <td class="on" data-day="6" data-hour="12"> </td>'
|
217
|
+
+' <td class="on" data-day="6" data-hour="13"> </td>'
|
218
|
+
+' <td class="on" data-day="6" data-hour="14"> </td>'
|
219
|
+
+' <td class="on" data-day="6" data-hour="15"> </td>'
|
220
|
+
+' <td class="on" data-day="6" data-hour="16"> </td>'
|
221
|
+
+' <td class="on" data-day="6" data-hour="17"> </td>'
|
222
|
+
+' <td class="on" data-day="6" data-hour="18"> </td>'
|
223
|
+
+' <td class="on" data-day="6" data-hour="19"> </td>'
|
224
|
+
+' <td class="on" data-day="6" data-hour="20"> </td>'
|
225
|
+
+' <td class="on" data-day="6" data-hour="21"> </td>'
|
226
|
+
+' <td class="on" data-day="6" data-hour="22"> </td>'
|
227
|
+
+' <td class="on" data-day="6" data-hour="23"> </td>'
|
228
|
+
+' </tr>'
|
229
|
+
+' </tbody>'
|
230
|
+
+' </table>'
|
231
|
+
+' </div>'
|
232
|
+
+'</div>'
|
233
|
+
}
|
234
|
+
|
235
|
+
beforeEach(function() {
|
236
|
+
$element = $(fixture())
|
237
|
+
$element.bootstrapScheduler()
|
238
|
+
$element.find('table.scheduler-badge').click()
|
239
|
+
})
|
240
|
+
|
241
|
+
describe("return values in the hidden field", function() {
|
242
|
+
|
243
|
+
it("apply no changes", function() {
|
244
|
+
var values
|
245
|
+
$('#scheduler-container button.apply').click()
|
246
|
+
values = JSON.parse($element.find('.scheduler-hidden-field').val())
|
247
|
+
expect(values).toEqual([[false, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true], [false, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true], [false, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true], [false, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true], [false, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true], [false, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true], [false, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true]])
|
248
|
+
})
|
249
|
+
|
250
|
+
it("cancel changes", function() {
|
251
|
+
var values
|
252
|
+
$('#scheduler-container a.none').click()
|
253
|
+
$('#scheduler-container button.cancel').click()
|
254
|
+
values = JSON.parse($element.find('.scheduler-hidden-field').val())
|
255
|
+
expect(values).toEqual([[false, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true], [false, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true], [false, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true], [false, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true], [false, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true], [false, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true], [false, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true]])
|
256
|
+
})
|
257
|
+
|
258
|
+
it("select all", function() {
|
259
|
+
var values
|
260
|
+
$('#scheduler-container a.all').click()
|
261
|
+
$('#scheduler-container button.apply').click()
|
262
|
+
values = JSON.parse($element.find('.scheduler-hidden-field').val())
|
263
|
+
expect(values).toEqual([[true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true], [true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true], [true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true], [true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true], [true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true], [true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true], [true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true]])
|
264
|
+
})
|
265
|
+
|
266
|
+
it("select none", function() {
|
267
|
+
var values
|
268
|
+
$('#scheduler-container a.none').click()
|
269
|
+
$('#scheduler-container button.apply').click()
|
270
|
+
values = JSON.parse($element.find('.scheduler-hidden-field').val())
|
271
|
+
expect(values).toEqual([[false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false], [false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false], [false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false], [false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false], [false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false], [false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false], [false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false]])
|
272
|
+
})
|
273
|
+
|
274
|
+
it("unselect a full day", function() {
|
275
|
+
var values
|
276
|
+
$('#scheduler-container a.day-header:first').click()
|
277
|
+
$('#scheduler-container button.apply').click()
|
278
|
+
values = JSON.parse($element.find('.scheduler-hidden-field').val())
|
279
|
+
expect(values).toEqual([[false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false], [false, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true], [false, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true], [false, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true], [false, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true], [false, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true], [false, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true]])
|
280
|
+
})
|
281
|
+
|
282
|
+
it("unselect a full hour", function() {
|
283
|
+
var values
|
284
|
+
$('#scheduler-container a.hour-header:last').click()
|
285
|
+
$('#scheduler-container button.apply').click()
|
286
|
+
values = JSON.parse($element.find('.scheduler-hidden-field').val())
|
287
|
+
expect(values).toEqual([[false, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, false], [false, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, false], [false, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, false], [false, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, false], [false, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, false], [false, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, false], [false, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, false]])
|
288
|
+
})
|
289
|
+
|
290
|
+
it("unselect one hour", function() {
|
291
|
+
var values
|
292
|
+
$('#scheduler-container td[data-day="0"][data-hour="0"]').click()
|
293
|
+
$('#scheduler-container button.apply').click()
|
294
|
+
values = JSON.parse($element.find('.scheduler-hidden-field').val())
|
295
|
+
expect(values).toEqual([[true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true], [false, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true], [false, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true], [false, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true], [false, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true], [false, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true], [false, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true]])
|
296
|
+
})
|
297
|
+
|
298
|
+
})
|
299
|
+
|
300
|
+
describe("update badge", function() {
|
301
|
+
|
302
|
+
it("apply no changes", function() {
|
303
|
+
var html
|
304
|
+
html = $element.find('table.scheduler-badge').html()
|
305
|
+
$('#scheduler-container button.apply').click()
|
306
|
+
expect($element.find('table.scheduler-badge').html()).toEqual(html)
|
307
|
+
})
|
308
|
+
|
309
|
+
it("cancel changes", function() {
|
310
|
+
var html
|
311
|
+
html = $element.find('table.scheduler-badge').html()
|
312
|
+
$('#scheduler-container a.none').click()
|
313
|
+
$('#scheduler-container button.cancel').click()
|
314
|
+
expect($element.find('table.scheduler-badge').html()).toEqual(html)
|
315
|
+
})
|
316
|
+
|
317
|
+
it("select all", function() {
|
318
|
+
$('#scheduler-container a.all').click()
|
319
|
+
$('#scheduler-container button.apply').click()
|
320
|
+
expect($element.find('table.scheduler-badge').html()).not.toContain('off')
|
321
|
+
})
|
322
|
+
|
323
|
+
it("select none", function() {
|
324
|
+
$('#scheduler-container a.none').click()
|
325
|
+
$('#scheduler-container button.apply').click()
|
326
|
+
expect($element.find('table.scheduler-badge').html()).not.toContain('on')
|
327
|
+
})
|
328
|
+
|
329
|
+
it("unselect a full day", function() {
|
330
|
+
var values
|
331
|
+
$('#scheduler-container a.day-header:first').click()
|
332
|
+
$('#scheduler-container button.apply').click()
|
333
|
+
expect($element.find('table.scheduler-badge tr:first').html()).not.toContain('on')
|
334
|
+
})
|
335
|
+
|
336
|
+
it("unselect a full hour", function() {
|
337
|
+
$('#scheduler-container a.hour-header:last').click()
|
338
|
+
$('#scheduler-container button.apply').click()
|
339
|
+
expect($element.find('table.scheduler-badge tr td:last-child.on')).not.toExist()
|
340
|
+
})
|
341
|
+
|
342
|
+
it("unselect one hour", function() {
|
343
|
+
$('#scheduler-container td[data-day="0"][data-hour="0"]').click()
|
344
|
+
$('#scheduler-container button.apply').click()
|
345
|
+
expect($element.find('table.scheduler-badge td[data-day="0"][data-hour="0"]')).toHaveClass('on')
|
346
|
+
})
|
347
|
+
|
348
|
+
})
|
349
|
+
|
350
|
+
})
|
351
|
+
|
352
|
+
})
|
353
|
+
|
354
|
+
})
|
@@ -0,0 +1,113 @@
|
|
1
|
+
describe("SelectOrNew", function() {
|
2
|
+
|
3
|
+
describe("Plugin", function() {
|
4
|
+
|
5
|
+
it("should be defined on jQuery object", function() {
|
6
|
+
expect($(document.body).selectOrNew).not.toThrow()
|
7
|
+
})
|
8
|
+
|
9
|
+
})
|
10
|
+
|
11
|
+
describe("Run tests in noConflict mode -- it's the only way to ensure that the plugin works in noConflict mode", function() {
|
12
|
+
|
13
|
+
beforeEach(function() {
|
14
|
+
$.fn.bootstrapSelectOrNew = $.fn.selectOrNew.noConflict()
|
15
|
+
})
|
16
|
+
|
17
|
+
afterEach(function() {
|
18
|
+
$.fn.selectOrNew = $.fn.bootstrapSelectOrNew
|
19
|
+
delete $.fn.bootstrapSelectOrNew
|
20
|
+
})
|
21
|
+
|
22
|
+
describe("initialization", function() {
|
23
|
+
|
24
|
+
it("should provide no conflict - selectOrNew was set back to undefined (orig value)", function() {
|
25
|
+
expect($.fn.selectOrNew).toBeUndefined()
|
26
|
+
})
|
27
|
+
|
28
|
+
it("should return jquery collection containing the element", function() {
|
29
|
+
var $el = $('<div/>')
|
30
|
+
var $selectOrNew = $el.bootstrapSelectOrNew()
|
31
|
+
expect($selectOrNew).toEqual(jasmine.any($))
|
32
|
+
expect($selectOrNew[0]).toBe($el[0])
|
33
|
+
})
|
34
|
+
|
35
|
+
})
|
36
|
+
|
37
|
+
describe("behaviour", function() {
|
38
|
+
|
39
|
+
var $element, $select, $input, $inputGroup
|
40
|
+
var fixture = function() {
|
41
|
+
return '<div class="form-group" data-select-or-new="true">'
|
42
|
+
+' <label class="control-label col-sm-2" for="thing_category">Category</label>'
|
43
|
+
+' <div class="col-sm-10">'
|
44
|
+
+' <select class="form-control" id="thing_category" name="thing[category]">'
|
45
|
+
+' <option value="">Please select</option>'
|
46
|
+
+' <option value="1">One</option>'
|
47
|
+
+' <option value="2">Two</option>'
|
48
|
+
+' <option value="0">New...</option>'
|
49
|
+
+' </select>'
|
50
|
+
+' <div class="input-group" style="display: none;">'
|
51
|
+
+' <input class="form-control" id="thing_new_category" name="thing[new_category]" placeholder="New..." type="text">'
|
52
|
+
+' <div class="input-group-addon select-or-new-cancel">'
|
53
|
+
+' <i class="text-danger glyphicon glyphicon-remove"></i>'
|
54
|
+
+' </div>'
|
55
|
+
+' </div>'
|
56
|
+
+' </div>'
|
57
|
+
+'</div>'
|
58
|
+
}
|
59
|
+
|
60
|
+
beforeEach(function() {
|
61
|
+
$element = $(fixture())
|
62
|
+
$element.appendTo('body')
|
63
|
+
|
64
|
+
$select = $element.find('select')
|
65
|
+
$input = $element.find('input')
|
66
|
+
$inputGroup = $element.find('div.input-group')
|
67
|
+
$cancelNew = $element.find('div.select-or-new-cancel')
|
68
|
+
|
69
|
+
$element.bootstrapSelectOrNew()
|
70
|
+
})
|
71
|
+
|
72
|
+
afterEach(function() {
|
73
|
+
$element.remove()
|
74
|
+
})
|
75
|
+
|
76
|
+
it("should show the input tag when 'New...' is selected", function() {
|
77
|
+
expect($select).toBeVisible()
|
78
|
+
expect($inputGroup).not.toBeVisible()
|
79
|
+
$select.val('0').trigger('change')
|
80
|
+
expect($select).not.toBeVisible()
|
81
|
+
expect($inputGroup).toBeVisible()
|
82
|
+
})
|
83
|
+
|
84
|
+
it("should focus on the input tag when 'New...' is selected", function() {
|
85
|
+
$select.val('0').trigger('change')
|
86
|
+
expect($input).toBeFocused()
|
87
|
+
})
|
88
|
+
|
89
|
+
it("should show the select tag when new is cancelled", function() {
|
90
|
+
$select.val('0').trigger('change')
|
91
|
+
$cancelNew.click()
|
92
|
+
expect($select).toBeVisible()
|
93
|
+
expect($inputGroup).not.toBeVisible()
|
94
|
+
})
|
95
|
+
|
96
|
+
it("should focus on the select tag when new is cancelled", function() {
|
97
|
+
$select.val('0').trigger('change')
|
98
|
+
$cancelNew.click()
|
99
|
+
expect($select).toBeFocused()
|
100
|
+
})
|
101
|
+
|
102
|
+
it("should empty the input value when new is cancelled", function() {
|
103
|
+
$select.val('0').trigger('change')
|
104
|
+
$input.val('New Category')
|
105
|
+
$cancelNew.click()
|
106
|
+
expect($input).toHaveValue('')
|
107
|
+
})
|
108
|
+
|
109
|
+
})
|
110
|
+
|
111
|
+
})
|
112
|
+
|
113
|
+
})
|