clipboard-rails 1.6.1 → 1.7.1

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: 4ee6eb4cb4d905e6c09a0a235a003399d174c84e
4
- data.tar.gz: 1bb2e34e63dc882fbcfe066235698d910f985f68
3
+ metadata.gz: 9b496a0f8b7d0f017b72f3934b0e4dc30b07b9e3
4
+ data.tar.gz: c9ee76b0fab13bf1bfd252e68d072309d8c166a0
5
5
  SHA512:
6
- metadata.gz: 5d52d92f104d51e28cb83f625984f31b7cc319a644ebe63b1356a0257d789dd1455f50abdd9cf69b39bcaf1295322367355f64020effdfac50871fb666203620
7
- data.tar.gz: d835f4ab1ff1435bd3571a2a80d091c5a0672d5af98c0b851a8e92e7dd7f34368ca3d2956a648945c1d11fab3a3689e38d999f00477a358c2d7b4ea9929a3e30
6
+ metadata.gz: 8f70e0f6ba52b74fb21a82178fbe505417ca949b148b7ae86bc63a3c04544641ba6b0d053a09f44c3bda6737f6f27a5b71b6614fd2361d49d65d056673d3e756
7
+ data.tar.gz: 7563e3d5e8123b5fb548430e04a6160d345f8861466fc78712d2deff31359f3c061515f3d6c8bbb8fea25a302422c68bc180e6fd5c4be530aa8b29f9f6bdec6d
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2016 Mohammed Sadiq
3
+ Copyright (c) 2017 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
data/README.md CHANGED
@@ -24,6 +24,8 @@ Or install it yourself as:
24
24
 
25
25
  $ gem install clipboard-rails
26
26
 
27
+ Note: After adding the gem to your gem file and running the bundle, restart rails server.
28
+
27
29
  Now you need to edit your `app/assets/javascripts/application.js` file and add the following line:
28
30
  ``` javascript
29
31
  //= require clipboard
@@ -38,8 +40,8 @@ Add this sample code to your `app/assets/javascripts/application.js` file
38
40
  ``` javascript
39
41
  $(document).ready(function(){
40
42
 
41
- var clip = new Clipboard('.clipboard-btn');
42
- console.log(clip);
43
+ var clipboard = new Clipboard('.clipboard-btn');
44
+ console.log(clipboard);
43
45
 
44
46
  });
45
47
  ```
@@ -54,7 +56,7 @@ Add this sample code to your template file like `index.html.erb`
54
56
 
55
57
  <!-- Trigger -->
56
58
  <button class="clipboard-btn" data-clipboard-action="copy" data-clipboard-target="#bar">
57
- Cut to clipboard
59
+ Copy to clipboard
58
60
  </button>
59
61
  ```
60
62
  ## Additional information
@@ -76,7 +78,7 @@ Add Tooltips + Highlight animation with Clipboard.js on button click using Boots
76
78
 
77
79
  // Tooltip
78
80
 
79
- $('button').tooltip({
81
+ $('.clipboard-btn').tooltip({
80
82
  trigger: 'click',
81
83
  placement: 'bottom'
82
84
  });
@@ -95,7 +97,7 @@ function hideTooltip(btn) {
95
97
 
96
98
  // Clipboard
97
99
 
98
- var clipboard = new Clipboard('button');
100
+ var clipboard = new Clipboard('.clipboard-btn');
99
101
 
100
102
  clipboard.on('success', function(e) {
101
103
  setTooltip(e.trigger, 'Copied!');
@@ -109,9 +111,19 @@ clipboard.on('error', function(e) {
109
111
  ```
110
112
 
111
113
  ``` html
112
- <!-- Animation on buttons HTML -->
113
- <button class="btn btn-primary" data-clipboard-text="It worked!">Click me</button>
114
- <button class="btn btn-primary" data-clipboard-text="It worked again!">Click me</button>
114
+ <!-- Example 1: Animation with single button HTML source-->
115
+ <button class="clipboard-btn btn btn-primary" data-clipboard-text="It worked!">Click me</button>
116
+
117
+ ```
118
+
119
+ ``` html
120
+ <!-- Example 2: with Target source -->
121
+ <textarea id="bar">Mussum ipsum cacilds...</textarea>
122
+
123
+ <!-- Trigger -->
124
+ <button class="clipboard-btn" data-clipboard-action="copy" data-clipboard-target="#bar">
125
+ Copy to clipboard
126
+ </button>
115
127
  ```
116
128
 
117
129
 
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
10
10
  spec.email = ["sadiqmmm@gmail.com"]
11
11
 
12
12
  spec.summary = spec.description
13
- spec.description = 'This gem provides the clipboard.js Javascript library for your Rails 3 and Rails 4 application.'
13
+ spec.description = 'This gem provides the clipboard.js Javascript library for your Rails 4 and Rails 5 application.'
14
14
  spec.homepage = 'https://github.com/sadiqmmm/clipboard-rails'
15
15
  spec.license = "MIT"
16
16
 
@@ -1,5 +1,5 @@
1
1
  module Clipboard
2
2
  module Rails
3
- VERSION = "1.6.1"
3
+ VERSION = "1.7.1"
4
4
  end
5
5
  end
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * clipboard.js v1.6.1
2
+ * clipboard.js v1.7.1
3
3
  * https://zenorocha.github.io/clipboard.js
4
4
  *
5
5
  * Licensed MIT © Zeno Rocha
@@ -29,7 +29,10 @@ if (typeof Element !== 'undefined' && !Element.prototype.matches) {
29
29
  */
30
30
  function closest (element, selector) {
31
31
  while (element && element.nodeType !== DOCUMENT_NODE_TYPE) {
32
- if (element.matches(selector)) return element;
32
+ if (typeof element.matches === 'function' &&
33
+ element.matches(selector)) {
34
+ return element;
35
+ }
33
36
  element = element.parentNode;
34
37
  }
35
38
  }
@@ -420,6 +423,7 @@ module.exports = E;
420
423
  var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
421
424
 
422
425
  this.action = options.action;
426
+ this.container = options.container;
423
427
  this.emitter = options.emitter;
424
428
  this.target = options.target;
425
429
  this.text = options.text;
@@ -448,7 +452,7 @@ module.exports = E;
448
452
  this.fakeHandlerCallback = function () {
449
453
  return _this.removeFake();
450
454
  };
451
- this.fakeHandler = document.body.addEventListener('click', this.fakeHandlerCallback) || true;
455
+ this.fakeHandler = this.container.addEventListener('click', this.fakeHandlerCallback) || true;
452
456
 
453
457
  this.fakeElem = document.createElement('textarea');
454
458
  // Prevent zooming on iOS
@@ -467,7 +471,7 @@ module.exports = E;
467
471
  this.fakeElem.setAttribute('readonly', '');
468
472
  this.fakeElem.value = this.text;
469
473
 
470
- document.body.appendChild(this.fakeElem);
474
+ this.container.appendChild(this.fakeElem);
471
475
 
472
476
  this.selectedText = (0, _select2.default)(this.fakeElem);
473
477
  this.copyText();
@@ -476,13 +480,13 @@ module.exports = E;
476
480
  key: 'removeFake',
477
481
  value: function removeFake() {
478
482
  if (this.fakeHandler) {
479
- document.body.removeEventListener('click', this.fakeHandlerCallback);
483
+ this.container.removeEventListener('click', this.fakeHandlerCallback);
480
484
  this.fakeHandler = null;
481
485
  this.fakeHandlerCallback = null;
482
486
  }
483
487
 
484
488
  if (this.fakeElem) {
485
- document.body.removeChild(this.fakeElem);
489
+ this.container.removeChild(this.fakeElem);
486
490
  this.fakeElem = null;
487
491
  }
488
492
  }
@@ -518,8 +522,8 @@ module.exports = E;
518
522
  }, {
519
523
  key: 'clearSelection',
520
524
  value: function clearSelection() {
521
- if (this.target) {
522
- this.target.blur();
525
+ if (this.trigger) {
526
+ this.trigger.focus();
523
527
  }
524
528
 
525
529
  window.getSelection().removeAllRanges();
@@ -601,6 +605,12 @@ module.exports = E;
601
605
  };
602
606
  }
603
607
 
608
+ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) {
609
+ return typeof obj;
610
+ } : function (obj) {
611
+ return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
612
+ };
613
+
604
614
  function _classCallCheck(instance, Constructor) {
605
615
  if (!(instance instanceof Constructor)) {
606
616
  throw new TypeError("Cannot call a class as a function");
@@ -681,6 +691,7 @@ module.exports = E;
681
691
  this.action = typeof options.action === 'function' ? options.action : this.defaultAction;
682
692
  this.target = typeof options.target === 'function' ? options.target : this.defaultTarget;
683
693
  this.text = typeof options.text === 'function' ? options.text : this.defaultText;
694
+ this.container = _typeof(options.container) === 'object' ? options.container : document.body;
684
695
  }
685
696
  }, {
686
697
  key: 'listenClick',
@@ -704,6 +715,7 @@ module.exports = E;
704
715
  action: this.action(trigger),
705
716
  target: this.target(trigger),
706
717
  text: this.text(trigger),
718
+ container: this.container,
707
719
  trigger: trigger,
708
720
  emitter: this
709
721
  });
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.6.1
4
+ version: 1.7.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mohammed Sadiq
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-03-12 00:00:00.000000000 Z
11
+ date: 2017-06-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -39,7 +39,7 @@ dependencies:
39
39
  - !ruby/object:Gem::Version
40
40
  version: '10.0'
41
41
  description: This gem provides the clipboard.js Javascript library for your Rails
42
- 3 and Rails 4 application.
42
+ 4 and Rails 5 application.
43
43
  email:
44
44
  - sadiqmmm@gmail.com
45
45
  executables: []
@@ -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.6.8
84
+ rubygems_version: 2.6.12
85
85
  signing_key:
86
86
  specification_version: 4
87
87
  summary: ''