Makes compilation faster but less spec-compliant

This commit is contained in:
Zeno Rocha 2015-09-20 00:47:18 -07:00
parent bea448d6c5
commit b1d0ac9520
2 changed files with 2 additions and 2 deletions

View File

@ -1 +1 @@
!function a(b,c,d){function e(g,h){if(!c[g]){if(!b[g]){var i="function"==typeof require&&require;if(!h&&i)return i(g,!0);if(f)return f(g,!0);var j=new Error("Cannot find module '"+g+"'");throw j.code="MODULE_NOT_FOUND",j}var k=c[g]={exports:{}};b[g][0].call(k.exports,function(a){var c=b[g][1][a];return e(c?c:a)},k,k.exports,a,b,c,d)}return c[g].exports}for(var f="function"==typeof require&&require,g=0;g<d.length;g++)e(d[g]);return e}({1:[function(a,b,c){(function(a){function c(){try{var a=new d("cat",{detail:{foo:"bar"}});return"cat"===a.type&&"bar"===a.detail.foo}catch(b){}return!1}var d=a.CustomEvent;b.exports=c()?d:"function"==typeof document.createEvent?function(a,b){var c=document.createEvent("CustomEvent");return b?c.initCustomEvent(a,b.bubbles,b.cancelable,b.detail):c.initCustomEvent(a,!1,!1,void 0),c}:function(a,b){var c=document.createEventObject();return c.type=a,b?(c.bubbles=Boolean(b.bubbles),c.cancelable=Boolean(b.cancelable),c.detail=b.detail):(c.bubbles=!1,c.cancelable=!1,c.detail=void 0),c}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],2:[function(a,b,c){(function(b){"use strict";function c(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}var d=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,c,d){return c&&a(b.prototype,c),d&&a(b,d),b}}(),e=a("custom-event"),f=function(){function a(b){c(this,a),this.triggers=document.querySelectorAll(b),this.init()}return d(a,[{key:"init",value:function(){var a=this;if(0===this.triggers.length)throw new Error("The provided selector is empty");[].forEach.call(this.triggers,function(b){return a.bind(b)})}},{key:"bind",value:function(a){a.addEventListener("click",function(a){var b=a.currentTarget.getAttribute("data-action"),c=a.currentTarget.getAttribute("data-target"),d=a.currentTarget.getAttribute("data-text");if("copy"===!b||"cut"===!b)throw new Error('Invalid "data-action" attribute');if(!c&&!d)throw new Error('Missing "data-target" or "data-text" attribute');new g({action:b,target:c,text:d,trigger:a.currentTarget})})}}]),a}(),g=function(){function a(b){c(this,a),this.action=b.action||"copy",this.target=document.getElementById(b.target),this.text=b.text,this.trigger=b.trigger,this.selectedText="",this.text?this.selectValue():this.target&&this.selectTarget()}return d(a,[{key:"selectValue",value:function(){var a=document.createElement("input");a.style.opacity=0,a.style.zIndex=-1,a.value=this.text,this.selectedText=this.text,document.body.appendChild(a),a.select(),this.copy(),document.body.removeChild(a)}},{key:"selectTarget",value:function(){if("INPUT"===this.target.nodeName||"TEXTAREA"===this.target.nodeName)this.target.select(),this.selectedText=this.target.value;else{var a=document.createRange(),b=window.getSelection();a.selectNode(this.target),b.addRange(a),this.selectedText=b.toString()}this.copy()}},{key:"copy",value:function(){var a=document.queryCommandSupported(this.action);try{document.execCommand(this.action),this.fireEventDetails(),window.getSelection().removeAllRanges()}catch(b){a=!1}a||this.fireNoSupport()}},{key:"fireEventDetails",value:function(){var a=new e(this.action,{detail:this.selectedText});this.trigger.dispatchEvent(a)}},{key:"fireNoSupport",value:function(){var a=new e("no-support");this.trigger.dispatchEvent(a)}}]),a}();b.Clipboard=f}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"custom-event":1}]},{},[2]);
!function a(b,c,d){function e(g,h){if(!c[g]){if(!b[g]){var i="function"==typeof require&&require;if(!h&&i)return i(g,!0);if(f)return f(g,!0);var j=new Error("Cannot find module '"+g+"'");throw j.code="MODULE_NOT_FOUND",j}var k=c[g]={exports:{}};b[g][0].call(k.exports,function(a){var c=b[g][1][a];return e(c?c:a)},k,k.exports,a,b,c,d)}return c[g].exports}for(var f="function"==typeof require&&require,g=0;g<d.length;g++)e(d[g]);return e}({1:[function(a,b,c){(function(a){function c(){try{var a=new d("cat",{detail:{foo:"bar"}});return"cat"===a.type&&"bar"===a.detail.foo}catch(b){}return!1}var d=a.CustomEvent;b.exports=c()?d:"function"==typeof document.createEvent?function(a,b){var c=document.createEvent("CustomEvent");return b?c.initCustomEvent(a,b.bubbles,b.cancelable,b.detail):c.initCustomEvent(a,!1,!1,void 0),c}:function(a,b){var c=document.createEventObject();return c.type=a,b?(c.bubbles=Boolean(b.bubbles),c.cancelable=Boolean(b.cancelable),c.detail=b.detail):(c.bubbles=!1,c.cancelable=!1,c.detail=void 0),c}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],2:[function(a,b,c){(function(b){"use strict";function c(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}var d=a("custom-event"),e=function(){function a(b){c(this,a),this.triggers=document.querySelectorAll(b),this.init()}return a.prototype.init=function(){var a=this;if(0===this.triggers.length)throw new Error("The provided selector is empty");[].forEach.call(this.triggers,function(b){return a.bind(b)})},a.prototype.bind=function(a){a.addEventListener("click",function(a){var b=a.currentTarget.getAttribute("data-action"),c=a.currentTarget.getAttribute("data-target"),d=a.currentTarget.getAttribute("data-text");if("copy"===!b||"cut"===!b)throw new Error('Invalid "data-action" attribute');if(!c&&!d)throw new Error('Missing "data-target" or "data-text" attribute');new f({action:b,target:c,text:d,trigger:a.currentTarget})})},a}(),f=function(){function a(b){c(this,a),this.action=b.action||"copy",this.target=document.getElementById(b.target),this.text=b.text,this.trigger=b.trigger,this.selectedText="",this.text?this.selectValue():this.target&&this.selectTarget()}return a.prototype.selectValue=function(){var a=document.createElement("input");a.style.opacity=0,a.style.zIndex=-1,a.value=this.text,this.selectedText=this.text,document.body.appendChild(a),a.select(),this.copy(),document.body.removeChild(a)},a.prototype.selectTarget=function(){if("INPUT"===this.target.nodeName||"TEXTAREA"===this.target.nodeName)this.target.select(),this.selectedText=this.target.value;else{var a=document.createRange(),b=window.getSelection();a.selectNode(this.target),b.addRange(a),this.selectedText=b.toString()}this.copy()},a.prototype.copy=function(){var a=document.queryCommandSupported(this.action);try{document.execCommand(this.action),this.fireEventDetails(),window.getSelection().removeAllRanges()}catch(b){a=!1}a||this.fireNoSupport()},a.prototype.fireEventDetails=function(){var a=new d(this.action,{detail:this.selectedText});this.trigger.dispatchEvent(a)},a.prototype.fireNoSupport=function(){var a=new d("no-support");this.trigger.dispatchEvent(a)},a}();b.Clipboard=e}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"custom-event":1}]},{},[2]);

View File

@ -19,7 +19,7 @@
},
"scripts": {
"publish": "npm run build && npm run minify",
"build": "browserify src/clipboard.js -t babelify --outfile dist/clipboard.min.js",
"build": "browserify src/clipboard.js -t [babelify --loose all] -o dist/clipboard.min.js",
"minify": "uglify -s dist/clipboard.min.js -o dist/clipboard.min.js"
}
}