@x-edu/live-player 0.0.21 → 0.0.23

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 (299) hide show
  1. package/.browserslistrc +10 -10
  2. package/.eslintignore +8 -8
  3. package/.eslintrc.js +26 -26
  4. package/.gem-mine +11 -11
  5. package/.postcssrc.js +6 -6
  6. package/README.md +145 -145
  7. package/babel.config.js +33 -33
  8. package/doc/develop.md +23 -23
  9. package/gem-mine.config.js +86 -86
  10. package/jest.config.js +9 -9
  11. package/jsconfig.json +15 -15
  12. package/mock/helper.js +8 -8
  13. package/mock/index.js +34 -34
  14. package/package.json +99 -99
  15. package/public/3rd/ali-player/alipayercomponents-1.0.8.min.js +26 -26
  16. package/public/3rd/ali-player/aliplayer-hls-min.js +27 -27
  17. package/public/3rd/ali-player/aliplayer-min.js +1 -1
  18. package/public/3rd/im-web-push/index.umd.js +14 -14
  19. package/public/JsBridge.js +1602 -1602
  20. package/public/fish/editor/themes/default/css/ueditor.css +1905 -1905
  21. package/public/fish/editor/third-party/codemirror/codemirror.css +104 -104
  22. package/public/fish/editor/third-party/codemirror/codemirror.js +3581 -3581
  23. package/public/fish/editor/third-party/zeroclipboard/ZeroClipboard.js +1255 -1255
  24. package/public/fish/editor/ueditor.all.min.js +16 -16
  25. package/public/fish/editor/ueditor.config.js +467 -467
  26. package/public/fish/icon/umd-4.1.2.js +1 -1
  27. package/public/fish/video/videoplayer.min.css +6 -6
  28. package/public/fish/video/videoplayer.min.js +31 -31
  29. package/public/fish/video/zh-CN.js +82 -82
  30. package/public/icon/demo.css +539 -539
  31. package/public/icon/demo_index.html +2189 -2189
  32. package/public/icon/iconfont.css +363 -363
  33. package/public/icon/iconfont.json +618 -618
  34. package/public/index.html +50 -50
  35. package/script/image/readme.md +77 -77
  36. package/script/postcss.js +48 -48
  37. package/src/App.jsx +24 -24
  38. package/src/asset/img/course/playing.svg +21 -21
  39. package/src/asset/img/icon-course-white.svg +3 -3
  40. package/src/asset/img/icon-course.svg +3 -3
  41. package/src/asset/img/icon-eye-white.svg +4 -4
  42. package/src/asset/img/icon-eye.svg +4 -4
  43. package/src/asset/img/icon-school-white.svg +3 -3
  44. package/src/asset/img/icon-school.svg +3 -3
  45. package/src/asset/img/loading.svg +52 -52
  46. package/src/asset/img/video-play.svg +6 -6
  47. package/src/asset/style/background.less +19 -19
  48. package/src/asset/style/banner.less +36 -36
  49. package/src/asset/style/base.less +74 -74
  50. package/src/asset/style/index.less +114 -114
  51. package/src/asset/style/reset-theme.less +141 -141
  52. package/src/asset/style/theme/index.less +55 -55
  53. package/src/asset/style/theme/party/global.less +20 -20
  54. package/src/asset/style/theme/party/override.less +57 -57
  55. package/src/asset/style/theme/test/global.less +18 -18
  56. package/src/asset/style/theme/test/override.less +45 -45
  57. package/src/asset/style/variable.less +12 -12
  58. package/src/component/AliPlayer/index.jsx +49 -49
  59. package/src/component/Avatar/index.jsx +50 -50
  60. package/src/component/Empty/index.jsx +34 -34
  61. package/src/component/Empty/index.module.less +37 -37
  62. package/src/component/IMChatroom/component/status/403.jsx +13 -13
  63. package/src/component/IMChatroom/component/status/404.jsx +13 -13
  64. package/src/component/IMChatroom/component/status/Error.jsx +23 -23
  65. package/src/component/IMChatroom/component/status/Loading.jsx +5 -5
  66. package/src/component/IMChatroom/config/app/config.js +118 -118
  67. package/src/component/IMChatroom/config/app/index.js +60 -60
  68. package/src/component/IMChatroom/config/env.js +5 -5
  69. package/src/component/IMChatroom/config/index.js +3 -3
  70. package/src/component/IMChatroom/config/request/config/base.js +124 -124
  71. package/src/component/IMChatroom/config/request/config/chatroom.js +26 -26
  72. package/src/component/IMChatroom/config/request/config/imCoreApi.js +21 -21
  73. package/src/component/IMChatroom/config/request/index.js +21 -21
  74. package/src/component/IMChatroom/config/request/proxy.js +39 -39
  75. package/src/component/IMChatroom/config/url.js +7 -7
  76. package/src/component/IMChatroom/constants/errorCode.js +9 -9
  77. package/src/component/IMChatroom/constants/index.js +84 -84
  78. package/src/component/IMChatroom/constants/origin.js +27 -27
  79. package/src/component/IMChatroom/context/chatroom.js +154 -154
  80. package/src/component/IMChatroom/context/connect.js +28 -28
  81. package/src/component/IMChatroom/i18n/en/index.json +73 -73
  82. package/src/component/IMChatroom/i18n/index.jsx +14 -14
  83. package/src/component/IMChatroom/i18n/language.js +9 -9
  84. package/src/component/IMChatroom/i18n/zh-CN/index.json +73 -73
  85. package/src/component/IMChatroom/index.jsx +49 -49
  86. package/src/component/IMChatroom/page/chat/index.jsx +27 -27
  87. package/src/component/IMChatroom/page/chat/messageEditor/index.jsx +375 -375
  88. package/src/component/IMChatroom/page/chat/messageList/index.jsx +354 -354
  89. package/src/component/IMChatroom/page/chat/stickedMessage/index.jsx +59 -59
  90. package/src/component/IMChatroom/page/chat/stickedMessage/style/index.module.less +7 -7
  91. package/src/component/IMChatroom/page/chat/style/index.module.less +51 -51
  92. package/src/component/IMChatroom/page/home/connect/index.jsx +188 -188
  93. package/src/component/IMChatroom/page/home/connect/status.jsx +124 -124
  94. package/src/component/IMChatroom/page/home/context/cmd.jsx +37 -37
  95. package/src/component/IMChatroom/page/home/context/index.jsx +67 -67
  96. package/src/component/IMChatroom/page/home/index.jsx +164 -164
  97. package/src/component/IMChatroom/page/home/notice/index.jsx +123 -123
  98. package/src/component/IMChatroom/page/home/notice/style/index.module.less +49 -49
  99. package/src/component/IMChatroom/page/home/style/index.module.less +110 -110
  100. package/src/component/IMChatroom/page/member/index.jsx +15 -15
  101. package/src/component/IMChatroom/page/member/memberCount/index.jsx +44 -44
  102. package/src/component/IMChatroom/page/member/memberList/index.jsx +121 -121
  103. package/src/component/IMChatroom/page/member/style/index.module.less +2 -2
  104. package/src/component/IMChatroom/sdk/bridge.js +39 -39
  105. package/src/component/IMChatroom/sdk/cs/constants.js +20 -20
  106. package/src/component/IMChatroom/sdk/cs/index.js +101 -101
  107. package/src/component/IMChatroom/sdk/imChatroom.js +15 -15
  108. package/src/component/IMChatroom/sdk/imcore/constants.js +128 -128
  109. package/src/component/IMChatroom/sdk/imcore/emitters/chatroomDestroyed.js +5 -5
  110. package/src/component/IMChatroom/sdk/imcore/emitters/chatroomInfoGetFail.js +5 -5
  111. package/src/component/IMChatroom/sdk/imcore/emitters/chatroomKickedByAdmin.js +5 -5
  112. package/src/component/IMChatroom/sdk/imcore/emitters/chatroomKickedBySelf.js +5 -5
  113. package/src/component/IMChatroom/sdk/imcore/emitters/chatroomLoginFail.js +5 -5
  114. package/src/component/IMChatroom/sdk/imcore/emitters/chatroomLoginSuccess.js +5 -5
  115. package/src/component/IMChatroom/sdk/imcore/emitters/chatroomMemberLogin.js +5 -5
  116. package/src/component/IMChatroom/sdk/imcore/emitters/chatroomMemberLogout.js +5 -5
  117. package/src/component/IMChatroom/sdk/imcore/emitters/connectionConnected.js +5 -5
  118. package/src/component/IMChatroom/sdk/imcore/emitters/connectionConnecting.js +5 -5
  119. package/src/component/IMChatroom/sdk/imcore/emitters/connectionDisconnect.js +5 -5
  120. package/src/component/IMChatroom/sdk/imcore/emitters/index.js +57 -57
  121. package/src/component/IMChatroom/sdk/imcore/emitters/messageReceive.js +36 -36
  122. package/src/component/IMChatroom/sdk/imcore/index.js +178 -178
  123. package/src/component/IMChatroom/sdk/imcore/interceptors/request.js +7 -7
  124. package/src/component/IMChatroom/sdk/imcore/interceptors/response.js +5 -5
  125. package/src/component/IMChatroom/sdk/imcore/plugins/getAuth.js +64 -64
  126. package/src/component/IMChatroom/sdk/imcore/plugins/getConversationId.js +20 -20
  127. package/src/component/IMChatroom/sdk/imcore/plugins/getExtInfo.js +10 -10
  128. package/src/component/IMChatroom/sdk/imcore/plugins/getLoginInfo.js +48 -48
  129. package/src/component/IMChatroom/sdk/imcore/plugins/getPlatformType.js +12 -12
  130. package/src/component/IMChatroom/sdk/imcore/plugins/index.js +22 -22
  131. package/src/component/IMChatroom/sdk/imcore/util/format.js +177 -177
  132. package/src/component/IMChatroom/sdk/imcore/util/parser.js +35 -35
  133. package/src/component/IMChatroom/sdk/oms.js +18 -18
  134. package/src/component/IMChatroom/sdk/uc.js +3 -3
  135. package/src/component/IMChatroom/subscription/channel/app.js +5 -5
  136. package/src/component/IMChatroom/subscription/channel/ctl.js +22 -22
  137. package/src/component/IMChatroom/subscription/channel/member.js +40 -40
  138. package/src/component/IMChatroom/subscription/channel/message.js +13 -13
  139. package/src/component/IMChatroom/subscription/channel/ntf.js +86 -86
  140. package/src/component/IMChatroom/subscription/channel/tel.js +5 -5
  141. package/src/component/IMChatroom/subscription/channel/websocket.js +5 -5
  142. package/src/component/IMChatroom/subscription/event.js +37 -37
  143. package/src/component/IMChatroom/subscription/index.js +19 -19
  144. package/src/component/IMChatroom/util/account.js +8 -8
  145. package/src/component/IMChatroom/util/chatroom.js +255 -255
  146. package/src/component/IMChatroom/util/jsonBigInt.js +5 -5
  147. package/src/component/IMChatroom/util/location.js +12 -12
  148. package/src/component/Icon/index.jsx +16 -16
  149. package/src/component/Icon/index.module.less +2 -2
  150. package/src/component/Pagination/LocalPagination.jsx +27 -27
  151. package/src/component/Pagination/RemotePagination.jsx +32 -32
  152. package/src/component/Pagination/index.jsx +32 -31
  153. package/src/component/Pagination/index.module.less +117 -110
  154. package/src/component/PlayerTip/index.jsx +34 -34
  155. package/src/component/VideoBase/index.jsx +242 -242
  156. package/src/component/VideoBase/style.less +65 -65
  157. package/src/component/VideoBase/utils.js +81 -81
  158. package/src/component/mixin.less +9 -9
  159. package/src/component/status/403.jsx +15 -15
  160. package/src/component/status/404/index.jsx +73 -73
  161. package/src/component/status/404/index.module.less +36 -36
  162. package/src/component/status/Error/error.module.less +13 -13
  163. package/src/component/status/Error/index.jsx +47 -47
  164. package/src/component/status/Loading/img/loading.svg +52 -52
  165. package/src/component/status/Loading/index.jsx +31 -31
  166. package/src/component/status/Loading/index.less +56 -56
  167. package/src/component/status/None/index.jsx +20 -20
  168. package/src/component/status/None/index.module.less +35 -35
  169. package/src/component/status/Status/index.jsx +26 -26
  170. package/src/component/status/Status/index.module.less +8 -8
  171. package/src/config/constant/commonUrl.js +2 -2
  172. package/src/config/constant/user.js +6 -6
  173. package/src/config/context/site-config.js +48 -48
  174. package/src/config/env/index.js +5 -5
  175. package/src/config/env/local/index.js +13 -13
  176. package/src/config/env/ncet-xedu/api.js +175 -175
  177. package/src/config/env/ncet-xedu/app.js +12 -12
  178. package/src/config/env/ncet-xedu/cs.js +8 -8
  179. package/src/config/env/ncet-xedu/index.js +14 -14
  180. package/src/config/env/ncet-xedu/push.js +5 -5
  181. package/src/config/env/preproduction/api.js +144 -144
  182. package/src/config/env/preproduction/app.js +12 -12
  183. package/src/config/env/preproduction/cs.js +8 -8
  184. package/src/config/env/preproduction/index.js +14 -14
  185. package/src/config/env/preproduction/push.js +5 -5
  186. package/src/config/env/product/api.js +113 -113
  187. package/src/config/env/product/app.js +12 -12
  188. package/src/config/env/product/cs.js +5 -5
  189. package/src/config/env/product/index.js +14 -14
  190. package/src/config/env/product/push.js +5 -5
  191. package/src/config/live.js +80 -80
  192. package/src/config/publicLive.js +53 -53
  193. package/src/config/request/assessments.js +24 -24
  194. package/src/config/request/config-center.js +8 -8
  195. package/src/config/request/helper.js +166 -166
  196. package/src/config/request/im-broadcasts.js +12 -12
  197. package/src/config/request/live-activity-gateway.js +8 -8
  198. package/src/config/request/live-activity.js +13 -13
  199. package/src/config/request/raw.js +6 -6
  200. package/src/config/request/x-cloud-web.js +13 -13
  201. package/src/config/request/x-proxy.js +34 -34
  202. package/src/demo/Detail.jsx +11 -11
  203. package/src/demo/List.jsx +66 -64
  204. package/src/demo/index.jsx +17 -17
  205. package/src/detail/LineSwitch/index.jsx +71 -71
  206. package/src/detail/LiveCountDown/index.jsx +44 -44
  207. package/src/detail/LiveCountDown/index.module.less +31 -31
  208. package/src/detail/LiveOnlineCount/img/icon.svg +15 -15
  209. package/src/detail/LiveOnlineCount/index.jsx +68 -68
  210. package/src/detail/LiveOnlineCount/index.module.less +34 -34
  211. package/src/detail/LiveOnlineCount/util.js +74 -74
  212. package/src/detail/LiveStatus/AnchorOnTheWay.jsx +88 -88
  213. package/src/detail/LiveStatus/index.jsx +202 -202
  214. package/src/detail/LiveStatus/index.module.less +192 -192
  215. package/src/detail/LiveVideo/config.js +37 -37
  216. package/src/detail/LiveVideo/index.jsx +188 -188
  217. package/src/detail/LiveVideo/index.module.less +41 -41
  218. package/src/detail/NotLoginChatroom/index.jsx +37 -37
  219. package/src/detail/NotLoginChatroom/index.module.less +46 -46
  220. package/src/detail/RecordVideo/index.jsx +150 -150
  221. package/src/detail/RecordVideo/index.module.less +31 -31
  222. package/src/detail/ReplayVideo/index.jsx +93 -93
  223. package/src/detail/ReplayVideo/index.module.less +65 -65
  224. package/src/detail/const.js +20 -20
  225. package/src/detail/hook/usePullSource.js +82 -82
  226. package/src/detail/hook/usePullState.js +51 -51
  227. package/src/detail/index.jsx +482 -482
  228. package/src/detail/index.module.less +188 -188
  229. package/src/hook/useAsync.js +84 -84
  230. package/src/hook/useGoToPage.js +83 -83
  231. package/src/hook/useInterval.js +28 -28
  232. package/src/hook/useIsMounted.js +17 -17
  233. package/src/hook/useModuleByRole.js +53 -53
  234. package/src/hook/usePageScrollable.js +52 -52
  235. package/src/hook/usePortal.js +83 -83
  236. package/src/hook/useScrollRestore/index.js +32 -32
  237. package/src/hook/useScrollRestore/scrollContext.js +20 -20
  238. package/src/hook/useTrackRef.js +11 -11
  239. package/src/hook/useWindowSize.js +28 -28
  240. package/src/hook/useZoom.js +47 -47
  241. package/src/index.js +10 -10
  242. package/src/lib/getLiveOnlineCount.js +10 -10
  243. package/src/lib/getServiceConfig.js +102 -102
  244. package/src/list/Empty/index.jsx +20 -20
  245. package/src/list/Empty/index.module.less +23 -23
  246. package/src/list/ListItem/Action/index.jsx +100 -98
  247. package/src/list/ListItem/Action/index.module.less +19 -21
  248. package/src/list/ListItem/img/play.svg +15 -15
  249. package/src/list/ListItem/img/video.svg +3 -0
  250. package/src/list/ListItem/index.jsx +46 -28
  251. package/src/list/ListItem/index.module.less +152 -146
  252. package/src/list/index.module.less +35 -35
  253. package/src/service/common.js +73 -73
  254. package/src/service/content-mgr.js +73 -73
  255. package/src/service/im-group.js +12 -12
  256. package/src/service/im.js +7 -7
  257. package/src/service/imBroadcasts.js +33 -33
  258. package/src/service/like.js +134 -134
  259. package/src/service/manageApi.js +7 -7
  260. package/src/service/managePortal.js +6 -6
  261. package/src/service/myStudyRecord.js +93 -93
  262. package/src/service/navigation.js +47 -47
  263. package/src/service/ndMeeting.js +10 -10
  264. package/src/service/ndr.js +122 -122
  265. package/src/service/news.js +93 -93
  266. package/src/service/personalCenter.js +270 -270
  267. package/src/service/qualityCourse.js +31 -31
  268. package/src/service/recommend.js +81 -81
  269. package/src/service/school.js +323 -323
  270. package/src/service/search.js +170 -170
  271. package/src/service/site-config.js +7 -7
  272. package/src/service/socialCensor.js +45 -45
  273. package/src/service/specialEdu.js +31 -31
  274. package/src/service/suggestion.js +85 -85
  275. package/src/service/syncClassroom.js +321 -321
  276. package/src/service/tCourse.js +204 -204
  277. package/src/service/tchTraining.js +37 -37
  278. package/src/service/uc.js +45 -45
  279. package/src/util/app.js +1 -1
  280. package/src/util/array.js +3 -3
  281. package/src/util/auth/func.js +57 -57
  282. package/src/util/date.js +53 -53
  283. package/src/util/env.js +9 -9
  284. package/src/util/getTimestamp.js +10 -10
  285. package/src/util/hof.js +105 -105
  286. package/src/util/live/index.js +42 -42
  287. package/src/util/netUrl.js +35 -35
  288. package/src/util/object.js +13 -13
  289. package/src/util/push/index.js +58 -58
  290. package/src/util/request.js +227 -227
  291. package/src/util/type.js +17 -17
  292. package/src/util/url.js +203 -203
  293. package/src/util/video.js +26 -26
  294. package/test/setup.js +21 -21
  295. package/test/unit/component/header/logo.spec.jsx +8 -8
  296. package/test/unit/helper.jsx +25 -25
  297. package/test/unit/util/date.spec.js +40 -40
  298. package/dist/XEduLivePlayer.common.js +0 -72605
  299. package/dist/XEduLivePlayerPre.common.js +0 -72625
@@ -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
  }());