admin-foogallery-attachment-autosave.js
1 day ago
admin-foogallery-divi.js
1 day ago
admin-foogallery-edit.js
1 day ago
admin-foogallery-editor.js
1 day ago
admin-foogallery-elementor.js
1 day ago
admin-page-foogallery-extensions-modal.js
1 day ago
admin-page-foogallery-extensions.js
1 day ago
admin-page-foogallery-settings.js
1 day ago
admin-tinymce.js
1 day ago
admin-uploader.js
1 day ago
foogallery-command-palette.js
1 day ago
foogallery.admin.datasources.js
1 day ago
foogallery.admin.min.js
1 day ago
foogallery.admin.template.js
1 day ago
foogallery.admin.datasources.js
84 lines
| 1 | jQuery(function ($) { |
| 2 | $('.gallery_datasources_button').on('click', function(e) { |
| 3 | e.preventDefault(); |
| 4 | $('.foogallery-datasources-modal-wrapper').show(); |
| 5 | }); |
| 6 | |
| 7 | $('.foogallery-datasources-modal-wrapper').on('click', '.media-modal-close, .foogallery-datasource-modal-cancel', function(e) { |
| 8 | $('.foogallery-datasources-modal-wrapper').hide(); |
| 9 | }); |
| 10 | |
| 11 | $('.foogallery-datasources-modal-wrapper').on('click', '.foogallery-datasource-modal-insert', function(e) { |
| 12 | var activeDatasource = $('.foogallery-datasource-modal-selector.active').data('datasource'); |
| 13 | |
| 14 | //set the datasource |
| 15 | $('#foogallery_datasource').val( activeDatasource ); |
| 16 | $('#_foogallery_datasource_recovery_original, #_foogallery_datasource_recovery_value').val(''); |
| 17 | |
| 18 | //raise a general event so that other datasources can clean up |
| 19 | $(document).trigger('foogallery-datasource-changed', activeDatasource); |
| 20 | |
| 21 | //raise a specific event for the new datasource so that things can be done |
| 22 | $(document).trigger('foogallery-datasource-changed-' + activeDatasource); |
| 23 | |
| 24 | //hide the datasource modal |
| 25 | $('.foogallery-datasources-modal-wrapper').hide(); |
| 26 | }); |
| 27 | |
| 28 | $('.foogallery-datasources-modal-wrapper').on('click', '.foogallery-datasource-modal-reload', function(e) { |
| 29 | e.preventDefault(); |
| 30 | |
| 31 | var $wrapper = $('.foogallery-datasources-modal-wrapper'), |
| 32 | datasource = $wrapper.data('datasource'), |
| 33 | $content = $('.foogallery-datasource-modal-container-inner.' + datasource); |
| 34 | |
| 35 | $content.addClass('not-loaded'); |
| 36 | |
| 37 | //force the refresh |
| 38 | $('.foogallery-datasource-modal-selector.active').click(); |
| 39 | }); |
| 40 | |
| 41 | $('.foogallery-datasource-modal-selector').on('click', function(e) { |
| 42 | e.preventDefault(); |
| 43 | |
| 44 | var datasource = $(this).data('datasource'), |
| 45 | $content = $('.foogallery-datasource-modal-container-inner.' + datasource), |
| 46 | $wrapper = $('.foogallery-datasources-modal-wrapper'); |
| 47 | |
| 48 | $('.foogallery-datasource-modal-selector').removeClass('active'); |
| 49 | $(this).addClass('active'); |
| 50 | |
| 51 | $('.foogallery-datasource-modal-container-inner').hide(); |
| 52 | |
| 53 | $content.show(); |
| 54 | |
| 55 | var datasource_value = $('#_foogallery_datasource_value').val(); |
| 56 | |
| 57 | if ( $content.hasClass('not-loaded') ) { |
| 58 | $content.find('.spinner').addClass('is-active'); |
| 59 | |
| 60 | $content.removeClass('not-loaded'); |
| 61 | |
| 62 | var data = 'action=foogallery_load_datasource_content' + |
| 63 | '&datasource=' + datasource + |
| 64 | '&datasource_value=' + encodeURIComponent(datasource_value) + |
| 65 | '&foogallery_id=' + $wrapper.data('foogalleryid') + |
| 66 | '&nonce=' + $wrapper.data('nonce'); |
| 67 | |
| 68 | $.ajax({ |
| 69 | type: "POST", |
| 70 | url: ajaxurl, |
| 71 | data: data, |
| 72 | success: function(data) { |
| 73 | $('.foogallery-datasource-modal-reload').show(); |
| 74 | $wrapper.data('datasource', datasource ); |
| 75 | |
| 76 | $content.html(data); |
| 77 | //raise a event so that datasource-specific code can run |
| 78 | $(document).trigger('foogallery-datasource-content-loaded-' + datasource); |
| 79 | } |
| 80 | }); |
| 81 | } |
| 82 | }); |
| 83 | }); |
| 84 |