You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
368 lines
29 KiB
368 lines
29 KiB
/* globals jQuery */
|
|
/*!
|
|
* Waves v0.7.5
|
|
* http://fian.my.id/Waves
|
|
*
|
|
* Copyright 2014-2016 Alfiana E. Sibuea and other contributors
|
|
* Released under the MIT license
|
|
* https://github.com/fians/Waves/blob/master/LICENSE
|
|
*/
|
|
!function(a,b){"use strict";"function"==typeof define&&define.amd?define([],function(){return b.apply(a)}):"object"==typeof exports?module.exports=b.call(a):a.Waves=b.call(a)}("object"==typeof global?global:this,function(){"use strict";function a(a){return null!==a&&a===a.window}function b(b){return a(b)?b:9===b.nodeType&&b.defaultView}function c(a){var b=typeof a;return"function"===b||"object"===b&&!!a}function d(a){return c(a)&&a.nodeType>0}function e(a){var b=m.call(a);return"[object String]"===b?l(a):c(a)&&/^\[object (Array|HTMLCollection|NodeList|Object)\]$/.test(b)&&a.hasOwnProperty("length")?a:d(a)?[a]:[]}function f(a){var c,d,e={top:0,left:0},f=a&&a.ownerDocument;return c=f.documentElement,"undefined"!=typeof a.getBoundingClientRect&&(e=a.getBoundingClientRect()),d=b(f),{top:e.top+d.pageYOffset-c.clientTop,left:e.left+d.pageXOffset-c.clientLeft}}function g(a){var b="";for(var c in a)a.hasOwnProperty(c)&&(b+=c+":"+a[c]+";");return b}function h(a,b,c){if(c){c.classList.remove("waves-rippling");var d=c.getAttribute("data-x"),e=c.getAttribute("data-y"),f=c.getAttribute("data-scale"),h=c.getAttribute("data-translate"),i=Date.now()-Number(c.getAttribute("data-hold")),j=350-i;0>j&&(j=0),"mousemove"===a.type&&(j=150);var k="mousemove"===a.type?2500:o.duration;setTimeout(function(){var a={top:e+"px",left:d+"px",opacity:"0","-webkit-transition-duration":k+"ms","-moz-transition-duration":k+"ms","-o-transition-duration":k+"ms","transition-duration":k+"ms","-webkit-transform":f+" "+h,"-moz-transform":f+" "+h,"-ms-transform":f+" "+h,"-o-transform":f+" "+h,transform:f+" "+h};c.setAttribute("style",g(a)),setTimeout(function(){try{b.removeChild(c)}catch(a){return!1}},k)},j)}}function i(a){if(q.allowEvent(a)===!1)return null;for(var b=null,c=a.target||a.srcElement;c.parentElement;){if(!(c instanceof SVGElement)&&c.classList.contains("waves-effect")){b=c;break}c=c.parentElement}return b}function j(a){var b=i(a);if(null!==b){if(b.disabled||b.getAttribute("disabled")||b.classList.contains("disabled"))return;if(q.registerEvent(a),"touchstart"===a.type&&o.delay){var c=!1,d=setTimeout(function(){d=null,o.show(a,b)},o.delay),e=function(e){d&&(clearTimeout(d),d=null,o.show(a,b)),c||(c=!0,o.hide(e,b))},f=function(a){d&&(clearTimeout(d),d=null),e(a)};b.addEventListener("touchmove",f,!1),b.addEventListener("touchend",e,!1),b.addEventListener("touchcancel",e,!1)}else o.show(a,b),n&&(b.addEventListener("touchend",o.hide,!1),b.addEventListener("touchcancel",o.hide,!1)),b.addEventListener("mouseup",o.hide,!1),b.addEventListener("mouseleave",o.hide,!1)}}var k=k||{},l=document.querySelectorAll.bind(document),m=Object.prototype.toString,n="ontouchstart"in window,o={duration:750,delay:200,show:function(a,b,c){if(2===a.button)return!1;b=b||this;var d=document.createElement("div");d.className="waves-ripple waves-rippling",b.appendChild(d);var e=f(b),h=0,i=0;"touches"in a&&a.touches.length?(h=a.touches[0].pageY-e.top,i=a.touches[0].pageX-e.left):(h=a.pageY-e.top,i=a.pageX-e.left),i=i>=0?i:0,h=h>=0?h:0;var j="scale("+b.clientWidth/100*3+")",k="translate(0,0)";c&&(k="translate("+c.x+"px, "+c.y+"px)"),d.setAttribute("data-hold",Date.now()),d.setAttribute("data-x",i),d.setAttribute("data-y",h),d.setAttribute("data-scale",j),d.setAttribute("data-translate",k);var l={top:h+"px",left:i+"px"};d.classList.add("waves-notransition"),d.setAttribute("style",g(l)),d.classList.remove("waves-notransition"),l["-webkit-transform"]=j+" "+k,l["-moz-transform"]=j+" "+k,l["-ms-transform"]=j+" "+k,l["-o-transform"]=j+" "+k,l.transform=j+" "+k,l.opacity="1";var m="mousemove"===a.type?2500:o.duration;l["-webkit-transition-duration"]=m+"ms",l["-moz-transition-duration"]=m+"ms",l["-o-transition-duration"]=m+"ms",l["transition-duration"]=m+"ms",d.setAttribute("style",g(l))},hide:function(a,b){b=b||this;for(var c=b.getElementsByClassName("waves-rippling"),d=0,e=c.length;e>d;d++)h(a,b,c[d])}},p={input:function(a){var b=a.parentNode;if("i"!==b.tagName.toLowerCase()||!b.classList.contains("waves-effect")){var c=document.createElement("i");c.className=a.className+" waves-input-wrapper",a.className="waves-button-input",b.replaceChild(c,a),c.appendChild(a);var d=window.getComputedStyle(a,null),e=d.color,f=d.backgroundColor;c.setAttribute("style","color:"+e+";background:"+f),a.setAttribute("style","background-color:rgba(0,0,0,0);")}},img:function(a){var b=a.parentNode;if("i"!==b.tagName.toLowerCase()||!b.classList.contains("waves-effect")){var c=document.createElement("i");b.replaceChild(c,a),c.appendChild(a)}}},q={touches:0,allowEvent:function(a){var b=!0;return/^(mousedown|mousemove)$/.test(a.type)&&q.touches&&(b=!1),b},registerEvent:function(a){var b=a.type;"touchstart"===b?q.touches+=1:/^(touchend|touchcancel)$/.test(b)&&setTimeout(function(){q.touches&&(q.touches-=1)},500)}};return k.init=function(a){var b=document.body;a=a||{},"duration"in a&&(o.duration=a.duration),"delay"in a&&(o.delay=a.delay),n&&(b.addEventListener("touchstart",j,!1),b.addEventListener("touchcancel",q.registerEvent,!1),b.addEventListener("touchend",q.registerEvent,!1)),b.addEventListener("mousedown",j,!1)},k.attach=function(a,b){a=e(a),"[object Array]"===m.call(b)&&(b=b.join(" ")),b=b?" "+b:"";for(var c,d,f=0,g=a.length;g>f;f++)c=a[f],d=c.tagName.toLowerCase(),-1!==["input","img"].indexOf(d)&&(p[d](c),c=c.parentElement),-1===c.className.indexOf("waves-effect")&&(c.className+=" waves-effect"+b)},k.ripple=function(a,b){a=e(a);var c=a.length;if(b=b||{},b.wait=b.wait||0,b.position=b.position||null,c)for(var d,g,h,i={},j=0,k={type:"mousedown",button:1},l=function(a,b){return function(){o.hide(a,b)}};c>j;j++)if(d=a[j],g=b.position||{x:d.clientWidth/2,y:d.clientHeight/2},h=f(d),i.x=h.left+g.x,i.y=h.top+g.y,k.pageX=i.x,k.pageY=i.y,o.show(k,d),b.wait>=0&&null!==b.wait){var m={type:"mouseup",button:1};setTimeout(l(m,d),b.wait)}},k.calm=function(a){a=e(a);for(var b={type:"mouseup",button:1},c=0,d=a.length;d>c;c++)o.hide(b,a[c])},k.displayEffect=function(a){k.init(a)},k});
|
|
//# sourceMappingURL=waves.min.js.map
|
|
(function ($) {
|
|
// Selector to select only not already processed elements
|
|
$.expr[":"].notmdproc = function (obj) {
|
|
if ($(obj).data("mdproc")) {
|
|
return false;
|
|
} else {
|
|
return true;
|
|
}
|
|
};
|
|
|
|
function _isChar(evt) {
|
|
if (typeof evt.which == "undefined") {
|
|
return true;
|
|
} else if (typeof evt.which == "number" && evt.which > 0) {
|
|
return (
|
|
!evt.ctrlKey
|
|
&& !evt.metaKey
|
|
&& !evt.altKey
|
|
&& evt.which != 8 // backspace
|
|
&& evt.which != 9 // tab
|
|
&& evt.which != 13 // enter
|
|
&& evt.which != 16 // shift
|
|
&& evt.which != 17 // ctrl
|
|
&& evt.which != 20 // caps lock
|
|
&& evt.which != 27 // escape
|
|
);
|
|
}
|
|
return false;
|
|
}
|
|
|
|
function _addFormGroupFocus(element) {
|
|
var $element = $(element);
|
|
if (!$element.prop('disabled')) { // this is showing as undefined on chrome but works fine on firefox??
|
|
$element.closest(".form-group").addClass("is-focused");
|
|
}
|
|
}
|
|
|
|
function _toggleDisabledState($element, state) {
|
|
var $target;
|
|
if ($element.hasClass('checkbox-inline') || $element.hasClass('radio-inline')) {
|
|
$target = $element;
|
|
} else {
|
|
$target = $element.closest('.checkbox').length ? $element.closest('.checkbox') : $element.closest('.radio');
|
|
}
|
|
return $target.toggleClass('disabled', state);
|
|
}
|
|
|
|
function _toggleTypeFocus($input) {
|
|
var disabledToggleType = false;
|
|
if ($input.is($.material.options.checkboxElements) || $input.is($.material.options.radioElements)) {
|
|
disabledToggleType = true;
|
|
}
|
|
$input.closest('label').hover(function () {
|
|
var $i = $(this).find('input');
|
|
var isDisabled = $i.prop('disabled'); // hack because the _addFormGroupFocus() wasn't identifying the property on chrome
|
|
if (disabledToggleType) {
|
|
_toggleDisabledState($(this), isDisabled);
|
|
}
|
|
if (!isDisabled) {
|
|
_addFormGroupFocus($i); // need to find the input so we can check disablement
|
|
}
|
|
},
|
|
function () {
|
|
_removeFormGroupFocus($(this).find('input'));
|
|
});
|
|
}
|
|
|
|
function _removeFormGroupFocus(element) {
|
|
$(element).closest(".form-group").removeClass("is-focused"); // remove class from form-group
|
|
}
|
|
|
|
$.material = {
|
|
"options": {
|
|
// These options set what will be started by $.material.init()
|
|
"validate": true,
|
|
"input": true,
|
|
"ripples": true,
|
|
"checkbox": true,
|
|
"togglebutton": true,
|
|
"radio": true,
|
|
"arrive": true,
|
|
"autofill": false,
|
|
|
|
"withRipples": [
|
|
".btn:not(.btn-link)",
|
|
".list-group-item",
|
|
".card-image",
|
|
".navbar a:not(.withoutripple)",
|
|
".dropdown-menu a",
|
|
".nav-tabs a:not(.withoutripple)",
|
|
".withripple",
|
|
".pagination li:not(.active):not(.disabled) a:not(.withoutripple)"
|
|
].join(","),
|
|
"inputElements": "input.form-control, textarea.form-control, select.form-control",
|
|
"checkboxElements": ".checkbox > label > input[type=checkbox], label.checkbox-inline > input[type=checkbox]",
|
|
"togglebuttonElements": ".togglebutton > label > input[type=checkbox]",
|
|
"radioElements": ".radio > label > input[type=radio], label.radio-inline > input[type=radio]"
|
|
},
|
|
"checkbox": function (selector) {
|
|
// Add fake-checkbox to material checkboxes
|
|
var $input = $((selector) ? selector : this.options.checkboxElements)
|
|
.filter(":notmdproc")
|
|
.data("mdproc", true)
|
|
.after("<span class='checkbox-material'><span class='check'></span></span>");
|
|
|
|
_toggleTypeFocus($input);
|
|
},
|
|
"togglebutton": function (selector) {
|
|
// Add fake-checkbox to material checkboxes
|
|
var $input = $((selector) ? selector : this.options.togglebuttonElements)
|
|
.filter(":notmdproc")
|
|
.data("mdproc", true)
|
|
.after("<span class='toggle'></span>");
|
|
|
|
_toggleTypeFocus($input);
|
|
},
|
|
"radio": function (selector) {
|
|
// Add fake-radio to material radios
|
|
var $input = $((selector) ? selector : this.options.radioElements)
|
|
.filter(":notmdproc")
|
|
.data("mdproc", true)
|
|
.after("<span class='circle'></span><span class='check'></span>");
|
|
|
|
_toggleTypeFocus($input);
|
|
},
|
|
"input": function (selector) {
|
|
$((selector) ? selector : this.options.inputElements)
|
|
.filter(":notmdproc")
|
|
.data("mdproc", true)
|
|
.each(function () {
|
|
var $input = $(this);
|
|
|
|
// Requires form-group standard markup (will add it if necessary)
|
|
var $formGroup = $input.closest(".form-group"); // note that form-group may be grandparent in the case of an input-group
|
|
if ($formGroup.length === 0 && $input.attr('type') !== "hidden" && !$input.attr('hidden')) {
|
|
$input.wrap("<div class='form-group'></div>");
|
|
$formGroup = $input.closest(".form-group"); // find node after attached (otherwise additional attachments don't work)
|
|
}
|
|
|
|
// Legacy - Add hint label if using the old shorthand data-hint attribute on the input
|
|
if ($input.attr("data-hint")) {
|
|
$input.after("<p class='help-block'>" + $input.attr("data-hint") + "</p>");
|
|
$input.removeAttr("data-hint");
|
|
}
|
|
|
|
// Legacy - Change input-sm/lg to form-group-sm/lg instead (preferred standard and simpler css/less variants)
|
|
var legacySizes = {
|
|
"input-lg": "form-group-lg",
|
|
"input-sm": "form-group-sm"
|
|
};
|
|
$.each(legacySizes, function (legacySize, standardSize) {
|
|
if ($input.hasClass(legacySize)) {
|
|
$input.removeClass(legacySize);
|
|
$formGroup.addClass(standardSize);
|
|
}
|
|
});
|
|
|
|
// Legacy - Add label-floating if using old shorthand <input class="floating-label" placeholder="foo">
|
|
if ($input.hasClass("floating-label")) {
|
|
var placeholder = $input.attr("placeholder");
|
|
$input.attr("placeholder", null).removeClass("floating-label");
|
|
var id = $input.attr("id");
|
|
var forAttribute = "";
|
|
if (id) {
|
|
forAttribute = "for='" + id + "'";
|
|
}
|
|
$formGroup.addClass("label-floating");
|
|
$input.after("<label " + forAttribute + "class='control-label'>" + placeholder + "</label>");
|
|
}
|
|
|
|
// Set as empty if is empty (damn I must improve this...)
|
|
if ($input.val() === null || $input.val() == "undefined" || $input.val() === "") {
|
|
$formGroup.addClass("is-empty");
|
|
}
|
|
|
|
// Support for file input
|
|
if ($formGroup.find("input[type=file]").length > 0) {
|
|
$formGroup.addClass("is-fileinput");
|
|
}
|
|
});
|
|
},
|
|
"attachInputEventHandlers": function () {
|
|
var validate = this.options.validate;
|
|
|
|
$(document)
|
|
.on("keydown paste", ".form-control", function (e) {
|
|
if (_isChar(e)) {
|
|
$(this).closest(".form-group").removeClass("is-empty");
|
|
}
|
|
})
|
|
.on("keyup change", ".form-control", function () {
|
|
var $input = $(this);
|
|
var $formGroup = $input.closest(".form-group");
|
|
var isValid = (typeof $input[0].checkValidity === "undefined" || $input[0].checkValidity());
|
|
|
|
if ($input.val() === "") {
|
|
$formGroup.addClass("is-empty");
|
|
}
|
|
else {
|
|
$formGroup.removeClass("is-empty");
|
|
}
|
|
|
|
// Validation events do not bubble, so they must be attached directly to the input: http://jsfiddle.net/PEpRM/1/
|
|
// Further, even the bind method is being caught, but since we are already calling #checkValidity here, just alter
|
|
// the form-group on change.
|
|
//
|
|
// NOTE: I'm not sure we should be intervening regarding validation, this seems better as a README and snippet of code.
|
|
// BUT, I've left it here for backwards compatibility.
|
|
if (validate) {
|
|
if (isValid) {
|
|
$formGroup.removeClass("has-error");
|
|
}
|
|
else {
|
|
$formGroup.addClass("has-error");
|
|
}
|
|
}
|
|
})
|
|
.on("focus", ".form-control, .form-group.is-fileinput", function () {
|
|
_addFormGroupFocus(this);
|
|
})
|
|
.on("blur", ".form-control, .form-group.is-fileinput", function () {
|
|
_removeFormGroupFocus(this);
|
|
})
|
|
// make sure empty is added back when there is a programmatic value change.
|
|
// NOTE: programmatic changing of value using $.val() must trigger the change event i.e. $.val('x').trigger('change')
|
|
.on("change", ".form-group input", function () {
|
|
var $input = $(this);
|
|
if ($input.attr("type") == "file") {
|
|
return;
|
|
}
|
|
|
|
var $formGroup = $input.closest(".form-group");
|
|
var value = $input.val();
|
|
if (value) {
|
|
$formGroup.removeClass("is-empty");
|
|
} else {
|
|
$formGroup.addClass("is-empty");
|
|
}
|
|
})
|
|
// set the fileinput readonly field with the name of the file
|
|
.on("change", ".form-group.is-fileinput input[type='file']", function () {
|
|
var $input = $(this);
|
|
var $formGroup = $input.closest(".form-group");
|
|
var value = "";
|
|
$.each(this.files, function (i, file) {
|
|
value += file.name + ", ";
|
|
});
|
|
value = value.substring(0, value.length - 2);
|
|
if (value) {
|
|
$formGroup.removeClass("is-empty");
|
|
} else {
|
|
$formGroup.addClass("is-empty");
|
|
}
|
|
$formGroup.find("input.form-control[readonly]").val(value);
|
|
});
|
|
},
|
|
"ripples": function (selector) {
|
|
alert(0);
|
|
},
|
|
"autofill": function () {
|
|
// This part of code will detect autofill when the page is loading (username and password inputs for example)
|
|
var loading = setInterval(function () {
|
|
$("input[type!=checkbox]").each(function () {
|
|
var $this = $(this);
|
|
if ($this.val() && $this.val() !== $this.attr("value")) {
|
|
$this.trigger("change");
|
|
}
|
|
});
|
|
}, 100);
|
|
|
|
// After 10 seconds we are quite sure all the needed inputs are autofilled then we can stop checking them
|
|
setTimeout(function () {
|
|
clearInterval(loading);
|
|
}, 10000);
|
|
},
|
|
"attachAutofillEventHandlers": function () {
|
|
// Listen on inputs of the focused form (because user can select from the autofill dropdown only when the input has focus)
|
|
var focused;
|
|
$(document)
|
|
.on("focus", "input", function () {
|
|
var $inputs = $(this).parents("form").find("input").not("[type=file]");
|
|
focused = setInterval(function () {
|
|
$inputs.each(function () {
|
|
var $this = $(this);
|
|
if ($this.val() !== $this.attr("value")) {
|
|
$this.trigger("change");
|
|
}
|
|
});
|
|
}, 100);
|
|
})
|
|
.on("blur", ".form-group input", function () {
|
|
clearInterval(focused);
|
|
});
|
|
},
|
|
"init": function (options) {
|
|
this.options = $.extend({}, this.options, options);
|
|
var $document = $(document);
|
|
|
|
if ($.fn.ripples && this.options.ripples) {
|
|
alert("0");
|
|
}
|
|
if (this.options.input) {
|
|
this.input();
|
|
this.attachInputEventHandlers();
|
|
}
|
|
if (this.options.checkbox) {
|
|
this.checkbox();
|
|
}
|
|
if (this.options.togglebutton) {
|
|
this.togglebutton();
|
|
}
|
|
if (this.options.radio) {
|
|
this.radio();
|
|
}
|
|
if (this.options.autofill) {
|
|
this.autofill();
|
|
this.attachAutofillEventHandlers();
|
|
}
|
|
Waves.attach('a', ['waves-block']);
|
|
Waves.attach('.btn');
|
|
Waves.attach('.btn-fab',['waves-circle']);
|
|
Waves.init();
|
|
if (document.arrive && this.options.arrive) {
|
|
if ($.fn.ripples && this.options.ripples) {
|
|
$document.arrive(this.options.withRipples, function () {
|
|
alert(0);
|
|
});
|
|
}
|
|
if (this.options.input) {
|
|
$document.arrive(this.options.inputElements, function () {
|
|
$.material.input($(this));
|
|
});
|
|
}
|
|
if (this.options.checkbox) {
|
|
$document.arrive(this.options.checkboxElements, function () {
|
|
$.material.checkbox($(this));
|
|
});
|
|
}
|
|
if (this.options.radio) {
|
|
$document.arrive(this.options.radioElements, function () {
|
|
$.material.radio($(this));
|
|
});
|
|
}
|
|
if (this.options.togglebutton) {
|
|
$document.arrive(this.options.togglebuttonElements, function () {
|
|
$.material.togglebutton($(this));
|
|
});
|
|
}
|
|
|
|
}
|
|
}
|
|
};
|
|
|
|
})(jQuery);
|
|
|
|
!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var e;e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,e.Clipboard=t()}}(function(){var t,e,n;return function t(e,n,o){function i(a,c){if(!n[a]){if(!e[a]){var l="function"==typeof require&&require;if(!c&&l)return l(a,!0);if(r)return r(a,!0);var s=new Error("Cannot find module '"+a+"'");throw s.code="MODULE_NOT_FOUND",s}var u=n[a]={exports:{}};e[a][0].call(u.exports,function(t){var n=e[a][1][t];return i(n||t)},u,u.exports,t,e,n,o)}return n[a].exports}for(var r="function"==typeof require&&require,a=0;a<o.length;a++)i(o[a]);return i}({1:[function(t,e,n){function o(t,e){for(;t&&t.nodeType!==i;){if("function"==typeof t.matches&&t.matches(e))return t;t=t.parentNode}}var i=9;if("undefined"!=typeof Element&&!Element.prototype.matches){var r=Element.prototype;r.matches=r.matchesSelector||r.mozMatchesSelector||r.msMatchesSelector||r.oMatchesSelector||r.webkitMatchesSelector}e.exports=o},{}],2:[function(t,e,n){function o(t,e,n,o,r){var a=i.apply(this,arguments);return t.addEventListener(n,a,r),{destroy:function(){t.removeEventListener(n,a,r)}}}function i(t,e,n,o){return function(n){n.delegateTarget=r(n.target,e),n.delegateTarget&&o.call(t,n)}}var r=t("./closest");e.exports=o},{"./closest":1}],3:[function(t,e,n){n.node=function(t){return void 0!==t&&t instanceof HTMLElement&&1===t.nodeType},n.nodeList=function(t){var e=Object.prototype.toString.call(t);return void 0!==t&&("[object NodeList]"===e||"[object HTMLCollection]"===e)&&"length"in t&&(0===t.length||n.node(t[0]))},n.string=function(t){return"string"==typeof t||t instanceof String},n.fn=function(t){return"[object Function]"===Object.prototype.toString.call(t)}},{}],4:[function(t,e,n){function o(t,e,n){if(!t&&!e&&!n)throw new Error("Missing required arguments");if(!c.string(e))throw new TypeError("Second argument must be a String");if(!c.fn(n))throw new TypeError("Third argument must be a Function");if(c.node(t))return i(t,e,n);if(c.nodeList(t))return r(t,e,n);if(c.string(t))return a(t,e,n);throw new TypeError("First argument must be a String, HTMLElement, HTMLCollection, or NodeList")}function i(t,e,n){return t.addEventListener(e,n),{destroy:function(){t.removeEventListener(e,n)}}}function r(t,e,n){return Array.prototype.forEach.call(t,function(t){t.addEventListener(e,n)}),{destroy:function(){Array.prototype.forEach.call(t,function(t){t.removeEventListener(e,n)})}}}function a(t,e,n){return l(document.body,t,e,n)}var c=t("./is"),l=t("delegate");e.exports=o},{"./is":3,delegate:2}],5:[function(t,e,n){function o(t){var e;if("SELECT"===t.nodeName)t.focus(),e=t.value;else if("INPUT"===t.nodeName||"TEXTAREA"===t.nodeName){var n=t.hasAttribute("readonly");n||t.setAttribute("readonly",""),t.select(),t.setSelectionRange(0,t.value.length),n||t.removeAttribute("readonly"),e=t.value}else{t.hasAttribute("contenteditable")&&t.focus();var o=window.getSelection(),i=document.createRange();i.selectNodeContents(t),o.removeAllRanges(),o.addRange(i),e=o.toString()}return e}e.exports=o},{}],6:[function(t,e,n){function o(){}o.prototype={on:function(t,e,n){var o=this.e||(this.e={});return(o[t]||(o[t]=[])).push({fn:e,ctx:n}),this},once:function(t,e,n){function o(){i.off(t,o),e.apply(n,arguments)}var i=this;return o._=e,this.on(t,o,n)},emit:function(t){var e=[].slice.call(arguments,1),n=((this.e||(this.e={}))[t]||[]).slice(),o=0,i=n.length;for(o;o<i;o++)n[o].fn.apply(n[o].ctx,e);return this},off:function(t,e){var n=this.e||(this.e={}),o=n[t],i=[];if(o&&e)for(var r=0,a=o.length;r<a;r++)o[r].fn!==e&&o[r].fn._!==e&&i.push(o[r]);return i.length?n[t]=i:delete n[t],this}},e.exports=o},{}],7:[function(e,n,o){!function(i,r){if("function"==typeof t&&t.amd)t(["module","select"],r);else if(void 0!==o)r(n,e("select"));else{var a={exports:{}};r(a,i.select),i.clipboardAction=a.exports}}(this,function(t,e){"use strict";function n(t){return t&&t.__esModule?t:{default:t}}function o(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}var i=n(e),r="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},a=function(){function t(t,e){for(var n=0;n<e.length;n++){var o=e[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,o.key,o)}}return function(e,n,o){return n&&t(e.prototype,n),o&&t(e,o),e}}(),c=function(){function t(e){o(this,t),this.resolveOptions(e),this.initSelection()}return a(t,[{key:"resolveOptions",value:function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.action=e.action,this.container=e.container,this.emitter=e.emitter,this.target=e.target,this.text=e.text,this.trigger=e.trigger,this.selectedText=""}},{key:"initSelection",value:function t(){this.text?this.selectFake():this.target&&this.selectTarget()}},{key:"selectFake",value:function t(){var e=this,n="rtl"==document.documentElement.getAttribute("dir");this.removeFake(),this.fakeHandlerCallback=function(){return e.removeFake()},this.fakeHandler=this.container.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[n?"right":"left"]="-9999px";var o=window.pageYOffset||document.documentElement.scrollTop;this.fakeElem.style.top=o+"px",this.fakeElem.setAttribute("readonly",""),this.fakeElem.value=this.text,this.container.appendChild(this.fakeElem),this.selectedText=(0,i.default)(this.fakeElem),this.copyText()}},{key:"removeFake",value:function t(){this.fakeHandler&&(this.container.removeEventListener("click",this.fakeHandlerCallback),this.fakeHandler=null,this.fakeHandlerCallback=null),this.fakeElem&&(this.container.removeChild(this.fakeElem),this.fakeElem=null)}},{key:"selectTarget",value:function t(){this.selectedText=(0,i.default)(this.target),this.copyText()}},{key:"copyText",value:function t(){var e=void 0;try{e=document.execCommand(this.action)}catch(t){e=!1}this.handleResult(e)}},{key:"handleResult",value:function t(e){this.emitter.emit(e?"success":"error",{action:this.action,text:this.selectedText,trigger:this.trigger,clearSelection:this.clearSelection.bind(this)})}},{key:"clearSelection",value:function t(){this.trigger&&this.trigger.focus(),window.getSelection().removeAllRanges()}},{key:"destroy",value:function t(){this.removeFake()}},{key:"action",set:function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"copy";if(this._action=e,"copy"!==this._action&&"cut"!==this._action)throw new Error('Invalid "action" value, use either "copy" or "cut"')},get:function t(){return this._action}},{key:"target",set:function t(e){if(void 0!==e){if(!e||"object"!==(void 0===e?"undefined":r(e))||1!==e.nodeType)throw new Error('Invalid "target" value, use a valid Element');if("copy"===this.action&&e.hasAttribute("disabled"))throw new Error('Invalid "target" attribute. Please use "readonly" instead of "disabled" attribute');if("cut"===this.action&&(e.hasAttribute("readonly")||e.hasAttribute("disabled")))throw new Error('Invalid "target" attribute. You can\'t cut text from elements with "readonly" or "disabled" attributes');this._target=e}},get:function t(){return this._target}}]),t}();t.exports=c})},{select:5}],8:[function(e,n,o){!function(i,r){if("function"==typeof t&&t.amd)t(["module","./clipboard-action","tiny-emitter","good-listener"],r);else if(void 0!==o)r(n,e("./clipboard-action"),e("tiny-emitter"),e("good-listener"));else{var a={exports:{}};r(a,i.clipboardAction,i.tinyEmitter,i.goodListener),i.clipboard=a.exports}}(this,function(t,e,n,o){"use strict";function i(t){return t&&t.__esModule?t:{default:t}}function r(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function a(t,e){if(!t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!e||"object"!=typeof e&&"function"!=typeof e?t:e}function c(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function, not "+typeof e);t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),e&&(Object.setPrototypeOf?Object.setPrototypeOf(t,e):t.__proto__=e)}function l(t,e){var n="data-clipboard-"+t;if(e.hasAttribute(n))return e.getAttribute(n)}var s=i(e),u=i(n),f=i(o),d="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},h=function(){function t(t,e){for(var n=0;n<e.length;n++){var o=e[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(t,o.key,o)}}return function(e,n,o){return n&&t(e.prototype,n),o&&t(e,o),e}}(),p=function(t){function e(t,n){r(this,e);var o=a(this,(e.__proto__||Object.getPrototypeOf(e)).call(this));return o.resolveOptions(n),o.listenClick(t),o}return c(e,t),h(e,[{key:"resolveOptions",value:function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};this.action="function"==typeof e.action?e.action:this.defaultAction,this.target="function"==typeof e.target?e.target:this.defaultTarget,this.text="function"==typeof e.text?e.text:this.defaultText,this.container="object"===d(e.container)?e.container:document.body}},{key:"listenClick",value:function t(e){var n=this;this.listener=(0,f.default)(e,"click",function(t){return n.onClick(t)})}},{key:"onClick",value:function t(e){var n=e.delegateTarget||e.currentTarget;this.clipboardAction&&(this.clipboardAction=null),this.clipboardAction=new s.default({action:this.action(n),target:this.target(n),text:this.text(n),container:this.container,trigger:n,emitter:this})}},{key:"defaultAction",value:function t(e){return l("action",e)}},{key:"defaultTarget",value:function t(e){var n=l("target",e);if(n)return document.querySelector(n)}},{key:"defaultText",value:function t(e){return l("text",e)}},{key:"destroy",value:function t(){this.listener.destroy(),this.clipboardAction&&(this.clipboardAction.destroy(),this.clipboardAction=null)}}],[{key:"isSupported",value:function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:["copy","cut"],n="string"==typeof e?[e]:e,o=!!document.queryCommandSupported;return n.forEach(function(t){o=o&&!!document.queryCommandSupported(t)}),o}}]),e}(u.default);t.exports=p})},{"./clipboard-action":7,"good-listener":4,"tiny-emitter":6}]},{},[8])(8)});
|