-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathcontent-cards-button.js
57 lines (57 loc) · 2.31 KB
/
content-cards-button.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
( function() {
tinymce.PluginManager.add( 'contentcards', function( editor, url ) {
editor.addButton( 'contentcards_shortcode', {
image: contentcards.icon,
onclick: function() {
var win = editor.windowManager.open( {
title: contentcards.texts.add_dialog_title,
bodyType: 'tabpanel',
body: [{
type: 'form',
title: contentcards.texts.main_label,
items: [{
type: 'textbox',
name: 'url',
label: contentcards.texts.link_label,
},
{
type: 'checkbox',
name: 'target',
label: contentcards.texts.target_label,
text: contentcards.texts.target_text,
checked:false
}
],
},{
type: 'form',
title: contentcards.texts.advanced_label,
items: [{
type: 'textbox',
name: 'class',
label: contentcards.texts.class_label,
},{
type: 'textbox',
name: 'word_limit',
label: contentcards.texts.wordlimit_label,
}
],
}],
onsubmit: function( e ) {
var result = win.toJSON();
var atts = '';
for ( var key in result ) {
if ( !result[key] ) {
continue;
}
if ( 'target' === key ) {
result[key] = '_blank';
}
atts += ' ' + key + '="' + result[key] + '"';
}
editor.insertContent( '[contentcards' + atts + '] ' );
}
} );
}
} );
} );
} )();