clipboard-rails 1.4.2 → 1.4.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9786c8c3887dd2f3f68184a98a827b00f84280c6
4
- data.tar.gz: 34db356a467a263cef35f9e229e79f481ec5d3c4
3
+ metadata.gz: 97e668f905893a41535a1700422c2ad31ff95f94
4
+ data.tar.gz: 83a9ce237ce1e2e3282ed1b925621cac7438e6b8
5
5
  SHA512:
6
- metadata.gz: 0b3621964578c3bda33a56e79f4cc16ec2a3156c9877aa658cef16392c4dcc72d14925337efbfad5d1845a3ef223ed0d2600fc79c69ed04941a226bf1425ab05
7
- data.tar.gz: 1b8e778dce4da4ef1c60232a5ff0d7e63ac12ac4ab23d85e5f1cba46fa955c6bcbc6d53e7555eb0b7a67468a36a6c3292238f83ef619bae8141b190691c5a08e
6
+ metadata.gz: bce2e2d5c8a1fa3eb90f1676ca5b882d007b62a6e516577f5849c3a9ea0e7b97b0bf3eca5c0cf7a34e4c2f479f1b3e0bf673a28014feaffa4c9b3e029e42fef4
7
+ data.tar.gz: f4858986c9f3607728fa078d7838216de4974f4055e513d44c49e8bad4d99e953ca2ff1802abe6d06bf34af9e79fdaea4bad163474142e3712e9c93b5538da07
@@ -1,5 +1,5 @@
1
1
  module Clipboard
2
2
  module Rails
3
- VERSION = "1.4.2"
3
+ VERSION = "1.4.3"
4
4
  end
5
5
  end
@@ -1,56 +1,10 @@
1
- (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.Clipboard = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
2
- /**
3
- * Module dependencies.
4
- */
5
-
6
- var closest = require('closest')
7
- , event = require('component-event');
8
-
9
- /**
10
- * Delegate event `type` to `selector`
11
- * and invoke `fn(e)`. A callback function
12
- * is returned which may be passed to `.unbind()`.
13
- *
14
- * @param {Element} el
15
- * @param {String} selector
16
- * @param {String} type
17
- * @param {Function} fn
18
- * @param {Boolean} capture
19
- * @return {Function}
20
- * @api public
21
- */
22
-
23
- // Some events don't bubble, so we want to bind to the capture phase instead
24
- // when delegating.
25
- var forceCaptureEvents = ['focus', 'blur'];
26
-
27
- exports.bind = function(el, selector, type, fn, capture){
28
- if (forceCaptureEvents.indexOf(type) !== -1) capture = true;
29
-
30
- return event.bind(el, type, function(e){
31
- var target = e.target || e.srcElement;
32
- e.delegateTarget = closest(target, selector, true, el);
33
- if (e.delegateTarget) fn.call(el, e);
34
- }, capture);
35
- };
36
-
37
- /**
38
- * Unbind event `type`'s callback `fn`.
1
+ /*!
2
+ * clipboard.js v1.4.3
3
+ * https://zenorocha.github.io/clipboard.js
39
4
  *
40
- * @param {Element} el
41
- * @param {String} type
42
- * @param {Function} fn
43
- * @param {Boolean} capture
44
- * @api public
5
+ * Licensed MIT © Zeno Rocha
45
6
  */
46
-
47
- exports.unbind = function(el, type, fn, capture){
48
- if (forceCaptureEvents.indexOf(type) !== -1) capture = true;
49
-
50
- event.unbind(el, type, fn, capture);
51
- };
52
-
53
- },{"closest":2,"component-event":4}],2:[function(require,module,exports){
7
+ (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.Clipboard = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
54
8
  var matches = require('matches-selector')
55
9
 
56
10
  module.exports = function (element, selector, checkYoSelf) {
@@ -62,7 +16,7 @@ module.exports = function (element, selector, checkYoSelf) {
62
16
  }
63
17
  }
64
18
 
65
- },{"matches-selector":3}],3:[function(require,module,exports){
19
+ },{"matches-selector":2}],2:[function(require,module,exports){
66
20
 
67
21
  /**
68
22
  * Element prototype.
@@ -103,42 +57,64 @@ function match(el, selector) {
103
57
  }
104
58
  return false;
105
59
  }
106
- },{}],4:[function(require,module,exports){
107
- var bind = window.addEventListener ? 'addEventListener' : 'attachEvent',
108
- unbind = window.removeEventListener ? 'removeEventListener' : 'detachEvent',
109
- prefix = bind !== 'addEventListener' ? 'on' : '';
60
+ },{}],3:[function(require,module,exports){
61
+ var closest = require('closest');
110
62
 
111
63
  /**
112
- * Bind `el` event `type` to `fn`.
64
+ * Delegate event `type` to `selector`
65
+ * and invoke `fn(e)`. A callback function
66
+ * is returned which may be passed to `.unbind()`.
113
67
  *
114
68
  * @param {Element} el
69
+ * @param {String} selector
115
70
  * @param {String} type
116
71
  * @param {Function} fn
117
72
  * @param {Boolean} capture
118
73
  * @return {Function}
119
- * @api public
120
74
  */
121
75
 
122
- exports.bind = function(el, type, fn, capture){
123
- el[bind](prefix + type, fn, capture || false);
124
- return fn;
76
+ exports.bind = function(el, selector, type, fn, capture){
77
+ return el.addEventListener(type, function(e){
78
+ var target = e.target || e.srcElement;
79
+ e.delegateTarget = closest(target, selector, true, el);
80
+ if (e.delegateTarget) fn.call(el, e);
81
+ }, capture);
125
82
  };
126
83
 
127
84
  /**
128
- * Unbind `el` event `type`'s callback `fn`.
85
+ * Unbind event `type`'s callback `fn`.
129
86
  *
130
87
  * @param {Element} el
131
88
  * @param {String} type
132
89
  * @param {Function} fn
133
90
  * @param {Boolean} capture
134
- * @return {Function}
135
- * @api public
136
91
  */
137
92
 
138
93
  exports.unbind = function(el, type, fn, capture){
139
- el[unbind](prefix + type, fn, capture || false);
140
- return fn;
94
+ el.removeEventListener(type, fn, capture);
141
95
  };
96
+
97
+ },{"closest":1}],4:[function(require,module,exports){
98
+ function select(element) {
99
+ var selection = window.getSelection();
100
+
101
+ if (element.nodeName === 'INPUT' || element.nodeName === 'TEXTAREA') {
102
+ element.selectionStart = 0;
103
+ element.selectionEnd = element.value.length;
104
+ }
105
+ else {
106
+ var range = document.createRange();
107
+
108
+ range.selectNodeContents(element);
109
+ selection.removeAllRanges();
110
+ selection.addRange(range);
111
+ }
112
+
113
+ return selection.toString();
114
+ }
115
+
116
+ module.exports = select;
117
+
142
118
  },{}],5:[function(require,module,exports){
143
119
  function E () {
144
120
  // Keep this empty so it's easier to inherit from
@@ -148,23 +124,24 @@ function E () {
148
124
  E.prototype = {
149
125
  on: function (name, callback, ctx) {
150
126
  var e = this.e || (this.e = {});
151
-
127
+
152
128
  (e[name] || (e[name] = [])).push({
153
129
  fn: callback,
154
130
  ctx: ctx
155
131
  });
156
-
132
+
157
133
  return this;
158
134
  },
159
135
 
160
136
  once: function (name, callback, ctx) {
161
137
  var self = this;
162
- var fn = function () {
163
- self.off(name, fn);
138
+ function listener () {
139
+ self.off(name, listener);
164
140
  callback.apply(ctx, arguments);
165
141
  };
166
-
167
- return this.on(name, fn, ctx);
142
+
143
+ listener._ = callback
144
+ return this.on(name, listener, ctx);
168
145
  },
169
146
 
170
147
  emit: function (name) {
@@ -172,11 +149,11 @@ E.prototype = {
172
149
  var evtArr = ((this.e || (this.e = {}))[name] || []).slice();
173
150
  var i = 0;
174
151
  var len = evtArr.length;
175
-
152
+
176
153
  for (i; i < len; i++) {
177
154
  evtArr[i].fn.apply(evtArr[i].ctx, data);
178
155
  }
179
-
156
+
180
157
  return this;
181
158
  },
182
159
 
@@ -184,21 +161,22 @@ E.prototype = {
184
161
  var e = this.e || (this.e = {});
185
162
  var evts = e[name];
186
163
  var liveEvents = [];
187
-
164
+
188
165
  if (evts && callback) {
189
166
  for (var i = 0, len = evts.length; i < len; i++) {
190
- if (evts[i].fn !== callback) liveEvents.push(evts[i]);
167
+ if (evts[i].fn !== callback && evts[i].fn._ !== callback)
168
+ liveEvents.push(evts[i]);
191
169
  }
192
170
  }
193
-
171
+
194
172
  // Remove event from queue to prevent memory leak
195
173
  // Suggested by https://github.com/lazd
196
174
  // Ref: https://github.com/scottcorgan/tiny-emitter/commit/c6ebfaa9bc973b33d110a84a307742b7cf94c953#commitcomment-5024910
197
175
 
198
- (liveEvents.length)
176
+ (liveEvents.length)
199
177
  ? e[name] = liveEvents
200
178
  : delete e[name];
201
-
179
+
202
180
  return this;
203
181
  }
204
182
  };
@@ -206,18 +184,25 @@ E.prototype = {
206
184
  module.exports = E;
207
185
 
208
186
  },{}],6:[function(require,module,exports){
209
- /**
210
- * Inner class which performs selection from either `text` or `target`
211
- * properties and then executes copy or cut operations.
212
- */
213
187
  'use strict';
214
188
 
215
189
  exports.__esModule = true;
216
190
 
217
191
  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; }; })();
218
192
 
193
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
194
+
219
195
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
220
196
 
197
+ var _select = require('select');
198
+
199
+ var _select2 = _interopRequireDefault(_select);
200
+
201
+ /**
202
+ * Inner class which performs selection from either `text` or `target`
203
+ * properties and then executes copy or cut operations.
204
+ */
205
+
221
206
  var ClipboardAction = (function () {
222
207
  /**
223
208
  * @param {Object} options
@@ -284,11 +269,10 @@ var ClipboardAction = (function () {
284
269
  this.fakeElem.style.top = (window.pageYOffset || document.documentElement.scrollTop) + 'px';
285
270
  this.fakeElem.setAttribute('readonly', '');
286
271
  this.fakeElem.value = this.text;
287
- this.selectedText = this.text;
288
272
 
289
273
  document.body.appendChild(this.fakeElem);
290
274
 
291
- this.fakeElem.select();
275
+ this.selectedText = _select2['default'](this.fakeElem);
292
276
  this.copyText();
293
277
  };
294
278
 
@@ -314,19 +298,7 @@ var ClipboardAction = (function () {
314
298
  */
315
299
 
316
300
  ClipboardAction.prototype.selectTarget = function selectTarget() {
317
- if (this.target.nodeName === 'INPUT' || this.target.nodeName === 'TEXTAREA') {
318
- this.target.select();
319
- this.selectedText = this.target.value;
320
- } else {
321
- var range = document.createRange();
322
- var selection = window.getSelection();
323
-
324
- selection.removeAllRanges();
325
- range.selectNodeContents(this.target);
326
- selection.addRange(range);
327
- this.selectedText = selection.toString();
328
- }
329
-
301
+ this.selectedText = _select2['default'](this.target);
330
302
  this.copyText();
331
303
  };
332
304
 
@@ -445,7 +417,7 @@ var ClipboardAction = (function () {
445
417
  exports['default'] = ClipboardAction;
446
418
  module.exports = exports['default'];
447
419
 
448
- },{}],7:[function(require,module,exports){
420
+ },{"select":4}],7:[function(require,module,exports){
449
421
  'use strict';
450
422
 
451
423
  exports.__esModule = true;
@@ -460,9 +432,9 @@ var _clipboardAction = require('./clipboard-action');
460
432
 
461
433
  var _clipboardAction2 = _interopRequireDefault(_clipboardAction);
462
434
 
463
- var _delegateEvents = require('delegate-events');
435
+ var _delegate = require('delegate');
464
436
 
465
- var _delegateEvents2 = _interopRequireDefault(_delegateEvents);
437
+ var _delegate2 = _interopRequireDefault(_delegate);
466
438
 
467
439
  var _tinyEmitter = require('tiny-emitter');
468
440
 
@@ -518,7 +490,7 @@ var Clipboard = (function (_Emitter) {
518
490
  Clipboard.prototype.delegateClick = function delegateClick(selector) {
519
491
  var _this = this;
520
492
 
521
- this.binding = _delegateEvents2['default'].bind(document.body, selector, 'click', function (e) {
493
+ this.binding = _delegate2['default'].bind(document.body, selector, 'click', function (e) {
522
494
  return _this.onClick(e);
523
495
  });
524
496
  };
@@ -529,7 +501,7 @@ var Clipboard = (function (_Emitter) {
529
501
  */
530
502
 
531
503
  Clipboard.prototype.undelegateClick = function undelegateClick() {
532
- _delegateEvents2['default'].unbind(document.body, 'click', this.binding);
504
+ _delegate2['default'].unbind(document.body, 'click', this.binding);
533
505
  };
534
506
 
535
507
  /**
@@ -611,5 +583,5 @@ function getAttributeValue(suffix, element) {
611
583
  exports['default'] = Clipboard;
612
584
  module.exports = exports['default'];
613
585
 
614
- },{"./clipboard-action":6,"delegate-events":1,"tiny-emitter":5}]},{},[7])(7)
586
+ },{"./clipboard-action":6,"delegate":3,"tiny-emitter":5}]},{},[7])(7)
615
587
  });
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.2
4
+ version: 1.4.3
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-14 00:00:00.000000000 Z
11
+ date: 2015-10-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler