| 1 |
/* |
| 2 |
User Submitted Posts - Plugin Settings |
| 3 |
@ https://perishablepress.com/user-submitted-posts/ |
| 4 |
*/ |
| 5 |
|
| 6 |
jQuery(document).ready(function($){ |
| 7 |
|
| 8 |
$('.default-hidden, .mm-table-wrap, .shortcode-info').hide(); |
| 9 |
|
| 10 |
// toggle all panels |
| 11 |
$('#mm-panel-toggle a').on('click', function(){ |
| 12 |
$('.toggle').slideToggle(300); |
| 13 |
return false; |
| 14 |
}); |
| 15 |
|
| 16 |
// toggle each panel |
| 17 |
$('h2').on('click', function(){ |
| 18 |
$(this).next().slideToggle(300); |
| 19 |
return false; |
| 20 |
}); |
| 21 |
|
| 22 |
// toggle form info |
| 23 |
$('.usp-custom-form').on('click', function(){ |
| 24 |
$('.usp-custom-form-info').slideDown(300); |
| 25 |
}); |
| 26 |
$('.usp-form').on('click', function(){ |
| 27 |
$('.usp-custom-form-info').slideUp(300); |
| 28 |
}); |
| 29 |
|
| 30 |
// toggle categories |
| 31 |
$('.usp-cat-toggle-link a').on('click', function(){ |
| 32 |
if ($('.usp-cat-toggle-div').is(':visible')){ |
| 33 |
$(this).text('Show categories'); |
| 34 |
} else { |
| 35 |
$(this).text('Hide categories'); |
| 36 |
} |
| 37 |
$(this).parent().toggleClass('toggle-open'); |
| 38 |
$('.usp-cat-toggle-div').toggle(300); |
| 39 |
return false; |
| 40 |
}); |
| 41 |
|
| 42 |
// toggle settings |
| 43 |
$('h3').on('click', function(){ |
| 44 |
$(this).next().slideToggle(300); |
| 45 |
$(this).toggleClass('toggle-open'); |
| 46 |
return false; |
| 47 |
}); |
| 48 |
|
| 49 |
// image uploader |
| 50 |
var custom_uploader; |
| 51 |
$('#upload_image_button').click(function(e){ |
| 52 |
e.preventDefault(); |
| 53 |
if (custom_uploader) { |
| 54 |
custom_uploader.open(); |
| 55 |
return; |
| 56 |
} |
| 57 |
custom_uploader = wp.media.frames.file_frame = wp.media({ |
| 58 |
multiple: false, |
| 59 |
library: { type: 'image' }, |
| 60 |
button: { text: 'Select Image' }, |
| 61 |
title: 'Select Default Featured Image', |
| 62 |
}); |
| 63 |
custom_uploader.on('select', function() { |
| 64 |
console.log(custom_uploader.state().get('selection').toJSON()); |
| 65 |
attachment = custom_uploader.state().get('selection').first().toJSON(); |
| 66 |
$('#upload_image').val(attachment.url); |
| 67 |
}); |
| 68 |
custom_uploader.open(); |
| 69 |
}); |
| 70 |
|
| 71 |
}); |