zeroclipboard-rails 0.0.10 → 0.0.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +7 -0
- data/app/assets/images/ZeroClipboard.swf +0 -0
- data/app/assets/javascripts/zeroclipboard/ZeroClipboard.js +739 -203
- data/lib/zeroclipboard-rails/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c0e30c574d43c8901a4d17de7cccd0f2cf2f5d1a
|
4
|
+
data.tar.gz: 2c8b393dde31058ea8e1a98b7e56367050de44bf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 90c89be1bee79a9be5dabfb5a12450b0a48492afbcdee0dc242a1dfc6daa0df3dbc34d0f2cdbe7b984cadd87f3de5ed96f0a500b136bda83451aeea05064bf82
|
7
|
+
data.tar.gz: a8d2a43dd97ac0227c7fdeeb3e4920acbc4f521b4358eadc9a26249e54c834e3e2c2a4c65e3b992d398872c47749b054bd50f1de6e2ee52d35b01572b0b200d7
|
data/README.md
CHANGED
@@ -152,6 +152,13 @@ This gem is merely a wrapper around [ZeroClipboard](https://github.com/zeroclipb
|
|
152
152
|
No patch for CSS zoom bug which still remains
|
153
153
|
</td>
|
154
154
|
</tr>
|
155
|
+
<tr>
|
156
|
+
<td><a href="https://rubygems.org/gems/zeroclipboard-rails/versions/0.0.11">0.0.11</a></td>
|
157
|
+
<td><a href="https://github.com/zeroclipboard/ZeroClipboard/tree/v1.3.1">1.3.1</a></td>
|
158
|
+
<td>
|
159
|
+
No patch for CSS zoom bug which still remains
|
160
|
+
</td>
|
161
|
+
</tr>
|
155
162
|
</table>
|
156
163
|
|
157
164
|
|
Binary file
|
@@ -1,13 +1,67 @@
|
|
1
1
|
/*!
|
2
2
|
* ZeroClipboard
|
3
3
|
* The ZeroClipboard library provides an easy way to copy text to the clipboard using an invisible Adobe Flash movie and a JavaScript interface.
|
4
|
-
* Copyright (c)
|
4
|
+
* Copyright (c) 2014 Jon Rohan, James M. Greene
|
5
5
|
* Licensed MIT
|
6
6
|
* http://zeroclipboard.org/
|
7
|
-
* v1.
|
7
|
+
* v1.3.1
|
8
8
|
*/
|
9
9
|
(function() {
|
10
10
|
"use strict";
|
11
|
+
var currentElement;
|
12
|
+
var flashState = {
|
13
|
+
bridge: null,
|
14
|
+
version: "0.0.0",
|
15
|
+
disabled: null,
|
16
|
+
outdated: null,
|
17
|
+
ready: null
|
18
|
+
};
|
19
|
+
var _clipData = {};
|
20
|
+
var clientIdCounter = 0;
|
21
|
+
var _clientMeta = {};
|
22
|
+
var elementIdCounter = 0;
|
23
|
+
var _elementMeta = {};
|
24
|
+
var _amdModuleId = null;
|
25
|
+
var _cjsModuleId = null;
|
26
|
+
var _swfPath = function() {
|
27
|
+
var i, jsDir, tmpJsPath, jsPath, swfPath = "ZeroClipboard.swf";
|
28
|
+
if (document.currentScript && (jsPath = document.currentScript.src)) {} else {
|
29
|
+
var scripts = document.getElementsByTagName("script");
|
30
|
+
if ("readyState" in scripts[0]) {
|
31
|
+
for (i = scripts.length; i--; ) {
|
32
|
+
if (scripts[i].readyState === "interactive" && (jsPath = scripts[i].src)) {
|
33
|
+
break;
|
34
|
+
}
|
35
|
+
}
|
36
|
+
} else if (document.readyState === "loading") {
|
37
|
+
jsPath = scripts[scripts.length - 1].src;
|
38
|
+
} else {
|
39
|
+
for (i = scripts.length; i--; ) {
|
40
|
+
tmpJsPath = scripts[i].src;
|
41
|
+
if (!tmpJsPath) {
|
42
|
+
jsDir = null;
|
43
|
+
break;
|
44
|
+
}
|
45
|
+
tmpJsPath = tmpJsPath.split("#")[0].split("?")[0];
|
46
|
+
tmpJsPath = tmpJsPath.slice(0, tmpJsPath.lastIndexOf("/") + 1);
|
47
|
+
if (jsDir == null) {
|
48
|
+
jsDir = tmpJsPath;
|
49
|
+
} else if (jsDir !== tmpJsPath) {
|
50
|
+
jsDir = null;
|
51
|
+
break;
|
52
|
+
}
|
53
|
+
}
|
54
|
+
if (jsDir !== null) {
|
55
|
+
jsPath = jsDir;
|
56
|
+
}
|
57
|
+
}
|
58
|
+
}
|
59
|
+
if (jsPath) {
|
60
|
+
jsPath = jsPath.split("#")[0].split("?")[0];
|
61
|
+
swfPath = jsPath.slice(0, jsPath.lastIndexOf("/") + 1) + swfPath;
|
62
|
+
}
|
63
|
+
return swfPath;
|
64
|
+
}();
|
11
65
|
var _camelizeCssPropName = function() {
|
12
66
|
var matcherRegex = /\-([a-z])/g, replacerFn = function(match, group) {
|
13
67
|
return group.toUpperCase();
|
@@ -31,18 +85,14 @@
|
|
31
85
|
if (prop === "cursor") {
|
32
86
|
if (!value || value === "auto") {
|
33
87
|
tagName = el.tagName.toLowerCase();
|
34
|
-
|
35
|
-
|
36
|
-
if (tagName === possiblePointers[i]) {
|
37
|
-
return "pointer";
|
38
|
-
}
|
88
|
+
if (tagName === "a") {
|
89
|
+
return "pointer";
|
39
90
|
}
|
40
91
|
}
|
41
92
|
}
|
42
93
|
return value;
|
43
94
|
};
|
44
95
|
var _elementMouseOver = function(event) {
|
45
|
-
if (!ZeroClipboard.prototype._singleton) return;
|
46
96
|
if (!event) {
|
47
97
|
event = window.event;
|
48
98
|
}
|
@@ -54,9 +104,12 @@
|
|
54
104
|
} else if (event.srcElement) {
|
55
105
|
target = event.srcElement;
|
56
106
|
}
|
57
|
-
ZeroClipboard.
|
107
|
+
ZeroClipboard.activate(target);
|
58
108
|
};
|
59
109
|
var _addEventHandler = function(element, method, func) {
|
110
|
+
if (!element || element.nodeType !== 1) {
|
111
|
+
return;
|
112
|
+
}
|
60
113
|
if (element.addEventListener) {
|
61
114
|
element.addEventListener(method, func, false);
|
62
115
|
} else if (element.attachEvent) {
|
@@ -64,6 +117,9 @@
|
|
64
117
|
}
|
65
118
|
};
|
66
119
|
var _removeEventHandler = function(element, method, func) {
|
120
|
+
if (!element || element.nodeType !== 1) {
|
121
|
+
return;
|
122
|
+
}
|
67
123
|
if (element.removeEventListener) {
|
68
124
|
element.removeEventListener(method, func, false);
|
69
125
|
} else if (element.detachEvent) {
|
@@ -71,8 +127,13 @@
|
|
71
127
|
}
|
72
128
|
};
|
73
129
|
var _addClass = function(element, value) {
|
74
|
-
if (element.
|
75
|
-
element
|
130
|
+
if (!element || element.nodeType !== 1) {
|
131
|
+
return element;
|
132
|
+
}
|
133
|
+
if (element.classList) {
|
134
|
+
if (!element.classList.contains(value)) {
|
135
|
+
element.classList.add(value);
|
136
|
+
}
|
76
137
|
return element;
|
77
138
|
}
|
78
139
|
if (value && typeof value === "string") {
|
@@ -94,8 +155,13 @@
|
|
94
155
|
return element;
|
95
156
|
};
|
96
157
|
var _removeClass = function(element, value) {
|
97
|
-
if (element.
|
98
|
-
element
|
158
|
+
if (!element || element.nodeType !== 1) {
|
159
|
+
return element;
|
160
|
+
}
|
161
|
+
if (element.classList) {
|
162
|
+
if (element.classList.contains(value)) {
|
163
|
+
element.classList.remove(value);
|
164
|
+
}
|
99
165
|
return element;
|
100
166
|
}
|
101
167
|
if (value && typeof value === "string" || value === undefined) {
|
@@ -124,18 +190,14 @@
|
|
124
190
|
}
|
125
191
|
return zoomFactor;
|
126
192
|
};
|
127
|
-
var _getDOMObjectPosition = function(obj) {
|
193
|
+
var _getDOMObjectPosition = function(obj, defaultZIndex) {
|
128
194
|
var info = {
|
129
195
|
left: 0,
|
130
196
|
top: 0,
|
131
197
|
width: 0,
|
132
198
|
height: 0,
|
133
|
-
zIndex:
|
199
|
+
zIndex: _getSafeZIndex(defaultZIndex) - 1
|
134
200
|
};
|
135
|
-
var zi = _getStyle(obj, "z-index");
|
136
|
-
if (zi && zi !== "auto") {
|
137
|
-
info.zIndex = parseInt(zi, 10);
|
138
|
-
}
|
139
201
|
if (obj.getBoundingClientRect) {
|
140
202
|
var rect = obj.getBoundingClientRect();
|
141
203
|
var pageXOffset, pageYOffset, zoomFactor;
|
@@ -156,309 +218,783 @@
|
|
156
218
|
}
|
157
219
|
return info;
|
158
220
|
};
|
159
|
-
var
|
160
|
-
var
|
161
|
-
if (
|
162
|
-
return (path.indexOf("?") === -1 ? "?" : "&") + "
|
221
|
+
var _cacheBust = function(path, options) {
|
222
|
+
var cacheBust = options == null || options && options.cacheBust === true && options.useNoCache === true;
|
223
|
+
if (cacheBust) {
|
224
|
+
return (path.indexOf("?") === -1 ? "?" : "&") + "noCache=" + new Date().getTime();
|
163
225
|
} else {
|
164
226
|
return "";
|
165
227
|
}
|
166
228
|
};
|
167
229
|
var _vars = function(options) {
|
168
|
-
var str = [];
|
169
|
-
var origins = [];
|
230
|
+
var i, len, domain, str = [], domains = [], trustedOriginsExpanded = [];
|
170
231
|
if (options.trustedOrigins) {
|
171
232
|
if (typeof options.trustedOrigins === "string") {
|
172
|
-
|
233
|
+
domains.push(options.trustedOrigins);
|
173
234
|
} else if (typeof options.trustedOrigins === "object" && "length" in options.trustedOrigins) {
|
174
|
-
|
235
|
+
domains = domains.concat(options.trustedOrigins);
|
175
236
|
}
|
176
237
|
}
|
177
238
|
if (options.trustedDomains) {
|
178
239
|
if (typeof options.trustedDomains === "string") {
|
179
|
-
|
240
|
+
domains.push(options.trustedDomains);
|
180
241
|
} else if (typeof options.trustedDomains === "object" && "length" in options.trustedDomains) {
|
181
|
-
|
242
|
+
domains = domains.concat(options.trustedDomains);
|
182
243
|
}
|
183
244
|
}
|
184
|
-
if (
|
185
|
-
|
245
|
+
if (domains.length) {
|
246
|
+
for (i = 0, len = domains.length; i < len; i++) {
|
247
|
+
if (domains.hasOwnProperty(i) && domains[i] && typeof domains[i] === "string") {
|
248
|
+
domain = _extractDomain(domains[i]);
|
249
|
+
if (!domain) {
|
250
|
+
continue;
|
251
|
+
}
|
252
|
+
if (domain === "*") {
|
253
|
+
trustedOriginsExpanded = [ domain ];
|
254
|
+
break;
|
255
|
+
}
|
256
|
+
trustedOriginsExpanded.push.apply(trustedOriginsExpanded, [ domain, "//" + domain, window.location.protocol + "//" + domain ]);
|
257
|
+
}
|
258
|
+
}
|
186
259
|
}
|
187
|
-
if (
|
188
|
-
str.push("
|
260
|
+
if (trustedOriginsExpanded.length) {
|
261
|
+
str.push("trustedOrigins=" + encodeURIComponent(trustedOriginsExpanded.join(",")));
|
189
262
|
}
|
190
|
-
if (typeof options.
|
191
|
-
str.push("
|
263
|
+
if (typeof options.jsModuleId === "string" && options.jsModuleId) {
|
264
|
+
str.push("jsModuleId=" + encodeURIComponent(options.jsModuleId));
|
192
265
|
}
|
193
266
|
return str.join("&");
|
194
267
|
};
|
195
|
-
var _inArray = function(elem, array) {
|
196
|
-
if (array.indexOf) {
|
197
|
-
return array.indexOf(elem);
|
268
|
+
var _inArray = function(elem, array, fromIndex) {
|
269
|
+
if (typeof array.indexOf === "function") {
|
270
|
+
return array.indexOf(elem, fromIndex);
|
271
|
+
}
|
272
|
+
var i, len = array.length;
|
273
|
+
if (typeof fromIndex === "undefined") {
|
274
|
+
fromIndex = 0;
|
275
|
+
} else if (fromIndex < 0) {
|
276
|
+
fromIndex = len + fromIndex;
|
198
277
|
}
|
199
|
-
for (
|
200
|
-
if (array[i] === elem) {
|
278
|
+
for (i = fromIndex; i < len; i++) {
|
279
|
+
if (array.hasOwnProperty(i) && array[i] === elem) {
|
201
280
|
return i;
|
202
281
|
}
|
203
282
|
}
|
204
283
|
return -1;
|
205
284
|
};
|
206
|
-
var
|
285
|
+
var _prepClip = function(elements) {
|
207
286
|
if (typeof elements === "string") throw new TypeError("ZeroClipboard doesn't accept query strings.");
|
208
287
|
if (!elements.length) return [ elements ];
|
209
288
|
return elements;
|
210
289
|
};
|
211
|
-
var _dispatchCallback = function(func,
|
290
|
+
var _dispatchCallback = function(func, context, args, async) {
|
212
291
|
if (async) {
|
213
292
|
window.setTimeout(function() {
|
214
|
-
func.
|
293
|
+
func.apply(context, args);
|
215
294
|
}, 0);
|
216
295
|
} else {
|
217
|
-
func.
|
296
|
+
func.apply(context, args);
|
297
|
+
}
|
298
|
+
};
|
299
|
+
var _getSafeZIndex = function(val) {
|
300
|
+
var zIndex, tmp;
|
301
|
+
if (val) {
|
302
|
+
if (typeof val === "number" && val > 0) {
|
303
|
+
zIndex = val;
|
304
|
+
} else if (typeof val === "string" && (tmp = parseInt(val, 10)) && !isNaN(tmp) && tmp > 0) {
|
305
|
+
zIndex = tmp;
|
306
|
+
}
|
307
|
+
}
|
308
|
+
if (!zIndex) {
|
309
|
+
if (typeof _globalConfig.zIndex === "number" && _globalConfig.zIndex > 0) {
|
310
|
+
zIndex = _globalConfig.zIndex;
|
311
|
+
} else if (typeof _globalConfig.zIndex === "string" && (tmp = parseInt(_globalConfig.zIndex, 10)) && !isNaN(tmp) && tmp > 0) {
|
312
|
+
zIndex = tmp;
|
313
|
+
}
|
314
|
+
}
|
315
|
+
return zIndex || 0;
|
316
|
+
};
|
317
|
+
var _deprecationWarning = function(deprecatedApiName, debugEnabled) {
|
318
|
+
if (deprecatedApiName && debugEnabled !== false && typeof console !== "undefined" && console && (console.warn || console.log)) {
|
319
|
+
var deprecationWarning = "`" + deprecatedApiName + "` is deprecated. See docs for more info:\n" + " https://github.com/zeroclipboard/zeroclipboard/blob/master/docs/instructions.md#deprecations";
|
320
|
+
if (console.warn) {
|
321
|
+
console.warn(deprecationWarning);
|
322
|
+
} else {
|
323
|
+
console.log(deprecationWarning);
|
324
|
+
}
|
325
|
+
}
|
326
|
+
};
|
327
|
+
var _extend = function() {
|
328
|
+
var i, len, arg, prop, src, copy, target = arguments[0] || {};
|
329
|
+
for (i = 1, len = arguments.length; i < len; i++) {
|
330
|
+
if ((arg = arguments[i]) != null) {
|
331
|
+
for (prop in arg) {
|
332
|
+
if (arg.hasOwnProperty(prop)) {
|
333
|
+
src = target[prop];
|
334
|
+
copy = arg[prop];
|
335
|
+
if (target === copy) {
|
336
|
+
continue;
|
337
|
+
}
|
338
|
+
if (copy !== undefined) {
|
339
|
+
target[prop] = copy;
|
340
|
+
}
|
341
|
+
}
|
342
|
+
}
|
343
|
+
}
|
344
|
+
}
|
345
|
+
return target;
|
346
|
+
};
|
347
|
+
var _extractDomain = function(originOrUrl) {
|
348
|
+
if (originOrUrl == null || originOrUrl === "") {
|
349
|
+
return null;
|
350
|
+
}
|
351
|
+
originOrUrl = originOrUrl.replace(/^\s+|\s+$/g, "");
|
352
|
+
if (originOrUrl === "") {
|
353
|
+
return null;
|
354
|
+
}
|
355
|
+
var protocolIndex = originOrUrl.indexOf("//");
|
356
|
+
originOrUrl = protocolIndex === -1 ? originOrUrl : originOrUrl.slice(protocolIndex + 2);
|
357
|
+
var pathIndex = originOrUrl.indexOf("/");
|
358
|
+
originOrUrl = pathIndex === -1 ? originOrUrl : protocolIndex === -1 || pathIndex === 0 ? null : originOrUrl.slice(0, pathIndex);
|
359
|
+
if (originOrUrl && originOrUrl.slice(-4).toLowerCase() === ".swf") {
|
360
|
+
return null;
|
361
|
+
}
|
362
|
+
return originOrUrl || null;
|
363
|
+
};
|
364
|
+
var _determineScriptAccess = function() {
|
365
|
+
var _extractAllDomains = function(origins, resultsArray) {
|
366
|
+
var i, len, tmp;
|
367
|
+
if (origins != null && resultsArray[0] !== "*") {
|
368
|
+
if (typeof origins === "string") {
|
369
|
+
origins = [ origins ];
|
370
|
+
}
|
371
|
+
if (typeof origins === "object" && "length" in origins) {
|
372
|
+
for (i = 0, len = origins.length; i < len; i++) {
|
373
|
+
if (origins.hasOwnProperty(i)) {
|
374
|
+
tmp = _extractDomain(origins[i]);
|
375
|
+
if (tmp) {
|
376
|
+
if (tmp === "*") {
|
377
|
+
resultsArray.length = 0;
|
378
|
+
resultsArray.push("*");
|
379
|
+
break;
|
380
|
+
}
|
381
|
+
if (_inArray(tmp, resultsArray) === -1) {
|
382
|
+
resultsArray.push(tmp);
|
383
|
+
}
|
384
|
+
}
|
385
|
+
}
|
386
|
+
}
|
387
|
+
}
|
388
|
+
}
|
389
|
+
};
|
390
|
+
var _accessLevelLookup = {
|
391
|
+
always: "always",
|
392
|
+
samedomain: "sameDomain",
|
393
|
+
never: "never"
|
394
|
+
};
|
395
|
+
return function(currentDomain, configOptions) {
|
396
|
+
var asaLower, allowScriptAccess = configOptions.allowScriptAccess;
|
397
|
+
if (typeof allowScriptAccess === "string" && (asaLower = allowScriptAccess.toLowerCase()) && /^always|samedomain|never$/.test(asaLower)) {
|
398
|
+
return _accessLevelLookup[asaLower];
|
399
|
+
}
|
400
|
+
var swfDomain = _extractDomain(configOptions.moviePath);
|
401
|
+
if (swfDomain === null) {
|
402
|
+
swfDomain = currentDomain;
|
403
|
+
}
|
404
|
+
var trustedDomains = [];
|
405
|
+
_extractAllDomains(configOptions.trustedOrigins, trustedDomains);
|
406
|
+
_extractAllDomains(configOptions.trustedDomains, trustedDomains);
|
407
|
+
var len = trustedDomains.length;
|
408
|
+
if (len > 0) {
|
409
|
+
if (len === 1 && trustedDomains[0] === "*") {
|
410
|
+
return "always";
|
411
|
+
}
|
412
|
+
if (_inArray(currentDomain, trustedDomains) !== -1) {
|
413
|
+
if (len === 1 && currentDomain === swfDomain) {
|
414
|
+
return "sameDomain";
|
415
|
+
}
|
416
|
+
return "always";
|
417
|
+
}
|
418
|
+
}
|
419
|
+
return "never";
|
420
|
+
};
|
421
|
+
}();
|
422
|
+
var _objectKeys = function(obj) {
|
423
|
+
if (obj == null) {
|
424
|
+
return [];
|
425
|
+
}
|
426
|
+
if (Object.keys) {
|
427
|
+
return Object.keys(obj);
|
428
|
+
}
|
429
|
+
var keys = [];
|
430
|
+
for (var prop in obj) {
|
431
|
+
if (obj.hasOwnProperty(prop)) {
|
432
|
+
keys.push(prop);
|
433
|
+
}
|
434
|
+
}
|
435
|
+
return keys;
|
436
|
+
};
|
437
|
+
var _deleteOwnProperties = function(obj) {
|
438
|
+
if (obj) {
|
439
|
+
for (var prop in obj) {
|
440
|
+
if (obj.hasOwnProperty(prop)) {
|
441
|
+
delete obj[prop];
|
442
|
+
}
|
443
|
+
}
|
444
|
+
}
|
445
|
+
return obj;
|
446
|
+
};
|
447
|
+
var _detectFlashSupport = function() {
|
448
|
+
var hasFlash = false;
|
449
|
+
if (typeof flashState.disabled === "boolean") {
|
450
|
+
hasFlash = flashState.disabled === false;
|
451
|
+
} else {
|
452
|
+
if (typeof ActiveXObject === "function") {
|
453
|
+
try {
|
454
|
+
if (new ActiveXObject("ShockwaveFlash.ShockwaveFlash")) {
|
455
|
+
hasFlash = true;
|
456
|
+
}
|
457
|
+
} catch (error) {}
|
458
|
+
}
|
459
|
+
if (!hasFlash && navigator.mimeTypes["application/x-shockwave-flash"]) {
|
460
|
+
hasFlash = true;
|
461
|
+
}
|
218
462
|
}
|
463
|
+
return hasFlash;
|
219
464
|
};
|
465
|
+
function _parseFlashVersion(flashVersion) {
|
466
|
+
return flashVersion.replace(/,/g, ".").replace(/[^0-9\.]/g, "");
|
467
|
+
}
|
468
|
+
function _isFlashVersionSupported(flashVersion) {
|
469
|
+
return parseFloat(_parseFlashVersion(flashVersion)) >= 10;
|
470
|
+
}
|
220
471
|
var ZeroClipboard = function(elements, options) {
|
221
|
-
if (
|
222
|
-
|
223
|
-
|
224
|
-
this.
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
472
|
+
if (!(this instanceof ZeroClipboard)) {
|
473
|
+
return new ZeroClipboard(elements, options);
|
474
|
+
}
|
475
|
+
this.id = "" + clientIdCounter++;
|
476
|
+
_clientMeta[this.id] = {
|
477
|
+
instance: this,
|
478
|
+
elements: [],
|
479
|
+
handlers: {}
|
480
|
+
};
|
481
|
+
if (elements) {
|
482
|
+
this.clip(elements);
|
483
|
+
}
|
484
|
+
if (typeof options !== "undefined") {
|
485
|
+
_deprecationWarning("new ZeroClipboard(elements, options)", _globalConfig.debug);
|
486
|
+
ZeroClipboard.config(options);
|
487
|
+
}
|
488
|
+
this.options = ZeroClipboard.config();
|
489
|
+
if (typeof flashState.disabled !== "boolean") {
|
490
|
+
flashState.disabled = !_detectFlashSupport();
|
491
|
+
}
|
492
|
+
if (flashState.disabled === false && flashState.outdated !== true) {
|
493
|
+
if (flashState.bridge === null) {
|
494
|
+
flashState.outdated = false;
|
495
|
+
flashState.ready = false;
|
496
|
+
_bridge();
|
497
|
+
}
|
237
498
|
}
|
238
|
-
var useHandCursor = this.options.forceHandCursor === true || _getStyle(element, "cursor") === "pointer";
|
239
|
-
_setHandCursor.call(this, useHandCursor);
|
240
|
-
return this;
|
241
499
|
};
|
242
500
|
ZeroClipboard.prototype.setText = function(newText) {
|
243
501
|
if (newText && newText !== "") {
|
244
|
-
|
245
|
-
if (
|
502
|
+
_clipData["text/plain"] = newText;
|
503
|
+
if (flashState.ready === true && flashState.bridge) {
|
504
|
+
flashState.bridge.setText(newText);
|
505
|
+
} else {}
|
246
506
|
}
|
247
507
|
return this;
|
248
508
|
};
|
249
|
-
ZeroClipboard.prototype.setTitle = function(newTitle) {
|
250
|
-
if (newTitle && newTitle !== "") this.htmlBridge.setAttribute("title", newTitle);
|
251
|
-
return this;
|
252
|
-
};
|
253
509
|
ZeroClipboard.prototype.setSize = function(width, height) {
|
254
|
-
if (
|
255
|
-
|
256
|
-
|
257
|
-
ZeroClipboard.prototype.setHandCursor = function(enabled) {
|
258
|
-
enabled = typeof enabled === "boolean" ? enabled : !!enabled;
|
259
|
-
_setHandCursor.call(this, enabled);
|
260
|
-
this.options.forceHandCursor = enabled;
|
510
|
+
if (flashState.ready === true && flashState.bridge) {
|
511
|
+
flashState.bridge.setSize(width, height);
|
512
|
+
} else {}
|
261
513
|
return this;
|
262
514
|
};
|
263
515
|
var _setHandCursor = function(enabled) {
|
264
|
-
if (
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
516
|
+
if (flashState.ready === true && flashState.bridge) {
|
517
|
+
flashState.bridge.setHandCursor(enabled);
|
518
|
+
} else {}
|
519
|
+
};
|
520
|
+
ZeroClipboard.prototype.destroy = function() {
|
521
|
+
this.unclip();
|
522
|
+
this.off();
|
523
|
+
delete _clientMeta[this.id];
|
524
|
+
};
|
525
|
+
var _getAllClients = function() {
|
526
|
+
var i, len, client, clients = [], clientIds = _objectKeys(_clientMeta);
|
527
|
+
for (i = 0, len = clientIds.length; i < len; i++) {
|
528
|
+
client = _clientMeta[clientIds[i]].instance;
|
529
|
+
if (client && client instanceof ZeroClipboard) {
|
530
|
+
clients.push(client);
|
531
|
+
}
|
532
|
+
}
|
533
|
+
return clients;
|
534
|
+
};
|
535
|
+
ZeroClipboard.version = "1.3.1";
|
536
|
+
var _globalConfig = {
|
537
|
+
swfPath: _swfPath,
|
538
|
+
trustedDomains: window.location.host ? [ window.location.host ] : [],
|
539
|
+
cacheBust: true,
|
540
|
+
forceHandCursor: false,
|
541
|
+
zIndex: 999999999,
|
542
|
+
debug: true,
|
543
|
+
title: null,
|
544
|
+
autoActivate: true
|
545
|
+
};
|
546
|
+
ZeroClipboard.config = function(options) {
|
547
|
+
if (typeof options === "object" && options !== null) {
|
548
|
+
_extend(_globalConfig, options);
|
549
|
+
}
|
550
|
+
if (typeof options === "string" && options) {
|
551
|
+
if (_globalConfig.hasOwnProperty(options)) {
|
552
|
+
return _globalConfig[options];
|
553
|
+
}
|
554
|
+
return;
|
555
|
+
}
|
556
|
+
var copy = {};
|
557
|
+
for (var prop in _globalConfig) {
|
558
|
+
if (_globalConfig.hasOwnProperty(prop)) {
|
559
|
+
if (typeof _globalConfig[prop] === "object" && _globalConfig[prop] !== null) {
|
560
|
+
if ("length" in _globalConfig[prop]) {
|
561
|
+
copy[prop] = _globalConfig[prop].slice(0);
|
562
|
+
} else {
|
563
|
+
copy[prop] = _extend({}, _globalConfig[prop]);
|
564
|
+
}
|
565
|
+
} else {
|
566
|
+
copy[prop] = _globalConfig[prop];
|
567
|
+
}
|
568
|
+
}
|
569
|
+
}
|
570
|
+
return copy;
|
279
571
|
};
|
280
572
|
ZeroClipboard.destroy = function() {
|
281
|
-
ZeroClipboard.
|
282
|
-
var
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
var hasFlash = false;
|
288
|
-
if (typeof ActiveXObject === "function") {
|
289
|
-
try {
|
290
|
-
if (new ActiveXObject("ShockwaveFlash.ShockwaveFlash")) {
|
291
|
-
hasFlash = true;
|
573
|
+
ZeroClipboard.deactivate();
|
574
|
+
for (var clientId in _clientMeta) {
|
575
|
+
if (_clientMeta.hasOwnProperty(clientId) && _clientMeta[clientId]) {
|
576
|
+
var client = _clientMeta[clientId].instance;
|
577
|
+
if (client && typeof client.destroy === "function") {
|
578
|
+
client.destroy();
|
292
579
|
}
|
293
|
-
}
|
580
|
+
}
|
294
581
|
}
|
295
|
-
|
296
|
-
|
582
|
+
var htmlBridge = _getHtmlBridge(flashState.bridge);
|
583
|
+
if (htmlBridge && htmlBridge.parentNode) {
|
584
|
+
htmlBridge.parentNode.removeChild(htmlBridge);
|
585
|
+
flashState.ready = null;
|
586
|
+
flashState.bridge = null;
|
587
|
+
}
|
588
|
+
};
|
589
|
+
ZeroClipboard.activate = function(element) {
|
590
|
+
if (currentElement) {
|
591
|
+
_removeClass(currentElement, _globalConfig.hoverClass);
|
592
|
+
_removeClass(currentElement, _globalConfig.activeClass);
|
593
|
+
}
|
594
|
+
currentElement = element;
|
595
|
+
_addClass(element, _globalConfig.hoverClass);
|
596
|
+
_reposition();
|
597
|
+
var newTitle = _globalConfig.title || element.getAttribute("title");
|
598
|
+
if (newTitle) {
|
599
|
+
var htmlBridge = _getHtmlBridge(flashState.bridge);
|
600
|
+
if (htmlBridge) {
|
601
|
+
htmlBridge.setAttribute("title", newTitle);
|
602
|
+
}
|
603
|
+
}
|
604
|
+
var useHandCursor = _globalConfig.forceHandCursor === true || _getStyle(element, "cursor") === "pointer";
|
605
|
+
_setHandCursor(useHandCursor);
|
606
|
+
};
|
607
|
+
ZeroClipboard.deactivate = function() {
|
608
|
+
var htmlBridge = _getHtmlBridge(flashState.bridge);
|
609
|
+
if (htmlBridge) {
|
610
|
+
htmlBridge.style.left = "0px";
|
611
|
+
htmlBridge.style.top = "-9999px";
|
612
|
+
htmlBridge.removeAttribute("title");
|
613
|
+
}
|
614
|
+
if (currentElement) {
|
615
|
+
_removeClass(currentElement, _globalConfig.hoverClass);
|
616
|
+
_removeClass(currentElement, _globalConfig.activeClass);
|
617
|
+
currentElement = null;
|
297
618
|
}
|
298
|
-
return hasFlash;
|
299
619
|
};
|
300
|
-
var _amdModuleId = null;
|
301
|
-
var _cjsModuleId = null;
|
302
620
|
var _bridge = function() {
|
303
621
|
var flashBridge, len;
|
304
|
-
var client = ZeroClipboard.prototype._singleton;
|
305
622
|
var container = document.getElementById("global-zeroclipboard-html-bridge");
|
306
623
|
if (!container) {
|
307
|
-
var opts =
|
308
|
-
|
309
|
-
|
310
|
-
opts.cjsModuleId = _cjsModuleId;
|
624
|
+
var opts = ZeroClipboard.config();
|
625
|
+
opts.jsModuleId = typeof _amdModuleId === "string" && _amdModuleId || typeof _cjsModuleId === "string" && _cjsModuleId || null;
|
626
|
+
var allowScriptAccess = _determineScriptAccess(window.location.host, _globalConfig);
|
311
627
|
var flashvars = _vars(opts);
|
312
|
-
var
|
628
|
+
var swfUrl = _globalConfig.moviePath + _cacheBust(_globalConfig.moviePath, _globalConfig);
|
629
|
+
var html = ' <object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" id="global-zeroclipboard-flash-bridge" width="100%" height="100%"> <param name="movie" value="' + swfUrl + '"/> <param name="allowScriptAccess" value="' + 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="' + flashvars + '"/> <embed src="' + swfUrl + '" loop="false" menu="false" quality="best" bgcolor="#ffffff" width="100%" height="100%" name="global-zeroclipboard-flash-bridge" allowScriptAccess="' + allowScriptAccess + '" allowFullScreen="false" type="application/x-shockwave-flash" wmode="transparent" pluginspage="http://www.macromedia.com/go/getflashplayer" flashvars="' + flashvars + '" scale="exactfit"> </embed> </object>';
|
313
630
|
container = document.createElement("div");
|
314
631
|
container.id = "global-zeroclipboard-html-bridge";
|
315
632
|
container.setAttribute("class", "global-zeroclipboard-container");
|
316
|
-
container.setAttribute("data-clipboard-ready", false);
|
317
633
|
container.style.position = "absolute";
|
318
|
-
container.style.left = "
|
634
|
+
container.style.left = "0px";
|
319
635
|
container.style.top = "-9999px";
|
320
636
|
container.style.width = "15px";
|
321
637
|
container.style.height = "15px";
|
322
|
-
container.style.zIndex = "
|
323
|
-
container.innerHTML = html;
|
638
|
+
container.style.zIndex = "" + _getSafeZIndex(_globalConfig.zIndex);
|
324
639
|
document.body.appendChild(container);
|
640
|
+
container.innerHTML = html;
|
325
641
|
}
|
326
|
-
client.htmlBridge = container;
|
327
642
|
flashBridge = document["global-zeroclipboard-flash-bridge"];
|
328
643
|
if (flashBridge && (len = flashBridge.length)) {
|
329
644
|
flashBridge = flashBridge[len - 1];
|
330
645
|
}
|
331
|
-
|
332
|
-
};
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
646
|
+
flashState.bridge = flashBridge || container.children[0].lastElementChild;
|
647
|
+
};
|
648
|
+
var _getHtmlBridge = function(flashBridge) {
|
649
|
+
var isFlashElement = /^OBJECT|EMBED$/;
|
650
|
+
var htmlBridge = flashBridge && flashBridge.parentNode;
|
651
|
+
while (htmlBridge && isFlashElement.test(htmlBridge.nodeName) && htmlBridge.parentNode) {
|
652
|
+
htmlBridge = htmlBridge.parentNode;
|
653
|
+
}
|
654
|
+
return htmlBridge || null;
|
655
|
+
};
|
656
|
+
var _reposition = function() {
|
657
|
+
if (currentElement) {
|
658
|
+
var pos = _getDOMObjectPosition(currentElement, _globalConfig.zIndex);
|
659
|
+
var htmlBridge = _getHtmlBridge(flashState.bridge);
|
660
|
+
if (htmlBridge) {
|
661
|
+
htmlBridge.style.top = pos.top + "px";
|
662
|
+
htmlBridge.style.left = pos.left + "px";
|
663
|
+
htmlBridge.style.width = pos.width + "px";
|
664
|
+
htmlBridge.style.height = pos.height + "px";
|
665
|
+
htmlBridge.style.zIndex = pos.zIndex + 1;
|
666
|
+
}
|
667
|
+
if (flashState.ready === true && flashState.bridge) {
|
668
|
+
flashState.bridge.setSize(pos.width, pos.height);
|
669
|
+
}
|
670
|
+
}
|
341
671
|
return this;
|
342
672
|
};
|
343
|
-
ZeroClipboard.prototype.
|
344
|
-
var
|
345
|
-
|
673
|
+
ZeroClipboard.prototype.on = function(eventName, func) {
|
674
|
+
var i, len, events, added = {}, handlers = _clientMeta[this.id] && _clientMeta[this.id].handlers;
|
675
|
+
if (typeof eventName === "string" && eventName) {
|
676
|
+
events = eventName.toLowerCase().split(/\s+/);
|
677
|
+
} else if (typeof eventName === "object" && eventName && typeof func === "undefined") {
|
678
|
+
for (i in eventName) {
|
679
|
+
if (eventName.hasOwnProperty(i) && typeof i === "string" && i && typeof eventName[i] === "function") {
|
680
|
+
this.on(i, eventName[i]);
|
681
|
+
}
|
682
|
+
}
|
683
|
+
}
|
684
|
+
if (events && events.length) {
|
685
|
+
for (i = 0, len = events.length; i < len; i++) {
|
686
|
+
eventName = events[i].replace(/^on/, "");
|
687
|
+
added[eventName] = true;
|
688
|
+
if (!handlers[eventName]) {
|
689
|
+
handlers[eventName] = [];
|
690
|
+
}
|
691
|
+
handlers[eventName].push(func);
|
692
|
+
}
|
693
|
+
if (added.noflash && flashState.disabled) {
|
694
|
+
_receiveEvent.call(this, "noflash", {});
|
695
|
+
}
|
696
|
+
if (added.wrongflash && flashState.outdated) {
|
697
|
+
_receiveEvent.call(this, "wrongflash", {
|
698
|
+
flashVersion: flashState.version
|
699
|
+
});
|
700
|
+
}
|
701
|
+
if (added.load && flashState.ready) {
|
702
|
+
_receiveEvent.call(this, "load", {
|
703
|
+
flashVersion: flashState.version
|
704
|
+
});
|
705
|
+
}
|
706
|
+
}
|
707
|
+
return this;
|
346
708
|
};
|
347
|
-
ZeroClipboard.prototype.
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
709
|
+
ZeroClipboard.prototype.off = function(eventName, func) {
|
710
|
+
var i, len, foundIndex, events, perEventHandlers, handlers = _clientMeta[this.id] && _clientMeta[this.id].handlers;
|
711
|
+
if (arguments.length === 0) {
|
712
|
+
events = _objectKeys(handlers);
|
713
|
+
} else if (typeof eventName === "string" && eventName) {
|
714
|
+
events = eventName.split(/\s+/);
|
715
|
+
} else if (typeof eventName === "object" && eventName && typeof func === "undefined") {
|
716
|
+
for (i in eventName) {
|
717
|
+
if (eventName.hasOwnProperty(i) && typeof i === "string" && i && typeof eventName[i] === "function") {
|
718
|
+
this.off(i, eventName[i]);
|
719
|
+
}
|
720
|
+
}
|
721
|
+
}
|
722
|
+
if (events && events.length) {
|
723
|
+
for (i = 0, len = events.length; i < len; i++) {
|
724
|
+
eventName = events[i].toLowerCase().replace(/^on/, "");
|
725
|
+
perEventHandlers = handlers[eventName];
|
726
|
+
if (perEventHandlers && perEventHandlers.length) {
|
727
|
+
if (func) {
|
728
|
+
foundIndex = _inArray(func, perEventHandlers);
|
729
|
+
while (foundIndex !== -1) {
|
730
|
+
perEventHandlers.splice(foundIndex, 1);
|
731
|
+
foundIndex = _inArray(func, perEventHandlers, foundIndex);
|
732
|
+
}
|
733
|
+
} else {
|
734
|
+
handlers[eventName].length = 0;
|
735
|
+
}
|
736
|
+
}
|
737
|
+
}
|
738
|
+
}
|
356
739
|
return this;
|
357
740
|
};
|
358
|
-
ZeroClipboard.
|
359
|
-
|
741
|
+
ZeroClipboard.prototype.handlers = function(eventName) {
|
742
|
+
var prop, copy = null, handlers = _clientMeta[this.id] && _clientMeta[this.id].handlers;
|
743
|
+
if (handlers) {
|
744
|
+
if (typeof eventName === "string" && eventName) {
|
745
|
+
return handlers[eventName] ? handlers[eventName].slice(0) : null;
|
746
|
+
}
|
747
|
+
copy = {};
|
748
|
+
for (prop in handlers) {
|
749
|
+
if (handlers.hasOwnProperty(prop) && handlers[prop]) {
|
750
|
+
copy[prop] = handlers[prop].slice(0);
|
751
|
+
}
|
752
|
+
}
|
753
|
+
}
|
754
|
+
return copy;
|
755
|
+
};
|
756
|
+
var _dispatchClientCallbacks = function(eventName, context, args, async) {
|
757
|
+
var handlers = _clientMeta[this.id] && _clientMeta[this.id].handlers[eventName];
|
758
|
+
if (handlers && handlers.length) {
|
759
|
+
var i, len, func, originalContext = context || this;
|
760
|
+
for (i = 0, len = handlers.length; i < len; i++) {
|
761
|
+
func = handlers[i];
|
762
|
+
context = originalContext;
|
763
|
+
if (typeof func === "string" && typeof window[func] === "function") {
|
764
|
+
func = window[func];
|
765
|
+
}
|
766
|
+
if (typeof func === "object" && func && typeof func.handleEvent === "function") {
|
767
|
+
context = func;
|
768
|
+
func = func.handleEvent;
|
769
|
+
}
|
770
|
+
if (typeof func === "function") {
|
771
|
+
_dispatchCallback(func, context, args, async);
|
772
|
+
}
|
773
|
+
}
|
774
|
+
}
|
775
|
+
return this;
|
360
776
|
};
|
361
|
-
ZeroClipboard.prototype.
|
362
|
-
|
363
|
-
for (var i = 0; i <
|
364
|
-
|
365
|
-
|
777
|
+
ZeroClipboard.prototype.clip = function(elements) {
|
778
|
+
elements = _prepClip(elements);
|
779
|
+
for (var i = 0; i < elements.length; i++) {
|
780
|
+
if (elements.hasOwnProperty(i) && elements[i] && elements[i].nodeType === 1) {
|
781
|
+
if (!elements[i].zcClippingId) {
|
782
|
+
elements[i].zcClippingId = "zcClippingId_" + elementIdCounter++;
|
783
|
+
_elementMeta[elements[i].zcClippingId] = [ this.id ];
|
784
|
+
if (_globalConfig.autoActivate === true) {
|
785
|
+
_addEventHandler(elements[i], "mouseover", _elementMouseOver);
|
786
|
+
}
|
787
|
+
} else if (_inArray(this.id, _elementMeta[elements[i].zcClippingId]) === -1) {
|
788
|
+
_elementMeta[elements[i].zcClippingId].push(this.id);
|
789
|
+
}
|
790
|
+
var clippedElements = _clientMeta[this.id].elements;
|
791
|
+
if (_inArray(elements[i], clippedElements) === -1) {
|
792
|
+
clippedElements.push(elements[i]);
|
793
|
+
}
|
794
|
+
}
|
366
795
|
}
|
367
|
-
|
368
|
-
|
796
|
+
return this;
|
797
|
+
};
|
798
|
+
ZeroClipboard.prototype.unclip = function(elements) {
|
799
|
+
var meta = _clientMeta[this.id];
|
800
|
+
if (meta) {
|
801
|
+
var clippedElements = meta.elements;
|
802
|
+
var arrayIndex;
|
803
|
+
if (typeof elements === "undefined") {
|
804
|
+
elements = clippedElements.slice(0);
|
805
|
+
} else {
|
806
|
+
elements = _prepClip(elements);
|
807
|
+
}
|
808
|
+
for (var i = elements.length; i--; ) {
|
809
|
+
if (elements.hasOwnProperty(i) && elements[i] && elements[i].nodeType === 1) {
|
810
|
+
arrayIndex = 0;
|
811
|
+
while ((arrayIndex = _inArray(elements[i], clippedElements, arrayIndex)) !== -1) {
|
812
|
+
clippedElements.splice(arrayIndex, 1);
|
813
|
+
}
|
814
|
+
var clientIds = _elementMeta[elements[i].zcClippingId];
|
815
|
+
if (clientIds) {
|
816
|
+
arrayIndex = 0;
|
817
|
+
while ((arrayIndex = _inArray(this.id, clientIds, arrayIndex)) !== -1) {
|
818
|
+
clientIds.splice(arrayIndex, 1);
|
819
|
+
}
|
820
|
+
if (clientIds.length === 0) {
|
821
|
+
if (_globalConfig.autoActivate === true) {
|
822
|
+
_removeEventHandler(elements[i], "mouseover", _elementMouseOver);
|
823
|
+
}
|
824
|
+
delete elements[i].zcClippingId;
|
825
|
+
}
|
826
|
+
}
|
827
|
+
}
|
828
|
+
}
|
369
829
|
}
|
370
830
|
return this;
|
371
831
|
};
|
372
|
-
ZeroClipboard.prototype.
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
832
|
+
ZeroClipboard.prototype.elements = function() {
|
833
|
+
var meta = _clientMeta[this.id];
|
834
|
+
return meta && meta.elements ? meta.elements.slice(0) : [];
|
835
|
+
};
|
836
|
+
var _getAllClientsClippedToElement = function(element) {
|
837
|
+
var elementMetaId, clientIds, i, len, client, clients = [];
|
838
|
+
if (element && element.nodeType === 1 && (elementMetaId = element.zcClippingId) && _elementMeta.hasOwnProperty(elementMetaId)) {
|
839
|
+
clientIds = _elementMeta[elementMetaId];
|
840
|
+
if (clientIds && clientIds.length) {
|
841
|
+
for (i = 0, len = clientIds.length; i < len; i++) {
|
842
|
+
client = _clientMeta[clientIds[i]].instance;
|
843
|
+
if (client && client instanceof ZeroClipboard) {
|
844
|
+
clients.push(client);
|
845
|
+
}
|
380
846
|
}
|
381
847
|
}
|
382
848
|
}
|
849
|
+
return clients;
|
850
|
+
};
|
851
|
+
_globalConfig.hoverClass = "zeroclipboard-is-hover";
|
852
|
+
_globalConfig.activeClass = "zeroclipboard-is-active";
|
853
|
+
_globalConfig.trustedOrigins = null;
|
854
|
+
_globalConfig.allowScriptAccess = null;
|
855
|
+
_globalConfig.useNoCache = true;
|
856
|
+
_globalConfig.moviePath = "ZeroClipboard.swf";
|
857
|
+
ZeroClipboard.detectFlashSupport = function() {
|
858
|
+
_deprecationWarning("ZeroClipboard.detectFlashSupport", _globalConfig.debug);
|
859
|
+
return _detectFlashSupport();
|
860
|
+
};
|
861
|
+
ZeroClipboard.dispatch = function(eventName, args) {
|
862
|
+
if (typeof eventName === "string" && eventName) {
|
863
|
+
var cleanEventName = eventName.toLowerCase().replace(/^on/, "");
|
864
|
+
if (cleanEventName) {
|
865
|
+
var clients = currentElement ? _getAllClientsClippedToElement(currentElement) : _getAllClients();
|
866
|
+
for (var i = 0, len = clients.length; i < len; i++) {
|
867
|
+
_receiveEvent.call(clients[i], cleanEventName, args);
|
868
|
+
}
|
869
|
+
}
|
870
|
+
}
|
871
|
+
};
|
872
|
+
ZeroClipboard.prototype.setHandCursor = function(enabled) {
|
873
|
+
_deprecationWarning("ZeroClipboard.prototype.setHandCursor", _globalConfig.debug);
|
874
|
+
enabled = typeof enabled === "boolean" ? enabled : !!enabled;
|
875
|
+
_setHandCursor(enabled);
|
876
|
+
_globalConfig.forceHandCursor = enabled;
|
383
877
|
return this;
|
384
878
|
};
|
385
|
-
ZeroClipboard.prototype.
|
879
|
+
ZeroClipboard.prototype.reposition = function() {
|
880
|
+
_deprecationWarning("ZeroClipboard.prototype.reposition", _globalConfig.debug);
|
881
|
+
return _reposition();
|
882
|
+
};
|
386
883
|
ZeroClipboard.prototype.receiveEvent = function(eventName, args) {
|
387
|
-
|
884
|
+
_deprecationWarning("ZeroClipboard.prototype.receiveEvent", _globalConfig.debug);
|
885
|
+
if (typeof eventName === "string" && eventName) {
|
886
|
+
var cleanEventName = eventName.toLowerCase().replace(/^on/, "");
|
887
|
+
if (cleanEventName) {
|
888
|
+
_receiveEvent.call(this, cleanEventName, args);
|
889
|
+
}
|
890
|
+
}
|
891
|
+
};
|
892
|
+
ZeroClipboard.prototype.setCurrent = function(element) {
|
893
|
+
_deprecationWarning("ZeroClipboard.prototype.setCurrent", _globalConfig.debug);
|
894
|
+
ZeroClipboard.activate(element);
|
895
|
+
return this;
|
896
|
+
};
|
897
|
+
ZeroClipboard.prototype.resetBridge = function() {
|
898
|
+
_deprecationWarning("ZeroClipboard.prototype.resetBridge", _globalConfig.debug);
|
899
|
+
ZeroClipboard.deactivate();
|
900
|
+
return this;
|
901
|
+
};
|
902
|
+
ZeroClipboard.prototype.setTitle = function(newTitle) {
|
903
|
+
_deprecationWarning("ZeroClipboard.prototype.setTitle", _globalConfig.debug);
|
904
|
+
newTitle = newTitle || _globalConfig.title || currentElement && currentElement.getAttribute("title");
|
905
|
+
if (newTitle) {
|
906
|
+
var htmlBridge = _getHtmlBridge(flashState.bridge);
|
907
|
+
if (htmlBridge) {
|
908
|
+
htmlBridge.setAttribute("title", newTitle);
|
909
|
+
}
|
910
|
+
}
|
911
|
+
return this;
|
912
|
+
};
|
913
|
+
ZeroClipboard.setDefaults = function(options) {
|
914
|
+
_deprecationWarning("ZeroClipboard.setDefaults", _globalConfig.debug);
|
915
|
+
ZeroClipboard.config(options);
|
916
|
+
};
|
917
|
+
ZeroClipboard.prototype.addEventListener = function(eventName, func) {
|
918
|
+
_deprecationWarning("ZeroClipboard.prototype.addEventListener", _globalConfig.debug);
|
919
|
+
return this.on(eventName, func);
|
920
|
+
};
|
921
|
+
ZeroClipboard.prototype.removeEventListener = function(eventName, func) {
|
922
|
+
_deprecationWarning("ZeroClipboard.prototype.removeEventListener", _globalConfig.debug);
|
923
|
+
return this.off(eventName, func);
|
924
|
+
};
|
925
|
+
ZeroClipboard.prototype.ready = function() {
|
926
|
+
_deprecationWarning("ZeroClipboard.prototype.ready", _globalConfig.debug);
|
927
|
+
return flashState.ready === true;
|
928
|
+
};
|
929
|
+
var _receiveEvent = function(eventName, args) {
|
930
|
+
eventName = eventName.toLowerCase().replace(/^on/, "");
|
931
|
+
var cleanVersion = args && args.flashVersion && _parseFlashVersion(args.flashVersion) || null;
|
388
932
|
var element = currentElement;
|
389
933
|
var performCallbackAsync = true;
|
390
934
|
switch (eventName) {
|
391
935
|
case "load":
|
392
|
-
if (
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
936
|
+
if (cleanVersion) {
|
937
|
+
if (!_isFlashVersionSupported(cleanVersion)) {
|
938
|
+
_receiveEvent.call(this, "onWrongFlash", {
|
939
|
+
flashVersion: cleanVersion
|
940
|
+
});
|
941
|
+
return;
|
942
|
+
}
|
943
|
+
flashState.outdated = false;
|
944
|
+
flashState.ready = true;
|
945
|
+
flashState.version = cleanVersion;
|
946
|
+
}
|
947
|
+
break;
|
948
|
+
|
949
|
+
case "wrongflash":
|
950
|
+
if (cleanVersion && !_isFlashVersionSupported(cleanVersion)) {
|
951
|
+
flashState.outdated = true;
|
952
|
+
flashState.ready = false;
|
953
|
+
flashState.version = cleanVersion;
|
397
954
|
}
|
398
|
-
this.htmlBridge.setAttribute("data-clipboard-ready", true);
|
399
955
|
break;
|
400
956
|
|
401
957
|
case "mouseover":
|
402
|
-
_addClass(element,
|
958
|
+
_addClass(element, _globalConfig.hoverClass);
|
403
959
|
break;
|
404
960
|
|
405
961
|
case "mouseout":
|
406
|
-
|
407
|
-
|
962
|
+
if (_globalConfig.autoActivate === true) {
|
963
|
+
ZeroClipboard.deactivate();
|
964
|
+
}
|
408
965
|
break;
|
409
966
|
|
410
967
|
case "mousedown":
|
411
|
-
_addClass(element,
|
968
|
+
_addClass(element, _globalConfig.activeClass);
|
412
969
|
break;
|
413
970
|
|
414
971
|
case "mouseup":
|
415
|
-
_removeClass(element,
|
972
|
+
_removeClass(element, _globalConfig.activeClass);
|
416
973
|
break;
|
417
974
|
|
418
975
|
case "datarequested":
|
419
976
|
var targetId = element.getAttribute("data-clipboard-target"), targetEl = !targetId ? null : document.getElementById(targetId);
|
420
977
|
if (targetEl) {
|
421
978
|
var textContent = targetEl.value || targetEl.textContent || targetEl.innerText;
|
422
|
-
if (textContent)
|
979
|
+
if (textContent) {
|
980
|
+
this.setText(textContent);
|
981
|
+
}
|
423
982
|
} else {
|
424
983
|
var defaultText = element.getAttribute("data-clipboard-text");
|
425
|
-
if (defaultText)
|
984
|
+
if (defaultText) {
|
985
|
+
this.setText(defaultText);
|
986
|
+
}
|
426
987
|
}
|
427
988
|
performCallbackAsync = false;
|
428
989
|
break;
|
429
990
|
|
430
991
|
case "complete":
|
431
|
-
|
992
|
+
_deleteOwnProperties(_clipData);
|
432
993
|
break;
|
433
994
|
}
|
434
|
-
|
435
|
-
|
436
|
-
|
437
|
-
func = window[func];
|
438
|
-
}
|
439
|
-
if (typeof func === "function") {
|
440
|
-
_dispatchCallback(func, element, this, args, performCallbackAsync);
|
441
|
-
}
|
442
|
-
}
|
443
|
-
};
|
444
|
-
ZeroClipboard.prototype.glue = function(elements) {
|
445
|
-
elements = _prepGlue(elements);
|
446
|
-
for (var i = 0; i < elements.length; i++) {
|
447
|
-
if (_inArray(elements[i], gluedElements) == -1) {
|
448
|
-
gluedElements.push(elements[i]);
|
449
|
-
_addEventHandler(elements[i], "mouseover", _elementMouseOver);
|
450
|
-
}
|
451
|
-
}
|
452
|
-
return this;
|
453
|
-
};
|
454
|
-
ZeroClipboard.prototype.unglue = function(elements) {
|
455
|
-
elements = _prepGlue(elements);
|
456
|
-
for (var i = 0; i < elements.length; i++) {
|
457
|
-
_removeEventHandler(elements[i], "mouseover", _elementMouseOver);
|
458
|
-
var arrayIndex = _inArray(elements[i], gluedElements);
|
459
|
-
if (arrayIndex != -1) gluedElements.splice(arrayIndex, 1);
|
460
|
-
}
|
461
|
-
return this;
|
995
|
+
var context = element;
|
996
|
+
var eventArgs = [ this, args ];
|
997
|
+
return _dispatchClientCallbacks.call(this, eventName, context, eventArgs, performCallbackAsync);
|
462
998
|
};
|
463
999
|
if (typeof define === "function" && define.amd) {
|
464
1000
|
define([ "require", "exports", "module" ], function(require, exports, module) {
|
@@ -471,4 +1007,4 @@
|
|
471
1007
|
} else {
|
472
1008
|
window.ZeroClipboard = ZeroClipboard;
|
473
1009
|
}
|
474
|
-
})();
|
1010
|
+
})();
|
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
|
+
version: 0.0.11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Henrik Wenz
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2014-01-31 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: railties
|
@@ -60,7 +60,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
60
60
|
version: '0'
|
61
61
|
requirements: []
|
62
62
|
rubyforge_project:
|
63
|
-
rubygems_version: 2.0.
|
63
|
+
rubygems_version: 2.0.14
|
64
64
|
signing_key:
|
65
65
|
specification_version: 4
|
66
66
|
summary: Adds the Javascript ZeroClipboard libary to Rails
|