Feature #23980 » 0004-Support-jsToolbar.patch
| lib/redmine/wiki_formatting/common_mark/helper.rb | ||
|---|---|---|
|
"var wikiImageMimeTypes = #{Redmine::MimeType.by_type('image').to_json};" \
|
||
|
"var userHlLanguages = #{lang.to_json};"
|
||
|
) +
|
||
|
stylesheet_link_tag('jstoolbar')
|
||
|
stylesheet_link_tag('jstoolbar') +
|
||
|
preload_icon_link('jstoolbar')
|
||
|
end
|
||
|
@heads_for_wiki_formatter_included = true
|
||
|
end
|
||
| lib/redmine/wiki_formatting/markdown/helper.rb | ||
|---|---|---|
|
"var wikiImageMimeTypes = #{Redmine::MimeType.by_type('image').to_json};" \
|
||
|
"var userHlLanguages = #{lang.to_json};"
|
||
|
) +
|
||
|
stylesheet_link_tag('jstoolbar')
|
||
|
stylesheet_link_tag('jstoolbar') +
|
||
|
preload_icon_link('jstoolbar')
|
||
|
end
|
||
|
@heads_for_wiki_formatter_included = true
|
||
|
end
|
||
| lib/redmine/wiki_formatting/textile/helper.rb | ||
|---|---|---|
|
javascript_tag(
|
||
|
"var wikiImageMimeTypes = #{Redmine::MimeType.by_type('image').to_json};" \
|
||
|
"var userHlLanguages = #{lang.to_json};") +
|
||
|
stylesheet_link_tag('jstoolbar')
|
||
|
stylesheet_link_tag('jstoolbar') +
|
||
|
preload_icon_link('jstoolbar')
|
||
|
end
|
||
|
@heads_for_wiki_formatter_included = true
|
||
|
end
|
||
| public/javascripts/jstoolbar/jstoolbar.js | ||
|---|---|---|
|
return;
|
||
|
}
|
||
|
var link = document.getElementById('jstoolbar_icon_path');
|
||
|
this.iconUrl = link !== null ? link.getAttribute('href') : null;
|
||
|
this.textarea = textarea;
|
||
|
this.toolbarBlock = document.createElement('div');
|
||
| ... | ... | |
|
this.scope = scope || null;
|
||
|
this.className = className || null;
|
||
|
}
|
||
|
jsButton.prototype.draw = function() {
|
||
|
jsButton.prototype.draw = function(icons = undefined) {
|
||
|
if (!this.scope) return null;
|
||
|
var button = document.createElement('button');
|
||
| ... | ... | |
|
span.appendChild(document.createTextNode(this.title));
|
||
|
button.appendChild(span);
|
||
|
if (icons) {
|
||
|
var icon = icons[this.className];
|
||
|
if (icon) {
|
||
|
var svgicon = createSVGIcon(icons[this.className]);
|
||
|
button.appendChild(svgicon);
|
||
|
}
|
||
|
button.classList.add('toolbar-svg')
|
||
|
}
|
||
|
if (this.icon != undefined) {
|
||
|
button.style.backgroundImage = 'url('+this.icon+')';
|
||
|
}
|
||
| ... | ... | |
|
}
|
||
|
},
|
||
|
draw: function(mode) {
|
||
|
const This = this
|
||
|
if (this.iconUrl) {
|
||
|
fetch(this.iconUrl, {
|
||
|
method: 'GET'
|
||
|
})
|
||
|
.then(function(res) {
|
||
|
res.json().then(function(data) {
|
||
|
This._draw(mode, data);
|
||
|
})
|
||
|
});
|
||
|
} else {
|
||
|
This._draw(mode);
|
||
|
}
|
||
|
},
|
||
|
_draw: function(mode, icons = undefined) {
|
||
|
this.setMode(mode);
|
||
|
// Empty toolbar
|
||
| ... | ... | |
|
if (!disabled && typeof this[b.type] == 'function') {
|
||
|
tool = this[b.type](i);
|
||
|
if (tool) newTool = tool.draw();
|
||
|
if (tool) newTool = tool.draw(icons);
|
||
|
if (newTool) {
|
||
|
this.toolNodes[i] = newTool; //mémorise l'accès DOM pour usage éventuel ultérieur
|
||
|
this.toolbar.appendChild(newTool);
|
||
| public/stylesheets/jstoolbar.css | ||
|---|---|---|
|
/* Buttons
|
||
|
-------------------------------------------------------- */
|
||
|
.jstb_strong {
|
||
|
.jstb_strong:not(.toolbar-svg) {
|
||
|
background-image: url(../images/jstoolbar/bt_strong.png);
|
||
|
}
|
||
|
.jstb_em {
|
||
|
.jstb_em:not(.toolbar-svg) {
|
||
|
background-image: url(../images/jstoolbar/bt_em.png);
|
||
|
}
|
||
|
.jstb_ins {
|
||
|
.jstb_ins:not(.toolbar-svg) {
|
||
|
background-image: url(../images/jstoolbar/bt_ins.png);
|
||
|
}
|
||
|
.jstb_del {
|
||
|
.jstb_del:not(.toolbar-svg) {
|
||
|
background-image: url(../images/jstoolbar/bt_del.png);
|
||
|
}
|
||
|
.jstb_code {
|
||
|
.jstb_code:not(.toolbar-svg) {
|
||
|
background-image: url(../images/jstoolbar/bt_code.png);
|
||
|
}
|
||
|
.jstb_h1 {
|
||
|
.jstb_h1:not(.toolbar-svg) {
|
||
|
background-image: url(../images/jstoolbar/bt_h1.png);
|
||
|
}
|
||
|
.jstb_h2 {
|
||
|
.jstb_h2:not(.toolbar-svg) {
|
||
|
background-image: url(../images/jstoolbar/bt_h2.png);
|
||
|
}
|
||
|
.jstb_h3 {
|
||
|
.jstb_h3:not(.toolbar-svg) {
|
||
|
background-image: url(../images/jstoolbar/bt_h3.png);
|
||
|
}
|
||
|
.jstb_ul {
|
||
|
.jstb_ul:not(.toolbar-svg) {
|
||
|
background-image: url(../images/jstoolbar/bt_ul.png);
|
||
|
}
|
||
|
.jstb_ol {
|
||
|
.jstb_ol:not(.toolbar-svg) {
|
||
|
background-image: url(../images/jstoolbar/bt_ol.png);
|
||
|
}
|
||
|
.jstb_tl {
|
||
|
.jstb_tl:not(.toolbar-svg) {
|
||
|
background-image: url(../images/jstoolbar/bt_tl.png);
|
||
|
}
|
||
|
.jstb_bq {
|
||
|
.jstb_bq:not(.toolbar-svg) {
|
||
|
background-image: url(../images/jstoolbar/bt_bq.png);
|
||
|
}
|
||
|
.jstb_unbq {
|
||
|
.jstb_unbq:not(.toolbar-svg) {
|
||
|
background-image: url(../images/jstoolbar/bt_bq_remove.png);
|
||
|
}
|
||
|
.jstb_pre {
|
||
|
.jstb_pre:not(.toolbar-svg) {
|
||
|
background-image: url(../images/jstoolbar/bt_pre.png);
|
||
|
}
|
||
|
.jstb_precode {
|
||
|
.jstb_precode:not(.toolbar-svg) {
|
||
|
background-image: url(../images/jstoolbar/bt_precode.png);
|
||
|
}
|
||
|
.jstb_link {
|
||
|
.jstb_link:not(.toolbar-svg) {
|
||
|
background-image: url(../images/jstoolbar/bt_link.png);
|
||
|
}
|
||
|
.jstb_img {
|
||
|
.jstb_img:not(.toolbar-svg) {
|
||
|
background-image: url(../images/jstoolbar/bt_img.png);
|
||
|
}
|
||
|
.jstb_table {
|
||
|
.jstb_table:not(.toolbar-svg) {
|
||
|
background-image: url(../images/jstoolbar/bt_table.png);
|
||
|
}
|
||
|
.jstb_help {
|
||
|
.jstb_help:not(.toolbar-svg) {
|
||
|
background-image: url(../images/help.png);
|
||
|
}
|
||
|
.toolbar-svg svg {
|
||
|
fill: #666;
|
||
|
margin-right: 4px;
|
||
|
}
|
||
|
button.toolbar-svg {
|
||
|
color: #666;
|
||
|
margin-right: 4px;
|
||
|
padding-left: 1px;
|
||
|
}
|
||
|
.jstb_code.toolbar-svg::before {
|
||
|
content: "C";
|
||
|
font-size: 15px;
|
||
|
font-weight: 700;
|
||
|
}
|
||
|
.jstb_h1.toolbar-svg::before {
|
||
|
content: "H1";
|
||
|
padding-left: 2px;
|
||
|
font-size: 12px;
|
||
|
font-weight: 700;
|
||
|
}
|
||
|
.jstb_h2.toolbar-svg::before {
|
||
|
content: "H2";
|
||
|
padding-left: 2px;
|
||
|
font-size: 12px;
|
||
|
font-weight: 700;
|
||
|
}
|
||
|
.jstb_h3.toolbar-svg::before {
|
||
|
content: "H3";
|
||
|
padding-left: 2px;
|
||
|
font-size: 12px;
|
||
|
font-weight: 700;
|
||
|
}
|
||
|
.jstb_pre.toolbar-svg::before {
|
||
|
padding: 0px 0px 3px 0px;
|
||
|
content: "pre";
|
||
|
font-size: 12px;
|
||
|
font-weight: 700;
|
||
|
}
|
||