Sync plugins from current page

Signed-off-by: Adrian Nöthlich <git@promasu.tech>
This commit is contained in:
2019-09-11 19:08:46 +02:00
parent 85d41e4216
commit 8515ff9587
1847 changed files with 505469 additions and 0 deletions

View File

@@ -0,0 +1,68 @@
(function($, undefined){
var Field = acf.Field.extend({
type: 'radio',
events: {
'click input[type="radio"]': 'onClick',
},
$control: function(){
return this.$('.acf-radio-list');
},
$input: function(){
return this.$('input:checked');
},
$inputText: function(){
return this.$('input[type="text"]');
},
getValue: function(){
var val = this.$input().val();
if( val === 'other' && this.get('other_choice') ) {
val = this.$inputText().val();
}
return val;
},
onClick: function( e, $el ){
// vars
var $label = $el.parent('label');
var selected = $label.hasClass('selected');
var val = $el.val();
// remove previous selected
this.$('.selected').removeClass('selected');
// add active class
$label.addClass('selected');
// allow null
if( this.get('allow_null') && selected ) {
$label.removeClass('selected');
$el.prop('checked', false).trigger('change');
val = false;
}
// other
if( this.get('other_choice') ) {
// enable
if( val === 'other' ) {
this.$inputText().prop('disabled', false);
// disable
} else {
this.$inputText().prop('disabled', true);
}
}
}
});
acf.registerFieldType( Field );
})(jQuery);