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
admin-foogallery-editor.js
105 lines
| 1 | // |
| 2 | |
| 3 | (function(FOOGALLERY, $, undefined) { |
| 4 | |
| 5 | FOOGALLERY.loadGalleries = function() { |
| 6 | $('.foogallery-modal-wrapper .spinner').addClass('is-active'); |
| 7 | $('.foogallery-modal-reload').hide(); |
| 8 | var data = 'action=foogallery_load_galleries' + |
| 9 | '&foogallery_load_galleries=' + $('#foogallery_load_galleries').val() + |
| 10 | '&_wp_http_referer=' + encodeURIComponent($('input[name="_wp_http_referer"]').val()); |
| 11 | |
| 12 | $.ajax({ |
| 13 | type: "POST", |
| 14 | url: ajaxurl, |
| 15 | data: data, |
| 16 | success: function(data) { |
| 17 | $('.foogallery-attachment-container').html(data); |
| 18 | FOOGALLERY.clearSelection(); |
| 19 | }, |
| 20 | complete: function() { |
| 21 | $('.foogallery-modal-wrapper .spinner').removeClass('is-active'); |
| 22 | $('.foogallery-modal-reload').show(); |
| 23 | } |
| 24 | }); |
| 25 | }; |
| 26 | |
| 27 | //hook up the extensions search |
| 28 | FOOGALLERY.bindEditorButton = function() { |
| 29 | $(document.body).on('click', '.foogallery-modal-trigger', function(e) { |
| 30 | e.preventDefault(); |
| 31 | //set the active editor |
| 32 | FOOGALLERY.activeEditor = $(this).data('editor'); |
| 33 | $('.foogallery-modal-wrapper').show(); |
| 34 | if ( $('.foogallery-modal-loading').length ) { |
| 35 | FOOGALLERY.loadGalleries(); |
| 36 | } else { |
| 37 | FOOGALLERY.clearSelection(); |
| 38 | } |
| 39 | }); |
| 40 | }; |
| 41 | |
| 42 | FOOGALLERY.bindModalElements = function() { |
| 43 | $(document.body).on('click', '.media-modal-close, .foogallery-modal-cancel', function(e) { |
| 44 | $('.foogallery-modal-wrapper').hide(); |
| 45 | }); |
| 46 | |
| 47 | $(document.body).on('click', '.foogallery-modal-reload', function(e) { |
| 48 | e.preventDefault(); |
| 49 | FOOGALLERY.loadGalleries(); |
| 50 | }); |
| 51 | |
| 52 | $(document.body).on('click', '.foogallery-gallery-select', function(e) { |
| 53 | var $this = $(this); |
| 54 | if ( $this.is('.foogallery-add-gallery') ) { |
| 55 | //if the add icon is click then do nothing |
| 56 | return; |
| 57 | } else { |
| 58 | $('.foogallery-gallery-select').removeClass('selected'); |
| 59 | $(this).addClass('selected'); |
| 60 | FOOGALLERY.changeSelection(); |
| 61 | } |
| 62 | }); |
| 63 | |
| 64 | $(document.body).on('click', '.foogallery-modal-insert', function(e) { |
| 65 | e.preventDefault(); |
| 66 | if ( $(this).attr('disabled') ) { |
| 67 | return; |
| 68 | } |
| 69 | var shortcode_tag = window.FOOGALLERY_SHORTCODE || 'foogallery', |
| 70 | shortcode = '[' + shortcode_tag + ' id="' + $('.foogallery-gallery-select.selected').data('foogallery-id') + '"]'; |
| 71 | |
| 72 | var editor = tinyMCE.get(FOOGALLERY.activeEditor); |
| 73 | if (editor) { |
| 74 | editor.execCommand('mceInsertContent', false, shortcode); |
| 75 | } else { |
| 76 | wp.media.editor.insert(shortcode); |
| 77 | } |
| 78 | |
| 79 | $('.foogallery-modal-wrapper').hide(); |
| 80 | }); |
| 81 | }; |
| 82 | |
| 83 | FOOGALLERY.changeSelection = function() { |
| 84 | var selected = $('.foogallery-gallery-select.selected'); |
| 85 | if (selected.length) { |
| 86 | $('.foogallery-modal-insert').removeAttr('disabled'); |
| 87 | } else { |
| 88 | $('.foogallery-modal-insert').attr('disabled', 'disabled'); |
| 89 | } |
| 90 | }; |
| 91 | |
| 92 | FOOGALLERY.clearSelection = function() { |
| 93 | $('.foogallery-gallery-select').removeClass('selected'); |
| 94 | FOOGALLERY.changeSelection(); |
| 95 | }; |
| 96 | |
| 97 | $(function() { //wait for ready |
| 98 | }); |
| 99 | |
| 100 | FOOGALLERY.bindEditorButton(); |
| 101 | FOOGALLERY.bindModalElements(); |
| 102 | FOOGALLERY.activeEditor = 'content'; |
| 103 | |
| 104 | }(window.FOOGALLERY = window.FOOGALLERY || {}, jQuery)); |
| 105 |