zeroclipboard-rails 0.0.5 → 0.0.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 ADDED
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ Yzc0M2VjMDc5M2I0ZGI1Nzk1YTI4MDhkYTVmNjI0OGM0MjM3MWIyMg==
5
+ data.tar.gz: !binary |-
6
+ YTY2OTViMDI3NGNiMjBhNjM3MGNhMmFhMTY0ZGQ3M2I1YmM2MGE0NQ==
7
+ !binary "U0hBNTEy":
8
+ metadata.gz: !binary |-
9
+ OTMzNmZmNjY4ZTc2ZTk2YzU4ZjBhZDUzNDZkY2M0MGVkOWMzZjAzYjNkZDkw
10
+ Yjg3M2IxZjc0Njk0ODVjYTJjZjk0MmUyYmU0MmZlNTYzMzYwNTczOWEwMjUy
11
+ YTIwMDZmNDkzYmI1YThmNzcyZDhiZTQyZWY1OGE3OGQ5YjRiYTI=
12
+ data.tar.gz: !binary |-
13
+ YWUzODkzODk3NGJmYWU4ZTMzNGVkYmMyYzZkMDVkOTdlMzM1YTE3MTcyMTM2
14
+ NTAxNzJlZmIzY2RlYzNhM2IyNTc3OGM5MWY0ZGFhZjFlNTllZGNmNDhjMDEz
15
+ OThmN2UwMzFhMzhlYTFiZDVjNDgwNzMxMDcyNDQyZTAxYTRiNTA=
data/README.md CHANGED
@@ -104,7 +104,21 @@ This gem is merely a wrapper around [ZeroClipboard](https://github.com/zeroclipb
104
104
  </td>
105
105
  </tr>
106
106
  <tr>
107
- <td><a href="https://rubygems.org/gems/zeroclipboard-rails/versions/0.0.3">0.0.4</a></td>
107
+ <td><a href="https://rubygems.org/gems/zeroclipboard-rails/versions/0.0.4">0.0.4</a></td>
108
+ <td><a href="https://github.com/zeroclipboard/ZeroClipboard/tree/v1.1.7">1.1.7</a></td>
109
+ <td>
110
+ Includes workaround for <a href="https://github.com/zeroclipboard/ZeroClipboard/issues/149">CSS zoom bug</a>
111
+ </td>
112
+ </tr>
113
+ <tr>
114
+ <td><a href="https://rubygems.org/gems/zeroclipboard-rails/versions/0.0.5">0.0.5</a></td>
115
+ <td><a href="https://github.com/zeroclipboard/ZeroClipboard/tree/v1.1.7">1.1.7</a></td>
116
+ <td>
117
+ Includes workaround for <a href="https://github.com/zeroclipboard/ZeroClipboard/issues/149">CSS zoom bug</a>
118
+ </td>
119
+ </tr>
120
+ <tr>
121
+ <td><a href="https://rubygems.org/gems/zeroclipboard-rails/versions/0.0.6">0.0.6</a></td>
108
122
  <td><a href="https://github.com/zeroclipboard/ZeroClipboard/tree/v1.1.7">1.1.7</a></td>
109
123
  <td>
110
124
  Includes workaround for <a href="https://github.com/zeroclipboard/ZeroClipboard/issues/149">CSS zoom bug</a>
Binary file
@@ -0,0 +1,2 @@
1
+ //= require "./zeroclipboard/ZeroClipboard"
2
+ //= require "./zeroclipboard/asset-path"
@@ -0,0 +1,383 @@
1
+ /*!
2
+ * zeroclipboard
3
+ * The Zero Clipboard library provides an easy way to copy text to the clipboard using an invisible Adobe Flash movie, and a JavaScript interface.
4
+ * Copyright 2012 Jon Rohan, James M. Greene, .
5
+ * Released under the MIT license
6
+ * http://jonrohan.github.com/ZeroClipboard/
7
+ * v1.1.7
8
+ */(function() {
9
+ "use strict";
10
+ var _getStyle = function(el, prop) {
11
+ var y = el.style[prop];
12
+ if (el.currentStyle) y = el.currentStyle[prop]; else if (window.getComputedStyle) y = document.defaultView.getComputedStyle(el, null).getPropertyValue(prop);
13
+ if (y == "auto" && prop == "cursor") {
14
+ var possiblePointers = [ "a" ];
15
+ for (var i = 0; i < possiblePointers.length; i++) {
16
+ if (el.tagName.toLowerCase() == possiblePointers[i]) {
17
+ return "pointer";
18
+ }
19
+ }
20
+ }
21
+ return y;
22
+ };
23
+ var _getZoom = function(obj) {
24
+ var zoom = 1;
25
+ if(RegExp(' AppleWebKit/').test(navigator.userAgent)){
26
+ while(obj)
27
+ {
28
+ zoom = zoom * _getStyle(obj,'zoom');
29
+ obj = obj.offsetParent;
30
+ }
31
+ }
32
+ return zoom;
33
+ };
34
+ var _elementMouseOver = function(event) {
35
+ if (!ZeroClipboard.prototype._singleton) return;
36
+ if (!event) {
37
+ event = window.event;
38
+ }
39
+ var target;
40
+ if (this !== window) {
41
+ target = this;
42
+ } else if (event.target) {
43
+ target = event.target;
44
+ } else if (event.srcElement) {
45
+ target = event.srcElement;
46
+ }
47
+ ZeroClipboard.prototype._singleton.setCurrent(target);
48
+ };
49
+ var _addEventHandler = function(element, method, func) {
50
+ if (element.addEventListener) {
51
+ element.addEventListener(method, func, false);
52
+ } else if (element.attachEvent) {
53
+ element.attachEvent("on" + method, func);
54
+ }
55
+ };
56
+ var _removeEventHandler = function(element, method, func) {
57
+ if (element.removeEventListener) {
58
+ element.removeEventListener(method, func, false);
59
+ } else if (element.detachEvent) {
60
+ element.detachEvent("on" + method, func);
61
+ }
62
+ };
63
+ var _addClass = function(element, value) {
64
+ if (element.addClass) {
65
+ element.addClass(value);
66
+ return element;
67
+ }
68
+ if (value && typeof value === "string") {
69
+ var classNames = (value || "").split(/\s+/);
70
+ if (element.nodeType === 1) {
71
+ if (!element.className) {
72
+ element.className = value;
73
+ } else {
74
+ var className = " " + element.className + " ", setClass = element.className;
75
+ for (var c = 0, cl = classNames.length; c < cl; c++) {
76
+ if (className.indexOf(" " + classNames[c] + " ") < 0) {
77
+ setClass += " " + classNames[c];
78
+ }
79
+ }
80
+ element.className = setClass.replace(/^\s+|\s+$/g, "");
81
+ }
82
+ }
83
+ }
84
+ return element;
85
+ };
86
+ var _removeClass = function(element, value) {
87
+ if (element.removeClass) {
88
+ element.removeClass(value);
89
+ return element;
90
+ }
91
+ if (value && typeof value === "string" || value === undefined) {
92
+ var classNames = (value || "").split(/\s+/);
93
+ if (element.nodeType === 1 && element.className) {
94
+ if (value) {
95
+ var className = (" " + element.className + " ").replace(/[\n\t]/g, " ");
96
+ for (var c = 0, cl = classNames.length; c < cl; c++) {
97
+ className = className.replace(" " + classNames[c] + " ", " ");
98
+ }
99
+ element.className = className.replace(/^\s+|\s+$/g, "");
100
+ } else {
101
+ element.className = "";
102
+ }
103
+ }
104
+ }
105
+ return element;
106
+ };
107
+ var _getDOMObjectPosition = function(obj) {
108
+ var info = {
109
+ left: 0,
110
+ top: 0,
111
+ width: obj.width || obj.offsetWidth || 0,
112
+ height: obj.height || obj.offsetHeight || 0,
113
+ zIndex: 9999
114
+ };
115
+ var zi = _getStyle(obj, "zIndex");
116
+ if (zi && zi != "auto") {
117
+ info.zIndex = parseInt(zi, 10);
118
+ }
119
+ if (typeof obj.getBoundingClientRect !== "undefined") {
120
+ var rect = obj.getBoundingClientRect();
121
+ var pageXOffset = window.pageXOffset || document.documentElement.scrollLeft || 0;
122
+ var pageYOffset = window.pageYOffset || document.documentElement.scrollTop || 0;
123
+ var leftBorderWidth = document.documentElement.clientLeft || 0;
124
+ var topBorderWidth = document.documentElement.clientTop || 0;
125
+ var zoom = _getZoom(obj);
126
+ info.width = rect.width * zoom;
127
+ info.height = rect.height * zoom;
128
+ info.left = (rect.left + pageXOffset - leftBorderWidth) * zoom;
129
+ info.top = (rect.top + pageYOffset - topBorderWidth) * zoom;
130
+ return info;
131
+ }
132
+ while (obj) {
133
+ var borderLeftWidth = parseInt(_getStyle(obj, "borderLeftWidth"), 10);
134
+ var borderTopWidth = parseInt(_getStyle(obj, "borderTopWidth"), 10);
135
+ info.left += isNaN(obj.offsetLeft) ? 0 : obj.offsetLeft;
136
+ info.left += isNaN(borderLeftWidth) ? 0 : borderLeftWidth;
137
+ info.top += isNaN(obj.offsetTop) ? 0 : obj.offsetTop;
138
+ info.top += isNaN(borderTopWidth) ? 0 : borderTopWidth;
139
+ obj = obj.offsetParent;
140
+ }
141
+ return info;
142
+ };
143
+ var _noCache = function(path) {
144
+ return (path.indexOf("?") >= 0 ? "&" : "?") + "nocache=" + (new Date).getTime();
145
+ };
146
+ var _vars = function(options) {
147
+ var str = [];
148
+ if (options.trustedDomains) {
149
+ if (typeof options.trustedDomains === "string") {
150
+ str.push("trustedDomain=" + options.trustedDomains);
151
+ } else {
152
+ str.push("trustedDomain=" + options.trustedDomains.join(","));
153
+ }
154
+ }
155
+ return str.join("&");
156
+ };
157
+ var _inArray = function(elem, array) {
158
+ if (array.indexOf) {
159
+ return array.indexOf(elem);
160
+ }
161
+ for (var i = 0, length = array.length; i < length; i++) {
162
+ if (array[i] === elem) {
163
+ return i;
164
+ }
165
+ }
166
+ return -1;
167
+ };
168
+ var _prepGlue = function(elements) {
169
+ if (typeof elements === "string") throw new TypeError("ZeroClipboard doesn't accept query strings.");
170
+ if (!elements.length) return [ elements ];
171
+ return elements;
172
+ };
173
+ var ZeroClipboard = function(elements, options) {
174
+ if (elements) (ZeroClipboard.prototype._singleton || this).glue(elements);
175
+ if (ZeroClipboard.prototype._singleton) return ZeroClipboard.prototype._singleton;
176
+ ZeroClipboard.prototype._singleton = this;
177
+ this.options = {};
178
+ for (var kd in _defaults) this.options[kd] = _defaults[kd];
179
+ for (var ko in options) this.options[ko] = options[ko];
180
+ this.handlers = {};
181
+ if (ZeroClipboard.detectFlashSupport()) _bridge();
182
+ };
183
+ var currentElement, gluedElements = [];
184
+ ZeroClipboard.prototype.setCurrent = function(element) {
185
+ currentElement = element;
186
+ this.reposition();
187
+ if (element.getAttribute("title")) {
188
+ this.setTitle(element.getAttribute("title"));
189
+ }
190
+ this.setHandCursor(_getStyle(element, "cursor") == "pointer");
191
+ };
192
+ ZeroClipboard.prototype.setText = function(newText) {
193
+ if (newText && newText !== "") {
194
+ this.options.text = newText;
195
+ if (this.ready()) this.flashBridge.setText(newText);
196
+ }
197
+ };
198
+ ZeroClipboard.prototype.setTitle = function(newTitle) {
199
+ if (newTitle && newTitle !== "") this.htmlBridge.setAttribute("title", newTitle);
200
+ };
201
+ ZeroClipboard.prototype.setSize = function(width, height) {
202
+ if (this.ready()) this.flashBridge.setSize(width, height);
203
+ };
204
+ ZeroClipboard.prototype.setHandCursor = function(enabled) {
205
+ if (this.ready()) this.flashBridge.setHandCursor(enabled);
206
+ };
207
+ ZeroClipboard.version = "1.1.7";
208
+ var _defaults = {
209
+ moviePath: "ZeroClipboard.swf",
210
+ trustedDomains: null,
211
+ text: null,
212
+ hoverClass: "zeroclipboard-is-hover",
213
+ activeClass: "zeroclipboard-is-active",
214
+ allowScriptAccess: "sameDomain"
215
+ };
216
+ ZeroClipboard.setDefaults = function(options) {
217
+ for (var ko in options) _defaults[ko] = options[ko];
218
+ };
219
+ ZeroClipboard.destroy = function() {
220
+ ZeroClipboard.prototype._singleton.unglue(gluedElements);
221
+ var bridge = ZeroClipboard.prototype._singleton.htmlBridge;
222
+ bridge.parentNode.removeChild(bridge);
223
+ delete ZeroClipboard.prototype._singleton;
224
+ };
225
+ ZeroClipboard.detectFlashSupport = function() {
226
+ var hasFlash = false;
227
+ try {
228
+ if (new ActiveXObject("ShockwaveFlash.ShockwaveFlash")) {
229
+ hasFlash = true;
230
+ }
231
+ } catch (error) {
232
+ if (navigator.mimeTypes["application/x-shockwave-flash"]) {
233
+ hasFlash = true;
234
+ }
235
+ }
236
+ return hasFlash;
237
+ };
238
+ var _bridge = function() {
239
+ var client = ZeroClipboard.prototype._singleton;
240
+ var container = document.getElementById("global-zeroclipboard-html-bridge");
241
+ if (!container) {
242
+ var html = ' <object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" id="global-zeroclipboard-flash-bridge" width="100%" height="100%"> <param name="movie" value="' + client.options.moviePath + _noCache(client.options.moviePath) + '"/> <param name="allowScriptAccess" value="' + client.options.allowScriptAccess + '"/> <param name="scale" value="exactfit"/> <param name="loop" value="false"/> <param name="menu" value="false"/> <param name="quality" value="best" /> <param name="bgcolor" value="#ffffff"/> <param name="wmode" value="transparent"/> <param name="flashvars" value="' + _vars(client.options) + '"/> <embed src="' + client.options.moviePath + _noCache(client.options.moviePath) + '" loop="false" menu="false" quality="best" bgcolor="#ffffff" width="100%" height="100%" name="global-zeroclipboard-flash-bridge" allowScriptAccess="always" allowFullScreen="false" type="application/x-shockwave-flash" wmode="transparent" pluginspage="http://www.macromedia.com/go/getflashplayer" flashvars="' + _vars(client.options) + '" scale="exactfit"> </embed> </object>';
243
+ container = document.createElement("div");
244
+ container.id = "global-zeroclipboard-html-bridge";
245
+ container.setAttribute("class", "global-zeroclipboard-container");
246
+ container.setAttribute("data-clipboard-ready", false);
247
+ container.style.position = "absolute";
248
+ container.style.left = "-9999px";
249
+ container.style.top = "-9999px";
250
+ container.style.width = "15px";
251
+ container.style.height = "15px";
252
+ container.style.zIndex = "9999";
253
+ container.innerHTML = html;
254
+ document.body.appendChild(container);
255
+ }
256
+ client.htmlBridge = container;
257
+ client.flashBridge = document["global-zeroclipboard-flash-bridge"] || container.children[0].lastElementChild;
258
+ };
259
+ ZeroClipboard.prototype.resetBridge = function() {
260
+ this.htmlBridge.style.left = "-9999px";
261
+ this.htmlBridge.style.top = "-9999px";
262
+ this.htmlBridge.removeAttribute("title");
263
+ this.htmlBridge.removeAttribute("data-clipboard-text");
264
+ _removeClass(currentElement, this.options.activeClass);
265
+ currentElement = null;
266
+ this.options.text = null;
267
+ };
268
+ ZeroClipboard.prototype.ready = function() {
269
+ var ready = this.htmlBridge.getAttribute("data-clipboard-ready");
270
+ return ready === "true" || ready === true;
271
+ };
272
+ ZeroClipboard.prototype.reposition = function() {
273
+ if (!currentElement) return false;
274
+ var pos = _getDOMObjectPosition(currentElement);
275
+ this.htmlBridge.style.top = pos.top + "px";
276
+ this.htmlBridge.style.left = pos.left + "px";
277
+ this.htmlBridge.style.width = pos.width + "px";
278
+ this.htmlBridge.style.height = pos.height + "px";
279
+ this.htmlBridge.style.zIndex = pos.zIndex + 1;
280
+ this.setSize(pos.width, pos.height);
281
+ };
282
+ ZeroClipboard.dispatch = function(eventName, args) {
283
+ ZeroClipboard.prototype._singleton.receiveEvent(eventName, args);
284
+ };
285
+ ZeroClipboard.prototype.on = function(eventName, func) {
286
+ var events = eventName.toString().split(/\s/g);
287
+ for (var i = 0; i < events.length; i++) {
288
+ eventName = events[i].toLowerCase().replace(/^on/, "");
289
+ if (!this.handlers[eventName]) this.handlers[eventName] = func;
290
+ }
291
+ if (this.handlers.noflash && !ZeroClipboard.detectFlashSupport()) {
292
+ this.receiveEvent("onNoFlash", null);
293
+ }
294
+ };
295
+ ZeroClipboard.prototype.addEventListener = ZeroClipboard.prototype.on;
296
+ ZeroClipboard.prototype.off = function(eventName, func) {
297
+ var events = eventName.toString().split(/\s/g);
298
+ for (var i = 0; i < events.length; i++) {
299
+ eventName = events[i].toLowerCase().replace(/^on/, "");
300
+ for (var event in this.handlers) {
301
+ if (event === eventName && this.handlers[event] === func) {
302
+ delete this.handlers[event];
303
+ }
304
+ }
305
+ }
306
+ };
307
+ ZeroClipboard.prototype.removeEventListener = ZeroClipboard.prototype.off;
308
+ ZeroClipboard.prototype.receiveEvent = function(eventName, args) {
309
+ eventName = eventName.toString().toLowerCase().replace(/^on/, "");
310
+ var element = currentElement;
311
+ switch (eventName) {
312
+ case "load":
313
+ if (args && parseFloat(args.flashVersion.replace(",", ".").replace(/[^0-9\.]/gi, "")) < 10) {
314
+ this.receiveEvent("onWrongFlash", {
315
+ flashVersion: args.flashVersion
316
+ });
317
+ return;
318
+ }
319
+ this.htmlBridge.setAttribute("data-clipboard-ready", true);
320
+ break;
321
+ case "mouseover":
322
+ _addClass(element, this.options.hoverClass);
323
+ break;
324
+ case "mouseout":
325
+ _removeClass(element, this.options.hoverClass);
326
+ this.resetBridge();
327
+ break;
328
+ case "mousedown":
329
+ _addClass(element, this.options.activeClass);
330
+ break;
331
+ case "mouseup":
332
+ _removeClass(element, this.options.activeClass);
333
+ break;
334
+ case "datarequested":
335
+ var targetId = element.getAttribute("data-clipboard-target"), targetEl = !targetId ? null : document.getElementById(targetId);
336
+ if (targetEl) {
337
+ var textContent = targetEl.value || targetEl.textContent || targetEl.innerText;
338
+ if (textContent) this.setText(textContent);
339
+ } else {
340
+ var defaultText = element.getAttribute("data-clipboard-text");
341
+ if (defaultText) this.setText(defaultText);
342
+ }
343
+ break;
344
+ case "complete":
345
+ this.options.text = null;
346
+ break;
347
+ }
348
+ if (this.handlers[eventName]) {
349
+ var func = this.handlers[eventName];
350
+ if (typeof func == "function") {
351
+ func.call(element, this, args);
352
+ } else if (typeof func == "string") {
353
+ window[func].call(element, this, args);
354
+ }
355
+ }
356
+ };
357
+ ZeroClipboard.prototype.glue = function(elements) {
358
+ elements = _prepGlue(elements);
359
+ for (var i = 0; i < elements.length; i++) {
360
+ if (_inArray(elements[i], gluedElements) == -1) {
361
+ gluedElements.push(elements[i]);
362
+ _addEventHandler(elements[i], "mouseover", _elementMouseOver);
363
+ }
364
+ }
365
+ };
366
+ ZeroClipboard.prototype.unglue = function(elements) {
367
+ elements = _prepGlue(elements);
368
+ for (var i = 0; i < elements.length; i++) {
369
+ _removeEventHandler(elements[i], "mouseover", _elementMouseOver);
370
+ var arrayIndex = _inArray(elements[i], gluedElements);
371
+ if (arrayIndex != -1) gluedElements.splice(arrayIndex, 1);
372
+ }
373
+ };
374
+ if (typeof module !== "undefined") {
375
+ module.exports = ZeroClipboard;
376
+ } else if (typeof define === "function" && define.amd) {
377
+ define(function() {
378
+ return ZeroClipboard;
379
+ });
380
+ } else {
381
+ window.ZeroClipboard = ZeroClipboard;
382
+ }
383
+ })();
@@ -0,0 +1 @@
1
+ ZeroClipboard.setDefaults( { moviePath: '<%= asset_path 'ZeroClipboard.swf' %>' } );
@@ -1,5 +1,5 @@
1
1
  module Zeroclipboard
2
2
  module Rails
3
- VERSION = "0.0.5"
3
+ VERSION = "0.0.6"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,8 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zeroclipboard-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
5
- prerelease:
4
+ version: 0.0.6
6
5
  platform: ruby
7
6
  authors:
8
7
  - Henrik Wenz
@@ -15,7 +14,6 @@ dependencies:
15
14
  - !ruby/object:Gem::Dependency
16
15
  name: railties
17
16
  requirement: !ruby/object:Gem::Requirement
18
- none: false
19
17
  requirements:
20
18
  - - ! '>='
21
19
  - !ruby/object:Gem::Version
@@ -23,7 +21,6 @@ dependencies:
23
21
  type: :runtime
24
22
  prerelease: false
25
23
  version_requirements: !ruby/object:Gem::Requirement
26
- none: false
27
24
  requirements:
28
25
  - - ! '>='
29
26
  - !ruby/object:Gem::Version
@@ -37,31 +34,34 @@ extra_rdoc_files: []
37
34
  files:
38
35
  - lib/zeroclipboard-rails.rb
39
36
  - lib/zeroclipboard-rails/version.rb
37
+ - app/assets/javascripts/zeroclipboard/asset-path.js.erb
38
+ - app/assets/javascripts/zeroclipboard/ZeroClipboard.js
39
+ - app/assets/javascripts/zeroclipboard.js
40
+ - app/assets/images/ZeroClipboard.swf
40
41
  - LICENSE
41
42
  - README.md
42
43
  homepage: https://github.com/HaNdTriX/zeroclipboard-rails
43
44
  licenses:
44
45
  - MIT
46
+ metadata: {}
45
47
  post_install_message:
46
48
  rdoc_options: []
47
49
  require_paths:
48
50
  - lib
49
51
  required_ruby_version: !ruby/object:Gem::Requirement
50
- none: false
51
52
  requirements:
52
53
  - - ! '>='
53
54
  - !ruby/object:Gem::Version
54
55
  version: '0'
55
56
  required_rubygems_version: !ruby/object:Gem::Requirement
56
- none: false
57
57
  requirements:
58
58
  - - ! '>='
59
59
  - !ruby/object:Gem::Version
60
60
  version: '0'
61
61
  requirements: []
62
62
  rubyforge_project:
63
- rubygems_version: 1.8.23
63
+ rubygems_version: 2.0.7
64
64
  signing_key:
65
- specification_version: 3
65
+ specification_version: 4
66
66
  summary: Adds the Javascript ZeroClipboard libary to Rails
67
67
  test_files: []