From e5a6797c82174ee8db95feaa557202ee6c35b018 Mon Sep 17 00:00:00 2001 From: Kevin Malakoff Date: Wed, 30 Sep 2015 01:59:41 -0700 Subject: [PATCH] Got rid of ES7 notation and built library --- dist/clipboard.js | 23 +++++++++++++++++++---- dist/clipboard.min.js | 2 +- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/dist/clipboard.js b/dist/clipboard.js index 58be0a7..fd93388 100644 --- a/dist/clipboard.js +++ b/dist/clipboard.js @@ -477,11 +477,21 @@ var Clipboard = (function (_Emitter) { _classCallCheck(this, Clipboard); _Emitter.call(this); + this.initialize = this.initialize.bind(this); // pre-bind for consistent reference on remove this.resolveOptions(options); this.delegateClick(selector); } + /** + * @param {String} selector + * @param {Object} options + */ + + Clipboard.prototype.destroy = function destroy() { + this.undelegateClick(); + }; + /** * Defines if attributes would be resolved using internal setter functions * or custom functions that were passed in the constructor. @@ -502,11 +512,16 @@ var Clipboard = (function (_Emitter) { */ Clipboard.prototype.delegateClick = function delegateClick(selector) { - var _this = this; + _delegateEvents2['default'].bind(document.body, selector, 'click', this.initialize); + }; - _delegateEvents2['default'].bind(document.body, selector, 'click', function (e) { - return _this.initialize(e); - }); + /** + * Undelegates a click event on the passed selector. + * @param {String} selector + */ + + Clipboard.prototype.undelegateClick = function undelegateClick() { + _delegateEvents2['default'].unbind(document.body, 'click', this.initialize); }; /** diff --git a/dist/clipboard.min.js b/dist/clipboard.min.js index ed23e3e..652ae29 100644 --- a/dist/clipboard.min.js +++ b/dist/clipboard.min.js @@ -1 +1 @@ -!function(a){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=a();else if("function"==typeof define&&define.amd)define([],a);else{var b;b="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,b.Clipboard=a()}}(function(){return 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;gd;d++)c[d].fn.apply(c[d].ctx,b);return this},off:function(a,b){var c=this.e||(this.e={}),d=c[a],e=[];if(d&&b)for(var f=0,g=d.length;g>f;f++)d[f].fn!==b&&e.push(d[f]);return e.length?c[a]=e:delete c[a],this}},b.exports=d},{}],6:[function(a,b,c){"use strict";function d(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}c.__esModule=!0;var e=function(){function a(a,b){for(var c=0;cd;d++)c[d].fn.apply(c[d].ctx,b);return this},off:function(a,b){var c=this.e||(this.e={}),d=c[a],e=[];if(d&&b)for(var f=0,g=d.length;g>f;f++)d[f].fn!==b&&e.push(d[f]);return e.length?c[a]=e:delete c[a],this}},b.exports=d},{}],6:[function(a,b,c){"use strict";function d(a,b){if(!(a instanceof b))throw new TypeError("Cannot call a class as a function")}c.__esModule=!0;var e=function(){function a(a,b){for(var c=0;c