| 1 |
(function() { |
| 2 |
|
| 3 |
tinymce.PluginManager.add( 'sh_cd_tinymce_button', function( editor, url ) { |
| 4 |
|
| 5 |
editor.addButton( 'sh_cd_tinymce_button', { |
| 6 |
title: sh_cd_tinymce[ 'button-text' ], |
| 7 |
image: sh_cd_tinymce[ 'button-image' ], |
| 8 |
type: 'menubutton', |
| 9 |
icon: false, |
| 10 |
menu: [ |
| 11 |
{ |
| 12 |
text: 'Your shortcodes', |
| 13 |
onclick: function() { |
| 14 |
sh_cd_tinymce_popup( editor, sh_cd_tinymce[ 'values-your' ] ); |
| 15 |
} |
| 16 |
}, |
| 17 |
{ |
| 18 |
text: 'Premade shortcodes', |
| 19 |
onclick: function() { |
| 20 |
sh_cd_tinymce_popup( editor, sh_cd_tinymce[ 'values-premade' ] ); |
| 21 |
} |
| 22 |
} |
| 23 |
] |
| 24 |
}); |
| 25 |
}); |
| 26 |
|
| 27 |
/** |
| 28 |
* Render pop up |
| 29 |
* @param editor |
| 30 |
* @param values |
| 31 |
*/ |
| 32 |
function sh_cd_tinymce_popup( editor, values ) { |
| 33 |
|
| 34 |
editor.windowManager.open( { |
| 35 |
title: sh_cd_tinymce[ 'dialog-title' ], |
| 36 |
width: 400, |
| 37 |
height:80, |
| 38 |
body: [ |
| 39 |
{ |
| 40 |
type: 'listbox', |
| 41 |
width: 400, |
| 42 |
name: 'shortcode', |
| 43 |
label: sh_cd_tinymce[ 'dialog-label' ], |
| 44 |
'values': values |
| 45 |
} |
| 46 |
], |
| 47 |
onsubmit: function( e ) { |
| 48 |
editor.insertContent( e.data.shortcode ); |
| 49 |
} |
| 50 |
}); |
| 51 |
} |
| 52 |
|
| 53 |
})(); |