| 1 |
'use strict'; |
| 2 |
|
| 3 |
|
| 4 |
var CharitableCampaignElementorWidget = window.CharitableCampaignElementorWidget || ( function( document, window, $ ) { |
| 5 |
|
| 6 |
var vars = {}; |
| 7 |
|
| 8 |
var app = { |
| 9 |
|
| 10 |
init: function() { |
| 11 |
app.events(); |
| 12 |
}, |
| 13 |
|
| 14 |
events: function() { |
| 15 |
|
| 16 |
$( window ).on('elementor/frontend/init', function ( $scope ) { |
| 17 |
|
| 18 |
//elementorFrontend.hooks.addAction('frontend/element_ready/charitable_campaign.default', app.frontendWidgetInit); |
| 19 |
if( 'undefined' !== typeof elementor ){ |
| 20 |
elementor.hooks.addAction( 'panel/open_editor/widget/charitable_campaign', app.widgetPanelOpen ); |
| 21 |
} |
| 22 |
|
| 23 |
}); |
| 24 |
|
| 25 |
}, |
| 26 |
|
| 27 |
CharitableInitWidget: function() { |
| 28 |
|
| 29 |
}, |
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
frontendWidgetInit : function( $scope ){ |
| 34 |
app.CharitableInitWidget(); |
| 35 |
}, |
| 36 |
|
| 37 |
findFeedSelector: function( event ) { |
| 38 |
|
| 39 |
vars.$select = event && event.$el ? |
| 40 |
event.$el.closest( '#elementor-controls' ).find( 'select[data-setting="campaign_id"]' ) : |
| 41 |
window.parent.jQuery( '#elementor-controls select[data-setting="campaign_id"]' ); |
| 42 |
}, |
| 43 |
|
| 44 |
|
| 45 |
selectFeedInPreview : function( event ){ |
| 46 |
|
| 47 |
vars.campaignId = $( this ).val(); |
| 48 |
|
| 49 |
app.findFeedSelector(); |
| 50 |
|
| 51 |
vars.$select.val( vars.campaignId ).trigger( 'change' ); |
| 52 |
|
| 53 |
}, |
| 54 |
|
| 55 |
|
| 56 |
widgetPanelOpen: function( panel, model ) { |
| 57 |
panel.$el.find( '.elementor-control.elementor-control-campaign_id' ).find( 'select' ).on( 'change', function(){ |
| 58 |
setTimeout(function(){ |
| 59 |
app.CharitableInitWidget(); |
| 60 |
}, 4000) |
| 61 |
}); |
| 62 |
}, |
| 63 |
|
| 64 |
|
| 65 |
|
| 66 |
}; |
| 67 |
|
| 68 |
return app; |
| 69 |
|
| 70 |
|
| 71 |
|
| 72 |
}( document, window, jQuery ) ); |
| 73 |
|
| 74 |
|
| 75 |
CharitableCampaignElementorWidget.init(); |