mirror of
https://github.com/nuxsmin/sysPass.git
synced 2026-03-05 16:14:11 +01:00
* [MOD] Changed copy to clipboard behavior when getting accounts password through Ajax.
This commit is contained in:
@@ -2,8 +2,8 @@
|
||||
/**
|
||||
* sysPass
|
||||
*
|
||||
* @author nuxsmin
|
||||
* @link http://syspass.org
|
||||
* @author nuxsmin
|
||||
* @link http://syspass.org
|
||||
* @copyright 2012-2017, Rubén Domínguez nuxsmin@$syspass.org
|
||||
*
|
||||
* This file is part of sysPass.
|
||||
@@ -152,6 +152,14 @@ class CustomFieldData extends CustomFieldBaseData
|
||||
return Html::sanitize($this->value);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getSafeHtmlValue()
|
||||
{
|
||||
return htmlspecialchars($this->value, ENT_QUOTES);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
|
||||
@@ -31,7 +31,7 @@ foreach ($customFields as $index => $field):?>
|
||||
type="password"
|
||||
class="mdl-textfield__input mdl-color-text--indigo-400 passwordfield__no-pki <?php echo $isView ? 'passwordfield__input-show' : 'passwordfield__input'; ?>"
|
||||
maxlength="500"
|
||||
value="<?php echo (!$showViewCustomPass && $field->getCleanValue() !== '') ? '***' : $field->getCleanValue(); ?>" <?php echo $field->getDefinition()->isRequired() ? 'required' : ''; ?> <?php echo $readonly; ?>>
|
||||
value="<?php echo (!$showViewCustomPass && $field->getValue() !== '') ? '***' : $field->getSafeHtmlValue(); ?>" <?php echo $field->getDefinition()->isRequired() ? 'required' : ''; ?> <?php echo $readonly; ?>>
|
||||
<label class="mdl-textfield__label"
|
||||
for="<?php echo $field->getDefinition()->getFormId(); ?>"><?php echo $field->getDefinition()->getName(); ?></label>
|
||||
</div>
|
||||
|
||||
@@ -590,45 +590,45 @@ sysPass.Main = function () {
|
||||
var initializeClipboard = function () {
|
||||
log.info("initializeClipboard");
|
||||
|
||||
if (!Clipboard.isSupported()) {
|
||||
if (!clipboard.isSupported()) {
|
||||
log.warn(config.LANG[65]);
|
||||
return;
|
||||
}
|
||||
|
||||
var clipboard = new Clipboard(".clip-pass-button", {
|
||||
async: function (trigger) {
|
||||
var _this = this;
|
||||
$("body").on("click", ".clip-pass-button", function () {
|
||||
var json = appActions.account.copypass($(this)).done(function (json) {
|
||||
sk.set(json.csrf);
|
||||
});
|
||||
|
||||
return appActions.account.copypass($(trigger)).then(function (json) {
|
||||
sk.set(json.csrf);
|
||||
clipboard.copy(json.responseJSON.data.accpass).then(
|
||||
function () {
|
||||
msg.ok(config.LANG[45]);
|
||||
},
|
||||
function (err) {
|
||||
msg.error(config.LANG[46]);
|
||||
}
|
||||
);
|
||||
}).on("click", ".dialog-clip-button", function () {
|
||||
var $target = $(this.dataset.clipboardTarget);
|
||||
|
||||
_this.asyncText = json.data.accpass;
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
clipboard.on("success", function (e) {
|
||||
msg.ok(config.LANG[45]);
|
||||
}).on("error", function (e) {
|
||||
msg.error(config.LANG[46]);
|
||||
});
|
||||
|
||||
// Portapapeles para claves visualizadas
|
||||
var clipboardDialog = new Clipboard(".dialog-clip-button");
|
||||
|
||||
clipboardDialog.on("success", function (e) {
|
||||
$(".dialog-text").removeClass("dialog-clip-copy");
|
||||
$(e.trigger.dataset.clipboardTarget).addClass("dialog-clip-copy");
|
||||
|
||||
e.clearSelection();
|
||||
});
|
||||
|
||||
var clipboardIcon = new Clipboard(".clip-pass-icon");
|
||||
|
||||
clipboardIcon.on("success", function (e) {
|
||||
msg.ok(config.LANG[45]);
|
||||
|
||||
e.clearSelection();
|
||||
clipboard.copy($target.text()).then(
|
||||
function () {
|
||||
$(".dialog-text").removeClass("dialog-clip-copy");
|
||||
$target.addClass("dialog-clip-copy");
|
||||
},
|
||||
function (err) {
|
||||
msg.error(config.LANG[46]);
|
||||
}
|
||||
);
|
||||
}).on("click", ".clip-pass-icon", function () {
|
||||
clipboard.copy(decodeEntities(this.dataset.clipboardText)).then(
|
||||
function () {
|
||||
msg.ok(config.LANG[45]);
|
||||
},
|
||||
function (err) {
|
||||
msg.error(config.LANG[46]);
|
||||
}
|
||||
);
|
||||
});
|
||||
};
|
||||
|
||||
@@ -770,6 +770,30 @@ sysPass.Main = function () {
|
||||
return image;
|
||||
};
|
||||
|
||||
/**
|
||||
* @author http://stackoverflow.com/users/24950/robert-k
|
||||
* @link http://stackoverflow.com/questions/5796718/html-entity-decode
|
||||
*/
|
||||
var decodeEntities = (function () {
|
||||
// this prevents any overhead from creating the object each time
|
||||
var element = document.createElement("div");
|
||||
|
||||
function decodeHTMLEntities(str) {
|
||||
if (str && typeof str === "string") {
|
||||
// strip script/html tags
|
||||
str = str.replace(/<script[^>]*>([\S\s]*?)<\/script>/gmi, "");
|
||||
str = str.replace(/<\/?\w(?:[^"'>]|"[^"]*"|'[^']*')*>/gmi, "");
|
||||
element.innerHTML = str;
|
||||
str = element.textContent;
|
||||
element.textContent = "";
|
||||
}
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
return decodeHTMLEntities;
|
||||
})();
|
||||
|
||||
// Objeto con métodos y propiedades protegidas
|
||||
var getProtected = function () {
|
||||
return $.extend({
|
||||
|
||||
39
js/app-main.min.js
vendored
39
js/app-main.min.js
vendored
@@ -1,22 +1,23 @@
|
||||
var $jscomp={scope:{}};$jscomp.defineProperty="function"==typeof Object.defineProperties?Object.defineProperty:function(a,g,f){if(f.get||f.set)throw new TypeError("ES3 does not support getters and setters.");a!=Array.prototype&&a!=Object.prototype&&(a[g]=f.value)};$jscomp.getGlobal=function(a){return"undefined"!=typeof window&&window===a?a:"undefined"!=typeof global?global:a};$jscomp.global=$jscomp.getGlobal(this);$jscomp.SYMBOL_PREFIX="jscomp_symbol_";
|
||||
$jscomp.initSymbol=function(){$jscomp.initSymbol=function(){};$jscomp.global.Symbol||($jscomp.global.Symbol=$jscomp.Symbol)};$jscomp.symbolCounter_=0;$jscomp.Symbol=function(a){return $jscomp.SYMBOL_PREFIX+(a||"")+$jscomp.symbolCounter_++};
|
||||
$jscomp.initSymbolIterator=function(){$jscomp.initSymbol();var a=$jscomp.global.Symbol.iterator;a||(a=$jscomp.global.Symbol.iterator=$jscomp.global.Symbol("iterator"));"function"!=typeof Array.prototype[a]&&$jscomp.defineProperty(Array.prototype,a,{configurable:!0,writable:!0,value:function(){return $jscomp.arrayIterator(this)}});$jscomp.initSymbolIterator=function(){}};$jscomp.arrayIterator=function(a){var g=0;return $jscomp.iteratorPrototype(function(){return g<a.length?{done:!1,value:a[g++]}:{done:!0}})};
|
||||
$jscomp.iteratorPrototype=function(a){$jscomp.initSymbolIterator();a={next:a};a[$jscomp.global.Symbol.iterator]=function(){return this};return a};$jscomp.array=$jscomp.array||{};$jscomp.iteratorFromArray=function(a,g){$jscomp.initSymbolIterator();a instanceof String&&(a+="");var f=0,d={next:function(){if(f<a.length){var e=f++;return{value:g(e,a[e]),done:!1}}d.next=function(){return{done:!0,value:void 0}};return d.next()}};d[Symbol.iterator]=function(){return d};return d};
|
||||
$jscomp.polyfill=function(a,g,f,d){if(g){f=$jscomp.global;a=a.split(".");for(d=0;d<a.length-1;d++){var e=a[d];e in f||(f[e]={});f=f[e]}a=a[a.length-1];d=f[a];g=g(d);g!=d&&null!=g&&$jscomp.defineProperty(f,a,{configurable:!0,writable:!0,value:g})}};$jscomp.polyfill("Array.prototype.keys",function(a){return a?a:function(){return $jscomp.iteratorFromArray(this,function(a){return a})}},"es6-impl","es3");
|
||||
$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={},r={},n={},k={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(){k.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(){t("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,l){var c={timeOut:0};"function"===typeof l&&(c.onHidden=l);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){k.info("getEnvironment");var l=window.location.pathname.split("/");a.APP_ROOT=window.location.protocol+"//"+window.location.host+function(){for(var b="",a=1;a<=l.length-2;a++)b+="/"+l[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()})},p={get:function(){k.info("sk:get");return $("#container").attr("data-sk")},set:function(b){k.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(){k.info("checkLogout");1===parseInt(A("logout"))&&h.sticky(a.LANG[61],function(){t("index.php")})},t=function(a){window.location.replace(a)},
|
||||
C=function(b){var l={actionId:b.data("action-id"),itemId:b.data("item-id"),sk:p.get()},c={requestDoneAction:"",setRequestData:function(a){$.extend(l,a)},getRequestData:function(){return l},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);l.sk=p.get();Object.keys(l).forEach(function(a){b.append(a,l[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 l=0;l<c.length;l++){var q=c[l];if(q.size/1E3>a.MAX_FILE_SIZE)h.error(a.LANG[18]+"<br>"+q.name+" (Max: "+a.MAX_FILE_SIZE+")");else{var d;a:{d=q.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[l]):h.error(a.LANG[19]+
|
||||
"<br>"+q.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(){k.info("fileUpload:init");var a=g(!1);b.on("dragover dragenter",function(a){k.info("fileUpload:drag");a.stopPropagation();a.preventDefault()});b.on("drop",function(a){k.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){k.info("checkPassLevel");g.passLength=a.val().length;v(zxcvbn(a.val()),a)},v=function(b,l){k.info("outputResult");var c=$(".passLevel-"+l.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){k.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(){k.info("initializeClipboard");Clipboard.isSupported()?((new Clipboard(".clip-pass-button",{async:function(a){var b=this;return e.account.copypass($(a)).then(function(a){p.set(a.csrf);b.asyncText=a.data.accpass})}})).on("success",function(b){h.ok(a.LANG[45])}).on("error",function(b){h.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){h.ok(a.LANG[45]);b.clearSelection()})):k.warn(a.LANG[65])},G=function(){k.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){k.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&&(k.info("height"),h());return d},J=function(){return $.extend({log:k,config:function(){return a},appTheme:function(){return f},appActions:function(){return e},appTriggers:function(){return d},appRequests:function(){return m},evalAction:H,resizeImage:I},r)},K=function(){return{actions:function(){return e},triggers:function(){return d},
|
||||
theme:function(){return f},sk:p,msg:h,log:k,passToClip:0,passwordData:g,outputResult:v,checkboxDetect:E,checkPassLevel:D,encryptFormValue:u,fileUpload:C,redirect:t,scrollUp:z,setContentSize:y}};(function(){k.info("init");r=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 r};
|
||||
$jscomp.iteratorPrototype=function(a){$jscomp.initSymbolIterator();a={next:a};a[$jscomp.global.Symbol.iterator]=function(){return this};return a};$jscomp.array=$jscomp.array||{};$jscomp.iteratorFromArray=function(a,g){$jscomp.initSymbolIterator();a instanceof String&&(a+="");var f=0,d={next:function(){if(f<a.length){var h=f++;return{value:g(h,a[h]),done:!1}}d.next=function(){return{done:!0,value:void 0}};return d.next()}};d[Symbol.iterator]=function(){return d};return d};
|
||||
$jscomp.polyfill=function(a,g,f,d){if(g){f=$jscomp.global;a=a.split(".");for(d=0;d<a.length-1;d++){var h=a[d];h in f||(f[h]={});f=f[h]}a=a[a.length-1];d=f[a];g=g(d);g!=d&&null!=g&&$jscomp.defineProperty(f,a,{configurable:!0,writable:!0,value:g})}};$jscomp.polyfill("Array.prototype.keys",function(a){return a?a:function(){return $jscomp.iteratorFromArray(this,function(a){return a})}},"es6-impl","es3");
|
||||
$jscomp.findInternal=function(a,g,f){a instanceof String&&(a=String(a));for(var d=a.length,h=0;h<d;h++){var m=a[h];if(g.call(f,m,h,a))return{i:h,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={},h={},m={},r={},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(){t("index.php")});
|
||||
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,e){var c={timeOut:0};"function"===typeof e&&(c.onHidden=e);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:h.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 e=window.location.pathname.split("/");a.APP_ROOT=window.location.protocol+"//"+window.location.host+function(){for(var b="",a=1;a<=e.length-2;a++)b+="/"+e[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(e){a.LANG=e.lang;a.PK=e.pk;a.CHECK_UPDATES=e.check_updates;a.CRYPT.setPublicKey(e.pk);a.TIMEZONE=e.timezone;a.LOCALE=e.locale;a.DEBUG=e.debug;a.MAX_FILE_SIZE=parseInt(e.max_file_size);a.COOKIES_ENABLED=e.cookies_enabled;"function"===typeof b&&b()})},p={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 e=$("#content").height()+200;a.css("height",e)}},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(){t("index.php")})},t=function(a){window.location.replace(a)},
|
||||
C=function(b){var e={actionId:b.data("action-id"),itemId:b.data("item-id"),sk:p.get()},c={requestDoneAction:"",setRequestData:function(a){$.extend(e,a)},getRequestData:function(){return e},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);e.sk=p.get();Object.keys(e).forEach(function(a){b.append(a,e[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?h.main.logout():k.error(a)})},d=function(e){if(5<e.length)k.error(a.LANG[17]+" (Max: 5)");else for(var c=0;c<e.length;c++){var q=e[c];if(q.size/1E3>a.MAX_FILE_SIZE)k.error(a.LANG[18]+"<br>"+q.name+" (Max: "+a.MAX_FILE_SIZE+")");else{var d;a:{d=q.name;for(var g=b.data("files-ext").toLowerCase().split(","),h=0;h<=g.length;h++)if(-1!==d.indexOf(g[h])){d=!0;break a}d=!1}d?f(e[c]):k.error(a.LANG[19]+
|
||||
"<br>"+q.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,e){l.info("outputResult");var c=$(".passLevel-"+e.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 e=b.val();""!==e&&parseInt(b.attr("data-length"))!==e.length&&(e=a.CRYPT.encrypt(e),b.val(e),b.attr("data-length",e.length))},G=function(){l.info("initializeClipboard");if(clipboard.isSupported())$("body").on("click",".clip-pass-button",function(){var b=h.account.copypass($(this)).done(function(a){p.set(a.csrf)});clipboard.copy(b.responseJSON.data.accpass).then(function(){k.ok(a.LANG[45])},function(b){k.error(a.LANG[46])})}).on("click",".dialog-clip-button",function(){var b=$(this.dataset.clipboardTarget);
|
||||
clipboard.copy(b.text()).then(function(){$(".dialog-text").removeClass("dialog-clip-copy");b.addClass("dialog-clip-copy")},function(b){k.error(a.LANG[46])})}).on("click",".clip-pass-icon",function(){clipboard.copy(F(this.dataset.clipboardText)).then(function(){k.ok(a.LANG[45])},function(b){k.error(a.LANG[46])})});else l.warn(a.LANG[65])},H=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())})},I=function(a,e){console.info("Eval: "+a);if("function"===typeof a)a(e);else throw Error("Function not found: "+a);},J=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},h=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?h():d.height>c&&(l.info("height"),k());return d},F=function(){var a=document.createElement("div");return function(b){b&&"string"===typeof b&&(b=b.replace(/<script[^>]*>([\S\s]*?)<\/script>/gmi,
|
||||
""),b=b.replace(/<\/?\w(?:[^"'>]|"[^"]*"|'[^']*')*>/gmi,""),a.innerHTML=b,b=a.textContent,a.textContent="");return b}}(),K=function(){return $.extend({log:l,config:function(){return a},appTheme:function(){return f},appActions:function(){return h},appTriggers:function(){return d},appRequests:function(){return m},evalAction:I,resizeImage:J},r)},L=function(){return{actions:function(){return h},triggers:function(){return d},theme:function(){return f},sk:p,msg:k,log:l,passToClip:0,passwordData:g,outputResult:v,
|
||||
checkboxDetect:E,checkPassLevel:D,encryptFormValue:u,fileUpload:C,redirect:t,scrollUp:z,setContentSize:y}};(function(){l.info("init");r=L();n=K();d=sysPass.Triggers(n);h=sysPass.Actions(n);m=sysPass.Requests(n);x(function(){""!==a.PK&&H();"function"===typeof sysPass.Theme&&(f=sysPass.Theme(n));!0===a.CHECK_UPDATES&&h.main.getUpdates();!1===a.COOKIES_ENABLED&&k.sticky(a.LANG[64]);G();w();B()})})();return r};
|
||||
|
||||
@@ -183,7 +183,7 @@ sysPass.Triggers = function (Common) {
|
||||
main: function () {
|
||||
log.info("views:main");
|
||||
|
||||
if (!Clipboard.isSupported()) {
|
||||
if (!clipboard.isSupported()) {
|
||||
Common.msg.info(Common.config().LANG[65]);
|
||||
}
|
||||
|
||||
|
||||
2
js/app-triggers.min.js
vendored
2
js/app-triggers.min.js
vendored
@@ -2,7 +2,7 @@ var $jscomp={scope:{},findInternal:function(b,d,e){b instanceof String&&(b=Strin
|
||||
$jscomp.getGlobal=function(b){return"undefined"!=typeof window&&window===b?b:"undefined"!=typeof global?global:b};$jscomp.global=$jscomp.getGlobal(this);$jscomp.polyfill=function(b,d,e,a){if(d){e=$jscomp.global;b=b.split(".");for(a=0;a<b.length-1;a++){var c=b[a];c in e||(e[c]={});e=e[c]}b=b[b.length-1];a=e[b];d=d(a);d!=a&&null!=d&&$jscomp.defineProperty(e,b,{configurable:!0,writable:!0,value:d})}};
|
||||
$jscomp.polyfill("Array.prototype.find",function(b){return b?b:function(b,e){return $jscomp.findInternal(this,b,e).v}},"es6-impl","es3");
|
||||
sysPass.Triggers=function(b){var d=b.log,e=function(a){var c={valueField:"id",labelField:"name",searchField:["name"]};a.find(".select-box").each(function(a){var d=$(this);c.plugins=d.hasClass("select-box-deselect")?{clear_selection:{title:b.config().LANG[51]}}:{};if(d.data("onchange")){var f=d.data("onchange").split("/");c.onChange=function(a){if(0<a)if(2===f.length)sysPassApp.actions()[f[0]][f[1]](d);else sysPassApp.actions()[f[0]](d)}}d.selectize(c)});a.find("#allowed_exts").selectize({create:function(a){return{value:a.toUpperCase(),
|
||||
text:a.toUpperCase()}},createFilter:/^[a-z0-9]{1,4}$/i,plugins:["remove_button"]});a.find("#wikifilter").selectize({create:!0,createFilter:/^[a-z0-9:._-]+$/i,plugins:["remove_button"]})};return{views:{main:function(){d.info("views:main");Clipboard.isSupported()||b.msg.info(b.config().LANG[65]);$(".btn-menu").click(function(){var a=$(this);"1"===a.attr("data-history-reset")&&b.appRequests().history.reset();b.appActions().doAction({actionId:a.data("action-id")},a.data("view"))});$("#btnLogout").click(function(a){b.appActions().main.logout()});
|
||||
text:a.toUpperCase()}},createFilter:/^[a-z0-9]{1,4}$/i,plugins:["remove_button"]});a.find("#wikifilter").selectize({create:!0,createFilter:/^[a-z0-9:._-]+$/i,plugins:["remove_button"]})};return{views:{main:function(){d.info("views:main");clipboard.isSupported()||b.msg.info(b.config().LANG[65]);$(".btn-menu").click(function(){var a=$(this);"1"===a.attr("data-history-reset")&&b.appRequests().history.reset();b.appActions().doAction({actionId:a.data("action-id")},a.data("view"))});$("#btnLogout").click(function(a){b.appActions().main.logout()});
|
||||
$("#btnPrefs").click(function(a){b.appActions().doAction({actionId:$(this).data("action-id")})});b.appActions().doAction({actionId:1},"search");"function"===typeof b.appTheme().viewsTriggers.main&&b.appTheme().viewsTriggers.main()},search:function(){d.info("views:search");var a=$("#frmSearch");0!==a.length&&(a.find("select, #rpp").on("change",function(){a.submit()}),a.find("button.btn-clear").on("click",function(b){b.preventDefault();a.find('input[name="searchfav"]').val(0);a[0].reset()}),a.find("input:text:visible:first").focus(),
|
||||
$("#globalSearch").click(function(){var b=1==$(this).prop("checked")?1:0;a.find("input[name='gsearch']").val(b);a.submit()}),"function"===typeof b.appTheme().viewsTriggers.search&&b.appTheme().viewsTriggers.search())},login:function(){d.info("views:login")},passreset:function(){d.info("views:passreset");var a=$("#frmPassReset");b.appTheme().passwordDetect(a)},footer:function(){d.info("views:footer")},common:function(a){d.info("views:common");e(a);"function"===typeof b.appTheme().viewsTriggers.common&&
|
||||
b.appTheme().viewsTriggers.common(a);b.appTriggers().updateFormHash(a)},datatabs:function(a){d.info("views:datatabs");$(".datagrid-action-search>form").each(function(){var a=$(this);a.find("button.btn-clear").on("click",function(b){b.preventDefault();a.trigger("reset")})})},config:function(){d.info("views:config");var a=$("#drop-import-files");if(0<a.length){var c=b.fileUpload(a);c.url=b.appActions().ajaxUrl.config["import"];c.beforeSendAction=function(){c.setRequestData({sk:b.sk.get(),csvDelimiter:$("#csvDelimiter").val(),
|
||||
|
||||
1121
js/clipboard.js
1121
js/clipboard.js
File diff suppressed because it is too large
Load Diff
32
js/clipboard.min.js
vendored
32
js/clipboard.min.js
vendored
@@ -1,23 +1,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&&null!=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,m=0;m<a.length;m++)d(a[m]);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 l=a.apply(this,arguments);d.addEventListener(h,l,e);return{destroy:function(){d.removeEventListener(h,l,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"),m=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 m(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,l=c.length;e<l;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.async=a.async;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 l=d(b);b=d(c);var m=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;this.async=a.async;this.asyncText=""}},{key:"listenClick",value:function(a){var b=this;this.listener=(0,m["default"])(a,"click",function(a){return b.onClick(a)})}},{key:"onClick",value:function(a){var b=
|
||||
a.delegateTarget||a.currentTarget;this.clipboardAction&&(this.clipboardAction=null);if("function"===typeof this.async){var c=this;this.async(b).then(function(){c.clipboardAction=new l["default"]({action:c.action(b),target:c.target(b),text:c.asyncText,trigger:b,emitter:c})})}else this.clipboardAction=new l["default"]({action:this.action(b),target:this.target(b),text:this.text(b),trigger:b,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)});
|
||||
(function(e,c){"undefined"!==typeof module?module.exports=c():"function"===typeof define&&"object"===typeof define.amd?define(c):this[e]=c()})("clipboard",function(){if("undefined"===typeof document||!document.addEventListener)return null;var e={};e.copy=function(){function c(){d=!1;b=null;g&&window.getSelection().removeAllRanges();g=!1}var d=!1,b=null,g=!1;document.addEventListener("copy",function(c){if(d){for(var f in b)c.clipboardData.setData(f,b[f]);c.preventDefault()}});return function(f){return new Promise(function(e,
|
||||
k){function h(b){try{if(document.execCommand("copy"))c(),e();else{if(b)throw c(),Error("Unable to copy. Perhaps it's not available in your browser?");var d=document.getSelection();if(!document.queryCommandEnabled("copy")&&d.isCollapsed){var f=document.createRange();f.selectNodeContents(document.body);d.removeAllRanges();d.addRange(f);g=!0}h(!0)}}catch(a){c(),k(a)}}d=!0;b="string"===typeof f?{"text/plain":f}:f instanceof Node?{"text/html":(new XMLSerializer).serializeToString(f)}:f;h(!1)})}}();e.paste=
|
||||
function(){var c=!1,d,b;document.addEventListener("paste",function(g){if(c){c=!1;g.preventDefault();var f=d;d=null;f(g.clipboardData.getData(b))}});return function(g){return new Promise(function(f,e){c=!0;d=f;b=g||"text/plain";try{document.execCommand("paste")||(c=!1,e(Error("Unable to paste. Pasting only works in Internet Explorer at the moment.")))}catch(k){c=!1,e(Error(k))}})}}();e.isSupported=function(){var c=0<arguments.length&&void 0!==arguments[0]?arguments[0]:["copy","cut"],d=!!document.queryCommandSupported;
|
||||
("string"===typeof c?[c]:c).forEach(function(b){d=d&&!!document.queryCommandSupported(b)});return d};"undefined"===typeof ClipboardEvent&&"undefined"!==typeof window.clipboardData&&"undefined"!==typeof window.clipboardData.setData&&(function(c){function d(a,b){return function(){a.apply(b,arguments)}}function b(a){if("object"!=typeof this)throw new TypeError("Promises must be constructed via new");if("function"!=typeof a)throw new TypeError("not a function");this._value=this._state=null;this._deferreds=
|
||||
[];m(a,d(f,this),d(h,this))}function e(a){var b=this;return null===this._state?void this._deferreds.push(a):void p(function(){var c=b._state?a.onFulfilled:a.onRejected;if(null===c)return void(b._state?a.resolve:a.reject)(b._value);var d;try{d=c(b._value)}catch(l){return void a.reject(l)}a.resolve(d)})}function f(a){try{if(a===this)throw new TypeError("A promise cannot be resolved with itself.");if(a&&("object"==typeof a||"function"==typeof a)){var b=a.then;if("function"==typeof b)return void m(d(b,
|
||||
a),d(f,this),d(h,this))}this._state=!0;this._value=a;k.call(this)}catch(r){h.call(this,r)}}function h(a){this._state=!1;this._value=a;k.call(this)}function k(){for(var a=0,b=this._deferreds.length;b>a;a++)e.call(this,this._deferreds[a]);this._deferreds=null}function n(a,b,c,d){this.onFulfilled="function"==typeof a?a:null;this.onRejected="function"==typeof b?b:null;this.resolve=c;this.reject=d}function m(a,b,c){var d=!1;try{a(function(a){d||(d=!0,b(a))},function(a){d||(d=!0,c(a))})}catch(l){d||(d=
|
||||
!0,c(l))}}var p=b.immediateFn||"function"==typeof setImmediate&&setImmediate||function(a){setTimeout(a,1)},q=Array.isArray||function(a){return"[object Array]"===Object.prototype.toString.call(a)};b.prototype["catch"]=function(a){return this.then(null,a)};b.prototype.then=function(a,c){var d=this;return new b(function(b,f){e.call(d,new n(a,c,b,f))})};b.all=function(){var a=Array.prototype.slice.call(1===arguments.length&&q(arguments[0])?arguments[0]:arguments);return new b(function(b,c){function d(e,
|
||||
g){try{if(g&&("object"==typeof g||"function"==typeof g)){var h=g.then;if("function"==typeof h)return void h.call(g,function(a){d(e,a)},c)}a[e]=g;0===--f&&b(a)}catch(t){c(t)}}if(0===a.length)return b([]);for(var f=a.length,e=0;e<a.length;e++)d(e,a[e])})};b.resolve=function(a){return a&&"object"==typeof a&&a.constructor===b?a:new b(function(b){b(a)})};b.reject=function(a){return new b(function(b,c){c(a)})};b.race=function(a){return new b(function(b,c){for(var d=0,e=a.length;e>d;d++)a[d].then(b,c)})};
|
||||
"undefined"!=typeof module&&module.exports?module.exports=b:c.Promise||(c.Promise=b)}(this),e.copy=function(c){return new Promise(function(d,b){if("string"!==typeof c&&!("text/plain"in c))throw Error("You must provide a text/plain type.");window.clipboardData.setData("Text","string"===typeof c?c:c["text/plain"])?d():b(Error("Copying was rejected."))})},e.paste=function(){return new Promise(function(c,d){var b=window.clipboardData.getData("Text");b?c(b):d(Error("Pasting was rejected."))})});return e});
|
||||
|
||||
Reference in New Issue
Block a user