Нет описания

admin-editor.js 1.4KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. ;(function($){
  2. $(function(){
  3. // Close modal
  4. var wpformsModalClose = function() {
  5. if ( $('#wpforms-modal-select-form').length ) {
  6. $('#wpforms-modal-select-form').get(0).selectedIndex = 0;
  7. $('#wpforms-modal-checkbox-title, #wpforms-modal-checkbox-description').prop('checked', false);
  8. }
  9. $('#wpforms-modal-backdrop, #wpforms-modal-wrap').css('display','none');
  10. $( document.body ).removeClass( 'modal-open' );
  11. };
  12. // Open modal when media button is clicked
  13. $(document).on('click', '.wpforms-insert-form-button', function(event) {
  14. event.preventDefault();
  15. $('#wpforms-modal-backdrop, #wpforms-modal-wrap').css('display','block');
  16. $( document.body ).addClass( 'modal-open' );
  17. });
  18. // Close modal on close or cancel links
  19. $(document).on('click', '#wpforms-modal-close, #wpforms-modal-cancel a', function(event) {
  20. event.preventDefault();
  21. wpformsModalClose();
  22. });
  23. // Insert shortcode into TinyMCE
  24. $(document).on('click', '#wpforms-modal-submit', function(event) {
  25. event.preventDefault();
  26. var shortcode;
  27. shortcode = '[wpforms id="' + $('#wpforms-modal-select-form').val() + '"';
  28. if ( $('#wpforms-modal-checkbox-title').is(':checked') ) {
  29. shortcode = shortcode+' title="true"';
  30. }
  31. if ( $('#wpforms-modal-checkbox-description').is(':checked') ) {
  32. shortcode = shortcode+' description="true"';
  33. }
  34. shortcode = shortcode+']';
  35. wp.media.editor.insert(shortcode);
  36. wpformsModalClose();
  37. });
  38. });
  39. }(jQuery));