cclaerhout
Well-known member
Wrong topicParse error: syntax error, unexpected T_STATIC in /home/hondamodif/domains/xxxxx.com/public_html/forum/library/Milano/Common/Install.php on line 31
Wrong topicParse error: syntax error, unexpected T_STATIC in /home/hondamodif/domains/xxxxx.com/public_html/forum/library/Milano/Common/Install.php on line 31
$(window).on('EditorInit', function(editor, config,textarea)
{
this.redactor = editor;
this.redactorOptions = config;
if (typeof this.redactor != 'undefined')
{
alert('found');
this.redactor.opts.buttonsCustom.fat_insertAttachment.callback = $.context(this, 'buttonCallback');
}
else {
alert('no redactor editor defined');
}
})
It is there before the redactor.js(it will be then there before the editor is loaded and would avoid any problems).
$view->createOwnTemplateObject()->addRequiredExternal('js','js/core/editorplugins.js');
$editorOptions['json']['buttons']['insert'] = array(
'title' => 'insert',
'callback' => 'foo'
);
<script src="js/xenforo/full/xenforo.js?_v=0885b55c"></script>
<script src="js/core/editorplugins.js?_v=0885b55c"></script>
<script src="js/core/editfunctions.js?_v=0885b55c"></script>
<script src="js/redactor/redactor.full.js?_v=0885b55c"></script>
<script src="js/xenforo/full/bb_code_edit.js?_v=0885b55c"></script>
yes.What about to put the event on document then? Same result?
$view->createOwnTemplateObject()->addRequiredExternal('js','js/core/editorplugins.js');
this.redactor = $textarea.data('redactor');
Would this be a good way to remove some buttons from the editor?It's a way to modify the default configuration, not to interact immediately with the Redactor API.
In the Bbm addon, to perform this I've used the editor setup listener (php), then get what the admin has selected as button configuration, put this config in a new key of the array $editorOptions['json'] (ref - see "Would this be a good way to remove some buttons from the editor?
beta: {title: 'β',callback: function(obj){obj.insertHtml('β');}}
Check the Bbm addon files, there's a php and js function that allows you to do what you're looking for (compatible with XenForo Redactor).Thanks for this tutorial @cclaerhout! I've tried to add a custom button which inserts an HTML symbol, but can't get it working (your tag buttons do though). Am I doing something wrong with this code:
Code:beta: {title: 'β',callback: function(obj){obj.insertHtml('β');}}
myCustomButton_1: {
title: 'myCustomButton_1',
tag: 'myBbCode1'
}
The easiest way should be to use the XenForo framework, but I've only seen quite limited JavaScript integration at the moment for overlays. So all depends of what you want to do. If you want to copy one existed function, just look at the XenForo source code and if you want to extend using a plugin, you can check this code ; with it you should be able to make any plugin you want using a XenForo Editor Framework event and the traditional way to create Redactor plugin.Is there an easy way (assume starting with the demo.js) to have the custom button trigger a modal where input can be inserted into the editor from such as this http://imperavi.com/redactor/examples/plugin-modal/ ?
Don't really look at the imperavi demo, since XenForo has its own framework. Just look at the file "bb_code_edit.js". For example, this part:This is not so clear to me, and looking at the source in this case doesn't help (I don't ask anything until I have tried it myself more than once) which is why I asked in the first place referencing the plugin-modal demo @ http://imperavi.com which I could not make work using your demo.js as a starting point.
Without a working example that's implementing a pre-made function such as the one here I have no frame of reference to understand what you mean and since xf already lets you easily add a button that inserts tags into the editor already, I figured that a prime value of this tutorial was to extend beyond that.
I am going to try working around tying into the editor to achieve what I need but thank you anyways.
media: {
title: this.getText('media'),
callback: $.context(this, 'getMediaModal')
}
getMediaModal: function(ed)
{
var self = this;
ed.saveSelection();
ed.modalInit(this.getText('media'), { url: this.dialogUrl + '&dialog=media' }, 600, $.proxy(function()
{
$('#redactor_insert_media_btn').click(function(e) {
e.preventDefault();
self.insertMedia(e, ed);
});
setTimeout(function() {
$('#redactor_media_link').focus();
}, 100);
}, ed));
},
&dialog=media
ed.execCommand('inserthtml', 'Your Text');
I believe this makes sense to me now (won't be sure until I try again while referencing this). Thanks for clearing it up a bit for me.Don't really look at the imperavi demo, since XenForo has its own framework. Just look at the file "bb_code_edit.js". For example, this part:
and it's callback:Code:media: { title: this.getText('media'), callback: $.context(this, 'getMediaModal') }
Code:getMediaModal: function(ed) { var self = this; ed.saveSelection(); ed.modalInit(this.getText('media'), { url: this.dialogUrl + '&dialog=media' }, 600, $.proxy(function() { $('#redactor_insert_media_btn').click(function(e) { e.preventDefault(); self.insertMedia(e, ed); }); setTimeout(function() { $('#redactor_media_link').focus(); }, 100); }, ed)); },
If you prefer to code something that looks more like the demos on the imperavi website, the previous link I gave you (ref) should help you. Note that you can extend or modify the XenForo Editor config, directly there (see data.config).
One last thing that can avoid you to waste time, the $.context function is not a jQuery default function. It's a function added by XenForo. If you want to do the same (there are may be differences, I haven't checked), use the official jQquery $.proxy function. It allows to pass the current context (like the this object in php) to the targeted function. Since jQuery has been updated in XenForo 1.2, this proxy function has become very convenient, cause you can pass arguments with it. See the official documentation for it.I believe this makes sense to me now (won't be sure until I try again while referencing this). Thanks for clearing it up a bit for me.
We use essential cookies to make this site work, and optional cookies to enhance your experience.