| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144 |
- /*!
- * ZeroClipboard
- * The ZeroClipboard library provides an easy way to copy text to the clipboard using an invisible Adobe Flash movie and a JavaScript interface
- * Copyright (c) 2009-2016 Jon Rohan, James M. Greene
- * Licensed MIT
- * http://zeroclipboard.org/
- * v2.3.0
- */
- (function(window, undefined) {
- "use strict";
- /**
- * Store references to critically important global functions that may be
- * overridden on certain web pages.
- */
- var _window = window, _document = _window.document, _navigator = _window.navigator, _setTimeout = _window.setTimeout, _clearTimeout = _window.clearTimeout, _setInterval = _window.setInterval, _clearInterval = _window.clearInterval, _getComputedStyle = _window.getComputedStyle, _encodeURIComponent = _window.encodeURIComponent, _ActiveXObject = _window.ActiveXObject, _Error = _window.Error, _parseInt = _window.Number.parseInt || _window.parseInt, _parseFloat = _window.Number.parseFloat || _window.parseFloat, _isNaN = _window.Number.isNaN || _window.isNaN, _now = _window.Date.now, _keys = _window.Object.keys, _hasOwn = _window.Object.prototype.hasOwnProperty, _slice = _window.Array.prototype.slice, _unwrap = function() {
- var unwrapper = function(el) {
- return el;
- };
- if (typeof _window.wrap === "function" && typeof _window.unwrap === "function") {
- try {
- var div = _document.createElement("div");
- var unwrappedDiv = _window.unwrap(div);
- if (div.nodeType === 1 && unwrappedDiv && unwrappedDiv.nodeType === 1) {
- unwrapper = _window.unwrap;
- }
- } catch (e) {}
- }
- return unwrapper;
- }();
- /**
- * Convert an `arguments` object into an Array.
- *
- * @returns The arguments as an Array
- * @private
- */
- var _args = function(argumentsObj) {
- return _slice.call(argumentsObj, 0);
- };
- /**
- * Shallow-copy the owned, enumerable properties of one object over to another, similar to jQuery's `$.extend`.
- *
- * @returns The target object, augmented
- * @private
- */
- var _extend = function() {
- var i, len, arg, prop, src, copy, args = _args(arguments), target = args[0] || {};
- for (i = 1, len = args.length; i < len; i++) {
- if ((arg = args[i]) != null) {
- for (prop in arg) {
- if (_hasOwn.call(arg, prop)) {
- src = target[prop];
- copy = arg[prop];
- if (target !== copy && copy !== undefined) {
- target[prop] = copy;
- }
- }
- }
- }
- }
- return target;
- };
- /**
- * Return a deep copy of the source object or array.
- *
- * @returns Object or Array
- * @private
- */
- var _deepCopy = function(source) {
- var copy, i, len, prop;
- if (typeof source !== "object" || source == null || typeof source.nodeType === "number") {
- copy = source;
- } else if (typeof source.length === "number") {
- copy = [];
- for (i = 0, len = source.length; i < len; i++) {
- if (_hasOwn.call(source, i)) {
- copy[i] = _deepCopy(source[i]);
- }
- }
- } else {
- copy = {};
- for (prop in source) {
- if (_hasOwn.call(source, prop)) {
- copy[prop] = _deepCopy(source[prop]);
- }
- }
- }
- return copy;
- };
- /**
- * Makes a shallow copy of `obj` (like `_extend`) but filters its properties based on a list of `keys` to keep.
- * The inverse of `_omit`, mostly. The big difference is that these properties do NOT need to be enumerable to
- * be kept.
- *
- * @returns A new filtered object.
- * @private
- */
- var _pick = function(obj, keys) {
- var newObj = {};
- for (var i = 0, len = keys.length; i < len; i++) {
- if (keys[i] in obj) {
- newObj[keys[i]] = obj[keys[i]];
- }
- }
- return newObj;
- };
- /**
- * Makes a shallow copy of `obj` (like `_extend`) but filters its properties based on a list of `keys` to omit.
- * The inverse of `_pick`.
- *
- * @returns A new filtered object.
- * @private
- */
- var _omit = function(obj, keys) {
- var newObj = {};
- for (var prop in obj) {
- if (keys.indexOf(prop) === -1) {
- newObj[prop] = obj[prop];
- }
- }
- return newObj;
- };
- /**
- * Remove all owned, enumerable properties from an object.
- *
- * @returns The original object without its owned, enumerable properties.
- * @private
- */
- var _deleteOwnProperties = function(obj) {
- if (obj) {
- for (var prop in obj) {
- if (_hasOwn.call(obj, prop)) {
- delete obj[prop];
- }
- }
- }
- return obj;
- };
- /**
- * Determine if an element is contained within another element.
- *
- * @returns Boolean
- * @private
- */
- var _containedBy = function(el, ancestorEl) {
- if (el && el.nodeType === 1 && el.ownerDocument && ancestorEl && (ancestorEl.nodeType === 1 && ancestorEl.ownerDocument && ancestorEl.ownerDocument === el.ownerDocument || ancestorEl.nodeType === 9 && !ancestorEl.ownerDocument && ancestorEl === el.ownerDocument)) {
- do {
- if (el === ancestorEl) {
- return true;
- }
- el = el.parentNode;
- } while (el);
- }
- return false;
- };
- /**
- * Get the URL path's parent directory.
- *
- * @returns String or `undefined`
- * @private
- */
- var _getDirPathOfUrl = function(url) {
- var dir;
- if (typeof url === "string" && url) {
- dir = url.split("#")[0].split("?")[0];
- dir = url.slice(0, url.lastIndexOf("/") + 1);
- }
- return dir;
- };
- /**
- * Get the current script's URL by throwing an `Error` and analyzing it.
- *
- * @returns String or `undefined`
- * @private
- */
- var _getCurrentScriptUrlFromErrorStack = function(stack) {
- var url, matches;
- if (typeof stack === "string" && stack) {
- matches = stack.match(/^(?:|[^:@]*@|.+\)@(?=http[s]?|file)|.+?\s+(?: at |@)(?:[^:\(]+ )*[\(]?)((?:http[s]?|file):\/\/[\/]?.+?\/[^:\)]*?)(?::\d+)(?::\d+)?/);
- if (matches && matches[1]) {
- url = matches[1];
- } else {
- matches = stack.match(/\)@((?:http[s]?|file):\/\/[\/]?.+?\/[^:\)]*?)(?::\d+)(?::\d+)?/);
- if (matches && matches[1]) {
- url = matches[1];
- }
- }
- }
- return url;
- };
- /**
- * Get the current script's URL by throwing an `Error` and analyzing it.
- *
- * @returns String or `undefined`
- * @private
- */
- var _getCurrentScriptUrlFromError = function() {
- var url, err;
- try {
- throw new _Error();
- } catch (e) {
- err = e;
- }
- if (err) {
- url = err.sourceURL || err.fileName || _getCurrentScriptUrlFromErrorStack(err.stack);
- }
- return url;
- };
- /**
- * Get the current script's URL.
- *
- * @returns String or `undefined`
- * @private
- */
- var _getCurrentScriptUrl = function() {
- var jsPath, scripts, i;
- if (_document.currentScript && (jsPath = _document.currentScript.src)) {
- return jsPath;
- }
- scripts = _document.getElementsByTagName("script");
- if (scripts.length === 1) {
- return scripts[0].src || undefined;
- }
- if ("readyState" in (scripts[0] || document.createElement("script"))) {
- for (i = scripts.length; i--; ) {
- if (scripts[i].readyState === "interactive" && (jsPath = scripts[i].src)) {
- return jsPath;
- }
- }
- }
- if (_document.readyState === "loading" && (jsPath = scripts[scripts.length - 1].src)) {
- return jsPath;
- }
- if (jsPath = _getCurrentScriptUrlFromError()) {
- return jsPath;
- }
- return undefined;
- };
- /**
- * Get the unanimous parent directory of ALL script tags.
- * If any script tags are either (a) inline or (b) from differing parent
- * directories, this method must return `undefined`.
- *
- * @returns String or `undefined`
- * @private
- */
- var _getUnanimousScriptParentDir = function() {
- var i, jsDir, jsPath, scripts = _document.getElementsByTagName("script");
- for (i = scripts.length; i--; ) {
- if (!(jsPath = scripts[i].src)) {
- jsDir = null;
- break;
- }
- jsPath = _getDirPathOfUrl(jsPath);
- if (jsDir == null) {
- jsDir = jsPath;
- } else if (jsDir !== jsPath) {
- jsDir = null;
- break;
- }
- }
- return jsDir || undefined;
- };
- /**
- * Get the presumed location of the "ZeroClipboard.swf" file, based on the location
- * of the executing JavaScript file (e.g. "ZeroClipboard.js", etc.).
- *
- * @returns String
- * @private
- */
- var _getDefaultSwfPath = function() {
- var jsDir = _getDirPathOfUrl(_getCurrentScriptUrl()) || _getUnanimousScriptParentDir() || "";
- return jsDir + "ZeroClipboard.swf";
- };
- /**
- * Is the client's operating system some version of Windows?
- *
- * @returns Boolean
- * @private
- */
- var _isWindows = function() {
- var isWindowsRegex = /win(dows|[\s]?(nt|me|ce|xp|vista|[\d]+))/i;
- return !!_navigator && (isWindowsRegex.test(_navigator.appVersion || "") || isWindowsRegex.test(_navigator.platform || "") || (_navigator.userAgent || "").indexOf("Windows") !== -1);
- };
- /**
- * Keep track of if the page is framed (in an `iframe`). This can never change.
- * @private
- */
- var _pageIsFramed = function() {
- return _window.opener == null && (!!_window.top && _window != _window.top || !!_window.parent && _window != _window.parent);
- }();
- /**
- * Keep track of if the page is XHTML (vs. HTML), which requires that everything
- * be rendering in XML mode.
- * @private
- */
- var _pageIsXhtml = _document.documentElement.nodeName === "html";
- /**
- * Keep track of the state of the Flash object.
- * @private
- */
- var _flashState = {
- bridge: null,
- version: "0.0.0",
- pluginType: "unknown",
- sandboxed: null,
- disabled: null,
- outdated: null,
- insecure: null,
- unavailable: null,
- degraded: null,
- deactivated: null,
- overdue: null,
- ready: null
- };
- /**
- * The minimum Flash Player version required to use ZeroClipboard completely.
- * @readonly
- * @private
- */
- var _minimumFlashVersion = "11.0.0";
- /**
- * The ZeroClipboard library version number, as reported by Flash, at the time the SWF was compiled.
- */
- var _zcSwfVersion;
- /**
- * Keep track of all event listener registrations.
- * @private
- */
- var _handlers = {};
- /**
- * Keep track of the currently activated element.
- * @private
- */
- var _currentElement;
- /**
- * Keep track of the element that was activated when a `copy` process started.
- * @private
- */
- var _copyTarget;
- /**
- * Keep track of data for the pending clipboard transaction.
- * @private
- */
- var _clipData = {};
- /**
- * Keep track of data formats for the pending clipboard transaction.
- * @private
- */
- var _clipDataFormatMap = null;
- /**
- * Keep track of the Flash availability check timeout.
- * @private
- */
- var _flashCheckTimeout = 0;
- /**
- * Keep track of SWF network errors interval polling.
- * @private
- */
- var _swfFallbackCheckInterval = 0;
- /**
- * The `message` store for events
- * @private
- */
- var _eventMessages = {
- ready: "Flash communication is established",
- error: {
- "flash-sandboxed": "Attempting to run Flash in a sandboxed iframe, which is impossible",
- "flash-disabled": "Flash is disabled or not installed. May also be attempting to run Flash in a sandboxed iframe, which is impossible.",
- "flash-outdated": "Flash is too outdated to support ZeroClipboard",
- "flash-insecure": "Flash will be unable to communicate due to a protocol mismatch between your `swfPath` configuration and the page",
- "flash-unavailable": "Flash is unable to communicate bidirectionally with JavaScript",
- "flash-degraded": "Flash is unable to preserve data fidelity when communicating with JavaScript",
- "flash-deactivated": "Flash is too outdated for your browser and/or is configured as click-to-activate.\nThis may also mean that the ZeroClipboard SWF object could not be loaded, so please check your `swfPath` configuration and/or network connectivity.\nMay also be attempting to run Flash in a sandboxed iframe, which is impossible.",
- "flash-overdue": "Flash communication was established but NOT within the acceptable time limit",
- "version-mismatch": "ZeroClipboard JS version number does not match ZeroClipboard SWF version number",
- "clipboard-error": "At least one error was thrown while ZeroClipboard was attempting to inject your data into the clipboard",
- "config-mismatch": "ZeroClipboard configuration does not match Flash's reality",
- "swf-not-found": "The ZeroClipboard SWF object could not be loaded, so please check your `swfPath` configuration and/or network connectivity",
- "browser-unsupported": "The browser does not support the required HTML DOM and JavaScript features"
- }
- };
- /**
- * The `name`s of `error` events that can only occur is Flash has at least
- * been able to load the SWF successfully.
- * @private
- */
- var _errorsThatOnlyOccurAfterFlashLoads = [ "flash-unavailable", "flash-degraded", "flash-overdue", "version-mismatch", "config-mismatch", "clipboard-error" ];
- /**
- * The `name`s of `error` events that should likely result in the `_flashState`
- * variable's property values being updated.
- * @private
- */
- var _flashStateErrorNames = [ "flash-sandboxed", "flash-disabled", "flash-outdated", "flash-insecure", "flash-unavailable", "flash-degraded", "flash-deactivated", "flash-overdue" ];
- /**
- * A RegExp to match the `name` property of `error` events related to Flash.
- * @private
- */
- var _flashStateErrorNameMatchingRegex = new RegExp("^flash-(" + _flashStateErrorNames.map(function(errorName) {
- return errorName.replace(/^flash-/, "");
- }).join("|") + ")$");
- /**
- * A RegExp to match the `name` property of `error` events related to Flash,
- * which is enabled.
- * @private
- */
- var _flashStateEnabledErrorNameMatchingRegex = new RegExp("^flash-(" + _flashStateErrorNames.filter(function(errorName) {
- return errorName !== "flash-disabled";
- }).map(function(errorName) {
- return errorName.replace(/^flash-/, "");
- }).join("|") + ")$");
- /**
- * ZeroClipboard configuration defaults for the Core module.
- * @private
- */
- var _globalConfig = {
- swfPath: _getDefaultSwfPath(),
- trustedDomains: _window.location.host ? [ _window.location.host ] : [],
- cacheBust: true,
- forceEnhancedClipboard: false,
- flashLoadTimeout: 3e4,
- autoActivate: true,
- bubbleEvents: true,
- fixLineEndings: true,
- containerId: "global-zeroclipboard-html-bridge",
- containerClass: "global-zeroclipboard-container",
- swfObjectId: "global-zeroclipboard-flash-bridge",
- hoverClass: "zeroclipboard-is-hover",
- activeClass: "zeroclipboard-is-active",
- forceHandCursor: false,
- title: null,
- zIndex: 999999999
- };
- /**
- * The underlying implementation of `ZeroClipboard.config`.
- * @private
- */
- var _config = function(options) {
- if (typeof options === "object" && options && !("length" in options)) {
- _keys(options).forEach(function(prop) {
- if (/^(?:forceHandCursor|title|zIndex|bubbleEvents|fixLineEndings)$/.test(prop)) {
- _globalConfig[prop] = options[prop];
- } else if (_flashState.bridge == null) {
- if (prop === "containerId" || prop === "swfObjectId") {
- if (_isValidHtml4Id(options[prop])) {
- _globalConfig[prop] = options[prop];
- } else {
- throw new Error("The specified `" + prop + "` value is not valid as an HTML4 Element ID");
- }
- } else {
- _globalConfig[prop] = options[prop];
- }
- }
- });
- }
- if (typeof options === "string" && options) {
- if (_hasOwn.call(_globalConfig, options)) {
- return _globalConfig[options];
- }
- return;
- }
- return _deepCopy(_globalConfig);
- };
- /**
- * The underlying implementation of `ZeroClipboard.state`.
- * @private
- */
- var _state = function() {
- _detectSandbox();
- return {
- browser: _extend(_pick(_navigator, [ "userAgent", "platform", "appName", "appVersion" ]), {
- isSupported: _isBrowserSupported()
- }),
- flash: _omit(_flashState, [ "bridge" ]),
- zeroclipboard: {
- version: ZeroClipboard.version,
- config: ZeroClipboard.config()
- }
- };
- };
- /**
- * Does this browser support all of the necessary DOM and JS features necessary?
- * @private
- */
- var _isBrowserSupported = function() {
- return !!(_document.addEventListener && _window.Object.keys && _window.Array.prototype.map);
- };
- /**
- * The underlying implementation of `ZeroClipboard.isFlashUnusable`.
- * @private
- */
- var _isFlashUnusable = function() {
- return !!(_flashState.sandboxed || _flashState.disabled || _flashState.outdated || _flashState.unavailable || _flashState.degraded || _flashState.deactivated);
- };
- /**
- * The underlying implementation of `ZeroClipboard.on`.
- * @private
- */
- var _on = function(eventType, listener) {
- var i, len, events, added = {};
- if (typeof eventType === "string" && eventType) {
- events = eventType.toLowerCase().split(/\s+/);
- } else if (typeof eventType === "object" && eventType && !("length" in eventType) && typeof listener === "undefined") {
- _keys(eventType).forEach(function(key) {
- var listener = eventType[key];
- if (typeof listener === "function") {
- ZeroClipboard.on(key, listener);
- }
- });
- }
- if (events && events.length && listener) {
- for (i = 0, len = events.length; i < len; i++) {
- eventType = events[i].replace(/^on/, "");
- added[eventType] = true;
- if (!_handlers[eventType]) {
- _handlers[eventType] = [];
- }
- _handlers[eventType].push(listener);
- }
- if (added.ready && _flashState.ready) {
- ZeroClipboard.emit({
- type: "ready"
- });
- }
- if (added.error) {
- if (!_isBrowserSupported()) {
- ZeroClipboard.emit({
- type: "error",
- name: "browser-unsupported"
- });
- }
- for (i = 0, len = _flashStateErrorNames.length; i < len; i++) {
- if (_flashState[_flashStateErrorNames[i].replace(/^flash-/, "")] === true) {
- ZeroClipboard.emit({
- type: "error",
- name: _flashStateErrorNames[i]
- });
- break;
- }
- }
- if (_zcSwfVersion !== undefined && ZeroClipboard.version !== _zcSwfVersion) {
- ZeroClipboard.emit({
- type: "error",
- name: "version-mismatch",
- jsVersion: ZeroClipboard.version,
- swfVersion: _zcSwfVersion
- });
- }
- }
- }
- return ZeroClipboard;
- };
- /**
- * The underlying implementation of `ZeroClipboard.off`.
- * @private
- */
- var _off = function(eventType, listener) {
- var i, len, foundIndex, events, perEventHandlers;
- if (arguments.length === 0) {
- events = _keys(_handlers);
- } else if (typeof eventType === "string" && eventType) {
- events = eventType.toLowerCase().split(/\s+/);
- } else if (typeof eventType === "object" && eventType && !("length" in eventType) && typeof listener === "undefined") {
- _keys(eventType).forEach(function(key) {
- var listener = eventType[key];
- if (typeof listener === "function") {
- ZeroClipboard.off(key, listener);
- }
- });
- }
- if (events && events.length) {
- for (i = 0, len = events.length; i < len; i++) {
- eventType = events[i].replace(/^on/, "");
- perEventHandlers = _handlers[eventType];
- if (perEventHandlers && perEventHandlers.length) {
- if (listener) {
- foundIndex = perEventHandlers.indexOf(listener);
- while (foundIndex !== -1) {
- perEventHandlers.splice(foundIndex, 1);
- foundIndex = perEventHandlers.indexOf(listener, foundIndex);
- }
- } else {
- perEventHandlers.length = 0;
- }
- }
- }
- }
- return ZeroClipboard;
- };
- /**
- * The underlying implementation of `ZeroClipboard.handlers`.
- * @private
- */
- var _listeners = function(eventType) {
- var copy;
- if (typeof eventType === "string" && eventType) {
- copy = _deepCopy(_handlers[eventType]) || null;
- } else {
- copy = _deepCopy(_handlers);
- }
- return copy;
- };
- /**
- * The underlying implementation of `ZeroClipboard.emit`.
- * @private
- */
- var _emit = function(event) {
- var eventCopy, returnVal, tmp;
- event = _createEvent(event);
- if (!event) {
- return;
- }
- if (_preprocessEvent(event)) {
- return;
- }
- if (event.type === "ready" && _flashState.overdue === true) {
- return ZeroClipboard.emit({
- type: "error",
- name: "flash-overdue"
- });
- }
- eventCopy = _extend({}, event);
- _dispatchCallbacks.call(this, eventCopy);
- if (event.type === "copy") {
- tmp = _mapClipDataToFlash(_clipData);
- returnVal = tmp.data;
- _clipDataFormatMap = tmp.formatMap;
- }
- return returnVal;
- };
- /**
- * Get the protocol of the configured SWF path.
- * @private
- */
- var _getSwfPathProtocol = function() {
- var swfPath = _globalConfig.swfPath || "", swfPathFirstTwoChars = swfPath.slice(0, 2), swfProtocol = swfPath.slice(0, swfPath.indexOf("://") + 1);
- return swfPathFirstTwoChars === "\\\\" ? "file:" : swfPathFirstTwoChars === "//" || swfProtocol === "" ? _window.location.protocol : swfProtocol;
- };
- /**
- * The underlying implementation of `ZeroClipboard.create`.
- * @private
- */
- var _create = function() {
- var maxWait, swfProtocol, previousState = _flashState.sandboxed;
- if (!_isBrowserSupported()) {
- _flashState.ready = false;
- ZeroClipboard.emit({
- type: "error",
- name: "browser-unsupported"
- });
- return;
- }
- _detectSandbox();
- if (typeof _flashState.ready !== "boolean") {
- _flashState.ready = false;
- }
- if (_flashState.sandboxed !== previousState && _flashState.sandboxed === true) {
- _flashState.ready = false;
- ZeroClipboard.emit({
- type: "error",
- name: "flash-sandboxed"
- });
- } else if (!ZeroClipboard.isFlashUnusable() && _flashState.bridge === null) {
- swfProtocol = _getSwfPathProtocol();
- if (swfProtocol && swfProtocol !== _window.location.protocol) {
- ZeroClipboard.emit({
- type: "error",
- name: "flash-insecure"
- });
- } else {
- maxWait = _globalConfig.flashLoadTimeout;
- if (typeof maxWait === "number" && maxWait >= 0) {
- _flashCheckTimeout = _setTimeout(function() {
- if (typeof _flashState.deactivated !== "boolean") {
- _flashState.deactivated = true;
- }
- if (_flashState.deactivated === true) {
- ZeroClipboard.emit({
- type: "error",
- name: "flash-deactivated"
- });
- }
- }, maxWait);
- }
- _flashState.overdue = false;
- _embedSwf();
- }
- }
- };
- /**
- * The underlying implementation of `ZeroClipboard.destroy`.
- * @private
- */
- var _destroy = function() {
- ZeroClipboard.clearData();
- ZeroClipboard.blur();
- ZeroClipboard.emit("destroy");
- _unembedSwf();
- ZeroClipboard.off();
- };
- /**
- * The underlying implementation of `ZeroClipboard.setData`.
- * @private
- */
- var _setData = function(format, data) {
- var dataObj;
- if (typeof format === "object" && format && typeof data === "undefined") {
- dataObj = format;
- ZeroClipboard.clearData();
- } else if (typeof format === "string" && format) {
- dataObj = {};
- dataObj[format] = data;
- } else {
- return;
- }
- for (var dataFormat in dataObj) {
- if (typeof dataFormat === "string" && dataFormat && _hasOwn.call(dataObj, dataFormat) && typeof dataObj[dataFormat] === "string" && dataObj[dataFormat]) {
- _clipData[dataFormat] = _fixLineEndings(dataObj[dataFormat]);
- }
- }
- };
- /**
- * The underlying implementation of `ZeroClipboard.clearData`.
- * @private
- */
- var _clearData = function(format) {
- if (typeof format === "undefined") {
- _deleteOwnProperties(_clipData);
- _clipDataFormatMap = null;
- } else if (typeof format === "string" && _hasOwn.call(_clipData, format)) {
- delete _clipData[format];
- }
- };
- /**
- * The underlying implementation of `ZeroClipboard.getData`.
- * @private
- */
- var _getData = function(format) {
- if (typeof format === "undefined") {
- return _deepCopy(_clipData);
- } else if (typeof format === "string" && _hasOwn.call(_clipData, format)) {
- return _clipData[format];
- }
- };
- /**
- * The underlying implementation of `ZeroClipboard.focus`/`ZeroClipboard.activate`.
- * @private
- */
- var _focus = function(element) {
- if (!(element && element.nodeType === 1)) {
- return;
- }
- if (_currentElement) {
- _removeClass(_currentElement, _globalConfig.activeClass);
- if (_currentElement !== element) {
- _removeClass(_currentElement, _globalConfig.hoverClass);
- }
- }
- _currentElement = element;
- _addClass(element, _globalConfig.hoverClass);
- var newTitle = element.getAttribute("title") || _globalConfig.title;
- if (typeof newTitle === "string" && newTitle) {
- var htmlBridge = _getHtmlBridge(_flashState.bridge);
- if (htmlBridge) {
- htmlBridge.setAttribute("title", newTitle);
- }
- }
- var useHandCursor = _globalConfig.forceHandCursor === true || _getStyle(element, "cursor") === "pointer";
- _setHandCursor(useHandCursor);
- _reposition();
- };
- /**
- * The underlying implementation of `ZeroClipboard.blur`/`ZeroClipboard.deactivate`.
- * @private
- */
- var _blur = function() {
- var htmlBridge = _getHtmlBridge(_flashState.bridge);
- if (htmlBridge) {
- htmlBridge.removeAttribute("title");
- htmlBridge.style.left = "0px";
- htmlBridge.style.top = "-9999px";
- htmlBridge.style.width = "1px";
- htmlBridge.style.height = "1px";
- }
- if (_currentElement) {
- _removeClass(_currentElement, _globalConfig.hoverClass);
- _removeClass(_currentElement, _globalConfig.activeClass);
- _currentElement = null;
- }
- };
- /**
- * The underlying implementation of `ZeroClipboard.activeElement`.
- * @private
- */
- var _activeElement = function() {
- return _currentElement || null;
- };
- /**
- * Check if a value is a valid HTML4 `ID` or `Name` token.
- * @private
- */
- var _isValidHtml4Id = function(id) {
- return typeof id === "string" && id && /^[A-Za-z][A-Za-z0-9_:\-\.]*$/.test(id);
- };
- /**
- * Create or update an `event` object, based on the `eventType`.
- * @private
- */
- var _createEvent = function(event) {
- var eventType;
- if (typeof event === "string" && event) {
- eventType = event;
- event = {};
- } else if (typeof event === "object" && event && typeof event.type === "string" && event.type) {
- eventType = event.type;
- }
- if (!eventType) {
- return;
- }
- eventType = eventType.toLowerCase();
- if (!event.target && (/^(copy|aftercopy|_click)$/.test(eventType) || eventType === "error" && event.name === "clipboard-error")) {
- event.target = _copyTarget;
- }
- _extend(event, {
- type: eventType,
- target: event.target || _currentElement || null,
- relatedTarget: event.relatedTarget || null,
- currentTarget: _flashState && _flashState.bridge || null,
- timeStamp: event.timeStamp || _now() || null
- });
- var msg = _eventMessages[event.type];
- if (event.type === "error" && event.name && msg) {
- msg = msg[event.name];
- }
- if (msg) {
- event.message = msg;
- }
- if (event.type === "ready") {
- _extend(event, {
- target: null,
- version: _flashState.version
- });
- }
- if (event.type === "error") {
- if (_flashStateErrorNameMatchingRegex.test(event.name)) {
- _extend(event, {
- target: null,
- minimumVersion: _minimumFlashVersion
- });
- }
- if (_flashStateEnabledErrorNameMatchingRegex.test(event.name)) {
- _extend(event, {
- version: _flashState.version
- });
- }
- if (event.name === "flash-insecure") {
- _extend(event, {
- pageProtocol: _window.location.protocol,
- swfProtocol: _getSwfPathProtocol()
- });
- }
- }
- if (event.type === "copy") {
- event.clipboardData = {
- setData: ZeroClipboard.setData,
- clearData: ZeroClipboard.clearData
- };
- }
- if (event.type === "aftercopy") {
- event = _mapClipResultsFromFlash(event, _clipDataFormatMap);
- }
- if (event.target && !event.relatedTarget) {
- event.relatedTarget = _getRelatedTarget(event.target);
- }
- return _addMouseData(event);
- };
- /**
- * Get a relatedTarget from the target's `data-clipboard-target` attribute
- * @private
- */
- var _getRelatedTarget = function(targetEl) {
- var relatedTargetId = targetEl && targetEl.getAttribute && targetEl.getAttribute("data-clipboard-target");
- return relatedTargetId ? _document.getElementById(relatedTargetId) : null;
- };
- /**
- * Add element and position data to `MouseEvent` instances
- * @private
- */
- var _addMouseData = function(event) {
- if (event && /^_(?:click|mouse(?:over|out|down|up|move))$/.test(event.type)) {
- var srcElement = event.target;
- var fromElement = event.type === "_mouseover" && event.relatedTarget ? event.relatedTarget : undefined;
- var toElement = event.type === "_mouseout" && event.relatedTarget ? event.relatedTarget : undefined;
- var pos = _getElementPosition(srcElement);
- var screenLeft = _window.screenLeft || _window.screenX || 0;
- var screenTop = _window.screenTop || _window.screenY || 0;
- var scrollLeft = _document.body.scrollLeft + _document.documentElement.scrollLeft;
- var scrollTop = _document.body.scrollTop + _document.documentElement.scrollTop;
- var pageX = pos.left + (typeof event._stageX === "number" ? event._stageX : 0);
- var pageY = pos.top + (typeof event._stageY === "number" ? event._stageY : 0);
- var clientX = pageX - scrollLeft;
- var clientY = pageY - scrollTop;
- var screenX = screenLeft + clientX;
- var screenY = screenTop + clientY;
- var moveX = typeof event.movementX === "number" ? event.movementX : 0;
- var moveY = typeof event.movementY === "number" ? event.movementY : 0;
- delete event._stageX;
- delete event._stageY;
- _extend(event, {
- srcElement: srcElement,
- fromElement: fromElement,
- toElement: toElement,
- screenX: screenX,
- screenY: screenY,
- pageX: pageX,
- pageY: pageY,
- clientX: clientX,
- clientY: clientY,
- x: clientX,
- y: clientY,
- movementX: moveX,
- movementY: moveY,
- offsetX: 0,
- offsetY: 0,
- layerX: 0,
- layerY: 0
- });
- }
- return event;
- };
- /**
- * Determine if an event's registered handlers should be execute synchronously or asynchronously.
- *
- * @returns {boolean}
- * @private
- */
- var _shouldPerformAsync = function(event) {
- var eventType = event && typeof event.type === "string" && event.type || "";
- return !/^(?:(?:before)?copy|destroy)$/.test(eventType);
- };
- /**
- * Control if a callback should be executed asynchronously or not.
- *
- * @returns `undefined`
- * @private
- */
- var _dispatchCallback = function(func, context, args, async) {
- if (async) {
- _setTimeout(function() {
- func.apply(context, args);
- }, 0);
- } else {
- func.apply(context, args);
- }
- };
- /**
- * Handle the actual dispatching of events to client instances.
- *
- * @returns `undefined`
- * @private
- */
- var _dispatchCallbacks = function(event) {
- if (!(typeof event === "object" && event && event.type)) {
- return;
- }
- var async = _shouldPerformAsync(event);
- var wildcardTypeHandlers = _handlers["*"] || [];
- var specificTypeHandlers = _handlers[event.type] || [];
- var handlers = wildcardTypeHandlers.concat(specificTypeHandlers);
- if (handlers && handlers.length) {
- var i, len, func, context, eventCopy, originalContext = this;
- for (i = 0, len = handlers.length; i < len; i++) {
- func = handlers[i];
- context = originalContext;
- if (typeof func === "string" && typeof _window[func] === "function") {
- func = _window[func];
- }
- if (typeof func === "object" && func && typeof func.handleEvent === "function") {
- context = func;
- func = func.handleEvent;
- }
- if (typeof func === "function") {
- eventCopy = _extend({}, event);
- _dispatchCallback(func, context, [ eventCopy ], async);
- }
- }
- }
- return this;
- };
- /**
- * Check an `error` event's `name` property to see if Flash has
- * already loaded, which rules out possible `iframe` sandboxing.
- * @private
- */
- var _getSandboxStatusFromErrorEvent = function(event) {
- var isSandboxed = null;
- if (_pageIsFramed === false || event && event.type === "error" && event.name && _errorsThatOnlyOccurAfterFlashLoads.indexOf(event.name) !== -1) {
- isSandboxed = false;
- }
- return isSandboxed;
- };
- /**
- * Preprocess any special behaviors, reactions, or state changes after receiving this event.
- * Executes only once per event emitted, NOT once per client.
- * @private
- */
- var _preprocessEvent = function(event) {
- var element = event.target || _currentElement || null;
- var sourceIsSwf = event._source === "swf";
- delete event._source;
- switch (event.type) {
- case "error":
- var isSandboxed = event.name === "flash-sandboxed" || _getSandboxStatusFromErrorEvent(event);
- if (typeof isSandboxed === "boolean") {
- _flashState.sandboxed = isSandboxed;
- }
- if (event.name === "browser-unsupported") {
- _extend(_flashState, {
- disabled: false,
- outdated: false,
- unavailable: false,
- degraded: false,
- deactivated: false,
- overdue: false,
- ready: false
- });
- } else if (_flashStateErrorNames.indexOf(event.name) !== -1) {
- _extend(_flashState, {
- disabled: event.name === "flash-disabled",
- outdated: event.name === "flash-outdated",
- insecure: event.name === "flash-insecure",
- unavailable: event.name === "flash-unavailable",
- degraded: event.name === "flash-degraded",
- deactivated: event.name === "flash-deactivated",
- overdue: event.name === "flash-overdue",
- ready: false
- });
- } else if (event.name === "version-mismatch") {
- _zcSwfVersion = event.swfVersion;
- _extend(_flashState, {
- disabled: false,
- outdated: false,
- insecure: false,
- unavailable: false,
- degraded: false,
- deactivated: false,
- overdue: false,
- ready: false
- });
- }
- _clearTimeoutsAndPolling();
- break;
- case "ready":
- _zcSwfVersion = event.swfVersion;
- var wasDeactivated = _flashState.deactivated === true;
- _extend(_flashState, {
- sandboxed: false,
- disabled: false,
- outdated: false,
- insecure: false,
- unavailable: false,
- degraded: false,
- deactivated: false,
- overdue: wasDeactivated,
- ready: !wasDeactivated
- });
- _clearTimeoutsAndPolling();
- break;
- case "beforecopy":
- _copyTarget = element;
- break;
- case "copy":
- var textContent, htmlContent, targetEl = event.relatedTarget;
- if (!(_clipData["text/html"] || _clipData["text/plain"]) && targetEl && (htmlContent = targetEl.value || targetEl.outerHTML || targetEl.innerHTML) && (textContent = targetEl.value || targetEl.textContent || targetEl.innerText)) {
- event.clipboardData.clearData();
- event.clipboardData.setData("text/plain", textContent);
- if (htmlContent !== textContent) {
- event.clipboardData.setData("text/html", htmlContent);
- }
- } else if (!_clipData["text/plain"] && event.target && (textContent = event.target.getAttribute("data-clipboard-text"))) {
- event.clipboardData.clearData();
- event.clipboardData.setData("text/plain", textContent);
- }
- break;
- case "aftercopy":
- _queueEmitClipboardErrors(event);
- ZeroClipboard.clearData();
- if (element && element !== _safeActiveElement() && element.focus) {
- element.focus();
- }
- break;
- case "_mouseover":
- ZeroClipboard.focus(element);
- if (_globalConfig.bubbleEvents === true && sourceIsSwf) {
- if (element && element !== event.relatedTarget && !_containedBy(event.relatedTarget, element)) {
- _fireMouseEvent(_extend({}, event, {
- type: "mouseenter",
- bubbles: false,
- cancelable: false
- }));
- }
- _fireMouseEvent(_extend({}, event, {
- type: "mouseover"
- }));
- }
- break;
- case "_mouseout":
- ZeroClipboard.blur();
- if (_globalConfig.bubbleEvents === true && sourceIsSwf) {
- if (element && element !== event.relatedTarget && !_containedBy(event.relatedTarget, element)) {
- _fireMouseEvent(_extend({}, event, {
- type: "mouseleave",
- bubbles: false,
- cancelable: false
- }));
- }
- _fireMouseEvent(_extend({}, event, {
- type: "mouseout"
- }));
- }
- break;
- case "_mousedown":
- _addClass(element, _globalConfig.activeClass);
- if (_globalConfig.bubbleEvents === true && sourceIsSwf) {
- _fireMouseEvent(_extend({}, event, {
- type: event.type.slice(1)
- }));
- }
- break;
- case "_mouseup":
- _removeClass(element, _globalConfig.activeClass);
- if (_globalConfig.bubbleEvents === true && sourceIsSwf) {
- _fireMouseEvent(_extend({}, event, {
- type: event.type.slice(1)
- }));
- }
- break;
- case "_click":
- _copyTarget = null;
- if (_globalConfig.bubbleEvents === true && sourceIsSwf) {
- _fireMouseEvent(_extend({}, event, {
- type: event.type.slice(1)
- }));
- }
- break;
- case "_mousemove":
- if (_globalConfig.bubbleEvents === true && sourceIsSwf) {
- _fireMouseEvent(_extend({}, event, {
- type: event.type.slice(1)
- }));
- }
- break;
- }
- if (/^_(?:click|mouse(?:over|out|down|up|move))$/.test(event.type)) {
- return true;
- }
- };
- /**
- * Check an "aftercopy" event for clipboard errors and emit a corresponding "error" event.
- * @private
- */
- var _queueEmitClipboardErrors = function(aftercopyEvent) {
- if (aftercopyEvent.errors && aftercopyEvent.errors.length > 0) {
- var errorEvent = _deepCopy(aftercopyEvent);
- _extend(errorEvent, {
- type: "error",
- name: "clipboard-error"
- });
- delete errorEvent.success;
- _setTimeout(function() {
- ZeroClipboard.emit(errorEvent);
- }, 0);
- }
- };
- /**
- * Dispatch a synthetic MouseEvent.
- *
- * @returns `undefined`
- * @private
- */
- var _fireMouseEvent = function(event) {
- if (!(event && typeof event.type === "string" && event)) {
- return;
- }
- var e, target = event.target || null, doc = target && target.ownerDocument || _document, defaults = {
- view: doc.defaultView || _window,
- canBubble: true,
- cancelable: true,
- detail: event.type === "click" ? 1 : 0,
- button: typeof event.which === "number" ? event.which - 1 : typeof event.button === "number" ? event.button : doc.createEvent ? 0 : 1
- }, args = _extend(defaults, event);
- if (!target) {
- return;
- }
- if (doc.createEvent && target.dispatchEvent) {
- args = [ args.type, args.canBubble, args.cancelable, args.view, args.detail, args.screenX, args.screenY, args.clientX, args.clientY, args.ctrlKey, args.altKey, args.shiftKey, args.metaKey, args.button, args.relatedTarget ];
- e = doc.createEvent("MouseEvents");
- if (e.initMouseEvent) {
- e.initMouseEvent.apply(e, args);
- e._source = "js";
- target.dispatchEvent(e);
- }
- }
- };
- /**
- * Continuously poll the DOM until either:
- * (a) the fallback content becomes visible, or
- * (b) we receive an event from SWF (handled elsewhere)
- *
- * IMPORTANT:
- * This is NOT a necessary check but it can result in significantly faster
- * detection of bad `swfPath` configuration and/or network/server issues [in
- * supported browsers] than waiting for the entire `flashLoadTimeout` duration
- * to elapse before detecting that the SWF cannot be loaded. The detection
- * duration can be anywhere from 10-30 times faster [in supported browsers] by
- * using this approach.
- *
- * @returns `undefined`
- * @private
- */
- var _watchForSwfFallbackContent = function() {
- var maxWait = _globalConfig.flashLoadTimeout;
- if (typeof maxWait === "number" && maxWait >= 0) {
- var pollWait = Math.min(1e3, maxWait / 10);
- var fallbackContentId = _globalConfig.swfObjectId + "_fallbackContent";
- _swfFallbackCheckInterval = _setInterval(function() {
- var el = _document.getElementById(fallbackContentId);
- if (_isElementVisible(el)) {
- _clearTimeoutsAndPolling();
- _flashState.deactivated = null;
- ZeroClipboard.emit({
- type: "error",
- name: "swf-not-found"
- });
- }
- }, pollWait);
- }
- };
- /**
- * Create the HTML bridge element to embed the Flash object into.
- * @private
- */
- var _createHtmlBridge = function() {
- var container = _document.createElement("div");
- container.id = _globalConfig.containerId;
- container.className = _globalConfig.containerClass;
- container.style.position = "absolute";
- container.style.left = "0px";
- container.style.top = "-9999px";
- container.style.width = "1px";
- container.style.height = "1px";
- container.style.zIndex = "" + _getSafeZIndex(_globalConfig.zIndex);
- return container;
- };
- /**
- * Get the HTML element container that wraps the Flash bridge object/element.
- * @private
- */
- var _getHtmlBridge = function(flashBridge) {
- var htmlBridge = flashBridge && flashBridge.parentNode;
- while (htmlBridge && htmlBridge.nodeName === "OBJECT" && htmlBridge.parentNode) {
- htmlBridge = htmlBridge.parentNode;
- }
- return htmlBridge || null;
- };
- /**
- *
- * @private
- */
- var _escapeXmlValue = function(val) {
- if (typeof val !== "string" || !val) {
- return val;
- }
- return val.replace(/["&'<>]/g, function(chr) {
- switch (chr) {
- case '"':
- return """;
- case "&":
- return "&";
- case "'":
- return "'";
- case "<":
- return "<";
- case ">":
- return ">";
- default:
- return chr;
- }
- });
- };
- /**
- * Create the SWF object.
- *
- * @returns The SWF object reference.
- * @private
- */
- var _embedSwf = function() {
- var len, flashBridge = _flashState.bridge, container = _getHtmlBridge(flashBridge);
- if (!flashBridge) {
- var allowScriptAccess = _determineScriptAccess(_window.location.host, _globalConfig);
- var allowNetworking = allowScriptAccess === "never" ? "none" : "all";
- var flashvars = _vars(_extend({
- jsVersion: ZeroClipboard.version
- }, _globalConfig));
- var swfUrl = _globalConfig.swfPath + _cacheBust(_globalConfig.swfPath, _globalConfig);
- if (_pageIsXhtml) {
- swfUrl = _escapeXmlValue(swfUrl);
- }
- container = _createHtmlBridge();
- var divToBeReplaced = _document.createElement("div");
- container.appendChild(divToBeReplaced);
- _document.body.appendChild(container);
- var tmpDiv = _document.createElement("div");
- var usingActiveX = _flashState.pluginType === "activex";
- tmpDiv.innerHTML = '<object id="' + _globalConfig.swfObjectId + '" name="' + _globalConfig.swfObjectId + '" ' + 'width="100%" height="100%" ' + (usingActiveX ? 'classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"' : 'type="application/x-shockwave-flash" data="' + swfUrl + '"') + ">" + (usingActiveX ? '<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 + '"/>' + '<div id="' + _globalConfig.swfObjectId + '_fallbackContent"> </div>' + "</object>";
- flashBridge = tmpDiv.firstChild;
- tmpDiv = null;
- _unwrap(flashBridge).ZeroClipboard = ZeroClipboard;
- container.replaceChild(flashBridge, divToBeReplaced);
- _watchForSwfFallbackContent();
- }
- if (!flashBridge) {
- flashBridge = _document[_globalConfig.swfObjectId];
- if (flashBridge && (len = flashBridge.length)) {
- flashBridge = flashBridge[len - 1];
- }
- if (!flashBridge && container) {
- flashBridge = container.firstChild;
- }
- }
- _flashState.bridge = flashBridge || null;
- return flashBridge;
- };
- /**
- * Destroy the SWF object.
- * @private
- */
- var _unembedSwf = function() {
- var flashBridge = _flashState.bridge;
- if (flashBridge) {
- var htmlBridge = _getHtmlBridge(flashBridge);
- if (htmlBridge) {
- if (_flashState.pluginType === "activex" && "readyState" in flashBridge) {
- flashBridge.style.display = "none";
- (function removeSwfFromIE() {
- if (flashBridge.readyState === 4) {
- for (var prop in flashBridge) {
- if (typeof flashBridge[prop] === "function") {
- flashBridge[prop] = null;
- }
- }
- if (flashBridge.parentNode) {
- flashBridge.parentNode.removeChild(flashBridge);
- }
- if (htmlBridge.parentNode) {
- htmlBridge.parentNode.removeChild(htmlBridge);
- }
- } else {
- _setTimeout(removeSwfFromIE, 10);
- }
- })();
- } else {
- if (flashBridge.parentNode) {
- flashBridge.parentNode.removeChild(flashBridge);
- }
- if (htmlBridge.parentNode) {
- htmlBridge.parentNode.removeChild(htmlBridge);
- }
- }
- }
- _clearTimeoutsAndPolling();
- _flashState.ready = null;
- _flashState.bridge = null;
- _flashState.deactivated = null;
- _flashState.insecure = null;
- _zcSwfVersion = undefined;
- }
- };
- /**
- * Map the data format names of the "clipData" to Flash-friendly names.
- *
- * @returns A new transformed object.
- * @private
- */
- var _mapClipDataToFlash = function(clipData) {
- var newClipData = {}, formatMap = {};
- if (!(typeof clipData === "object" && clipData)) {
- return;
- }
- for (var dataFormat in clipData) {
- if (dataFormat && _hasOwn.call(clipData, dataFormat) && typeof clipData[dataFormat] === "string" && clipData[dataFormat]) {
- switch (dataFormat.toLowerCase()) {
- case "text/plain":
- case "text":
- case "air:text":
- case "flash:text":
- newClipData.text = clipData[dataFormat];
- formatMap.text = dataFormat;
- break;
- case "text/html":
- case "html":
- case "air:html":
- case "flash:html":
- newClipData.html = clipData[dataFormat];
- formatMap.html = dataFormat;
- break;
- case "application/rtf":
- case "text/rtf":
- case "rtf":
- case "richtext":
- case "air:rtf":
- case "flash:rtf":
- newClipData.rtf = clipData[dataFormat];
- formatMap.rtf = dataFormat;
- break;
- default:
- break;
- }
- }
- }
- return {
- data: newClipData,
- formatMap: formatMap
- };
- };
- /**
- * Map the data format names from Flash-friendly names back to their original "clipData" names (via a format mapping).
- *
- * @returns A new transformed object.
- * @private
- */
- var _mapClipResultsFromFlash = function(clipResults, formatMap) {
- if (!(typeof clipResults === "object" && clipResults && typeof formatMap === "object" && formatMap)) {
- return clipResults;
- }
- var newResults = {};
- for (var prop in clipResults) {
- if (_hasOwn.call(clipResults, prop)) {
- if (prop === "errors") {
- newResults[prop] = clipResults[prop] ? clipResults[prop].slice() : [];
- for (var i = 0, len = newResults[prop].length; i < len; i++) {
- newResults[prop][i].format = formatMap[newResults[prop][i].format];
- }
- } else if (prop !== "success" && prop !== "data") {
- newResults[prop] = clipResults[prop];
- } else {
- newResults[prop] = {};
- var tmpHash = clipResults[prop];
- for (var dataFormat in tmpHash) {
- if (dataFormat && _hasOwn.call(tmpHash, dataFormat) && _hasOwn.call(formatMap, dataFormat)) {
- newResults[prop][formatMap[dataFormat]] = tmpHash[dataFormat];
- }
- }
- }
- }
- }
- return newResults;
- };
- /**
- * Will look at a path, and will create a "?noCache={time}" or "&noCache={time}"
- * query param string to return. Does NOT append that string to the original path.
- * This is useful because ExternalInterface often breaks when a Flash SWF is cached.
- *
- * @returns The `noCache` query param with necessary "?"/"&" prefix.
- * @private
- */
- var _cacheBust = function(path, options) {
- var cacheBust = options == null || options && options.cacheBust === true;
- if (cacheBust) {
- return (path.indexOf("?") === -1 ? "?" : "&") + "noCache=" + _now();
- } else {
- return "";
- }
- };
- /**
- * Creates a query string for the FlashVars param.
- * Does NOT include the cache-busting query param.
- *
- * @returns FlashVars query string
- * @private
- */
- var _vars = function(options) {
- var i, len, domain, domains, str = "", trustedOriginsExpanded = [];
- if (options.trustedDomains) {
- if (typeof options.trustedDomains === "string") {
- domains = [ options.trustedDomains ];
- } else if (typeof options.trustedDomains === "object" && "length" in options.trustedDomains) {
- domains = options.trustedDomains;
- }
- }
- if (domains && domains.length) {
- for (i = 0, len = domains.length; i < len; i++) {
- if (_hasOwn.call(domains, i) && domains[i] && typeof domains[i] === "string") {
- domain = _extractDomain(domains[i]);
- if (!domain) {
- continue;
- }
- if (domain === "*") {
- trustedOriginsExpanded.length = 0;
- trustedOriginsExpanded.push(domain);
- break;
- }
- trustedOriginsExpanded.push.apply(trustedOriginsExpanded, [ domain, "//" + domain, _window.location.protocol + "//" + domain ]);
- }
- }
- }
- if (trustedOriginsExpanded.length) {
- str += "trustedOrigins=" + _encodeURIComponent(trustedOriginsExpanded.join(","));
- }
- if (options.forceEnhancedClipboard === true) {
- str += (str ? "&" : "") + "forceEnhancedClipboard=true";
- }
- if (typeof options.swfObjectId === "string" && options.swfObjectId) {
- str += (str ? "&" : "") + "swfObjectId=" + _encodeURIComponent(options.swfObjectId);
- }
- if (typeof options.jsVersion === "string" && options.jsVersion) {
- str += (str ? "&" : "") + "jsVersion=" + _encodeURIComponent(options.jsVersion);
- }
- return str;
- };
- /**
- * Extract the domain (e.g. "github.com") from an origin (e.g. "https://github.com") or
- * URL (e.g. "https://github.com/zeroclipboard/zeroclipboard/").
- *
- * @returns the domain
- * @private
- */
- var _extractDomain = function(originOrUrl) {
- if (originOrUrl == null || originOrUrl === "") {
- return null;
- }
- originOrUrl = originOrUrl.replace(/^\s+|\s+$/g, "");
- if (originOrUrl === "") {
- return null;
- }
- var protocolIndex = originOrUrl.indexOf("//");
- originOrUrl = protocolIndex === -1 ? originOrUrl : originOrUrl.slice(protocolIndex + 2);
- var pathIndex = originOrUrl.indexOf("/");
- originOrUrl = pathIndex === -1 ? originOrUrl : protocolIndex === -1 || pathIndex === 0 ? null : originOrUrl.slice(0, pathIndex);
- if (originOrUrl && originOrUrl.slice(-4).toLowerCase() === ".swf") {
- return null;
- }
- return originOrUrl || null;
- };
- /**
- * Set `allowScriptAccess` based on `trustedDomains` and `window.location.host` vs. `swfPath`.
- *
- * @returns The appropriate script access level.
- * @private
- */
- var _determineScriptAccess = function() {
- var _extractAllDomains = function(origins) {
- var i, len, tmp, resultsArray = [];
- if (typeof origins === "string") {
- origins = [ origins ];
- }
- if (!(typeof origins === "object" && origins && typeof origins.length === "number")) {
- return resultsArray;
- }
- for (i = 0, len = origins.length; i < len; i++) {
- if (_hasOwn.call(origins, i) && (tmp = _extractDomain(origins[i]))) {
- if (tmp === "*") {
- resultsArray.length = 0;
- resultsArray.push("*");
- break;
- }
- if (resultsArray.indexOf(tmp) === -1) {
- resultsArray.push(tmp);
- }
- }
- }
- return resultsArray;
- };
- return function(currentDomain, configOptions) {
- var swfDomain = _extractDomain(configOptions.swfPath);
- if (swfDomain === null) {
- swfDomain = currentDomain;
- }
- var trustedDomains = _extractAllDomains(configOptions.trustedDomains);
- var len = trustedDomains.length;
- if (len > 0) {
- if (len === 1 && trustedDomains[0] === "*") {
- return "always";
- }
- if (trustedDomains.indexOf(currentDomain) !== -1) {
- if (len === 1 && currentDomain === swfDomain) {
- return "sameDomain";
- }
- return "always";
- }
- }
- return "never";
- };
- }();
- /**
- * Get the currently active/focused DOM element.
- *
- * @returns the currently active/focused element, or `null`
- * @private
- */
- var _safeActiveElement = function() {
- try {
- return _document.activeElement;
- } catch (err) {
- return null;
- }
- };
- /**
- * Add a class to an element, if it doesn't already have it.
- *
- * @returns The element, with its new class added.
- * @private
- */
- var _addClass = function(element, value) {
- var c, cl, className, classNames = [];
- if (typeof value === "string" && value) {
- classNames = value.split(/\s+/);
- }
- if (element && element.nodeType === 1 && classNames.length > 0) {
- className = (" " + (element.className || "") + " ").replace(/[\t\r\n\f]/g, " ");
- for (c = 0, cl = classNames.length; c < cl; c++) {
- if (className.indexOf(" " + classNames[c] + " ") === -1) {
- className += classNames[c] + " ";
- }
- }
- className = className.replace(/^\s+|\s+$/g, "");
- if (className !== element.className) {
- element.className = className;
- }
- }
- return element;
- };
- /**
- * Remove a class from an element, if it has it.
- *
- * @returns The element, with its class removed.
- * @private
- */
- var _removeClass = function(element, value) {
- var c, cl, className, classNames = [];
- if (typeof value === "string" && value) {
- classNames = value.split(/\s+/);
- }
- if (element && element.nodeType === 1 && classNames.length > 0) {
- if (element.className) {
- className = (" " + element.className + " ").replace(/[\t\r\n\f]/g, " ");
- for (c = 0, cl = classNames.length; c < cl; c++) {
- className = className.replace(" " + classNames[c] + " ", " ");
- }
- className = className.replace(/^\s+|\s+$/g, "");
- if (className !== element.className) {
- element.className = className;
- }
- }
- }
- return element;
- };
- /**
- * Attempt to interpret the element's CSS styling. If `prop` is `"cursor"`,
- * then we assume that it should be a hand ("pointer") cursor if the element
- * is an anchor element ("a" tag).
- *
- * @returns The computed style property.
- * @private
- */
- var _getStyle = function(el, prop) {
- var value = _getComputedStyle(el, null).getPropertyValue(prop);
- if (prop === "cursor") {
- if (!value || value === "auto") {
- if (el.nodeName === "A") {
- return "pointer";
- }
- }
- }
- return value;
- };
- /**
- * Get the absolutely positioned coordinates of a DOM element.
- *
- * @returns Object containing the element's position, width, and height.
- * @private
- */
- var _getElementPosition = function(el) {
- var pos = {
- left: 0,
- top: 0,
- width: 0,
- height: 0
- };
- if (el.getBoundingClientRect) {
- var elRect = el.getBoundingClientRect();
- var pageXOffset = _window.pageXOffset;
- var pageYOffset = _window.pageYOffset;
- var leftBorderWidth = _document.documentElement.clientLeft || 0;
- var topBorderWidth = _document.documentElement.clientTop || 0;
- var leftBodyOffset = 0;
- var topBodyOffset = 0;
- if (_getStyle(_document.body, "position") === "relative") {
- var bodyRect = _document.body.getBoundingClientRect();
- var htmlRect = _document.documentElement.getBoundingClientRect();
- leftBodyOffset = bodyRect.left - htmlRect.left || 0;
- topBodyOffset = bodyRect.top - htmlRect.top || 0;
- }
- pos.left = elRect.left + pageXOffset - leftBorderWidth - leftBodyOffset;
- pos.top = elRect.top + pageYOffset - topBorderWidth - topBodyOffset;
- pos.width = "width" in elRect ? elRect.width : elRect.right - elRect.left;
- pos.height = "height" in elRect ? elRect.height : elRect.bottom - elRect.top;
- }
- return pos;
- };
- /**
- * Determine is an element is visible somewhere within the document (page).
- *
- * @returns Boolean
- * @private
- */
- var _isElementVisible = function(el) {
- if (!el) {
- return false;
- }
- var styles = _getComputedStyle(el, null);
- if (!styles) {
- return false;
- }
- var hasCssHeight = _parseFloat(styles.height) > 0;
- var hasCssWidth = _parseFloat(styles.width) > 0;
- var hasCssTop = _parseFloat(styles.top) >= 0;
- var hasCssLeft = _parseFloat(styles.left) >= 0;
- var cssKnows = hasCssHeight && hasCssWidth && hasCssTop && hasCssLeft;
- var rect = cssKnows ? null : _getElementPosition(el);
- var isVisible = styles.display !== "none" && styles.visibility !== "collapse" && (cssKnows || !!rect && (hasCssHeight || rect.height > 0) && (hasCssWidth || rect.width > 0) && (hasCssTop || rect.top >= 0) && (hasCssLeft || rect.left >= 0));
- return isVisible;
- };
- /**
- * Clear all existing timeouts and interval polling delegates.
- *
- * @returns `undefined`
- * @private
- */
- var _clearTimeoutsAndPolling = function() {
- _clearTimeout(_flashCheckTimeout);
- _flashCheckTimeout = 0;
- _clearInterval(_swfFallbackCheckInterval);
- _swfFallbackCheckInterval = 0;
- };
- /**
- * Reposition the Flash object to cover the currently activated element.
- *
- * @returns `undefined`
- * @private
- */
- var _reposition = function() {
- var htmlBridge;
- if (_currentElement && (htmlBridge = _getHtmlBridge(_flashState.bridge))) {
- var pos = _getElementPosition(_currentElement);
- _extend(htmlBridge.style, {
- width: pos.width + "px",
- height: pos.height + "px",
- top: pos.top + "px",
- left: pos.left + "px",
- zIndex: "" + _getSafeZIndex(_globalConfig.zIndex)
- });
- }
- };
- /**
- * Sends a signal to the Flash object to display the hand cursor if `true`.
- *
- * @returns `undefined`
- * @private
- */
- var _setHandCursor = function(enabled) {
- if (_flashState.ready === true) {
- if (_flashState.bridge && typeof _flashState.bridge.setHandCursor === "function") {
- _flashState.bridge.setHandCursor(enabled);
- } else {
- _flashState.ready = false;
- }
- }
- };
- /**
- * Get a safe value for `zIndex`
- *
- * @returns an integer, or "auto"
- * @private
- */
- var _getSafeZIndex = function(val) {
- if (/^(?:auto|inherit)$/.test(val)) {
- return val;
- }
- var zIndex;
- if (typeof val === "number" && !_isNaN(val)) {
- zIndex = val;
- } else if (typeof val === "string") {
- zIndex = _getSafeZIndex(_parseInt(val, 10));
- }
- return typeof zIndex === "number" ? zIndex : "auto";
- };
- /**
- * Ensure OS-compliant line endings, i.e. "\r\n" on Windows, "\n" elsewhere
- *
- * @returns string
- * @private
- */
- var _fixLineEndings = function(content) {
- var replaceRegex = /(\r\n|\r|\n)/g;
- if (typeof content === "string" && _globalConfig.fixLineEndings === true) {
- if (_isWindows()) {
- if (/((^|[^\r])\n|\r([^\n]|$))/.test(content)) {
- content = content.replace(replaceRegex, "\r\n");
- }
- } else if (/\r/.test(content)) {
- content = content.replace(replaceRegex, "\n");
- }
- }
- return content;
- };
- /**
- * Attempt to detect if ZeroClipboard is executing inside of a sandboxed iframe.
- * If it is, Flash Player cannot be used, so ZeroClipboard is dead in the water.
- *
- * @see {@link http://lists.w3.org/Archives/Public/public-whatwg-archive/2014Dec/0002.html}
- * @see {@link https://github.com/zeroclipboard/zeroclipboard/issues/511}
- * @see {@link http://zeroclipboard.org/test-iframes.html}
- *
- * @returns `true` (is sandboxed), `false` (is not sandboxed), or `null` (uncertain)
- * @private
- */
- var _detectSandbox = function(doNotReassessFlashSupport) {
- var effectiveScriptOrigin, frame, frameError, previousState = _flashState.sandboxed, isSandboxed = null;
- doNotReassessFlashSupport = doNotReassessFlashSupport === true;
- if (_pageIsFramed === false) {
- isSandboxed = false;
- } else {
- try {
- frame = window.frameElement || null;
- } catch (e) {
- frameError = {
- name: e.name,
- message: e.message
- };
- }
- if (frame && frame.nodeType === 1 && frame.nodeName === "IFRAME") {
- try {
- isSandboxed = frame.hasAttribute("sandbox");
- } catch (e) {
- isSandboxed = null;
- }
- } else {
- try {
- effectiveScriptOrigin = document.domain || null;
- } catch (e) {
- effectiveScriptOrigin = null;
- }
- if (effectiveScriptOrigin === null || frameError && frameError.name === "SecurityError" && /(^|[\s\(\[@])sandbox(es|ed|ing|[\s\.,!\)\]@]|$)/.test(frameError.message.toLowerCase())) {
- isSandboxed = true;
- }
- }
- }
- _flashState.sandboxed = isSandboxed;
- if (previousState !== isSandboxed && !doNotReassessFlashSupport) {
- _detectFlashSupport(_ActiveXObject);
- }
- return isSandboxed;
- };
- /**
- * Detect the Flash Player status, version, and plugin type.
- *
- * @see {@link https://code.google.com/p/doctype-mirror/wiki/ArticleDetectFlash#The_code}
- * @see {@link http://stackoverflow.com/questions/12866060/detecting-pepper-ppapi-flash-with-javascript}
- *
- * @returns `undefined`
- * @private
- */
- var _detectFlashSupport = function(ActiveXObject) {
- var plugin, ax, mimeType, hasFlash = false, isActiveX = false, isPPAPI = false, flashVersion = "";
- /**
- * Derived from Apple's suggested sniffer.
- * @param {String} desc e.g. "Shockwave Flash 7.0 r61"
- * @returns {String} "7.0.61"
- * @private
- */
- function parseFlashVersion(desc) {
- var matches = desc.match(/[\d]+/g);
- matches.length = 3;
- return matches.join(".");
- }
- function isPepperFlash(flashPlayerFileName) {
- return !!flashPlayerFileName && (flashPlayerFileName = flashPlayerFileName.toLowerCase()) && (/^(pepflashplayer\.dll|libpepflashplayer\.so|pepperflashplayer\.plugin)$/.test(flashPlayerFileName) || flashPlayerFileName.slice(-13) === "chrome.plugin");
- }
- function inspectPlugin(plugin) {
- if (plugin) {
- hasFlash = true;
- if (plugin.version) {
- flashVersion = parseFlashVersion(plugin.version);
- }
- if (!flashVersion && plugin.description) {
- flashVersion = parseFlashVersion(plugin.description);
- }
- if (plugin.filename) {
- isPPAPI = isPepperFlash(plugin.filename);
- }
- }
- }
- if (_navigator.plugins && _navigator.plugins.length) {
- plugin = _navigator.plugins["Shockwave Flash"];
- inspectPlugin(plugin);
- if (_navigator.plugins["Shockwave Flash 2.0"]) {
- hasFlash = true;
- flashVersion = "2.0.0.11";
- }
- } else if (_navigator.mimeTypes && _navigator.mimeTypes.length) {
- mimeType = _navigator.mimeTypes["application/x-shockwave-flash"];
- plugin = mimeType && mimeType.enabledPlugin;
- inspectPlugin(plugin);
- } else if (typeof ActiveXObject !== "undefined") {
- isActiveX = true;
- try {
- ax = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");
- hasFlash = true;
- flashVersion = parseFlashVersion(ax.GetVariable("$version"));
- } catch (e1) {
- try {
- ax = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");
- hasFlash = true;
- flashVersion = "6.0.21";
- } catch (e2) {
- try {
- ax = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
- hasFlash = true;
- flashVersion = parseFlashVersion(ax.GetVariable("$version"));
- } catch (e3) {
- isActiveX = false;
- }
- }
- }
- }
- _flashState.disabled = hasFlash !== true;
- _flashState.outdated = flashVersion && _parseFloat(flashVersion) < _parseFloat(_minimumFlashVersion);
- _flashState.version = flashVersion || "0.0.0";
- _flashState.pluginType = isPPAPI ? "pepper" : isActiveX ? "activex" : hasFlash ? "netscape" : "unknown";
- };
- /**
- * Invoke the Flash detection algorithms immediately upon inclusion so we're not waiting later.
- */
- _detectFlashSupport(_ActiveXObject);
- /**
- * Always assess the `sandboxed` state of the page at important Flash-related moments.
- */
- _detectSandbox(true);
- /**
- * A shell constructor for `ZeroClipboard` client instances.
- *
- * @constructor
- */
- var ZeroClipboard = function() {
- if (!(this instanceof ZeroClipboard)) {
- return new ZeroClipboard();
- }
- if (typeof ZeroClipboard._createClient === "function") {
- ZeroClipboard._createClient.apply(this, _args(arguments));
- }
- };
- /**
- * The ZeroClipboard library's version number.
- *
- * @static
- * @readonly
- * @property {string}
- */
- ZeroClipboard.version = "2.3.0";
- /**
- * Update or get a copy of the ZeroClipboard global configuration.
- * Returns a copy of the current/updated configuration.
- *
- * @returns Object
- * @static
- */
- ZeroClipboard.config = function() {
- return _config.apply(this, _args(arguments));
- };
- /**
- * Diagnostic method that describes the state of the browser, Flash Player, and ZeroClipboard.
- *
- * @returns Object
- * @static
- */
- ZeroClipboard.state = function() {
- return _state.apply(this, _args(arguments));
- };
- /**
- * Check if Flash is unusable for any reason: disabled, outdated, deactivated, etc.
- *
- * @returns Boolean
- * @static
- */
- ZeroClipboard.isFlashUnusable = function() {
- return _isFlashUnusable.apply(this, _args(arguments));
- };
- /**
- * Register an event listener.
- *
- * @returns `ZeroClipboard`
- * @static
- */
- ZeroClipboard.on = function() {
- return _on.apply(this, _args(arguments));
- };
- /**
- * Unregister an event listener.
- * If no `listener` function/object is provided, it will unregister all listeners for the provided `eventType`.
- * If no `eventType` is provided, it will unregister all listeners for every event type.
- *
- * @returns `ZeroClipboard`
- * @static
- */
- ZeroClipboard.off = function() {
- return _off.apply(this, _args(arguments));
- };
- /**
- * Retrieve event listeners for an `eventType`.
- * If no `eventType` is provided, it will retrieve all listeners for every event type.
- *
- * @returns array of listeners for the `eventType`; if no `eventType`, then a map/hash object of listeners for all event types; or `null`
- */
- ZeroClipboard.handlers = function() {
- return _listeners.apply(this, _args(arguments));
- };
- /**
- * Event emission receiver from the Flash object, forwarding to any registered JavaScript event listeners.
- *
- * @returns For the "copy" event, returns the Flash-friendly "clipData" object; otherwise `undefined`.
- * @static
- */
- ZeroClipboard.emit = function() {
- return _emit.apply(this, _args(arguments));
- };
- /**
- * Create and embed the Flash object.
- *
- * @returns The Flash object
- * @static
- */
- ZeroClipboard.create = function() {
- return _create.apply(this, _args(arguments));
- };
- /**
- * Self-destruct and clean up everything, including the embedded Flash object.
- *
- * @returns `undefined`
- * @static
- */
- ZeroClipboard.destroy = function() {
- return _destroy.apply(this, _args(arguments));
- };
- /**
- * Set the pending data for clipboard injection.
- *
- * @returns `undefined`
- * @static
- */
- ZeroClipboard.setData = function() {
- return _setData.apply(this, _args(arguments));
- };
- /**
- * Clear the pending data for clipboard injection.
- * If no `format` is provided, all pending data formats will be cleared.
- *
- * @returns `undefined`
- * @static
- */
- ZeroClipboard.clearData = function() {
- return _clearData.apply(this, _args(arguments));
- };
- /**
- * Get a copy of the pending data for clipboard injection.
- * If no `format` is provided, a copy of ALL pending data formats will be returned.
- *
- * @returns `String` or `Object`
- * @static
- */
- ZeroClipboard.getData = function() {
- return _getData.apply(this, _args(arguments));
- };
- /**
- * Sets the current HTML object that the Flash object should overlay. This will put the global
- * Flash object on top of the current element; depending on the setup, this may also set the
- * pending clipboard text data as well as the Flash object's wrapping element's title attribute
- * based on the underlying HTML element and ZeroClipboard configuration.
- *
- * @returns `undefined`
- * @static
- */
- ZeroClipboard.focus = ZeroClipboard.activate = function() {
- return _focus.apply(this, _args(arguments));
- };
- /**
- * Un-overlays the Flash object. This will put the global Flash object off-screen; depending on
- * the setup, this may also unset the Flash object's wrapping element's title attribute based on
- * the underlying HTML element and ZeroClipboard configuration.
- *
- * @returns `undefined`
- * @static
- */
- ZeroClipboard.blur = ZeroClipboard.deactivate = function() {
- return _blur.apply(this, _args(arguments));
- };
- /**
- * Returns the currently focused/"activated" HTML element that the Flash object is wrapping.
- *
- * @returns `HTMLElement` or `null`
- * @static
- */
- ZeroClipboard.activeElement = function() {
- return _activeElement.apply(this, _args(arguments));
- };
- if (typeof define === "function" && define.amd) {
- define(function() {
- return ZeroClipboard;
- });
- } else if (typeof module === "object" && module && typeof module.exports === "object" && module.exports) {
- module.exports = ZeroClipboard;
- } else {
- window.ZeroClipboard = ZeroClipboard;
- }
- })(function() {
- return this || window;
- }());
|