Skip to content

Instantly share code, notes, and snippets.

@OlegShchavelev
Last active May 3, 2020 23:15
Show Gist options
  • Save OlegShchavelev/8e7454ad7cf5dc0ede75b6b0ee563319 to your computer and use it in GitHub Desktop.
Save OlegShchavelev/8e7454ad7cf5dc0ede75b6b0ee563319 to your computer and use it in GitHub Desktop.
Кнопка для TinyMCE
tinymce.PluginManager.add('showcase', function (editor, url) {
// Add a button that opens a window
editor.addButton('showcase', {
text: 'Вставить витрину товаров',
icon: false,
onclick: function () {
// Open window
editor.windowManager.open({
title: 'Параметры витрины товаров',
minWidth: 500,
body: [
{
type: 'textbox',
name: 'parent',
label: 'Parent ID',
tooltip: 'Укажите ID категории',
},
{
type: 'textbox',
name: 'resource',
label: 'Resource ID',
tooltip: 'Укажите ID товаров через запятую',
},
{
type: 'textbox',
name: 'limit',
label: 'Limit',
tooltip: 'Укажите лимит выборки товаров',
},
],
onsubmit: function (e) {
// Check parent value
if (e.data.parent.length != 0) {
var parent = ' parent="' + e.data.parent + '"';
}
else {
var parent = '';
}
// Check resource value
if (e.data.resource.length != 0) {
var resource = ' resource="' + e.data.resource + '"';
}
else {
var resource = '';
}
// Check limit value
if (e.data.limit.length != 0) {
var limit = ' limit="' + e.data.limit + '"';
}
else {
var limit = '';
}
// Insert content when the window form is submitted
editor.insertContent('' +
'[showcase'
+ parent
+ resource
+ limit
+ ']'
);
}
});
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment