forked from snowdreams1006/gitbook-plugin-copyright
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplugin.js
More file actions
30 lines (25 loc) · 859 Bytes
/
Copy pathplugin.js
File metadata and controls
30 lines (25 loc) · 859 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
require(["gitbook", "jQuery"], function(gitbook, $) {
gitbook.events.bind('start', function (e, config) {
var conf = config['edit-link'];
var label = conf.label;
var base = conf.base;
var lang = gitbook.state.innerLanguage;
if (lang) {
// label can be a unique string for multi-languages site
if (typeof label === 'object') label = label[lang];
lang = lang + '/';
}
// Add slash at the end if not present
if (base.slice(-1) != "/") {
base = base + "/";
}
gitbook.toolbar.createButton({
icon: 'fa fa-edit',
text: label,
onClick: function() {
var filepath = gitbook.state.filepath;
window.open(base + lang + filepath);
}
});
});
});