UNPKG

imdone

Version:

A task board and wiki in one!

9 lines 15.4 kB
/*! * ZeroClipboard * The ZeroClipboard library provides an easy way to copy text to the clipboard using an invisible Adobe Flash movie and a JavaScript interface. * Copyright (c) 2014 Jon Rohan, James M. Greene * Licensed MIT * http://zeroclipboard.org/ * v1.3.0-beta.1 */ !function(){"use strict";function a(a){return a.replace(/,/g,".").replace(/[^0-9\.]/g,"")}function b(b){return parseFloat(a(b))>=10}var c,d={bridge:null,version:"0.0.0",noflash:null,wrongflash:null,ready:null},e={},f=0,g={},h=0,i={},j=function(){var a=/\-([a-z])/g,b=function(a,b){return b.toUpperCase()};return function(c){return c.replace(a,b)}}(),k=function(a,b){var c,d,e;return window.getComputedStyle?c=window.getComputedStyle(a,null).getPropertyValue(b):(d=j(b),c=a.currentStyle?a.currentStyle[d]:a.style[d]),"cursor"!==b||c&&"auto"!==c||(e=a.tagName.toLowerCase(),"a"!==e)?c:"pointer"},l=function(a){a||(a=window.event);var b;this!==window?b=this:a.target?b=a.target:a.srcElement&&(b=a.srcElement),F.activate(b)},m=function(a,b,c){a&&1===a.nodeType&&(a.addEventListener?a.addEventListener(b,c,!1):a.attachEvent&&a.attachEvent("on"+b,c))},n=function(a,b,c){a&&1===a.nodeType&&(a.removeEventListener?a.removeEventListener(b,c,!1):a.detachEvent&&a.detachEvent("on"+b,c))},o=function(a,b){if(!a||1!==a.nodeType)return a;if(a.classList)return a.classList.contains(b)||a.classList.add(b),a;if(b&&"string"==typeof b){var c=(b||"").split(/\s+/);if(1===a.nodeType)if(a.className){for(var d=" "+a.className+" ",e=a.className,f=0,g=c.length;g>f;f++)d.indexOf(" "+c[f]+" ")<0&&(e+=" "+c[f]);a.className=e.replace(/^\s+|\s+$/g,"")}else a.className=b}return a},p=function(a,b){if(!a||1!==a.nodeType)return a;if(a.classList)return a.classList.contains(b)&&a.classList.remove(b),a;if(b&&"string"==typeof b||void 0===b){var c=(b||"").split(/\s+/);if(1===a.nodeType&&a.className)if(b){for(var d=(" "+a.className+" ").replace(/[\n\t]/g," "),e=0,f=c.length;f>e;e++)d=d.replace(" "+c[e]+" "," ");a.className=d.replace(/^\s+|\s+$/g,"")}else a.className=""}return a},q=function(){var a,b,c,d=1;return"function"==typeof document.body.getBoundingClientRect&&(a=document.body.getBoundingClientRect(),b=a.right-a.left,c=document.body.offsetWidth,d=Math.round(b/c*100)/100),d},r=function(a,b){var c={left:0,top:0,width:0,height:0,zIndex:x(b)-1};if(a.getBoundingClientRect){var d,e,f,g=a.getBoundingClientRect();"pageXOffset"in window&&"pageYOffset"in window?(d=window.pageXOffset,e=window.pageYOffset):(f=q(),d=Math.round(document.documentElement.scrollLeft/f),e=Math.round(document.documentElement.scrollTop/f));var h=document.documentElement.clientLeft||0,i=document.documentElement.clientTop||0;c.left=g.left+d-h,c.top=g.top+e-i,c.width="width"in g?g.width:g.right-g.left,c.height="height"in g?g.height:g.bottom-g.top}return c},s=function(a,b){var c=!(b&&b.useNoCache===!1);return c?(-1===a.indexOf("?")?"?":"&")+"nocache="+(new Date).getTime():""},t=function(a){var b,c,d,e=[],f=[],g=[];if(a.trustedOrigins&&("string"==typeof a.trustedOrigins?f.push(a.trustedOrigins):"object"==typeof a.trustedOrigins&&"length"in a.trustedOrigins&&(f=f.concat(a.trustedOrigins))),a.trustedDomains&&("string"==typeof a.trustedDomains?f.push(a.trustedDomains):"object"==typeof a.trustedDomains&&"length"in a.trustedDomains&&(f=f.concat(a.trustedDomains))),f.length)for(b=0,c=f.length;c>b;b++)if(f.hasOwnProperty(b)&&f[b]&&"string"==typeof f[b]){if(d=A(f[b]),!d)continue;if("*"===d){g=[d];break}g.push.apply(g,[d,"//"+d,window.location.protocol+"//"+d])}return g.length&&e.push("trustedOrigins="+encodeURIComponent(g.join(","))),"string"==typeof a.amdModuleId&&a.amdModuleId&&e.push("amdModuleId="+encodeURIComponent(a.amdModuleId)),"string"==typeof a.cjsModuleId&&a.cjsModuleId&&e.push("cjsModuleId="+encodeURIComponent(a.cjsModuleId)),e.join("&")},u=function(a,b,c){if("function"==typeof b.indexOf)return b.indexOf(a,c);var d,e=b.length;for("undefined"==typeof c?c=0:0>c&&(c=e+c),d=c;e>d;d++)if(b.hasOwnProperty(d)&&b[d]===a)return d;return-1},v=function(a){if("string"==typeof a)throw new TypeError("ZeroClipboard doesn't accept query strings.");return a.length?a:[a]},w=function(a,b,c,d,e){e?window.setTimeout(function(){a.call(b,c,d)},0):a.call(b,c,d)},x=function(a){var b,c;return a&&("number"==typeof a&&a>0?b=a:"string"==typeof a&&(c=parseInt(a,10))&&!isNaN(c)&&c>0&&(b=c)),b||("number"==typeof I.zIndex&&I.zIndex>0?b=I.zIndex:"string"==typeof I.zIndex&&(c=parseInt(I.zIndex,10))&&!isNaN(c)&&c>0&&(b=c)),b||0},y=function(a,b){if(a&&b!==!1&&"undefined"!=typeof console&&console&&(console.warn||console.log)){var c="`"+a+"` is deprecated. See docs for more info:\n https://github.com/zeroclipboard/zeroclipboard/blob/master/docs/instructions.md#deprecations";console.warn?console.warn(c):console.log(c)}},z=function(){var a,b,c,d,e,f,g=arguments[0]||{};for(a=1,b=arguments.length;b>a;a++)if(null!=(c=arguments[a]))for(d in c)if(c.hasOwnProperty(d)){if(e=g[d],f=c[d],g===f)continue;void 0!==f&&(g[d]=f)}return g},A=function(a){if(null==a||""===a)return null;if(a=a.replace(/^\s+|\s+$/g,""),""===a)return null;var b=a.indexOf("//");a=-1===b?a:a.slice(b+2);var c=a.indexOf("/");return a=-1===c?a:-1===b||0===c?null:a.slice(0,c),a&&".swf"===a.slice(-4).toLowerCase()?null:a||null},B=function(){var a=function(a,b){var c,d,e;if(null!=a&&"*"!==b[0]&&("string"==typeof a&&(a=[a]),"object"==typeof a&&"length"in a))for(c=0,d=a.length;d>c;c++)if(a.hasOwnProperty(c)&&(e=A(a[c]))){if("*"===e){b.length=0,b.push("*");break}-1===u(e,b)&&b.push(e)}},b={always:"always",samedomain:"sameDomain",never:"never"};return function(c,d){var e,f=d.allowScriptAccess;if("string"==typeof f&&(e=f.toLowerCase())&&/^always|samedomain|never$/.test(e))return b[e];var g=A(d.moviePath);null===g&&(g=c);var h=[];a(d.trustedOrigins,h),a(d.trustedDomains,h);var i=h.length;if(i>0){if(1===i&&"*"===h[0])return"always";if(-1!==u(c,h))return 1===i&&c===g?"sameDomain":"always"}return"never"}}(),C=function(a){if(null==a)return[];if(Object.keys)return Object.keys(a);var b=[];for(var c in a)a.hasOwnProperty(c)&&b.push(c);return b},D=function(a){if(a)for(var b in a)a.hasOwnProperty(b)&&delete a[b];return a},E=function(){var a=!1;if("boolean"==typeof d.noflash)a=d.noflash===!1;else{if("function"==typeof ActiveXObject)try{new ActiveXObject("ShockwaveFlash.ShockwaveFlash")&&(a=!0)}catch(b){}!a&&navigator.mimeTypes["application/x-shockwave-flash"]&&(a=!0)}return a},F=function(a,b){return this instanceof F?(this.id=""+f++,g[this.id]={instance:this,elements:[],handlers:{}},a&&this.glue(a),"undefined"!=typeof b&&(y("new ZeroClipboard(elements, options)",I.debug),F.config(b)),this.options=F.config(),"boolean"!=typeof d.noflash&&(d.noflash=!E()),d.noflash===!1&&d.wrongflash!==!0&&null===d.bridge&&(d.wrongflash=!1,d.ready=!1,L()),void 0):new F(a,b)};F.prototype.setText=function(a){return a&&""!==a&&(e["text/plain"]=a,d.ready===!0&&d.bridge&&d.bridge.setText(a)),this},F.prototype.setSize=function(a,b){return d.ready===!0&&d.bridge&&d.bridge.setSize(a,b),this};var G=function(a){d.ready===!0&&d.bridge&&d.bridge.setHandCursor(a)};F.prototype.destroy=function(){this.unglue(),this.off(),delete g[this.id]};var H=function(){var a,b,c,d=[],e=C(g);for(a=0,b=e.length;b>a;a++)c=g[e[a]].instance,c&&c instanceof F&&d.push(c);return d};F.version="1.3.0-beta.1";var I={moviePath:"ZeroClipboard.swf",trustedDomains:window.location.host?[window.location.host]:[],useNoCache:!0,forceHandCursor:!1,zIndex:999999999,debug:!0,title:null};F.config=function(a){"object"==typeof a&&null!==a&&z(I,a);{if("string"!=typeof a||!a){var b={};for(var c in I)I.hasOwnProperty(c)&&(b[c]="object"==typeof I[c]&&null!==I[c]?"length"in I[c]?I[c].slice(0):z({},I[c]):I[c]);return b}if(I.hasOwnProperty(a))return I[a]}},F.destroy=function(){F.deactivate();for(var a in g)if(g.hasOwnProperty(a)&&g[a]){var b=g[a].instance;b&&"function"==typeof b.destroy&&b.destroy()}var c=M(d.bridge);c&&c.parentNode&&(c.parentNode.removeChild(c),d.ready=null,d.bridge=null)},F.activate=function(a){c&&(p(c,I.hoverClass),p(c,I.activeClass)),c=a,o(a,I.hoverClass),N();var b=I.title||a.getAttribute("title");if(b){var e=M(d.bridge);e&&e.setAttribute("title",b)}var f=I.forceHandCursor===!0||"pointer"===k(a,"cursor");G(f)},F.deactivate=function(){var a=M(d.bridge);a&&(a.style.left="0px",a.style.top="-9999px",a.removeAttribute("title")),c&&(p(c,I.hoverClass),p(c,I.activeClass),c=null)};var J=null,K=null,L=function(){var a,b,c=document.getElementById("global-zeroclipboard-html-bridge");if(!c){var e=F.config();e.amdModuleId=J,e.cjsModuleId=K;var f=B(window.location.host,I),g=t(e),h=I.moviePath+s(I.moviePath,I),i=' <object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" id="global-zeroclipboard-flash-bridge" width="100%" height="100%"> <param name="movie" value="'+h+'"/> <param name="allowScriptAccess" value="'+f+'"/> <param name="scale" value="exactfit"/> <param name="loop" value="false"/> <param name="menu" value="false"/> <param name="quality" value="best" /> <param name="bgcolor" value="#ffffff"/> <param name="wmode" value="transparent"/> <param name="flashvars" value="'+g+'"/> <embed src="'+h+'" loop="false" menu="false" quality="best" bgcolor="#ffffff" width="100%" height="100%" name="global-zeroclipboard-flash-bridge" allowScriptAccess="'+f+'" allowFullScreen="false" type="application/x-shockwave-flash" wmode="transparent" pluginspage="http://www.macromedia.com/go/getflashplayer" flashvars="'+g+'" scale="exactfit"> </embed> </object>';c=document.createElement("div"),c.id="global-zeroclipboard-html-bridge",c.setAttribute("class","global-zeroclipboard-container"),c.style.position="absolute",c.style.left="0px",c.style.top="-9999px",c.style.width="15px",c.style.height="15px",c.style.zIndex=""+x(I.zIndex),document.body.appendChild(c),c.innerHTML=i}a=document["global-zeroclipboard-flash-bridge"],a&&(b=a.length)&&(a=a[b-1]),d.bridge=a||c.children[0].lastElementChild},M=function(a){for(var b=/^object|embed$/,c=a&&a.parentNode;c&&b.test(c.tagName.toLowerCase())&&c.parentNode;)c=c.parentNode;return c||null},N=function(){if(c){var a=r(c,I.zIndex),b=M(d.bridge);b&&(b.style.top=a.top+"px",b.style.left=a.left+"px",b.style.width=a.width+"px",b.style.height=a.height+"px",b.style.zIndex=a.zIndex+1),d.ready===!0&&d.bridge&&d.bridge.setSize(a.width,a.height)}return this};F.dispatch=function(a,b){if("string"==typeof a&&a){var d=a.toLowerCase().replace(/^on/,"");if(d)for(var e=c?P(c):H(),f=0,g=e.length;g>f;f++)O.call(e[f],d,b)}},F.prototype.on=function(a,b){for(var c=a.toString().split(/\s+/),e={},f=g[this.id]&&g[this.id].handlers,h=0,i=c.length;i>h;h++)a=c[h].toLowerCase().replace(/^on/,""),e[a]=!0,f[a]||(f[a]=[]),f[a].push(b);return e.noflash&&d.noflash&&O.call(this,"onNoFlash",{}),e.wrongflash&&d.wrongflash&&O.call(this,"onWrongFlash",{flashVersion:d.version}),e.load&&d.ready&&O.call(this,"onLoad",{flashVersion:d.version}),this},F.prototype.off=function(a,b){var c,d,e,f,h,i=g[this.id]&&g[this.id].handlers;if(0===arguments.length?f=C(i):"string"==typeof a&&a&&(f=a.split(/\s+/)),f&&f.length)for(c=0,d=f.length;d>c;c++)if(a=f[c].toLowerCase().replace(/^on/,""),h=i[a],h&&h.length)if(b)for(e=u(b,h);-1!==e;)h.splice(e,1),e=u(b,h,e);else i[a].length=0;return this},F.prototype.handlers=function(a){var b,c=null,d=g[this.id]&&g[this.id].handlers;if(d){if("string"==typeof a&&a)return d[a]?d[a].slice(0):null;c={};for(b in d)d.hasOwnProperty(b)&&d[b]&&(c[b]=d[b].slice(0))}return c};var O=function(f,h){f=f.toLowerCase().replace(/^on/,"");var i=h&&h.flashVersion&&a(h.flashVersion)||null,j=c,k=!0;switch(f){case"load":if(i){if(!b(i))return O.call(this,"onWrongFlash",{flashVersion:i}),void 0;d.wrongflash=!1,d.ready=!0,d.version=i}break;case"wrongflash":i&&!b(i)&&(d.wrongflash=!0,d.ready=!1,d.version=i);break;case"mouseover":o(j,I.hoverClass);break;case"mouseout":F.deactivate();break;case"mousedown":o(j,I.activeClass);break;case"mouseup":p(j,I.activeClass);break;case"datarequested":var l=j.getAttribute("data-clipboard-target"),m=l?document.getElementById(l):null;if(m){var n=m.value||m.textContent||m.innerText;n&&this.setText(n)}else{var q=j.getAttribute("data-clipboard-text");q&&this.setText(q)}k=!1;break;case"complete":D(e)}var r=g[this.id]&&g[this.id].handlers[f];if(r&&r.length){var s,t,u;for(s=0,t=r.length;t>s;s++)u=r[s],"string"==typeof u&&"function"==typeof window[u]&&(u=window[u]),"function"==typeof u&&w(u,j,this,h,k)}};F.prototype.glue=function(a){a=v(a);for(var b=0;b<a.length;b++)if(a.hasOwnProperty(b)&&a[b]&&1===a[b].nodeType){a[b].zcClippingId?-1===u(this.id,i[a[b].zcClippingId])&&i[a[b].zcClippingId].push(this.id):(a[b].zcClippingId="zcClippingId_"+h++,i[a[b].zcClippingId]=[this.id],m(a[b],"mouseover",l));var c=g[this.id].elements;-1===u(a[b],c)&&c.push(a[b])}return this},F.prototype.unglue=function(a){var b=g[this.id];if(b){"undefined"==typeof a&&(a=b.elements.slice(0)),a=v(a);for(var c=0;c<a.length;c++)if(a.hasOwnProperty(c)&&a[c]&&1===a[c].nodeType){for(var d=b.elements,e=0;-1!==(e=u(a[c],d,e));)d.splice(e,1);var f=i[a[c].zcClippingId];if(f){for(e=0;-1!==(e=u(this.id,f,e));)f.splice(e,1);0===f.length&&(n(a[c],"mouseover",l),delete a[c].zcClippingId)}}}return this},F.prototype.elements=function(){var a=g[this.id];return a&&a.elements?a.elements.slice(0):[]};var P=function(a){var b,c,d,e,f,h=[];if(a&&1===a.nodeType&&(b=a.zcClippingId)&&i.hasOwnProperty(b)&&(c=i[b],c&&c.length))for(d=0,e=c.length;e>d;d++)f=g[c[d]].instance,f&&f instanceof F&&h.push(f);return h};I.hoverClass="zeroclipboard-is-hover",I.activeClass="zeroclipboard-is-active",I.trustedOrigins=null,I.allowScriptAccess=null,F.detectFlashSupport=function(){var a=I.debug;return y("ZeroClipboard.detectFlashSupport",a),E()},F.prototype.setHandCursor=function(a){return y("ZeroClipboard.prototype.setHandCursor",I.debug),a="boolean"==typeof a?a:!!a,G(a),I.forceHandCursor=a,this},F.prototype.reposition=function(){return y("ZeroClipboard.prototype.reposition",I.debug),N()},F.prototype.receiveEvent=function(a,b){if(y("ZeroClipboard.prototype.receiveEvent",I.debug),"string"==typeof a&&a){var c=a.toLowerCase().replace(/^on/,"");c&&O.call(this,c,b)}},F.prototype.setCurrent=function(a){return y("ZeroClipboard.prototype.setCurrent",I.debug),F.activate(a),this},F.prototype.resetBridge=function(){return y("ZeroClipboard.prototype.resetBridge",I.debug),F.deactivate(),this},F.prototype.setTitle=function(a){if(y("ZeroClipboard.prototype.setTitle",I.debug),a=a||I.title||c&&c.getAttribute("title")){var b=M(d.bridge);b&&b.setAttribute("title",a)}return this},F.setDefaults=function(a){y("ZeroClipboard.setDefaults",I.debug),F.config(a)},F.prototype.addEventListener=function(){return y("ZeroClipboard.prototype.addEventListener",I.debug),this.on.apply(this,[].slice.call(arguments,0))},F.prototype.removeEventListener=function(){return y("ZeroClipboard.prototype.removeEventListener",I.debug),this.off.apply(this,[].slice.call(arguments,0))},F.prototype.ready=function(){return y("ZeroClipboard.prototype.ready",I.debug),d.ready===!0},"function"==typeof define&&define.amd?define(["require","exports","module"],function(a,b,c){return J=c&&c.id||null,F}):"object"==typeof module&&module&&"object"==typeof module.exports&&module.exports?(K=module.id||null,module.exports=F):window.ZeroClipboard=F}();