main
Last change
on this file was d24f17c, checked in by Aleksandar Panovski <apano77@…>, 15 months ago |
Initial commit
|
-
Property mode
set to
100644
|
File size:
605 bytes
|
Rev | Line | |
---|
[d24f17c] | 1 | (function () {
|
---|
| 2 |
|
---|
| 3 | if (typeof Prism === 'undefined' || typeof document === 'undefined' || !document.querySelector) {
|
---|
| 4 | return;
|
---|
| 5 | }
|
---|
| 6 |
|
---|
| 7 | Prism.plugins.toolbar.registerButton('download-file', function (env) {
|
---|
| 8 | var pre = env.element.parentNode;
|
---|
| 9 | if (!pre || !/pre/i.test(pre.nodeName) || !pre.hasAttribute('data-src') || !pre.hasAttribute('data-download-link')) {
|
---|
| 10 | return;
|
---|
| 11 | }
|
---|
| 12 | var src = pre.getAttribute('data-src');
|
---|
| 13 | var a = document.createElement('a');
|
---|
| 14 | a.textContent = pre.getAttribute('data-download-link-label') || 'Download';
|
---|
| 15 | a.setAttribute('download', '');
|
---|
| 16 | a.href = src;
|
---|
| 17 | return a;
|
---|
| 18 | });
|
---|
| 19 |
|
---|
| 20 | }());
|
---|
Note:
See
TracBrowser
for help on using the repository browser.