PluginProbe
Fast Chat Button / trunk
Fast Chat Button vtrunk
trunk 1.0.0 1.0.1 1.1.0 1.1.1 2.0.0 2.1.0 2.1.1
fast-chat-button / include / scripts.php

scripts.php in Fast Chat Button trunk, at include/scripts.php

57 lines 2.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly ?>
2 <script>
3
4 jQuery("document").ready(function($) {
5
6 // ==================================================
7 // Dealing with uploading images
8 // ==================================================
9
10 $('.yydev_upload_image, .yydev_light_img_bg').click(function(e) {
11
12 var uploadButtonParent = $(this).parent();
13
14 e.preventDefault();
15 var image = wp.media({
16 title: 'Upload Image'}).open()
17 .on('select', function(e){
18
19 // This will return the selected image from the Media Uploader, the result is an object
20 var images_length = image.state().get("selection").length;
21 var images = image.state().get("selection").models;
22
23 console.log(images);
24
25 var image_url = images[0].toJSON().url;
26 var image_alt = images[0].toJSON().alt;
27 var image_caption = images[0].toJSON().caption;
28 var image_title = images[0].toJSON().title;
29 var image_id = images[0].toJSON().id;
30
31 // Let's assign the url value to the input field
32 uploadButtonParent.find('.yydev_light_img_bg').attr('src', image_url); // changing image icon
33 uploadButtonParent.find('.yydev_image_input').val(image_url); // changing input url
34
35 }); // .on('select', function(e){
36
37 }); // $('.edit-button-image-upload').click(function(e) {
38
39 // ==================================================
40 // Changing the url when changing chat type
41 // ==================================================
42
43 $('.yydevelopment-btn-chat .chat_button_type').on('change', function() {
44
45 var imgURL = $(this).val();
46 if( imgURL === 'custom') {
47 $(".yydev_upload_image").trigger("click");
48 } else {
49 $(".yydevelopment-btn-chat img.yydev_light_img_bg").attr("src", imgURL);
50 $(".yydevelopment-btn-chat .yydev_image_input").val(imgURL);
51 }
52
53 }); // $('input#background_color').change(function() {
54
55 }); // jQuery("document").ready(function($) {
56
57 </script>