Adding Event listener to CKEDITOR plugin - javascript

I'm creating CKEDITOR plugin. Suppose, I have following:
CKEDITOR.plugins.add('internallink', {
icons: 'internallink',
toolbar: 'insert,100',
init: function (editor) {
editor.addCommand('internallink', new CKEDITOR.dialogCommand('internalLinkDialog'));
editor.ui.addButton('InternalLink', {
label: 'Internal link',
command: 'internallink',
toolbar: 'links'
});
CKEDITOR.dialog.add('internalLinkDialog', function (editor) {
return {
title: 'Internal link',
minWidth: 600,
minHeight: 400,
contents: [
{
id: 'tab-main',
label: 'Select page',
elements: [
{
type: 'select',
id: 'page_tree',
label: 'Select page',
items: [[1],[2],[3]],
},
]
}
],
};
});
}
});
I want a tooltip to appear while hovering one of select options.
How can I insert event listener for this?

option element doesn't have onMouseOver event.
That's it )

Related

How can I detect onChange event in TinyMCE custom plugin it?

I'm trying to develop a custom TinyMCE plugin which will load the items for a selectbox list based on the options of another selectbox list. However, I cannot figure out how to detect any even on the selectbox list.
The documentation is almost entirely useless, as it provides no mention of custom plugin options - only the boilerplate code to start off.
How can I detect an onchange event when the select lists's selection is altered?
tinymce.PluginManager.add('custom', function(editor, url) {
var openDialog = function () {
return editor.windowManager.open({
title: 'Custom',
body: {
type: 'panel',
items: [
{
type: 'selectbox',
name: 'options',
label: 'Options',
items: [
{text: 'Primary', value: 'primay style'},
{text: 'Success', value: 'success style'},
{text: 'Error', value: 'error style'}
],
onchange: function() {
alert('hi');
},
flex: true,
}, {
type: 'selectbox',
name: 'selection',
label: 'Selection',
items: [
],
flex:true,
}
]
},
buttons: [
{
type: 'cancel',
text: 'Close'
},
{
type: 'submit',
text: 'Save',
primary: true
},
],
onSubmit: function (api) {
var data = api.getData();
/* Insert content when the window form is submitted */
editor.insertContent(data);
api.close();
}
});
};
/* Add a button that opens a window */
editor.ui.registry.addButton('custom', {
text: 'Custom',
onAction: function () {
/* Open window */
openDialog();
}
});
/* Adds a menu item, which can then be included in any menu via the menu/menubar configuration
*/
editor.ui.registry.addMenuItem('custom', {
text: 'Custom',
onAction: function() {
/* Open window */
openDialog();
}
});
/* Return the metadata for the help plugin */
return {
getMetadata: function () {
return {
name: 'Example plugin',
url: 'http://exampleplugindocsurl.com'
};
}
};
});

CKEDITOR dialog - open second tab on button click

I have CKEDITOR dialog with two tabs:
- view one
- view two
Inside view one I have a button that should open view two if clicked by the user.
But I don't know how to do this. This is my CKEDITOR.dialog code:
CKEDITOR.dialog.add('placeholder', function(editor) {
var lang = editor.lang.placeholder,
generalLabel = editor.lang.common.generalTab,
validNameRegex = /^[^\[\]<>]+$/;
return {
title: 'some title',
minWidth: 300,
minHeight: 150,
contents: [{
id: 'initial-view',
label: 'view one',
title: generalLabel,
elements: [{
id: 'name-one',
style: 'width: 100%;',
type: 'html',
html: 'Organizational units'
}, {
type: 'button',
id: 'buttonId',
label: 'Click me',
title: 'My title',
setup: function(widget) {
},
onClick: function(widget) {
// this = CKEDITOR.ui.dialog.button
My code should go here........?
}
}]
}, {
id: 'organizational-unit-view',
label: 'view two',
title: generalLabel,
elements: [
// Dialog window UI elements.
{
id: 'list-of-vars',
style: 'width: 100%;',
type: 'html',
html: 'second view --- html goes here',
label: lang.name,
setup: function(widget) {
this.setValue(widget.data.name);
},
commit: function(widget) {
widget.setData('name', this.getValue());
}
}
]
}]
};
});
My question is how should I handle that button click? What method should I use? Basically how to open view two?
I found a solution. On click event is should use getDialog():
this.getDialog().selectPage('your-content-id);
Like this:
onClick: function(widget) {
this.getDialog().selectPage('organizational-unit-view');
}

Getting select's option value in onChange function of CKEDITOR's plugin

So, for example, I have CKEDITOR plugin
CKEDITOR.plugins.add('internallink', {
icons: 'internallink',
toolbar: 'insert,100',
init: function (editor) {
editor.addCommand('internallink', new CKEDITOR.dialogCommand('internalLinkDialog'));
editor.ui.addButton('InternalLink', {
label: 'Internal link',
command: 'internallink',
toolbar: 'links'
});
CKEDITOR.dialog.add('internalLinkDialog', function (editor) {
return {
title: 'Internal link',
minWidth: 600,
minHeight: 400,
contents: [
{
id: 'tab-main',
label: 'Select page',
elements: [
{
type: 'select',
id: 'page_tree',
label: 'Select page',
items: [[1],[2],[3]],
onChange: function() {
...
}
},
]
}
],
onShow: function () {
...
},
onOk: function () {
...
},
};
});
}
});
As you can see, there is select item with options.
And when I've selected one of select's options, I need to display this value.
How can I get this value in
onChange: function () {
...
}
Tell me, please, how can I do it :)
Well, the solition is:
onChange: function() {
alert( 'Current value: ' + this.getValue() );
}
http://docs.ckeditor.com/#!/api/CKEDITOR.dialog.definition.select

tinymce, get input field value from dialog box with click button on the main window

I know, no one uses tinymce in this site. Because I asked 2 question before related tinymce. No one visited the pages. But again, I have a problem. I coded like this:
editor.addButton('site_link', {
icon: 'fa-heart',
tooltip: 'Internal link',
onclick: function() {
editor.windowManager.open({
file : url + '/link.php',
width : 500,
height : 200,
title: 'Internal link',
buttons: [
{
text: "Get Link",
classes: 'widget btn primary',
id: "link",
onclick: function() {
var link = $('#bag_link').val();
alert(link);
}
},
{
id: "close",
text: 'Kapat',
onclick: 'close'
}
]
});
}
});
And the "link.php" page is like this:
When click "Get Link" button, I want to get values form elements which located in the "link.php". But I did not manage it. Could you help me ? How can I do this?
I had to wrestle through this too, but i came up with something like this.
Instead of calling the windowmanager i had the following inside the onclick function:
function showDialog()
{
var var1, var2;
// do whatever you need here
var win = tinymce.ui.Factory.create({
type: 'window',
layout: "flex",
pack: "center",
align: "center",
onClose: function() {
ed.focus();
},
onSubmit: function(e) {
var x,y,z;
e.preventDefault();
// read Field!!!!!
x = win.find('#my_content_field').value();
// Do whatever you need here
// Dialog schließen
win.close();
},
onPostRender: function(){
ed.my_control = this;
},
buttons: [
{
text: "Paste",
onclick: function() {
win.submit();
}},
{
text: "Cancel",
name: 'cancel',
disabled: false,
onclick: function() {
win.close();
}}
],
title: 'my title',
items: {
type: "form",
padding: 20,
labelGap: 30,
spacing: 10,
items: [
{
type: 'textbox',
multiline: true,
name: 'my_content_field',
value: 'standard text'
}
]
}
}).renderTo().reflow();
};

Toolbar in extjs4

I have some toolbar in my exts 4 window
this.tbar = {
xtype: 'toolbar',
items: [
{
id: "btnClearFilter",
itemId: "btnClearFilter",
action: 'delFilter',
disabled: true,
handler: function (btn, e) {
btn.setDisabled(true);
}
},
'-',
{
text: 'Export',
tooltip: 'Export',
disabled: false,
menu : {
items: [{
text: 'Export 1'
, icon: 'Content/Resources/images/Excel-16.png'
, action: 'export'
}]
}
}
]
};
From controller i can cause action delFilter like this
'ns-main-win > toolbar button[action=delFilter]': {
click: this.delFilter
},
How couse action from menu item?
I dunno what you mean, you want to trigger the action on delFilter?
Ext.getCmp('btnClearFilter').click()
Have you tried giving the menu item an id and then searching using that
'#export'{
click:this.export
}

Categories

Resources