Skip to content

Instantly share code, notes, and snippets.

@dleitee
Created March 31, 2016 11:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dleitee/27b036ac5e4aff92b2bcc9b75564f75d to your computer and use it in GitHub Desktop.
Save dleitee/27b036ac5e4aff92b2bcc9b75564f75d to your computer and use it in GitHub Desktop.
!function(){"use strict";var o,n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(o){return typeof o}:function(o){return o&&"function"==typeof Symbol&&o.constructor===Symbol?"symbol":typeof o};"object"===("undefined"==typeof module?"undefined":n(module))&&module.exports?(o=require("angular"),module.exports="ng-clipboard"):o=window.angular,o.module("ng-clipboard",[]),o.module("ng-clipboard").directive("ngCopy",["createFake",function(o){return{restrict:"A",scope:{ngCopy:"=",onSuccess:"=",onError:"="},link:function(n,e){var t=function(){n.onSuccess()},c=function(){n.onError()};e.on("click",function(){o(n.ngCopy,"copy",t,c)})}}}]),o.module("ng-clipboard").directive("ngCut",["createFake",function(o){return{restrict:"A",scope:{ngCut:"=",onSuccess:"&",onError:"&"},link:function(n,e){var t=function(){n.ngCut="",n.onSuccess()},c=function(){n.onError()};e.on("click",function(){o(n.ngCut,"copy",t,c)})}}}]),o.module("ng-clipboard").factory("createFake",function(){return function(o,n,e,t){var c=document.createElement("textarea");c.setAttribute("style","position: absolute;overflow: hidden;width: 0;height: 0;top: 0;left: 0;"),c.innerText=o,document.body.appendChild(c),c.select();try{document.execCommand(n),e()}catch(r){console.log(r),t(r)}c.remove()}})}();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment