Changeset 3035121
- Timestamp:
- 02/13/2024 01:33:54 PM (5 months ago)
- Location:
- acf-rrule-field
- Files:
-
- 6 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
acf-rrule-field/tags/1.4.2/acf-rrule.php
r3023435 r3035121 5 5 Plugin URI: https://github.com/marcbelletre/acf-rrule 6 6 Description: Create recurring rules with a single ACF field 7 Version: 1.4. 17 Version: 1.4. 8 8 Author: Marc Bellêtre 9 9 Author URI: https://pixelparfait.fr … … 45 45 // - these will be passed into the field class. 46 46 $this->settings = [ 47 'version' => '1.4. 1',47 'version' => '1.4.', 48 48 'url' => plugin_dir_url(__FILE__), 49 49 'path' => plugin_dir_path(__FILE__), -
acf-rrule-field/tags/1.4.2/assets/js/input.js
r2497275 r3035121 1 (function ($){1 (function{ 2 2 3 4 5 6 7 8 3 9 4 /** 5 * initialize_field 6 * 7 * This function will initialize the $field. 8 * 9 * @date 30/11/17 10 * @since 5.6.5 11 * 12 * @param n/a 13 * @return n/a 14 */ 10 field.$el.find('.acf-field[data-frequency], .freq-suffix[data-frequency]').each(function () { 11 if ($(this).data('frequency') != freq) { 12 $(this).hide(); 13 } else { 14 $(this).show(); 15 } 16 }); 17 } 15 18 16 function initialize_field( $field ) { 19 const selectEndType = function ($input) { 20 var type = $input.val(); 17 21 18 $field.find('.frequency-select').on('change', function () { 19 var freq = $(this).val(); 22 field.$el.find('.acf-field[data-end-type]').each(function () { 23 if ($(this).data('end-type') != type) { 24 $(this).hide(); 25 } else { 26 $(this).show(); 27 } 28 }); 29 } 20 30 21 $field.find('.acf-field[data-frequency], .freq-suffix[data-frequency]').each(function () { 22 if ($(this).data('frequency') != freq) { 23 $(this).hide(); 24 } else { 25 $(this).show(); 26 } 27 }); 28 }).trigger('change'); 31 const selectMonthlyBy = function ($input) { 32 var parent = $input.closest('.acf-field'); 33 var value = $input.val() ? $input.val() : "''"; 29 34 30 $field.find('.end-type-select').on('change', function () { 31 var type = $(this).val(); 35 parent.find('.acf-input').addClass('is-disabled'); 36 parent.find('.acf-input[data-monthly-by=' + value + ']').removeClass('is-disabled'); 37 } 32 38 33 $field.find('.acf-field[data-end-type]').each(function () { 34 if ($(this).data('end-type') != type) { 35 $(this).hide(); 36 } else { 37 $(this).show(); 38 } 39 }); 40 }).trigger('change'); 39 field.$el.find('.frequency-select').on('change', function () { 40 selectFrequency($(this)); 41 }); 41 42 42 $field.find('.monthly-by-options').on('change', 'input[type=radio]', function () { 43 var parent = $(this).closest('.acf-field'); 43 field.$el.find('.end-type-select').on('change', function () { 44 selectEndType($(this)); 45 }); 44 46 45 parent.find('.acf-input').addClass('is-disabled'); 46 parent.find('.acf-input[data-monthly-by=' + $(this).val() + ']').removeClass('is-disabled');47 47 field.$el.find('.monthly-by-options').on('change', 'input[type=radio]', function () { 48 ); 49 }); 48 50 49 } 51 selectFrequency(field.$el.find('.frequency-select')); 52 selectEndType(field.$el.find('.end-type-select')); 53 selectMonthlyBy(field.$el.find('.monthly-by-options')); 54 } 50 55 56 57 58 59 51 60 52 if( typeof acf.add_action !== 'undefined' ) { 61 var Field = acf.Field.extend({ 62 type: 'button_group_multiple', 63 events: { 64 'click input[type="checkbox"]': 'onClick' 65 }, 66 $control: function () { 67 return this.$('.acf-button-group'); 68 }, 69 $input: function () { 70 return this.$('input:checked'); 71 }, 72 setValue: function (val) { 73 this.$('input[value="' + val + '"]').prop('checked', true).trigger('change'); 74 }, 75 onClick: function (e, $el) { 76 var $label = $el.parent('label'); 53 77 54 /* 55 * ready & append (ACF5) 56 * 57 * These two events are called when a field element is ready for initizliation. 58 * - ready: on page load similar to $(document).ready() 59 * - append: on new DOM elements appended via repeater field or other AJAX calls 60 * 61 * @param n/a 62 * @return n/a 63 */ 78 // Toggle active class 79 if ($el.prop('checked')) { 80 $label.addClass('selected'); 81 } else { 82 $label.removeClass('selected'); 83 } 84 } 85 }); 64 86 65 acf.add_action('ready_field/type=rrule', initialize_field); 66 acf.add_action('append_field/type=rrule', initialize_field); 67 68 69 } else { 70 71 /* 72 * acf/setup_fields (ACF4) 73 * 74 * This single event is called when a field element is ready for initialization. 75 * 76 * @param event an event object. This can be ignored 77 * @param element An element which contains the new HTML 78 * @return n/a 79 */ 80 81 $(document).on('acf/setup_fields', function(e, postbox){ 82 83 // find all relevant fields 84 $(postbox).find('.field[data-field_type="rrule"]').each(function(){ 85 86 // initialize 87 initialize_field( $(this) ); 88 89 }); 90 91 }); 92 93 } 87 acf.registerFieldType(Field); 94 88 95 89 })(jQuery); 96 97 (function($, undefined){98 99 var Field = acf.Field.extend({100 101 type: 'button_group_multiple',102 103 events: {104 'click input[type="checkbox"]': 'onClick'105 },106 107 $control: function(){108 return this.$('.acf-button-group');109 },110 111 $input: function(){112 return this.$('input:checked');113 },114 115 setValue: function( val ){116 this.$('input[value="' + val + '"]').prop('checked', true).trigger('change');117 },118 119 onClick: function( e, $el ){120 121 // vars122 var $label = $el.parent('label');123 124 // toggle active class125 if ($el.prop('checked')) {126 $label.addClass('selected');127 } else {128 $label.removeClass('selected');129 }130 }131 });132 133 acf.registerFieldType( Field );134 135 })(jQuery); -
acf-rrule-field/tags/1.4.2/readme.txt
r3023435 r3035121 5 5 Tested up to: 6.3 6 6 Requires PHP: 7.2 7 Stable tag: 1.4. 17 Stable tag: 1.4. 8 8 License: GPLv2 or later 9 9 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 31 31 32 32 == Changelog == 33 34 35 33 36 34 37 = 1.4.1 = -
acf-rrule-field/trunk/acf-rrule.php
r3023435 r3035121 5 5 Plugin URI: https://github.com/marcbelletre/acf-rrule 6 6 Description: Create recurring rules with a single ACF field 7 Version: 1.4. 17 Version: 1.4. 8 8 Author: Marc Bellêtre 9 9 Author URI: https://pixelparfait.fr … … 45 45 // - these will be passed into the field class. 46 46 $this->settings = [ 47 'version' => '1.4. 1',47 'version' => '1.4.', 48 48 'url' => plugin_dir_url(__FILE__), 49 49 'path' => plugin_dir_path(__FILE__), -
acf-rrule-field/trunk/assets/js/input.js
r2497275 r3035121 1 (function ($){1 (function{ 2 2 3 4 5 6 7 8 3 9 4 /** 5 * initialize_field 6 * 7 * This function will initialize the $field. 8 * 9 * @date 30/11/17 10 * @since 5.6.5 11 * 12 * @param n/a 13 * @return n/a 14 */ 10 field.$el.find('.acf-field[data-frequency], .freq-suffix[data-frequency]').each(function () { 11 if ($(this).data('frequency') != freq) { 12 $(this).hide(); 13 } else { 14 $(this).show(); 15 } 16 }); 17 } 15 18 16 function initialize_field( $field ) { 19 const selectEndType = function ($input) { 20 var type = $input.val(); 17 21 18 $field.find('.frequency-select').on('change', function () { 19 var freq = $(this).val(); 22 field.$el.find('.acf-field[data-end-type]').each(function () { 23 if ($(this).data('end-type') != type) { 24 $(this).hide(); 25 } else { 26 $(this).show(); 27 } 28 }); 29 } 20 30 21 $field.find('.acf-field[data-frequency], .freq-suffix[data-frequency]').each(function () { 22 if ($(this).data('frequency') != freq) { 23 $(this).hide(); 24 } else { 25 $(this).show(); 26 } 27 }); 28 }).trigger('change'); 31 const selectMonthlyBy = function ($input) { 32 var parent = $input.closest('.acf-field'); 33 var value = $input.val() ? $input.val() : "''"; 29 34 30 $field.find('.end-type-select').on('change', function () { 31 var type = $(this).val(); 35 parent.find('.acf-input').addClass('is-disabled'); 36 parent.find('.acf-input[data-monthly-by=' + value + ']').removeClass('is-disabled'); 37 } 32 38 33 $field.find('.acf-field[data-end-type]').each(function () { 34 if ($(this).data('end-type') != type) { 35 $(this).hide(); 36 } else { 37 $(this).show(); 38 } 39 }); 40 }).trigger('change'); 39 field.$el.find('.frequency-select').on('change', function () { 40 selectFrequency($(this)); 41 }); 41 42 42 $field.find('.monthly-by-options').on('change', 'input[type=radio]', function () { 43 var parent = $(this).closest('.acf-field'); 43 field.$el.find('.end-type-select').on('change', function () { 44 selectEndType($(this)); 45 }); 44 46 45 parent.find('.acf-input').addClass('is-disabled'); 46 parent.find('.acf-input[data-monthly-by=' + $(this).val() + ']').removeClass('is-disabled');47 47 field.$el.find('.monthly-by-options').on('change', 'input[type=radio]', function () { 48 ); 49 }); 48 50 49 } 51 selectFrequency(field.$el.find('.frequency-select')); 52 selectEndType(field.$el.find('.end-type-select')); 53 selectMonthlyBy(field.$el.find('.monthly-by-options')); 54 } 50 55 56 57 58 59 51 60 52 if( typeof acf.add_action !== 'undefined' ) { 61 var Field = acf.Field.extend({ 62 type: 'button_group_multiple', 63 events: { 64 'click input[type="checkbox"]': 'onClick' 65 }, 66 $control: function () { 67 return this.$('.acf-button-group'); 68 }, 69 $input: function () { 70 return this.$('input:checked'); 71 }, 72 setValue: function (val) { 73 this.$('input[value="' + val + '"]').prop('checked', true).trigger('change'); 74 }, 75 onClick: function (e, $el) { 76 var $label = $el.parent('label'); 53 77 54 /* 55 * ready & append (ACF5) 56 * 57 * These two events are called when a field element is ready for initizliation. 58 * - ready: on page load similar to $(document).ready() 59 * - append: on new DOM elements appended via repeater field or other AJAX calls 60 * 61 * @param n/a 62 * @return n/a 63 */ 78 // Toggle active class 79 if ($el.prop('checked')) { 80 $label.addClass('selected'); 81 } else { 82 $label.removeClass('selected'); 83 } 84 } 85 }); 64 86 65 acf.add_action('ready_field/type=rrule', initialize_field); 66 acf.add_action('append_field/type=rrule', initialize_field); 67 68 69 } else { 70 71 /* 72 * acf/setup_fields (ACF4) 73 * 74 * This single event is called when a field element is ready for initialization. 75 * 76 * @param event an event object. This can be ignored 77 * @param element An element which contains the new HTML 78 * @return n/a 79 */ 80 81 $(document).on('acf/setup_fields', function(e, postbox){ 82 83 // find all relevant fields 84 $(postbox).find('.field[data-field_type="rrule"]').each(function(){ 85 86 // initialize 87 initialize_field( $(this) ); 88 89 }); 90 91 }); 92 93 } 87 acf.registerFieldType(Field); 94 88 95 89 })(jQuery); 96 97 (function($, undefined){98 99 var Field = acf.Field.extend({100 101 type: 'button_group_multiple',102 103 events: {104 'click input[type="checkbox"]': 'onClick'105 },106 107 $control: function(){108 return this.$('.acf-button-group');109 },110 111 $input: function(){112 return this.$('input:checked');113 },114 115 setValue: function( val ){116 this.$('input[value="' + val + '"]').prop('checked', true).trigger('change');117 },118 119 onClick: function( e, $el ){120 121 // vars122 var $label = $el.parent('label');123 124 // toggle active class125 if ($el.prop('checked')) {126 $label.addClass('selected');127 } else {128 $label.removeClass('selected');129 }130 }131 });132 133 acf.registerFieldType( Field );134 135 })(jQuery); -
acf-rrule-field/trunk/readme.txt
r3023435 r3035121 5 5 Tested up to: 6.3 6 6 Requires PHP: 7.2 7 Stable tag: 1.4. 17 Stable tag: 1.4. 8 8 License: GPLv2 or later 9 9 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 31 31 32 32 == Changelog == 33 34 35 33 36 34 37 = 1.4.1 =
Note: See TracChangeset
for help on using the changeset viewer.