clipboard-rails 1.5.5 → 1.5.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 770b1fd6c1b179dd51d7a970b984447e3711ada7
4
- data.tar.gz: e38af34f32775f6c4a4a045a1cf5f0a0928d7173
3
+ metadata.gz: 308a3459bc626a1ad5326f4605034167b84bfe61
4
+ data.tar.gz: bb825185fd39dcd6171b17d1d630935715384807
5
5
  SHA512:
6
- metadata.gz: 8678a124215bbfc16158120b0a1c6fab516550f81a1acc12933424b8b9ea5d782a1590dc1c77bf514c9eede5bbb7aad3dc562b5dda5b3425599efc7eb943d93e
7
- data.tar.gz: 61009f1be5ad470a8bcda471476c1945e95f77340cf0502ac2835a83f9f094af7501fc0801e5859a207dae137fbbf779186ea950f9559dad152cb02b301a2604
6
+ metadata.gz: 5e14ba95432452856a4d6fa1e146376c0d144b2c2d36184542ca26f631edae759f717bb64f373a9240e1fb0a550608e79900f7bccd354f39fe0d25c1ce8d2886
7
+ data.tar.gz: 7d14c6ffcf789bbe59d7b404bcdb7effd4c8cfedcc8b07cae65ebd5923229d383a4a1f818add26f5f584934145564fa5654210c80bd45d1227dc6a1e4ac5ff4b
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2015 Mohammed Sadiq
3
+ Copyright (c) 2016 Mohammed Sadiq
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
@@ -1,5 +1,5 @@
1
1
  module Clipboard
2
2
  module Rails
3
- VERSION = "1.5.5"
3
+ VERSION = "1.5.6"
4
4
  end
5
5
  end
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * clipboard.js v1.5.5
2
+ * clipboard.js v1.5.6
3
3
  * https://zenorocha.github.io/clipboard.js
4
4
  *
5
5
  * Licensed MIT © Zeno Rocha
@@ -16,48 +16,7 @@ module.exports = function (element, selector, checkYoSelf) {
16
16
  }
17
17
  }
18
18
 
19
- },{"matches-selector":2}],2:[function(require,module,exports){
20
-
21
- /**
22
- * Element prototype.
23
- */
24
-
25
- var proto = Element.prototype;
26
-
27
- /**
28
- * Vendor function.
29
- */
30
-
31
- var vendor = proto.matchesSelector
32
- || proto.webkitMatchesSelector
33
- || proto.mozMatchesSelector
34
- || proto.msMatchesSelector
35
- || proto.oMatchesSelector;
36
-
37
- /**
38
- * Expose `match()`.
39
- */
40
-
41
- module.exports = match;
42
-
43
- /**
44
- * Match `el` to `selector`.
45
- *
46
- * @param {Element} el
47
- * @param {String} selector
48
- * @return {Boolean}
49
- * @api public
50
- */
51
-
52
- function match(el, selector) {
53
- if (vendor) return vendor.call(el, selector);
54
- var nodes = el.parentNode.querySelectorAll(selector);
55
- for (var i = 0; i < nodes.length; ++i) {
56
- if (nodes[i] == el) return true;
57
- }
58
- return false;
59
- }
60
- },{}],3:[function(require,module,exports){
19
+ },{"matches-selector":5}],2:[function(require,module,exports){
61
20
  var closest = require('closest');
62
21
 
63
22
  /**
@@ -67,16 +26,17 @@ var closest = require('closest');
67
26
  * @param {String} selector
68
27
  * @param {String} type
69
28
  * @param {Function} callback
29
+ * @param {Boolean} useCapture
70
30
  * @return {Object}
71
31
  */
72
- function delegate(element, selector, type, callback) {
32
+ function delegate(element, selector, type, callback, useCapture) {
73
33
  var listenerFn = listener.apply(this, arguments);
74
34
 
75
- element.addEventListener(type, listenerFn);
35
+ element.addEventListener(type, listenerFn, useCapture);
76
36
 
77
37
  return {
78
38
  destroy: function() {
79
- element.removeEventListener(type, listenerFn);
39
+ element.removeEventListener(type, listenerFn, useCapture);
80
40
  }
81
41
  }
82
42
  }
@@ -102,7 +62,7 @@ function listener(element, selector, type, callback) {
102
62
 
103
63
  module.exports = delegate;
104
64
 
105
- },{"closest":1}],4:[function(require,module,exports){
65
+ },{"closest":1}],3:[function(require,module,exports){
106
66
  /**
107
67
  * Check if argument is a HTML element.
108
68
  *
@@ -147,13 +107,13 @@ exports.string = function(value) {
147
107
  * @param {Object} value
148
108
  * @return {Boolean}
149
109
  */
150
- exports.function = function(value) {
110
+ exports.fn = function(value) {
151
111
  var type = Object.prototype.toString.call(value);
152
112
 
153
113
  return type === '[object Function]';
154
114
  };
155
115
 
156
- },{}],5:[function(require,module,exports){
116
+ },{}],4:[function(require,module,exports){
157
117
  var is = require('./is');
158
118
  var delegate = require('delegate');
159
119
 
@@ -175,7 +135,7 @@ function listen(target, type, callback) {
175
135
  throw new TypeError('Second argument must be a String');
176
136
  }
177
137
 
178
- if (!is.function(callback)) {
138
+ if (!is.fn(callback)) {
179
139
  throw new TypeError('Third argument must be a Function');
180
140
  }
181
141
 
@@ -250,7 +210,48 @@ function listenSelector(selector, type, callback) {
250
210
 
251
211
  module.exports = listen;
252
212
 
253
- },{"./is":4,"delegate":3}],6:[function(require,module,exports){
213
+ },{"./is":3,"delegate":2}],5:[function(require,module,exports){
214
+
215
+ /**
216
+ * Element prototype.
217
+ */
218
+
219
+ var proto = Element.prototype;
220
+
221
+ /**
222
+ * Vendor function.
223
+ */
224
+
225
+ var vendor = proto.matchesSelector
226
+ || proto.webkitMatchesSelector
227
+ || proto.mozMatchesSelector
228
+ || proto.msMatchesSelector
229
+ || proto.oMatchesSelector;
230
+
231
+ /**
232
+ * Expose `match()`.
233
+ */
234
+
235
+ module.exports = match;
236
+
237
+ /**
238
+ * Match `el` to `selector`.
239
+ *
240
+ * @param {Element} el
241
+ * @param {String} selector
242
+ * @return {Boolean}
243
+ * @api public
244
+ */
245
+
246
+ function match(el, selector) {
247
+ if (vendor) return vendor.call(el, selector);
248
+ var nodes = el.parentNode.querySelectorAll(selector);
249
+ for (var i = 0; i < nodes.length; ++i) {
250
+ if (nodes[i] == el) return true;
251
+ }
252
+ return false;
253
+ }
254
+ },{}],6:[function(require,module,exports){
254
255
  function select(element) {
255
256
  var selectedText;
256
257
 
@@ -351,24 +352,28 @@ module.exports = E;
351
352
  },{}],8:[function(require,module,exports){
352
353
  'use strict';
353
354
 
354
- exports.__esModule = true;
355
-
356
- var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })();
355
+ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; };
357
356
 
358
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
357
+ var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
359
358
 
360
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
359
+ Object.defineProperty(exports, "__esModule", {
360
+ value: true
361
+ });
361
362
 
362
363
  var _select = require('select');
363
364
 
364
365
  var _select2 = _interopRequireDefault(_select);
365
366
 
367
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
368
+
369
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
370
+
366
371
  /**
367
372
  * Inner class which performs selection from either `text` or `target`
368
373
  * properties and then executes copy or cut operations.
369
374
  */
370
375
 
371
- var ClipboardAction = (function () {
376
+ var ClipboardAction = function () {
372
377
  /**
373
378
  * @param {Object} options
374
379
  */
@@ -385,152 +390,171 @@ var ClipboardAction = (function () {
385
390
  * @param {Object} options
386
391
  */
387
392
 
388
- ClipboardAction.prototype.resolveOptions = function resolveOptions() {
389
- var options = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0];
390
-
391
- this.action = options.action;
392
- this.emitter = options.emitter;
393
- this.target = options.target;
394
- this.text = options.text;
395
- this.trigger = options.trigger;
393
+ _createClass(ClipboardAction, [{
394
+ key: 'resolveOptions',
395
+ value: function resolveOptions() {
396
+ var options = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0];
396
397
 
397
- this.selectedText = '';
398
- };
398
+ this.action = options.action;
399
+ this.emitter = options.emitter;
400
+ this.target = options.target;
401
+ this.text = options.text;
402
+ this.trigger = options.trigger;
399
403
 
400
- /**
401
- * Decides which selection strategy is going to be applied based
402
- * on the existence of `text` and `target` properties.
403
- */
404
-
405
- ClipboardAction.prototype.initSelection = function initSelection() {
406
- if (this.text && this.target) {
407
- throw new Error('Multiple attributes declared, use either "target" or "text"');
408
- } else if (this.text) {
409
- this.selectFake();
410
- } else if (this.target) {
411
- this.selectTarget();
412
- } else {
413
- throw new Error('Missing required attributes, use either "target" or "text"');
404
+ this.selectedText = '';
414
405
  }
415
- };
416
406
 
417
- /**
418
- * Creates a fake textarea element, sets its value from `text` property,
419
- * and makes a selection on it.
420
- */
407
+ /**
408
+ * Decides which selection strategy is going to be applied based
409
+ * on the existence of `text` and `target` properties.
410
+ */
421
411
 
422
- ClipboardAction.prototype.selectFake = function selectFake() {
423
- var _this = this;
412
+ }, {
413
+ key: 'initSelection',
414
+ value: function initSelection() {
415
+ if (this.text && this.target) {
416
+ throw new Error('Multiple attributes declared, use either "target" or "text"');
417
+ } else if (this.text) {
418
+ this.selectFake();
419
+ } else if (this.target) {
420
+ this.selectTarget();
421
+ } else {
422
+ throw new Error('Missing required attributes, use either "target" or "text"');
423
+ }
424
+ }
424
425
 
425
- this.removeFake();
426
+ /**
427
+ * Creates a fake textarea element, sets its value from `text` property,
428
+ * and makes a selection on it.
429
+ */
426
430
 
427
- this.fakeHandler = document.body.addEventListener('click', function () {
428
- return _this.removeFake();
429
- });
431
+ }, {
432
+ key: 'selectFake',
433
+ value: function selectFake() {
434
+ var _this = this;
430
435
 
431
- this.fakeElem = document.createElement('textarea');
432
- this.fakeElem.style.position = 'absolute';
433
- this.fakeElem.style.left = '-9999px';
434
- this.fakeElem.style.top = (window.pageYOffset || document.documentElement.scrollTop) + 'px';
435
- this.fakeElem.setAttribute('readonly', '');
436
- this.fakeElem.value = this.text;
436
+ var isRTL = document.documentElement.getAttribute('dir') == 'rtl';
437
437
 
438
- document.body.appendChild(this.fakeElem);
438
+ this.removeFake();
439
439
 
440
- this.selectedText = _select2['default'](this.fakeElem);
441
- this.copyText();
442
- };
440
+ this.fakeHandler = document.body.addEventListener('click', function () {
441
+ return _this.removeFake();
442
+ });
443
443
 
444
- /**
445
- * Only removes the fake element after another click event, that way
446
- * a user can hit `Ctrl+C` to copy because selection still exists.
447
- */
444
+ this.fakeElem = document.createElement('textarea');
445
+ this.fakeElem.style.position = 'absolute';
446
+ this.fakeElem.style[isRTL ? 'right' : 'left'] = '-9999px';
447
+ this.fakeElem.style.top = (window.pageYOffset || document.documentElement.scrollTop) + 'px';
448
+ this.fakeElem.setAttribute('readonly', '');
449
+ this.fakeElem.value = this.text;
448
450
 
449
- ClipboardAction.prototype.removeFake = function removeFake() {
450
- if (this.fakeHandler) {
451
- document.body.removeEventListener('click');
452
- this.fakeHandler = null;
453
- }
451
+ document.body.appendChild(this.fakeElem);
454
452
 
455
- if (this.fakeElem) {
456
- document.body.removeChild(this.fakeElem);
457
- this.fakeElem = null;
453
+ this.selectedText = (0, _select2.default)(this.fakeElem);
454
+ this.copyText();
458
455
  }
459
- };
460
456
 
461
- /**
462
- * Selects the content from element passed on `target` property.
463
- */
457
+ /**
458
+ * Only removes the fake element after another click event, that way
459
+ * a user can hit `Ctrl+C` to copy because selection still exists.
460
+ */
464
461
 
465
- ClipboardAction.prototype.selectTarget = function selectTarget() {
466
- this.selectedText = _select2['default'](this.target);
467
- this.copyText();
468
- };
462
+ }, {
463
+ key: 'removeFake',
464
+ value: function removeFake() {
465
+ if (this.fakeHandler) {
466
+ document.body.removeEventListener('click');
467
+ this.fakeHandler = null;
468
+ }
469
469
 
470
- /**
471
- * Executes the copy operation based on the current selection.
472
- */
470
+ if (this.fakeElem) {
471
+ document.body.removeChild(this.fakeElem);
472
+ this.fakeElem = null;
473
+ }
474
+ }
473
475
 
474
- ClipboardAction.prototype.copyText = function copyText() {
475
- var succeeded = undefined;
476
+ /**
477
+ * Selects the content from element passed on `target` property.
478
+ */
476
479
 
477
- try {
478
- succeeded = document.execCommand(this.action);
479
- } catch (err) {
480
- succeeded = false;
480
+ }, {
481
+ key: 'selectTarget',
482
+ value: function selectTarget() {
483
+ this.selectedText = (0, _select2.default)(this.target);
484
+ this.copyText();
481
485
  }
482
486
 
483
- this.handleResult(succeeded);
484
- };
487
+ /**
488
+ * Executes the copy operation based on the current selection.
489
+ */
485
490
 
486
- /**
487
- * Fires an event based on the copy operation result.
488
- * @param {Boolean} succeeded
489
- */
491
+ }, {
492
+ key: 'copyText',
493
+ value: function copyText() {
494
+ var succeeded = undefined;
495
+
496
+ try {
497
+ succeeded = document.execCommand(this.action);
498
+ } catch (err) {
499
+ succeeded = false;
500
+ }
490
501
 
491
- ClipboardAction.prototype.handleResult = function handleResult(succeeded) {
492
- if (succeeded) {
493
- this.emitter.emit('success', {
494
- action: this.action,
495
- text: this.selectedText,
496
- trigger: this.trigger,
497
- clearSelection: this.clearSelection.bind(this)
498
- });
499
- } else {
500
- this.emitter.emit('error', {
501
- action: this.action,
502
- trigger: this.trigger,
503
- clearSelection: this.clearSelection.bind(this)
504
- });
502
+ this.handleResult(succeeded);
505
503
  }
506
- };
507
504
 
508
- /**
509
- * Removes current selection and focus from `target` element.
510
- */
505
+ /**
506
+ * Fires an event based on the copy operation result.
507
+ * @param {Boolean} succeeded
508
+ */
511
509
 
512
- ClipboardAction.prototype.clearSelection = function clearSelection() {
513
- if (this.target) {
514
- this.target.blur();
510
+ }, {
511
+ key: 'handleResult',
512
+ value: function handleResult(succeeded) {
513
+ if (succeeded) {
514
+ this.emitter.emit('success', {
515
+ action: this.action,
516
+ text: this.selectedText,
517
+ trigger: this.trigger,
518
+ clearSelection: this.clearSelection.bind(this)
519
+ });
520
+ } else {
521
+ this.emitter.emit('error', {
522
+ action: this.action,
523
+ trigger: this.trigger,
524
+ clearSelection: this.clearSelection.bind(this)
525
+ });
526
+ }
515
527
  }
516
528
 
517
- window.getSelection().removeAllRanges();
518
- };
529
+ /**
530
+ * Removes current selection and focus from `target` element.
531
+ */
519
532
 
520
- /**
521
- * Sets the `action` to be performed which can be either 'copy' or 'cut'.
522
- * @param {String} action
523
- */
533
+ }, {
534
+ key: 'clearSelection',
535
+ value: function clearSelection() {
536
+ if (this.target) {
537
+ this.target.blur();
538
+ }
524
539
 
525
- /**
526
- * Destroy lifecycle.
527
- */
540
+ window.getSelection().removeAllRanges();
541
+ }
528
542
 
529
- ClipboardAction.prototype.destroy = function destroy() {
530
- this.removeFake();
531
- };
543
+ /**
544
+ * Sets the `action` to be performed which can be either 'copy' or 'cut'.
545
+ * @param {String} action
546
+ */
532
547
 
533
- _createClass(ClipboardAction, [{
548
+ }, {
549
+ key: 'destroy',
550
+
551
+ /**
552
+ * Destroy lifecycle.
553
+ */
554
+ value: function destroy() {
555
+ this.removeFake();
556
+ }
557
+ }, {
534
558
  key: 'action',
535
559
  set: function set() {
536
560
  var action = arguments.length <= 0 || arguments[0] === undefined ? 'copy' : arguments[0];
@@ -540,12 +564,13 @@ var ClipboardAction = (function () {
540
564
  if (this._action !== 'copy' && this._action !== 'cut') {
541
565
  throw new Error('Invalid "action" value, use either "copy" or "cut"');
542
566
  }
543
- },
567
+ }
544
568
 
545
569
  /**
546
570
  * Gets the `action` property.
547
571
  * @return {String}
548
572
  */
573
+ ,
549
574
  get: function get() {
550
575
  return this._action;
551
576
  }
@@ -555,43 +580,42 @@ var ClipboardAction = (function () {
555
580
  * that will be have its content copied.
556
581
  * @param {Element} target
557
582
  */
583
+
558
584
  }, {
559
585
  key: 'target',
560
586
  set: function set(target) {
561
587
  if (target !== undefined) {
562
- if (target && typeof target === 'object' && target.nodeType === 1) {
588
+ if (target && (typeof target === 'undefined' ? 'undefined' : _typeof(target)) === 'object' && target.nodeType === 1) {
563
589
  this._target = target;
564
590
  } else {
565
591
  throw new Error('Invalid "target" value, use a valid Element');
566
592
  }
567
593
  }
568
- },
594
+ }
569
595
 
570
596
  /**
571
597
  * Gets the `target` property.
572
598
  * @return {String|HTMLElement}
573
599
  */
600
+ ,
574
601
  get: function get() {
575
602
  return this._target;
576
603
  }
577
604
  }]);
578
605
 
579
606
  return ClipboardAction;
580
- })();
607
+ }();
581
608
 
582
- exports['default'] = ClipboardAction;
583
- module.exports = exports['default'];
609
+ exports.default = ClipboardAction;
584
610
 
585
611
  },{"select":6}],9:[function(require,module,exports){
586
612
  'use strict';
587
613
 
588
- exports.__esModule = true;
589
-
590
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
591
-
592
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
614
+ var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
593
615
 
594
- function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
616
+ Object.defineProperty(exports, "__esModule", {
617
+ value: true
618
+ });
595
619
 
596
620
  var _clipboardAction = require('./clipboard-action');
597
621
 
@@ -605,12 +629,20 @@ var _goodListener = require('good-listener');
605
629
 
606
630
  var _goodListener2 = _interopRequireDefault(_goodListener);
607
631
 
632
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
633
+
634
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
635
+
636
+ function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
637
+
638
+ function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
639
+
608
640
  /**
609
641
  * Base class which takes one or more elements, adds event listeners to them,
610
642
  * and instantiates a new `ClipboardAction` on each click.
611
643
  */
612
644
 
613
- var Clipboard = (function (_Emitter) {
645
+ var Clipboard = function (_Emitter) {
614
646
  _inherits(Clipboard, _Emitter);
615
647
 
616
648
  /**
@@ -621,113 +653,130 @@ var Clipboard = (function (_Emitter) {
621
653
  function Clipboard(trigger, options) {
622
654
  _classCallCheck(this, Clipboard);
623
655
 
624
- _Emitter.call(this);
656
+ var _this = _possibleConstructorReturn(this, Object.getPrototypeOf(Clipboard).call(this));
625
657
 
626
- this.resolveOptions(options);
627
- this.listenClick(trigger);
658
+ _this.resolveOptions(options);
659
+ _this.listenClick(trigger);
660
+ return _this;
628
661
  }
629
662
 
630
- /**
631
- * Helper function to retrieve attribute value.
632
- * @param {String} suffix
633
- * @param {Element} element
634
- */
635
-
636
663
  /**
637
664
  * Defines if attributes would be resolved using internal setter functions
638
665
  * or custom functions that were passed in the constructor.
639
666
  * @param {Object} options
640
667
  */
641
668
 
642
- Clipboard.prototype.resolveOptions = function resolveOptions() {
643
- var options = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0];
669
+ _createClass(Clipboard, [{
670
+ key: 'resolveOptions',
671
+ value: function resolveOptions() {
672
+ var options = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0];
644
673
 
645
- this.action = typeof options.action === 'function' ? options.action : this.defaultAction;
646
- this.target = typeof options.target === 'function' ? options.target : this.defaultTarget;
647
- this.text = typeof options.text === 'function' ? options.text : this.defaultText;
648
- };
674
+ this.action = typeof options.action === 'function' ? options.action : this.defaultAction;
675
+ this.target = typeof options.target === 'function' ? options.target : this.defaultTarget;
676
+ this.text = typeof options.text === 'function' ? options.text : this.defaultText;
677
+ }
649
678
 
650
- /**
651
- * Adds a click event listener to the passed trigger.
652
- * @param {String|HTMLElement|HTMLCollection|NodeList} trigger
653
- */
679
+ /**
680
+ * Adds a click event listener to the passed trigger.
681
+ * @param {String|HTMLElement|HTMLCollection|NodeList} trigger
682
+ */
654
683
 
655
- Clipboard.prototype.listenClick = function listenClick(trigger) {
656
- var _this = this;
684
+ }, {
685
+ key: 'listenClick',
686
+ value: function listenClick(trigger) {
687
+ var _this2 = this;
657
688
 
658
- this.listener = _goodListener2['default'](trigger, 'click', function (e) {
659
- return _this.onClick(e);
660
- });
661
- };
689
+ this.listener = (0, _goodListener2.default)(trigger, 'click', function (e) {
690
+ return _this2.onClick(e);
691
+ });
692
+ }
662
693
 
663
- /**
664
- * Defines a new `ClipboardAction` on each click event.
665
- * @param {Event} e
666
- */
694
+ /**
695
+ * Defines a new `ClipboardAction` on each click event.
696
+ * @param {Event} e
697
+ */
667
698
 
668
- Clipboard.prototype.onClick = function onClick(e) {
669
- var trigger = e.delegateTarget || e.currentTarget;
699
+ }, {
700
+ key: 'onClick',
701
+ value: function onClick(e) {
702
+ var trigger = e.delegateTarget || e.currentTarget;
670
703
 
671
- if (this.clipboardAction) {
672
- this.clipboardAction = null;
673
- }
704
+ if (this.clipboardAction) {
705
+ this.clipboardAction = null;
706
+ }
674
707
 
675
- this.clipboardAction = new _clipboardAction2['default']({
676
- action: this.action(trigger),
677
- target: this.target(trigger),
678
- text: this.text(trigger),
679
- trigger: trigger,
680
- emitter: this
681
- });
682
- };
708
+ this.clipboardAction = new _clipboardAction2.default({
709
+ action: this.action(trigger),
710
+ target: this.target(trigger),
711
+ text: this.text(trigger),
712
+ trigger: trigger,
713
+ emitter: this
714
+ });
715
+ }
683
716
 
684
- /**
685
- * Default `action` lookup function.
686
- * @param {Element} trigger
687
- */
717
+ /**
718
+ * Default `action` lookup function.
719
+ * @param {Element} trigger
720
+ */
688
721
 
689
- Clipboard.prototype.defaultAction = function defaultAction(trigger) {
690
- return getAttributeValue('action', trigger);
691
- };
722
+ }, {
723
+ key: 'defaultAction',
724
+ value: function defaultAction(trigger) {
725
+ return getAttributeValue('action', trigger);
726
+ }
692
727
 
693
- /**
694
- * Default `target` lookup function.
695
- * @param {Element} trigger
696
- */
728
+ /**
729
+ * Default `target` lookup function.
730
+ * @param {Element} trigger
731
+ */
697
732
 
698
- Clipboard.prototype.defaultTarget = function defaultTarget(trigger) {
699
- var selector = getAttributeValue('target', trigger);
733
+ }, {
734
+ key: 'defaultTarget',
735
+ value: function defaultTarget(trigger) {
736
+ var selector = getAttributeValue('target', trigger);
700
737
 
701
- if (selector) {
702
- return document.querySelector(selector);
738
+ if (selector) {
739
+ return document.querySelector(selector);
740
+ }
703
741
  }
704
- };
705
742
 
706
- /**
707
- * Default `text` lookup function.
708
- * @param {Element} trigger
709
- */
743
+ /**
744
+ * Default `text` lookup function.
745
+ * @param {Element} trigger
746
+ */
710
747
 
711
- Clipboard.prototype.defaultText = function defaultText(trigger) {
712
- return getAttributeValue('text', trigger);
713
- };
748
+ }, {
749
+ key: 'defaultText',
750
+ value: function defaultText(trigger) {
751
+ return getAttributeValue('text', trigger);
752
+ }
714
753
 
715
- /**
716
- * Destroy lifecycle.
717
- */
754
+ /**
755
+ * Destroy lifecycle.
756
+ */
718
757
 
719
- Clipboard.prototype.destroy = function destroy() {
720
- this.listener.destroy();
758
+ }, {
759
+ key: 'destroy',
760
+ value: function destroy() {
761
+ this.listener.destroy();
721
762
 
722
- if (this.clipboardAction) {
723
- this.clipboardAction.destroy();
724
- this.clipboardAction = null;
763
+ if (this.clipboardAction) {
764
+ this.clipboardAction.destroy();
765
+ this.clipboardAction = null;
766
+ }
725
767
  }
726
- };
768
+ }]);
727
769
 
728
770
  return Clipboard;
729
- })(_tinyEmitter2['default']);
771
+ }(_tinyEmitter2.default);
730
772
 
773
+ /**
774
+ * Helper function to retrieve attribute value.
775
+ * @param {String} suffix
776
+ * @param {Element} element
777
+ */
778
+
779
+ exports.default = Clipboard;
731
780
  function getAttributeValue(suffix, element) {
732
781
  var attribute = 'data-clipboard-' + suffix;
733
782
 
@@ -738,8 +787,5 @@ function getAttributeValue(suffix, element) {
738
787
  return element.getAttribute(attribute);
739
788
  }
740
789
 
741
- exports['default'] = Clipboard;
742
- module.exports = exports['default'];
743
-
744
- },{"./clipboard-action":8,"good-listener":5,"tiny-emitter":7}]},{},[9])(9)
790
+ },{"./clipboard-action":8,"good-listener":4,"tiny-emitter":7}]},{},[9])(9)
745
791
  });
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: clipboard-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.5
4
+ version: 1.5.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mohammed Sadiq
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-11-13 00:00:00.000000000 Z
11
+ date: 2016-02-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -81,7 +81,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
81
81
  version: '0'
82
82
  requirements: []
83
83
  rubyforge_project:
84
- rubygems_version: 2.4.8
84
+ rubygems_version: 2.5.1
85
85
  signing_key:
86
86
  specification_version: 4
87
87
  summary: ''