clipboard-rails 1.4.3 → 1.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/clipboard/rails/version.rb +1 -1
- data/vendor/assets/javascripts/clipboard.js +209 -53
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e052ee82b3c3ec5e3bf9486a07bdfdc3403f83ab
|
4
|
+
data.tar.gz: 8a4bc12307def0cc86b8dafd60ff667f46f747a1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8b8cd6da6c1f0a2b821f8e63baea39bb304288253003df3fdcbcb4d920238244ecf65d6c60fe0317530b3cfd2c7f9512224cf8bf6a156d588d04db4fad1ae7b5
|
7
|
+
data.tar.gz: 03354f091925d645d66633bf3db879facea9b5bf7c9b62e2846b6fd0b8695936e3ff8b72dc1adb9b38c1ed942683e59efe3e56e14572fb8bb1591823019c28fa
|
@@ -1,5 +1,5 @@
|
|
1
1
|
/*!
|
2
|
-
* clipboard.js v1.
|
2
|
+
* clipboard.js v1.5.0
|
3
3
|
* https://zenorocha.github.io/clipboard.js
|
4
4
|
*
|
5
5
|
* Licensed MIT © Zeno Rocha
|
@@ -61,61 +61,226 @@ function match(el, selector) {
|
|
61
61
|
var closest = require('closest');
|
62
62
|
|
63
63
|
/**
|
64
|
-
*
|
65
|
-
* and invoke `fn(e)`. A callback function
|
66
|
-
* is returned which may be passed to `.unbind()`.
|
64
|
+
* Delegates event to a selector.
|
67
65
|
*
|
68
|
-
* @param {Element}
|
66
|
+
* @param {Element} element
|
69
67
|
* @param {String} selector
|
70
68
|
* @param {String} type
|
71
|
-
* @param {Function}
|
72
|
-
* @
|
69
|
+
* @param {Function} callback
|
70
|
+
* @return {Object}
|
71
|
+
*/
|
72
|
+
function delegate(element, selector, type, callback) {
|
73
|
+
var listenerFn = listener.apply(this, arguments);
|
74
|
+
|
75
|
+
element.addEventListener(type, listenerFn);
|
76
|
+
|
77
|
+
return {
|
78
|
+
destroy: function() {
|
79
|
+
element.removeEventListener(type, listenerFn);
|
80
|
+
}
|
81
|
+
}
|
82
|
+
}
|
83
|
+
|
84
|
+
/**
|
85
|
+
* Finds closest match and invokes callback.
|
86
|
+
*
|
87
|
+
* @param {Element} element
|
88
|
+
* @param {String} selector
|
89
|
+
* @param {String} type
|
90
|
+
* @param {Function} callback
|
73
91
|
* @return {Function}
|
74
92
|
*/
|
93
|
+
function listener(element, selector, type, callback) {
|
94
|
+
return function(e) {
|
95
|
+
var delegateTarget = closest(e.target, selector, true);
|
75
96
|
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
97
|
+
if (delegateTarget) {
|
98
|
+
Object.defineProperty(e, 'target', {
|
99
|
+
value: delegateTarget
|
100
|
+
});
|
101
|
+
|
102
|
+
callback.call(element, e);
|
103
|
+
}
|
104
|
+
}
|
105
|
+
}
|
106
|
+
|
107
|
+
module.exports = delegate;
|
108
|
+
|
109
|
+
},{"closest":1}],4:[function(require,module,exports){
|
110
|
+
/**
|
111
|
+
* Check if argument is a HTML element.
|
112
|
+
*
|
113
|
+
* @param {Object} value
|
114
|
+
* @return {Boolean}
|
115
|
+
*/
|
116
|
+
exports.node = function(value) {
|
117
|
+
return value !== undefined
|
118
|
+
&& value instanceof HTMLElement
|
119
|
+
&& value.nodeType === 1;
|
82
120
|
};
|
83
121
|
|
84
122
|
/**
|
85
|
-
*
|
123
|
+
* Check if argument is a list of HTML elements.
|
86
124
|
*
|
87
|
-
* @param {
|
88
|
-
* @
|
89
|
-
* @param {Function} fn
|
90
|
-
* @param {Boolean} capture
|
125
|
+
* @param {Object} value
|
126
|
+
* @return {Boolean}
|
91
127
|
*/
|
128
|
+
exports.nodeList = function(value) {
|
129
|
+
var type = Object.prototype.toString.call(value);
|
92
130
|
|
93
|
-
|
94
|
-
|
131
|
+
return value !== undefined
|
132
|
+
&& (type === '[object NodeList]' || type === '[object HTMLCollection]')
|
133
|
+
&& ('length' in value)
|
134
|
+
&& (value.length === 0 || exports.node(value[0]));
|
95
135
|
};
|
96
136
|
|
97
|
-
|
137
|
+
/**
|
138
|
+
* Check if argument is a string.
|
139
|
+
*
|
140
|
+
* @param {Object} value
|
141
|
+
* @return {Boolean}
|
142
|
+
*/
|
143
|
+
exports.string = function(value) {
|
144
|
+
return typeof value === 'string'
|
145
|
+
|| value instanceof String;
|
146
|
+
};
|
147
|
+
|
148
|
+
/**
|
149
|
+
* Check if argument is a function.
|
150
|
+
*
|
151
|
+
* @param {Object} value
|
152
|
+
* @return {Boolean}
|
153
|
+
*/
|
154
|
+
exports.function = function(value) {
|
155
|
+
var type = Object.prototype.toString.call(value);
|
156
|
+
|
157
|
+
return type === '[object Function]';
|
158
|
+
};
|
159
|
+
|
160
|
+
},{}],5:[function(require,module,exports){
|
161
|
+
var is = require('./is');
|
162
|
+
var delegate = require('delegate');
|
163
|
+
|
164
|
+
/**
|
165
|
+
* Validates all params and calls the right
|
166
|
+
* listener function based on its target type.
|
167
|
+
*
|
168
|
+
* @param {String|HTMLElement|HTMLCollection|NodeList} target
|
169
|
+
* @param {String} type
|
170
|
+
* @param {Function} callback
|
171
|
+
* @return {Object}
|
172
|
+
*/
|
173
|
+
function listen(target, type, callback) {
|
174
|
+
if (!target && !type && !callback) {
|
175
|
+
throw new Error('Missing required arguments');
|
176
|
+
}
|
177
|
+
|
178
|
+
if (!is.string(type)) {
|
179
|
+
throw new TypeError('Second argument must be a String');
|
180
|
+
}
|
181
|
+
|
182
|
+
if (!is.function(callback)) {
|
183
|
+
throw new TypeError('Third argument must be a Function');
|
184
|
+
}
|
185
|
+
|
186
|
+
if (is.node(target)) {
|
187
|
+
return listenNode(target, type, callback);
|
188
|
+
}
|
189
|
+
else if (is.nodeList(target)) {
|
190
|
+
return listenNodeList(target, type, callback);
|
191
|
+
}
|
192
|
+
else if (is.string(target)) {
|
193
|
+
return listenSelector(target, type, callback);
|
194
|
+
}
|
195
|
+
else {
|
196
|
+
throw new TypeError('First argument must be a String, HTMLElement, HTMLCollection, or NodeList');
|
197
|
+
}
|
198
|
+
}
|
199
|
+
|
200
|
+
/**
|
201
|
+
* Adds an event listener to a HTML element
|
202
|
+
* and returns a remove listener function.
|
203
|
+
*
|
204
|
+
* @param {HTMLElement} node
|
205
|
+
* @param {String} type
|
206
|
+
* @param {Function} callback
|
207
|
+
* @return {Object}
|
208
|
+
*/
|
209
|
+
function listenNode(node, type, callback) {
|
210
|
+
node.addEventListener(type, callback);
|
211
|
+
|
212
|
+
return {
|
213
|
+
destroy: function() {
|
214
|
+
node.removeEventListener(type, callback);
|
215
|
+
}
|
216
|
+
}
|
217
|
+
}
|
218
|
+
|
219
|
+
/**
|
220
|
+
* Add an event listener to a list of HTML elements
|
221
|
+
* and returns a remove listener function.
|
222
|
+
*
|
223
|
+
* @param {NodeList|HTMLCollection} nodeList
|
224
|
+
* @param {String} type
|
225
|
+
* @param {Function} callback
|
226
|
+
* @return {Object}
|
227
|
+
*/
|
228
|
+
function listenNodeList(nodeList, type, callback) {
|
229
|
+
Array.prototype.forEach.call(nodeList, function(node) {
|
230
|
+
node.addEventListener(type, callback);
|
231
|
+
});
|
232
|
+
|
233
|
+
return {
|
234
|
+
destroy: function() {
|
235
|
+
Array.prototype.forEach.call(nodeList, function(node) {
|
236
|
+
node.removeEventListener(type, callback);
|
237
|
+
});
|
238
|
+
}
|
239
|
+
}
|
240
|
+
}
|
241
|
+
|
242
|
+
/**
|
243
|
+
* Add an event listener to a selector
|
244
|
+
* and returns a remove listener function.
|
245
|
+
*
|
246
|
+
* @param {String} selector
|
247
|
+
* @param {String} type
|
248
|
+
* @param {Function} callback
|
249
|
+
* @return {Object}
|
250
|
+
*/
|
251
|
+
function listenSelector(selector, type, callback) {
|
252
|
+
return delegate(document.body, selector, type, callback);
|
253
|
+
}
|
254
|
+
|
255
|
+
module.exports = listen;
|
256
|
+
|
257
|
+
},{"./is":4,"delegate":3}],6:[function(require,module,exports){
|
98
258
|
function select(element) {
|
99
|
-
var
|
259
|
+
var selectedText;
|
100
260
|
|
101
261
|
if (element.nodeName === 'INPUT' || element.nodeName === 'TEXTAREA') {
|
102
262
|
element.selectionStart = 0;
|
103
263
|
element.selectionEnd = element.value.length;
|
264
|
+
|
265
|
+
selectedText = element.value;
|
104
266
|
}
|
105
267
|
else {
|
268
|
+
var selection = window.getSelection();
|
106
269
|
var range = document.createRange();
|
107
270
|
|
108
271
|
range.selectNodeContents(element);
|
109
272
|
selection.removeAllRanges();
|
110
273
|
selection.addRange(range);
|
274
|
+
|
275
|
+
selectedText = selection.toString();
|
111
276
|
}
|
112
277
|
|
113
|
-
return
|
278
|
+
return selectedText;
|
114
279
|
}
|
115
280
|
|
116
281
|
module.exports = select;
|
117
282
|
|
118
|
-
},{}],
|
283
|
+
},{}],7:[function(require,module,exports){
|
119
284
|
function E () {
|
120
285
|
// Keep this empty so it's easier to inherit from
|
121
286
|
// (via https://github.com/lipsmack from https://github.com/scottcorgan/tiny-emitter/issues/3)
|
@@ -183,7 +348,7 @@ E.prototype = {
|
|
183
348
|
|
184
349
|
module.exports = E;
|
185
350
|
|
186
|
-
},{}],
|
351
|
+
},{}],8:[function(require,module,exports){
|
187
352
|
'use strict';
|
188
353
|
|
189
354
|
exports.__esModule = true;
|
@@ -417,7 +582,7 @@ var ClipboardAction = (function () {
|
|
417
582
|
exports['default'] = ClipboardAction;
|
418
583
|
module.exports = exports['default'];
|
419
584
|
|
420
|
-
},{"select":
|
585
|
+
},{"select":6}],9:[function(require,module,exports){
|
421
586
|
'use strict';
|
422
587
|
|
423
588
|
exports.__esModule = true;
|
@@ -432,16 +597,16 @@ var _clipboardAction = require('./clipboard-action');
|
|
432
597
|
|
433
598
|
var _clipboardAction2 = _interopRequireDefault(_clipboardAction);
|
434
599
|
|
435
|
-
var _delegate = require('delegate');
|
436
|
-
|
437
|
-
var _delegate2 = _interopRequireDefault(_delegate);
|
438
|
-
|
439
600
|
var _tinyEmitter = require('tiny-emitter');
|
440
601
|
|
441
602
|
var _tinyEmitter2 = _interopRequireDefault(_tinyEmitter);
|
442
603
|
|
604
|
+
var _goodListener = require('good-listener');
|
605
|
+
|
606
|
+
var _goodListener2 = _interopRequireDefault(_goodListener);
|
607
|
+
|
443
608
|
/**
|
444
|
-
* Base class which takes
|
609
|
+
* Base class which takes one or more elements, adds event listeners to them,
|
445
610
|
* and instantiates a new `ClipboardAction` on each click.
|
446
611
|
*/
|
447
612
|
|
@@ -449,17 +614,17 @@ var Clipboard = (function (_Emitter) {
|
|
449
614
|
_inherits(Clipboard, _Emitter);
|
450
615
|
|
451
616
|
/**
|
452
|
-
* @param {String}
|
617
|
+
* @param {String|HTMLElement|HTMLCollection|NodeList} trigger
|
453
618
|
* @param {Object} options
|
454
619
|
*/
|
455
620
|
|
456
|
-
function Clipboard(
|
621
|
+
function Clipboard(trigger, options) {
|
457
622
|
_classCallCheck(this, Clipboard);
|
458
623
|
|
459
624
|
_Emitter.call(this);
|
460
625
|
|
461
626
|
this.resolveOptions(options);
|
462
|
-
this.
|
627
|
+
this.listenClick(trigger);
|
463
628
|
}
|
464
629
|
|
465
630
|
/**
|
@@ -483,27 +648,18 @@ var Clipboard = (function (_Emitter) {
|
|
483
648
|
};
|
484
649
|
|
485
650
|
/**
|
486
|
-
*
|
487
|
-
* @param {String}
|
651
|
+
* Adds a click event listener to the passed trigger.
|
652
|
+
* @param {String|HTMLElement|HTMLCollection|NodeList} trigger
|
488
653
|
*/
|
489
654
|
|
490
|
-
Clipboard.prototype.
|
655
|
+
Clipboard.prototype.listenClick = function listenClick(trigger) {
|
491
656
|
var _this = this;
|
492
657
|
|
493
|
-
this.
|
658
|
+
this.listener = _goodListener2['default'](trigger, 'click', function (e) {
|
494
659
|
return _this.onClick(e);
|
495
660
|
});
|
496
661
|
};
|
497
662
|
|
498
|
-
/**
|
499
|
-
* Undelegates a click event on body.
|
500
|
-
* @param {String} selector
|
501
|
-
*/
|
502
|
-
|
503
|
-
Clipboard.prototype.undelegateClick = function undelegateClick() {
|
504
|
-
_delegate2['default'].unbind(document.body, 'click', this.binding);
|
505
|
-
};
|
506
|
-
|
507
663
|
/**
|
508
664
|
* Defines a new `ClipboardAction` on each click event.
|
509
665
|
* @param {Event} e
|
@@ -515,10 +671,10 @@ var Clipboard = (function (_Emitter) {
|
|
515
671
|
}
|
516
672
|
|
517
673
|
this.clipboardAction = new _clipboardAction2['default']({
|
518
|
-
action: this.action(e.
|
519
|
-
target: this.target(e.
|
520
|
-
text: this.text(e.
|
521
|
-
trigger: e.
|
674
|
+
action: this.action(e.target),
|
675
|
+
target: this.target(e.target),
|
676
|
+
text: this.text(e.target),
|
677
|
+
trigger: e.target,
|
522
678
|
emitter: this
|
523
679
|
});
|
524
680
|
};
|
@@ -559,7 +715,7 @@ var Clipboard = (function (_Emitter) {
|
|
559
715
|
*/
|
560
716
|
|
561
717
|
Clipboard.prototype.destroy = function destroy() {
|
562
|
-
this.
|
718
|
+
this.listener.destroy();
|
563
719
|
|
564
720
|
if (this.clipboardAction) {
|
565
721
|
this.clipboardAction.destroy();
|
@@ -583,5 +739,5 @@ function getAttributeValue(suffix, element) {
|
|
583
739
|
exports['default'] = Clipboard;
|
584
740
|
module.exports = exports['default'];
|
585
741
|
|
586
|
-
},{"./clipboard-action":
|
742
|
+
},{"./clipboard-action":8,"good-listener":5,"tiny-emitter":7}]},{},[9])(9)
|
587
743
|
});
|
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.
|
4
|
+
version: 1.5.0
|
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-10-
|
11
|
+
date: 2015-10-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|