zclip-rails 0.0.1 → 0.0.2
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 +15 -0
- data/README.md +5 -0
- data/lib/zclip-rails/version.rb +1 -1
- data/vendor/assets/images/ZeroClipboard.swf +0 -0
- data/vendor/assets/javascripts/zclip/jquery.zclip.js.erb +13 -12
- data/vendor/assets/javascripts/zero-clipboard/zero-clipboard.js +341 -312
- metadata +6 -12
- data/vendor/assets/images/ZeroClipboard10.swf +0 -0
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
ZjVjNTlhMzYyODI4NzQwYjExOGY2NzZkMzIwNzdlNDhhYzNmZTEyYg==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
YWE5YmMzNGU1YzJmNmUxMTdjYWYxZWI1ODMwMzgxZmE4MTdlZDc4NQ==
|
7
|
+
!binary "U0hBNTEy":
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
ZGZjMWZkNjk2NTExYjViOGE4ZDIxMjk2YTViMTIwNmZlN2I5YmM2OTUyMmZi
|
10
|
+
ZTE4YmY3ZjRiNjczNDkxYjQyNGFjM2E4Y2ZmMzJmMjJmYzUxMzc2N2VhOTBl
|
11
|
+
YmYyZTQ3YjM2MDIwOWNjY2NhZTE3MWYwMzQxODhiZDc1ZmJmNjI=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
ODE5MTc5NzlmMTJmZmZlZDExYmRiYzc1MjE3MjdjZmZjZmNkZjliYzhiYjFl
|
14
|
+
ODAyNzhiYmY4OTNjYWYzNDU0OGRkYjU1MWZjMjQ0OWE5NjA4Yjk0MDg5ZmZl
|
15
|
+
MTcwMDc5YmY4ZDljMmNjODg1NGI5NzdkZmFjYzUxMTE1NmQ3Njk=
|
data/README.md
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
# :warning: Author Warning :warning:
|
2
|
+
|
3
|
+
I added this wrapper to give access to the zclip Jquery plugin. Nevertheless I can not recommend Zclip on complex projects.
|
4
|
+
A better solution is to use the [zeroclipboard-rails](https://github.com/HaNdTriX/zeroclipboard-rails) gem in addition with this [script](https://github.com/HaNdTriX/zeroclipboard-rails/wiki/zeroclipboard-rails---jQuery-Examples).
|
5
|
+
|
1
6
|
# Zclip::Rails
|
2
7
|
|
3
8
|
Adds easy copytoclipboard functionality to your html-elements this is done by including the Jquery zClip libary to Rails 3.x.
|
data/lib/zclip-rails/version.rb
CHANGED
Binary file
|
@@ -22,13 +22,14 @@
|
|
22
22
|
|
23
23
|
var settings = $.extend({
|
24
24
|
|
25
|
-
path: '<%= asset_path '
|
25
|
+
path: '<%= asset_path 'ZeroClipboard.swf' %>',
|
26
26
|
copy: null,
|
27
27
|
beforeCopy: null,
|
28
28
|
afterCopy: null,
|
29
29
|
clickAfter: true,
|
30
30
|
setHandCursor: true,
|
31
|
-
|
31
|
+
mouseOver: null,
|
32
|
+
mouseOut: null,
|
32
33
|
|
33
34
|
}, params);
|
34
35
|
|
@@ -38,9 +39,8 @@
|
|
38
39
|
var o = $(this);
|
39
40
|
|
40
41
|
if (o.is(':visible') && (typeof settings.copy == 'string' || $.isFunction(settings.copy))) {
|
42
|
+
var clip = new ZeroClipboard( o, { moviePath: settings.path });
|
41
43
|
|
42
|
-
ZeroClipboard.setMoviePath(settings.path);
|
43
|
-
var clip = new ZeroClipboard.Client();
|
44
44
|
|
45
45
|
if($.isFunction(settings.copy)){
|
46
46
|
o.bind('zClip_copy',settings.copy);
|
@@ -53,13 +53,14 @@
|
|
53
53
|
}
|
54
54
|
|
55
55
|
clip.setHandCursor(settings.setHandCursor);
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
}
|
60
|
-
|
61
|
-
|
62
|
-
}
|
56
|
+
|
57
|
+
if($.isFunction(settings.mouseOver)){
|
58
|
+
clip.on('mouseover', settings.mouseOver);
|
59
|
+
}
|
60
|
+
if($.isFunction(settings.mouseOut)){
|
61
|
+
clip.on('mouseout', settings.mouseOut);
|
62
|
+
}
|
63
|
+
|
63
64
|
clip.addEventListener('mouseDown', function (client) {
|
64
65
|
|
65
66
|
o.trigger('mousedown');
|
@@ -99,7 +100,7 @@
|
|
99
100
|
|
100
101
|
clip.glue(o[0], o.parent()[0]);
|
101
102
|
|
102
|
-
|
103
|
+
$(window).bind('load resize',function(){clip.reposition();});
|
103
104
|
|
104
105
|
|
105
106
|
}
|
@@ -1,337 +1,366 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
if (
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
thingy.addClass = function(name) { this.removeClass(name); this.className += ' ' + name; };
|
19
|
-
thingy.removeClass = function(name) {
|
20
|
-
var classes = this.className.split(/\s+/);
|
21
|
-
var idx = -1;
|
22
|
-
for (var k = 0; k < classes.length; k++) {
|
23
|
-
if (classes[k] == name) { idx = k; k = classes.length; }
|
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";
|
24
18
|
}
|
25
|
-
|
26
|
-
|
27
|
-
|
19
|
+
}
|
20
|
+
}
|
21
|
+
return y;
|
22
|
+
};
|
23
|
+
var _elementMouseOver = function(event) {
|
24
|
+
if (!ZeroClipboard.prototype._singleton) return;
|
25
|
+
if (!event) {
|
26
|
+
event = window.event;
|
27
|
+
}
|
28
|
+
var target;
|
29
|
+
if (this !== window) {
|
30
|
+
target = this;
|
31
|
+
} else if (event.target) {
|
32
|
+
target = event.target;
|
33
|
+
} else if (event.srcElement) {
|
34
|
+
target = event.srcElement;
|
35
|
+
}
|
36
|
+
ZeroClipboard.prototype._singleton.setCurrent(target);
|
37
|
+
};
|
38
|
+
var _addEventHandler = function(element, method, func) {
|
39
|
+
if (element.addEventListener) {
|
40
|
+
element.addEventListener(method, func, false);
|
41
|
+
} else if (element.attachEvent) {
|
42
|
+
element.attachEvent("on" + method, func);
|
43
|
+
}
|
44
|
+
};
|
45
|
+
var _removeEventHandler = function(element, method, func) {
|
46
|
+
if (element.removeEventListener) {
|
47
|
+
element.removeEventListener(method, func, false);
|
48
|
+
} else if (element.detachEvent) {
|
49
|
+
element.detachEvent("on" + method, func);
|
50
|
+
}
|
51
|
+
};
|
52
|
+
var _addClass = function(element, value) {
|
53
|
+
if (element.addClass) {
|
54
|
+
element.addClass(value);
|
55
|
+
return element;
|
56
|
+
}
|
57
|
+
if (value && typeof value === "string") {
|
58
|
+
var classNames = (value || "").split(/\s+/);
|
59
|
+
if (element.nodeType === 1) {
|
60
|
+
if (!element.className) {
|
61
|
+
element.className = value;
|
62
|
+
} else {
|
63
|
+
var className = " " + element.className + " ", setClass = element.className;
|
64
|
+
for (var c = 0, cl = classNames.length; c < cl; c++) {
|
65
|
+
if (className.indexOf(" " + classNames[c] + " ") < 0) {
|
66
|
+
setClass += " " + classNames[c];
|
67
|
+
}
|
68
|
+
}
|
69
|
+
element.className = setClass.replace(/^\s+|\s+$/g, "");
|
28
70
|
}
|
29
|
-
|
30
|
-
};
|
31
|
-
thingy.hasClass = function(name) {
|
32
|
-
return !!this.className.match( new RegExp("\\s*" + name + "\\s*") );
|
33
|
-
};
|
71
|
+
}
|
34
72
|
}
|
35
|
-
return
|
36
|
-
}
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
73
|
+
return element;
|
74
|
+
};
|
75
|
+
var _removeClass = function(element, value) {
|
76
|
+
if (element.removeClass) {
|
77
|
+
element.removeClass(value);
|
78
|
+
return element;
|
79
|
+
}
|
80
|
+
if (value && typeof value === "string" || value === undefined) {
|
81
|
+
var classNames = (value || "").split(/\s+/);
|
82
|
+
if (element.nodeType === 1 && element.className) {
|
83
|
+
if (value) {
|
84
|
+
var className = (" " + element.className + " ").replace(/[\n\t]/g, " ");
|
85
|
+
for (var c = 0, cl = classNames.length; c < cl; c++) {
|
86
|
+
className = className.replace(" " + classNames[c] + " ", " ");
|
87
|
+
}
|
88
|
+
element.className = className.replace(/^\s+|\s+$/g, "");
|
89
|
+
} else {
|
90
|
+
element.className = "";
|
91
|
+
}
|
92
|
+
}
|
53
93
|
}
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
// register new client to receive events
|
58
|
-
this.clients[id] = client;
|
59
|
-
},
|
60
|
-
|
61
|
-
getDOMObjectPosition: function(obj, stopObj) {
|
62
|
-
// get absolute coordinates for dom element
|
94
|
+
return element;
|
95
|
+
};
|
96
|
+
var _getDOMObjectPosition = function(obj) {
|
63
97
|
var info = {
|
64
98
|
left: 0,
|
65
99
|
top: 0,
|
66
|
-
width: obj.width
|
67
|
-
height: obj.height
|
100
|
+
width: obj.width || obj.offsetWidth || 0,
|
101
|
+
height: obj.height || obj.offsetHeight || 0,
|
102
|
+
zIndex: 9999
|
68
103
|
};
|
69
|
-
|
70
|
-
|
71
|
-
info.
|
72
|
-
|
73
|
-
|
74
|
-
|
104
|
+
var zi = _getStyle(obj, "zIndex");
|
105
|
+
if (zi && zi != "auto") {
|
106
|
+
info.zIndex = parseInt(zi, 10);
|
107
|
+
}
|
108
|
+
while (obj) {
|
109
|
+
var borderLeftWidth = parseInt(_getStyle(obj, "borderLeftWidth"), 10);
|
110
|
+
var borderTopWidth = parseInt(_getStyle(obj, "borderTopWidth"), 10);
|
111
|
+
info.left += isNaN(obj.offsetLeft) ? 0 : obj.offsetLeft;
|
112
|
+
info.left += isNaN(borderLeftWidth) ? 0 : borderLeftWidth;
|
113
|
+
info.top += isNaN(obj.offsetTop) ? 0 : obj.offsetTop;
|
114
|
+
info.top += isNaN(borderTopWidth) ? 0 : borderTopWidth;
|
75
115
|
obj = obj.offsetParent;
|
76
116
|
}
|
77
|
-
|
78
117
|
return info;
|
79
|
-
}
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
this.id = ZeroClipboard.nextId++;
|
87
|
-
this.movieId = 'ZeroClipboardMovie_' + this.id;
|
88
|
-
|
89
|
-
// register client with singleton to receive flash events
|
90
|
-
ZeroClipboard.register(this.id, this);
|
91
|
-
|
92
|
-
// create movie
|
93
|
-
if (elem) this.glue(elem);
|
94
|
-
}
|
95
|
-
};
|
96
|
-
|
97
|
-
ZeroClipboard.Client.prototype = {
|
98
|
-
|
99
|
-
id: 0, // unique ID for us
|
100
|
-
title: "", // tooltip for the flash element
|
101
|
-
ready: false, // whether movie is ready to receive events or not
|
102
|
-
movie: null, // reference to movie object
|
103
|
-
clipText: '', // text to copy to clipboard
|
104
|
-
handCursorEnabled: true, // whether to show hand cursor, or default pointer cursor
|
105
|
-
cssEffects: true, // enable CSS mouse effects on dom container
|
106
|
-
handlers: null, // user event handlers
|
107
|
-
zIndex: 99, // default zIndex of the movie object
|
108
|
-
|
109
|
-
glue: function(elem, appendElem, stylesToAdd) {
|
110
|
-
// glue to DOM element
|
111
|
-
// elem can be ID or actual DOM element object
|
112
|
-
this.domElement = ZeroClipboard.$(elem);
|
113
|
-
|
114
|
-
// float just above object, or default zIndex if dom element isn't set
|
115
|
-
if (this.domElement.style.zIndex) {
|
116
|
-
this.zIndex = parseInt(this.domElement.style.zIndex, 10) + 1;
|
117
|
-
}
|
118
|
-
|
119
|
-
// check if the element has a title
|
120
|
-
if (this.domElement.getAttribute("title") != null) {
|
121
|
-
this.title = this.domElement.getAttribute("title");
|
118
|
+
};
|
119
|
+
var _noCache = function(path) {
|
120
|
+
var client = ZeroClipboard.prototype._singleton;
|
121
|
+
if (client.options.useNoCache) {
|
122
|
+
return (path.indexOf("?") >= 0 ? "&nocache=" : "?nocache=") + (new Date).getTime();
|
123
|
+
} else {
|
124
|
+
return "";
|
122
125
|
}
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
+
};
|
127
|
+
var _vars = function(options) {
|
128
|
+
var str = [];
|
129
|
+
if (options.trustedDomains) {
|
130
|
+
if (typeof options.trustedDomains === "string") {
|
131
|
+
str.push("trustedDomain=" + options.trustedDomains);
|
132
|
+
} else {
|
133
|
+
str.push("trustedDomain=" + options.trustedDomains.join(","));
|
134
|
+
}
|
126
135
|
}
|
127
|
-
|
128
|
-
|
136
|
+
return str.join("&");
|
137
|
+
};
|
138
|
+
var _inArray = function(elem, array) {
|
139
|
+
if (array.indexOf) {
|
140
|
+
return array.indexOf(elem);
|
129
141
|
}
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
// create floating DIV above element
|
135
|
-
this.div = document.createElement('div');
|
136
|
-
var style = this.div.style;
|
137
|
-
style.position = 'absolute';
|
138
|
-
style.left = '' + box.left + 'px';
|
139
|
-
style.top = '' + box.top + 'px';
|
140
|
-
style.width = '' + box.width + 'px';
|
141
|
-
style.height = '' + box.height + 'px';
|
142
|
-
style.zIndex = this.zIndex;
|
143
|
-
|
144
|
-
if (typeof(stylesToAdd) == 'object') {
|
145
|
-
for (var addedStyle in stylesToAdd) {
|
146
|
-
style[addedStyle] = stylesToAdd[addedStyle];
|
142
|
+
for (var i = 0, length = array.length; i < length; i++) {
|
143
|
+
if (array[i] === elem) {
|
144
|
+
return i;
|
147
145
|
}
|
148
146
|
}
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
}
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
147
|
+
return -1;
|
148
|
+
};
|
149
|
+
var _prepGlue = function(elements) {
|
150
|
+
if (typeof elements === "string") throw new TypeError("ZeroClipboard doesn't accept query strings.");
|
151
|
+
if (!elements.length) return [ elements ];
|
152
|
+
return elements;
|
153
|
+
};
|
154
|
+
var ZeroClipboard = function(elements, options) {
|
155
|
+
if (elements) (ZeroClipboard.prototype._singleton || this).glue(elements);
|
156
|
+
if (ZeroClipboard.prototype._singleton) return ZeroClipboard.prototype._singleton;
|
157
|
+
ZeroClipboard.prototype._singleton = this;
|
158
|
+
this.options = {};
|
159
|
+
for (var kd in _defaults) this.options[kd] = _defaults[kd];
|
160
|
+
for (var ko in options) this.options[ko] = options[ko];
|
161
|
+
this.handlers = {};
|
162
|
+
if (ZeroClipboard.detectFlashSupport()) _bridge();
|
163
|
+
};
|
164
|
+
var currentElement, gluedElements = [];
|
165
|
+
ZeroClipboard.prototype.setCurrent = function(element) {
|
166
|
+
currentElement = element;
|
167
|
+
this.reposition();
|
168
|
+
if (element.getAttribute("title")) {
|
169
|
+
this.setTitle(element.getAttribute("title"));
|
169
170
|
}
|
170
|
-
|
171
|
-
|
172
|
-
|
171
|
+
this.setHandCursor(_getStyle(element, "cursor") == "pointer");
|
172
|
+
};
|
173
|
+
ZeroClipboard.prototype.setText = function(newText) {
|
174
|
+
if (newText && newText !== "") {
|
175
|
+
this.options.text = newText;
|
176
|
+
if (this.ready()) this.flashBridge.setText(newText);
|
173
177
|
}
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
if (this.
|
180
|
-
|
178
|
+
};
|
179
|
+
ZeroClipboard.prototype.setTitle = function(newTitle) {
|
180
|
+
if (newTitle && newTitle !== "") this.htmlBridge.setAttribute("title", newTitle);
|
181
|
+
};
|
182
|
+
ZeroClipboard.prototype.setSize = function(width, height) {
|
183
|
+
if (this.ready()) this.flashBridge.setSize(width, height);
|
184
|
+
};
|
185
|
+
ZeroClipboard.prototype.setHandCursor = function(enabled) {
|
186
|
+
if (this.ready()) this.flashBridge.setHandCursor(enabled);
|
187
|
+
};
|
188
|
+
ZeroClipboard.version = "1.1.7";
|
189
|
+
var _defaults = {
|
190
|
+
moviePath: "ZeroClipboard.swf",
|
191
|
+
trustedDomains: null,
|
192
|
+
text: null,
|
193
|
+
hoverClass: "zeroclipboard-is-hover",
|
194
|
+
activeClass: "zeroclipboard-is-active",
|
195
|
+
allowScriptAccess: "sameDomain",
|
196
|
+
useNoCache: true
|
197
|
+
};
|
198
|
+
ZeroClipboard.setDefaults = function(options) {
|
199
|
+
for (var ko in options) _defaults[ko] = options[ko];
|
200
|
+
};
|
201
|
+
ZeroClipboard.destroy = function() {
|
202
|
+
ZeroClipboard.prototype._singleton.unglue(gluedElements);
|
203
|
+
var bridge = ZeroClipboard.prototype._singleton.htmlBridge;
|
204
|
+
bridge.parentNode.removeChild(bridge);
|
205
|
+
delete ZeroClipboard.prototype._singleton;
|
206
|
+
};
|
207
|
+
ZeroClipboard.detectFlashSupport = function() {
|
208
|
+
var hasFlash = false;
|
209
|
+
if (typeof ActiveXObject === "function") {
|
210
|
+
try {
|
211
|
+
if (new ActiveXObject("ShockwaveFlash.ShockwaveFlash")) {
|
212
|
+
hasFlash = true;
|
213
|
+
}
|
214
|
+
} catch (error) {}
|
181
215
|
}
|
182
|
-
|
183
|
-
|
184
|
-
show: function() {
|
185
|
-
// show ourselves after a call to hide()
|
186
|
-
this.reposition();
|
187
|
-
},
|
188
|
-
|
189
|
-
destroy: function() {
|
190
|
-
// destroy control and floater
|
191
|
-
if (this.domElement && this.div) {
|
192
|
-
this.hide();
|
193
|
-
this.div.innerHTML = '';
|
194
|
-
|
195
|
-
var body = document.getElementsByTagName('body')[0];
|
196
|
-
try { body.removeChild( this.div ); } catch(e) {}
|
197
|
-
|
198
|
-
this.domElement = null;
|
199
|
-
this.div = null;
|
216
|
+
if (!hasFlash && navigator.mimeTypes["application/x-shockwave-flash"]) {
|
217
|
+
hasFlash = true;
|
200
218
|
}
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
if (
|
207
|
-
|
208
|
-
|
219
|
+
return hasFlash;
|
220
|
+
};
|
221
|
+
var _bridge = function() {
|
222
|
+
var client = ZeroClipboard.prototype._singleton;
|
223
|
+
var container = document.getElementById("global-zeroclipboard-html-bridge");
|
224
|
+
if (!container) {
|
225
|
+
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>';
|
226
|
+
container = document.createElement("div");
|
227
|
+
container.id = "global-zeroclipboard-html-bridge";
|
228
|
+
container.setAttribute("class", "global-zeroclipboard-container");
|
229
|
+
container.setAttribute("data-clipboard-ready", false);
|
230
|
+
container.style.position = "absolute";
|
231
|
+
container.style.left = "-9999px";
|
232
|
+
container.style.top = "-9999px";
|
233
|
+
container.style.width = "15px";
|
234
|
+
container.style.height = "15px";
|
235
|
+
container.style.zIndex = "9999";
|
236
|
+
container.innerHTML = html;
|
237
|
+
document.body.appendChild(container);
|
209
238
|
}
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
239
|
+
client.htmlBridge = container;
|
240
|
+
client.flashBridge = document["global-zeroclipboard-flash-bridge"] || container.children[0].lastElementChild;
|
241
|
+
};
|
242
|
+
ZeroClipboard.prototype.resetBridge = function() {
|
243
|
+
this.htmlBridge.style.left = "-9999px";
|
244
|
+
this.htmlBridge.style.top = "-9999px";
|
245
|
+
this.htmlBridge.removeAttribute("title");
|
246
|
+
this.htmlBridge.removeAttribute("data-clipboard-text");
|
247
|
+
_removeClass(currentElement, this.options.activeClass);
|
248
|
+
currentElement = null;
|
249
|
+
this.options.text = null;
|
250
|
+
};
|
251
|
+
ZeroClipboard.prototype.ready = function() {
|
252
|
+
var ready = this.htmlBridge.getAttribute("data-clipboard-ready");
|
253
|
+
return ready === "true" || ready === true;
|
254
|
+
};
|
255
|
+
ZeroClipboard.prototype.reposition = function() {
|
256
|
+
if (!currentElement) return false;
|
257
|
+
var pos = _getDOMObjectPosition(currentElement);
|
258
|
+
this.htmlBridge.style.top = pos.top + "px";
|
259
|
+
this.htmlBridge.style.left = pos.left + "px";
|
260
|
+
this.htmlBridge.style.width = pos.width + "px";
|
261
|
+
this.htmlBridge.style.height = pos.height + "px";
|
262
|
+
this.htmlBridge.style.zIndex = pos.zIndex + 1;
|
263
|
+
this.setSize(pos.width, pos.height);
|
264
|
+
};
|
265
|
+
ZeroClipboard.dispatch = function(eventName, args) {
|
266
|
+
ZeroClipboard.prototype._singleton.receiveEvent(eventName, args);
|
267
|
+
};
|
268
|
+
ZeroClipboard.prototype.on = function(eventName, func) {
|
269
|
+
var events = eventName.toString().split(/\s/g);
|
270
|
+
for (var i = 0; i < events.length; i++) {
|
271
|
+
eventName = events[i].toLowerCase().replace(/^on/, "");
|
272
|
+
if (!this.handlers[eventName]) this.handlers[eventName] = func;
|
216
273
|
}
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
},
|
230
|
-
|
231
|
-
addEventListener: function(eventName, func) {
|
232
|
-
// add user event listener for event
|
233
|
-
// event types: load, queueStart, fileStart, fileComplete, queueComplete, progress, error, cancel
|
234
|
-
eventName = eventName.toString().toLowerCase().replace(/^on/, '');
|
235
|
-
if (!this.handlers[eventName]) this.handlers[eventName] = [];
|
236
|
-
this.handlers[eventName].push(func);
|
237
|
-
},
|
238
|
-
|
239
|
-
setHandCursor: function(enabled) {
|
240
|
-
// enable hand cursor (true), or default arrow cursor (false)
|
241
|
-
this.handCursorEnabled = enabled;
|
242
|
-
if (this.ready) this.movie.setHandCursor(enabled);
|
243
|
-
},
|
244
|
-
|
245
|
-
setCSSEffects: function(enabled) {
|
246
|
-
// enable or disable CSS effects on DOM container
|
247
|
-
this.cssEffects = !!enabled;
|
248
|
-
},
|
249
|
-
|
250
|
-
receiveEvent: function(eventName, args) {
|
251
|
-
// receive event from flash
|
252
|
-
eventName = eventName.toString().toLowerCase().replace(/^on/, '');
|
253
|
-
|
254
|
-
// special behavior for certain events
|
255
|
-
switch (eventName) {
|
256
|
-
case 'load':
|
257
|
-
// movie claims it is ready, but in IE this isn't always the case...
|
258
|
-
// bug fix: Cannot extend EMBED DOM elements in Firefox, must use traditional function
|
259
|
-
this.movie = document.getElementById(this.movieId);
|
260
|
-
if (!this.movie) {
|
261
|
-
var self = this;
|
262
|
-
setTimeout( function() { self.receiveEvent('load', null); }, 1 );
|
263
|
-
return;
|
264
|
-
}
|
265
|
-
|
266
|
-
// firefox on pc needs a "kick" in order to set these in certain cases
|
267
|
-
if (!this.ready && navigator.userAgent.match(/Firefox/) && navigator.userAgent.match(/Windows/)) {
|
268
|
-
var self = this;
|
269
|
-
setTimeout( function() { self.receiveEvent('load', null); }, 100 );
|
270
|
-
this.ready = true;
|
271
|
-
return;
|
272
|
-
}
|
273
|
-
|
274
|
-
this.ready = true;
|
275
|
-
this.movie.setText( this.clipText );
|
276
|
-
this.movie.setTitle( this.title );
|
277
|
-
this.movie.setHandCursor( this.handCursorEnabled );
|
278
|
-
break;
|
279
|
-
|
280
|
-
case 'mouseover':
|
281
|
-
if (this.domElement && this.cssEffects) {
|
282
|
-
this.domElement.addClass('hover');
|
283
|
-
if (this.recoverActive) this.domElement.addClass('active');
|
284
|
-
}
|
285
|
-
break;
|
286
|
-
|
287
|
-
case 'mouseout':
|
288
|
-
if (this.domElement && this.cssEffects) {
|
289
|
-
this.recoverActive = false;
|
290
|
-
if (this.domElement.hasClass('active')) {
|
291
|
-
this.domElement.removeClass('active');
|
292
|
-
this.recoverActive = true;
|
293
|
-
}
|
294
|
-
this.domElement.removeClass('hover');
|
295
|
-
}
|
296
|
-
break;
|
297
|
-
|
298
|
-
case 'mousedown':
|
299
|
-
if (this.domElement && this.cssEffects) {
|
300
|
-
this.domElement.addClass('active');
|
301
|
-
}
|
302
|
-
break;
|
303
|
-
|
304
|
-
case 'mouseup':
|
305
|
-
if (this.domElement && this.cssEffects) {
|
306
|
-
this.domElement.removeClass('active');
|
307
|
-
this.recoverActive = false;
|
274
|
+
if (this.handlers.noflash && !ZeroClipboard.detectFlashSupport()) {
|
275
|
+
this.receiveEvent("onNoFlash", null);
|
276
|
+
}
|
277
|
+
};
|
278
|
+
ZeroClipboard.prototype.addEventListener = ZeroClipboard.prototype.on;
|
279
|
+
ZeroClipboard.prototype.off = function(eventName, func) {
|
280
|
+
var events = eventName.toString().split(/\s/g);
|
281
|
+
for (var i = 0; i < events.length; i++) {
|
282
|
+
eventName = events[i].toLowerCase().replace(/^on/, "");
|
283
|
+
for (var event in this.handlers) {
|
284
|
+
if (event === eventName && this.handlers[event] === func) {
|
285
|
+
delete this.handlers[event];
|
308
286
|
}
|
309
|
-
|
310
|
-
}
|
311
|
-
|
287
|
+
}
|
288
|
+
}
|
289
|
+
};
|
290
|
+
ZeroClipboard.prototype.removeEventListener = ZeroClipboard.prototype.off;
|
291
|
+
ZeroClipboard.prototype.receiveEvent = function(eventName, args) {
|
292
|
+
eventName = eventName.toString().toLowerCase().replace(/^on/, "");
|
293
|
+
var element = currentElement;
|
294
|
+
switch (eventName) {
|
295
|
+
case "load":
|
296
|
+
if (args && parseFloat(args.flashVersion.replace(",", ".").replace(/[^0-9\.]/gi, "")) < 10) {
|
297
|
+
this.receiveEvent("onWrongFlash", {
|
298
|
+
flashVersion: args.flashVersion
|
299
|
+
});
|
300
|
+
return;
|
301
|
+
}
|
302
|
+
this.htmlBridge.setAttribute("data-clipboard-ready", true);
|
303
|
+
break;
|
304
|
+
case "mouseover":
|
305
|
+
_addClass(element, this.options.hoverClass);
|
306
|
+
break;
|
307
|
+
case "mouseout":
|
308
|
+
_removeClass(element, this.options.hoverClass);
|
309
|
+
this.resetBridge();
|
310
|
+
break;
|
311
|
+
case "mousedown":
|
312
|
+
_addClass(element, this.options.activeClass);
|
313
|
+
break;
|
314
|
+
case "mouseup":
|
315
|
+
_removeClass(element, this.options.activeClass);
|
316
|
+
break;
|
317
|
+
case "datarequested":
|
318
|
+
var targetId = element.getAttribute("data-clipboard-target"), targetEl = !targetId ? null : document.getElementById(targetId);
|
319
|
+
if (targetEl) {
|
320
|
+
var textContent = targetEl.value || targetEl.textContent || targetEl.innerText;
|
321
|
+
if (textContent) this.setText(textContent);
|
322
|
+
} else {
|
323
|
+
var defaultText = element.getAttribute("data-clipboard-text");
|
324
|
+
if (defaultText) this.setText(defaultText);
|
325
|
+
}
|
326
|
+
break;
|
327
|
+
case "complete":
|
328
|
+
this.options.text = null;
|
329
|
+
break;
|
330
|
+
}
|
312
331
|
if (this.handlers[eventName]) {
|
313
|
-
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
332
|
+
var func = this.handlers[eventName];
|
333
|
+
if (typeof func == "function") {
|
334
|
+
func.call(element, this, args);
|
335
|
+
} else if (typeof func == "string") {
|
336
|
+
window[func].call(element, this, args);
|
337
|
+
}
|
338
|
+
}
|
339
|
+
};
|
340
|
+
ZeroClipboard.prototype.glue = function(elements) {
|
341
|
+
elements = _prepGlue(elements);
|
342
|
+
for (var i = 0; i < elements.length; i++) {
|
343
|
+
if (_inArray(elements[i], gluedElements) == -1) {
|
344
|
+
gluedElements.push(elements[i]);
|
345
|
+
_addEventHandler(elements[i], "mouseover", _elementMouseOver);
|
346
|
+
}
|
347
|
+
}
|
348
|
+
};
|
349
|
+
ZeroClipboard.prototype.unglue = function(elements) {
|
350
|
+
elements = _prepGlue(elements);
|
351
|
+
for (var i = 0; i < elements.length; i++) {
|
352
|
+
_removeEventHandler(elements[i], "mouseover", _elementMouseOver);
|
353
|
+
var arrayIndex = _inArray(elements[i], gluedElements);
|
354
|
+
if (arrayIndex != -1) gluedElements.splice(arrayIndex, 1);
|
355
|
+
}
|
356
|
+
};
|
357
|
+
if (typeof module !== "undefined") {
|
358
|
+
module.exports = ZeroClipboard;
|
359
|
+
} else if (typeof define === "function" && define.amd) {
|
360
|
+
define(function() {
|
361
|
+
return ZeroClipboard;
|
362
|
+
});
|
363
|
+
} else {
|
364
|
+
window.ZeroClipboard = ZeroClipboard;
|
330
365
|
}
|
331
|
-
|
332
|
-
};
|
333
|
-
|
334
|
-
if (typeof module !== "undefined") {
|
335
|
-
module.exports = ZeroClipboard;
|
336
|
-
}
|
337
|
-
|
366
|
+
})();
|
metadata
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: zclip-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
5
|
-
prerelease:
|
4
|
+
version: 0.0.2
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Henrik Wenz
|
@@ -11,12 +10,11 @@ authors:
|
|
11
10
|
autorequire:
|
12
11
|
bindir: bin
|
13
12
|
cert_chain: []
|
14
|
-
date:
|
13
|
+
date: 2013-06-24 00:00:00.000000000 Z
|
15
14
|
dependencies:
|
16
15
|
- !ruby/object:Gem::Dependency
|
17
16
|
name: railties
|
18
17
|
requirement: !ruby/object:Gem::Requirement
|
19
|
-
none: false
|
20
18
|
requirements:
|
21
19
|
- - ~>
|
22
20
|
- !ruby/object:Gem::Version
|
@@ -24,7 +22,6 @@ dependencies:
|
|
24
22
|
type: :runtime
|
25
23
|
prerelease: false
|
26
24
|
version_requirements: !ruby/object:Gem::Requirement
|
27
|
-
none: false
|
28
25
|
requirements:
|
29
26
|
- - ~>
|
30
27
|
- !ruby/object:Gem::Version
|
@@ -32,7 +29,6 @@ dependencies:
|
|
32
29
|
- !ruby/object:Gem::Dependency
|
33
30
|
name: jquery-rails
|
34
31
|
requirement: !ruby/object:Gem::Requirement
|
35
|
-
none: false
|
36
32
|
requirements:
|
37
33
|
- - ! '>='
|
38
34
|
- !ruby/object:Gem::Version
|
@@ -40,7 +36,6 @@ dependencies:
|
|
40
36
|
type: :runtime
|
41
37
|
prerelease: false
|
42
38
|
version_requirements: !ruby/object:Gem::Requirement
|
43
|
-
none: false
|
44
39
|
requirements:
|
45
40
|
- - ! '>='
|
46
41
|
- !ruby/object:Gem::Version
|
@@ -55,7 +50,7 @@ extra_rdoc_files: []
|
|
55
50
|
files:
|
56
51
|
- lib/zclip-rails/version.rb
|
57
52
|
- lib/zclip-rails.rb
|
58
|
-
- vendor/assets/images/
|
53
|
+
- vendor/assets/images/ZeroClipboard.swf
|
59
54
|
- vendor/assets/javascripts/zclip/jquery.zclip.js.erb
|
60
55
|
- vendor/assets/javascripts/zclip.js
|
61
56
|
- vendor/assets/javascripts/zero-clipboard/zero-clipboard.js
|
@@ -63,26 +58,25 @@ files:
|
|
63
58
|
- README.md
|
64
59
|
homepage: https://github.com/HaNdTriX/zclip-rails
|
65
60
|
licenses: []
|
61
|
+
metadata: {}
|
66
62
|
post_install_message:
|
67
63
|
rdoc_options: []
|
68
64
|
require_paths:
|
69
65
|
- lib
|
70
66
|
required_ruby_version: !ruby/object:Gem::Requirement
|
71
|
-
none: false
|
72
67
|
requirements:
|
73
68
|
- - ! '>='
|
74
69
|
- !ruby/object:Gem::Version
|
75
70
|
version: '0'
|
76
71
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
77
|
-
none: false
|
78
72
|
requirements:
|
79
73
|
- - ! '>='
|
80
74
|
- !ruby/object:Gem::Version
|
81
75
|
version: '0'
|
82
76
|
requirements: []
|
83
77
|
rubyforge_project:
|
84
|
-
rubygems_version:
|
78
|
+
rubygems_version: 2.0.3
|
85
79
|
signing_key:
|
86
|
-
specification_version:
|
80
|
+
specification_version: 4
|
87
81
|
summary: Adds easy copy to clipboard functionality to your Rails 3.x app
|
88
82
|
test_files: []
|
Binary file
|