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 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
| !function (e, t, a) { var initCopyCode = function(){ var copyHtml = ''; copyHtml += '<button class="btn-copy" data-clipboard-snippet="">'; copyHtml += ' <i class="fa fa-copy"></i><span>Copy</span>'; copyHtml += '</button>'; $(".highlight .code pre").before(copyHtml); var clipboard = new ClipboardJS('.btn-copy', { target: function(trigger) { return trigger.nextElementSibling; } }); clipboard.on('success', function(e) { console.info('Action:', e.action); console.info('Text:', e.text); console.info('Trigger:', e.trigger); success_prompt(COPY_SUCCESS); e.clearSelection(); }); clipboard.on('error', function(e) { console.error('Action:', e.action); console.error('Trigger:', e.trigger); fail_prompt(COPY_FAILURE); }); } initCopyCode(); }(window, document);
var prompt = function (message, style, time){ style = (style === undefined) ? 'alert-success' : style; time = (time === undefined) ? 1500 : time*1000; $('<div>') .appendTo('body') .addClass('alert ' + style) .html(message) .show() .delay(time) .fadeOut(); };
var success_prompt = function(message, time){ prompt(message, 'alert-success', time); };
var fail_prompt = function(message, time){ prompt(message, 'alert-danger', time); };
var warning_prompt = function(message, time){ prompt(message, 'alert-warning', time); };
var info_prompt = function(message, time){ prompt(message, 'alert-info', time); };
|