by Ange Tuteur July 7th 2015, 12:22 pm
@Michael_vx and
@Sir. Mayo,
This is absolutely possible by setting a new command for the editor. Here's an example I'll give you which will do just that :
Administration Panel > Modules > JavaScript codes management > Create a new script
Placement : In all the pages
Paste the following script :
- Code:
$(function() {
if (!$.sceditor) return;
$.sceditor.command.set('messages', {
dropDown : function(editor, caller, callback) {
var messages = {
'Title' : 'Message content',
'Hello' : 'Good day !',
'Goodbye' : 'See you !'
},
a, d = document.createElement('DIV'), i;
for (i in messages) {
a = document.createElement('A');
a.className = 'sceditor-font-option';
a.title = messages[i];
a.innerHTML = i;
a.onclick = function() {
callback(this.title);
editor.closeDropDown(true);
return false;
};
d.appendChild(a);
}
editor.createDropDown(caller, 'messages', d);
},
exec : function(c) {
var e = this;
$.sceditor.command.get('messages').dropDown(e, c, function(content) {
e.insertText(content);
});
},
txtExec : function(c) {
var e = this;
$.sceditor.command.get('messages').dropDown(e, c, function(content) {
e.insertText(content);
});
},
tooltip : 'Preset messages'
});
toolbar += '|messages'
});
To change the messages you will need to modify the
messages object, which is shown below :
- Code:
var messages = {
'Title' : 'Message content',
'Hello' : 'Good day !',
'Goodbye' : 'See you !'
},
These are set in
TITLE : MESSAGE pairs. To add more message presets, simply add a comma after the last pair and create a new pair. ( title : message )
Once done, you'll have a new button to insert preset messages.
Par default the button image is the youtube icon. That can be changed by using the following CSS rule, and replacing
IMAGE by the image of your button.
- Code:
.sceditor-button-messages div {
background-image:url('IMAGE') !important;
}
Have a good day, and see you.
Last edited by Ange Tuteur on July 10th 2015, 10:39 am; edited 1 time in total