clipboard-rails 1.5.16 → 1.6.0

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: 93064c17a8044f99b9104e68339b272bf644d7cd
4
- data.tar.gz: 4744cfe7fc97c40d354c499efb999abe6b439795
3
+ metadata.gz: fdde22aa567b1e181a2eb373a59f8b9a5dacc792
4
+ data.tar.gz: be7cd97ee8d48b8ea85f09511ae4574afe19cb46
5
5
  SHA512:
6
- metadata.gz: 559f99d751b69b05eb462aab85e92f65b2e9c68eee4152de95696f293abd39681ebd1cd980893fb314e2777ccb97de6f0994d5dbbd168ab0f771528b44ecdd07
7
- data.tar.gz: d37d68ea1af38fdb19a43bbcdb8c3758a33d188b9ef935c58c5fa58654cfb9f784198778765c410e6971c95db6aa98b0d8be73f5be34f65212dabced413ea6d8
6
+ metadata.gz: 8ed84fdf6938a670897f3aba81b1848913d09f2ec7bd6ecc8da3251a0848733a8e7c1762ea3c89515d26e36f9e78a25dc564f26afe40f09ac3099916af2d695e
7
+ data.tar.gz: 0a43c16cdb82ec9973b831bbb79edde4f66646ace8b0f29f548822ebf8b9eff26ae1f3a80b8a10f9b20b1c8ec3ea6006e10fd5d8cfbced0bf8051ad25a29ac3a
data/README.md CHANGED
@@ -67,6 +67,55 @@ If you omit this attribute, **copy** will be used by default.
67
67
 
68
68
  Read the clipboard.js documentation here http://zenorocha.github.io/clipboard.js/ for full usage information.
69
69
 
70
+
71
+ ## Add Tooltips + Highlight animation:
72
+
73
+ Add Tooltips + Highlight animation with Clipboard.js on button click using Bootstrap Tooltip
74
+
75
+ ``` javascript
76
+
77
+ // Tooltip
78
+
79
+ $('button').tooltip({
80
+ trigger: 'click',
81
+ placement: 'bottom'
82
+ });
83
+
84
+ function setTooltip(btn, message) {
85
+ $(btn).tooltip('hide')
86
+ .attr('data-original-title', message)
87
+ .tooltip('show');
88
+ }
89
+
90
+ function hideTooltip(btn) {
91
+ setTimeout(function() {
92
+ $(btn).tooltip('hide');
93
+ }, 1000);
94
+ }
95
+
96
+ // Clipboard
97
+
98
+ var clipboard = new Clipboard('button');
99
+
100
+ clipboard.on('success', function(e) {
101
+ setTooltip(e.trigger, 'Copied!');
102
+ hideTooltip(e.trigger);
103
+ });
104
+
105
+ clipboard.on('error', function(e) {
106
+ setTooltip(e.trigger, 'Failed!');
107
+ hideTooltip(e.trigger);
108
+ });
109
+ ```
110
+
111
+ ``` 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>
115
+ ```
116
+
117
+
118
+
70
119
  ## Development
71
120
 
72
121
  After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake false` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
@@ -1,5 +1,5 @@
1
1
  module Clipboard
2
2
  module Rails
3
- VERSION = "1.5.16"
3
+ VERSION = "1.6.0"
4
4
  end
5
5
  end
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * clipboard.js v1.5.16
2
+ * clipboard.js v1.6.0
3
3
  * https://zenorocha.github.io/clipboard.js
4
4
  *
5
5
  * Licensed MIT © Zeno Rocha
@@ -240,9 +240,19 @@ function select(element) {
240
240
  selectedText = element.value;
241
241
  }
242
242
  else if (element.nodeName === 'INPUT' || element.nodeName === 'TEXTAREA') {
243
- element.focus();
243
+ var isReadOnly = element.hasAttribute('readonly');
244
+
245
+ if (!isReadOnly) {
246
+ element.setAttribute('readonly', '');
247
+ }
248
+
249
+ element.select();
244
250
  element.setSelectionRange(0, element.value.length);
245
251
 
252
+ if (!isReadOnly) {
253
+ element.removeAttribute('readonly');
254
+ }
255
+
246
256
  selectedText = element.value;
247
257
  }
248
258
  else {
@@ -452,7 +462,6 @@ module.exports = E;
452
462
  this.fakeElem.style[isRTL ? 'right' : 'left'] = '-9999px';
453
463
  // Move element to the same position vertically
454
464
  var yPosition = window.pageYOffset || document.documentElement.scrollTop;
455
- this.fakeElem.addEventListener('focus', window.scrollTo(0, yPosition));
456
465
  this.fakeElem.style.top = yPosition + 'px';
457
466
 
458
467
  this.fakeElem.setAttribute('readonly', '');
@@ -728,6 +737,20 @@ module.exports = E;
728
737
  this.clipboardAction = null;
729
738
  }
730
739
  }
740
+ }], [{
741
+ key: 'isSupported',
742
+ value: function isSupported() {
743
+ var action = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ['copy', 'cut'];
744
+
745
+ var actions = typeof action === 'string' ? [action] : action;
746
+ var support = !!document.queryCommandSupported;
747
+
748
+ actions.forEach(function (action) {
749
+ support = support && !!document.queryCommandSupported(action);
750
+ });
751
+
752
+ return support;
753
+ }
731
754
  }]);
732
755
 
733
756
  return Clipboard;
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.16
4
+ version: 1.6.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: 2016-12-13 00:00:00.000000000 Z
11
+ date: 2017-02-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler