diff --git a/js/ZeroClipboard.min.js b/js/ZeroClipboard.min.js deleted file mode 100755 index 32535fd..0000000 --- a/js/ZeroClipboard.min.js +++ /dev/null @@ -1,8 +0,0 @@ -/*! - * zeroclipboard - * The Zero Clipboard library provides an easy way to copy text to the clipboard using an invisible Adobe Flash movie, and a JavaScript interface. - * Copyright 2012 Jon Rohan, James M. Greene, . - * Released under the MIT license - * http://jonrohan.github.com/ZeroClipboard/ - * v1.1.7 - */(function(){"use strict";var a=function(a,b){var c=a.style[b];a.currentStyle?c=a.currentStyle[b]:window.getComputedStyle&&(c=document.defaultView.getComputedStyle(a,null).getPropertyValue(b));if(c=="auto"&&b=="cursor"){var d=["a"];for(var e=0;e=0?"&":"?")+"nocache="+(new Date).getTime()},i=function(a){var b=[];return a.trustedDomains&&(typeof a.trustedDomains=="string"?b.push("trustedDomain="+a.trustedDomains):b.push("trustedDomain="+a.trustedDomains.join(","))),b.join("&")},j=function(a,b){if(b.indexOf)return b.indexOf(a);for(var c=0,d=b.length;c ';b=document.createElement("div"),b.id="global-zeroclipboard-html-bridge",b.setAttribute("class","global-zeroclipboard-container"),b.setAttribute("data-clipboard-ready",!1),b.style.position="absolute",b.style.left="-9999px",b.style.top="-9999px",b.style.width="15px",b.style.height="15px",b.style.zIndex="9999",b.innerHTML=c,document.body.appendChild(b)}a.htmlBridge=b,a.flashBridge=document["global-zeroclipboard-flash-bridge"]||b.children[0].lastElementChild};l.prototype.resetBridge=function(){this.htmlBridge.style.left="-9999px",this.htmlBridge.style.top="-9999px",this.htmlBridge.removeAttribute("title"),this.htmlBridge.removeAttribute("data-clipboard-text"),f(m,this.options.activeClass),m=null,this.options.text=null},l.prototype.ready=function(){var a=this.htmlBridge.getAttribute("data-clipboard-ready");return a==="true"||a===!0},l.prototype.reposition=function(){if(!m)return!1;var a=g(m);this.htmlBridge.style.top=a.top+"px",this.htmlBridge.style.left=a.left+"px",this.htmlBridge.style.width=a.width+"px",this.htmlBridge.style.height=a.height+"px",this.htmlBridge.style.zIndex=a.zIndex+1,this.setSize(a.width,a.height)},l.dispatch=function(a,b){l.prototype._singleton.receiveEvent(a,b)},l.prototype.on=function(a,b){var c=a.toString().split(/\s/g);for(var d=0;do;o++)n[o].fn.apply(n[o].ctx,e);return this},off:function(t,e){var n=this.e||(this.e={}),o=n[t],i=[];if(o&&e)for(var r=0,c=o.length;c>r;r++)o[r].fn!==e&&o[r].fn._!==e&&i.push(o[r]);return i.length?n[t]=i:delete n[t],this}},e.exports=o},{}],8:[function(e,n,o){!function(i,r){if("function"==typeof t&&t.amd)t(["module","select"],r);else if("undefined"!=typeof o)r(n,e("select"));else{var c={exports:{}};r(c,i.select),i.clipboardAction=c.exports}}(this,function(t,e){"use strict";function n(t){return t&&t.__esModule?t:{"default":t}}function o(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}var i=n(e),r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol?"symbol":typeof t},c=function(){function t(t,e){for(var n=0;n pre").each(function(index) { - Spring.buildCopyButton($(this), index); - } - ); - } + + $("pre.highlight").each(function(index) { + Spring.buildCopyButton($(this), index); + } + ); + var errorMessage = function() { + if (/Mac/i.test(navigator.userAgent)) { + return 'Press Cmd-C to Copy'; + } + else { + return 'Press Ctrl-C to Copy'; + } + }; + var snippets = new Clipboard('.copy-button'); + snippets.on('success', function(e) { + e.clearSelection(); + Spring.showTooltip(e.trigger, "Copied!"); + }); + snippets.on('error', function(e) { + Spring.showTooltip(e.trigger, errorMessage()); + }); +} + +Spring.showTooltip = function(elem, message) { + $(elem).tooltip({placement:'right', title:message}); + $(elem).tooltip('show'); + setTimeout(function(){$(elem).tooltip('destroy');},1000); } Spring.buildCopyButton = function (preEl, id) { - var codeBlockId = "code-block-"+ id; + var codeBlockId = "code-block-"+ id; var copyButtonId = "copy-button-" + id; preEl.attr('id', codeBlockId); - var button = $(''); + var button = $(''); preEl.before(button); - var zero = new ZeroClipboard(button); - $(zero.htmlBridge).tooltip({title: "copy to clipboard", placement: 'bottom'}); } diff --git a/js/projectDocumentationWidget.js b/js/projectDocumentationWidget.js index 7475385..a52d9ba 100644 --- a/js/projectDocumentationWidget.js +++ b/js/projectDocumentationWidget.js @@ -107,9 +107,7 @@ Spring.SnippetView = Backbone.View.extend({ var html = $(this.combinedTemplate(this.model)); this.$el.html(html); - if (ZeroClipboard.detectFlashSupport()) { - Spring.buildCopyButton(html.find(":first"), "snippet"); - } + Spring.buildCopyButton(html.find(":first"), "snippet"); return this; },