_acf-blocks.js
1 year ago
_acf-field-flexible-content.js
1 year ago
_acf-field-gallery.js
1 year ago
_acf-field-repeater.js
1 year ago
_acf-jsx-names.js
1 year ago
_acf-setting-clone.js
1 year ago
_acf-setting-flexible-content.js
1 year ago
_acf-setting-repeater.js
1 year ago
_acf-ui-options-page.js
1 year ago
acf-pro-blocks.js
1 year ago
acf-pro-field-group.js
1 year ago
acf-pro-input.js
1 year ago
acf-pro-ui-options-page.js
1 year ago
_acf-setting-repeater.js
55 lines
| 1 | ( function ( $ ) { |
| 2 | /* |
| 3 | * Repeater |
| 4 | * |
| 5 | * This field type requires some extra logic for its settings |
| 6 | * |
| 7 | * @type function |
| 8 | * @date 24/10/13 |
| 9 | * @since ACF 5.0.0 |
| 10 | * |
| 11 | * @param n/a |
| 12 | * @return n/a |
| 13 | */ |
| 14 | |
| 15 | var RepeaterCollapsedFieldSetting = acf.FieldSetting.extend( { |
| 16 | type: 'repeater', |
| 17 | name: 'collapsed', |
| 18 | events: { |
| 19 | 'focus select': 'onFocus', |
| 20 | }, |
| 21 | onFocus: function ( e, $el ) { |
| 22 | // vars |
| 23 | var $select = $el; |
| 24 | |
| 25 | // collapsed |
| 26 | var choices = []; |
| 27 | |
| 28 | // keep 'null' choice |
| 29 | choices.push( { |
| 30 | label: $select.find( 'option[value=""]' ).text(), |
| 31 | value: '', |
| 32 | } ); |
| 33 | |
| 34 | // find sub fields |
| 35 | var $list = this.fieldObject.$( '.acf-field-list:first' ); |
| 36 | var fields = acf.getFieldObjects( { |
| 37 | list: $list, |
| 38 | } ); |
| 39 | |
| 40 | // loop |
| 41 | fields.map( function ( field ) { |
| 42 | choices.push( { |
| 43 | label: field.prop( 'label' ), |
| 44 | value: field.prop( 'key' ), |
| 45 | } ); |
| 46 | } ); |
| 47 | |
| 48 | // render |
| 49 | acf.renderSelect( $select, choices ); |
| 50 | }, |
| 51 | } ); |
| 52 | |
| 53 | acf.registerFieldSetting( RepeaterCollapsedFieldSetting ); |
| 54 | } )( jQuery ); |
| 55 |