mirror of
https://github.com/meineerde/redmine.git
synced 2025-12-19 15:01:14 +00:00
Inline code highlighting toolbar button (#14937).
git-svn-id: http://svn.redmine.org/redmine/trunk@15316 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
ffa4dd00f6
commit
a3b188762a
BIN
public/images/jstoolbar/bt_precode.png
Normal file
BIN
public/images/jstoolbar/bt_precode.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 389 B |
File diff suppressed because one or more lines are too long
@ -372,3 +372,24 @@ jsToolBar.prototype.resizeDragStop = function(event) {
|
|||||||
document.removeEventListener('mousemove', this.dragMoveHdlr, false);
|
document.removeEventListener('mousemove', this.dragMoveHdlr, false);
|
||||||
document.removeEventListener('mouseup', this.dragStopHdlr, false);
|
document.removeEventListener('mouseup', this.dragStopHdlr, false);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* Code highlighting menu */
|
||||||
|
jsToolBar.prototype.precodeMenu = function(fn){
|
||||||
|
var codeRayLanguages = ["c", "clojure", "cpp", "css", "delphi", "diff", "erb", "go", "groovy", "haml", "html", "java", "javascript", "json", "lua", "php", "python", "ruby", "sass", "sql", "text", "xml", "yaml"];
|
||||||
|
var menu = $("<ul style='position:absolute;'></ul>");
|
||||||
|
for (var i = 0; i < codeRayLanguages.length; i++) {
|
||||||
|
$("<li></li>").text(codeRayLanguages[i]).appendTo(menu).mousedown(function(){
|
||||||
|
fn($(this).text());
|
||||||
|
});
|
||||||
|
}
|
||||||
|
$("body").append(menu);
|
||||||
|
menu.menu().width(150).position({
|
||||||
|
my: "left top",
|
||||||
|
at: "left bottom",
|
||||||
|
of: this.toolNodes['precode']
|
||||||
|
});
|
||||||
|
$(document).on("mousedown", function() {
|
||||||
|
menu.remove();
|
||||||
|
});
|
||||||
|
return false;
|
||||||
|
};
|
||||||
|
|||||||
@ -7,6 +7,7 @@ jsToolBar.strings['Code'] = 'Inline Code';
|
|||||||
jsToolBar.strings['Heading 1'] = 'Heading 1';
|
jsToolBar.strings['Heading 1'] = 'Heading 1';
|
||||||
jsToolBar.strings['Heading 2'] = 'Heading 2';
|
jsToolBar.strings['Heading 2'] = 'Heading 2';
|
||||||
jsToolBar.strings['Heading 3'] = 'Heading 3';
|
jsToolBar.strings['Heading 3'] = 'Heading 3';
|
||||||
|
jsToolBar.strings['Highlighted code'] = 'Highlighted code';
|
||||||
jsToolBar.strings['Unordered list'] = 'Unordered list';
|
jsToolBar.strings['Unordered list'] = 'Unordered list';
|
||||||
jsToolBar.strings['Ordered list'] = 'Ordered list';
|
jsToolBar.strings['Ordered list'] = 'Ordered list';
|
||||||
jsToolBar.strings['Quote'] = 'Quote';
|
jsToolBar.strings['Quote'] = 'Quote';
|
||||||
|
|||||||
@ -170,6 +170,20 @@ jsToolBar.prototype.elements.pre = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Code highlighting
|
||||||
|
jsToolBar.prototype.elements.precode = {
|
||||||
|
type: 'button',
|
||||||
|
title: 'Highlighted code',
|
||||||
|
fn: {
|
||||||
|
wiki: function() {
|
||||||
|
var This = this;
|
||||||
|
this.precodeMenu(function(lang){
|
||||||
|
This.encloseLineSelection('~~~ ' + lang + '\n', '\n~~~\n');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// spacer
|
// spacer
|
||||||
jsToolBar.prototype.elements.space4 = {type: 'space'}
|
jsToolBar.prototype.elements.space4 = {type: 'space'}
|
||||||
|
|
||||||
|
|||||||
@ -179,6 +179,20 @@ jsToolBar.prototype.elements.pre = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Code highlighting
|
||||||
|
jsToolBar.prototype.elements.precode = {
|
||||||
|
type: 'button',
|
||||||
|
title: 'Highlighted code',
|
||||||
|
fn: {
|
||||||
|
wiki: function() {
|
||||||
|
var This = this;
|
||||||
|
this.precodeMenu(function(lang){
|
||||||
|
This.encloseLineSelection('<pre><code class="' + lang + '">\n', '\n</code></pre>\n');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// spacer
|
// spacer
|
||||||
jsToolBar.prototype.elements.space4 = {type: 'space'}
|
jsToolBar.prototype.elements.space4 = {type: 'space'}
|
||||||
|
|
||||||
|
|||||||
@ -89,6 +89,9 @@
|
|||||||
.jstb_pre {
|
.jstb_pre {
|
||||||
background-image: url(../images/jstoolbar/bt_pre.png);
|
background-image: url(../images/jstoolbar/bt_pre.png);
|
||||||
}
|
}
|
||||||
|
.jstb_precode {
|
||||||
|
background-image: url(../images/jstoolbar/bt_precode.png);
|
||||||
|
}
|
||||||
.jstb_link {
|
.jstb_link {
|
||||||
background-image: url(../images/jstoolbar/bt_link.png);
|
background-image: url(../images/jstoolbar/bt_link.png);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user