| 1 |
(function ( $ ) { |
| 2 |
|
| 3 |
// EDIT |
| 4 |
|
| 5 |
// On click ct save, show spinner |
| 6 |
$("#publishing-action #ct-save").on("click", function(e) { |
| 7 |
var $this = $(this); |
| 8 |
|
| 9 |
if( $this.prop('disabled') === true ) { |
| 10 |
return; |
| 11 |
} |
| 12 |
|
| 13 |
$this.closest('#publishing-action').find('.spinner').addClass('is-active'); |
| 14 |
$this.hide(); |
| 15 |
$this.closest('#publishing-action').find('#ct-save-disabled').show(); |
| 16 |
}); |
| 17 |
|
| 18 |
// On click ct add, show spinner |
| 19 |
$("#ct_add_form #ct-add").on("click", function(e) { |
| 20 |
var $this = $(this); |
| 21 |
|
| 22 |
if( $this.prop('disabled') === true ) { |
| 23 |
return; |
| 24 |
} |
| 25 |
|
| 26 |
var any_error = false; |
| 27 |
|
| 28 |
$this.closest('form').find('input[required="1"]').each(function() { |
| 29 |
var field = $(this); |
| 30 |
|
| 31 |
if( field.val() === '' ) { |
| 32 |
field.parent().addClass('form-required form-invalid'); |
| 33 |
any_error = true; |
| 34 |
} |
| 35 |
}) |
| 36 |
|
| 37 |
if( any_error ) { |
| 38 |
return; |
| 39 |
} |
| 40 |
|
| 41 |
$this.closest('.submit').find('.spinner').addClass('is-active'); |
| 42 |
$this.hide(); |
| 43 |
$this.closest('.submit').find('#ct-add-disabled').show(); |
| 44 |
}); |
| 45 |
|
| 46 |
$("body").on("keyup", ".form-required.form-invalid input, .form-required.form-invalid textarea", function(e) { |
| 47 |
$(this).parent().removeClass('form-required'); |
| 48 |
$(this).parent().removeClass('form-invalid'); |
| 49 |
}); |
| 50 |
|
| 51 |
})( jQuery ); |