* [FIX] Related #500. Try to fix an issue when copying to clipboard. Updated Clipboard.js plugin

This commit is contained in:
nuxsmin
2017-03-16 00:28:00 +01:00
parent 373ba30161
commit 2ef5ff248e
6 changed files with 290 additions and 264 deletions

View File

@@ -405,7 +405,7 @@ class Util
*/
public static function getVersion($retBuild = false, $normalized = false)
{
$build = 17031501;
$build = 17031601;
$version = [2, 1, 2];
if ($normalized === true) {

View File

@@ -13,9 +13,9 @@
<table>
<tbody>
<tr>
<td class="dialog-user-text"><?php echo $login; ?></td>
<td class="dialog-text dialog-user-text"><?php echo $login; ?></td>
<td class="right">
<button class="dialog-clip-user-button mdl-button mdl-js-button mdl-js-ripple-effect"
<button class="dialog-clip-button mdl-button mdl-js-button mdl-js-ripple-effect"
title="<?php echo __('Copiar Usuario'); ?>" data-clipboard-target=".dialog-user-text">
<?php echo __('Usuario'); ?>
<i class="material-icons"><?php echo $icons->getIconClipboard()->getIcon(); ?></i>
@@ -24,9 +24,9 @@
</tr>
<tr>
<?php if (!$isImage): ?>
<td class="dialog-pass-text"><?php echo $pass; ?></td>
<td class="dialog-text dialog-pass-text"><?php echo $pass; ?></td>
<td class="right">
<button class="dialog-clip-pass-button mdl-button mdl-js-button mdl-js-ripple-effect"
<button class="dialog-clip-button mdl-button mdl-js-button mdl-js-ripple-effect"
title="<?php echo __('Copiar Clave'); ?>" data-clipboard-target=".dialog-pass-text">
<?php echo __('Clave'); ?>
<i class="material-icons"><?php echo $icons->getIconClipboard()->getIcon(); ?></i>

View File

@@ -600,27 +600,17 @@ sysPass.Main = function () {
clipboard.on("success", function (e) {
msg.ok(config.LANG[45]);
});
clipboard.on("error", function (e) {
}).on("error", function (e) {
msg.error(config.LANG[46]);
});
// Portapapeles para claves visualizadas
var clipboardDialog = new Clipboard(".dialog-clip-button");
// Inicializar el objeto para copiar al portapapeles
var clipboardPass = new Clipboard(".dialog-clip-pass-button");
var clipboardUser = new Clipboard(".dialog-clip-user-button");
clipboardDialog.on("success", function (e) {
$(".dialog-text").removeClass("dialog-clip-copy");
$(e.trigger.dataset.clipboardTarget).addClass("dialog-clip-copy");
clipboardPass.on("success", function (e) {
$(".dialog-user-text").removeClass("dialog-clip-copy");
$(".dialog-pass-text").addClass("dialog-clip-copy");
e.clearSelection();
});
clipboardUser.on("success", function (e) {
$(".dialog-pass-text").removeClass("dialog-clip-copy");
$(".dialog-user-text").addClass("dialog-clip-copy");
e.clearSelection();
});

27
js/app-main.min.js vendored
View File

@@ -6,18 +6,17 @@ $jscomp.polyfill=function(a,g,f,d){if(g){f=$jscomp.global;a=a.split(".");for(d=0
$jscomp.findInternal=function(a,g,f){a instanceof String&&(a=String(a));for(var d=a.length,e=0;e<d;e++){var m=a[e];if(g.call(f,m,e,a))return{i:e,v:m}}return{i:-1,v:void 0}};$jscomp.polyfill("Array.prototype.find",function(a){return a?a:function(a,f){return $jscomp.findInternal(this,a,f).v}},"es6-impl","es3");
sysPass.Main=function(){var a={APP_ROOT:"",LANG:[],PK:"",MAX_FILE_SIZE:1024,CRYPT:new JSEncrypt,CHECK_UPDATES:!1,TIMEZONE:"",LOCALE:"",DEBUG:"",COOKIES_ENABLED:!1},g={passLength:0,minPasswordLength:8,complexity:{chars:!0,numbers:!0,symbols:!0,uppercase:!0,numlength:12}},f={},d={},e={},m={},q={},n={},l={log:function(b){!0===a.DEBUG&&console.log(b)},info:function(b){!0===a.DEBUG&&console.info(b)},error:function(b){console.error(b)},warn:function(b){console.warn(b)},debug:function(b){!0===a.DEBUG&&console.debug(b)}};
toastr.options={closeButton:!0,debug:!1,newestOnTop:!1,progressBar:!1,positionClass:"toast-top-center",preventDuplicates:!1,onclick:null,showDuration:"300",hideDuration:"1000",timeOut:"5000",extendedTimeOut:"1000",showEasing:"swing",hideEasing:"linear",showMethod:"fadeIn",hideMethod:"fadeOut"};var w=function(){l.info("setupCallbacks");var b=$("#container").data("page");if(""!==b&&"function"===typeof d.views[b])d.views[b]();0<$("footer").length&&d.views.footer();$("#btnBack").click(function(){r("index.php")});
d.bodyHooks()},h={ok:function(b){toastr.success(b)},error:function(b){toastr.error(b)},warn:function(b){toastr.warning(b)},info:function(b){toastr.info(b)},sticky:function(b,k){var c={timeOut:0};"function"===typeof k&&(c.onHidden=k);toastr.warning(b,a.LANG[60],c)},out:function(b){if("object"===typeof b){var a=b.status,c=b.description;void 0!==b.messages&&0<b.messages.length&&(c=c+"<br>"+b.messages.join("<br>"));switch(a){case 0:h.ok(c);break;case 1:case 2:case 4:h.error(c);break;case 3:h.warn(c);
break;case 10:e.main.logout();break;case 100:h.ok(c);h.sticky(c);break;case 101:h.error(c);h.sticky(c);break;default:h.error(c)}}},html:{error:function(b){return'<p class="error round">Oops...<br>'+a.LANG[1]+"<br>"+b+"</p>"}}},x=function(b){l.info("getEnvironment");var k=window.location.pathname.split("/");a.APP_ROOT=window.location.protocol+"//"+window.location.host+function(){for(var a="",b=1;b<=k.length-2;b++)a+="/"+k[b];return a}();var c=m.getRequestOpts();c.url="/ajax/ajax_getEnvironment.php";
c.method="get";c.async=!1;c.useLoading=!1;c.data={isAjax:1};m.getActionCall(c,function(c){a.LANG=c.lang;a.PK=c.pk;a.CHECK_UPDATES=c.check_updates;a.CRYPT.setPublicKey(c.pk);a.TIMEZONE=c.timezone;a.LOCALE=c.locale;a.DEBUG=c.debug;a.MAX_FILE_SIZE=parseInt(c.max_file_size);a.COOKIES_ENABLED=c.cookies_enabled;"function"===typeof b&&b()})},t={get:function(){l.info("sk:get");return $("#container").attr("data-sk")},set:function(a){l.info("sk:set");$("#container").attr("data-sk",a)}},y=function(){var a=$("#container");
if(!a.hasClass("content-no-auto-resize")){var k=$("#content").height()+200;a.css("height",k)}},z=function(){$("html, body").animate({scrollTop:0},"slow")},A=function(a){for(var b=[],c,d=window.location.href.slice(window.location.href.indexOf("?")+1).split("&"),f=0;f<d.length;f++)c=d[f].split("="),b.push(c[0]),b[c[0]]=c[1];return void 0!==a&&void 0!==b[a]?b[a]:b},B=function(){l.info("checkLogout");1===parseInt(A("logout"))&&h.sticky(a.LANG[61],function(){r("index.php")})},r=function(a){window.location.replace(a)},
C=function(b){var k={actionId:b.data("action-id"),itemId:b.data("item-id"),sk:t.get()},c={requestDoneAction:"",setRequestData:function(a){$.extend(k,a)},getRequestData:function(){return k},beforeSendAction:"",url:""},f=function(a){if(void 0===c.url||""===c.url)return!1;var b=new FormData;b.append("inFile",a);b.append("isAjax",1);k.sk=t.get();Object.keys(k).forEach(function(a){b.append(a,k[a])});a=m.getRequestOpts();a.url=c.url;a.processData=!1;a.contentType=!1;a.data=b;m.getActionCall(a,function(a){var b=
a.status;a=a.description;0===b?("function"===typeof c.requestDoneAction&&c.requestDoneAction(),h.ok(a)):10===b?e.main.logout():h.error(a)})},d=function(c){if(5<c.length)h.error(a.LANG[17]+" (Max: 5)");else for(var k=0;k<c.length;k++){var p=c[k];if(p.size/1E3>a.MAX_FILE_SIZE)h.error(a.LANG[18]+"<br>"+p.name+" (Max: "+a.MAX_FILE_SIZE+")");else{var d;a:{d=p.name;for(var g=b.data("files-ext").toLowerCase().split(","),e=0;e<=g.length;e++)if(-1!==d.indexOf(g[e])){d=!0;break a}d=!1}d?f(c[k]):h.error(a.LANG[19]+
d.bodyHooks()},k={ok:function(b){toastr.success(b)},error:function(b){toastr.error(b)},warn:function(b){toastr.warning(b)},info:function(b){toastr.info(b)},sticky:function(b,h){var c={timeOut:0};"function"===typeof h&&(c.onHidden=h);toastr.warning(b,a.LANG[60],c)},out:function(b){if("object"===typeof b){var a=b.status,c=b.description;void 0!==b.messages&&0<b.messages.length&&(c=c+"<br>"+b.messages.join("<br>"));switch(a){case 0:k.ok(c);break;case 1:case 2:case 4:k.error(c);break;case 3:k.warn(c);
break;case 10:e.main.logout();break;case 100:k.ok(c);k.sticky(c);break;case 101:k.error(c);k.sticky(c);break;default:k.error(c)}}},html:{error:function(b){return'<p class="error round">Oops...<br>'+a.LANG[1]+"<br>"+b+"</p>"}}},x=function(b){l.info("getEnvironment");var h=window.location.pathname.split("/");a.APP_ROOT=window.location.protocol+"//"+window.location.host+function(){for(var b="",a=1;a<=h.length-2;a++)b+="/"+h[a];return b}();var c=m.getRequestOpts();c.url="/ajax/ajax_getEnvironment.php";
c.method="get";c.async=!1;c.useLoading=!1;c.data={isAjax:1};m.getActionCall(c,function(c){a.LANG=c.lang;a.PK=c.pk;a.CHECK_UPDATES=c.check_updates;a.CRYPT.setPublicKey(c.pk);a.TIMEZONE=c.timezone;a.LOCALE=c.locale;a.DEBUG=c.debug;a.MAX_FILE_SIZE=parseInt(c.max_file_size);a.COOKIES_ENABLED=c.cookies_enabled;"function"===typeof b&&b()})},t={get:function(){l.info("sk:get");return $("#container").attr("data-sk")},set:function(b){l.info("sk:set");$("#container").attr("data-sk",b)}},y=function(){var b=$("#container");
if(!b.hasClass("content-no-auto-resize")){var a=$("#content").height()+200;b.css("height",a)}},z=function(){$("html, body").animate({scrollTop:0},"slow")},A=function(a){for(var b=[],c,d=window.location.href.slice(window.location.href.indexOf("?")+1).split("&"),f=0;f<d.length;f++)c=d[f].split("="),b.push(c[0]),b[c[0]]=c[1];return void 0!==a&&void 0!==b[a]?b[a]:b},B=function(){l.info("checkLogout");1===parseInt(A("logout"))&&k.sticky(a.LANG[61],function(){r("index.php")})},r=function(a){window.location.replace(a)},
C=function(b){var h={actionId:b.data("action-id"),itemId:b.data("item-id"),sk:t.get()},c={requestDoneAction:"",setRequestData:function(a){$.extend(h,a)},getRequestData:function(){return h},beforeSendAction:"",url:""},f=function(a){if(void 0===c.url||""===c.url)return!1;var b=new FormData;b.append("inFile",a);b.append("isAjax",1);h.sk=t.get();Object.keys(h).forEach(function(a){b.append(a,h[a])});a=m.getRequestOpts();a.url=c.url;a.processData=!1;a.contentType=!1;a.data=b;m.getActionCall(a,function(a){var b=
a.status;a=a.description;0===b?("function"===typeof c.requestDoneAction&&c.requestDoneAction(),k.ok(a)):10===b?e.main.logout():k.error(a)})},d=function(c){if(5<c.length)k.error(a.LANG[17]+" (Max: 5)");else for(var h=0;h<c.length;h++){var p=c[h];if(p.size/1E3>a.MAX_FILE_SIZE)k.error(a.LANG[18]+"<br>"+p.name+" (Max: "+a.MAX_FILE_SIZE+")");else{var d;a:{d=p.name;for(var g=b.data("files-ext").toLowerCase().split(","),e=0;e<=g.length;e++)if(-1!==d.indexOf(g[e])){d=!0;break a}d=!1}d?f(c[h]):k.error(a.LANG[19]+
"<br>"+p.name)}}},g=function(a){var b=$("#fileUploadForm");!1===a&&b.hide();a=b.find("input[type='file']");a.on("change",function(){"function"===typeof c.beforeSendAction&&c.beforeSendAction();d(this.files)});return a};window.File&&window.FileList&&window.FileReader?function(){l.info("fileUpload:init");var a=g(!1);b.on("dragover dragenter",function(a){l.info("fileUpload:drag");a.stopPropagation();a.preventDefault()});b.on("drop",function(a){l.info("fileUpload:drop");a.stopPropagation();a.preventDefault();
"function"===typeof c.beforeSendAction&&c.beforeSendAction();d(a.originalEvent.dataTransfer.files)});b.on("click",function(){a.click()})}():g(!0);return c},D=function(a){l.info("checkPassLevel");g.passLength=a.val().length;v(zxcvbn(a.val()),a)},v=function(b,k){l.info("outputResult");var c=$(".passLevel-"+k.attr("id")),d=b.score;c.show();c.removeClass("weak good strong strongest");0===g.passLength?c.attr("title","").empty():g.passLength<g.minPasswordLength?c.attr("title",a.LANG[11]).addClass("weak"):
0===d?c.attr("title",a.LANG[9]+" - "+b.feedback.warning).addClass("weak"):1===d||2===d?c.attr("title",a.LANG[8]+" - "+b.feedback.warning).addClass("good"):3===d?c.attr("title",a.LANG[7]).addClass("strong"):4===d&&c.attr("title",a.LANG[10]).addClass("strongest")},E=function(b){$(b).find(".checkbox").button({icons:{primary:"ui-icon-transferthick-e-w"}}).click(function(){var b=$(this);!0===b.prop("checked")?b.button("option","label",a.LANG[40]):b.button("option","label",a.LANG[41])})},u=function(b){l.info("encryptFormValue");
var d=b.val();""!==d&&parseInt(b.attr("data-length"))!==d.length&&(d=a.CRYPT.encrypt(d),b.val(d),b.attr("data-length",d.length))},F=function(){l.info("initializeClipboard");var b=new Clipboard(".clip-pass-button",{text:function(a){return e.account.copypass($(a)).responseJSON.data.accpass}});b.on("success",function(b){h.ok(a.LANG[45])});b.on("error",function(b){h.error(a.LANG[46])});var b=new Clipboard(".dialog-clip-pass-button"),d=new Clipboard(".dialog-clip-user-button");b.on("success",function(a){$(".dialog-user-text").removeClass("dialog-clip-copy");
$(".dialog-pass-text").addClass("dialog-clip-copy");a.clearSelection()});d.on("success",function(a){$(".dialog-pass-text").removeClass("dialog-clip-copy");$(".dialog-user-text").addClass("dialog-clip-copy");a.clearSelection()});(new Clipboard(".clip-pass-icon")).on("success",function(b){h.ok(a.LANG[45]);b.clearSelection()})},G=function(){l.info("bindPassEncrypt");$("body").on("blur",":input[type=password]",function(a){a=$(this);a.hasClass("passwordfield__no-pki")||u(a)}).on("keypress",":input[type=password]",
function(a){13===a.keyCode&&(a.preventDefault(),a=$(this),u(a),a.closest("form").submit())})},H=function(a,d){console.info("Eval: "+a);if("function"===typeof a)a(d);else throw Error("Function not found: "+a);},I=function(a){l.info("resizeImage");var b=.9*$(window).width(),c=.9*$(window).height(),d={width:a.width(),height:a.height()},f={calc:0,main:0,secondary:0,factor:.9,rel:d.width/d.height},g=function(a){a.main>a.secondary?a.calc=a.main/a.rel:a.main<a.secondary&&(a.calc=a.main*a.rel);a.calc>a.secondary&&
(a.main*=a.factor,g(a));return a},e=function(){f.main=b;f.secondary=c;var e=g(f);a.css({width:e.main,height:e.calc});d.width=e.main;d.height=e.calc},h=function(){f.main=c;f.secondary=b;var e=g(f);a.css({width:e.calc,height:e.main});d.width=e.calc;d.height=e.main};d.width>b?e():d.height>c&&(l.info("height"),h());return d},J=function(){return $.extend({log:l,config:function(){return a},appTheme:function(){return f},appActions:function(){return e},appTriggers:function(){return d},appRequests:function(){return m},
evalAction:H,resizeImage:I},q)},K=function(){return{actions:function(){return e},triggers:function(){return d},theme:function(){return f},sk:t,msg:h,log:l,passToClip:0,passwordData:g,outputResult:v,checkboxDetect:E,checkPassLevel:D,encryptFormValue:u,fileUpload:C,redirect:r,scrollUp:z,setContentSize:y}};(function(){l.info("init");q=K();n=J();d=sysPass.Triggers(n);e=sysPass.Actions(n);m=sysPass.Requests(n);x(function(){""!==a.PK&&G();"function"===typeof sysPass.Theme&&(f=sysPass.Theme(n));!0===a.CHECK_UPDATES&&
e.main.getUpdates();!1===a.COOKIES_ENABLED&&h.sticky(a.LANG[64]);F();w();B()})})();return q};
"function"===typeof c.beforeSendAction&&c.beforeSendAction();d(a.originalEvent.dataTransfer.files)});b.on("click",function(){a.click()})}():g(!0);return c},D=function(a){l.info("checkPassLevel");g.passLength=a.val().length;v(zxcvbn(a.val()),a)},v=function(b,d){l.info("outputResult");var c=$(".passLevel-"+d.attr("id")),h=b.score;c.show();c.removeClass("weak good strong strongest");0===g.passLength?c.attr("title","").empty():g.passLength<g.minPasswordLength?c.attr("title",a.LANG[11]).addClass("weak"):
0===h?c.attr("title",a.LANG[9]+" - "+b.feedback.warning).addClass("weak"):1===h||2===h?c.attr("title",a.LANG[8]+" - "+b.feedback.warning).addClass("good"):3===h?c.attr("title",a.LANG[7]).addClass("strong"):4===h&&c.attr("title",a.LANG[10]).addClass("strongest")},E=function(b){$(b).find(".checkbox").button({icons:{primary:"ui-icon-transferthick-e-w"}}).click(function(){var b=$(this);!0===b.prop("checked")?b.button("option","label",a.LANG[40]):b.button("option","label",a.LANG[41])})},u=function(b){l.info("encryptFormValue");
var d=b.val();""!==d&&parseInt(b.attr("data-length"))!==d.length&&(d=a.CRYPT.encrypt(d),b.val(d),b.attr("data-length",d.length))},F=function(){l.info("initializeClipboard");(new Clipboard(".clip-pass-button",{text:function(a){return e.account.copypass($(a)).responseJSON.data.accpass}})).on("success",function(b){k.ok(a.LANG[45])}).on("error",function(b){k.error(a.LANG[46])});(new Clipboard(".dialog-clip-button")).on("success",function(a){$(".dialog-text").removeClass("dialog-clip-copy");$(a.trigger.dataset.clipboardTarget).addClass("dialog-clip-copy");
a.clearSelection()});(new Clipboard(".clip-pass-icon")).on("success",function(b){k.ok(a.LANG[45]);b.clearSelection()})},G=function(){l.info("bindPassEncrypt");$("body").on("blur",":input[type=password]",function(a){a=$(this);a.hasClass("passwordfield__no-pki")||u(a)}).on("keypress",":input[type=password]",function(a){13===a.keyCode&&(a.preventDefault(),a=$(this),u(a),a.closest("form").submit())})},H=function(a,d){console.info("Eval: "+a);if("function"===typeof a)a(d);else throw Error("Function not found: "+
a);},I=function(a){l.info("resizeImage");var b=.9*$(window).width(),c=.9*$(window).height(),d={width:a.width(),height:a.height()},f={calc:0,main:0,secondary:0,factor:.9,rel:d.width/d.height},g=function(a){a.main>a.secondary?a.calc=a.main/a.rel:a.main<a.secondary&&(a.calc=a.main*a.rel);a.calc>a.secondary&&(a.main*=a.factor,g(a));return a},e=function(){f.main=b;f.secondary=c;var e=g(f);a.css({width:e.main,height:e.calc});d.width=e.main;d.height=e.calc},k=function(){f.main=c;f.secondary=b;var e=g(f);
a.css({width:e.calc,height:e.main});d.width=e.calc;d.height=e.main};d.width>b?e():d.height>c&&(l.info("height"),k());return d},J=function(){return $.extend({log:l,config:function(){return a},appTheme:function(){return f},appActions:function(){return e},appTriggers:function(){return d},appRequests:function(){return m},evalAction:H,resizeImage:I},q)},K=function(){return{actions:function(){return e},triggers:function(){return d},theme:function(){return f},sk:t,msg:k,log:l,passToClip:0,passwordData:g,
outputResult:v,checkboxDetect:E,checkPassLevel:D,encryptFormValue:u,fileUpload:C,redirect:r,scrollUp:z,setContentSize:y}};(function(){l.info("init");q=K();n=J();d=sysPass.Triggers(n);e=sysPass.Actions(n);m=sysPass.Requests(n);x(function(){""!==a.PK&&G();"function"===typeof sysPass.Theme&&(f=sysPass.Theme(n));!0===a.CHECK_UPDATES&&e.main.getUpdates();!1===a.COOKIES_ENABLED&&k.sticky(a.LANG[64]);F();w();B()})})();return q};

View File

@@ -1,23 +1,43 @@
/*!
* clipboard.js v1.5.12
* clipboard.js v1.6.1
* https://zenorocha.github.io/clipboard.js
*
* Licensed MIT © Zeno Rocha
*/
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.Clipboard = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
var matches = require('matches-selector')
var DOCUMENT_NODE_TYPE = 9;
module.exports = function (element, selector, checkYoSelf) {
var parent = checkYoSelf ? element : element.parentNode
/**
* A polyfill for Element.matches()
*/
if (typeof Element !== 'undefined' && !Element.prototype.matches) {
var proto = Element.prototype;
while (parent && parent !== document) {
if (matches(parent, selector)) return parent;
parent = parent.parentNode
}
proto.matches = proto.matchesSelector ||
proto.mozMatchesSelector ||
proto.msMatchesSelector ||
proto.oMatchesSelector ||
proto.webkitMatchesSelector;
}
},{"matches-selector":5}],2:[function(require,module,exports){
var closest = require('closest');
/**
* Finds the closest parent that matches a selector.
*
* @param {Element} element
* @param {String} selector
* @return {Function}
*/
function closest (element, selector) {
while (element && element.nodeType !== DOCUMENT_NODE_TYPE) {
if (element.matches(selector)) return element;
element = element.parentNode;
}
}
module.exports = closest;
},{}],2:[function(require,module,exports){
var closest = require('./closest');
/**
* Delegates event to a selector.
@@ -52,7 +72,7 @@ function delegate(element, selector, type, callback, useCapture) {
*/
function listener(element, selector, type, callback) {
return function(e) {
e.delegateTarget = closest(e.target, selector, true);
e.delegateTarget = closest(e.target, selector);
if (e.delegateTarget) {
callback.call(element, e);
@@ -62,7 +82,7 @@ function listener(element, selector, type, callback) {
module.exports = delegate;
},{"closest":1}],3:[function(require,module,exports){
},{"./closest":1}],3:[function(require,module,exports){
/**
* Check if argument is a HTML element.
*
@@ -211,54 +231,28 @@ function listenSelector(selector, type, callback) {
module.exports = listen;
},{"./is":3,"delegate":2}],5:[function(require,module,exports){
/**
* Element prototype.
*/
var proto = Element.prototype;
/**
* Vendor function.
*/
var vendor = proto.matchesSelector
|| proto.webkitMatchesSelector
|| proto.mozMatchesSelector
|| proto.msMatchesSelector
|| proto.oMatchesSelector;
/**
* Expose `match()`.
*/
module.exports = match;
/**
* Match `el` to `selector`.
*
* @param {Element} el
* @param {String} selector
* @return {Boolean}
* @api public
*/
function match(el, selector) {
if (vendor) return vendor.call(el, selector);
var nodes = el.parentNode.querySelectorAll(selector);
for (var i = 0; i < nodes.length; ++i) {
if (nodes[i] == el) return true;
}
return false;
}
},{}],6:[function(require,module,exports){
function select(element) {
var selectedText;
if (element.nodeName === 'INPUT' || element.nodeName === 'TEXTAREA') {
if (element.nodeName === 'SELECT') {
element.focus();
selectedText = element.value;
}
else if (element.nodeName === 'INPUT' || element.nodeName === 'TEXTAREA') {
var isReadOnly = element.hasAttribute('readonly');
if (!isReadOnly) {
element.setAttribute('readonly', '');
}
element.select();
element.setSelectionRange(0, element.value.length);
if (!isReadOnly) {
element.removeAttribute('readonly');
}
selectedText = element.value;
}
else {
@@ -281,14 +275,14 @@ function select(element) {
module.exports = select;
},{}],7:[function(require,module,exports){
},{}],6:[function(require,module,exports){
function E () {
// Keep this empty so it's easier to inherit from
// Keep this empty so it's easier to inherit from
// (via https://github.com/lipsmack from https://github.com/scottcorgan/tiny-emitter/issues/3)
}
E.prototype = {
on: function (name, callback, ctx) {
on: function (name, callback, ctx) {
var e = this.e || (this.e = {});
(e[name] || (e[name] = [])).push({
@@ -349,7 +343,7 @@ E.prototype = {
module.exports = E;
},{}],8:[function(require,module,exports){
},{}],7:[function(require,module,exports){
(function (global, factory) {
if (typeof define === "function" && define.amd) {
define(['module', 'select'], factory);
@@ -376,7 +370,7 @@ module.exports = E;
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) {
return typeof obj;
} : function (obj) {
return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj;
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
};
function _classCallCheck(instance, Constructor) {
@@ -407,7 +401,6 @@ module.exports = E;
/**
* @param {Object} options
*/
function ClipboardAction(options) {
_classCallCheck(this, ClipboardAction);
@@ -421,122 +414,125 @@ module.exports = E;
*/
ClipboardAction.prototype.resolveOptions = function resolveOptions() {
var options = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0];
_createClass(ClipboardAction, [{
key: 'resolveOptions',
value: function resolveOptions() {
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
this.action = options.action;
this.emitter = options.emitter;
this.target = options.target;
this.text = options.text;
this.trigger = options.trigger;
this.action = options.action;
this.emitter = options.emitter;
this.target = options.target;
this.text = options.text;
this.trigger = options.trigger;
this.selectedText = '';
};
ClipboardAction.prototype.initSelection = function initSelection() {
if (this.text) {
this.selectFake();
} else if (this.target) {
this.selectTarget();
this.selectedText = '';
}
};
ClipboardAction.prototype.selectFake = function selectFake() {
var _this = this;
var isRTL = document.documentElement.getAttribute('dir') == 'rtl';
this.removeFake();
this.fakeHandlerCallback = function () {
return _this.removeFake();
};
this.fakeHandler = document.body.addEventListener('click', this.fakeHandlerCallback) || true;
this.fakeElem = document.createElement('textarea');
// Prevent zooming on iOS
this.fakeElem.style.fontSize = '12pt';
// Reset box model
this.fakeElem.style.border = '0';
this.fakeElem.style.padding = '0';
this.fakeElem.style.margin = '0';
// Move element out of screen horizontally
this.fakeElem.style.position = 'absolute';
this.fakeElem.style[isRTL ? 'right' : 'left'] = '-9999px';
// Move element to the same position vertically
this.fakeElem.style.top = (window.pageYOffset || document.documentElement.scrollTop) + 'px';
this.fakeElem.setAttribute('readonly', '');
this.fakeElem.value = this.text;
document.body.appendChild(this.fakeElem);
this.selectedText = (0, _select2.default)(this.fakeElem);
this.copyText();
};
ClipboardAction.prototype.removeFake = function removeFake() {
if (this.fakeHandler) {
document.body.removeEventListener('click', this.fakeHandlerCallback);
this.fakeHandler = null;
this.fakeHandlerCallback = null;
}, {
key: 'initSelection',
value: function initSelection() {
if (this.text) {
this.selectFake();
} else if (this.target) {
this.selectTarget();
}
}
}, {
key: 'selectFake',
value: function selectFake() {
var _this = this;
if (this.fakeElem) {
document.body.removeChild(this.fakeElem);
this.fakeElem = null;
var isRTL = document.documentElement.getAttribute('dir') == 'rtl';
this.removeFake();
this.fakeHandlerCallback = function () {
return _this.removeFake();
};
this.fakeHandler = document.body.addEventListener('click', this.fakeHandlerCallback) || true;
this.fakeElem = document.createElement('textarea');
// Prevent zooming on iOS
this.fakeElem.style.fontSize = '12pt';
// Reset box model
this.fakeElem.style.border = '0';
this.fakeElem.style.padding = '0';
this.fakeElem.style.margin = '0';
// Move element out of screen horizontally
this.fakeElem.style.position = 'absolute';
this.fakeElem.style[isRTL ? 'right' : 'left'] = '-9999px';
// Move element to the same position vertically
var yPosition = window.pageYOffset || document.documentElement.scrollTop;
this.fakeElem.style.top = yPosition + 'px';
this.fakeElem.setAttribute('readonly', '');
this.fakeElem.value = this.text;
document.body.appendChild(this.fakeElem);
this.selectedText = (0, _select2.default)(this.fakeElem);
this.copyText();
}
};
}, {
key: 'removeFake',
value: function removeFake() {
if (this.fakeHandler) {
document.body.removeEventListener('click', this.fakeHandlerCallback);
this.fakeHandler = null;
this.fakeHandlerCallback = null;
}
ClipboardAction.prototype.selectTarget = function selectTarget() {
this.selectedText = (0, _select2.default)(this.target);
this.copyText();
};
ClipboardAction.prototype.copyText = function copyText() {
var succeeded = undefined;
try {
succeeded = document.execCommand(this.action);
} catch (err) {
succeeded = false;
if (this.fakeElem) {
document.body.removeChild(this.fakeElem);
this.fakeElem = null;
}
}
}, {
key: 'selectTarget',
value: function selectTarget() {
this.selectedText = (0, _select2.default)(this.target);
this.copyText();
}
}, {
key: 'copyText',
value: function copyText() {
var succeeded = void 0;
this.handleResult(succeeded);
};
try {
succeeded = document.execCommand(this.action);
} catch (err) {
succeeded = false;
}
ClipboardAction.prototype.handleResult = function handleResult(succeeded) {
if (succeeded) {
this.emitter.emit('success', {
this.handleResult(succeeded);
}
}, {
key: 'handleResult',
value: function handleResult(succeeded) {
this.emitter.emit(succeeded ? 'success' : 'error', {
action: this.action,
text: this.selectedText,
trigger: this.trigger,
clearSelection: this.clearSelection.bind(this)
});
} else {
this.emitter.emit('error', {
action: this.action,
trigger: this.trigger,
clearSelection: this.clearSelection.bind(this)
});
}
};
}, {
key: 'clearSelection',
value: function clearSelection() {
if (this.target) {
this.target.blur();
}
ClipboardAction.prototype.clearSelection = function clearSelection() {
if (this.target) {
this.target.blur();
window.getSelection().removeAllRanges();
}
window.getSelection().removeAllRanges();
};
ClipboardAction.prototype.destroy = function destroy() {
this.removeFake();
};
_createClass(ClipboardAction, [{
}, {
key: 'destroy',
value: function destroy() {
this.removeFake();
}
}, {
key: 'action',
set: function set() {
var action = arguments.length <= 0 || arguments[0] === undefined ? 'copy' : arguments[0];
var action = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'copy';
this._action = action;
@@ -577,7 +573,7 @@ module.exports = E;
module.exports = ClipboardAction;
});
},{"select":6}],9:[function(require,module,exports){
},{"select":5}],8:[function(require,module,exports){
(function (global, factory) {
if (typeof define === "function" && define.amd) {
define(['module', './clipboard-action', 'tiny-emitter', 'good-listener'], factory);
@@ -611,6 +607,24 @@ module.exports = E;
}
}
var _createClass = function () {
function defineProperties(target, props) {
for (var i = 0; i < props.length; i++) {
var descriptor = props[i];
descriptor.enumerable = descriptor.enumerable || false;
descriptor.configurable = true;
if ("value" in descriptor) descriptor.writable = true;
Object.defineProperty(target, descriptor.key, descriptor);
}
}
return function (Constructor, protoProps, staticProps) {
if (protoProps) defineProperties(Constructor.prototype, protoProps);
if (staticProps) defineProperties(Constructor, staticProps);
return Constructor;
};
}();
function _possibleConstructorReturn(self, call) {
if (!self) {
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
@@ -642,11 +656,10 @@ module.exports = E;
* @param {String|HTMLElement|HTMLCollection|NodeList} trigger
* @param {Object} options
*/
function Clipboard(trigger, options) {
_classCallCheck(this, Clipboard);
var _this = _possibleConstructorReturn(this, _Emitter.call(this));
var _this = _possibleConstructorReturn(this, (Clipboard.__proto__ || Object.getPrototypeOf(Clipboard)).call(this));
_this.resolveOptions(options);
_this.listenClick(trigger);
@@ -660,62 +673,85 @@ module.exports = E;
*/
Clipboard.prototype.resolveOptions = function resolveOptions() {
var options = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0];
_createClass(Clipboard, [{
key: 'resolveOptions',
value: function resolveOptions() {
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
this.action = typeof options.action === 'function' ? options.action : this.defaultAction;
this.target = typeof options.target === 'function' ? options.target : this.defaultTarget;
this.text = typeof options.text === 'function' ? options.text : this.defaultText;
};
Clipboard.prototype.listenClick = function listenClick(trigger) {
var _this2 = this;
this.listener = (0, _goodListener2.default)(trigger, 'click', function (e) {
return _this2.onClick(e);
});
};
Clipboard.prototype.onClick = function onClick(e) {
var trigger = e.delegateTarget || e.currentTarget;
if (this.clipboardAction) {
this.clipboardAction = null;
this.action = typeof options.action === 'function' ? options.action : this.defaultAction;
this.target = typeof options.target === 'function' ? options.target : this.defaultTarget;
this.text = typeof options.text === 'function' ? options.text : this.defaultText;
}
}, {
key: 'listenClick',
value: function listenClick(trigger) {
var _this2 = this;
this.clipboardAction = new _clipboardAction2.default({
action: this.action(trigger),
target: this.target(trigger),
text: this.text(trigger),
trigger: trigger,
emitter: this
});
};
Clipboard.prototype.defaultAction = function defaultAction(trigger) {
return getAttributeValue('action', trigger);
};
Clipboard.prototype.defaultTarget = function defaultTarget(trigger) {
var selector = getAttributeValue('target', trigger);
if (selector) {
return document.querySelector(selector);
this.listener = (0, _goodListener2.default)(trigger, 'click', function (e) {
return _this2.onClick(e);
});
}
};
}, {
key: 'onClick',
value: function onClick(e) {
var trigger = e.delegateTarget || e.currentTarget;
Clipboard.prototype.defaultText = function defaultText(trigger) {
return getAttributeValue('text', trigger);
};
if (this.clipboardAction) {
this.clipboardAction = null;
}
Clipboard.prototype.destroy = function destroy() {
this.listener.destroy();
if (this.clipboardAction) {
this.clipboardAction.destroy();
this.clipboardAction = null;
this.clipboardAction = new _clipboardAction2.default({
action: this.action(trigger),
target: this.target(trigger),
text: this.text(trigger),
trigger: trigger,
emitter: this
});
}
};
}, {
key: 'defaultAction',
value: function defaultAction(trigger) {
return getAttributeValue('action', trigger);
}
}, {
key: 'defaultTarget',
value: function defaultTarget(trigger) {
var selector = getAttributeValue('target', trigger);
if (selector) {
return document.querySelector(selector);
}
}
}, {
key: 'defaultText',
value: function defaultText(trigger) {
return getAttributeValue('text', trigger);
}
}, {
key: 'destroy',
value: function destroy() {
this.listener.destroy();
if (this.clipboardAction) {
this.clipboardAction.destroy();
this.clipboardAction = null;
}
}
}], [{
key: 'isSupported',
value: function isSupported() {
var action = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ['copy', 'cut'];
var actions = typeof action === 'string' ? [action] : action;
var support = !!document.queryCommandSupported;
actions.forEach(function (action) {
support = support && !!document.queryCommandSupported(action);
});
return support;
}
}]);
return Clipboard;
}(_tinyEmitter2.default);
@@ -738,5 +774,5 @@ module.exports = E;
module.exports = Clipboard;
});
},{"./clipboard-action":8,"good-listener":4,"tiny-emitter":7}]},{},[9])(9)
},{"./clipboard-action":7,"good-listener":4,"tiny-emitter":6}]},{},[8])(8)
});

43
js/clipboard.min.js vendored
View File

@@ -1,21 +1,22 @@
var $jscomp={scope:{}};$jscomp.defineProperty="function"==typeof Object.defineProperties?Object.defineProperty:function(h,b,c){if(c.get||c.set)throw new TypeError("ES3 does not support getters and setters.");h!=Array.prototype&&h!=Object.prototype&&(h[b]=c.value)};$jscomp.getGlobal=function(h){return"undefined"!=typeof window&&window===h?h:"undefined"!=typeof global?global:h};$jscomp.global=$jscomp.getGlobal(this);
$jscomp.polyfill=function(h,b,c,e){if(b){c=$jscomp.global;h=h.split(".");for(e=0;e<h.length-1;e++){var a=h[e];a in c||(c[a]={});c=c[a]}h=h[h.length-1];e=c[h];b=b(e);b!=e&&null!=b&&$jscomp.defineProperty(c,h,{configurable:!0,writable:!0,value:b})}};$jscomp.polyfill("Object.setPrototypeOf",function(h){return h?h:"object"!=typeof"".__proto__?null:function(b,c){b.__proto__=c;if(b.__proto__!==c)throw new TypeError(b+" is not extensible");return b}},"es6","es5");
(function(h){"object"===typeof exports&&"undefined"!==typeof module?module.exports=h():"function"===typeof define&&define.amd?define([],h):("undefined"!==typeof window?window:"undefined"!==typeof global?global:"undefined"!==typeof self?self:this).Clipboard=h()})(function(){return function b(c,e,a){function d(g,l){if(!e[g]){if(!c[g]){var f="function"==typeof require&&require;if(!l&&f)return f(g,!0);if(k)return k(g,!0);f=Error("Cannot find module '"+g+"'");throw f.code="MODULE_NOT_FOUND",f;}f=e[g]=
{exports:{}};c[g][0].call(f.exports,function(f){var a=c[g][1][f];return d(a?a:f)},f,f.exports,b,c,e,a)}return e[g].exports}for(var k="function"==typeof require&&require,l=0;l<a.length;l++)d(a[l]);return d}({1:[function(b,c,e){var a=b("matches-selector");c.exports=function(d,k,b){for(d=b?d:d.parentNode;d&&d!==document;){if(a(d,k))return d;d=d.parentNode}}},{"matches-selector":5}],2:[function(b,c,e){function a(a,b,g,c){return function(f){f.delegateTarget=d(f.target,b,!0);f.delegateTarget&&c.call(a,
f)}}var d=b("closest");c.exports=function(d,b,g,c,f){var m=a.apply(this,arguments);d.addEventListener(g,m,f);return{destroy:function(){d.removeEventListener(g,m,f)}}}},{closest:1}],3:[function(b,c,e){e.node=function(a){return void 0!==a&&a instanceof HTMLElement&&1===a.nodeType};e.nodeList=function(a){var d=Object.prototype.toString.call(a);return void 0!==a&&("[object NodeList]"===d||"[object HTMLCollection]"===d)&&"length"in a&&(0===a.length||e.node(a[0]))};e.string=function(a){return"string"===
typeof a||a instanceof String};e.fn=function(a){return"[object Function]"===Object.prototype.toString.call(a)}},{}],4:[function(b,c,e){function a(a,d,f){a.addEventListener(d,f);return{destroy:function(){a.removeEventListener(d,f)}}}function d(a,d,f){Array.prototype.forEach.call(a,function(a){a.addEventListener(d,f)});return{destroy:function(){Array.prototype.forEach.call(a,function(a){a.removeEventListener(d,f)})}}}var k=b("./is"),l=b("delegate");c.exports=function(g,b,f){if(!g&&!b&&!f)throw Error("Missing required arguments");
if(!k.string(b))throw new TypeError("Second argument must be a String");if(!k.fn(f))throw new TypeError("Third argument must be a Function");if(k.node(g))return a(g,b,f);if(k.nodeList(g))return d(g,b,f);if(k.string(g))return l(document.body,g,b,f);throw new TypeError("First argument must be a String, HTMLElement, HTMLCollection, or NodeList");}},{"./is":3,delegate:2}],5:[function(b,c,e){b=Element.prototype;var a=b.matchesSelector||b.webkitMatchesSelector||b.mozMatchesSelector||b.msMatchesSelector||
b.oMatchesSelector;c.exports=function(d,b){if(a)return a.call(d,b);for(var c=d.parentNode.querySelectorAll(b),g=0;g<c.length;++g)if(c[g]==d)return!0;return!1}},{}],6:[function(b,c,e){c.exports=function(a){if("INPUT"===a.nodeName||"TEXTAREA"===a.nodeName)a.focus(),a.setSelectionRange(0,a.value.length),a=a.value;else{a.hasAttribute("contenteditable")&&a.focus();var d=window.getSelection(),b=document.createRange();b.selectNodeContents(a);d.removeAllRanges();d.addRange(b);a=d.toString()}return a}},{}],
7:[function(b,c,e){function a(){}a.prototype={on:function(a,b,c){var d=this.e||(this.e={});(d[a]||(d[a]=[])).push({fn:b,ctx:c});return this},once:function(a,b,c){function d(){e.off(a,d);b.apply(c,arguments)}var e=this;d._=b;return this.on(a,d,c)},emit:function(a){var d=[].slice.call(arguments,1),b=((this.e||(this.e={}))[a]||[]).slice(),c=0,e=b.length;for(c;c<e;c++)b[c].fn.apply(b[c].ctx,d);return this},off:function(a,b){var d=this.e||(this.e={}),c=d[a],e=[];if(c&&b)for(var f=0,m=c.length;f<m;f++)c[f].fn!==
b&&c[f].fn._!==b&&e.push(c[f]);e.length?d[a]=e:delete d[a];return this}};c.exports=a},{}],8:[function(b,c,e){(function(a,d){if("undefined"!==typeof e)d(c,b("select"));else{var k={exports:{}};d(k,a.select);a.clipboardAction=k.exports}})(this,function(a,b){var d=b&&b.__esModule?b:{"default":b},c="function"===typeof Symbol&&"symbol"===typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"===typeof Symbol&&a.constructor===Symbol?"symbol":typeof a},e=function(){function a(a,
b){for(var d=0;d<b.length;d++){var c=b[d];c.enumerable=c.enumerable||!1;c.configurable=!0;"value"in c&&(c.writable=!0);Object.defineProperty(a,c.key,c)}}return function(b,c,d){c&&a(b.prototype,c);d&&a(b,d);return b}}(),p=function(){function a(b){if(!(this instanceof a))throw new TypeError("Cannot call a class as a function");this.resolveOptions(b);this.initSelection()}a.prototype.resolveOptions=function(){var a=0>=arguments.length||void 0===arguments[0]?{}:arguments[0];this.action=a.action;this.emitter=
a.emitter;this.target=a.target;this.text=a.text;this.trigger=a.trigger;this.selectedText=""};a.prototype.initSelection=function(){this.text?this.selectFake():this.target&&this.selectTarget()};a.prototype.selectFake=function(){var a=this,b="rtl"==document.documentElement.getAttribute("dir");this.removeFake();this.fakeHandlerCallback=function(){return a.removeFake()};this.fakeHandler=document.body.addEventListener("click",this.fakeHandlerCallback)||!0;this.fakeElem=document.createElement("textarea");
this.fakeElem.style.fontSize="12pt";this.fakeElem.style.border="0";this.fakeElem.style.padding="0";this.fakeElem.style.margin="0";this.fakeElem.style.position="absolute";this.fakeElem.style[b?"right":"left"]="-9999px";this.fakeElem.style.top=(window.pageYOffset||document.documentElement.scrollTop)+"px";this.fakeElem.setAttribute("readonly","");this.fakeElem.value=this.text;document.body.appendChild(this.fakeElem);this.selectedText=(0,d["default"])(this.fakeElem);this.copyText()};a.prototype.removeFake=
function(){this.fakeHandler&&(document.body.removeEventListener("click",this.fakeHandlerCallback),this.fakeHandlerCallback=this.fakeHandler=null);this.fakeElem&&(document.body.removeChild(this.fakeElem),this.fakeElem=null)};a.prototype.selectTarget=function(){this.selectedText=(0,d["default"])(this.target);this.copyText()};a.prototype.copyText=function(){var a=void 0;try{a=document.execCommand(this.action)}catch(n){a=!1}this.handleResult(a)};a.prototype.handleResult=function(a){a?this.emitter.emit("success",
{action:this.action,text:this.selectedText,trigger:this.trigger,clearSelection:this.clearSelection.bind(this)}):this.emitter.emit("error",{action:this.action,trigger:this.trigger,clearSelection:this.clearSelection.bind(this)})};a.prototype.clearSelection=function(){this.target&&this.target.blur();window.getSelection().removeAllRanges()};a.prototype.destroy=function(){this.removeFake()};e(a,[{key:"action",set:function(){this._action=0>=arguments.length||void 0===arguments[0]?"copy":arguments[0];if("copy"!==
this._action&&"cut"!==this._action)throw Error('Invalid "action" value, use either "copy" or "cut"');},get:function(){return this._action}},{key:"target",set:function(a){if(void 0!==a)if(a&&"object"===("undefined"===typeof a?"undefined":c(a))&&1===a.nodeType){if("copy"===this.action&&a.hasAttribute("disabled"))throw Error('Invalid "target" attribute. Please use "readonly" instead of "disabled" attribute');if("cut"===this.action&&(a.hasAttribute("readonly")||a.hasAttribute("disabled")))throw Error('Invalid "target" attribute. You can\'t cut text from elements with "readonly" or "disabled" attributes');
this._target=a}else throw Error('Invalid "target" value, use a valid Element');},get:function(){return this._target}}]);return a}();a.exports=p})},{select:6}],9:[function(b,c,e){(function(a,d){if("undefined"!==typeof e)d(c,b("./clipboard-action"),b("tiny-emitter"),b("good-listener"));else{var k={exports:{}};d(k,a.clipboardAction,a.tinyEmitter,a.goodListener);a.clipboard=k.exports}})(this,function(a,b,c,e){function d(a){return a&&a.__esModule?a:{"default":a}}function k(a,b){if("function"!==typeof b&&
null!==b)throw new TypeError("Super expression must either be null or a function, not "+typeof b);a.prototype=Object.create(b&&b.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}});b&&(Object.setPrototypeOf?Object.setPrototypeOf(a,b):a.__proto__=b)}function f(a,b){var c="data-clipboard-"+a;if(b.hasAttribute(c))return b.getAttribute(c)}var l=d(b);b=d(c);var n=d(e);e=function(a){function b(c,d){if(!(this instanceof b))throw new TypeError("Cannot call a class as a function");
var e;e=a.call(this);if(!this)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");e=!e||"object"!==typeof e&&"function"!==typeof e?this:e;e.resolveOptions(d);e.listenClick(c);return e}k(b,a);b.prototype.resolveOptions=function(){var a=0>=arguments.length||void 0===arguments[0]?{}:arguments[0];this.action="function"===typeof a.action?a.action:this.defaultAction;this.target="function"===typeof a.target?a.target:this.defaultTarget;this.text="function"===typeof a.text?
a.text:this.defaultText};b.prototype.listenClick=function(a){var b=this;this.listener=(0,n["default"])(a,"click",function(a){return b.onClick(a)})};b.prototype.onClick=function(a){a=a.delegateTarget||a.currentTarget;this.clipboardAction&&(this.clipboardAction=null);this.clipboardAction=new l["default"]({action:this.action(a),target:this.target(a),text:this.text(a),trigger:a,emitter:this})};b.prototype.defaultAction=function(a){return f("action",a)};b.prototype.defaultTarget=function(a){if(a=f("target",
a))return document.querySelector(a)};b.prototype.defaultText=function(a){return f("text",a)};b.prototype.destroy=function(){this.listener.destroy();this.clipboardAction&&(this.clipboardAction.destroy(),this.clipboardAction=null)};return b}(b["default"]);a.exports=e})},{"./clipboard-action":8,"good-listener":4,"tiny-emitter":7}]},{},[9])(9)});
var $jscomp={scope:{}};$jscomp.defineProperty="function"==typeof Object.defineProperties?Object.defineProperty:function(g,b,c){if(c.get||c.set)throw new TypeError("ES3 does not support getters and setters.");g!=Array.prototype&&g!=Object.prototype&&(g[b]=c.value)};$jscomp.getGlobal=function(g){return"undefined"!=typeof window&&window===g?g:"undefined"!=typeof global?global:g};$jscomp.global=$jscomp.getGlobal(this);
$jscomp.polyfill=function(g,b,c,f){if(b){c=$jscomp.global;g=g.split(".");for(f=0;f<g.length-1;f++){var a=g[f];a in c||(c[a]={});c=c[a]}g=g[g.length-1];f=c[g];b=b(f);b!=f&&null!=b&&$jscomp.defineProperty(c,g,{configurable:!0,writable:!0,value:b})}};$jscomp.polyfill("Object.setPrototypeOf",function(g){return g?g:"object"!=typeof"".__proto__?null:function(b,c){b.__proto__=c;if(b.__proto__!==c)throw new TypeError(b+" is not extensible");return b}},"es6","es5");
(function(g){"object"===typeof exports&&"undefined"!==typeof module?module.exports=g():"function"===typeof define&&define.amd?define([],g):("undefined"!==typeof window?window:"undefined"!==typeof global?global:"undefined"!==typeof self?self:this).Clipboard=g()})(function(){return function b(c,f,a){function d(h,n){if(!f[h]){if(!c[h]){var e="function"==typeof require&&require;if(!n&&e)return e(h,!0);if(k)return k(h,!0);e=Error("Cannot find module '"+h+"'");throw e.code="MODULE_NOT_FOUND",e;}e=f[h]=
{exports:{}};c[h][0].call(e.exports,function(a){var e=c[h][1][a];return d(e?e:a)},e,e.exports,b,c,f,a)}return f[h].exports}for(var k="function"==typeof require&&require,l=0;l<a.length;l++)d(a[l]);return d}({1:[function(b,c,f){"undefined"===typeof Element||Element.prototype.matches||(b=Element.prototype,b.matches=b.matchesSelector||b.mozMatchesSelector||b.msMatchesSelector||b.oMatchesSelector||b.webkitMatchesSelector);c.exports=function(a,d){for(;a&&9!==a.nodeType;){if(a.matches(d))return a;a=a.parentNode}}},
{}],2:[function(b,c,f){function a(a,b,h,c){return function(e){e.delegateTarget=d(e.target,b);e.delegateTarget&&c.call(a,e)}}var d=b("./closest");c.exports=function(d,b,h,c,e){var m=a.apply(this,arguments);d.addEventListener(h,m,e);return{destroy:function(){d.removeEventListener(h,m,e)}}}},{"./closest":1}],3:[function(b,c,f){f.node=function(a){return void 0!==a&&a instanceof HTMLElement&&1===a.nodeType};f.nodeList=function(a){var d=Object.prototype.toString.call(a);return void 0!==a&&("[object NodeList]"===
d||"[object HTMLCollection]"===d)&&"length"in a&&(0===a.length||f.node(a[0]))};f.string=function(a){return"string"===typeof a||a instanceof String};f.fn=function(a){return"[object Function]"===Object.prototype.toString.call(a)}},{}],4:[function(b,c,f){function a(a,d,e){a.addEventListener(d,e);return{destroy:function(){a.removeEventListener(d,e)}}}function d(a,d,e){Array.prototype.forEach.call(a,function(a){a.addEventListener(d,e)});return{destroy:function(){Array.prototype.forEach.call(a,function(a){a.removeEventListener(d,
e)})}}}var k=b("./is"),l=b("delegate");c.exports=function(h,b,e){if(!h&&!b&&!e)throw Error("Missing required arguments");if(!k.string(b))throw new TypeError("Second argument must be a String");if(!k.fn(e))throw new TypeError("Third argument must be a Function");if(k.node(h))return a(h,b,e);if(k.nodeList(h))return d(h,b,e);if(k.string(h))return l(document.body,h,b,e);throw new TypeError("First argument must be a String, HTMLElement, HTMLCollection, or NodeList");}},{"./is":3,delegate:2}],5:[function(b,
c,f){c.exports=function(a){if("SELECT"===a.nodeName)a.focus(),a=a.value;else if("INPUT"===a.nodeName||"TEXTAREA"===a.nodeName){var d=a.hasAttribute("readonly");d||a.setAttribute("readonly","");a.select();a.setSelectionRange(0,a.value.length);d||a.removeAttribute("readonly");a=a.value}else{a.hasAttribute("contenteditable")&&a.focus();var d=window.getSelection(),b=document.createRange();b.selectNodeContents(a);d.removeAllRanges();d.addRange(b);a=d.toString()}return a}},{}],6:[function(b,c,f){function a(){}
a.prototype={on:function(a,b,c){var d=this.e||(this.e={});(d[a]||(d[a]=[])).push({fn:b,ctx:c});return this},once:function(a,b,c){function d(){f.off(a,d);b.apply(c,arguments)}var f=this;d._=b;return this.on(a,d,c)},emit:function(a){var b=[].slice.call(arguments,1),d=((this.e||(this.e={}))[a]||[]).slice(),c=0,f=d.length;for(c;c<f;c++)d[c].fn.apply(d[c].ctx,b);return this},off:function(a,b){var d=this.e||(this.e={}),c=d[a],f=[];if(c&&b)for(var e=0,m=c.length;e<m;e++)c[e].fn!==b&&c[e].fn._!==b&&f.push(c[e]);
f.length?d[a]=f:delete d[a];return this}};c.exports=a},{}],7:[function(b,c,f){(function(a,d){if("undefined"!==typeof f)d(c,b("select"));else{var k={exports:{}};d(k,a.select);a.clipboardAction=k.exports}})(this,function(a,b){var c=b&&b.__esModule?b:{"default":b},d="function"===typeof Symbol&&"symbol"===typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"===typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},f=function(){function a(a,b){for(var c=
0;c<b.length;c++){var d=b[c];d.enumerable=d.enumerable||!1;d.configurable=!0;"value"in d&&(d.writable=!0);Object.defineProperty(a,d.key,d)}}return function(b,d,c){d&&a(b.prototype,d);c&&a(b,c);return b}}(),n=function(){function a(b){if(!(this instanceof a))throw new TypeError("Cannot call a class as a function");this.resolveOptions(b);this.initSelection()}f(a,[{key:"resolveOptions",value:function(){var a=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{};this.action=a.action;this.emitter=a.emitter;
this.target=a.target;this.text=a.text;this.trigger=a.trigger;this.selectedText=""}},{key:"initSelection",value:function(){this.text?this.selectFake():this.target&&this.selectTarget()}},{key:"selectFake",value:function(){var a=this,b="rtl"==document.documentElement.getAttribute("dir");this.removeFake();this.fakeHandlerCallback=function(){return a.removeFake()};this.fakeHandler=document.body.addEventListener("click",this.fakeHandlerCallback)||!0;this.fakeElem=document.createElement("textarea");this.fakeElem.style.fontSize=
"12pt";this.fakeElem.style.border="0";this.fakeElem.style.padding="0";this.fakeElem.style.margin="0";this.fakeElem.style.position="absolute";this.fakeElem.style[b?"right":"left"]="-9999px";this.fakeElem.style.top=(window.pageYOffset||document.documentElement.scrollTop)+"px";this.fakeElem.setAttribute("readonly","");this.fakeElem.value=this.text;document.body.appendChild(this.fakeElem);this.selectedText=(0,c["default"])(this.fakeElem);this.copyText()}},{key:"removeFake",value:function(){this.fakeHandler&&
(document.body.removeEventListener("click",this.fakeHandlerCallback),this.fakeHandlerCallback=this.fakeHandler=null);this.fakeElem&&(document.body.removeChild(this.fakeElem),this.fakeElem=null)}},{key:"selectTarget",value:function(){this.selectedText=(0,c["default"])(this.target);this.copyText()}},{key:"copyText",value:function(){var a=void 0;try{a=document.execCommand(this.action)}catch(q){a=!1}this.handleResult(a)}},{key:"handleResult",value:function(a){this.emitter.emit(a?"success":"error",{action:this.action,
text:this.selectedText,trigger:this.trigger,clearSelection:this.clearSelection.bind(this)})}},{key:"clearSelection",value:function(){this.target&&this.target.blur();window.getSelection().removeAllRanges()}},{key:"destroy",value:function(){this.removeFake()}},{key:"action",set:function(){this._action=0<arguments.length&&void 0!==arguments[0]?arguments[0]:"copy";if("copy"!==this._action&&"cut"!==this._action)throw Error('Invalid "action" value, use either "copy" or "cut"');},get:function(){return this._action}},
{key:"target",set:function(a){if(void 0!==a)if(a&&"object"===("undefined"===typeof a?"undefined":d(a))&&1===a.nodeType){if("copy"===this.action&&a.hasAttribute("disabled"))throw Error('Invalid "target" attribute. Please use "readonly" instead of "disabled" attribute');if("cut"===this.action&&(a.hasAttribute("readonly")||a.hasAttribute("disabled")))throw Error('Invalid "target" attribute. You can\'t cut text from elements with "readonly" or "disabled" attributes');this._target=a}else throw Error('Invalid "target" value, use a valid Element');
},get:function(){return this._target}}]);return a}();a.exports=n})},{select:5}],8:[function(b,c,f){(function(a,d){if("undefined"!==typeof f)d(c,b("./clipboard-action"),b("tiny-emitter"),b("good-listener"));else{var k={exports:{}};d(k,a.clipboardAction,a.tinyEmitter,a.goodListener);a.clipboard=k.exports}})(this,function(a,b,c,f){function d(a){return a&&a.__esModule?a:{"default":a}}function k(a,b){if("function"!==typeof b&&null!==b)throw new TypeError("Super expression must either be null or a function, not "+
typeof b);a.prototype=Object.create(b&&b.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}});b&&(Object.setPrototypeOf?Object.setPrototypeOf(a,b):a.__proto__=b)}function e(a,b){var c="data-clipboard-"+a;if(b.hasAttribute(c))return b.getAttribute(c)}var m=d(b);b=d(c);var l=d(f),p=function(){function a(a,b){for(var c=0;c<b.length;c++){var d=b[c];d.enumerable=d.enumerable||!1;d.configurable=!0;"value"in d&&(d.writable=!0);Object.defineProperty(a,d.key,d)}}return function(b,d,
c){d&&a(b.prototype,d);c&&a(b,c);return b}}();f=function(a){function b(a,d){if(!(this instanceof b))throw new TypeError("Cannot call a class as a function");var c;c=(b.__proto__||Object.getPrototypeOf(b)).call(this);if(!this)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");c=!c||"object"!==typeof c&&"function"!==typeof c?this:c;c.resolveOptions(d);c.listenClick(a);return c}k(b,a);p(b,[{key:"resolveOptions",value:function(){var a=0<arguments.length&&void 0!==arguments[0]?
arguments[0]:{};this.action="function"===typeof a.action?a.action:this.defaultAction;this.target="function"===typeof a.target?a.target:this.defaultTarget;this.text="function"===typeof a.text?a.text:this.defaultText}},{key:"listenClick",value:function(a){var b=this;this.listener=(0,l["default"])(a,"click",function(a){return b.onClick(a)})}},{key:"onClick",value:function(a){a=a.delegateTarget||a.currentTarget;this.clipboardAction&&(this.clipboardAction=null);this.clipboardAction=new m["default"]({action:this.action(a),
target:this.target(a),text:this.text(a),trigger:a,emitter:this})}},{key:"defaultAction",value:function(a){return e("action",a)}},{key:"defaultTarget",value:function(a){if(a=e("target",a))return document.querySelector(a)}},{key:"defaultText",value:function(a){return e("text",a)}},{key:"destroy",value:function(){this.listener.destroy();this.clipboardAction&&(this.clipboardAction.destroy(),this.clipboardAction=null)}}],[{key:"isSupported",value:function(){var a=0<arguments.length&&void 0!==arguments[0]?
arguments[0]:["copy","cut"],b=!!document.queryCommandSupported;("string"===typeof a?[a]:a).forEach(function(a){b=b&&!!document.queryCommandSupported(a)});return b}}]);return b}(b["default"]);a.exports=f})},{"./clipboard-action":7,"good-listener":4,"tiny-emitter":6}]},{},[8])(8)});