PluginProbe
Repeater Fields for Gravity Forms / 3.2.0
Repeater Fields for Gravity Forms v3.2.0
3.2.0 3.1.1 3.1.0 3.0.4 3.0.3 3.0.2 3.0.1 3.0.0 2.5.1 2.5.0 2.4.6 trunk 2.0.5 2.0.9 2.1.0 2.3.2 2.3.7 2.4.1 2.4.3 2.4.4 2.4.5
← All changes | libs/wp_repeater.js +78 -11 3.0.2 → 3.2.0 View file →
@@ -171,8 +171,17 @@
171 171 repeater.val(val_repeater + ", " + link);
172 172 }
173 173 return html.replace("onclick", "data-onclick");;
174 174 });
175 + if (window.gform && typeof window.gform.addFilter === 'function') {
176 + window.gform.addFilter('gform_datepicker_options_pre_init', function (options, formId, fieldId) {
177 + if (typeof fieldId === 'string' && fieldId.indexOf('-') > -1) {
178 + var originalFieldId = fieldId.split('-')[0];
179 + return window.gform.applyFilters('gform_datepicker_options_pre_init', options, formId, originalFieldId);
180 + }
181 + return options;
182 + }, 9);
183 + }
175 184 var repeater_fields_htmls = {};
176 185 //condition out repeater out
177 186 gform.addAction('gform_post_conditional_logic_field_action1', function (formId, action, targetId, defaultValues, isInit) {
178 187 if (targetId != "") {
@@ -342,13 +351,35 @@
342 351 } else {
343 352 $(this).attr("name", name + "__" + id_rand);
344 353 }
345 354 $(this).attr("id", id + "-" + id_rand);
355 + if ($(this).hasClass('gform-datepicker') || $(this).hasClass('datepicker')) {
356 + $(this).removeAttr('data-initialized').removeData('initialized').removeClass('hasDatepicker');
357 + if (this.dataset) {
358 + delete this.dataset.initialized;
359 + delete this.dataset.toggleClickedBeforeInit;
360 + }
361 + var $toggleBtn = $(this).siblings('.gform-datepicker-toggle');
362 + if (!$toggleBtn.length) {
363 + $toggleBtn = $(this).closest('.ginput_container_date').find('.gform-datepicker-toggle');
364 + }
365 + if ($toggleBtn.length) {
366 + $toggleBtn.attr('id', 'datepicker_toggle_' + id + '-' + id_rand);
367 + $toggleBtn.attr('aria-controls', id + '-' + id_rand);
368 + }
369 + var $kbd = $(this).siblings('#keyboardHint_' + id);
370 + if (!$kbd.length) {
371 + $kbd = $(this).closest('.ginput_container_date').find('#keyboardHint_' + id);
372 + }
373 + if ($kbd.length) {
374 + $kbd.attr('id', 'keyboardHint_' + id + '-' + id_rand);
375 + }
376 + }
346 377 var value_check = localStorage.getItem(id + "-" + id_rand);
347 378 if (type == "checkbox") {
348 379 $(this).closest("div").find("label").attr("for", id + "-" + id_rand);
349 380 if (value_check != null) {
350 - $(this).attr("checked", "checked");
381 + $(this).prop("checked", true).attr("checked", "checked");
351 382 }
352 383 } else if (type == "file") {
353 384 $(this).attr("id", id + "-" + id_rand);
354 385 } else if (type == "radio") {
@@ -357,9 +388,9 @@
357 388 var value_check = localStorage.getItem(name + "__" + id_rand);
358 389 if (value_check != null) {
359 390 var old_check = $(this).val();
360 391 if (old_check == value_check) {
361 - $(this).attr("checked", true);
392 + $(this).prop("checked", true).attr("checked", "checked");
362 393 }
363 394 }
364 395 }
365 396 else {
@@ -418,8 +449,9 @@
418 449 var header = get_repeater_data_header(start_field);
419 450 item.find(".repeater-field-header").append(header);
420 451 item.find(".repeater-field-content").append(html_field);
421 452 button.find(".repeater-field-warp-item").append(item);
453 + item.find("input[type=radio][checked], input[type=checkbox][checked]").prop("checked", true);
422 454 update_repeater_count_header();
423 455 $("input").trigger("done_load_repeater");
424 456 var form_ids = button.attr("id").split("_");
425 457 if (yeeaddons_gf_repeater_data.pro == "ok") {
@@ -487,12 +519,45 @@
487 519 conditional_logic_custom(key);
488 520 input_ids = [];
489 521 $('.gform-datepicker').each(function () {
490 522 var $element = $(this);
491 - initSingleDatepicker($element);
492 - $element.addClass('initialized');
523 + if (typeof $.fn.datepicker === 'function') {
524 + // Legacy GF < 3.0: jQuery UI datepicker available
525 + if (!$element.hasClass('hasDatepicker')) {
526 + initSingleDatepicker($element);
527 + $element.addClass('initialized');
528 + }
529 + }
493 530 });
531 + // GF 3.0+: Re-trigger datepicker initialization for the form
532 + // so GF's theme script loads the datepicker chunk and sets up delegation
533 + reinitGF3Datepicker(button);
494 534 }
535 + /**
536 + * Re-trigger GF 3.0 datepicker initialization.
537 + * GF 3.0 uses lazy-loading: the datepicker chunk is only loaded when
538 + * gform/post_render fires and .gform-datepicker elements exist in the DOM.
539 + * Since the repeater removes original fields before GF checks for them,
540 + * we need to re-dispatch the event after creating new rows.
541 + */
542 + var _gf3DatepickerTriggered = {};
543 + function reinitGF3Datepicker(el) {
544 + if (typeof $.fn.datepicker === 'function') {
545 + return; // Legacy jQuery UI datepicker is available, no need for GF 3.0 re-init
546 + }
547 + var $wrapper = el.closest('.gform_wrapper');
548 + if (!$wrapper.length) return;
549 + var formId = parseInt($wrapper.attr('id').replace('gform_wrapper_', ''));
550 + if (!formId || isNaN(formId)) return;
551 + // Only trigger once per form per page load to avoid duplicate event listeners
552 + if (_gf3DatepickerTriggered[formId]) return;
553 + _gf3DatepickerTriggered[formId] = true;
554 + // Dispatch gform/post_render so GF's theme script detects datepicker fields
555 + // and lazy-loads the accessible datepicker chunk
556 + document.dispatchEvent(new CustomEvent('gform/post_render', {
557 + detail: { formId: formId, currentPage: 1 }
558 + }));
559 + }
495 560 function yeeaddons_change_id_logic(value, key) {
496 561 var field_rules_inner = [];
497 562 if (value && value.field && Array.isArray(value.field.rules)) { // added this line to fix js issue in add more to autofill multiple data
498 563 $.each(value.field.rules, function (key_2, value_2) {
@@ -877,15 +942,17 @@
877 942 }
878 943 inputId = inputId.split('_');
879 944 // allow the user to override the datepicker options object
880 945 optionsObj = gform.applyFilters('gform_datepicker_options_pre_init', optionsObj, inputId[1], inputId[2], $element);
881 - $element.datepicker(optionsObj);
882 - // We give the input focus after selecting a date which differs from default Datepicker behavior; this prevents
883 - // users from clicking on the input again to open the datepicker. Let's add a manual click event to handle this.
884 - if ($element.is(':input')) {
885 - $element.click(function () {
886 - $element.datepicker('show');
887 - });
946 + if (typeof $element.datepicker === 'function') {
947 + $element.datepicker(optionsObj);
948 + // We give the input focus after selecting a date which differs from default Datepicker behavior; this prevents
949 + // users from clicking on the input again to open the datepicker. Let's add a manual click event to handle this.
950 + if ($element.is(':input')) {
951 + $element.click(function () {
952 + $element.datepicker('show');
953 + });
954 + }
888 955 }
889 956 }
890 957 })
891 958 $(document).on("change", ".gfield--type-repeater_end input,.gfield--type-repeater_end textarea,.gfield--type-repeater_end select", function (event) {