PluginProbe
WP Ultimate Post Grid / 2.2
WP Ultimate Post Grid v2.2
4.1.1 trunk 1.5 1.6 1.7 1.7.1 1.7.2 1.8 1.9 2.0 2.1 2.2 2.3 2.4.0 2.5.0 2.6.0 2.7.0 2.8.0 2.8.2 3.0.0 3.3.0 3.4.0 3.5.0 3.6.0 3.7.0 All 32 releases
wp-ultimate-post-grid / js / admin_post.js

admin_post.js in WP Ultimate Post Grid 2.2, at js/admin_post.js

61 lines 2.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 jQuery(document).ready(function ($) {
2 jQuery('#wpupg_add_custom_image').on('click', function(e) {
3 e.preventDefault();
4
5 var button = jQuery(this);
6 var input_url = button.parents('#wpupg_form_post').find('#wpupg_custom_image');
7 var input_id = button.parents('#wpupg_form_post').find('#wpupg_custom_image_id');
8
9 if(typeof wp.media == 'function') {
10 var custom_uploader = wp.media({
11 title: 'Insert Media',
12 button: {
13 text: 'Set Custom Image'
14 },
15 multiple: false
16 })
17 .on('select', function() {
18 var attachment = custom_uploader.state().get('selection').first().toJSON();
19 input_url.val(attachment.url);
20 input_id.val(attachment.id);
21 })
22 .open();
23 }
24 });
25
26 jQuery('#wpupg_custom_image').on('keyup change', function() {
27 jQuery(this).siblings('#wpupg_custom_image_id').val('');
28 });
29
30 jQuery('.term-custom-image').on('click', '#wpupg_custom_image_button.button-add', function (e) {
31 console.log(wp.media);
32 if(typeof wp.media == 'function') {
33 var custom_uploader = wp.media({
34 title: wpupg_admin_post.text_add_grid_image,
35 button: {
36 text: wpupg_admin_post.text_add_grid_image
37 },
38 multiple: false
39 })
40 .on('select', function() {
41 var attachment = custom_uploader.state().get('selection').first().toJSON();
42 jQuery('#wpupg_custom_image_img').attr('src', attachment.url);
43 jQuery('#wpupg_custom_image').val(attachment.id);
44 jQuery('#wpupg_custom_image_button')
45 .removeClass('button-add')
46 .addClass('button-remove')
47 .val(wpupg_admin_post.text_remove_grid_image);
48 })
49 .open();
50 }
51 });
52
53 jQuery('.term-custom-image').on('click', '#wpupg_custom_image_button.button-remove', function (e) {
54 jQuery('#wpupg_custom_image_img').attr('src', '');
55 jQuery('#wpupg_custom_image').val('');
56 jQuery('#wpupg_custom_image_button')
57 .removeClass('button-remove')
58 .addClass('button-add')
59 .val(wpupg_admin_post.text_add_grid_image);
60 });
61 });