From 540038e2ad3f485d1eb6ef8b43143d5b54e304af Mon Sep 17 00:00:00 2001 From: Zeno Rocha Date: Thu, 24 Sep 2015 16:18:50 -0700 Subject: [PATCH] Adds documentation for each block --- dist/clipboard.min.js | 2 +- src/clipboard-action.js | 65 +++++++++++++++++++++++++++++++++++------ src/clipboard.js | 29 +++++++++++++++++- 3 files changed, 85 insertions(+), 11 deletions(-) diff --git a/dist/clipboard.min.js b/dist/clipboard.min.js index 03fd08a..e99413e 100644 --- a/dist/clipboard.min.js +++ b/dist/clipboard.min.js @@ -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 this.bind(trigger)); } + /** + * Adds a click event listener for each element. + */ bind(trigger) { trigger.addEventListener('click', (e) => this.initialize(e)); } + /** + * Defines a new `ClipboardAction` on each click event. + * @param {Event} e + */ initialize(e) { new ClipboardAction({ action : e.currentTarget.getAttribute('data-action'), @@ -20,6 +36,11 @@ export default class Clipboard { }); } + /** + * Sets the `triggers` property if there's at least + * one match for the provided selector. + * @param {NodeList} triggers + */ set triggers(triggers) { if (!triggers.length) { throw new Error('No matches were found for the provided selector'); @@ -28,9 +49,15 @@ export default class Clipboard { this._triggers = triggers; } + /** + * Gets the `triggers` property. + * @return {NodeList} + */ get triggers() { return this._triggers; } } +export default Clipboard; + global.Clipboard = Clipboard;