@lingxiteam/lcdp-ueditor-react 1.0.3-alpha.4 → 1.0.3-alpha.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (76) hide show
  1. package/es/LcdpUeditor.js +52 -40
  2. package/es/const.js +4 -4
  3. package/es/defaultConfig.json +76 -76
  4. package/es/tools/UeditorResourceLoader.js +6 -6
  5. package/es/tools/loadScript.js +3 -3
  6. package/lib/LcdpUeditor.js +16 -5
  7. package/lib/defaultConfig.json +76 -76
  8. package/package.json +35 -35
  9. package/ueditor-resource/dialogs/anchor/anchor.html +62 -62
  10. package/ueditor-resource/dialogs/attachment/attachment.css +2 -2
  11. package/ueditor-resource/dialogs/attachment/attachment.html +61 -61
  12. package/ueditor-resource/dialogs/audio/audio.css +2 -2
  13. package/ueditor-resource/dialogs/audio/audio.html +93 -93
  14. package/ueditor-resource/dialogs/background/background.css +2 -2
  15. package/ueditor-resource/dialogs/background/background.html +59 -59
  16. package/ueditor-resource/dialogs/contentimport/contentimport.html +176 -176
  17. package/ueditor-resource/dialogs/emotion/emotion.css +2 -2
  18. package/ueditor-resource/dialogs/emotion/emotion.html +70 -70
  19. package/ueditor-resource/dialogs/formula/formula.html +98 -98
  20. package/ueditor-resource/dialogs/help/help.css +2 -2
  21. package/ueditor-resource/dialogs/help/help.html +82 -82
  22. package/ueditor-resource/dialogs/image/image.css +2 -2
  23. package/ueditor-resource/dialogs/image/image.html +144 -144
  24. package/ueditor-resource/dialogs/insertframe/insertframe.html +135 -135
  25. package/ueditor-resource/dialogs/link/link.html +148 -148
  26. package/ueditor-resource/dialogs/preview/preview.html +45 -45
  27. package/ueditor-resource/dialogs/scrawl/scrawl.css +2 -2
  28. package/ueditor-resource/dialogs/scrawl/scrawl.html +95 -95
  29. package/ueditor-resource/dialogs/searchreplace/searchreplace.html +144 -144
  30. package/ueditor-resource/dialogs/spechars/spechars.html +42 -42
  31. package/ueditor-resource/dialogs/table/edittable.css +2 -2
  32. package/ueditor-resource/dialogs/table/edittable.html +69 -69
  33. package/ueditor-resource/dialogs/table/edittd.html +62 -62
  34. package/ueditor-resource/dialogs/table/edittip.html +33 -33
  35. package/ueditor-resource/dialogs/template/template.css +2 -2
  36. package/ueditor-resource/dialogs/template/template.html +26 -26
  37. package/ueditor-resource/dialogs/video/video.css +2 -2
  38. package/ueditor-resource/dialogs/video/video.html +114 -114
  39. package/ueditor-resource/dialogs/wordimage/wordimage.html +221 -221
  40. package/ueditor-resource/themes/default/css/ueditor.css +2 -2
  41. package/ueditor-resource/themes/default/dialog.css +2 -2
  42. package/ueditor-resource/themes/default/dialogbase.css +2 -2
  43. package/ueditor-resource/themes/default/exts/ai.svg +12 -12
  44. package/ueditor-resource/themes/default/exts/apk.svg +12 -12
  45. package/ueditor-resource/themes/default/exts/chm.svg +12 -12
  46. package/ueditor-resource/themes/default/exts/css.svg +12 -12
  47. package/ueditor-resource/themes/default/exts/doc.svg +22 -22
  48. package/ueditor-resource/themes/default/exts/docx.svg +22 -22
  49. package/ueditor-resource/themes/default/exts/dwg.svg +16 -16
  50. package/ueditor-resource/themes/default/exts/folder.svg +3 -3
  51. package/ueditor-resource/themes/default/exts/gif.svg +14 -14
  52. package/ueditor-resource/themes/default/exts/html.svg +12 -12
  53. package/ueditor-resource/themes/default/exts/jpeg.svg +14 -14
  54. package/ueditor-resource/themes/default/exts/jpg.svg +14 -14
  55. package/ueditor-resource/themes/default/exts/log.svg +12 -12
  56. package/ueditor-resource/themes/default/exts/mp3.svg +14 -14
  57. package/ueditor-resource/themes/default/exts/mp4.svg +12 -12
  58. package/ueditor-resource/themes/default/exts/pdf.svg +14 -14
  59. package/ueditor-resource/themes/default/exts/png.svg +14 -14
  60. package/ueditor-resource/themes/default/exts/ppt.svg +24 -24
  61. package/ueditor-resource/themes/default/exts/pptx.svg +24 -24
  62. package/ueditor-resource/themes/default/exts/psd.svg +12 -12
  63. package/ueditor-resource/themes/default/exts/rar.svg +12 -12
  64. package/ueditor-resource/themes/default/exts/svg.svg +12 -12
  65. package/ueditor-resource/themes/default/exts/torrent.svg +14 -14
  66. package/ueditor-resource/themes/default/exts/txt.svg +14 -14
  67. package/ueditor-resource/themes/default/exts/unknown.svg +12 -12
  68. package/ueditor-resource/themes/default/exts/xls.svg +25 -25
  69. package/ueditor-resource/themes/default/exts/xlsx.svg +25 -25
  70. package/ueditor-resource/themes/default/exts/zip.svg +12 -12
  71. package/ueditor-resource/themes/iframe.css +2 -2
  72. package/ueditor-resource/third-party/SyntaxHighlighter/shCoreDefault.css +2 -2
  73. package/ueditor-resource/third-party/codemirror/codemirror.css +2 -2
  74. package/ueditor-resource/third-party/webuploader/webuploader.css +2 -2
  75. package/ueditor-resource/third-party/zeroclipboard/ZeroClipboard.js +1255 -1255
  76. package/ueditor-resource/ueditor.all.js +3 -3
@@ -1,1256 +1,1256 @@
1
- /*!
2
- * ZeroClipboard
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) 2014 Jon Rohan, James M. Greene
5
- * Licensed MIT
6
- * http://zeroclipboard.org/
7
- * v2.0.0-beta.5
8
- */
9
- (function(window) {
10
- "use strict";
11
- var _currentElement;
12
- var _flashState = {
13
- bridge: null,
14
- version: "0.0.0",
15
- pluginType: "unknown",
16
- disabled: null,
17
- outdated: null,
18
- unavailable: null,
19
- deactivated: null,
20
- overdue: null,
21
- ready: null
22
- };
23
- var _clipData = {};
24
- var _clipDataFormatMap = null;
25
- var _clientIdCounter = 0;
26
- var _clientMeta = {};
27
- var _elementIdCounter = 0;
28
- var _elementMeta = {};
29
- var _swfPath = function() {
30
- var i, jsDir, tmpJsPath, jsPath, swfPath = "ZeroClipboard.swf";
31
- if (!(document.currentScript && (jsPath = document.currentScript.src))) {
32
- var scripts = document.getElementsByTagName("script");
33
- if ("readyState" in scripts[0]) {
34
- for (i = scripts.length; i--; ) {
35
- if (scripts[i].readyState === "interactive" && (jsPath = scripts[i].src)) {
36
- break;
37
- }
38
- }
39
- } else if (document.readyState === "loading") {
40
- jsPath = scripts[scripts.length - 1].src;
41
- } else {
42
- for (i = scripts.length; i--; ) {
43
- tmpJsPath = scripts[i].src;
44
- if (!tmpJsPath) {
45
- jsDir = null;
46
- break;
47
- }
48
- tmpJsPath = tmpJsPath.split("#")[0].split("?")[0];
49
- tmpJsPath = tmpJsPath.slice(0, tmpJsPath.lastIndexOf("/") + 1);
50
- if (jsDir == null) {
51
- jsDir = tmpJsPath;
52
- } else if (jsDir !== tmpJsPath) {
53
- jsDir = null;
54
- break;
55
- }
56
- }
57
- if (jsDir !== null) {
58
- jsPath = jsDir;
59
- }
60
- }
61
- }
62
- if (jsPath) {
63
- jsPath = jsPath.split("#")[0].split("?")[0];
64
- swfPath = jsPath.slice(0, jsPath.lastIndexOf("/") + 1) + swfPath;
65
- }
66
- return swfPath;
67
- }();
68
- var _camelizeCssPropName = function() {
69
- var matcherRegex = /\-([a-z])/g, replacerFn = function(match, group) {
70
- return group.toUpperCase();
71
- };
72
- return function(prop) {
73
- return prop.replace(matcherRegex, replacerFn);
74
- };
75
- }();
76
- var _getStyle = function(el, prop) {
77
- var value, camelProp, tagName;
78
- if (window.getComputedStyle) {
79
- value = window.getComputedStyle(el, null).getPropertyValue(prop);
80
- } else {
81
- camelProp = _camelizeCssPropName(prop);
82
- if (el.currentStyle) {
83
- value = el.currentStyle[camelProp];
84
- } else {
85
- value = el.style[camelProp];
86
- }
87
- }
88
- if (prop === "cursor") {
89
- if (!value || value === "auto") {
90
- tagName = el.tagName.toLowerCase();
91
- if (tagName === "a") {
92
- return "pointer";
93
- }
94
- }
95
- }
96
- return value;
97
- };
98
- var _elementMouseOver = function(event) {
99
- if (!event) {
100
- event = window.event;
101
- }
102
- var target;
103
- if (this !== window) {
104
- target = this;
105
- } else if (event.target) {
106
- target = event.target;
107
- } else if (event.srcElement) {
108
- target = event.srcElement;
109
- }
110
- ZeroClipboard.activate(target);
111
- };
112
- var _addEventHandler = function(element, method, func) {
113
- if (!element || element.nodeType !== 1) {
114
- return;
115
- }
116
- if (element.addEventListener) {
117
- element.addEventListener(method, func, false);
118
- } else if (element.attachEvent) {
119
- element.attachEvent("on" + method, func);
120
- }
121
- };
122
- var _removeEventHandler = function(element, method, func) {
123
- if (!element || element.nodeType !== 1) {
124
- return;
125
- }
126
- if (element.removeEventListener) {
127
- element.removeEventListener(method, func, false);
128
- } else if (element.detachEvent) {
129
- element.detachEvent("on" + method, func);
130
- }
131
- };
132
- var _addClass = function(element, value) {
133
- if (!element || element.nodeType !== 1) {
134
- return element;
135
- }
136
- if (element.classList) {
137
- if (!element.classList.contains(value)) {
138
- element.classList.add(value);
139
- }
140
- return element;
141
- }
142
- if (value && typeof value === "string") {
143
- var classNames = (value || "").split(/\s+/);
144
- if (element.nodeType === 1) {
145
- if (!element.className) {
146
- element.className = value;
147
- } else {
148
- var className = " " + element.className + " ", setClass = element.className;
149
- for (var c = 0, cl = classNames.length; c < cl; c++) {
150
- if (className.indexOf(" " + classNames[c] + " ") < 0) {
151
- setClass += " " + classNames[c];
152
- }
153
- }
154
- element.className = setClass.replace(/^\s+|\s+$/g, "");
155
- }
156
- }
157
- }
158
- return element;
159
- };
160
- var _removeClass = function(element, value) {
161
- if (!element || element.nodeType !== 1) {
162
- return element;
163
- }
164
- if (element.classList) {
165
- if (element.classList.contains(value)) {
166
- element.classList.remove(value);
167
- }
168
- return element;
169
- }
170
- if (value && typeof value === "string" || value === undefined) {
171
- var classNames = (value || "").split(/\s+/);
172
- if (element.nodeType === 1 && element.className) {
173
- if (value) {
174
- var className = (" " + element.className + " ").replace(/[\n\t]/g, " ");
175
- for (var c = 0, cl = classNames.length; c < cl; c++) {
176
- className = className.replace(" " + classNames[c] + " ", " ");
177
- }
178
- element.className = className.replace(/^\s+|\s+$/g, "");
179
- } else {
180
- element.className = "";
181
- }
182
- }
183
- }
184
- return element;
185
- };
186
- var _getZoomFactor = function() {
187
- var rect, physicalWidth, logicalWidth, zoomFactor = 1;
188
- if (typeof document.body.getBoundingClientRect === "function") {
189
- rect = document.body.getBoundingClientRect();
190
- physicalWidth = rect.right - rect.left;
191
- logicalWidth = document.body.offsetWidth;
192
- zoomFactor = Math.round(physicalWidth / logicalWidth * 100) / 100;
193
- }
194
- return zoomFactor;
195
- };
196
- var _getDOMObjectPosition = function(obj, defaultZIndex) {
197
- var info = {
198
- left: 0,
199
- top: 0,
200
- width: 0,
201
- height: 0,
202
- zIndex: _getSafeZIndex(defaultZIndex) - 1
203
- };
204
- if (obj.getBoundingClientRect) {
205
- var rect = obj.getBoundingClientRect();
206
- var pageXOffset, pageYOffset, zoomFactor;
207
- if ("pageXOffset" in window && "pageYOffset" in window) {
208
- pageXOffset = window.pageXOffset;
209
- pageYOffset = window.pageYOffset;
210
- } else {
211
- zoomFactor = _getZoomFactor();
212
- pageXOffset = Math.round(document.documentElement.scrollLeft / zoomFactor);
213
- pageYOffset = Math.round(document.documentElement.scrollTop / zoomFactor);
214
- }
215
- var leftBorderWidth = document.documentElement.clientLeft || 0;
216
- var topBorderWidth = document.documentElement.clientTop || 0;
217
- info.left = rect.left + pageXOffset - leftBorderWidth;
218
- info.top = rect.top + pageYOffset - topBorderWidth;
219
- info.width = "width" in rect ? rect.width : rect.right - rect.left;
220
- info.height = "height" in rect ? rect.height : rect.bottom - rect.top;
221
- }
222
- return info;
223
- };
224
- var _cacheBust = function(path, options) {
225
- var cacheBust = options == null || options && options.cacheBust === true;
226
- if (cacheBust) {
227
- return (path.indexOf("?") === -1 ? "?" : "&") + "noCache=" + new Date().getTime();
228
- } else {
229
- return "";
230
- }
231
- };
232
- var _vars = function(options) {
233
- var i, len, domain, domains, str = "", trustedOriginsExpanded = [];
234
- if (options.trustedDomains) {
235
- if (typeof options.trustedDomains === "string") {
236
- domains = [ options.trustedDomains ];
237
- } else if (typeof options.trustedDomains === "object" && "length" in options.trustedDomains) {
238
- domains = options.trustedDomains;
239
- }
240
- }
241
- if (domains && domains.length) {
242
- for (i = 0, len = domains.length; i < len; i++) {
243
- if (domains.hasOwnProperty(i) && domains[i] && typeof domains[i] === "string") {
244
- domain = _extractDomain(domains[i]);
245
- if (!domain) {
246
- continue;
247
- }
248
- if (domain === "*") {
249
- trustedOriginsExpanded = [ domain ];
250
- break;
251
- }
252
- trustedOriginsExpanded.push.apply(trustedOriginsExpanded, [ domain, "//" + domain, window.location.protocol + "//" + domain ]);
253
- }
254
- }
255
- }
256
- if (trustedOriginsExpanded.length) {
257
- str += "trustedOrigins=" + encodeURIComponent(trustedOriginsExpanded.join(","));
258
- }
259
- if (options.forceEnhancedClipboard === true) {
260
- str += (str ? "&" : "") + "forceEnhancedClipboard=true";
261
- }
262
- return str;
263
- };
264
- var _inArray = function(elem, array, fromIndex) {
265
- if (typeof array.indexOf === "function") {
266
- return array.indexOf(elem, fromIndex);
267
- }
268
- var i, len = array.length;
269
- if (typeof fromIndex === "undefined") {
270
- fromIndex = 0;
271
- } else if (fromIndex < 0) {
272
- fromIndex = len + fromIndex;
273
- }
274
- for (i = fromIndex; i < len; i++) {
275
- if (array.hasOwnProperty(i) && array[i] === elem) {
276
- return i;
277
- }
278
- }
279
- return -1;
280
- };
281
- var _prepClip = function(elements) {
282
- if (typeof elements === "string") {
283
- throw new TypeError("ZeroClipboard doesn't accept query strings.");
284
- }
285
- return typeof elements.length !== "number" ? [ elements ] : elements;
286
- };
287
- var _dispatchCallback = function(func, context, args, async) {
288
- if (async) {
289
- window.setTimeout(function() {
290
- func.apply(context, args);
291
- }, 0);
292
- } else {
293
- func.apply(context, args);
294
- }
295
- };
296
- var _getSafeZIndex = function(val) {
297
- var zIndex, tmp;
298
- if (val) {
299
- if (typeof val === "number" && val > 0) {
300
- zIndex = val;
301
- } else if (typeof val === "string" && (tmp = parseInt(val, 10)) && !isNaN(tmp) && tmp > 0) {
302
- zIndex = tmp;
303
- }
304
- }
305
- if (!zIndex) {
306
- if (typeof _globalConfig.zIndex === "number" && _globalConfig.zIndex > 0) {
307
- zIndex = _globalConfig.zIndex;
308
- } else if (typeof _globalConfig.zIndex === "string" && (tmp = parseInt(_globalConfig.zIndex, 10)) && !isNaN(tmp) && tmp > 0) {
309
- zIndex = tmp;
310
- }
311
- }
312
- return zIndex || 0;
313
- };
314
- var _extend = function() {
315
- var i, len, arg, prop, src, copy, target = arguments[0] || {};
316
- for (i = 1, len = arguments.length; i < len; i++) {
317
- if ((arg = arguments[i]) != null) {
318
- for (prop in arg) {
319
- if (arg.hasOwnProperty(prop)) {
320
- src = target[prop];
321
- copy = arg[prop];
322
- if (target === copy) {
323
- continue;
324
- }
325
- if (copy !== undefined) {
326
- target[prop] = copy;
327
- }
328
- }
329
- }
330
- }
331
- }
332
- return target;
333
- };
334
- var _extractDomain = function(originOrUrl) {
335
- if (originOrUrl == null || originOrUrl === "") {
336
- return null;
337
- }
338
- originOrUrl = originOrUrl.replace(/^\s+|\s+$/g, "");
339
- if (originOrUrl === "") {
340
- return null;
341
- }
342
- var protocolIndex = originOrUrl.indexOf("//");
343
- originOrUrl = protocolIndex === -1 ? originOrUrl : originOrUrl.slice(protocolIndex + 2);
344
- var pathIndex = originOrUrl.indexOf("/");
345
- originOrUrl = pathIndex === -1 ? originOrUrl : protocolIndex === -1 || pathIndex === 0 ? null : originOrUrl.slice(0, pathIndex);
346
- if (originOrUrl && originOrUrl.slice(-4).toLowerCase() === ".swf") {
347
- return null;
348
- }
349
- return originOrUrl || null;
350
- };
351
- var _determineScriptAccess = function() {
352
- var _extractAllDomains = function(origins, resultsArray) {
353
- var i, len, tmp;
354
- if (origins == null || resultsArray[0] === "*") {
355
- return;
356
- }
357
- if (typeof origins === "string") {
358
- origins = [ origins ];
359
- }
360
- if (!(typeof origins === "object" && typeof origins.length === "number")) {
361
- return;
362
- }
363
- for (i = 0, len = origins.length; i < len; i++) {
364
- if (origins.hasOwnProperty(i) && (tmp = _extractDomain(origins[i]))) {
365
- if (tmp === "*") {
366
- resultsArray.length = 0;
367
- resultsArray.push("*");
368
- break;
369
- }
370
- if (_inArray(tmp, resultsArray) === -1) {
371
- resultsArray.push(tmp);
372
- }
373
- }
374
- }
375
- };
376
- return function(currentDomain, configOptions) {
377
- var swfDomain = _extractDomain(configOptions.swfPath);
378
- if (swfDomain === null) {
379
- swfDomain = currentDomain;
380
- }
381
- var trustedDomains = [];
382
- _extractAllDomains(configOptions.trustedOrigins, trustedDomains);
383
- _extractAllDomains(configOptions.trustedDomains, trustedDomains);
384
- var len = trustedDomains.length;
385
- if (len > 0) {
386
- if (len === 1 && trustedDomains[0] === "*") {
387
- return "always";
388
- }
389
- if (_inArray(currentDomain, trustedDomains) !== -1) {
390
- if (len === 1 && currentDomain === swfDomain) {
391
- return "sameDomain";
392
- }
393
- return "always";
394
- }
395
- }
396
- return "never";
397
- };
398
- }();
399
- var _objectKeys = function(obj) {
400
- if (obj == null) {
401
- return [];
402
- }
403
- if (Object.keys) {
404
- return Object.keys(obj);
405
- }
406
- var keys = [];
407
- for (var prop in obj) {
408
- if (obj.hasOwnProperty(prop)) {
409
- keys.push(prop);
410
- }
411
- }
412
- return keys;
413
- };
414
- var _deleteOwnProperties = function(obj) {
415
- if (obj) {
416
- for (var prop in obj) {
417
- if (obj.hasOwnProperty(prop)) {
418
- delete obj[prop];
419
- }
420
- }
421
- }
422
- return obj;
423
- };
424
- var _safeActiveElement = function() {
425
- try {
426
- return document.activeElement;
427
- } catch (err) {}
428
- return null;
429
- };
430
- var _pick = function(obj, keys) {
431
- var newObj = {};
432
- for (var i = 0, len = keys.length; i < len; i++) {
433
- if (keys[i] in obj) {
434
- newObj[keys[i]] = obj[keys[i]];
435
- }
436
- }
437
- return newObj;
438
- };
439
- var _omit = function(obj, keys) {
440
- var newObj = {};
441
- for (var prop in obj) {
442
- if (_inArray(prop, keys) === -1) {
443
- newObj[prop] = obj[prop];
444
- }
445
- }
446
- return newObj;
447
- };
448
- var _mapClipDataToFlash = function(clipData) {
449
- var newClipData = {}, formatMap = {};
450
- if (!(typeof clipData === "object" && clipData)) {
451
- return;
452
- }
453
- for (var dataFormat in clipData) {
454
- if (dataFormat && clipData.hasOwnProperty(dataFormat) && typeof clipData[dataFormat] === "string" && clipData[dataFormat]) {
455
- switch (dataFormat.toLowerCase()) {
456
- case "text/plain":
457
- case "text":
458
- case "air:text":
459
- case "flash:text":
460
- newClipData.text = clipData[dataFormat];
461
- formatMap.text = dataFormat;
462
- break;
463
-
464
- case "text/html":
465
- case "html":
466
- case "air:html":
467
- case "flash:html":
468
- newClipData.html = clipData[dataFormat];
469
- formatMap.html = dataFormat;
470
- break;
471
-
472
- case "application/rtf":
473
- case "text/rtf":
474
- case "rtf":
475
- case "richtext":
476
- case "air:rtf":
477
- case "flash:rtf":
478
- newClipData.rtf = clipData[dataFormat];
479
- formatMap.rtf = dataFormat;
480
- break;
481
-
482
- default:
483
- break;
484
- }
485
- }
486
- }
487
- return {
488
- data: newClipData,
489
- formatMap: formatMap
490
- };
491
- };
492
- var _mapClipResultsFromFlash = function(clipResults, formatMap) {
493
- if (!(typeof clipResults === "object" && clipResults && typeof formatMap === "object" && formatMap)) {
494
- return clipResults;
495
- }
496
- var newResults = {};
497
- for (var prop in clipResults) {
498
- if (clipResults.hasOwnProperty(prop)) {
499
- if (prop !== "success" && prop !== "data") {
500
- newResults[prop] = clipResults[prop];
501
- continue;
502
- }
503
- newResults[prop] = {};
504
- var tmpHash = clipResults[prop];
505
- for (var dataFormat in tmpHash) {
506
- if (dataFormat && tmpHash.hasOwnProperty(dataFormat) && formatMap.hasOwnProperty(dataFormat)) {
507
- newResults[prop][formatMap[dataFormat]] = tmpHash[dataFormat];
508
- }
509
- }
510
- }
511
- }
512
- return newResults;
513
- };
514
- var _args = function(arraySlice) {
515
- return function(args) {
516
- return arraySlice.call(args, 0);
517
- };
518
- }(window.Array.prototype.slice);
519
- var _detectFlashSupport = function() {
520
- var plugin, ax, mimeType, hasFlash = false, isActiveX = false, isPPAPI = false, flashVersion = "";
521
- function parseFlashVersion(desc) {
522
- var matches = desc.match(/[\d]+/g);
523
- matches.length = 3;
524
- return matches.join(".");
525
- }
526
- function isPepperFlash(flashPlayerFileName) {
527
- return !!flashPlayerFileName && (flashPlayerFileName = flashPlayerFileName.toLowerCase()) && (/^(pepflashplayer\.dll|libpepflashplayer\.so|pepperflashplayer\.plugin)$/.test(flashPlayerFileName) || flashPlayerFileName.slice(-13) === "chrome.plugin");
528
- }
529
- function inspectPlugin(plugin) {
530
- if (plugin) {
531
- hasFlash = true;
532
- if (plugin.version) {
533
- flashVersion = parseFlashVersion(plugin.version);
534
- }
535
- if (!flashVersion && plugin.description) {
536
- flashVersion = parseFlashVersion(plugin.description);
537
- }
538
- if (plugin.filename) {
539
- isPPAPI = isPepperFlash(plugin.filename);
540
- }
541
- }
542
- }
543
- if (navigator.plugins && navigator.plugins.length) {
544
- plugin = navigator.plugins["Shockwave Flash"];
545
- inspectPlugin(plugin);
546
- if (navigator.plugins["Shockwave Flash 2.0"]) {
547
- hasFlash = true;
548
- flashVersion = "2.0.0.11";
549
- }
550
- } else if (navigator.mimeTypes && navigator.mimeTypes.length) {
551
- mimeType = navigator.mimeTypes["application/x-shockwave-flash"];
552
- plugin = mimeType && mimeType.enabledPlugin;
553
- inspectPlugin(plugin);
554
- } else if (typeof ActiveXObject !== "undefined") {
555
- isActiveX = true;
556
- try {
557
- ax = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");
558
- hasFlash = true;
559
- flashVersion = parseFlashVersion(ax.GetVariable("$version"));
560
- } catch (e1) {
561
- try {
562
- ax = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");
563
- hasFlash = true;
564
- flashVersion = "6.0.21";
565
- } catch (e2) {
566
- try {
567
- ax = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
568
- hasFlash = true;
569
- flashVersion = parseFlashVersion(ax.GetVariable("$version"));
570
- } catch (e3) {
571
- isActiveX = false;
572
- }
573
- }
574
- }
575
- }
576
- _flashState.disabled = hasFlash !== true;
577
- _flashState.outdated = flashVersion && parseFloat(flashVersion) < 11;
578
- _flashState.version = flashVersion || "0.0.0";
579
- _flashState.pluginType = isPPAPI ? "pepper" : isActiveX ? "activex" : hasFlash ? "netscape" : "unknown";
580
- };
581
- _detectFlashSupport();
582
- var ZeroClipboard = function(elements) {
583
- if (!(this instanceof ZeroClipboard)) {
584
- return new ZeroClipboard(elements);
585
- }
586
- this.id = "" + _clientIdCounter++;
587
- _clientMeta[this.id] = {
588
- instance: this,
589
- elements: [],
590
- handlers: {}
591
- };
592
- if (elements) {
593
- this.clip(elements);
594
- }
595
- if (typeof _flashState.ready !== "boolean") {
596
- _flashState.ready = false;
597
- }
598
- if (!ZeroClipboard.isFlashUnusable() && _flashState.bridge === null) {
599
- var _client = this;
600
- var maxWait = _globalConfig.flashLoadTimeout;
601
- if (typeof maxWait === "number" && maxWait >= 0) {
602
- setTimeout(function() {
603
- if (typeof _flashState.deactivated !== "boolean") {
604
- _flashState.deactivated = true;
605
- }
606
- if (_flashState.deactivated === true) {
607
- ZeroClipboard.emit({
608
- type: "error",
609
- name: "flash-deactivated",
610
- client: _client
611
- });
612
- }
613
- }, maxWait);
614
- }
615
- _flashState.overdue = false;
616
- _bridge();
617
- }
618
- };
619
- ZeroClipboard.prototype.setText = function(text) {
620
- ZeroClipboard.setData("text/plain", text);
621
- return this;
622
- };
623
- ZeroClipboard.prototype.setHtml = function(html) {
624
- ZeroClipboard.setData("text/html", html);
625
- return this;
626
- };
627
- ZeroClipboard.prototype.setRichText = function(richText) {
628
- ZeroClipboard.setData("application/rtf", richText);
629
- return this;
630
- };
631
- ZeroClipboard.prototype.setData = function() {
632
- ZeroClipboard.setData.apply(ZeroClipboard, _args(arguments));
633
- return this;
634
- };
635
- ZeroClipboard.prototype.clearData = function() {
636
- ZeroClipboard.clearData.apply(ZeroClipboard, _args(arguments));
637
- return this;
638
- };
639
- ZeroClipboard.prototype.setSize = function(width, height) {
640
- _setSize(width, height);
641
- return this;
642
- };
643
- var _setHandCursor = function(enabled) {
644
- if (_flashState.ready === true && _flashState.bridge && typeof _flashState.bridge.setHandCursor === "function") {
645
- _flashState.bridge.setHandCursor(enabled);
646
- } else {
647
- _flashState.ready = false;
648
- }
649
- };
650
- ZeroClipboard.prototype.destroy = function() {
651
- this.unclip();
652
- this.off();
653
- delete _clientMeta[this.id];
654
- };
655
- var _getAllClients = function() {
656
- var i, len, client, clients = [], clientIds = _objectKeys(_clientMeta);
657
- for (i = 0, len = clientIds.length; i < len; i++) {
658
- client = _clientMeta[clientIds[i]].instance;
659
- if (client && client instanceof ZeroClipboard) {
660
- clients.push(client);
661
- }
662
- }
663
- return clients;
664
- };
665
- ZeroClipboard.version = "2.0.0-beta.5";
666
- var _globalConfig = {
667
- swfPath: _swfPath,
668
- trustedDomains: window.location.host ? [ window.location.host ] : [],
669
- cacheBust: true,
670
- forceHandCursor: false,
671
- forceEnhancedClipboard: false,
672
- zIndex: 999999999,
673
- debug: false,
674
- title: null,
675
- autoActivate: true,
676
- flashLoadTimeout: 3e4
677
- };
678
- ZeroClipboard.isFlashUnusable = function() {
679
- return !!(_flashState.disabled || _flashState.outdated || _flashState.unavailable || _flashState.deactivated);
680
- };
681
- ZeroClipboard.config = function(options) {
682
- if (typeof options === "object" && options !== null) {
683
- _extend(_globalConfig, options);
684
- }
685
- if (typeof options === "string" && options) {
686
- if (_globalConfig.hasOwnProperty(options)) {
687
- return _globalConfig[options];
688
- }
689
- return;
690
- }
691
- var copy = {};
692
- for (var prop in _globalConfig) {
693
- if (_globalConfig.hasOwnProperty(prop)) {
694
- if (typeof _globalConfig[prop] === "object" && _globalConfig[prop] !== null) {
695
- if ("length" in _globalConfig[prop]) {
696
- copy[prop] = _globalConfig[prop].slice(0);
697
- } else {
698
- copy[prop] = _extend({}, _globalConfig[prop]);
699
- }
700
- } else {
701
- copy[prop] = _globalConfig[prop];
702
- }
703
- }
704
- }
705
- return copy;
706
- };
707
- ZeroClipboard.destroy = function() {
708
- ZeroClipboard.deactivate();
709
- for (var clientId in _clientMeta) {
710
- if (_clientMeta.hasOwnProperty(clientId) && _clientMeta[clientId]) {
711
- var client = _clientMeta[clientId].instance;
712
- if (client && typeof client.destroy === "function") {
713
- client.destroy();
714
- }
715
- }
716
- }
717
- var flashBridge = _flashState.bridge;
718
- if (flashBridge) {
719
- var htmlBridge = _getHtmlBridge(flashBridge);
720
- if (htmlBridge) {
721
- if (_flashState.pluginType === "activex" && "readyState" in flashBridge) {
722
- flashBridge.style.display = "none";
723
- (function removeSwfFromIE() {
724
- if (flashBridge.readyState === 4) {
725
- for (var prop in flashBridge) {
726
- if (typeof flashBridge[prop] === "function") {
727
- flashBridge[prop] = null;
728
- }
729
- }
730
- flashBridge.parentNode.removeChild(flashBridge);
731
- if (htmlBridge.parentNode) {
732
- htmlBridge.parentNode.removeChild(htmlBridge);
733
- }
734
- } else {
735
- setTimeout(removeSwfFromIE, 10);
736
- }
737
- })();
738
- } else {
739
- flashBridge.parentNode.removeChild(flashBridge);
740
- if (htmlBridge.parentNode) {
741
- htmlBridge.parentNode.removeChild(htmlBridge);
742
- }
743
- }
744
- }
745
- _flashState.ready = null;
746
- _flashState.bridge = null;
747
- _flashState.deactivated = null;
748
- }
749
- ZeroClipboard.clearData();
750
- };
751
- ZeroClipboard.activate = function(element) {
752
- if (_currentElement) {
753
- _removeClass(_currentElement, _globalConfig.hoverClass);
754
- _removeClass(_currentElement, _globalConfig.activeClass);
755
- }
756
- _currentElement = element;
757
- _addClass(element, _globalConfig.hoverClass);
758
- _reposition();
759
- var newTitle = _globalConfig.title || element.getAttribute("title");
760
- if (newTitle) {
761
- var htmlBridge = _getHtmlBridge(_flashState.bridge);
762
- if (htmlBridge) {
763
- htmlBridge.setAttribute("title", newTitle);
764
- }
765
- }
766
- var useHandCursor = _globalConfig.forceHandCursor === true || _getStyle(element, "cursor") === "pointer";
767
- _setHandCursor(useHandCursor);
768
- };
769
- ZeroClipboard.deactivate = function() {
770
- var htmlBridge = _getHtmlBridge(_flashState.bridge);
771
- if (htmlBridge) {
772
- htmlBridge.removeAttribute("title");
773
- htmlBridge.style.left = "0px";
774
- htmlBridge.style.top = "-9999px";
775
- _setSize(1, 1);
776
- }
777
- if (_currentElement) {
778
- _removeClass(_currentElement, _globalConfig.hoverClass);
779
- _removeClass(_currentElement, _globalConfig.activeClass);
780
- _currentElement = null;
781
- }
782
- };
783
- ZeroClipboard.state = function() {
784
- return {
785
- browser: _pick(window.navigator, [ "userAgent", "platform", "appName" ]),
786
- flash: _omit(_flashState, [ "bridge" ]),
787
- zeroclipboard: {
788
- version: ZeroClipboard.version,
789
- config: ZeroClipboard.config()
790
- }
791
- };
792
- };
793
- ZeroClipboard.setData = function(format, data) {
794
- var dataObj;
795
- if (typeof format === "object" && format && typeof data === "undefined") {
796
- dataObj = format;
797
- ZeroClipboard.clearData();
798
- } else if (typeof format === "string" && format) {
799
- dataObj = {};
800
- dataObj[format] = data;
801
- } else {
802
- return;
803
- }
804
- for (var dataFormat in dataObj) {
805
- if (dataFormat && dataObj.hasOwnProperty(dataFormat) && typeof dataObj[dataFormat] === "string" && dataObj[dataFormat]) {
806
- _clipData[dataFormat] = dataObj[dataFormat];
807
- }
808
- }
809
- };
810
- ZeroClipboard.clearData = function(format) {
811
- if (typeof format === "undefined") {
812
- _deleteOwnProperties(_clipData);
813
- _clipDataFormatMap = null;
814
- } else if (typeof format === "string" && _clipData.hasOwnProperty(format)) {
815
- delete _clipData[format];
816
- }
817
- };
818
- var _bridge = function() {
819
- var flashBridge, len;
820
- var container = document.getElementById("global-zeroclipboard-html-bridge");
821
- if (!container) {
822
- var allowScriptAccess = _determineScriptAccess(window.location.host, _globalConfig);
823
- var allowNetworking = allowScriptAccess === "never" ? "none" : "all";
824
- var flashvars = _vars(_globalConfig);
825
- var swfUrl = _globalConfig.swfPath + _cacheBust(_globalConfig.swfPath, _globalConfig);
826
- container = _createHtmlBridge();
827
- var divToBeReplaced = document.createElement("div");
828
- container.appendChild(divToBeReplaced);
829
- document.body.appendChild(container);
830
- var tmpDiv = document.createElement("div");
831
- var oldIE = _flashState.pluginType === "activex";
832
- tmpDiv.innerHTML = '<object id="global-zeroclipboard-flash-bridge" name="global-zeroclipboard-flash-bridge" ' + 'width="100%" height="100%" ' + (oldIE ? 'classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"' : 'type="application/x-shockwave-flash" data="' + swfUrl + '"') + ">" + (oldIE ? '<param name="movie" value="' + swfUrl + '"/>' : "") + '<param name="allowScriptAccess" value="' + allowScriptAccess + '"/>' + '<param name="allowNetworking" value="' + allowNetworking + '"/>' + '<param name="menu" value="false"/>' + '<param name="wmode" value="transparent"/>' + '<param name="flashvars" value="' + flashvars + '"/>' + "</object>";
833
- flashBridge = tmpDiv.firstChild;
834
- tmpDiv = null;
835
- flashBridge.ZeroClipboard = ZeroClipboard;
836
- container.replaceChild(flashBridge, divToBeReplaced);
837
- }
838
- if (!flashBridge) {
839
- flashBridge = document["global-zeroclipboard-flash-bridge"];
840
- if (flashBridge && (len = flashBridge.length)) {
841
- flashBridge = flashBridge[len - 1];
842
- }
843
- if (!flashBridge) {
844
- flashBridge = container.firstChild;
845
- }
846
- }
847
- _flashState.bridge = flashBridge || null;
848
- };
849
- var _createHtmlBridge = function() {
850
- var container = document.createElement("div");
851
- container.id = "global-zeroclipboard-html-bridge";
852
- container.className = "global-zeroclipboard-container";
853
- container.style.position = "absolute";
854
- container.style.left = "0px";
855
- container.style.top = "-9999px";
856
- container.style.width = "1px";
857
- container.style.height = "1px";
858
- container.style.zIndex = "" + _getSafeZIndex(_globalConfig.zIndex);
859
- return container;
860
- };
861
- var _getHtmlBridge = function(flashBridge) {
862
- var htmlBridge = flashBridge && flashBridge.parentNode;
863
- while (htmlBridge && htmlBridge.nodeName === "OBJECT" && htmlBridge.parentNode) {
864
- htmlBridge = htmlBridge.parentNode;
865
- }
866
- return htmlBridge || null;
867
- };
868
- var _reposition = function() {
869
- if (_currentElement) {
870
- var pos = _getDOMObjectPosition(_currentElement, _globalConfig.zIndex);
871
- var htmlBridge = _getHtmlBridge(_flashState.bridge);
872
- if (htmlBridge) {
873
- htmlBridge.style.top = pos.top + "px";
874
- htmlBridge.style.left = pos.left + "px";
875
- htmlBridge.style.width = pos.width + "px";
876
- htmlBridge.style.height = pos.height + "px";
877
- htmlBridge.style.zIndex = pos.zIndex + 1;
878
- }
879
- _setSize(pos.width, pos.height);
880
- }
881
- };
882
- var _setSize = function(width, height) {
883
- var htmlBridge = _getHtmlBridge(_flashState.bridge);
884
- if (htmlBridge) {
885
- htmlBridge.style.width = width + "px";
886
- htmlBridge.style.height = height + "px";
887
- }
888
- };
889
- ZeroClipboard.emit = function(event) {
890
- var eventType, eventObj, performCallbackAsync, clients, i, len, eventCopy, returnVal, tmp;
891
- if (typeof event === "string" && event) {
892
- eventType = event;
893
- }
894
- if (typeof event === "object" && event && typeof event.type === "string" && event.type) {
895
- eventType = event.type;
896
- eventObj = event;
897
- }
898
- if (!eventType) {
899
- return;
900
- }
901
- event = _createEvent(eventType, eventObj);
902
- _preprocessEvent(event);
903
- if (event.type === "ready" && _flashState.overdue === true) {
904
- return ZeroClipboard.emit({
905
- type: "error",
906
- name: "flash-overdue"
907
- });
908
- }
909
- performCallbackAsync = !/^(before)?copy$/.test(event.type);
910
- if (event.client) {
911
- _dispatchClientCallbacks.call(event.client, event, performCallbackAsync);
912
- } else {
913
- clients = event.target && event.target !== window && _globalConfig.autoActivate === true ? _getAllClientsClippedToElement(event.target) : _getAllClients();
914
- for (i = 0, len = clients.length; i < len; i++) {
915
- eventCopy = _extend({}, event, {
916
- client: clients[i]
917
- });
918
- _dispatchClientCallbacks.call(clients[i], eventCopy, performCallbackAsync);
919
- }
920
- }
921
- if (event.type === "copy") {
922
- tmp = _mapClipDataToFlash(_clipData);
923
- returnVal = tmp.data;
924
- _clipDataFormatMap = tmp.formatMap;
925
- }
926
- return returnVal;
927
- };
928
- var _dispatchClientCallbacks = function(event, async) {
929
- var handlers = _clientMeta[this.id] && _clientMeta[this.id].handlers[event.type];
930
- if (handlers && handlers.length) {
931
- var i, len, func, context, originalContext = this;
932
- for (i = 0, len = handlers.length; i < len; i++) {
933
- func = handlers[i];
934
- context = originalContext;
935
- if (typeof func === "string" && typeof window[func] === "function") {
936
- func = window[func];
937
- }
938
- if (typeof func === "object" && func && typeof func.handleEvent === "function") {
939
- context = func;
940
- func = func.handleEvent;
941
- }
942
- if (typeof func === "function") {
943
- _dispatchCallback(func, context, [ event ], async);
944
- }
945
- }
946
- }
947
- return this;
948
- };
949
- var _eventMessages = {
950
- ready: "Flash communication is established",
951
- error: {
952
- "flash-disabled": "Flash is disabled or not installed",
953
- "flash-outdated": "Flash is too outdated to support ZeroClipboard",
954
- "flash-unavailable": "Flash is unable to communicate bidirectionally with JavaScript",
955
- "flash-deactivated": "Flash is too outdated for your browser and/or is configured as click-to-activate",
956
- "flash-overdue": "Flash communication was established but NOT within the acceptable time limit"
957
- }
958
- };
959
- var _createEvent = function(eventType, event) {
960
- if (!(eventType || event && event.type)) {
961
- return;
962
- }
963
- event = event || {};
964
- eventType = (eventType || event.type).toLowerCase();
965
- _extend(event, {
966
- type: eventType,
967
- target: event.target || _currentElement || null,
968
- relatedTarget: event.relatedTarget || null,
969
- currentTarget: _flashState && _flashState.bridge || null
970
- });
971
- var msg = _eventMessages[event.type];
972
- if (event.type === "error" && event.name && msg) {
973
- msg = msg[event.name];
974
- }
975
- if (msg) {
976
- event.message = msg;
977
- }
978
- if (event.type === "ready") {
979
- _extend(event, {
980
- target: null,
981
- version: _flashState.version
982
- });
983
- }
984
- if (event.type === "error") {
985
- event.target = null;
986
- if (/^flash-(outdated|unavailable|deactivated|overdue)$/.test(event.name)) {
987
- _extend(event, {
988
- version: _flashState.version,
989
- minimumVersion: "11.0.0"
990
- });
991
- }
992
- }
993
- if (event.type === "copy") {
994
- event.clipboardData = {
995
- setData: ZeroClipboard.setData,
996
- clearData: ZeroClipboard.clearData
997
- };
998
- }
999
- if (event.type === "aftercopy") {
1000
- event = _mapClipResultsFromFlash(event, _clipDataFormatMap);
1001
- }
1002
- if (event.target && !event.relatedTarget) {
1003
- event.relatedTarget = _getRelatedTarget(event.target);
1004
- }
1005
- return event;
1006
- };
1007
- var _getRelatedTarget = function(targetEl) {
1008
- var relatedTargetId = targetEl && targetEl.getAttribute && targetEl.getAttribute("data-clipboard-target");
1009
- return relatedTargetId ? document.getElementById(relatedTargetId) : null;
1010
- };
1011
- var _preprocessEvent = function(event) {
1012
- var element = event.target || _currentElement;
1013
- switch (event.type) {
1014
- case "error":
1015
- if (_inArray(event.name, [ "flash-disabled", "flash-outdated", "flash-deactivated", "flash-overdue" ])) {
1016
- _extend(_flashState, {
1017
- disabled: event.name === "flash-disabled",
1018
- outdated: event.name === "flash-outdated",
1019
- unavailable: event.name === "flash-unavailable",
1020
- deactivated: event.name === "flash-deactivated",
1021
- overdue: event.name === "flash-overdue",
1022
- ready: false
1023
- });
1024
- }
1025
- break;
1026
-
1027
- case "ready":
1028
- var wasDeactivated = _flashState.deactivated === true;
1029
- _extend(_flashState, {
1030
- disabled: false,
1031
- outdated: false,
1032
- unavailable: false,
1033
- deactivated: false,
1034
- overdue: wasDeactivated,
1035
- ready: !wasDeactivated
1036
- });
1037
- break;
1038
-
1039
- case "copy":
1040
- var textContent, htmlContent, targetEl = event.relatedTarget;
1041
- if (!(_clipData["text/html"] || _clipData["text/plain"]) && targetEl && (htmlContent = targetEl.value || targetEl.outerHTML || targetEl.innerHTML) && (textContent = targetEl.value || targetEl.textContent || targetEl.innerText)) {
1042
- event.clipboardData.clearData();
1043
- event.clipboardData.setData("text/plain", textContent);
1044
- if (htmlContent !== textContent) {
1045
- event.clipboardData.setData("text/html", htmlContent);
1046
- }
1047
- } else if (!_clipData["text/plain"] && event.target && (textContent = event.target.getAttribute("data-clipboard-text"))) {
1048
- event.clipboardData.clearData();
1049
- event.clipboardData.setData("text/plain", textContent);
1050
- }
1051
- break;
1052
-
1053
- case "aftercopy":
1054
- ZeroClipboard.clearData();
1055
- if (element && element !== _safeActiveElement() && element.focus) {
1056
- element.focus();
1057
- }
1058
- break;
1059
-
1060
- case "mouseover":
1061
- _addClass(element, _globalConfig.hoverClass);
1062
- break;
1063
-
1064
- case "mouseout":
1065
- if (_globalConfig.autoActivate === true) {
1066
- ZeroClipboard.deactivate();
1067
- }
1068
- break;
1069
-
1070
- case "mousedown":
1071
- _addClass(element, _globalConfig.activeClass);
1072
- break;
1073
-
1074
- case "mouseup":
1075
- _removeClass(element, _globalConfig.activeClass);
1076
- break;
1077
- }
1078
- };
1079
- ZeroClipboard.prototype.on = function(eventName, func) {
1080
- var i, len, events, added = {}, handlers = _clientMeta[this.id] && _clientMeta[this.id].handlers;
1081
- if (typeof eventName === "string" && eventName) {
1082
- events = eventName.toLowerCase().split(/\s+/);
1083
- } else if (typeof eventName === "object" && eventName && typeof func === "undefined") {
1084
- for (i in eventName) {
1085
- if (eventName.hasOwnProperty(i) && typeof i === "string" && i && typeof eventName[i] === "function") {
1086
- this.on(i, eventName[i]);
1087
- }
1088
- }
1089
- }
1090
- if (events && events.length) {
1091
- for (i = 0, len = events.length; i < len; i++) {
1092
- eventName = events[i].replace(/^on/, "");
1093
- added[eventName] = true;
1094
- if (!handlers[eventName]) {
1095
- handlers[eventName] = [];
1096
- }
1097
- handlers[eventName].push(func);
1098
- }
1099
- if (added.ready && _flashState.ready) {
1100
- ZeroClipboard.emit({
1101
- type: "ready",
1102
- client: this
1103
- });
1104
- }
1105
- if (added.error) {
1106
- var errorTypes = [ "disabled", "outdated", "unavailable", "deactivated", "overdue" ];
1107
- for (i = 0, len = errorTypes.length; i < len; i++) {
1108
- if (_flashState[errorTypes[i]]) {
1109
- ZeroClipboard.emit({
1110
- type: "error",
1111
- name: "flash-" + errorTypes[i],
1112
- client: this
1113
- });
1114
- break;
1115
- }
1116
- }
1117
- }
1118
- }
1119
- return this;
1120
- };
1121
- ZeroClipboard.prototype.off = function(eventName, func) {
1122
- var i, len, foundIndex, events, perEventHandlers, handlers = _clientMeta[this.id] && _clientMeta[this.id].handlers;
1123
- if (arguments.length === 0) {
1124
- events = _objectKeys(handlers);
1125
- } else if (typeof eventName === "string" && eventName) {
1126
- events = eventName.split(/\s+/);
1127
- } else if (typeof eventName === "object" && eventName && typeof func === "undefined") {
1128
- for (i in eventName) {
1129
- if (eventName.hasOwnProperty(i) && typeof i === "string" && i && typeof eventName[i] === "function") {
1130
- this.off(i, eventName[i]);
1131
- }
1132
- }
1133
- }
1134
- if (events && events.length) {
1135
- for (i = 0, len = events.length; i < len; i++) {
1136
- eventName = events[i].toLowerCase().replace(/^on/, "");
1137
- perEventHandlers = handlers[eventName];
1138
- if (perEventHandlers && perEventHandlers.length) {
1139
- if (func) {
1140
- foundIndex = _inArray(func, perEventHandlers);
1141
- while (foundIndex !== -1) {
1142
- perEventHandlers.splice(foundIndex, 1);
1143
- foundIndex = _inArray(func, perEventHandlers, foundIndex);
1144
- }
1145
- } else {
1146
- handlers[eventName].length = 0;
1147
- }
1148
- }
1149
- }
1150
- }
1151
- return this;
1152
- };
1153
- ZeroClipboard.prototype.handlers = function(eventName) {
1154
- var prop, copy = null, handlers = _clientMeta[this.id] && _clientMeta[this.id].handlers;
1155
- if (handlers) {
1156
- if (typeof eventName === "string" && eventName) {
1157
- return handlers[eventName] ? handlers[eventName].slice(0) : null;
1158
- }
1159
- copy = {};
1160
- for (prop in handlers) {
1161
- if (handlers.hasOwnProperty(prop) && handlers[prop]) {
1162
- copy[prop] = handlers[prop].slice(0);
1163
- }
1164
- }
1165
- }
1166
- return copy;
1167
- };
1168
- ZeroClipboard.prototype.clip = function(elements) {
1169
- elements = _prepClip(elements);
1170
- for (var i = 0; i < elements.length; i++) {
1171
- if (elements.hasOwnProperty(i) && elements[i] && elements[i].nodeType === 1) {
1172
- if (!elements[i].zcClippingId) {
1173
- elements[i].zcClippingId = "zcClippingId_" + _elementIdCounter++;
1174
- _elementMeta[elements[i].zcClippingId] = [ this.id ];
1175
- if (_globalConfig.autoActivate === true) {
1176
- _addEventHandler(elements[i], "mouseover", _elementMouseOver);
1177
- }
1178
- } else if (_inArray(this.id, _elementMeta[elements[i].zcClippingId]) === -1) {
1179
- _elementMeta[elements[i].zcClippingId].push(this.id);
1180
- }
1181
- var clippedElements = _clientMeta[this.id].elements;
1182
- if (_inArray(elements[i], clippedElements) === -1) {
1183
- clippedElements.push(elements[i]);
1184
- }
1185
- }
1186
- }
1187
- return this;
1188
- };
1189
- ZeroClipboard.prototype.unclip = function(elements) {
1190
- var meta = _clientMeta[this.id];
1191
- if (!meta) {
1192
- return this;
1193
- }
1194
- var clippedElements = meta.elements;
1195
- var arrayIndex;
1196
- if (typeof elements === "undefined") {
1197
- elements = clippedElements.slice(0);
1198
- } else {
1199
- elements = _prepClip(elements);
1200
- }
1201
- for (var i = elements.length; i--; ) {
1202
- if (elements.hasOwnProperty(i) && elements[i] && elements[i].nodeType === 1) {
1203
- arrayIndex = 0;
1204
- while ((arrayIndex = _inArray(elements[i], clippedElements, arrayIndex)) !== -1) {
1205
- clippedElements.splice(arrayIndex, 1);
1206
- }
1207
- var clientIds = _elementMeta[elements[i].zcClippingId];
1208
- if (clientIds) {
1209
- arrayIndex = 0;
1210
- while ((arrayIndex = _inArray(this.id, clientIds, arrayIndex)) !== -1) {
1211
- clientIds.splice(arrayIndex, 1);
1212
- }
1213
- if (clientIds.length === 0) {
1214
- if (_globalConfig.autoActivate === true) {
1215
- _removeEventHandler(elements[i], "mouseover", _elementMouseOver);
1216
- }
1217
- delete elements[i].zcClippingId;
1218
- }
1219
- }
1220
- }
1221
- }
1222
- return this;
1223
- };
1224
- ZeroClipboard.prototype.elements = function() {
1225
- var meta = _clientMeta[this.id];
1226
- return meta && meta.elements ? meta.elements.slice(0) : [];
1227
- };
1228
- var _getAllClientsClippedToElement = function(element) {
1229
- var elementMetaId, clientIds, i, len, client, clients = [];
1230
- if (element && element.nodeType === 1 && (elementMetaId = element.zcClippingId) && _elementMeta.hasOwnProperty(elementMetaId)) {
1231
- clientIds = _elementMeta[elementMetaId];
1232
- if (clientIds && clientIds.length) {
1233
- for (i = 0, len = clientIds.length; i < len; i++) {
1234
- client = _clientMeta[clientIds[i]].instance;
1235
- if (client && client instanceof ZeroClipboard) {
1236
- clients.push(client);
1237
- }
1238
- }
1239
- }
1240
- }
1241
- return clients;
1242
- };
1243
- _globalConfig.hoverClass = "zeroclipboard-is-hover";
1244
- _globalConfig.activeClass = "zeroclipboard-is-active";
1245
- if (typeof define === "function" && define.amd) {
1246
- define(function() {
1247
- return ZeroClipboard;
1248
- });
1249
- } else if (typeof module === "object" && module && typeof module.exports === "object" && module.exports) {
1250
- module.exports = ZeroClipboard;
1251
- } else {
1252
- window.ZeroClipboard = ZeroClipboard;
1253
- }
1254
- })(function() {
1255
- return this;
1
+ /*!
2
+ * ZeroClipboard
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) 2014 Jon Rohan, James M. Greene
5
+ * Licensed MIT
6
+ * http://zeroclipboard.org/
7
+ * v2.0.0-beta.5
8
+ */
9
+ (function(window) {
10
+ "use strict";
11
+ var _currentElement;
12
+ var _flashState = {
13
+ bridge: null,
14
+ version: "0.0.0",
15
+ pluginType: "unknown",
16
+ disabled: null,
17
+ outdated: null,
18
+ unavailable: null,
19
+ deactivated: null,
20
+ overdue: null,
21
+ ready: null
22
+ };
23
+ var _clipData = {};
24
+ var _clipDataFormatMap = null;
25
+ var _clientIdCounter = 0;
26
+ var _clientMeta = {};
27
+ var _elementIdCounter = 0;
28
+ var _elementMeta = {};
29
+ var _swfPath = function() {
30
+ var i, jsDir, tmpJsPath, jsPath, swfPath = "ZeroClipboard.swf";
31
+ if (!(document.currentScript && (jsPath = document.currentScript.src))) {
32
+ var scripts = document.getElementsByTagName("script");
33
+ if ("readyState" in scripts[0]) {
34
+ for (i = scripts.length; i--; ) {
35
+ if (scripts[i].readyState === "interactive" && (jsPath = scripts[i].src)) {
36
+ break;
37
+ }
38
+ }
39
+ } else if (document.readyState === "loading") {
40
+ jsPath = scripts[scripts.length - 1].src;
41
+ } else {
42
+ for (i = scripts.length; i--; ) {
43
+ tmpJsPath = scripts[i].src;
44
+ if (!tmpJsPath) {
45
+ jsDir = null;
46
+ break;
47
+ }
48
+ tmpJsPath = tmpJsPath.split("#")[0].split("?")[0];
49
+ tmpJsPath = tmpJsPath.slice(0, tmpJsPath.lastIndexOf("/") + 1);
50
+ if (jsDir == null) {
51
+ jsDir = tmpJsPath;
52
+ } else if (jsDir !== tmpJsPath) {
53
+ jsDir = null;
54
+ break;
55
+ }
56
+ }
57
+ if (jsDir !== null) {
58
+ jsPath = jsDir;
59
+ }
60
+ }
61
+ }
62
+ if (jsPath) {
63
+ jsPath = jsPath.split("#")[0].split("?")[0];
64
+ swfPath = jsPath.slice(0, jsPath.lastIndexOf("/") + 1) + swfPath;
65
+ }
66
+ return swfPath;
67
+ }();
68
+ var _camelizeCssPropName = function() {
69
+ var matcherRegex = /\-([a-z])/g, replacerFn = function(match, group) {
70
+ return group.toUpperCase();
71
+ };
72
+ return function(prop) {
73
+ return prop.replace(matcherRegex, replacerFn);
74
+ };
75
+ }();
76
+ var _getStyle = function(el, prop) {
77
+ var value, camelProp, tagName;
78
+ if (window.getComputedStyle) {
79
+ value = window.getComputedStyle(el, null).getPropertyValue(prop);
80
+ } else {
81
+ camelProp = _camelizeCssPropName(prop);
82
+ if (el.currentStyle) {
83
+ value = el.currentStyle[camelProp];
84
+ } else {
85
+ value = el.style[camelProp];
86
+ }
87
+ }
88
+ if (prop === "cursor") {
89
+ if (!value || value === "auto") {
90
+ tagName = el.tagName.toLowerCase();
91
+ if (tagName === "a") {
92
+ return "pointer";
93
+ }
94
+ }
95
+ }
96
+ return value;
97
+ };
98
+ var _elementMouseOver = function(event) {
99
+ if (!event) {
100
+ event = window.event;
101
+ }
102
+ var target;
103
+ if (this !== window) {
104
+ target = this;
105
+ } else if (event.target) {
106
+ target = event.target;
107
+ } else if (event.srcElement) {
108
+ target = event.srcElement;
109
+ }
110
+ ZeroClipboard.activate(target);
111
+ };
112
+ var _addEventHandler = function(element, method, func) {
113
+ if (!element || element.nodeType !== 1) {
114
+ return;
115
+ }
116
+ if (element.addEventListener) {
117
+ element.addEventListener(method, func, false);
118
+ } else if (element.attachEvent) {
119
+ element.attachEvent("on" + method, func);
120
+ }
121
+ };
122
+ var _removeEventHandler = function(element, method, func) {
123
+ if (!element || element.nodeType !== 1) {
124
+ return;
125
+ }
126
+ if (element.removeEventListener) {
127
+ element.removeEventListener(method, func, false);
128
+ } else if (element.detachEvent) {
129
+ element.detachEvent("on" + method, func);
130
+ }
131
+ };
132
+ var _addClass = function(element, value) {
133
+ if (!element || element.nodeType !== 1) {
134
+ return element;
135
+ }
136
+ if (element.classList) {
137
+ if (!element.classList.contains(value)) {
138
+ element.classList.add(value);
139
+ }
140
+ return element;
141
+ }
142
+ if (value && typeof value === "string") {
143
+ var classNames = (value || "").split(/\s+/);
144
+ if (element.nodeType === 1) {
145
+ if (!element.className) {
146
+ element.className = value;
147
+ } else {
148
+ var className = " " + element.className + " ", setClass = element.className;
149
+ for (var c = 0, cl = classNames.length; c < cl; c++) {
150
+ if (className.indexOf(" " + classNames[c] + " ") < 0) {
151
+ setClass += " " + classNames[c];
152
+ }
153
+ }
154
+ element.className = setClass.replace(/^\s+|\s+$/g, "");
155
+ }
156
+ }
157
+ }
158
+ return element;
159
+ };
160
+ var _removeClass = function(element, value) {
161
+ if (!element || element.nodeType !== 1) {
162
+ return element;
163
+ }
164
+ if (element.classList) {
165
+ if (element.classList.contains(value)) {
166
+ element.classList.remove(value);
167
+ }
168
+ return element;
169
+ }
170
+ if (value && typeof value === "string" || value === undefined) {
171
+ var classNames = (value || "").split(/\s+/);
172
+ if (element.nodeType === 1 && element.className) {
173
+ if (value) {
174
+ var className = (" " + element.className + " ").replace(/[\n\t]/g, " ");
175
+ for (var c = 0, cl = classNames.length; c < cl; c++) {
176
+ className = className.replace(" " + classNames[c] + " ", " ");
177
+ }
178
+ element.className = className.replace(/^\s+|\s+$/g, "");
179
+ } else {
180
+ element.className = "";
181
+ }
182
+ }
183
+ }
184
+ return element;
185
+ };
186
+ var _getZoomFactor = function() {
187
+ var rect, physicalWidth, logicalWidth, zoomFactor = 1;
188
+ if (typeof document.body.getBoundingClientRect === "function") {
189
+ rect = document.body.getBoundingClientRect();
190
+ physicalWidth = rect.right - rect.left;
191
+ logicalWidth = document.body.offsetWidth;
192
+ zoomFactor = Math.round(physicalWidth / logicalWidth * 100) / 100;
193
+ }
194
+ return zoomFactor;
195
+ };
196
+ var _getDOMObjectPosition = function(obj, defaultZIndex) {
197
+ var info = {
198
+ left: 0,
199
+ top: 0,
200
+ width: 0,
201
+ height: 0,
202
+ zIndex: _getSafeZIndex(defaultZIndex) - 1
203
+ };
204
+ if (obj.getBoundingClientRect) {
205
+ var rect = obj.getBoundingClientRect();
206
+ var pageXOffset, pageYOffset, zoomFactor;
207
+ if ("pageXOffset" in window && "pageYOffset" in window) {
208
+ pageXOffset = window.pageXOffset;
209
+ pageYOffset = window.pageYOffset;
210
+ } else {
211
+ zoomFactor = _getZoomFactor();
212
+ pageXOffset = Math.round(document.documentElement.scrollLeft / zoomFactor);
213
+ pageYOffset = Math.round(document.documentElement.scrollTop / zoomFactor);
214
+ }
215
+ var leftBorderWidth = document.documentElement.clientLeft || 0;
216
+ var topBorderWidth = document.documentElement.clientTop || 0;
217
+ info.left = rect.left + pageXOffset - leftBorderWidth;
218
+ info.top = rect.top + pageYOffset - topBorderWidth;
219
+ info.width = "width" in rect ? rect.width : rect.right - rect.left;
220
+ info.height = "height" in rect ? rect.height : rect.bottom - rect.top;
221
+ }
222
+ return info;
223
+ };
224
+ var _cacheBust = function(path, options) {
225
+ var cacheBust = options == null || options && options.cacheBust === true;
226
+ if (cacheBust) {
227
+ return (path.indexOf("?") === -1 ? "?" : "&") + "noCache=" + new Date().getTime();
228
+ } else {
229
+ return "";
230
+ }
231
+ };
232
+ var _vars = function(options) {
233
+ var i, len, domain, domains, str = "", trustedOriginsExpanded = [];
234
+ if (options.trustedDomains) {
235
+ if (typeof options.trustedDomains === "string") {
236
+ domains = [ options.trustedDomains ];
237
+ } else if (typeof options.trustedDomains === "object" && "length" in options.trustedDomains) {
238
+ domains = options.trustedDomains;
239
+ }
240
+ }
241
+ if (domains && domains.length) {
242
+ for (i = 0, len = domains.length; i < len; i++) {
243
+ if (domains.hasOwnProperty(i) && domains[i] && typeof domains[i] === "string") {
244
+ domain = _extractDomain(domains[i]);
245
+ if (!domain) {
246
+ continue;
247
+ }
248
+ if (domain === "*") {
249
+ trustedOriginsExpanded = [ domain ];
250
+ break;
251
+ }
252
+ trustedOriginsExpanded.push.apply(trustedOriginsExpanded, [ domain, "//" + domain, window.location.protocol + "//" + domain ]);
253
+ }
254
+ }
255
+ }
256
+ if (trustedOriginsExpanded.length) {
257
+ str += "trustedOrigins=" + encodeURIComponent(trustedOriginsExpanded.join(","));
258
+ }
259
+ if (options.forceEnhancedClipboard === true) {
260
+ str += (str ? "&" : "") + "forceEnhancedClipboard=true";
261
+ }
262
+ return str;
263
+ };
264
+ var _inArray = function(elem, array, fromIndex) {
265
+ if (typeof array.indexOf === "function") {
266
+ return array.indexOf(elem, fromIndex);
267
+ }
268
+ var i, len = array.length;
269
+ if (typeof fromIndex === "undefined") {
270
+ fromIndex = 0;
271
+ } else if (fromIndex < 0) {
272
+ fromIndex = len + fromIndex;
273
+ }
274
+ for (i = fromIndex; i < len; i++) {
275
+ if (array.hasOwnProperty(i) && array[i] === elem) {
276
+ return i;
277
+ }
278
+ }
279
+ return -1;
280
+ };
281
+ var _prepClip = function(elements) {
282
+ if (typeof elements === "string") {
283
+ throw new TypeError("ZeroClipboard doesn't accept query strings.");
284
+ }
285
+ return typeof elements.length !== "number" ? [ elements ] : elements;
286
+ };
287
+ var _dispatchCallback = function(func, context, args, async) {
288
+ if (async) {
289
+ window.setTimeout(function() {
290
+ func.apply(context, args);
291
+ }, 0);
292
+ } else {
293
+ func.apply(context, args);
294
+ }
295
+ };
296
+ var _getSafeZIndex = function(val) {
297
+ var zIndex, tmp;
298
+ if (val) {
299
+ if (typeof val === "number" && val > 0) {
300
+ zIndex = val;
301
+ } else if (typeof val === "string" && (tmp = parseInt(val, 10)) && !isNaN(tmp) && tmp > 0) {
302
+ zIndex = tmp;
303
+ }
304
+ }
305
+ if (!zIndex) {
306
+ if (typeof _globalConfig.zIndex === "number" && _globalConfig.zIndex > 0) {
307
+ zIndex = _globalConfig.zIndex;
308
+ } else if (typeof _globalConfig.zIndex === "string" && (tmp = parseInt(_globalConfig.zIndex, 10)) && !isNaN(tmp) && tmp > 0) {
309
+ zIndex = tmp;
310
+ }
311
+ }
312
+ return zIndex || 0;
313
+ };
314
+ var _extend = function() {
315
+ var i, len, arg, prop, src, copy, target = arguments[0] || {};
316
+ for (i = 1, len = arguments.length; i < len; i++) {
317
+ if ((arg = arguments[i]) != null) {
318
+ for (prop in arg) {
319
+ if (arg.hasOwnProperty(prop)) {
320
+ src = target[prop];
321
+ copy = arg[prop];
322
+ if (target === copy) {
323
+ continue;
324
+ }
325
+ if (copy !== undefined) {
326
+ target[prop] = copy;
327
+ }
328
+ }
329
+ }
330
+ }
331
+ }
332
+ return target;
333
+ };
334
+ var _extractDomain = function(originOrUrl) {
335
+ if (originOrUrl == null || originOrUrl === "") {
336
+ return null;
337
+ }
338
+ originOrUrl = originOrUrl.replace(/^\s+|\s+$/g, "");
339
+ if (originOrUrl === "") {
340
+ return null;
341
+ }
342
+ var protocolIndex = originOrUrl.indexOf("//");
343
+ originOrUrl = protocolIndex === -1 ? originOrUrl : originOrUrl.slice(protocolIndex + 2);
344
+ var pathIndex = originOrUrl.indexOf("/");
345
+ originOrUrl = pathIndex === -1 ? originOrUrl : protocolIndex === -1 || pathIndex === 0 ? null : originOrUrl.slice(0, pathIndex);
346
+ if (originOrUrl && originOrUrl.slice(-4).toLowerCase() === ".swf") {
347
+ return null;
348
+ }
349
+ return originOrUrl || null;
350
+ };
351
+ var _determineScriptAccess = function() {
352
+ var _extractAllDomains = function(origins, resultsArray) {
353
+ var i, len, tmp;
354
+ if (origins == null || resultsArray[0] === "*") {
355
+ return;
356
+ }
357
+ if (typeof origins === "string") {
358
+ origins = [ origins ];
359
+ }
360
+ if (!(typeof origins === "object" && typeof origins.length === "number")) {
361
+ return;
362
+ }
363
+ for (i = 0, len = origins.length; i < len; i++) {
364
+ if (origins.hasOwnProperty(i) && (tmp = _extractDomain(origins[i]))) {
365
+ if (tmp === "*") {
366
+ resultsArray.length = 0;
367
+ resultsArray.push("*");
368
+ break;
369
+ }
370
+ if (_inArray(tmp, resultsArray) === -1) {
371
+ resultsArray.push(tmp);
372
+ }
373
+ }
374
+ }
375
+ };
376
+ return function(currentDomain, configOptions) {
377
+ var swfDomain = _extractDomain(configOptions.swfPath);
378
+ if (swfDomain === null) {
379
+ swfDomain = currentDomain;
380
+ }
381
+ var trustedDomains = [];
382
+ _extractAllDomains(configOptions.trustedOrigins, trustedDomains);
383
+ _extractAllDomains(configOptions.trustedDomains, trustedDomains);
384
+ var len = trustedDomains.length;
385
+ if (len > 0) {
386
+ if (len === 1 && trustedDomains[0] === "*") {
387
+ return "always";
388
+ }
389
+ if (_inArray(currentDomain, trustedDomains) !== -1) {
390
+ if (len === 1 && currentDomain === swfDomain) {
391
+ return "sameDomain";
392
+ }
393
+ return "always";
394
+ }
395
+ }
396
+ return "never";
397
+ };
398
+ }();
399
+ var _objectKeys = function(obj) {
400
+ if (obj == null) {
401
+ return [];
402
+ }
403
+ if (Object.keys) {
404
+ return Object.keys(obj);
405
+ }
406
+ var keys = [];
407
+ for (var prop in obj) {
408
+ if (obj.hasOwnProperty(prop)) {
409
+ keys.push(prop);
410
+ }
411
+ }
412
+ return keys;
413
+ };
414
+ var _deleteOwnProperties = function(obj) {
415
+ if (obj) {
416
+ for (var prop in obj) {
417
+ if (obj.hasOwnProperty(prop)) {
418
+ delete obj[prop];
419
+ }
420
+ }
421
+ }
422
+ return obj;
423
+ };
424
+ var _safeActiveElement = function() {
425
+ try {
426
+ return document.activeElement;
427
+ } catch (err) {}
428
+ return null;
429
+ };
430
+ var _pick = function(obj, keys) {
431
+ var newObj = {};
432
+ for (var i = 0, len = keys.length; i < len; i++) {
433
+ if (keys[i] in obj) {
434
+ newObj[keys[i]] = obj[keys[i]];
435
+ }
436
+ }
437
+ return newObj;
438
+ };
439
+ var _omit = function(obj, keys) {
440
+ var newObj = {};
441
+ for (var prop in obj) {
442
+ if (_inArray(prop, keys) === -1) {
443
+ newObj[prop] = obj[prop];
444
+ }
445
+ }
446
+ return newObj;
447
+ };
448
+ var _mapClipDataToFlash = function(clipData) {
449
+ var newClipData = {}, formatMap = {};
450
+ if (!(typeof clipData === "object" && clipData)) {
451
+ return;
452
+ }
453
+ for (var dataFormat in clipData) {
454
+ if (dataFormat && clipData.hasOwnProperty(dataFormat) && typeof clipData[dataFormat] === "string" && clipData[dataFormat]) {
455
+ switch (dataFormat.toLowerCase()) {
456
+ case "text/plain":
457
+ case "text":
458
+ case "air:text":
459
+ case "flash:text":
460
+ newClipData.text = clipData[dataFormat];
461
+ formatMap.text = dataFormat;
462
+ break;
463
+
464
+ case "text/html":
465
+ case "html":
466
+ case "air:html":
467
+ case "flash:html":
468
+ newClipData.html = clipData[dataFormat];
469
+ formatMap.html = dataFormat;
470
+ break;
471
+
472
+ case "application/rtf":
473
+ case "text/rtf":
474
+ case "rtf":
475
+ case "richtext":
476
+ case "air:rtf":
477
+ case "flash:rtf":
478
+ newClipData.rtf = clipData[dataFormat];
479
+ formatMap.rtf = dataFormat;
480
+ break;
481
+
482
+ default:
483
+ break;
484
+ }
485
+ }
486
+ }
487
+ return {
488
+ data: newClipData,
489
+ formatMap: formatMap
490
+ };
491
+ };
492
+ var _mapClipResultsFromFlash = function(clipResults, formatMap) {
493
+ if (!(typeof clipResults === "object" && clipResults && typeof formatMap === "object" && formatMap)) {
494
+ return clipResults;
495
+ }
496
+ var newResults = {};
497
+ for (var prop in clipResults) {
498
+ if (clipResults.hasOwnProperty(prop)) {
499
+ if (prop !== "success" && prop !== "data") {
500
+ newResults[prop] = clipResults[prop];
501
+ continue;
502
+ }
503
+ newResults[prop] = {};
504
+ var tmpHash = clipResults[prop];
505
+ for (var dataFormat in tmpHash) {
506
+ if (dataFormat && tmpHash.hasOwnProperty(dataFormat) && formatMap.hasOwnProperty(dataFormat)) {
507
+ newResults[prop][formatMap[dataFormat]] = tmpHash[dataFormat];
508
+ }
509
+ }
510
+ }
511
+ }
512
+ return newResults;
513
+ };
514
+ var _args = function(arraySlice) {
515
+ return function(args) {
516
+ return arraySlice.call(args, 0);
517
+ };
518
+ }(window.Array.prototype.slice);
519
+ var _detectFlashSupport = function() {
520
+ var plugin, ax, mimeType, hasFlash = false, isActiveX = false, isPPAPI = false, flashVersion = "";
521
+ function parseFlashVersion(desc) {
522
+ var matches = desc.match(/[\d]+/g);
523
+ matches.length = 3;
524
+ return matches.join(".");
525
+ }
526
+ function isPepperFlash(flashPlayerFileName) {
527
+ return !!flashPlayerFileName && (flashPlayerFileName = flashPlayerFileName.toLowerCase()) && (/^(pepflashplayer\.dll|libpepflashplayer\.so|pepperflashplayer\.plugin)$/.test(flashPlayerFileName) || flashPlayerFileName.slice(-13) === "chrome.plugin");
528
+ }
529
+ function inspectPlugin(plugin) {
530
+ if (plugin) {
531
+ hasFlash = true;
532
+ if (plugin.version) {
533
+ flashVersion = parseFlashVersion(plugin.version);
534
+ }
535
+ if (!flashVersion && plugin.description) {
536
+ flashVersion = parseFlashVersion(plugin.description);
537
+ }
538
+ if (plugin.filename) {
539
+ isPPAPI = isPepperFlash(plugin.filename);
540
+ }
541
+ }
542
+ }
543
+ if (navigator.plugins && navigator.plugins.length) {
544
+ plugin = navigator.plugins["Shockwave Flash"];
545
+ inspectPlugin(plugin);
546
+ if (navigator.plugins["Shockwave Flash 2.0"]) {
547
+ hasFlash = true;
548
+ flashVersion = "2.0.0.11";
549
+ }
550
+ } else if (navigator.mimeTypes && navigator.mimeTypes.length) {
551
+ mimeType = navigator.mimeTypes["application/x-shockwave-flash"];
552
+ plugin = mimeType && mimeType.enabledPlugin;
553
+ inspectPlugin(plugin);
554
+ } else if (typeof ActiveXObject !== "undefined") {
555
+ isActiveX = true;
556
+ try {
557
+ ax = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");
558
+ hasFlash = true;
559
+ flashVersion = parseFlashVersion(ax.GetVariable("$version"));
560
+ } catch (e1) {
561
+ try {
562
+ ax = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");
563
+ hasFlash = true;
564
+ flashVersion = "6.0.21";
565
+ } catch (e2) {
566
+ try {
567
+ ax = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
568
+ hasFlash = true;
569
+ flashVersion = parseFlashVersion(ax.GetVariable("$version"));
570
+ } catch (e3) {
571
+ isActiveX = false;
572
+ }
573
+ }
574
+ }
575
+ }
576
+ _flashState.disabled = hasFlash !== true;
577
+ _flashState.outdated = flashVersion && parseFloat(flashVersion) < 11;
578
+ _flashState.version = flashVersion || "0.0.0";
579
+ _flashState.pluginType = isPPAPI ? "pepper" : isActiveX ? "activex" : hasFlash ? "netscape" : "unknown";
580
+ };
581
+ _detectFlashSupport();
582
+ var ZeroClipboard = function(elements) {
583
+ if (!(this instanceof ZeroClipboard)) {
584
+ return new ZeroClipboard(elements);
585
+ }
586
+ this.id = "" + _clientIdCounter++;
587
+ _clientMeta[this.id] = {
588
+ instance: this,
589
+ elements: [],
590
+ handlers: {}
591
+ };
592
+ if (elements) {
593
+ this.clip(elements);
594
+ }
595
+ if (typeof _flashState.ready !== "boolean") {
596
+ _flashState.ready = false;
597
+ }
598
+ if (!ZeroClipboard.isFlashUnusable() && _flashState.bridge === null) {
599
+ var _client = this;
600
+ var maxWait = _globalConfig.flashLoadTimeout;
601
+ if (typeof maxWait === "number" && maxWait >= 0) {
602
+ setTimeout(function() {
603
+ if (typeof _flashState.deactivated !== "boolean") {
604
+ _flashState.deactivated = true;
605
+ }
606
+ if (_flashState.deactivated === true) {
607
+ ZeroClipboard.emit({
608
+ type: "error",
609
+ name: "flash-deactivated",
610
+ client: _client
611
+ });
612
+ }
613
+ }, maxWait);
614
+ }
615
+ _flashState.overdue = false;
616
+ _bridge();
617
+ }
618
+ };
619
+ ZeroClipboard.prototype.setText = function(text) {
620
+ ZeroClipboard.setData("text/plain", text);
621
+ return this;
622
+ };
623
+ ZeroClipboard.prototype.setHtml = function(html) {
624
+ ZeroClipboard.setData("text/html", html);
625
+ return this;
626
+ };
627
+ ZeroClipboard.prototype.setRichText = function(richText) {
628
+ ZeroClipboard.setData("application/rtf", richText);
629
+ return this;
630
+ };
631
+ ZeroClipboard.prototype.setData = function() {
632
+ ZeroClipboard.setData.apply(ZeroClipboard, _args(arguments));
633
+ return this;
634
+ };
635
+ ZeroClipboard.prototype.clearData = function() {
636
+ ZeroClipboard.clearData.apply(ZeroClipboard, _args(arguments));
637
+ return this;
638
+ };
639
+ ZeroClipboard.prototype.setSize = function(width, height) {
640
+ _setSize(width, height);
641
+ return this;
642
+ };
643
+ var _setHandCursor = function(enabled) {
644
+ if (_flashState.ready === true && _flashState.bridge && typeof _flashState.bridge.setHandCursor === "function") {
645
+ _flashState.bridge.setHandCursor(enabled);
646
+ } else {
647
+ _flashState.ready = false;
648
+ }
649
+ };
650
+ ZeroClipboard.prototype.destroy = function() {
651
+ this.unclip();
652
+ this.off();
653
+ delete _clientMeta[this.id];
654
+ };
655
+ var _getAllClients = function() {
656
+ var i, len, client, clients = [], clientIds = _objectKeys(_clientMeta);
657
+ for (i = 0, len = clientIds.length; i < len; i++) {
658
+ client = _clientMeta[clientIds[i]].instance;
659
+ if (client && client instanceof ZeroClipboard) {
660
+ clients.push(client);
661
+ }
662
+ }
663
+ return clients;
664
+ };
665
+ ZeroClipboard.version = "2.0.0-beta.5";
666
+ var _globalConfig = {
667
+ swfPath: _swfPath,
668
+ trustedDomains: window.location.host ? [ window.location.host ] : [],
669
+ cacheBust: true,
670
+ forceHandCursor: false,
671
+ forceEnhancedClipboard: false,
672
+ zIndex: 999999999,
673
+ debug: false,
674
+ title: null,
675
+ autoActivate: true,
676
+ flashLoadTimeout: 3e4
677
+ };
678
+ ZeroClipboard.isFlashUnusable = function() {
679
+ return !!(_flashState.disabled || _flashState.outdated || _flashState.unavailable || _flashState.deactivated);
680
+ };
681
+ ZeroClipboard.config = function(options) {
682
+ if (typeof options === "object" && options !== null) {
683
+ _extend(_globalConfig, options);
684
+ }
685
+ if (typeof options === "string" && options) {
686
+ if (_globalConfig.hasOwnProperty(options)) {
687
+ return _globalConfig[options];
688
+ }
689
+ return;
690
+ }
691
+ var copy = {};
692
+ for (var prop in _globalConfig) {
693
+ if (_globalConfig.hasOwnProperty(prop)) {
694
+ if (typeof _globalConfig[prop] === "object" && _globalConfig[prop] !== null) {
695
+ if ("length" in _globalConfig[prop]) {
696
+ copy[prop] = _globalConfig[prop].slice(0);
697
+ } else {
698
+ copy[prop] = _extend({}, _globalConfig[prop]);
699
+ }
700
+ } else {
701
+ copy[prop] = _globalConfig[prop];
702
+ }
703
+ }
704
+ }
705
+ return copy;
706
+ };
707
+ ZeroClipboard.destroy = function() {
708
+ ZeroClipboard.deactivate();
709
+ for (var clientId in _clientMeta) {
710
+ if (_clientMeta.hasOwnProperty(clientId) && _clientMeta[clientId]) {
711
+ var client = _clientMeta[clientId].instance;
712
+ if (client && typeof client.destroy === "function") {
713
+ client.destroy();
714
+ }
715
+ }
716
+ }
717
+ var flashBridge = _flashState.bridge;
718
+ if (flashBridge) {
719
+ var htmlBridge = _getHtmlBridge(flashBridge);
720
+ if (htmlBridge) {
721
+ if (_flashState.pluginType === "activex" && "readyState" in flashBridge) {
722
+ flashBridge.style.display = "none";
723
+ (function removeSwfFromIE() {
724
+ if (flashBridge.readyState === 4) {
725
+ for (var prop in flashBridge) {
726
+ if (typeof flashBridge[prop] === "function") {
727
+ flashBridge[prop] = null;
728
+ }
729
+ }
730
+ flashBridge.parentNode.removeChild(flashBridge);
731
+ if (htmlBridge.parentNode) {
732
+ htmlBridge.parentNode.removeChild(htmlBridge);
733
+ }
734
+ } else {
735
+ setTimeout(removeSwfFromIE, 10);
736
+ }
737
+ })();
738
+ } else {
739
+ flashBridge.parentNode.removeChild(flashBridge);
740
+ if (htmlBridge.parentNode) {
741
+ htmlBridge.parentNode.removeChild(htmlBridge);
742
+ }
743
+ }
744
+ }
745
+ _flashState.ready = null;
746
+ _flashState.bridge = null;
747
+ _flashState.deactivated = null;
748
+ }
749
+ ZeroClipboard.clearData();
750
+ };
751
+ ZeroClipboard.activate = function(element) {
752
+ if (_currentElement) {
753
+ _removeClass(_currentElement, _globalConfig.hoverClass);
754
+ _removeClass(_currentElement, _globalConfig.activeClass);
755
+ }
756
+ _currentElement = element;
757
+ _addClass(element, _globalConfig.hoverClass);
758
+ _reposition();
759
+ var newTitle = _globalConfig.title || element.getAttribute("title");
760
+ if (newTitle) {
761
+ var htmlBridge = _getHtmlBridge(_flashState.bridge);
762
+ if (htmlBridge) {
763
+ htmlBridge.setAttribute("title", newTitle);
764
+ }
765
+ }
766
+ var useHandCursor = _globalConfig.forceHandCursor === true || _getStyle(element, "cursor") === "pointer";
767
+ _setHandCursor(useHandCursor);
768
+ };
769
+ ZeroClipboard.deactivate = function() {
770
+ var htmlBridge = _getHtmlBridge(_flashState.bridge);
771
+ if (htmlBridge) {
772
+ htmlBridge.removeAttribute("title");
773
+ htmlBridge.style.left = "0px";
774
+ htmlBridge.style.top = "-9999px";
775
+ _setSize(1, 1);
776
+ }
777
+ if (_currentElement) {
778
+ _removeClass(_currentElement, _globalConfig.hoverClass);
779
+ _removeClass(_currentElement, _globalConfig.activeClass);
780
+ _currentElement = null;
781
+ }
782
+ };
783
+ ZeroClipboard.state = function() {
784
+ return {
785
+ browser: _pick(window.navigator, [ "userAgent", "platform", "appName" ]),
786
+ flash: _omit(_flashState, [ "bridge" ]),
787
+ zeroclipboard: {
788
+ version: ZeroClipboard.version,
789
+ config: ZeroClipboard.config()
790
+ }
791
+ };
792
+ };
793
+ ZeroClipboard.setData = function(format, data) {
794
+ var dataObj;
795
+ if (typeof format === "object" && format && typeof data === "undefined") {
796
+ dataObj = format;
797
+ ZeroClipboard.clearData();
798
+ } else if (typeof format === "string" && format) {
799
+ dataObj = {};
800
+ dataObj[format] = data;
801
+ } else {
802
+ return;
803
+ }
804
+ for (var dataFormat in dataObj) {
805
+ if (dataFormat && dataObj.hasOwnProperty(dataFormat) && typeof dataObj[dataFormat] === "string" && dataObj[dataFormat]) {
806
+ _clipData[dataFormat] = dataObj[dataFormat];
807
+ }
808
+ }
809
+ };
810
+ ZeroClipboard.clearData = function(format) {
811
+ if (typeof format === "undefined") {
812
+ _deleteOwnProperties(_clipData);
813
+ _clipDataFormatMap = null;
814
+ } else if (typeof format === "string" && _clipData.hasOwnProperty(format)) {
815
+ delete _clipData[format];
816
+ }
817
+ };
818
+ var _bridge = function() {
819
+ var flashBridge, len;
820
+ var container = document.getElementById("global-zeroclipboard-html-bridge");
821
+ if (!container) {
822
+ var allowScriptAccess = _determineScriptAccess(window.location.host, _globalConfig);
823
+ var allowNetworking = allowScriptAccess === "never" ? "none" : "all";
824
+ var flashvars = _vars(_globalConfig);
825
+ var swfUrl = _globalConfig.swfPath + _cacheBust(_globalConfig.swfPath, _globalConfig);
826
+ container = _createHtmlBridge();
827
+ var divToBeReplaced = document.createElement("div");
828
+ container.appendChild(divToBeReplaced);
829
+ document.body.appendChild(container);
830
+ var tmpDiv = document.createElement("div");
831
+ var oldIE = _flashState.pluginType === "activex";
832
+ tmpDiv.innerHTML = '<object id="global-zeroclipboard-flash-bridge" name="global-zeroclipboard-flash-bridge" ' + 'width="100%" height="100%" ' + (oldIE ? 'classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"' : 'type="application/x-shockwave-flash" data="' + swfUrl + '"') + ">" + (oldIE ? '<param name="movie" value="' + swfUrl + '"/>' : "") + '<param name="allowScriptAccess" value="' + allowScriptAccess + '"/>' + '<param name="allowNetworking" value="' + allowNetworking + '"/>' + '<param name="menu" value="false"/>' + '<param name="wmode" value="transparent"/>' + '<param name="flashvars" value="' + flashvars + '"/>' + "</object>";
833
+ flashBridge = tmpDiv.firstChild;
834
+ tmpDiv = null;
835
+ flashBridge.ZeroClipboard = ZeroClipboard;
836
+ container.replaceChild(flashBridge, divToBeReplaced);
837
+ }
838
+ if (!flashBridge) {
839
+ flashBridge = document["global-zeroclipboard-flash-bridge"];
840
+ if (flashBridge && (len = flashBridge.length)) {
841
+ flashBridge = flashBridge[len - 1];
842
+ }
843
+ if (!flashBridge) {
844
+ flashBridge = container.firstChild;
845
+ }
846
+ }
847
+ _flashState.bridge = flashBridge || null;
848
+ };
849
+ var _createHtmlBridge = function() {
850
+ var container = document.createElement("div");
851
+ container.id = "global-zeroclipboard-html-bridge";
852
+ container.className = "global-zeroclipboard-container";
853
+ container.style.position = "absolute";
854
+ container.style.left = "0px";
855
+ container.style.top = "-9999px";
856
+ container.style.width = "1px";
857
+ container.style.height = "1px";
858
+ container.style.zIndex = "" + _getSafeZIndex(_globalConfig.zIndex);
859
+ return container;
860
+ };
861
+ var _getHtmlBridge = function(flashBridge) {
862
+ var htmlBridge = flashBridge && flashBridge.parentNode;
863
+ while (htmlBridge && htmlBridge.nodeName === "OBJECT" && htmlBridge.parentNode) {
864
+ htmlBridge = htmlBridge.parentNode;
865
+ }
866
+ return htmlBridge || null;
867
+ };
868
+ var _reposition = function() {
869
+ if (_currentElement) {
870
+ var pos = _getDOMObjectPosition(_currentElement, _globalConfig.zIndex);
871
+ var htmlBridge = _getHtmlBridge(_flashState.bridge);
872
+ if (htmlBridge) {
873
+ htmlBridge.style.top = pos.top + "px";
874
+ htmlBridge.style.left = pos.left + "px";
875
+ htmlBridge.style.width = pos.width + "px";
876
+ htmlBridge.style.height = pos.height + "px";
877
+ htmlBridge.style.zIndex = pos.zIndex + 1;
878
+ }
879
+ _setSize(pos.width, pos.height);
880
+ }
881
+ };
882
+ var _setSize = function(width, height) {
883
+ var htmlBridge = _getHtmlBridge(_flashState.bridge);
884
+ if (htmlBridge) {
885
+ htmlBridge.style.width = width + "px";
886
+ htmlBridge.style.height = height + "px";
887
+ }
888
+ };
889
+ ZeroClipboard.emit = function(event) {
890
+ var eventType, eventObj, performCallbackAsync, clients, i, len, eventCopy, returnVal, tmp;
891
+ if (typeof event === "string" && event) {
892
+ eventType = event;
893
+ }
894
+ if (typeof event === "object" && event && typeof event.type === "string" && event.type) {
895
+ eventType = event.type;
896
+ eventObj = event;
897
+ }
898
+ if (!eventType) {
899
+ return;
900
+ }
901
+ event = _createEvent(eventType, eventObj);
902
+ _preprocessEvent(event);
903
+ if (event.type === "ready" && _flashState.overdue === true) {
904
+ return ZeroClipboard.emit({
905
+ type: "error",
906
+ name: "flash-overdue"
907
+ });
908
+ }
909
+ performCallbackAsync = !/^(before)?copy$/.test(event.type);
910
+ if (event.client) {
911
+ _dispatchClientCallbacks.call(event.client, event, performCallbackAsync);
912
+ } else {
913
+ clients = event.target && event.target !== window && _globalConfig.autoActivate === true ? _getAllClientsClippedToElement(event.target) : _getAllClients();
914
+ for (i = 0, len = clients.length; i < len; i++) {
915
+ eventCopy = _extend({}, event, {
916
+ client: clients[i]
917
+ });
918
+ _dispatchClientCallbacks.call(clients[i], eventCopy, performCallbackAsync);
919
+ }
920
+ }
921
+ if (event.type === "copy") {
922
+ tmp = _mapClipDataToFlash(_clipData);
923
+ returnVal = tmp.data;
924
+ _clipDataFormatMap = tmp.formatMap;
925
+ }
926
+ return returnVal;
927
+ };
928
+ var _dispatchClientCallbacks = function(event, async) {
929
+ var handlers = _clientMeta[this.id] && _clientMeta[this.id].handlers[event.type];
930
+ if (handlers && handlers.length) {
931
+ var i, len, func, context, originalContext = this;
932
+ for (i = 0, len = handlers.length; i < len; i++) {
933
+ func = handlers[i];
934
+ context = originalContext;
935
+ if (typeof func === "string" && typeof window[func] === "function") {
936
+ func = window[func];
937
+ }
938
+ if (typeof func === "object" && func && typeof func.handleEvent === "function") {
939
+ context = func;
940
+ func = func.handleEvent;
941
+ }
942
+ if (typeof func === "function") {
943
+ _dispatchCallback(func, context, [ event ], async);
944
+ }
945
+ }
946
+ }
947
+ return this;
948
+ };
949
+ var _eventMessages = {
950
+ ready: "Flash communication is established",
951
+ error: {
952
+ "flash-disabled": "Flash is disabled or not installed",
953
+ "flash-outdated": "Flash is too outdated to support ZeroClipboard",
954
+ "flash-unavailable": "Flash is unable to communicate bidirectionally with JavaScript",
955
+ "flash-deactivated": "Flash is too outdated for your browser and/or is configured as click-to-activate",
956
+ "flash-overdue": "Flash communication was established but NOT within the acceptable time limit"
957
+ }
958
+ };
959
+ var _createEvent = function(eventType, event) {
960
+ if (!(eventType || event && event.type)) {
961
+ return;
962
+ }
963
+ event = event || {};
964
+ eventType = (eventType || event.type).toLowerCase();
965
+ _extend(event, {
966
+ type: eventType,
967
+ target: event.target || _currentElement || null,
968
+ relatedTarget: event.relatedTarget || null,
969
+ currentTarget: _flashState && _flashState.bridge || null
970
+ });
971
+ var msg = _eventMessages[event.type];
972
+ if (event.type === "error" && event.name && msg) {
973
+ msg = msg[event.name];
974
+ }
975
+ if (msg) {
976
+ event.message = msg;
977
+ }
978
+ if (event.type === "ready") {
979
+ _extend(event, {
980
+ target: null,
981
+ version: _flashState.version
982
+ });
983
+ }
984
+ if (event.type === "error") {
985
+ event.target = null;
986
+ if (/^flash-(outdated|unavailable|deactivated|overdue)$/.test(event.name)) {
987
+ _extend(event, {
988
+ version: _flashState.version,
989
+ minimumVersion: "11.0.0"
990
+ });
991
+ }
992
+ }
993
+ if (event.type === "copy") {
994
+ event.clipboardData = {
995
+ setData: ZeroClipboard.setData,
996
+ clearData: ZeroClipboard.clearData
997
+ };
998
+ }
999
+ if (event.type === "aftercopy") {
1000
+ event = _mapClipResultsFromFlash(event, _clipDataFormatMap);
1001
+ }
1002
+ if (event.target && !event.relatedTarget) {
1003
+ event.relatedTarget = _getRelatedTarget(event.target);
1004
+ }
1005
+ return event;
1006
+ };
1007
+ var _getRelatedTarget = function(targetEl) {
1008
+ var relatedTargetId = targetEl && targetEl.getAttribute && targetEl.getAttribute("data-clipboard-target");
1009
+ return relatedTargetId ? document.getElementById(relatedTargetId) : null;
1010
+ };
1011
+ var _preprocessEvent = function(event) {
1012
+ var element = event.target || _currentElement;
1013
+ switch (event.type) {
1014
+ case "error":
1015
+ if (_inArray(event.name, [ "flash-disabled", "flash-outdated", "flash-deactivated", "flash-overdue" ])) {
1016
+ _extend(_flashState, {
1017
+ disabled: event.name === "flash-disabled",
1018
+ outdated: event.name === "flash-outdated",
1019
+ unavailable: event.name === "flash-unavailable",
1020
+ deactivated: event.name === "flash-deactivated",
1021
+ overdue: event.name === "flash-overdue",
1022
+ ready: false
1023
+ });
1024
+ }
1025
+ break;
1026
+
1027
+ case "ready":
1028
+ var wasDeactivated = _flashState.deactivated === true;
1029
+ _extend(_flashState, {
1030
+ disabled: false,
1031
+ outdated: false,
1032
+ unavailable: false,
1033
+ deactivated: false,
1034
+ overdue: wasDeactivated,
1035
+ ready: !wasDeactivated
1036
+ });
1037
+ break;
1038
+
1039
+ case "copy":
1040
+ var textContent, htmlContent, targetEl = event.relatedTarget;
1041
+ if (!(_clipData["text/html"] || _clipData["text/plain"]) && targetEl && (htmlContent = targetEl.value || targetEl.outerHTML || targetEl.innerHTML) && (textContent = targetEl.value || targetEl.textContent || targetEl.innerText)) {
1042
+ event.clipboardData.clearData();
1043
+ event.clipboardData.setData("text/plain", textContent);
1044
+ if (htmlContent !== textContent) {
1045
+ event.clipboardData.setData("text/html", htmlContent);
1046
+ }
1047
+ } else if (!_clipData["text/plain"] && event.target && (textContent = event.target.getAttribute("data-clipboard-text"))) {
1048
+ event.clipboardData.clearData();
1049
+ event.clipboardData.setData("text/plain", textContent);
1050
+ }
1051
+ break;
1052
+
1053
+ case "aftercopy":
1054
+ ZeroClipboard.clearData();
1055
+ if (element && element !== _safeActiveElement() && element.focus) {
1056
+ element.focus();
1057
+ }
1058
+ break;
1059
+
1060
+ case "mouseover":
1061
+ _addClass(element, _globalConfig.hoverClass);
1062
+ break;
1063
+
1064
+ case "mouseout":
1065
+ if (_globalConfig.autoActivate === true) {
1066
+ ZeroClipboard.deactivate();
1067
+ }
1068
+ break;
1069
+
1070
+ case "mousedown":
1071
+ _addClass(element, _globalConfig.activeClass);
1072
+ break;
1073
+
1074
+ case "mouseup":
1075
+ _removeClass(element, _globalConfig.activeClass);
1076
+ break;
1077
+ }
1078
+ };
1079
+ ZeroClipboard.prototype.on = function(eventName, func) {
1080
+ var i, len, events, added = {}, handlers = _clientMeta[this.id] && _clientMeta[this.id].handlers;
1081
+ if (typeof eventName === "string" && eventName) {
1082
+ events = eventName.toLowerCase().split(/\s+/);
1083
+ } else if (typeof eventName === "object" && eventName && typeof func === "undefined") {
1084
+ for (i in eventName) {
1085
+ if (eventName.hasOwnProperty(i) && typeof i === "string" && i && typeof eventName[i] === "function") {
1086
+ this.on(i, eventName[i]);
1087
+ }
1088
+ }
1089
+ }
1090
+ if (events && events.length) {
1091
+ for (i = 0, len = events.length; i < len; i++) {
1092
+ eventName = events[i].replace(/^on/, "");
1093
+ added[eventName] = true;
1094
+ if (!handlers[eventName]) {
1095
+ handlers[eventName] = [];
1096
+ }
1097
+ handlers[eventName].push(func);
1098
+ }
1099
+ if (added.ready && _flashState.ready) {
1100
+ ZeroClipboard.emit({
1101
+ type: "ready",
1102
+ client: this
1103
+ });
1104
+ }
1105
+ if (added.error) {
1106
+ var errorTypes = [ "disabled", "outdated", "unavailable", "deactivated", "overdue" ];
1107
+ for (i = 0, len = errorTypes.length; i < len; i++) {
1108
+ if (_flashState[errorTypes[i]]) {
1109
+ ZeroClipboard.emit({
1110
+ type: "error",
1111
+ name: "flash-" + errorTypes[i],
1112
+ client: this
1113
+ });
1114
+ break;
1115
+ }
1116
+ }
1117
+ }
1118
+ }
1119
+ return this;
1120
+ };
1121
+ ZeroClipboard.prototype.off = function(eventName, func) {
1122
+ var i, len, foundIndex, events, perEventHandlers, handlers = _clientMeta[this.id] && _clientMeta[this.id].handlers;
1123
+ if (arguments.length === 0) {
1124
+ events = _objectKeys(handlers);
1125
+ } else if (typeof eventName === "string" && eventName) {
1126
+ events = eventName.split(/\s+/);
1127
+ } else if (typeof eventName === "object" && eventName && typeof func === "undefined") {
1128
+ for (i in eventName) {
1129
+ if (eventName.hasOwnProperty(i) && typeof i === "string" && i && typeof eventName[i] === "function") {
1130
+ this.off(i, eventName[i]);
1131
+ }
1132
+ }
1133
+ }
1134
+ if (events && events.length) {
1135
+ for (i = 0, len = events.length; i < len; i++) {
1136
+ eventName = events[i].toLowerCase().replace(/^on/, "");
1137
+ perEventHandlers = handlers[eventName];
1138
+ if (perEventHandlers && perEventHandlers.length) {
1139
+ if (func) {
1140
+ foundIndex = _inArray(func, perEventHandlers);
1141
+ while (foundIndex !== -1) {
1142
+ perEventHandlers.splice(foundIndex, 1);
1143
+ foundIndex = _inArray(func, perEventHandlers, foundIndex);
1144
+ }
1145
+ } else {
1146
+ handlers[eventName].length = 0;
1147
+ }
1148
+ }
1149
+ }
1150
+ }
1151
+ return this;
1152
+ };
1153
+ ZeroClipboard.prototype.handlers = function(eventName) {
1154
+ var prop, copy = null, handlers = _clientMeta[this.id] && _clientMeta[this.id].handlers;
1155
+ if (handlers) {
1156
+ if (typeof eventName === "string" && eventName) {
1157
+ return handlers[eventName] ? handlers[eventName].slice(0) : null;
1158
+ }
1159
+ copy = {};
1160
+ for (prop in handlers) {
1161
+ if (handlers.hasOwnProperty(prop) && handlers[prop]) {
1162
+ copy[prop] = handlers[prop].slice(0);
1163
+ }
1164
+ }
1165
+ }
1166
+ return copy;
1167
+ };
1168
+ ZeroClipboard.prototype.clip = function(elements) {
1169
+ elements = _prepClip(elements);
1170
+ for (var i = 0; i < elements.length; i++) {
1171
+ if (elements.hasOwnProperty(i) && elements[i] && elements[i].nodeType === 1) {
1172
+ if (!elements[i].zcClippingId) {
1173
+ elements[i].zcClippingId = "zcClippingId_" + _elementIdCounter++;
1174
+ _elementMeta[elements[i].zcClippingId] = [ this.id ];
1175
+ if (_globalConfig.autoActivate === true) {
1176
+ _addEventHandler(elements[i], "mouseover", _elementMouseOver);
1177
+ }
1178
+ } else if (_inArray(this.id, _elementMeta[elements[i].zcClippingId]) === -1) {
1179
+ _elementMeta[elements[i].zcClippingId].push(this.id);
1180
+ }
1181
+ var clippedElements = _clientMeta[this.id].elements;
1182
+ if (_inArray(elements[i], clippedElements) === -1) {
1183
+ clippedElements.push(elements[i]);
1184
+ }
1185
+ }
1186
+ }
1187
+ return this;
1188
+ };
1189
+ ZeroClipboard.prototype.unclip = function(elements) {
1190
+ var meta = _clientMeta[this.id];
1191
+ if (!meta) {
1192
+ return this;
1193
+ }
1194
+ var clippedElements = meta.elements;
1195
+ var arrayIndex;
1196
+ if (typeof elements === "undefined") {
1197
+ elements = clippedElements.slice(0);
1198
+ } else {
1199
+ elements = _prepClip(elements);
1200
+ }
1201
+ for (var i = elements.length; i--; ) {
1202
+ if (elements.hasOwnProperty(i) && elements[i] && elements[i].nodeType === 1) {
1203
+ arrayIndex = 0;
1204
+ while ((arrayIndex = _inArray(elements[i], clippedElements, arrayIndex)) !== -1) {
1205
+ clippedElements.splice(arrayIndex, 1);
1206
+ }
1207
+ var clientIds = _elementMeta[elements[i].zcClippingId];
1208
+ if (clientIds) {
1209
+ arrayIndex = 0;
1210
+ while ((arrayIndex = _inArray(this.id, clientIds, arrayIndex)) !== -1) {
1211
+ clientIds.splice(arrayIndex, 1);
1212
+ }
1213
+ if (clientIds.length === 0) {
1214
+ if (_globalConfig.autoActivate === true) {
1215
+ _removeEventHandler(elements[i], "mouseover", _elementMouseOver);
1216
+ }
1217
+ delete elements[i].zcClippingId;
1218
+ }
1219
+ }
1220
+ }
1221
+ }
1222
+ return this;
1223
+ };
1224
+ ZeroClipboard.prototype.elements = function() {
1225
+ var meta = _clientMeta[this.id];
1226
+ return meta && meta.elements ? meta.elements.slice(0) : [];
1227
+ };
1228
+ var _getAllClientsClippedToElement = function(element) {
1229
+ var elementMetaId, clientIds, i, len, client, clients = [];
1230
+ if (element && element.nodeType === 1 && (elementMetaId = element.zcClippingId) && _elementMeta.hasOwnProperty(elementMetaId)) {
1231
+ clientIds = _elementMeta[elementMetaId];
1232
+ if (clientIds && clientIds.length) {
1233
+ for (i = 0, len = clientIds.length; i < len; i++) {
1234
+ client = _clientMeta[clientIds[i]].instance;
1235
+ if (client && client instanceof ZeroClipboard) {
1236
+ clients.push(client);
1237
+ }
1238
+ }
1239
+ }
1240
+ }
1241
+ return clients;
1242
+ };
1243
+ _globalConfig.hoverClass = "zeroclipboard-is-hover";
1244
+ _globalConfig.activeClass = "zeroclipboard-is-active";
1245
+ if (typeof define === "function" && define.amd) {
1246
+ define(function() {
1247
+ return ZeroClipboard;
1248
+ });
1249
+ } else if (typeof module === "object" && module && typeof module.exports === "object" && module.exports) {
1250
+ module.exports = ZeroClipboard;
1251
+ } else {
1252
+ window.ZeroClipboard = ZeroClipboard;
1253
+ }
1254
+ })(function() {
1255
+ return this;
1256
1256
  }());