| 1 |
(function () { |
| 2 |
tinymce.create('tinymce.plugins.wpforo_spoiler_button', { |
| 3 |
/** |
| 4 |
* Initializes the plugin, this will be executed after the plugin has been created. |
| 5 |
* This call is done before the editor instance has finished it's initialization so use the onInit event |
| 6 |
* of the editor instance to intercept that event. |
| 7 |
* |
| 8 |
* @param {tinymce.Editor} ed Editor instance that the plugin is initialized in. |
| 9 |
* @param {string} url Absolute URL to where the plugin is located. |
| 10 |
*/ |
| 11 |
init: function (ed, url) { |
| 12 |
|
| 13 |
function showDialog() { |
| 14 |
var data = {text: ed.selection.getContent({format: 'raw'})}; |
| 15 |
|
| 16 |
ed.windowManager.open({ |
| 17 |
title: 'Insert Spoiler', |
| 18 |
data: data, |
| 19 |
body: [{ |
| 20 |
name: 'title', |
| 21 |
type: 'textbox', |
| 22 |
label: 'Title' |
| 23 |
}], |
| 24 |
onSubmit: function (e) { |
| 25 |
data = tinymce.extend(data, e.data); |
| 26 |
ed.insertContent('[spoiler' + (data.title ? ' title="' + data.title + '"' : '') + ']' + data.text + '[/spoiler]', {format: 'bbcode'}); |
| 27 |
} |
| 28 |
}); |
| 29 |
} |
| 30 |
|
| 31 |
ed.addButton('wpf_spoil', { |
| 32 |
icon: 'pluscircle', |
| 33 |
tooltip: 'Spoiler', |
| 34 |
onclick: showDialog |
| 35 |
}); |
| 36 |
} |
| 37 |
}); |
| 38 |
|
| 39 |
// Register plugin |
| 40 |
tinymce.PluginManager.add('wpforo_spoiler_button', tinymce.plugins.wpforo_spoiler_button); |
| 41 |
})(); |