On Thursday, August 1, 2013 6:13:25 AM UTC-7, Clemens wrote:
Hi.
How can I add custom buttons to the wiki toolbar which appears above the
text area when editing tickets and wiki pages?
RjOllos, 05.08.2013 19:55:
The functionality is defined in wikitoolbar.js, (1) and should be fairly
easy to extend. I'm minimally proficient in JavaScript and jQuery, so I'll
suggest one way it could probably be done, but there may be better ways. In
fact, someone might know of a way we could modify Trac so that it is easier
to add buttons.
1. Put the JavaScript code at the of this message in
$env/site/wikitoolbar_extensions.js
2. Put the Python code at the end of this message in
$env/plugins/wikitoolbar_extensions.py
Hello List, Hello RjOllos.
I got your code working for wiki-editing and also tuned some CSS to the
additional wiki-toolbar button look nice, see my other post. Thanks for
the help.
However; I have a problem, if everything runs on the ticket-view instead
simple wiki-edit.
The additional button is added 2x times to the edit-comment toolbar and
0x to the edit-description toolbar.
The ticket-view has two "wikitext" text areas:
- One for adding comment:
<textarea id="comment" class="wikitext trac-resizable" ...>
- Another one for editing the ticket description:
<textarea id="field-description" class="wikitext trac-resizable" ...>
It seems that somehow the Java-Script code below operates 2x times on
the one toolbar and 0x times on the other one.
How can we solve this?
I do not have enough Java Script knowledge to find the answer. Any help
is welcome. I can send the full code to everybody who is willing to help me.
Thanks
Clemens
---------------------------------------
(function($) {
window.extendWikiFormattingToolbar = function(textarea) {
if ((document.selection == undefined)
&& (textarea.setSelectionRange == undefined)) {
return;
}
var toolbar = $("div.wikitoolbar").get(0);
function addButton(id, title, fn) {
SNIP SNIP SNIP
function encloseSelection(prefix, suffix) {
SNIP SNIP SNIP
addButton("pageoutline", _("Page Outline"), function() {
encloseSelection("[[PageOutline(", ")]");
});
}
})(jQuery);
jQuery(document).ready(function($) {
$("textarea.wikitext").each(function() {
extendWikiFormattingToolbar(this) });
});
--
You received this message because you are subscribed to the Google Groups "Trac
Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/trac-users.
For more options, visit https://groups.google.com/groups/opt_out.