This repository has been archived by the owner on Dec 10, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
tinymce_buttons.js
79 lines (76 loc) · 3.07 KB
/
tinymce_buttons.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
(function() {
tinymce.PluginManager.add('asciiplayerbutton', function( editor, url ) {
editor.addButton( 'asciiplayerbutton', {
text: tinyMCE_object.button_name,
icon: false,
onclick: function() {
editor.windowManager.open( {
title: tinyMCE_object.button_title,
body: [
{
type: 'textbox',
name: 'cast_url',
label: tinyMCE_object.image_title,
value: '',
classes: 'cast_url',
},
{
type: 'button',
name: 'cast_upload_button',
label: '',
text: tinyMCE_object.image_button_title,
classes: 'cast_upload_button',
},//new stuff!
{
type : 'checkbox',
name : 'autoplay',
label : 'Autoplay',
text : 'Autoplay',
checked : false
},
{
type : 'checkbox',
name : 'preload',
label : 'Preload',
text : 'Preload',
checked : true
},
{
type : 'listbox',
name : 'playersize',
label : 'Size',
values : [
{ text: 'Small', value: 'small' },
{ text: 'Medium', value: 'medium' },
{ text: 'Big', value: 'big' }
],
value : 'big' // Sets the default
},
],
onsubmit: function( e ) {
editor.insertContent( '[asciiplayer cast_url="' + e.data.cast_url + '" playersize="' + e.data.playersize + '" autoplay="' + e.data.autoplay + '" preload="' + e.data.preload + '"]');
}
});
},
});
});
})();
jQuery(document).ready(function($){
$(document).on('click', '.mce-cast_upload_button', upload_image_tinymce);
function upload_image_tinymce(e) {
e.preventDefault();
var $input_field = $('.mce-cast_url');
var custom_uploader = wp.media.frames.file_frame = wp.media({
title: 'Add Cast',
button: {
text: 'Add Cast'
},
multiple: false
});
custom_uploader.on('select', function() {
var attachment = custom_uploader.state().get('selection').first().toJSON();
$input_field.val(attachment.url);
});
custom_uploader.open();
}
});