From 775e4b898d2ef1a98f1a4862ebee4c2d663b96fb Mon Sep 17 00:00:00 2001 From: Zeno Rocha Date: Mon, 28 Sep 2015 21:56:29 -0700 Subject: [PATCH] Source formatting --- src/clipboard.js | 61 +++++++++++++++++++++++++----------------------- 1 file changed, 32 insertions(+), 29 deletions(-) diff --git a/src/clipboard.js b/src/clipboard.js index 33287c9..10f2ea9 100644 --- a/src/clipboard.js +++ b/src/clipboard.js @@ -28,14 +28,44 @@ class Clipboard extends Emitter { } /** - * Resolves contructor options. + * Defines if attributes would be resolved using an internal setter function + * or a custom function that was passed in the constructor. * @param {Object} options */ resolveOptions(options) { options = options || {}; + this.action = (typeof options.action === 'function') ? options.action : this.setAction; this.target = (typeof options.target === 'function') ? options.target : this.setTarget; - this.text = (typeof options.text === 'function') ? options.text : this.setText; + this.text = (typeof options.text === 'function') ? options.text : this.setText; + } + + /** + * Sets the `action` lookup function. + * @param {Element} trigger + */ + setAction(trigger) { + return trigger.getAttribute(prefix + 'action'); + } + + /** + * Sets the `target` lookup function. + * @param {Element} trigger + */ + setTarget(trigger) { + let target = trigger.getAttribute(prefix + 'target'); + + if (target) { + return document.querySelector(target); + } + } + + /** + * Sets the `text` lookup function. + * @param {Element} trigger + */ + setText(trigger) { + return trigger.getAttribute(prefix + 'text'); } /** @@ -55,33 +85,6 @@ class Clipboard extends Emitter { emitter : this }); } - - /** - * Sets the `action` lookup function. - * @param {Element} trigger - */ - setAction(trigger) { - return trigger.getAttribute(prefix + 'action'); - } - - /** - * Sets the `target` lookup function. - * @param {Element} trigger - */ - setTarget(trigger) { - let target = trigger.getAttribute(prefix + 'target'); - if (target) { - return document.querySelector(target); - } - } - - /** - * Sets the `text` lookup function. - * @param {Element} trigger - */ - setText(trigger) { - return trigger.getAttribute(prefix + 'text'); - } } export default Clipboard;