X-Git-Url: http://git.roojs.org/?p=roojs1;a=blobdiff_plain;f=roojs-debug.js;h=ba91ad09eead0c6570e07dc4ddd380aaf90928ad;hp=84a06ea9c1891cb96b31c126f10858cdd65458fc;hb=c3fae677247c171d616820f63a06609c27abacb3;hpb=fe420d2446bbf077df23ab1ce3159fe2cd786415 diff --git a/roojs-debug.js b/roojs-debug.js index 84a06ea9c1..ba91ad09ee 100644 --- a/roojs-debug.js +++ b/roojs-debug.js @@ -14505,7 +14505,44 @@ Roo.extend(Roo.util.ClickRepeater, Roo.util.Observable, { this.el.removeClass(this.pressClass); this.fireEvent("mouseup", this); } -});/* +});/** + * @class Roo.util.Clipboard + * @static + * + * Clipboard UTILS + * + **/ +Roo.util.Clipboard = { + /** + * Writes a string to the clipboard - using the Clipboard API if https, otherwise using text area. + * @param {String} text to copy to clipboard + */ + write : function(text) { + // navigator clipboard api needs a secure context (https) + if (navigator.clipboard && window.isSecureContext) { + // navigator clipboard api method' + navigator.clipboard.writeText(text); + return ; + } + // text area method + var ta = document.createElement("textarea"); + ta.value = text; + // make the textarea out of viewport + ta.style.position = "fixed"; + ta.style.left = "-999999px"; + ta.style.top = "-999999px"; + document.body.appendChild(ta); + ta.focus(); + ta.select(); + document.execCommand('copy'); + (function() { + ta.remove(); + }).defer(100); + + } + +} + /* * Based on: * Ext JS Library 1.1.1 * Copyright(c) 2006-2007, Ext JS, LLC.