zeroclipboard-rails 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Zeroclipboard::Rails
2
2
 
3
- Add the [ZeroClipboard](https://github.com/jonrohan/ZeroClipboard) libary to your Rails app
3
+ Add the [ZeroClipboard](https://github.com/zeroclipboard/ZeroClipboard) libary to your Rails app
4
4
 
5
5
  ## Setup
6
6
 
@@ -24,7 +24,7 @@ Add this line to your `app/assets/javascripts/application.js` file:
24
24
 
25
25
  ## Usage
26
26
 
27
- For usage information, browser support see the [ZeroClipboard documentation](https://github.com/jonrohan/ZeroClipboard/blob/master/docs/instructions.md). The 'Setup' section can be skipped as this is covered by the Rails-specific instructions provided above.
27
+ For usage information, browser support see the [ZeroClipboard documentation](https://github.com/zeroclipboard/ZeroClipboard/blob/master/docs/instructions.md). The 'Setup' section can be skipped as this is covered by the Rails-specific instructions provided above.
28
28
 
29
29
  ## Example (HTML, ERB)
30
30
 
@@ -88,7 +88,7 @@ Place the following in a [Haml](http://haml.info/) view file:
88
88
 
89
89
  ## Version mapping
90
90
 
91
- This gem is merely a wrapper around [ZeroClipboard](https://github.com/jonrohan/ZeroClipboard). The mapping between the gem version and the version of the underlying ZeroClipboard code is as follows:
91
+ This gem is merely a wrapper around [ZeroClipboard](https://github.com/zeroclipboard/ZeroClipboard). The mapping between the gem version and the version of the underlying ZeroClipboard code is as follows:
92
92
 
93
93
  <table>
94
94
  <tr>
@@ -115,7 +115,7 @@ This gem is merely a wrapper around [ZeroClipboard](https://github.com/jonrohan/
115
115
 
116
116
  ## Credits
117
117
 
118
- Credits entirely to the team behind [ZeroClipboard](https://github.com/jonrohan/ZeroClipboard)
118
+ Credits entirely to the team behind [ZeroClipboard](https://github.com/zeroclipboard/ZeroClipboard)
119
119
 
120
120
  ## Contributing
121
121
 
@@ -1,5 +1,5 @@
1
1
  module Zeroclipboard
2
2
  module Rails
3
- VERSION = "0.0.4"
3
+ VERSION = "0.0.5"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zeroclipboard-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2013-06-11 00:00:00.000000000 Z
13
+ date: 2013-09-03 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: railties
@@ -28,7 +28,7 @@ dependencies:
28
28
  - - ! '>='
29
29
  - !ruby/object:Gem::Version
30
30
  version: '3.1'
31
- description: Adds the Javascript ZeroClipboard libary to Rails
31
+ description: ZeroClipboard libary support for Rails
32
32
  email:
33
33
  - handtrix@gmail.com
34
34
  executables: []
@@ -37,14 +37,11 @@ extra_rdoc_files: []
37
37
  files:
38
38
  - lib/zeroclipboard-rails.rb
39
39
  - lib/zeroclipboard-rails/version.rb
40
- - vendor/assets/javascripts/zeroclipboard/asset-path.js.erb
41
- - vendor/assets/javascripts/zeroclipboard/ZeroClipboard.js
42
- - vendor/assets/javascripts/zeroclipboard.js
43
- - vendor/assets/images/ZeroClipboard.swf
44
40
  - LICENSE
45
41
  - README.md
46
42
  homepage: https://github.com/HaNdTriX/zeroclipboard-rails
47
- licenses: []
43
+ licenses:
44
+ - MIT
48
45
  post_install_message:
49
46
  rdoc_options: []
50
47
  require_paths:
@@ -63,7 +60,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
63
60
  version: '0'
64
61
  requirements: []
65
62
  rubyforge_project:
66
- rubygems_version: 1.8.25
63
+ rubygems_version: 1.8.23
67
64
  signing_key:
68
65
  specification_version: 3
69
66
  summary: Adds the Javascript ZeroClipboard libary to Rails
Binary file
@@ -1,383 +0,0 @@
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
- })();
@@ -1 +0,0 @@
1
- ZeroClipboard.setDefaults( { moviePath: '<%= asset_path 'ZeroClipboard.swf' %>' } );
@@ -1,2 +0,0 @@
1
- //= require "./zeroclipboard/ZeroClipboard"
2
- //= require "./zeroclipboard/asset-path"