cck_forms 3.5.3 → 3.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a91e75ce357b6e287e833754915ed9bcf8c1c9c80497d62df870b6232f733b80
4
- data.tar.gz: 36737ba5b476046f4e44194f080ce6d5954c910df8423176be39dc583668f0d8
3
+ metadata.gz: 1ac913bdb00f008ff4928945481a137270c4002c162e96c827f2d076b4ab24fb
4
+ data.tar.gz: 6466bf72731c201e6d3386d85e3db8f42dacd12b14377bc69c616307873ececb
5
5
  SHA512:
6
- metadata.gz: d24f02ab68aefc70674270a6885de2f5f2530769c3dc7cbc794b95e4489f76a4fe9fd19e17808677ef797a9dd966e41ec51b0d9aad0b7559aa6f96d684391fc8
7
- data.tar.gz: 81887a6a4937bad555b6ce46bc2ac4099fd5b3b4fa7d1e55d17fc350cc37bd7bcd6b11262ea6bd3efab5289190b8c309cd2b84032f57d0885282532ca49920d1
6
+ metadata.gz: 36dcc060729037b66807f262eb4864fae2f8ca0d378a0bb77c20dce705ee72a9dadf109299ddd9dc1793c7545391b3fb254b3bbf2b87251b7f07c4a6c8576d62
7
+ data.tar.gz: cbf452a9e33468bf091cee8e5e02691883e3187bb2bb167f1df56da317904739b4a78369a54da02ad060e9f87ffc2e7af4de0cc6b146c967fbdde0299e1383dc
@@ -53,7 +53,7 @@ class CckForms::ParameterTypeClass::WorkHours
53
53
  met_days.reject! { |_, value| value }
54
54
 
55
55
  met_days.keys.each do |day_name|
56
- form_builder.fields_for(:value, index: day_name) { |day_builder| result << CckForms::ParameterTypeClass::WorkHours::WorkHoursDay.new(day: day_name, open_24_hours: true).build_form(day_builder) }
56
+ form_builder.fields_for(:value, index: day_name) { |day_builder| result << CckForms::ParameterTypeClass::WorkHours::WorkHoursDay.new(day: day_name, open_24_hours: false).build_form(day_builder) }
57
57
  end
58
58
 
59
59
  form_builder.fields_for(:template) do |day_builder|
@@ -226,9 +226,11 @@ class CckForms::ParameterTypeClass::WorkHours
226
226
 
227
227
  open_until_last_client_html = unless options[:hide_open_until_last_client]
228
228
  <<HTML
229
- <div class="checkbox">
230
- <label class="form_work_hours_option">#{form_builder.check_box :open_until_last_client} <nobr>#{I18n.t 'cck_forms.work_hours.until_last_client'}</nobr></label>
231
- </div>
229
+ <li class="nav-item">
230
+ <a class="nav-link">
231
+ #{form_builder.check_box :open_until_last_client} #{I18n.t 'cck_forms.work_hours.until_last_client'}
232
+ </a>
233
+ </li>
232
234
  HTML
233
235
  end
234
236
 
@@ -237,21 +239,25 @@ HTML
237
239
  <div class="form_work_hours_time">
238
240
  #{header}
239
241
  </div>
242
+ <div class="form_work_hours_time form-inline">
243
+ <div class="form_work_hours_selects">
244
+ <span class="form_work_hours_select">
245
+ <span>#{I18n.t 'cck_forms.work_hours.time_from'}</span> #{open_time_form}
246
+ </span>
247
+ <span class="form_work_hours_select">
248
+ <span>#{I18n.t 'cck_forms.work_hours.time_till'}</span> #{close_time_form}
249
+ </span>
250
+ </div>
251
+ </div>
240
252
  <div class="form_work_hours_time">
241
- <table width="100%">
242
- <tr>
243
- <td width="60%" class="form-inline">
244
- #{I18n.t 'cck_forms.work_hours.time_from'} #{open_time_form}
245
- #{I18n.t 'cck_forms.work_hours.time_till'} #{close_time_form}
246
- </td>
247
- <td width="40%">
248
- <div class="checkbox">
249
- <label class="form_work_hours_option">#{form_builder.check_box :open_24_hours} #{I18n.t 'cck_forms.work_hours.24h'}</label>
250
- </div>
251
- #{open_until_last_client_html}
252
- </td>
253
- </tr>
254
- </table>
253
+ <ul class="nav nav-pills">
254
+ <li class="nav-item">
255
+ <a class="nav-link">
256
+ #{form_builder.check_box :open_24_hours} #{I18n.t 'cck_forms.work_hours.24h'}
257
+ </a>
258
+ </li>
259
+ #{open_until_last_client_html}
260
+ </ul>
255
261
  </div>
256
262
  </div>
257
263
  HTML
@@ -1,3 +1,3 @@
1
1
  module CckForms
2
- VERSION = '3.5.3'
2
+ VERSION = '3.6.1'
3
3
  end
@@ -166,10 +166,12 @@ $(function() {
166
166
  * days are grouped by the same "work value" (checkboxes & open/close time):
167
167
  *
168
168
  * > [^] Mon [^] Tue [^] Wed [^] Thu [^] Fri [_] Sat [_] Sun
169
- * > from [09]:[00] till [20]:[00] [_] open 24 hours [_] open until last client
169
+ * > from [09]:[00] till [20]:[00]
170
+ * > [_] open 24 hours [_] open until last client
170
171
  *
171
172
  * > [_] Mon [_] Tue [_] Wed [_] Thu [_] Fri [^] Sat [^] Sun
172
- * > from [10]:[00] till [__]:[__] [_] open 24 hours [^] open until last client
173
+ * > from [10]:[00] till [__]:[__]
174
+ * > [_] open 24 hours [^] open until last client
173
175
  *
174
176
  * [ Add days ]
175
177
  *
@@ -200,7 +202,7 @@ $(function() {
200
202
  $widget.createGroup([], []);
201
203
  });
202
204
 
203
- this._lastP = $('<p></p>').appendTo($form).append($addGroupLink);
205
+ this._lastP = $('<p class="form_work_hours_add_days"></p>').appendTo($form).append($addGroupLink);
204
206
 
205
207
  this._$template = $form.find(".form_work_hours_day_template");
206
208
 
@@ -239,13 +241,17 @@ $(function() {
239
241
  var newHtml = this._$template[0].outerHTML.replace(/((?:id|name)="[^"]*)template([^"]*")/g, "$1" + this.newGroupId() + "$2");
240
242
  var $newGroup = $(newHtml);
241
243
 
242
- // mark checkboxes
244
+ // mark day checkboxes
243
245
  for(var i = 0, ic = days.length; i < ic; ++ i) {
244
- $newGroup.find("input[name$=\"[days]\"][value=" + days[i] + "]").prop("checked", true).closest(".nav-link").addClass("active");
246
+ $newGroup
247
+ .find("input[name$=\"[days]\"][value=" + days[i] + "]")
248
+ .prop("checked", true)
249
+ .closest(".nav-link").addClass("active") // Bootstrap 4
250
+ .closest(".nav-item").addClass("active"); // Bootstrap 3
245
251
  }
246
252
 
247
253
  // hide checkboxes, link-o-buttons will be in their place
248
- $newGroup.find("input[name$=\"[days]\"]").hide();
254
+ $newGroup.find("input[type=checkbox]").hide();
249
255
  $newGroup.find(".nav-pills").on("click", "a", function(event) {
250
256
  // skip events originated at checkbox inside this link
251
257
  if(event.target == this) {
@@ -262,6 +268,12 @@ $(function() {
262
268
 
263
269
  // make HTML & instantiate widget workhoursday
264
270
  $newGroup.workhoursday().workhoursday("value", value).insertBefore(this._lastP).show();
271
+
272
+ // highlight checked checkboxes
273
+ $newGroup
274
+ .find("input[name$=\"[open_24_hours]\"]:checked, input[name$=\"[open_until_last_client]\"]:checked")
275
+ .closest(".nav-link").addClass("active") // Bootstrap 4
276
+ .closest(".nav-item").addClass("active"); // Bootstrap 3
265
277
  },
266
278
 
267
279
  /**
@@ -289,7 +301,8 @@ $(function() {
289
301
  this._days[dayName].workhoursday("value", $group.workhoursday("value"));
290
302
 
291
303
  // mark the day as active
292
- input.parentNode.className += " active";
304
+ input.parentNode.className += " active"; // Bootstrap 4
305
+ input.parentNode.parentNode.className += " active"; // Bootstrap 3
293
306
 
294
307
  } else {
295
308
 
@@ -300,7 +313,8 @@ $(function() {
300
313
  if($group.find("input:checked[name$='[days]']").size() == 0) {
301
314
  $group.remove();
302
315
  } else {
303
- input.parentNode.className = input.parentNode.className.replace(/(^|\s)active($|\s)/, "$1");
316
+ input.parentNode.className = input.parentNode.className.replace(/(^|\s)active($|\s)/, "$1"); // Bootstrap 4
317
+ input.parentNode.parentNode.className = input.parentNode.parentNode.className.replace(/(^|\s)active($|\s)/, "$1"); // Bootstrap 3
304
318
  }
305
319
  }
306
320
 
@@ -324,23 +338,39 @@ $(function() {
324
338
  // open 24 hours? nullify open/close time
325
339
  case "open_24_hours":
326
340
  $group.workhoursday("openTime", {hours: '', minutes: ''}).workhoursday("closeTime", {hours: '', minutes: ''});
341
+
342
+ input.parentNode.className += " active"; // Bootstrap 4
343
+ input.parentNode.parentNode.className += " active"; // Bootstrap 3
327
344
  break;
328
345
 
329
346
  // open until last client? nullify close time
330
347
  case "open_until_last_client":
331
348
  $group.workhoursday("closeTime", {hours: '', minutes: ''});
349
+
350
+ input.parentNode.className += " active"; // Bootstrap 4
351
+ input.parentNode.parentNode.className += " active"; // Bootstrap 3
332
352
  break;
333
353
 
334
354
  // close time set? uncheck "open until last" checkbox
335
355
  case "close_time_hours":
336
356
  case "close_time_minutes":
337
357
  $group.workhoursday("openUntilLastClient", false);
358
+
359
+ $group
360
+ .find("input[name$=\"[open_until_last_client]\"]")
361
+ .closest(".nav-link").removeClass("active") // Bootstrap 4
362
+ .closest(".nav-item").removeClass("active"); // Bootstrap 3
338
363
  // break skipped on purpose!
339
364
 
340
365
  // any time set? uncheck "open 24h" checkbox
341
366
  case "open_time_hours":
342
367
  case "open_time_minutes":
343
368
  $group.workhoursday("open24Hours", false);
369
+
370
+ $group
371
+ .find("input[name$=\"[open_24_hours]\"]")
372
+ .closest(".nav-link").removeClass("active") // Bootstrap 4
373
+ .closest(".nav-item").removeClass("active"); // Bootstrap 3
344
374
  break;
345
375
  }
346
376
 
@@ -350,6 +380,13 @@ $(function() {
350
380
  $group.workhoursday(camelCasedTime, {minutes: 0})
351
381
  }
352
382
 
383
+ // input unchecked
384
+ } else if(inputNodeName == "input" && !input.checked && (fieldName == "open_24_hours" || fieldName == "open_until_last_client")) {
385
+
386
+ // remove active class
387
+ input.parentNode.className = input.parentNode.className.replace(/(^|\s)active($|\s)/, "$1"); // Bootstrap 4
388
+ input.parentNode.parentNode.className = input.parentNode.parentNode.className.replace(/(^|\s)active($|\s)/, "$1"); // Bootstrap 3
389
+
353
390
  // not input
354
391
  } else {
355
392
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cck_forms
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.5.3
4
+ version: 3.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ilya Konanykhin
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-05-06 00:00:00.000000000 Z
11
+ date: 2024-09-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -117,7 +117,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
117
117
  - !ruby/object:Gem::Version
118
118
  version: '0'
119
119
  requirements: []
120
- rubygems_version: 3.0.9
120
+ rubygems_version: 3.0.3
121
121
  signing_key:
122
122
  specification_version: 4
123
123
  summary: Content Construction Kit Forms