| 1 |
( function( $ ) { |
| 2 |
// /** |
| 3 |
|
| 4 |
$( document ).ready( function() { |
| 5 |
|
| 6 |
/* control WIDTH of item in design->preview */ |
| 7 |
|
| 8 |
$('#charitable-field-options').on( 'input', '.charitable-number-slider', function( e ) { |
| 9 |
var $this = $( this ), |
| 10 |
width = parseInt( $this.val() ) > 0 ? parseInt( $this.val() ) : 0, |
| 11 |
field_id = $( this ).closest('.charitable-panel-field').data('field-id'); |
| 12 |
|
| 13 |
if ( width < 10 ) { |
| 14 |
width = 10; |
| 15 |
} else if ( width > 95 ) { |
| 16 |
width = 100; |
| 17 |
} |
| 18 |
|
| 19 |
$('.charitable-field[data-field-id="' + field_id + '"]').find('.charitable-preview-field-container').css('width', width + '%' ); |
| 20 |
|
| 21 |
} ); |
| 22 |
|
| 23 |
/* control ALIGNMENT of item in design->preview */ |
| 24 |
|
| 25 |
$('#charitable-field-options').on( 'click', 'span a', function( e ) { |
| 26 |
var $this = $( this ), |
| 27 |
alignValue = $this.data('align-value'), |
| 28 |
field_id = $( this ).closest('.charitable-panel-field').data('field-id'); |
| 29 |
|
| 30 |
$('.charitable-field[data-field-id="' + field_id + '"]').find('.charitable-preview-field-container').removeClass(function (index, className) { |
| 31 |
return (className.match (/(^|\s)charitable-preview-align-\S+/g) || []).join(' '); |
| 32 |
}).addClass('charitable-preview-align-' + alignValue); |
| 33 |
|
| 34 |
|
| 35 |
} ); |
| 36 |
|
| 37 |
/* control COLUMNS of item in design->preview */ |
| 38 |
|
| 39 |
$('#charitable-field-options').on( 'change', '.charitable-campaign-builder-preview-columns select', function( e ) { |
| 40 |
|
| 41 |
var $this = $( this ), |
| 42 |
selectedValue = $this.val(), |
| 43 |
field_id = $( this ).closest('.charitable-panel-field').data('field-id'); |
| 44 |
|
| 45 |
$('.charitable-field[data-field-id="' + field_id + '"]').find('.charitable-preview-field-container').removeClass(function (index, className) { |
| 46 |
return (className.match (/(^|\s)charitable-preview-columns-\S+/g) || []).join(' '); |
| 47 |
}).addClass('charitable-preview-columns-' + selectedValue); |
| 48 |
|
| 49 |
|
| 50 |
} ); |
| 51 |
|
| 52 |
|
| 53 |
} ); |
| 54 |
|
| 55 |
})( jQuery ); |