fomantic-ui 2.9.1-beta.8 → 2.9.1

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 (521) hide show
  1. package/.eslint/eqeqeq-rule.js +18 -0
  2. package/.eslint/index.js +29 -0
  3. package/.eslint/no-extra-parens-rule.js +17 -0
  4. package/.eslint/package.json +11 -0
  5. package/.eslintrc.js +123 -0
  6. package/.github/auto_assign.yml +0 -1
  7. package/.github/workflows/ci.yml +37 -4
  8. package/.github/workflows/nightly.yml +1 -1
  9. package/.github/workflows/release.yml +1 -1
  10. package/.prettierrc.js +12 -0
  11. package/.stylelintrc.js +48 -0
  12. package/CHANGELOG.md +112 -0
  13. package/README.md +1 -1
  14. package/dist/components/accordion.css +35 -53
  15. package/dist/components/accordion.js +568 -595
  16. package/dist/components/accordion.min.css +2 -2
  17. package/dist/components/accordion.min.js +3 -3
  18. package/dist/components/ad.css +34 -45
  19. package/dist/components/ad.min.css +2 -2
  20. package/dist/components/api.js +1157 -1179
  21. package/dist/components/api.min.js +3 -3
  22. package/dist/components/breadcrumb.css +5 -5
  23. package/dist/components/breadcrumb.min.css +2 -2
  24. package/dist/components/button.css +709 -1111
  25. package/dist/components/button.min.css +2 -2
  26. package/dist/components/calendar.css +24 -27
  27. package/dist/components/calendar.js +1934 -1809
  28. package/dist/components/calendar.min.css +2 -2
  29. package/dist/components/calendar.min.js +3 -3
  30. package/dist/components/card.css +219 -365
  31. package/dist/components/card.min.css +2 -2
  32. package/dist/components/checkbox.css +120 -191
  33. package/dist/components/checkbox.js +842 -841
  34. package/dist/components/checkbox.min.css +2 -2
  35. package/dist/components/checkbox.min.js +3 -3
  36. package/dist/components/comment.css +41 -59
  37. package/dist/components/comment.min.css +2 -2
  38. package/dist/components/container.css +7 -6
  39. package/dist/components/container.min.css +2 -2
  40. package/dist/components/dimmer.css +53 -172
  41. package/dist/components/dimmer.js +706 -737
  42. package/dist/components/dimmer.min.css +2 -2
  43. package/dist/components/dimmer.min.js +3 -3
  44. package/dist/components/divider.css +43 -61
  45. package/dist/components/divider.min.css +2 -2
  46. package/dist/components/dropdown.css +252 -386
  47. package/dist/components/dropdown.js +4195 -4236
  48. package/dist/components/dropdown.min.css +2 -2
  49. package/dist/components/dropdown.min.js +3 -3
  50. package/dist/components/embed.css +18 -29
  51. package/dist/components/embed.js +645 -675
  52. package/dist/components/embed.min.css +2 -2
  53. package/dist/components/embed.min.js +3 -3
  54. package/dist/components/emoji.css +3556 -3556
  55. package/dist/components/emoji.min.css +1 -1
  56. package/dist/components/feed.css +35 -57
  57. package/dist/components/feed.min.css +2 -2
  58. package/dist/components/flag.css +270 -268
  59. package/dist/components/flag.min.css +2 -2
  60. package/dist/components/flyout.css +95 -141
  61. package/dist/components/flyout.js +1514 -1465
  62. package/dist/components/flyout.min.css +2 -2
  63. package/dist/components/flyout.min.js +3 -3
  64. package/dist/components/form.css +244 -339
  65. package/dist/components/form.js +2022 -2004
  66. package/dist/components/form.min.css +2 -2
  67. package/dist/components/form.min.js +3 -3
  68. package/dist/components/grid.css +183 -329
  69. package/dist/components/grid.min.css +2 -2
  70. package/dist/components/header.css +118 -142
  71. package/dist/components/header.min.css +2 -2
  72. package/dist/components/icon.css +662 -745
  73. package/dist/components/icon.min.css +2 -2
  74. package/dist/components/image.css +39 -63
  75. package/dist/components/image.min.css +2 -2
  76. package/dist/components/input.css +356 -274
  77. package/dist/components/input.min.css +2 -2
  78. package/dist/components/item.css +84 -131
  79. package/dist/components/item.min.css +2 -2
  80. package/dist/components/label.css +359 -410
  81. package/dist/components/label.min.css +2 -2
  82. package/dist/components/list.css +49 -70
  83. package/dist/components/list.min.css +2 -2
  84. package/dist/components/loader.css +67 -155
  85. package/dist/components/loader.min.css +2 -2
  86. package/dist/components/menu.css +270 -431
  87. package/dist/components/menu.min.css +1 -1
  88. package/dist/components/message.css +125 -197
  89. package/dist/components/message.min.css +2 -2
  90. package/dist/components/modal.css +120 -154
  91. package/dist/components/modal.js +1544 -1486
  92. package/dist/components/modal.min.css +2 -2
  93. package/dist/components/modal.min.js +3 -3
  94. package/dist/components/nag.css +53 -63
  95. package/dist/components/nag.js +520 -526
  96. package/dist/components/nag.min.css +2 -2
  97. package/dist/components/nag.min.js +3 -3
  98. package/dist/components/placeholder.css +22 -42
  99. package/dist/components/placeholder.min.css +2 -2
  100. package/dist/components/popup.css +424 -202
  101. package/dist/components/popup.js +1456 -1456
  102. package/dist/components/popup.min.css +2 -2
  103. package/dist/components/popup.min.js +3 -3
  104. package/dist/components/progress.css +106 -211
  105. package/dist/components/progress.js +969 -997
  106. package/dist/components/progress.min.css +2 -2
  107. package/dist/components/progress.min.js +3 -3
  108. package/dist/components/rail.css +15 -20
  109. package/dist/components/rail.min.css +1 -1
  110. package/dist/components/rating.css +80 -121
  111. package/dist/components/rating.js +507 -523
  112. package/dist/components/rating.min.css +2 -2
  113. package/dist/components/rating.min.js +3 -3
  114. package/dist/components/reset.css +8 -13
  115. package/dist/components/reset.min.css +2 -2
  116. package/dist/components/reveal.css +44 -83
  117. package/dist/components/reveal.min.css +2 -2
  118. package/dist/components/search.css +69 -98
  119. package/dist/components/search.js +1520 -1534
  120. package/dist/components/search.min.css +2 -2
  121. package/dist/components/search.min.js +3 -3
  122. package/dist/components/segment.css +148 -224
  123. package/dist/components/segment.min.css +2 -2
  124. package/dist/components/shape.css +14 -30
  125. package/dist/components/shape.js +783 -810
  126. package/dist/components/shape.min.css +2 -2
  127. package/dist/components/shape.min.js +3 -3
  128. package/dist/components/sidebar.css +103 -206
  129. package/dist/components/sidebar.js +1061 -1099
  130. package/dist/components/sidebar.min.css +2 -2
  131. package/dist/components/sidebar.min.js +3 -3
  132. package/dist/components/site.css +28 -41
  133. package/dist/components/site.js +436 -476
  134. package/dist/components/site.min.css +2 -2
  135. package/dist/components/site.min.js +3 -3
  136. package/dist/components/slider.css +93 -121
  137. package/dist/components/slider.js +1310 -1311
  138. package/dist/components/slider.min.css +1 -1
  139. package/dist/components/slider.min.js +3 -3
  140. package/dist/components/state.js +638 -657
  141. package/dist/components/state.min.js +3 -3
  142. package/dist/components/statistic.css +75 -116
  143. package/dist/components/statistic.min.css +2 -2
  144. package/dist/components/step.css +77 -150
  145. package/dist/components/step.min.css +2 -2
  146. package/dist/components/sticky.css +1 -5
  147. package/dist/components/sticky.js +847 -901
  148. package/dist/components/sticky.min.css +2 -2
  149. package/dist/components/sticky.min.js +3 -3
  150. package/dist/components/tab.css +10 -14
  151. package/dist/components/tab.js +902 -966
  152. package/dist/components/tab.min.css +2 -2
  153. package/dist/components/tab.min.js +3 -3
  154. package/dist/components/table.css +547 -774
  155. package/dist/components/table.min.css +2 -2
  156. package/dist/components/text.css +32 -32
  157. package/dist/components/text.min.css +1 -1
  158. package/dist/components/toast.css +69 -147
  159. package/dist/components/toast.js +910 -884
  160. package/dist/components/toast.min.css +2 -2
  161. package/dist/components/toast.min.js +3 -3
  162. package/dist/components/transition.css +299 -1356
  163. package/dist/components/transition.js +1048 -1077
  164. package/dist/components/transition.min.css +2 -2
  165. package/dist/components/transition.min.js +3 -3
  166. package/dist/components/visibility.js +1213 -1245
  167. package/dist/components/visibility.min.js +3 -3
  168. package/dist/semantic.css +9344 -12298
  169. package/dist/semantic.js +29181 -29423
  170. package/dist/semantic.min.css +3 -3
  171. package/dist/semantic.min.js +3 -3
  172. package/dist/themes/basic/assets/fonts/icons.woff2 +0 -0
  173. package/dist/themes/github/assets/fonts/octicons.woff2 +0 -0
  174. package/examples/.eslintrc.js +6 -0
  175. package/examples/assets/library/jquery.min.js +2 -4
  176. package/examples/assets/show-examples.js +13 -13
  177. package/examples/attached.html +1 -1
  178. package/examples/bootstrap.html +1 -1
  179. package/examples/components/button.html +1 -1
  180. package/examples/components/card.html +6 -6
  181. package/examples/components/input.html +1 -1
  182. package/examples/components/menu.html +1 -1
  183. package/examples/components/site.html +1 -1
  184. package/examples/components/sticky-context.html +2 -2
  185. package/examples/components/table.html +1 -1
  186. package/examples/fixed.html +3 -3
  187. package/examples/grid.html +5 -5
  188. package/examples/homepage.html +1 -1
  189. package/examples/login.html +2 -2
  190. package/examples/responsive.html +2 -2
  191. package/examples/sticky.html +4 -4
  192. package/examples/theming.html +1 -1
  193. package/gulpfile.js +13 -11
  194. package/package.json +17 -8
  195. package/scripts/nightly-version.js +83 -75
  196. package/src/_site/collections/menu.overrides +1 -1
  197. package/src/_site/elements/flag.variables +2 -2
  198. package/src/_site/globals/site.variables +1 -1
  199. package/src/_site/modules/embed.variables +3 -0
  200. package/src/definitions/behaviors/api.js +1158 -1180
  201. package/src/definitions/behaviors/form.js +2021 -2003
  202. package/src/definitions/behaviors/state.js +644 -663
  203. package/src/definitions/behaviors/visibility.js +1212 -1244
  204. package/src/definitions/collections/breadcrumb.less +43 -47
  205. package/src/definitions/collections/form.less +866 -884
  206. package/src/definitions/collections/grid.less +1681 -1699
  207. package/src/definitions/collections/menu.less +1522 -1544
  208. package/src/definitions/collections/message.less +294 -298
  209. package/src/definitions/collections/table.less +1657 -1661
  210. package/src/definitions/elements/button.less +1716 -1750
  211. package/src/definitions/elements/container.less +211 -211
  212. package/src/definitions/elements/divider.less +198 -211
  213. package/src/definitions/elements/emoji.less +41 -48
  214. package/src/definitions/elements/flag.less +46 -48
  215. package/src/definitions/elements/header.less +351 -359
  216. package/src/definitions/elements/icon.less +541 -484
  217. package/src/definitions/elements/image.less +216 -227
  218. package/src/definitions/elements/input.less +692 -699
  219. package/src/definitions/elements/label.less +784 -806
  220. package/src/definitions/elements/list.less +810 -814
  221. package/src/definitions/elements/loader.less +273 -268
  222. package/src/definitions/elements/placeholder.less +173 -170
  223. package/src/definitions/elements/rail.less +93 -93
  224. package/src/definitions/elements/reveal.less +192 -198
  225. package/src/definitions/elements/segment.less +742 -749
  226. package/src/definitions/elements/step.less +423 -437
  227. package/src/definitions/elements/text.less +34 -36
  228. package/src/definitions/globals/reset.less +11 -8
  229. package/src/definitions/globals/site.js +435 -475
  230. package/src/definitions/globals/site.less +108 -110
  231. package/src/definitions/modules/accordion.js +567 -594
  232. package/src/definitions/modules/accordion.less +244 -248
  233. package/src/definitions/modules/calendar.js +1933 -1808
  234. package/src/definitions/modules/calendar.less +100 -97
  235. package/src/definitions/modules/checkbox.js +841 -840
  236. package/src/definitions/modules/checkbox.less +531 -552
  237. package/src/definitions/modules/dimmer.js +705 -736
  238. package/src/definitions/modules/dimmer.less +294 -305
  239. package/src/definitions/modules/dropdown.js +4194 -4235
  240. package/src/definitions/modules/dropdown.less +1568 -1598
  241. package/src/definitions/modules/embed.js +644 -674
  242. package/src/definitions/modules/embed.less +82 -84
  243. package/src/definitions/modules/flyout.js +1513 -1464
  244. package/src/definitions/modules/flyout.less +453 -455
  245. package/src/definitions/modules/modal.js +1543 -1485
  246. package/src/definitions/modules/modal.less +459 -467
  247. package/src/definitions/modules/nag.js +519 -525
  248. package/src/definitions/modules/nag.less +136 -149
  249. package/src/definitions/modules/popup.js +1455 -1455
  250. package/src/definitions/modules/popup.less +738 -693
  251. package/src/definitions/modules/progress.js +968 -996
  252. package/src/definitions/modules/progress.less +523 -499
  253. package/src/definitions/modules/rating.js +506 -522
  254. package/src/definitions/modules/rating.less +98 -103
  255. package/src/definitions/modules/search.js +1519 -1533
  256. package/src/definitions/modules/search.less +374 -394
  257. package/src/definitions/modules/shape.js +782 -809
  258. package/src/definitions/modules/shape.less +70 -79
  259. package/src/definitions/modules/sidebar.js +1060 -1098
  260. package/src/definitions/modules/sidebar.less +463 -476
  261. package/src/definitions/modules/slider.js +1309 -1310
  262. package/src/definitions/modules/slider.less +309 -310
  263. package/src/definitions/modules/sticky.js +863 -917
  264. package/src/definitions/modules/sticky.less +17 -25
  265. package/src/definitions/modules/tab.js +901 -965
  266. package/src/definitions/modules/tab.less +48 -54
  267. package/src/definitions/modules/toast.js +909 -883
  268. package/src/definitions/modules/toast.less +589 -589
  269. package/src/definitions/modules/transition.js +1047 -1076
  270. package/src/definitions/modules/transition.less +58 -59
  271. package/src/definitions/views/ad.less +207 -208
  272. package/src/definitions/views/card.less +955 -973
  273. package/src/definitions/views/comment.less +192 -200
  274. package/src/definitions/views/feed.less +222 -226
  275. package/src/definitions/views/item.less +437 -448
  276. package/src/definitions/views/statistic.less +273 -279
  277. package/src/semantic.less +8 -6
  278. package/src/theme.config.example +53 -53
  279. package/src/theme.less +44 -35
  280. package/src/themes/amazon/elements/button.overrides +23 -24
  281. package/src/themes/amazon/elements/button.variables +18 -23
  282. package/src/themes/amazon/globals/site.variables +16 -17
  283. package/src/themes/basic/assets/fonts/icons.woff2 +0 -0
  284. package/src/themes/basic/collections/table.overrides +0 -1
  285. package/src/themes/basic/collections/table.variables +3 -3
  286. package/src/themes/basic/elements/button.overrides +0 -1
  287. package/src/themes/basic/elements/button.variables +9 -9
  288. package/src/themes/basic/elements/icon.overrides +9 -169
  289. package/src/themes/basic/elements/icon.variables +161 -18
  290. package/src/themes/basic/elements/step.overrides +2 -2
  291. package/src/themes/basic/elements/step.variables +2 -2
  292. package/src/themes/basic/globals/reset.overrides +1 -1
  293. package/src/themes/basic/globals/reset.variables +1 -1
  294. package/src/themes/basic/modules/progress.variables +2 -2
  295. package/src/themes/basic/views/card.overrides +0 -1
  296. package/src/themes/basic/views/card.variables +6 -6
  297. package/src/themes/bookish/elements/header.overrides +4 -4
  298. package/src/themes/bookish/elements/header.variables +5 -5
  299. package/src/themes/bootstrap3/elements/button.overrides +3 -0
  300. package/src/themes/bootstrap3/elements/button.variables +20 -25
  301. package/src/themes/chubby/collections/form.overrides +9 -9
  302. package/src/themes/chubby/collections/form.variables +3 -3
  303. package/src/themes/chubby/collections/menu.overrides +3 -0
  304. package/src/themes/chubby/collections/menu.variables +3 -3
  305. package/src/themes/chubby/elements/button.overrides +8 -10
  306. package/src/themes/chubby/elements/button.variables +10 -10
  307. package/src/themes/chubby/elements/header.overrides +1 -1
  308. package/src/themes/chubby/elements/header.variables +4 -4
  309. package/src/themes/chubby/modules/accordion.overrides +2 -2
  310. package/src/themes/chubby/modules/accordion.variables +4 -4
  311. package/src/themes/chubby/views/comment.overrides +5 -5
  312. package/src/themes/chubby/views/comment.variables +11 -11
  313. package/src/themes/classic/collections/table.variables +3 -3
  314. package/src/themes/classic/elements/button.variables +36 -43
  315. package/src/themes/classic/elements/header.variables +4 -4
  316. package/src/themes/classic/modules/progress.variables +3 -3
  317. package/src/themes/classic/views/card.overrides +25 -27
  318. package/src/themes/classic/views/card.variables +7 -7
  319. package/src/themes/colored/modules/checkbox.overrides +3 -0
  320. package/src/themes/colored/modules/checkbox.variables +1 -3
  321. package/src/themes/default/collections/breadcrumb.variables +4 -4
  322. package/src/themes/default/collections/form.variables +15 -16
  323. package/src/themes/default/collections/grid.overrides +0 -1
  324. package/src/themes/default/collections/grid.variables +15 -16
  325. package/src/themes/default/collections/menu.variables +31 -45
  326. package/src/themes/default/collections/message.variables +84 -123
  327. package/src/themes/default/collections/table.overrides +3 -0
  328. package/src/themes/default/collections/table.variables +30 -34
  329. package/src/themes/default/elements/button.variables +44 -53
  330. package/src/themes/default/elements/container.variables +8 -16
  331. package/src/themes/default/elements/divider.overrides +8 -9
  332. package/src/themes/default/elements/divider.variables +5 -6
  333. package/src/themes/default/elements/emoji.overrides +0 -1
  334. package/src/themes/default/elements/emoji.variables +3556 -3556
  335. package/src/themes/default/elements/flag.variables +1595 -1595
  336. package/src/themes/default/elements/header.overrides +0 -1
  337. package/src/themes/default/elements/header.variables +21 -21
  338. package/src/themes/default/elements/icon.variables +2016 -2012
  339. package/src/themes/default/elements/image.variables +6 -7
  340. package/src/themes/default/elements/input.variables +11 -12
  341. package/src/themes/default/elements/label.variables +25 -26
  342. package/src/themes/default/elements/list.variables +17 -21
  343. package/src/themes/default/elements/loader.variables +16 -17
  344. package/src/themes/default/elements/placeholder.variables +12 -9
  345. package/src/themes/default/elements/rail.variables +4 -5
  346. package/src/themes/default/elements/reveal.variables +1 -1
  347. package/src/themes/default/elements/segment.variables +24 -36
  348. package/src/themes/default/elements/step.overrides +4 -4
  349. package/src/themes/default/elements/step.variables +19 -22
  350. package/src/themes/default/elements/text.variables +2 -3
  351. package/src/themes/default/globals/colors.less +588 -588
  352. package/src/themes/default/globals/reset.overrides +63 -59
  353. package/src/themes/default/globals/reset.variables +1 -1
  354. package/src/themes/default/globals/site.variables +1074 -1123
  355. package/src/themes/default/globals/variation.variables +6 -4
  356. package/src/themes/default/modules/accordion.overrides +11 -11
  357. package/src/themes/default/modules/accordion.variables +15 -20
  358. package/src/themes/default/modules/calendar.variables +2 -0
  359. package/src/themes/default/modules/chatroom.variables +1 -1
  360. package/src/themes/default/modules/checkbox.overrides +9 -13
  361. package/src/themes/default/modules/checkbox.variables +24 -33
  362. package/src/themes/default/modules/dimmer.variables +14 -17
  363. package/src/themes/default/modules/dropdown.overrides +17 -17
  364. package/src/themes/default/modules/dropdown.variables +29 -31
  365. package/src/themes/default/modules/embed.variables +9 -13
  366. package/src/themes/default/modules/flyout.variables +10 -8
  367. package/src/themes/default/modules/modal.variables +64 -67
  368. package/src/themes/default/modules/nag.variables +11 -14
  369. package/src/themes/default/modules/popup.variables +14 -13
  370. package/src/themes/default/modules/progress.variables +17 -19
  371. package/src/themes/default/modules/rating.variables +10 -12
  372. package/src/themes/default/modules/search.variables +12 -17
  373. package/src/themes/default/modules/shape.variables +7 -8
  374. package/src/themes/default/modules/sidebar.variables +4 -4
  375. package/src/themes/default/modules/slider.variables +55 -54
  376. package/src/themes/default/modules/sticky.variables +1 -1
  377. package/src/themes/default/modules/toast.variables +8 -8
  378. package/src/themes/default/modules/transition.overrides +936 -915
  379. package/src/themes/default/modules/transition.variables +1 -1
  380. package/src/themes/default/views/ad.variables +1 -1
  381. package/src/themes/default/views/card.variables +33 -45
  382. package/src/themes/default/views/comment.variables +7 -9
  383. package/src/themes/default/views/feed.variables +10 -10
  384. package/src/themes/default/views/item.variables +20 -23
  385. package/src/themes/default/views/statistic.variables +8 -8
  386. package/src/themes/duo/elements/loader.variables +1 -1
  387. package/src/themes/famfamfam/elements/flag.overrides +263 -268
  388. package/src/themes/famfamfam/elements/flag.variables +4 -4
  389. package/src/themes/fixed-width/collections/grid.variables +4 -4
  390. package/src/themes/fixed-width/modules/modal.variables +11 -13
  391. package/src/themes/flat/collections/form.overrides +9 -9
  392. package/src/themes/flat/collections/form.variables +16 -17
  393. package/src/themes/flat/globals/site.variables +69 -74
  394. package/src/themes/github/assets/fonts/octicons.woff2 +0 -0
  395. package/src/themes/github/collections/breadcrumb.variables +0 -1
  396. package/src/themes/github/collections/form.overrides +7 -8
  397. package/src/themes/github/collections/form.variables +16 -18
  398. package/src/themes/github/collections/grid.variables +1 -2
  399. package/src/themes/github/collections/menu.overrides +2 -2
  400. package/src/themes/github/collections/menu.variables +24 -26
  401. package/src/themes/github/collections/message.overrides +3 -3
  402. package/src/themes/github/collections/message.variables +12 -14
  403. package/src/themes/github/collections/table.variables +2 -2
  404. package/src/themes/github/elements/button.overrides +0 -1
  405. package/src/themes/github/elements/button.variables +26 -30
  406. package/src/themes/github/elements/header.variables +2 -2
  407. package/src/themes/github/elements/icon.overrides +3 -208
  408. package/src/themes/github/elements/icon.variables +234 -19
  409. package/src/themes/github/elements/image.variables +1 -1
  410. package/src/themes/github/elements/input.overrides +16 -16
  411. package/src/themes/github/elements/input.variables +4 -5
  412. package/src/themes/github/elements/label.overrides +3 -3
  413. package/src/themes/github/elements/label.variables +0 -1
  414. package/src/themes/github/elements/segment.variables +9 -10
  415. package/src/themes/github/elements/step.overrides +13 -13
  416. package/src/themes/github/elements/step.variables +6 -6
  417. package/src/themes/github/globals/site.variables +16 -16
  418. package/src/themes/github/modules/dropdown.overrides +18 -19
  419. package/src/themes/github/modules/dropdown.variables +8 -10
  420. package/src/themes/github/modules/popup.variables +0 -2
  421. package/src/themes/gmail/collections/message.overrides +3 -0
  422. package/src/themes/gmail/collections/message.variables +4 -4
  423. package/src/themes/instagram/views/card.overrides +4 -5
  424. package/src/themes/instagram/views/card.variables +7 -8
  425. package/src/themes/joypixels/elements/emoji.overrides +0 -2
  426. package/src/themes/joypixels/elements/emoji.variables +3554 -3554
  427. package/src/themes/material/collections/menu.overrides +1 -1
  428. package/src/themes/material/collections/menu.variables +4 -4
  429. package/src/themes/material/elements/button.overrides +7 -9
  430. package/src/themes/material/elements/button.variables +44 -46
  431. package/src/themes/material/elements/header.overrides +3 -3
  432. package/src/themes/material/elements/header.variables +8 -10
  433. package/src/themes/material/elements/icon.overrides +3 -934
  434. package/src/themes/material/elements/icon.variables +958 -18
  435. package/src/themes/material/globals/site.overrides +3 -0
  436. package/src/themes/material/globals/site.variables +83 -84
  437. package/src/themes/material/modules/dropdown.overrides +2 -2
  438. package/src/themes/material/modules/dropdown.variables +5 -5
  439. package/src/themes/material/modules/modal.overrides +3 -3
  440. package/src/themes/material/modules/modal.variables +4 -5
  441. package/src/themes/pulsar/elements/loader.overrides +23 -61
  442. package/src/themes/raised/elements/button.variables +8 -9
  443. package/src/themes/resetcss/globals/reset.overrides +115 -33
  444. package/src/themes/resetcss/globals/reset.variables +1 -1
  445. package/src/themes/round/elements/button.overrides +3 -0
  446. package/src/themes/round/elements/button.variables +33 -38
  447. package/src/themes/rtl/globals/site.overrides +1 -1
  448. package/src/themes/rtl/globals/site.variables +5 -6
  449. package/src/themes/striped/modules/progress.overrides +20 -16
  450. package/src/themes/systemfont/globals/reset.overrides +1 -1
  451. package/src/themes/systemfont/globals/site.variables +6 -6
  452. package/src/themes/timeline/views/feed.overrides +12 -12
  453. package/src/themes/timeline/views/feed.variables +8 -8
  454. package/src/themes/twitter/elements/button.overrides +4 -5
  455. package/src/themes/twitter/elements/button.variables +17 -18
  456. package/src/themes/twitter/elements/emoji.variables +3556 -3556
  457. package/tasks/.eslintrc.js +9 -0
  458. package/tasks/README.md +2 -4
  459. package/tasks/admin/components/create.js +268 -277
  460. package/tasks/admin/components/init.js +123 -129
  461. package/tasks/admin/components/update.js +151 -158
  462. package/tasks/admin/distributions/create.js +183 -189
  463. package/tasks/admin/distributions/init.js +125 -131
  464. package/tasks/admin/distributions/update.js +147 -153
  465. package/tasks/admin/publish.js +5 -9
  466. package/tasks/admin/register.js +37 -39
  467. package/tasks/admin/release.js +8 -12
  468. package/tasks/build/assets.js +43 -40
  469. package/tasks/build/css.js +230 -217
  470. package/tasks/build/javascript.js +120 -114
  471. package/tasks/build.js +11 -11
  472. package/tasks/check-install.js +15 -17
  473. package/tasks/clean.js +6 -6
  474. package/tasks/collections/README.md +3 -5
  475. package/tasks/collections/admin.js +34 -36
  476. package/tasks/collections/build.js +19 -21
  477. package/tasks/collections/docs.js +11 -13
  478. package/tasks/collections/install.js +11 -13
  479. package/tasks/collections/rtl.js +9 -12
  480. package/tasks/collections/various.js +10 -12
  481. package/tasks/config/admin/github.js +17 -19
  482. package/tasks/config/admin/oauth.example.js +4 -4
  483. package/tasks/config/admin/release.js +98 -98
  484. package/tasks/config/admin/templates/README.md +8 -8
  485. package/tasks/config/admin/templates/bower.json +3 -2
  486. package/tasks/config/admin/templates/component-package.js +9 -10
  487. package/tasks/config/admin/templates/css-package.js +19 -21
  488. package/tasks/config/admin/templates/less-package.js +12 -14
  489. package/tasks/config/admin/templates/package.json +6 -6
  490. package/tasks/config/defaults.js +116 -116
  491. package/tasks/config/docs.js +23 -23
  492. package/tasks/config/npm/gulpfile.js +15 -14
  493. package/tasks/config/project/config.js +124 -136
  494. package/tasks/config/project/install.js +722 -719
  495. package/tasks/config/project/release.js +34 -41
  496. package/tasks/config/tasks.js +168 -167
  497. package/tasks/config/user.js +28 -32
  498. package/tasks/docs/build.js +100 -96
  499. package/tasks/docs/metadata.js +91 -98
  500. package/tasks/docs/serve.js +84 -82
  501. package/tasks/install.js +373 -382
  502. package/tasks/rtl/build.js +4 -3
  503. package/tasks/rtl/watch.js +4 -3
  504. package/tasks/version.js +4 -6
  505. package/tasks/watch.js +29 -31
  506. package/test/.eslintrc.js +23 -0
  507. package/test/meteor/assets.js +11 -14
  508. package/test/meteor/fonts.js +12 -13
  509. package/test/modules/accordion.spec.js +6 -8
  510. package/test/modules/checkbox.spec.js +5 -7
  511. package/test/modules/dropdown.spec.js +5 -7
  512. package/test/modules/modal.spec.js +6 -8
  513. package/test/modules/module.spec.js +158 -178
  514. package/test/modules/popup.spec.js +5 -7
  515. package/test/modules/search.spec.js +5 -7
  516. package/test/modules/shape.spec.js +5 -7
  517. package/test/modules/sidebar.spec.js +5 -7
  518. package/test/modules/tab.spec.js +6 -8
  519. package/test/modules/transition.spec.js +5 -7
  520. package/test/modules/video.spec.js +5 -7
  521. package/.github/workflows/codeql.yml +0 -68
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * # Fomantic-UI 2.9.1-beta.8+edc5e7e - Popup
2
+ * # Fomantic-UI 2.9.1 - Popup
3
3
  * https://github.com/fomantic/Fomantic-UI/
4
4
  *
5
5
  *
@@ -8,1528 +8,1528 @@
8
8
  *
9
9
  */
10
10
 
11
- ;(function ($, window, document, undefined) {
12
-
13
- 'use strict';
14
-
15
- $.isFunction = $.isFunction || function(obj) {
16
- return typeof obj === "function" && typeof obj.nodeType !== "number";
17
- };
18
-
19
- window = (typeof window != 'undefined' && window.Math == Math)
20
- ? window
21
- : (typeof self != 'undefined' && self.Math == Math)
22
- ? self
23
- : Function('return this')()
24
- ;
25
-
26
- $.fn.popup = function(parameters) {
27
- var
28
- $allModules = $(this),
29
- $document = $(document),
30
- $window = $(window),
31
- $body = $('body'),
32
-
33
- moduleSelector = $allModules.selector || '',
34
-
35
- clickEvent = ('ontouchstart' in document.documentElement)
36
- ? 'touchstart'
37
- : 'click',
38
-
39
- time = new Date().getTime(),
40
- performance = [],
41
-
42
- query = arguments[0],
43
- methodInvoked = (typeof query == 'string'),
44
- queryArguments = [].slice.call(arguments, 1),
45
-
46
- returnedValue
47
- ;
48
- $allModules
49
- .each(function() {
50
- var
51
- settings = ( $.isPlainObject(parameters) )
52
- ? $.extend(true, {}, $.fn.popup.settings, parameters)
53
- : $.extend({}, $.fn.popup.settings),
54
-
55
- selector = settings.selector,
56
- className = settings.className,
57
- error = settings.error,
58
- metadata = settings.metadata,
59
- namespace = settings.namespace,
60
-
61
- eventNamespace = '.' + settings.namespace,
62
- moduleNamespace = 'module-' + namespace,
63
-
64
- $module = $(this),
65
- $context = [window,document].indexOf(settings.context) < 0 ? $document.find(settings.context) : $(settings.context),
66
- $scrollContext = [window,document].indexOf(settings.scrollContext) < 0 ? $document.find(settings.scrollContext) : $(settings.scrollContext),
67
- $boundary = [window,document].indexOf(settings.boundary) < 0 ? $document.find(settings.boundary) : $(settings.boundary),
68
- $target = (settings.target)
69
- ? ([window,document].indexOf(settings.target) < 0 ? $document.find(settings.target) : $(settings.target))
70
- : $module,
71
-
72
- $popup,
73
- $offsetParent,
74
-
75
- searchDepth = 0,
76
- triedPositions = false,
77
- openedWithTouch = false,
78
-
79
- element = this,
80
- instance = $module.data(moduleNamespace),
81
-
82
- documentObserver,
83
- elementNamespace,
84
- id,
85
- module
86
- ;
87
-
88
- module = {
89
-
90
- // binds events
91
- initialize: function() {
92
- module.debug('Initializing', $module);
93
- module.createID();
94
- module.bind.events();
95
- if(!module.exists() && settings.preserve) {
96
- module.create();
97
- }
98
- if(settings.observeChanges) {
99
- module.observeChanges();
100
- }
101
- module.instantiate();
102
- },
11
+ (function ($, window, document) {
12
+ 'use strict';
103
13
 
104
- instantiate: function() {
105
- module.verbose('Storing instance', module);
106
- instance = module;
107
- $module
108
- .data(moduleNamespace, instance)
109
- ;
110
- },
14
+ function isFunction(obj) {
15
+ return typeof obj === 'function' && typeof obj.nodeType !== 'number';
16
+ }
111
17
 
112
- observeChanges: function() {
113
- if('MutationObserver' in window) {
114
- documentObserver = new MutationObserver(module.event.documentChanged);
115
- documentObserver.observe(document, {
116
- childList : true,
117
- subtree : true
118
- });
119
- module.debug('Setting up mutation observer', documentObserver);
120
- }
121
- },
18
+ window = window !== undefined && window.Math === Math
19
+ ? window
20
+ : globalThis;
122
21
 
123
- refresh: function() {
124
- if(settings.popup) {
125
- $popup = $document.find(settings.popup).eq(0);
126
- }
127
- else {
128
- if(settings.inline) {
129
- $popup = $target.nextAll(selector.popup).eq(0);
130
- settings.popup = $popup;
131
- }
132
- }
133
- if(settings.popup) {
134
- $popup.addClass(className.loading);
135
- $offsetParent = module.get.offsetParent();
136
- $popup.removeClass(className.loading);
137
- if(settings.movePopup && module.has.popup() && module.get.offsetParent($popup)[0] !== $offsetParent[0]) {
138
- module.debug('Moving popup to the same offset parent as target');
139
- $popup
140
- .detach()
141
- .appendTo($offsetParent)
142
- ;
143
- }
144
- }
145
- else {
146
- $offsetParent = (settings.inline)
147
- ? module.get.offsetParent($target)
148
- : module.has.popup()
149
- ? module.get.offsetParent($popup)
150
- : $body
151
- ;
152
- }
153
- if( $offsetParent.is('html') && $offsetParent[0] !== $body[0] ) {
154
- module.debug('Setting page as offset parent');
155
- $offsetParent = $body;
156
- }
157
- if( module.get.variation() ) {
158
- module.set.variation();
159
- }
160
- },
22
+ $.fn.popup = function (parameters) {
23
+ var
24
+ $allModules = $(this),
25
+ $document = $(document),
26
+ $window = $(window),
27
+ $body = $('body'),
161
28
 
162
- reposition: function() {
163
- module.refresh();
164
- module.set.position();
165
- },
29
+ moduleSelector = $allModules.selector || '',
166
30
 
167
- destroy: function() {
168
- module.debug('Destroying previous module');
169
- if(documentObserver) {
170
- documentObserver.disconnect();
171
- }
172
- // remove element only if was created dynamically
173
- if($popup && !settings.preserve) {
174
- module.removePopup();
175
- }
176
- // clear all timeouts
177
- clearTimeout(module.hideTimer);
178
- clearTimeout(module.showTimer);
179
- // remove events
180
- module.unbind.close();
181
- module.unbind.events();
182
- $module
183
- .removeData(moduleNamespace)
184
- ;
185
- },
31
+ clickEvent = 'ontouchstart' in document.documentElement
32
+ ? 'touchstart'
33
+ : 'click',
186
34
 
187
- event: {
188
- start: function(event) {
189
- var
190
- delay = ($.isPlainObject(settings.delay))
191
- ? settings.delay.show
192
- : settings.delay
193
- ;
194
- clearTimeout(module.hideTimer);
195
- if(!openedWithTouch || (openedWithTouch && settings.addTouchEvents) ) {
196
- module.showTimer = setTimeout(module.show, delay);
197
- }
198
- },
199
- end: function() {
200
- var
201
- delay = ($.isPlainObject(settings.delay))
202
- ? settings.delay.hide
203
- : settings.delay
204
- ;
205
- clearTimeout(module.showTimer);
206
- module.hideTimer = setTimeout(module.hide, delay);
207
- },
208
- touchstart: function(event) {
209
- openedWithTouch = true;
210
- if(settings.addTouchEvents) {
211
- module.show();
212
- }
213
- },
214
- resize: function() {
215
- if( module.is.visible() ) {
216
- module.set.position();
217
- }
218
- },
219
- documentChanged: function(mutations) {
220
- [].forEach.call(mutations, function(mutation) {
221
- if(mutation.removedNodes) {
222
- [].forEach.call(mutation.removedNodes, function(node) {
223
- if(node == element || $(node).find(element).length > 0) {
224
- module.debug('Element removed from DOM, tearing down events');
225
- module.destroy();
226
- }
227
- });
228
- }
229
- });
230
- },
231
- hideGracefully: function(event) {
35
+ time = Date.now(),
36
+ performance = [],
37
+
38
+ query = arguments[0],
39
+ methodInvoked = typeof query === 'string',
40
+ queryArguments = [].slice.call(arguments, 1),
41
+
42
+ returnedValue
43
+ ;
44
+ $allModules.each(function () {
232
45
  var
233
- $target = $(event.target),
234
- isInDOM = $.contains(document.documentElement, event.target),
235
- inPopup = ($target.closest(selector.popup).length > 0)
46
+ settings = $.isPlainObject(parameters)
47
+ ? $.extend(true, {}, $.fn.popup.settings, parameters)
48
+ : $.extend({}, $.fn.popup.settings),
49
+
50
+ selector = settings.selector,
51
+ className = settings.className,
52
+ error = settings.error,
53
+ metadata = settings.metadata,
54
+ namespace = settings.namespace,
55
+
56
+ eventNamespace = '.' + settings.namespace,
57
+ moduleNamespace = 'module-' + namespace,
58
+
59
+ $module = $(this),
60
+ $context = [window, document].indexOf(settings.context) < 0 ? $document.find(settings.context) : $(settings.context),
61
+ $scrollContext = [window, document].indexOf(settings.scrollContext) < 0 ? $document.find(settings.scrollContext) : $(settings.scrollContext),
62
+ $boundary = [window, document].indexOf(settings.boundary) < 0 ? $document.find(settings.boundary) : $(settings.boundary),
63
+ $target = settings.target
64
+ ? ([window, document].indexOf(settings.target) < 0 ? $document.find(settings.target) : $(settings.target))
65
+ : $module,
66
+
67
+ $popup,
68
+ $offsetParent,
69
+
70
+ searchDepth = 0,
71
+ triedPositions = false,
72
+ openedWithTouch = false,
73
+
74
+ element = this,
75
+ instance = $module.data(moduleNamespace),
76
+
77
+ documentObserver,
78
+ elementNamespace,
79
+ id,
80
+ module
236
81
  ;
237
- // don't close on clicks inside popup
238
- if(event && !inPopup && isInDOM) {
239
- module.debug('Click occurred outside popup hiding popup');
240
- module.hide();
241
- }
242
- else {
243
- module.debug('Click was inside popup, keeping popup open');
244
- }
245
- }
246
- },
247
82
 
248
- // generates popup html from metadata
249
- create: function() {
250
- var
251
- html = module.get.html(),
252
- title = module.get.title(),
253
- content = module.get.content()
254
- ;
255
-
256
- if(html || content || title) {
257
- module.debug('Creating pop-up html');
258
- if(!html) {
259
- html = settings.templates.popup({
260
- title : title,
261
- content : content
262
- });
263
- }
264
- $popup = $('<div/>')
265
- .addClass(className.popup)
266
- .data(metadata.activator, $module)
267
- .html(html)
268
- ;
269
- if(settings.inline) {
270
- module.verbose('Inserting popup element inline', $popup);
271
- $popup
272
- .insertAfter($module)
273
- ;
274
- }
275
- else {
276
- module.verbose('Appending popup element to body', $popup);
277
- $popup
278
- .appendTo( $context )
279
- ;
280
- }
281
- module.refresh();
282
- module.set.variation();
83
+ module = {
84
+
85
+ // binds events
86
+ initialize: function () {
87
+ module.debug('Initializing', $module);
88
+ module.createID();
89
+ module.bind.events();
90
+ if (!module.exists() && settings.preserve) {
91
+ module.create();
92
+ }
93
+ if (settings.observeChanges) {
94
+ module.observeChanges();
95
+ }
96
+ module.instantiate();
97
+ },
283
98
 
284
- if(settings.hoverable) {
285
- module.bind.popup();
286
- }
287
- settings.onCreate.call($popup, element);
288
- }
289
- else if(settings.popup) {
290
- $document.find(settings.popup).data(metadata.activator, $module);
291
- module.verbose('Used popup specified in settings');
292
- module.refresh();
293
- if(settings.hoverable) {
294
- module.bind.popup();
295
- }
296
- }
297
- else if($target.next(selector.popup).length !== 0) {
298
- module.verbose('Pre-existing popup found');
299
- settings.inline = true;
300
- settings.popup = $target.next(selector.popup).data(metadata.activator, $module);
301
- module.refresh();
302
- if(settings.hoverable) {
303
- module.bind.popup();
304
- }
305
- }
306
- else {
307
- module.debug('No content specified skipping display', element);
308
- }
309
- },
99
+ instantiate: function () {
100
+ module.verbose('Storing instance', module);
101
+ instance = module;
102
+ $module
103
+ .data(moduleNamespace, instance)
104
+ ;
105
+ },
310
106
 
311
- createID: function() {
312
- id = (Math.random().toString(16) + '000000000').slice(2, 10);
313
- elementNamespace = '.' + id;
314
- module.verbose('Creating unique id for element', id);
315
- },
107
+ observeChanges: function () {
108
+ if ('MutationObserver' in window) {
109
+ documentObserver = new MutationObserver(module.event.documentChanged);
110
+ documentObserver.observe(document, {
111
+ childList: true,
112
+ subtree: true,
113
+ });
114
+ module.debug('Setting up mutation observer', documentObserver);
115
+ }
116
+ },
316
117
 
317
- // determines popup state
318
- toggle: function() {
319
- module.debug('Toggling pop-up');
320
- if( module.is.hidden() ) {
321
- module.debug('Popup is hidden, showing pop-up');
322
- module.unbind.close();
323
- module.show();
324
- }
325
- else {
326
- module.debug('Popup is visible, hiding pop-up');
327
- module.hide();
328
- }
329
- },
118
+ refresh: function () {
119
+ if (settings.popup) {
120
+ $popup = $document.find(settings.popup).eq(0);
121
+ } else {
122
+ if (settings.inline) {
123
+ $popup = $target.nextAll(selector.popup).eq(0);
124
+ settings.popup = $popup;
125
+ }
126
+ }
127
+ if (settings.popup) {
128
+ $popup.addClass(className.loading);
129
+ $offsetParent = module.get.offsetParent();
130
+ $popup.removeClass(className.loading);
131
+ if (settings.movePopup && module.has.popup() && module.get.offsetParent($popup)[0] !== $offsetParent[0]) {
132
+ module.debug('Moving popup to the same offset parent as target');
133
+ $popup
134
+ .detach()
135
+ .appendTo($offsetParent)
136
+ ;
137
+ }
138
+ } else {
139
+ $offsetParent = settings.inline
140
+ ? module.get.offsetParent($target)
141
+ : (module.has.popup()
142
+ ? module.get.offsetParent($popup)
143
+ : $body);
144
+ }
145
+ if ($offsetParent.is('html') && $offsetParent[0] !== $body[0]) {
146
+ module.debug('Setting page as offset parent');
147
+ $offsetParent = $body;
148
+ }
149
+ if (module.get.variation()) {
150
+ module.set.variation();
151
+ }
152
+ },
330
153
 
331
- show: function(callback) {
332
- callback = callback || function(){};
333
- module.debug('Showing pop-up', settings.transition);
334
- if(module.is.hidden() && !( module.is.active() && module.is.dropdown()) ) {
335
- if( !module.exists() ) {
336
- module.create();
337
- }
338
- if(settings.onShow.call($popup, element) === false) {
339
- module.debug('onShow callback returned false, cancelling popup animation');
340
- return;
341
- }
342
- else if(!settings.preserve && !settings.popup) {
343
- module.refresh();
344
- }
345
- if( $popup && module.set.position() ) {
346
- module.save.conditions();
347
- if(settings.exclusive) {
348
- module.hideAll();
349
- }
350
- module.animate.show(callback);
351
- }
352
- }
353
- },
154
+ reposition: function () {
155
+ module.refresh();
156
+ module.set.position();
157
+ },
354
158
 
159
+ destroy: function () {
160
+ module.debug('Destroying previous module');
161
+ if (documentObserver) {
162
+ documentObserver.disconnect();
163
+ }
164
+ // remove element only if was created dynamically
165
+ if ($popup && !settings.preserve) {
166
+ module.removePopup();
167
+ }
168
+ // clear all timeouts
169
+ clearTimeout(module.hideTimer);
170
+ clearTimeout(module.showTimer);
171
+ // remove events
172
+ module.unbind.close();
173
+ module.unbind.events();
174
+ $module
175
+ .removeData(moduleNamespace)
176
+ ;
177
+ },
355
178
 
356
- hide: function(callback) {
357
- callback = callback || function(){};
358
- if( module.is.visible() || module.is.animating() ) {
359
- if(settings.onHide.call($popup, element) === false) {
360
- module.debug('onHide callback returned false, cancelling popup animation');
361
- return;
362
- }
363
- module.remove.visible();
364
- module.unbind.close();
365
- module.restore.conditions();
366
- module.animate.hide(callback);
367
- }
368
- },
179
+ event: {
180
+ start: function (event) {
181
+ var
182
+ delay = $.isPlainObject(settings.delay)
183
+ ? settings.delay.show
184
+ : settings.delay
185
+ ;
186
+ clearTimeout(module.hideTimer);
187
+ if (!openedWithTouch || (openedWithTouch && settings.addTouchEvents)) {
188
+ module.showTimer = setTimeout(module.show, delay);
189
+ }
190
+ },
191
+ end: function () {
192
+ var
193
+ delay = $.isPlainObject(settings.delay)
194
+ ? settings.delay.hide
195
+ : settings.delay
196
+ ;
197
+ clearTimeout(module.showTimer);
198
+ module.hideTimer = setTimeout(module.hide, delay);
199
+ },
200
+ touchstart: function (event) {
201
+ openedWithTouch = true;
202
+ if (settings.addTouchEvents) {
203
+ module.show();
204
+ }
205
+ },
206
+ resize: function () {
207
+ if (module.is.visible()) {
208
+ module.set.position();
209
+ }
210
+ },
211
+ documentChanged: function (mutations) {
212
+ [].forEach.call(mutations, function (mutation) {
213
+ if (mutation.removedNodes) {
214
+ [].forEach.call(mutation.removedNodes, function (node) {
215
+ if (node === element || $(node).find(element).length > 0) {
216
+ module.debug('Element removed from DOM, tearing down events');
217
+ module.destroy();
218
+ }
219
+ });
220
+ }
221
+ });
222
+ },
223
+ hideGracefully: function (event) {
224
+ var
225
+ $target = $(event.target),
226
+ isInDOM = $.contains(document.documentElement, event.target),
227
+ inPopup = $target.closest(selector.popup).length > 0
228
+ ;
229
+ // don't close on clicks inside popup
230
+ if (event && !inPopup && isInDOM) {
231
+ module.debug('Click occurred outside popup hiding popup');
232
+ module.hide();
233
+ } else {
234
+ module.debug('Click was inside popup, keeping popup open');
235
+ }
236
+ },
237
+ },
369
238
 
370
- hideAll: function() {
371
- $document.find(selector.popup)
372
- .filter('.' + className.popupVisible)
373
- .each(function() {
374
- $(this)
375
- .data(metadata.activator)
376
- .popup('hide')
377
- ;
378
- })
379
- ;
380
- },
381
- exists: function() {
382
- if(!$popup) {
383
- return false;
384
- }
385
- if(settings.inline || settings.popup) {
386
- return ( module.has.popup() );
387
- }
388
- else {
389
- return ( $popup.closest($context).length >= 1 )
390
- ? true
391
- : false
392
- ;
393
- }
394
- },
239
+ // generates popup html from metadata
240
+ create: function () {
241
+ var
242
+ html = module.get.html(),
243
+ title = module.get.title(),
244
+ content = module.get.content()
245
+ ;
246
+
247
+ if (html || content || title) {
248
+ module.debug('Creating pop-up html');
249
+ if (!html) {
250
+ html = settings.templates.popup({
251
+ title: title,
252
+ content: content,
253
+ });
254
+ }
255
+ $popup = $('<div/>')
256
+ .addClass(className.popup)
257
+ .data(metadata.activator, $module)
258
+ .html(html)
259
+ ;
260
+ if (settings.inline) {
261
+ module.verbose('Inserting popup element inline', $popup);
262
+ $popup
263
+ .insertAfter($module)
264
+ ;
265
+ } else {
266
+ module.verbose('Appending popup element to body', $popup);
267
+ $popup
268
+ .appendTo($context)
269
+ ;
270
+ }
271
+ module.refresh();
272
+ module.set.variation();
273
+
274
+ if (settings.hoverable) {
275
+ module.bind.popup();
276
+ }
277
+ settings.onCreate.call($popup, element);
278
+ } else if (settings.popup) {
279
+ $document.find(settings.popup).data(metadata.activator, $module);
280
+ module.verbose('Used popup specified in settings');
281
+ module.refresh();
282
+ if (settings.hoverable) {
283
+ module.bind.popup();
284
+ }
285
+ } else if ($target.next(selector.popup).length > 0) {
286
+ module.verbose('Pre-existing popup found');
287
+ settings.inline = true;
288
+ settings.popup = $target.next(selector.popup).data(metadata.activator, $module);
289
+ module.refresh();
290
+ if (settings.hoverable) {
291
+ module.bind.popup();
292
+ }
293
+ } else {
294
+ module.debug('No content specified skipping display', element);
295
+ }
296
+ },
395
297
 
396
- removePopup: function() {
397
- if( module.has.popup() && !settings.popup) {
398
- module.debug('Removing popup', $popup);
399
- $popup.remove();
400
- $popup = undefined;
401
- settings.onRemove.call($popup, element);
402
- }
403
- },
298
+ createID: function () {
299
+ id = (Math.random().toString(16) + '000000000').slice(2, 10);
300
+ elementNamespace = '.' + id;
301
+ module.verbose('Creating unique id for element', id);
302
+ },
404
303
 
405
- save: {
406
- conditions: function() {
407
- module.cache = {
408
- title: $module.attr('title')
409
- };
410
- if (module.cache.title) {
411
- $module.removeAttr('title');
412
- }
413
- module.verbose('Saving original attributes', module.cache.title);
414
- }
415
- },
416
- restore: {
417
- conditions: function() {
418
- if(module.cache && module.cache.title) {
419
- $module.attr('title', module.cache.title);
420
- module.verbose('Restoring original attributes', module.cache.title);
421
- }
422
- return true;
423
- }
424
- },
425
- supports: {
426
- svg: function() {
427
- return (typeof SVGGraphicsElement !== 'undefined');
428
- }
429
- },
430
- animate: {
431
- show: function(callback) {
432
- callback = $.isFunction(callback) ? callback : function(){};
433
- if(settings.transition && $.fn.transition !== undefined && $module.transition('is supported')) {
434
- module.set.visible();
435
- $popup
436
- .transition({
437
- animation : (settings.transition.showMethod || settings.transition) + ' in',
438
- queue : false,
439
- debug : settings.debug,
440
- verbose : settings.verbose,
441
- silent : settings.silent,
442
- duration : settings.transition.showDuration || settings.duration,
443
- onComplete : function() {
444
- module.bind.close();
445
- callback.call($popup, element);
446
- settings.onVisible.call($popup, element);
447
- }
448
- })
449
- ;
450
- }
451
- else {
452
- module.error(error.noTransition);
453
- }
454
- },
455
- hide: function(callback) {
456
- callback = $.isFunction(callback) ? callback : function(){};
457
- module.debug('Hiding pop-up');
458
- if(settings.transition && $.fn.transition !== undefined && $module.transition('is supported')) {
459
- $popup
460
- .transition({
461
- animation : (settings.transition.hideMethod || settings.transition) + ' out',
462
- queue : false,
463
- duration : settings.transition.hideDuration || settings.duration,
464
- debug : settings.debug,
465
- verbose : settings.verbose,
466
- silent : settings.silent,
467
- onComplete : function() {
468
- module.reset();
469
- callback.call($popup, element);
470
- settings.onHidden.call($popup, element);
471
- }
472
- })
473
- ;
474
- }
475
- else {
476
- module.error(error.noTransition);
477
- }
478
- }
479
- },
304
+ // determines popup state
305
+ toggle: function () {
306
+ module.debug('Toggling pop-up');
307
+ if (module.is.hidden()) {
308
+ module.debug('Popup is hidden, showing pop-up');
309
+ module.unbind.close();
310
+ module.show();
311
+ } else {
312
+ module.debug('Popup is visible, hiding pop-up');
313
+ module.hide();
314
+ }
315
+ },
480
316
 
481
- change: {
482
- content: function(html) {
483
- $popup.html(html);
484
- }
485
- },
317
+ show: function (callback) {
318
+ callback = callback || function () {};
319
+ module.debug('Showing pop-up', settings.transition);
320
+ if (module.is.hidden() && !(module.is.active() && module.is.dropdown())) {
321
+ if (!module.exists()) {
322
+ module.create();
323
+ }
324
+ if (settings.onShow.call($popup, element) === false) {
325
+ module.debug('onShow callback returned false, cancelling popup animation');
326
+
327
+ return;
328
+ }
329
+ if (!settings.preserve && !settings.popup) {
330
+ module.refresh();
331
+ }
332
+ if ($popup && module.set.position()) {
333
+ module.save.conditions();
334
+ if (settings.exclusive) {
335
+ module.hideAll();
336
+ }
337
+ module.animate.show(callback);
338
+ }
339
+ }
340
+ },
486
341
 
487
- get: {
488
- html: function() {
489
- $module.removeData(metadata.html);
490
- return $module.data(metadata.html) || settings.html;
491
- },
492
- title: function() {
493
- $module.removeData(metadata.title);
494
- return $module.data(metadata.title) || settings.title;
495
- },
496
- content: function() {
497
- $module.removeData(metadata.content);
498
- return $module.data(metadata.content) || settings.content || $module.attr('title');
499
- },
500
- variation: function() {
501
- $module.removeData(metadata.variation);
502
- return $module.data(metadata.variation) || settings.variation;
503
- },
504
- popup: function() {
505
- return $popup;
506
- },
507
- popupOffset: function() {
508
- return $popup.offset();
509
- },
510
- calculations: function() {
511
- var
512
- $popupOffsetParent = module.get.offsetParent($popup),
513
- targetElement = $target[0],
514
- isWindow = ($boundary[0] == window),
515
- targetOffset = $target.offset(),
516
- parentOffset = settings.inline || (settings.popup && settings.movePopup)
517
- ? $target.offsetParent().offset()
518
- : { top: 0, left: 0 },
519
- screenPosition = (isWindow)
520
- ? { top: 0, left: 0 }
521
- : $boundary.offset(),
522
- calculations = {},
523
- scroll = (isWindow)
524
- ? { top: $window.scrollTop(), left: $window.scrollLeft() }
525
- : { top: 0, left: 0},
526
- screen
527
- ;
528
- calculations = {
529
- // element which is launching popup
530
- target : {
531
- element : $target[0],
532
- width : $target.outerWidth(),
533
- height : $target.outerHeight(),
534
- top : targetOffset.top - parentOffset.top,
535
- left : targetOffset.left - parentOffset.left,
536
- margin : {}
537
- },
538
- // popup itself
539
- popup : {
540
- width : $popup.outerWidth(),
541
- height : $popup.outerHeight()
542
- },
543
- // offset container (or 3d context)
544
- parent : {
545
- width : $offsetParent.outerWidth(),
546
- height : $offsetParent.outerHeight()
547
- },
548
- // screen boundaries
549
- screen : {
550
- top : screenPosition.top,
551
- left : screenPosition.left,
552
- scroll: {
553
- top : scroll.top,
554
- left : scroll.left
342
+ hide: function (callback) {
343
+ callback = callback || function () {};
344
+ if (module.is.visible() || module.is.animating()) {
345
+ if (settings.onHide.call($popup, element) === false) {
346
+ module.debug('onHide callback returned false, cancelling popup animation');
347
+
348
+ return;
349
+ }
350
+ module.remove.visible();
351
+ module.unbind.close();
352
+ module.restore.conditions();
353
+ module.animate.hide(callback);
354
+ }
555
355
  },
556
- width : $boundary.width(),
557
- height : $boundary.height()
558
- }
559
- };
560
356
 
561
- // if popup offset context is not same as target, then adjust calculations
562
- if($popupOffsetParent[0] !== $offsetParent[0]) {
563
- var
564
- popupOffset = $popupOffsetParent.offset()
565
- ;
566
- calculations.target.top -= popupOffset.top;
567
- calculations.target.left -= popupOffset.left;
568
- calculations.parent.width = $popupOffsetParent.outerWidth();
569
- calculations.parent.height = $popupOffsetParent.outerHeight();
570
- }
357
+ hideAll: function () {
358
+ $document.find(selector.popup)
359
+ .filter('.' + className.popupVisible)
360
+ .each(function () {
361
+ $(this)
362
+ .data(metadata.activator)
363
+ .popup('hide')
364
+ ;
365
+ })
366
+ ;
367
+ },
368
+ exists: function () {
369
+ if (!$popup) {
370
+ return false;
371
+ }
372
+ if (settings.inline || settings.popup) {
373
+ return module.has.popup();
374
+ }
375
+
376
+ return $popup.closest($context).length > 0;
377
+ },
571
378
 
572
- // add in container calcs if fluid
573
- if( settings.setFluidWidth && module.is.fluid() ) {
574
- calculations.container = {
575
- width: $popup.parent().outerWidth()
576
- };
577
- calculations.popup.width = calculations.container.width;
578
- }
379
+ removePopup: function () {
380
+ if (module.has.popup() && !settings.popup) {
381
+ module.debug('Removing popup', $popup);
382
+ $popup.remove();
383
+ $popup = undefined;
384
+ settings.onRemove.call($popup, element);
385
+ }
386
+ },
579
387
 
580
- // add in margins if inline
581
- calculations.target.margin.top = (settings.inline)
582
- ? parseInt( window.getComputedStyle(targetElement).getPropertyValue('margin-top'), 10)
583
- : 0
584
- ;
585
- calculations.target.margin.left = (settings.inline)
586
- ? module.is.rtl()
587
- ? parseInt( window.getComputedStyle(targetElement).getPropertyValue('margin-right'), 10)
588
- : parseInt( window.getComputedStyle(targetElement).getPropertyValue('margin-left'), 10)
589
- : 0
590
- ;
591
- // calculate screen boundaries
592
- screen = calculations.screen;
593
- calculations.boundary = {
594
- top : screen.top + screen.scroll.top,
595
- bottom : screen.top + screen.scroll.top + screen.height,
596
- left : screen.left + screen.scroll.left,
597
- right : screen.left + screen.scroll.left + screen.width
598
- };
599
- return calculations;
600
- },
601
- id: function() {
602
- return id;
603
- },
604
- startEvent: function() {
605
- if(settings.on == 'hover') {
606
- return 'mouseenter';
607
- }
608
- else if(settings.on == 'focus') {
609
- return 'focus';
610
- }
611
- return false;
612
- },
613
- scrollEvent: function() {
614
- return 'scroll';
615
- },
616
- endEvent: function() {
617
- if(settings.on == 'hover') {
618
- return 'mouseleave';
619
- }
620
- else if(settings.on == 'focus') {
621
- return 'blur';
622
- }
623
- return false;
624
- },
625
- distanceFromBoundary: function(offset, calculations) {
626
- var
627
- distanceFromBoundary = {},
628
- popup,
629
- boundary
630
- ;
631
- calculations = calculations || module.get.calculations();
632
-
633
- // shorthand
634
- popup = calculations.popup;
635
- boundary = calculations.boundary;
636
-
637
- if(offset) {
638
- distanceFromBoundary = {
639
- top : (offset.top - boundary.top),
640
- left : (offset.left - boundary.left),
641
- right : (boundary.right - (offset.left + popup.width) ),
642
- bottom : (boundary.bottom - (offset.top + popup.height) )
643
- };
644
- module.verbose('Distance from boundaries determined', offset, distanceFromBoundary);
645
- }
646
- return distanceFromBoundary;
647
- },
648
- offsetParent: function($element) {
649
- var
650
- element = ($element !== undefined)
651
- ? $element[0]
652
- : $target[0],
653
- parentNode = element.parentNode,
654
- $node = $(parentNode)
655
- ;
656
- if(parentNode) {
657
- var
658
- is2D = ($node.css('transform') === 'none'),
659
- isStatic = ($node.css('position') === 'static'),
660
- isBody = $node.is('body')
661
- ;
662
- while(parentNode && !isBody && isStatic && is2D) {
663
- parentNode = parentNode.parentNode;
664
- $node = $(parentNode);
665
- is2D = ($node.css('transform') === 'none');
666
- isStatic = ($node.css('position') === 'static');
667
- isBody = $node.is('body');
668
- }
669
- }
670
- return ($node && $node.length > 0)
671
- ? $node
672
- : $()
673
- ;
674
- },
675
- positions: function() {
676
- return {
677
- 'top left' : false,
678
- 'top center' : false,
679
- 'top right' : false,
680
- 'bottom left' : false,
681
- 'bottom center' : false,
682
- 'bottom right' : false,
683
- 'left center' : false,
684
- 'right center' : false
388
+ save: {
389
+ conditions: function () {
390
+ module.cache = {
391
+ title: $module.attr('title'),
392
+ };
393
+ if (module.cache.title) {
394
+ $module.removeAttr('title');
395
+ }
396
+ module.verbose('Saving original attributes', module.cache.title);
397
+ },
398
+ },
399
+ restore: {
400
+ conditions: function () {
401
+ if (module.cache && module.cache.title) {
402
+ $module.attr('title', module.cache.title);
403
+ module.verbose('Restoring original attributes', module.cache.title);
404
+ }
405
+
406
+ return true;
407
+ },
408
+ },
409
+ supports: {
410
+ svg: function () {
411
+ return typeof SVGGraphicsElement !== 'undefined';
412
+ },
413
+ },
414
+ animate: {
415
+ show: function (callback) {
416
+ callback = isFunction(callback) ? callback : function () {};
417
+ if (settings.transition && module.can.useElement('transition') && $module.transition('is supported')) {
418
+ module.set.visible();
419
+ $popup
420
+ .transition({
421
+ animation: (settings.transition.showMethod || settings.transition) + ' in',
422
+ queue: false,
423
+ debug: settings.debug,
424
+ verbose: settings.verbose,
425
+ silent: settings.silent,
426
+ duration: settings.transition.showDuration || settings.duration,
427
+ onComplete: function () {
428
+ module.bind.close();
429
+ callback.call($popup, element);
430
+ settings.onVisible.call($popup, element);
431
+ },
432
+ })
433
+ ;
434
+ }
435
+ },
436
+ hide: function (callback) {
437
+ callback = isFunction(callback) ? callback : function () {};
438
+ module.debug('Hiding pop-up');
439
+ if (settings.transition && $.fn.transition !== undefined && $module.transition('is supported')) {
440
+ $popup
441
+ .transition({
442
+ animation: (settings.transition.hideMethod || settings.transition) + ' out',
443
+ queue: false,
444
+ duration: settings.transition.hideDuration || settings.duration,
445
+ debug: settings.debug,
446
+ verbose: settings.verbose,
447
+ silent: settings.silent,
448
+ onComplete: function () {
449
+ module.reset();
450
+ callback.call($popup, element);
451
+ settings.onHidden.call($popup, element);
452
+ },
453
+ })
454
+ ;
455
+ } else {
456
+ module.error(error.noTransition);
457
+ }
458
+ },
459
+ },
460
+
461
+ change: {
462
+ content: function (html) {
463
+ $popup.html(html);
464
+ },
465
+ },
466
+
467
+ get: {
468
+ html: function () {
469
+ $module.removeData(metadata.html);
470
+
471
+ return $module.data(metadata.html) || settings.html;
472
+ },
473
+ title: function () {
474
+ $module.removeData(metadata.title);
475
+
476
+ return $module.data(metadata.title) || settings.title;
477
+ },
478
+ content: function () {
479
+ $module.removeData(metadata.content);
480
+
481
+ return $module.data(metadata.content) || settings.content || $module.attr('title');
482
+ },
483
+ variation: function () {
484
+ $module.removeData(metadata.variation);
485
+
486
+ return $module.data(metadata.variation) || settings.variation;
487
+ },
488
+ popup: function () {
489
+ return $popup;
490
+ },
491
+ popupOffset: function () {
492
+ return $popup.offset();
493
+ },
494
+ calculations: function () {
495
+ var
496
+ $popupOffsetParent = module.get.offsetParent($popup),
497
+ targetElement = $target[0],
498
+ isWindowEl = $boundary[0] === window,
499
+ targetOffset = $target.offset(),
500
+ parentOffset = settings.inline || (settings.popup && settings.movePopup)
501
+ ? $target.offsetParent().offset()
502
+ : { top: 0, left: 0 },
503
+ screenPosition = isWindowEl
504
+ ? { top: 0, left: 0 }
505
+ : $boundary.offset(),
506
+ calculations = {},
507
+ scroll = isWindowEl
508
+ ? { top: $window.scrollTop(), left: $window.scrollLeft() }
509
+ : { top: 0, left: 0 },
510
+ screen
511
+ ;
512
+ calculations = {
513
+ // element which is launching popup
514
+ target: {
515
+ element: $target[0],
516
+ width: $target.outerWidth(),
517
+ height: $target.outerHeight(),
518
+ top: targetOffset.top - parentOffset.top,
519
+ left: targetOffset.left - parentOffset.left,
520
+ margin: {},
521
+ },
522
+ // popup itself
523
+ popup: {
524
+ width: $popup.outerWidth(),
525
+ height: $popup.outerHeight(),
526
+ },
527
+ // offset container (or 3d context)
528
+ parent: {
529
+ width: $offsetParent.outerWidth(),
530
+ height: $offsetParent.outerHeight(),
531
+ },
532
+ // screen boundaries
533
+ screen: {
534
+ top: screenPosition.top,
535
+ left: screenPosition.left,
536
+ scroll: {
537
+ top: scroll.top,
538
+ left: scroll.left,
539
+ },
540
+ width: $boundary.width(),
541
+ height: $boundary.height(),
542
+ },
543
+ };
544
+
545
+ // if popup offset context is not same as target, then adjust calculations
546
+ if ($popupOffsetParent[0] !== $offsetParent[0]) {
547
+ var
548
+ popupOffset = $popupOffsetParent.offset()
549
+ ;
550
+ calculations.target.top -= popupOffset.top;
551
+ calculations.target.left -= popupOffset.left;
552
+ calculations.parent.width = $popupOffsetParent.outerWidth();
553
+ calculations.parent.height = $popupOffsetParent.outerHeight();
554
+ }
555
+
556
+ // add in container calcs if fluid
557
+ if (settings.setFluidWidth && module.is.fluid()) {
558
+ calculations.container = {
559
+ width: $popup.parent().outerWidth(),
560
+ };
561
+ calculations.popup.width = calculations.container.width;
562
+ }
563
+
564
+ // add in margins if inline
565
+ calculations.target.margin.top = settings.inline
566
+ ? parseInt(window.getComputedStyle(targetElement).getPropertyValue('margin-top'), 10)
567
+ : 0;
568
+ calculations.target.margin.left = settings.inline
569
+ ? (module.is.rtl()
570
+ ? parseInt(window.getComputedStyle(targetElement).getPropertyValue('margin-right'), 10)
571
+ : parseInt(window.getComputedStyle(targetElement).getPropertyValue('margin-left'), 10))
572
+ : 0;
573
+ // calculate screen boundaries
574
+ screen = calculations.screen;
575
+ calculations.boundary = {
576
+ top: screen.top + screen.scroll.top,
577
+ bottom: screen.top + screen.scroll.top + screen.height,
578
+ left: screen.left + screen.scroll.left,
579
+ right: screen.left + screen.scroll.left + screen.width,
580
+ };
581
+
582
+ return calculations;
583
+ },
584
+ id: function () {
585
+ return id;
586
+ },
587
+ startEvent: function () {
588
+ if (settings.on === 'hover') {
589
+ return 'mouseenter';
590
+ }
591
+ if (settings.on === 'focus') {
592
+ return 'focus';
593
+ }
594
+
595
+ return false;
596
+ },
597
+ scrollEvent: function () {
598
+ return 'scroll';
599
+ },
600
+ endEvent: function () {
601
+ if (settings.on === 'hover') {
602
+ return 'mouseleave';
603
+ }
604
+ if (settings.on === 'focus') {
605
+ return 'blur';
606
+ }
607
+
608
+ return false;
609
+ },
610
+ distanceFromBoundary: function (offset, calculations) {
611
+ var
612
+ distanceFromBoundary = {},
613
+ popup,
614
+ boundary
615
+ ;
616
+ calculations = calculations || module.get.calculations();
617
+
618
+ // shorthand
619
+ popup = calculations.popup;
620
+ boundary = calculations.boundary;
621
+
622
+ if (offset) {
623
+ distanceFromBoundary = {
624
+ top: offset.top - boundary.top,
625
+ left: offset.left - boundary.left,
626
+ right: boundary.right - (offset.left + popup.width),
627
+ bottom: boundary.bottom - (offset.top + popup.height),
628
+ };
629
+ module.verbose('Distance from boundaries determined', offset, distanceFromBoundary);
630
+ }
631
+
632
+ return distanceFromBoundary;
633
+ },
634
+ offsetParent: function ($element) {
635
+ var
636
+ element = $element !== undefined
637
+ ? $element[0]
638
+ : $target[0],
639
+ parentNode = element.parentNode,
640
+ $node = $(parentNode)
641
+ ;
642
+ if (parentNode) {
643
+ var
644
+ is2D = $node.css('transform') === 'none',
645
+ isStatic = $node.css('position') === 'static',
646
+ isBody = $node.is('body')
647
+ ;
648
+ while (parentNode && !isBody && isStatic && is2D) {
649
+ parentNode = parentNode.parentNode;
650
+ $node = $(parentNode);
651
+ is2D = $node.css('transform') === 'none';
652
+ isStatic = $node.css('position') === 'static';
653
+ isBody = $node.is('body');
654
+ }
655
+ }
656
+
657
+ return $node && $node.length > 0
658
+ ? $node
659
+ : $();
660
+ },
661
+ positions: function () {
662
+ return {
663
+ 'top left': false,
664
+ 'top center': false,
665
+ 'top right': false,
666
+ 'bottom left': false,
667
+ 'bottom center': false,
668
+ 'bottom right': false,
669
+ 'left center': false,
670
+ 'right center': false,
671
+ };
672
+ },
673
+ nextPosition: function (position) {
674
+ var
675
+ positions = position.split(' '),
676
+ verticalPosition = positions[0],
677
+ horizontalPosition = positions[1],
678
+ opposite = {
679
+ top: 'bottom',
680
+ bottom: 'top',
681
+ left: 'right',
682
+ right: 'left',
683
+ },
684
+ adjacent = {
685
+ left: 'center',
686
+ center: 'right',
687
+ right: 'left',
688
+ },
689
+ backup = {
690
+ 'top left': 'top center',
691
+ 'top center': 'top right',
692
+ 'top right': 'right center',
693
+ 'right center': 'bottom right',
694
+ 'bottom right': 'bottom center',
695
+ 'bottom center': 'bottom left',
696
+ 'bottom left': 'left center',
697
+ 'left center': 'top left',
698
+ },
699
+ adjacentsAvailable = verticalPosition === 'top' || verticalPosition === 'bottom',
700
+ oppositeTried = false,
701
+ adjacentTried = false,
702
+ nextPosition = false
703
+ ;
704
+ if (!triedPositions) {
705
+ module.verbose('All available positions available');
706
+ triedPositions = module.get.positions();
707
+ }
708
+
709
+ module.debug('Recording last position tried', position);
710
+ triedPositions[position] = true;
711
+
712
+ if (settings.prefer === 'opposite') {
713
+ nextPosition = [opposite[verticalPosition], horizontalPosition];
714
+ nextPosition = nextPosition.join(' ');
715
+ oppositeTried = triedPositions[nextPosition] === true;
716
+ module.debug('Trying opposite strategy', nextPosition);
717
+ }
718
+ if ((settings.prefer === 'adjacent') && adjacentsAvailable) {
719
+ nextPosition = [verticalPosition, adjacent[horizontalPosition]];
720
+ nextPosition = nextPosition.join(' ');
721
+ adjacentTried = triedPositions[nextPosition] === true;
722
+ module.debug('Trying adjacent strategy', nextPosition);
723
+ }
724
+ if (adjacentTried || oppositeTried) {
725
+ module.debug('Using backup position', nextPosition);
726
+ nextPosition = backup[position];
727
+ }
728
+
729
+ return nextPosition;
730
+ },
731
+ },
732
+
733
+ set: {
734
+ position: function (position, calculations) {
735
+ // exit conditions
736
+ if ($target.length === 0 || $popup.length === 0) {
737
+ module.error(error.notFound);
738
+
739
+ return;
740
+ }
741
+ var
742
+ offset,
743
+ distanceAway,
744
+ target,
745
+ popup,
746
+ parent,
747
+ positioning,
748
+ popupOffset,
749
+ distanceFromBoundary
750
+ ;
751
+
752
+ calculations = calculations || module.get.calculations();
753
+ position = position || $module.data(metadata.position) || settings.position;
754
+
755
+ offset = $module.data(metadata.offset) || settings.offset;
756
+ distanceAway = settings.distanceAway;
757
+
758
+ // shorthand
759
+ target = calculations.target;
760
+ popup = calculations.popup;
761
+ parent = calculations.parent;
762
+
763
+ if (module.should.centerArrow(calculations)) {
764
+ module.verbose('Adjusting offset to center arrow on small target element');
765
+ if (position === 'top left' || position === 'bottom left') {
766
+ offset += target.width / 2;
767
+ offset -= settings.arrowPixelsFromEdge;
768
+ }
769
+ if (position === 'top right' || position === 'bottom right') {
770
+ offset -= target.width / 2;
771
+ offset += settings.arrowPixelsFromEdge;
772
+ }
773
+ }
774
+
775
+ if (target.width === 0 && target.height === 0 && !module.is.svg(target.element)) {
776
+ module.debug('Popup target is hidden, no action taken');
777
+
778
+ return false;
779
+ }
780
+
781
+ if (settings.inline) {
782
+ module.debug('Adding margin to calculation', target.margin);
783
+ if (position === 'left center' || position === 'right center') {
784
+ offset += target.margin.top;
785
+ distanceAway += -target.margin.left;
786
+ } else if (position === 'top left' || position === 'top center' || position === 'top right') {
787
+ offset += target.margin.left;
788
+ distanceAway -= target.margin.top;
789
+ } else {
790
+ offset += target.margin.left;
791
+ distanceAway += target.margin.top;
792
+ }
793
+ }
794
+
795
+ module.debug('Determining popup position from calculations', position, calculations);
796
+
797
+ if (module.is.rtl()) {
798
+ position = position.replace(/left|right/g, function (match) {
799
+ return match === 'left'
800
+ ? 'right'
801
+ : 'left';
802
+ });
803
+ module.debug('RTL: Popup position updated', position);
804
+ }
805
+
806
+ // if last attempt use specified last resort position
807
+ if (searchDepth === settings.maxSearchDepth && typeof settings.lastResort === 'string') {
808
+ position = settings.lastResort;
809
+ }
810
+
811
+ switch (position) {
812
+ case 'top left': {
813
+ positioning = {
814
+ top: 'auto',
815
+ bottom: parent.height - target.top + distanceAway,
816
+ left: target.left + offset,
817
+ right: 'auto',
818
+ };
819
+
820
+ break;
821
+ }
822
+ case 'top center': {
823
+ positioning = {
824
+ bottom: parent.height - target.top + distanceAway,
825
+ left: target.left + (target.width / 2) - (popup.width / 2) + offset,
826
+ top: 'auto',
827
+ right: 'auto',
828
+ };
829
+
830
+ break;
831
+ }
832
+ case 'top right': {
833
+ positioning = {
834
+ bottom: parent.height - target.top + distanceAway,
835
+ right: parent.width - target.left - target.width - offset,
836
+ top: 'auto',
837
+ left: 'auto',
838
+ };
839
+
840
+ break;
841
+ }
842
+ case 'left center': {
843
+ positioning = {
844
+ top: target.top + (target.height / 2) - (popup.height / 2) + offset,
845
+ right: parent.width - target.left + distanceAway,
846
+ left: 'auto',
847
+ bottom: 'auto',
848
+ };
849
+
850
+ break;
851
+ }
852
+ case 'right center': {
853
+ positioning = {
854
+ top: target.top + (target.height / 2) - (popup.height / 2) + offset,
855
+ left: target.left + target.width + distanceAway,
856
+ bottom: 'auto',
857
+ right: 'auto',
858
+ };
859
+
860
+ break;
861
+ }
862
+ case 'bottom left': {
863
+ positioning = {
864
+ top: target.top + target.height + distanceAway,
865
+ left: target.left + offset,
866
+ bottom: 'auto',
867
+ right: 'auto',
868
+ };
869
+
870
+ break;
871
+ }
872
+ case 'bottom center': {
873
+ positioning = {
874
+ top: target.top + target.height + distanceAway,
875
+ left: target.left + (target.width / 2) - (popup.width / 2) + offset,
876
+ bottom: 'auto',
877
+ right: 'auto',
878
+ };
879
+
880
+ break;
881
+ }
882
+ case 'bottom right': {
883
+ positioning = {
884
+ top: target.top + target.height + distanceAway,
885
+ right: parent.width - target.left - target.width - offset,
886
+ left: 'auto',
887
+ bottom: 'auto',
888
+ };
889
+
890
+ break;
891
+ }
892
+ }
893
+ if (positioning === undefined) {
894
+ module.error(error.invalidPosition, position);
895
+ }
896
+
897
+ module.debug('Calculated popup positioning values', positioning);
898
+
899
+ // tentatively place on stage
900
+ $popup
901
+ .css(positioning)
902
+ .removeClass(className.position)
903
+ .addClass(position)
904
+ .addClass(className.loading)
905
+ ;
906
+
907
+ popupOffset = module.get.popupOffset();
908
+
909
+ // see if any boundaries are surpassed with this tentative position
910
+ distanceFromBoundary = module.get.distanceFromBoundary(popupOffset, calculations);
911
+
912
+ if (!settings.forcePosition && module.is.offstage(distanceFromBoundary, position)) {
913
+ module.debug('Position is outside viewport', position);
914
+ if (searchDepth < settings.maxSearchDepth) {
915
+ searchDepth++;
916
+ position = module.get.nextPosition(position);
917
+ module.debug('Trying new position', position);
918
+
919
+ return $popup
920
+ ? module.set.position(position, calculations)
921
+ : false;
922
+ }
923
+ if (settings.lastResort) {
924
+ module.debug('No position found, showing with last position');
925
+ } else {
926
+ module.debug('Popup could not find a position to display', $popup);
927
+ module.error(error.cannotPlace, element);
928
+ module.remove.attempts();
929
+ module.remove.loading();
930
+ module.reset();
931
+ settings.onUnplaceable.call($popup, element);
932
+
933
+ return false;
934
+ }
935
+ }
936
+ module.debug('Position is on stage', position);
937
+ module.remove.attempts();
938
+ module.remove.loading();
939
+ if (settings.setFluidWidth && module.is.fluid()) {
940
+ module.set.fluidWidth(calculations);
941
+ }
942
+
943
+ return true;
944
+ },
945
+
946
+ fluidWidth: function (calculations) {
947
+ calculations = calculations || module.get.calculations();
948
+ module.debug('Automatically setting element width to parent width', calculations.parent.width);
949
+ $popup.css('width', calculations.container.width);
950
+ },
951
+
952
+ variation: function (variation) {
953
+ variation = variation || module.get.variation();
954
+ if (variation && module.has.popup()) {
955
+ module.verbose('Adding variation to popup', variation);
956
+ $popup.addClass(variation);
957
+ }
958
+ },
959
+
960
+ visible: function () {
961
+ $module.addClass(className.visible);
962
+ },
963
+ },
964
+
965
+ remove: {
966
+ loading: function () {
967
+ $popup.removeClass(className.loading);
968
+ },
969
+ variation: function (variation) {
970
+ variation = variation || module.get.variation();
971
+ if (variation) {
972
+ module.verbose('Removing variation', variation);
973
+ $popup.removeClass(variation);
974
+ }
975
+ },
976
+ visible: function () {
977
+ $module.removeClass(className.visible);
978
+ },
979
+ attempts: function () {
980
+ module.verbose('Resetting all searched positions');
981
+ searchDepth = 0;
982
+ triedPositions = false;
983
+ },
984
+ },
985
+
986
+ bind: {
987
+ events: function () {
988
+ module.debug('Binding popup events to module');
989
+ if (settings.on === 'click') {
990
+ $module
991
+ .on(clickEvent + eventNamespace, module.toggle)
992
+ ;
993
+ }
994
+ if (settings.on === 'hover') {
995
+ $module
996
+ .on('touchstart' + eventNamespace, module.event.touchstart)
997
+ ;
998
+ }
999
+ if (module.get.startEvent()) {
1000
+ $module
1001
+ .on(module.get.startEvent() + eventNamespace, module.event.start)
1002
+ .on(module.get.endEvent() + eventNamespace, module.event.end)
1003
+ ;
1004
+ }
1005
+ if (settings.target) {
1006
+ module.debug('Target set to element', $target);
1007
+ }
1008
+ $window.on('resize' + elementNamespace, module.event.resize);
1009
+ },
1010
+ popup: function () {
1011
+ module.verbose('Allowing hover events on popup to prevent closing');
1012
+ if ($popup && module.has.popup()) {
1013
+ $popup
1014
+ .on('mouseenter' + eventNamespace, module.event.start)
1015
+ .on('mouseleave' + eventNamespace, module.event.end)
1016
+ ;
1017
+ }
1018
+ },
1019
+ close: function () {
1020
+ if (settings.hideOnScroll === true || (settings.hideOnScroll === 'auto' && settings.on !== 'click')) {
1021
+ module.bind.closeOnScroll();
1022
+ }
1023
+ if (module.is.closable()) {
1024
+ module.bind.clickaway();
1025
+ } else if (settings.on === 'hover' && openedWithTouch) {
1026
+ module.bind.touchClose();
1027
+ }
1028
+ },
1029
+ closeOnScroll: function () {
1030
+ module.verbose('Binding scroll close event to document');
1031
+ $scrollContext
1032
+ .one(module.get.scrollEvent() + elementNamespace, module.event.hideGracefully)
1033
+ ;
1034
+ },
1035
+ touchClose: function () {
1036
+ module.verbose('Binding popup touchclose event to document');
1037
+ $document
1038
+ .on('touchstart' + elementNamespace, function (event) {
1039
+ module.verbose('Touched away from popup');
1040
+ module.event.hideGracefully.call(element, event);
1041
+ })
1042
+ ;
1043
+ },
1044
+ clickaway: function () {
1045
+ module.verbose('Binding popup close event to document');
1046
+ $document
1047
+ .on(clickEvent + elementNamespace, function (event) {
1048
+ module.verbose('Clicked away from popup');
1049
+ module.event.hideGracefully.call(element, event);
1050
+ })
1051
+ ;
1052
+ },
1053
+ },
1054
+
1055
+ unbind: {
1056
+ events: function () {
1057
+ $window
1058
+ .off(elementNamespace)
1059
+ ;
1060
+ $module
1061
+ .off(eventNamespace)
1062
+ ;
1063
+ },
1064
+ close: function () {
1065
+ $document
1066
+ .off(elementNamespace)
1067
+ ;
1068
+ $scrollContext
1069
+ .off(elementNamespace)
1070
+ ;
1071
+ },
1072
+ },
1073
+
1074
+ can: {
1075
+ useElement: function (element) {
1076
+ if ($.fn[element] !== undefined) {
1077
+ return true;
1078
+ }
1079
+ module.error(error.noElement.replace('{element}', element));
1080
+
1081
+ return false;
1082
+ },
1083
+ },
1084
+
1085
+ has: {
1086
+ popup: function () {
1087
+ return $popup && $popup.length > 0;
1088
+ },
1089
+ },
1090
+
1091
+ should: {
1092
+ centerArrow: function (calculations) {
1093
+ return !module.is.basic() && calculations.target.width <= (settings.arrowPixelsFromEdge * 2);
1094
+ },
1095
+ },
1096
+
1097
+ is: {
1098
+ closable: function () {
1099
+ if (settings.closable === 'auto') {
1100
+ return settings.on !== 'hover';
1101
+ }
1102
+
1103
+ return settings.closable;
1104
+ },
1105
+ offstage: function (distanceFromBoundary, position) {
1106
+ var
1107
+ offstage = []
1108
+ ;
1109
+ // return boundaries that have been surpassed
1110
+ $.each(distanceFromBoundary, function (direction, distance) {
1111
+ if (distance < -settings.jitter) {
1112
+ module.debug('Position exceeds allowable distance from edge', direction, distance, position);
1113
+ offstage.push(direction);
1114
+ }
1115
+ });
1116
+
1117
+ return offstage.length > 0;
1118
+ },
1119
+ svg: function (element) {
1120
+ return module.supports.svg() && (element instanceof SVGGraphicsElement);
1121
+ },
1122
+ basic: function () {
1123
+ return $module.hasClass(className.basic);
1124
+ },
1125
+ active: function () {
1126
+ return $module.hasClass(className.active);
1127
+ },
1128
+ animating: function () {
1129
+ return $popup !== undefined && $popup.hasClass(className.animating);
1130
+ },
1131
+ fluid: function () {
1132
+ return $popup !== undefined && $popup.hasClass(className.fluid);
1133
+ },
1134
+ visible: function () {
1135
+ return $popup !== undefined && $popup.hasClass(className.popupVisible);
1136
+ },
1137
+ dropdown: function () {
1138
+ return $module.hasClass(className.dropdown);
1139
+ },
1140
+ hidden: function () {
1141
+ return !module.is.visible();
1142
+ },
1143
+ rtl: function () {
1144
+ return $module.attr('dir') === 'rtl' || $module.css('direction') === 'rtl' || $body.attr('dir') === 'rtl' || $body.css('direction') === 'rtl' || $context.attr('dir') === 'rtl' || $context.css('direction') === 'rtl';
1145
+ },
1146
+ },
1147
+
1148
+ reset: function () {
1149
+ module.remove.visible();
1150
+ if (settings.preserve) {
1151
+ if ($.fn.transition !== undefined) {
1152
+ $popup
1153
+ .transition('remove transition')
1154
+ ;
1155
+ }
1156
+ } else {
1157
+ module.removePopup();
1158
+ }
1159
+ },
1160
+
1161
+ setting: function (name, value) {
1162
+ if ($.isPlainObject(name)) {
1163
+ $.extend(true, settings, name);
1164
+ } else if (value !== undefined) {
1165
+ settings[name] = value;
1166
+ } else {
1167
+ return settings[name];
1168
+ }
1169
+ },
1170
+ internal: function (name, value) {
1171
+ if ($.isPlainObject(name)) {
1172
+ $.extend(true, module, name);
1173
+ } else if (value !== undefined) {
1174
+ module[name] = value;
1175
+ } else {
1176
+ return module[name];
1177
+ }
1178
+ },
1179
+ debug: function () {
1180
+ if (!settings.silent && settings.debug) {
1181
+ if (settings.performance) {
1182
+ module.performance.log(arguments);
1183
+ } else {
1184
+ module.debug = Function.prototype.bind.call(console.info, console, settings.name + ':');
1185
+ module.debug.apply(console, arguments);
1186
+ }
1187
+ }
1188
+ },
1189
+ verbose: function () {
1190
+ if (!settings.silent && settings.verbose && settings.debug) {
1191
+ if (settings.performance) {
1192
+ module.performance.log(arguments);
1193
+ } else {
1194
+ module.verbose = Function.prototype.bind.call(console.info, console, settings.name + ':');
1195
+ module.verbose.apply(console, arguments);
1196
+ }
1197
+ }
1198
+ },
1199
+ error: function () {
1200
+ if (!settings.silent) {
1201
+ module.error = Function.prototype.bind.call(console.error, console, settings.name + ':');
1202
+ module.error.apply(console, arguments);
1203
+ }
1204
+ },
1205
+ performance: {
1206
+ log: function (message) {
1207
+ var
1208
+ currentTime,
1209
+ executionTime,
1210
+ previousTime
1211
+ ;
1212
+ if (settings.performance) {
1213
+ currentTime = Date.now();
1214
+ previousTime = time || currentTime;
1215
+ executionTime = currentTime - previousTime;
1216
+ time = currentTime;
1217
+ performance.push({
1218
+ Name: message[0],
1219
+ Arguments: [].slice.call(message, 1) || '',
1220
+ Element: element,
1221
+ 'Execution Time': executionTime,
1222
+ });
1223
+ }
1224
+ clearTimeout(module.performance.timer);
1225
+ module.performance.timer = setTimeout(module.performance.display, 500);
1226
+ },
1227
+ display: function () {
1228
+ var
1229
+ title = settings.name + ':',
1230
+ totalTime = 0
1231
+ ;
1232
+ time = false;
1233
+ clearTimeout(module.performance.timer);
1234
+ $.each(performance, function (index, data) {
1235
+ totalTime += data['Execution Time'];
1236
+ });
1237
+ title += ' ' + totalTime + 'ms';
1238
+ if (moduleSelector) {
1239
+ title += ' \'' + moduleSelector + '\'';
1240
+ }
1241
+ if (performance.length > 0) {
1242
+ console.groupCollapsed(title);
1243
+ if (console.table) {
1244
+ console.table(performance);
1245
+ } else {
1246
+ $.each(performance, function (index, data) {
1247
+ console.log(data.Name + ': ' + data['Execution Time'] + 'ms');
1248
+ });
1249
+ }
1250
+ console.groupEnd();
1251
+ }
1252
+ performance = [];
1253
+ },
1254
+ },
1255
+ invoke: function (query, passedArguments, context) {
1256
+ var
1257
+ object = instance,
1258
+ maxDepth,
1259
+ found,
1260
+ response
1261
+ ;
1262
+ passedArguments = passedArguments || queryArguments;
1263
+ context = context || element;
1264
+ if (typeof query === 'string' && object !== undefined) {
1265
+ query = query.split(/[ .]/);
1266
+ maxDepth = query.length - 1;
1267
+ $.each(query, function (depth, value) {
1268
+ var camelCaseValue = depth !== maxDepth
1269
+ ? value + query[depth + 1].charAt(0).toUpperCase() + query[depth + 1].slice(1)
1270
+ : query
1271
+ ;
1272
+ if ($.isPlainObject(object[camelCaseValue]) && (depth !== maxDepth)) {
1273
+ object = object[camelCaseValue];
1274
+ } else if (object[camelCaseValue] !== undefined) {
1275
+ found = object[camelCaseValue];
1276
+
1277
+ return false;
1278
+ } else if ($.isPlainObject(object[value]) && (depth !== maxDepth)) {
1279
+ object = object[value];
1280
+ } else if (object[value] !== undefined) {
1281
+ found = object[value];
1282
+
1283
+ return false;
1284
+ } else {
1285
+ module.error(error.method, query);
1286
+
1287
+ return false;
1288
+ }
1289
+ });
1290
+ }
1291
+ if (isFunction(found)) {
1292
+ response = found.apply(context, passedArguments);
1293
+ } else if (found !== undefined) {
1294
+ response = found;
1295
+ }
1296
+ if (Array.isArray(returnedValue)) {
1297
+ returnedValue.push(response);
1298
+ } else if (returnedValue !== undefined) {
1299
+ returnedValue = [returnedValue, response];
1300
+ } else if (response !== undefined) {
1301
+ returnedValue = response;
1302
+ }
1303
+
1304
+ return found;
1305
+ },
685
1306
  };
686
- },
687
- nextPosition: function(position) {
688
- var
689
- positions = position.split(' '),
690
- verticalPosition = positions[0],
691
- horizontalPosition = positions[1],
692
- opposite = {
693
- top : 'bottom',
694
- bottom : 'top',
695
- left : 'right',
696
- right : 'left'
697
- },
698
- adjacent = {
699
- left : 'center',
700
- center : 'right',
701
- right : 'left'
702
- },
703
- backup = {
704
- 'top left' : 'top center',
705
- 'top center' : 'top right',
706
- 'top right' : 'right center',
707
- 'right center' : 'bottom right',
708
- 'bottom right' : 'bottom center',
709
- 'bottom center' : 'bottom left',
710
- 'bottom left' : 'left center',
711
- 'left center' : 'top left'
712
- },
713
- adjacentsAvailable = (verticalPosition == 'top' || verticalPosition == 'bottom'),
714
- oppositeTried = false,
715
- adjacentTried = false,
716
- nextPosition = false
717
- ;
718
- if(!triedPositions) {
719
- module.verbose('All available positions available');
720
- triedPositions = module.get.positions();
1307
+
1308
+ if (methodInvoked) {
1309
+ if (instance === undefined) {
1310
+ module.initialize();
1311
+ }
1312
+ module.invoke(query);
1313
+ } else {
1314
+ if (instance !== undefined) {
1315
+ instance.invoke('destroy');
1316
+ }
1317
+ module.initialize();
721
1318
  }
1319
+ });
722
1320
 
723
- module.debug('Recording last position tried', position);
724
- triedPositions[position] = true;
1321
+ return returnedValue !== undefined
1322
+ ? returnedValue
1323
+ : this;
1324
+ };
725
1325
 
726
- if(settings.prefer === 'opposite') {
727
- nextPosition = [opposite[verticalPosition], horizontalPosition];
728
- nextPosition = nextPosition.join(' ');
729
- oppositeTried = (triedPositions[nextPosition] === true);
730
- module.debug('Trying opposite strategy', nextPosition);
731
- }
732
- if((settings.prefer === 'adjacent') && adjacentsAvailable ) {
733
- nextPosition = [verticalPosition, adjacent[horizontalPosition]];
734
- nextPosition = nextPosition.join(' ');
735
- adjacentTried = (triedPositions[nextPosition] === true);
736
- module.debug('Trying adjacent strategy', nextPosition);
737
- }
738
- if(adjacentTried || oppositeTried) {
739
- module.debug('Using backup position', nextPosition);
740
- nextPosition = backup[position];
741
- }
742
- return nextPosition;
743
- }
744
- },
1326
+ $.fn.popup.settings = {
745
1327
 
746
- set: {
747
- position: function(position, calculations) {
1328
+ name: 'Popup',
748
1329
 
749
- // exit conditions
750
- if($target.length === 0 || $popup.length === 0) {
751
- module.error(error.notFound);
752
- return;
753
- }
754
- var
755
- offset,
756
- distanceAway,
757
- target,
758
- popup,
759
- parent,
760
- positioning,
761
- popupOffset,
762
- distanceFromBoundary
763
- ;
1330
+ // module settings
1331
+ silent: false,
1332
+ debug: false,
1333
+ verbose: false,
1334
+ performance: true,
1335
+ namespace: 'popup',
764
1336
 
765
- calculations = calculations || module.get.calculations();
766
- position = position || $module.data(metadata.position) || settings.position;
767
-
768
- offset = $module.data(metadata.offset) || settings.offset;
769
- distanceAway = settings.distanceAway;
770
-
771
- // shorthand
772
- target = calculations.target;
773
- popup = calculations.popup;
774
- parent = calculations.parent;
775
-
776
- if(module.should.centerArrow(calculations)) {
777
- module.verbose('Adjusting offset to center arrow on small target element');
778
- if(position == 'top left' || position == 'bottom left') {
779
- offset += (target.width / 2);
780
- offset -= settings.arrowPixelsFromEdge;
781
- }
782
- if(position == 'top right' || position == 'bottom right') {
783
- offset -= (target.width / 2);
784
- offset += settings.arrowPixelsFromEdge;
785
- }
786
- }
1337
+ // whether it should use dom mutation observers
1338
+ observeChanges: true,
787
1339
 
788
- if(target.width === 0 && target.height === 0 && !module.is.svg(target.element)) {
789
- module.debug('Popup target is hidden, no action taken');
790
- return false;
791
- }
1340
+ // callback only when element added to dom
1341
+ onCreate: function () {},
792
1342
 
793
- if(settings.inline) {
794
- module.debug('Adding margin to calculation', target.margin);
795
- if(position == 'left center' || position == 'right center') {
796
- offset += target.margin.top;
797
- distanceAway += -target.margin.left;
798
- }
799
- else if (position == 'top left' || position == 'top center' || position == 'top right') {
800
- offset += target.margin.left;
801
- distanceAway -= target.margin.top;
802
- }
803
- else {
804
- offset += target.margin.left;
805
- distanceAway += target.margin.top;
806
- }
807
- }
1343
+ // callback before element removed from dom
1344
+ onRemove: function () {},
808
1345
 
809
- module.debug('Determining popup position from calculations', position, calculations);
1346
+ // callback before show animation
1347
+ onShow: function () {},
810
1348
 
811
- if (module.is.rtl()) {
812
- position = position.replace(/left|right/g, function (match) {
813
- return (match == 'left')
814
- ? 'right'
815
- : 'left'
816
- ;
817
- });
818
- module.debug('RTL: Popup position updated', position);
819
- }
1349
+ // callback after show animation
1350
+ onVisible: function () {},
820
1351
 
821
- // if last attempt use specified last resort position
822
- if(searchDepth == settings.maxSearchDepth && typeof settings.lastResort === 'string') {
823
- position = settings.lastResort;
824
- }
1352
+ // callback before hide animation
1353
+ onHide: function () {},
825
1354
 
826
- switch (position) {
827
- case 'top left':
828
- positioning = {
829
- top : 'auto',
830
- bottom : parent.height - target.top + distanceAway,
831
- left : target.left + offset,
832
- right : 'auto'
833
- };
834
- break;
835
- case 'top center':
836
- positioning = {
837
- bottom : parent.height - target.top + distanceAway,
838
- left : target.left + (target.width / 2) - (popup.width / 2) + offset,
839
- top : 'auto',
840
- right : 'auto'
841
- };
842
- break;
843
- case 'top right':
844
- positioning = {
845
- bottom : parent.height - target.top + distanceAway,
846
- right : parent.width - target.left - target.width - offset,
847
- top : 'auto',
848
- left : 'auto'
849
- };
850
- break;
851
- case 'left center':
852
- positioning = {
853
- top : target.top + (target.height / 2) - (popup.height / 2) + offset,
854
- right : parent.width - target.left + distanceAway,
855
- left : 'auto',
856
- bottom : 'auto'
857
- };
858
- break;
859
- case 'right center':
860
- positioning = {
861
- top : target.top + (target.height / 2) - (popup.height / 2) + offset,
862
- left : target.left + target.width + distanceAway,
863
- bottom : 'auto',
864
- right : 'auto'
865
- };
866
- break;
867
- case 'bottom left':
868
- positioning = {
869
- top : target.top + target.height + distanceAway,
870
- left : target.left + offset,
871
- bottom : 'auto',
872
- right : 'auto'
873
- };
874
- break;
875
- case 'bottom center':
876
- positioning = {
877
- top : target.top + target.height + distanceAway,
878
- left : target.left + (target.width / 2) - (popup.width / 2) + offset,
879
- bottom : 'auto',
880
- right : 'auto'
881
- };
882
- break;
883
- case 'bottom right':
884
- positioning = {
885
- top : target.top + target.height + distanceAway,
886
- right : parent.width - target.left - target.width - offset,
887
- left : 'auto',
888
- bottom : 'auto'
889
- };
890
- break;
891
- }
892
- if(positioning === undefined) {
893
- module.error(error.invalidPosition, position);
894
- }
1355
+ // callback when popup cannot be positioned in visible screen
1356
+ onUnplaceable: function () {},
895
1357
 
896
- module.debug('Calculated popup positioning values', positioning);
1358
+ // callback after hide animation
1359
+ onHidden: function () {},
897
1360
 
898
- // tentatively place on stage
899
- $popup
900
- .css(positioning)
901
- .removeClass(className.position)
902
- .addClass(position)
903
- .addClass(className.loading)
904
- ;
1361
+ // when to show popup
1362
+ on: 'hover',
905
1363
 
906
- popupOffset = module.get.popupOffset();
1364
+ // element to use to determine if popup is out of boundary
1365
+ boundary: window,
907
1366
 
908
- // see if any boundaries are surpassed with this tentative position
909
- distanceFromBoundary = module.get.distanceFromBoundary(popupOffset, calculations);
1367
+ // whether to add touchstart events when using hover
1368
+ addTouchEvents: true,
910
1369
 
911
- if(!settings.forcePosition && module.is.offstage(distanceFromBoundary, position) ) {
912
- module.debug('Position is outside viewport', position);
913
- if(searchDepth < settings.maxSearchDepth) {
914
- searchDepth++;
915
- position = module.get.nextPosition(position);
916
- module.debug('Trying new position', position);
917
- return ($popup)
918
- ? module.set.position(position, calculations)
919
- : false
920
- ;
921
- }
922
- else {
923
- if(settings.lastResort) {
924
- module.debug('No position found, showing with last position');
925
- }
926
- else {
927
- module.debug('Popup could not find a position to display', $popup);
928
- module.error(error.cannotPlace, element);
929
- module.remove.attempts();
930
- module.remove.loading();
931
- module.reset();
932
- settings.onUnplaceable.call($popup, element);
933
- return false;
934
- }
935
- }
936
- }
937
- module.debug('Position is on stage', position);
938
- module.remove.attempts();
939
- module.remove.loading();
940
- if( settings.setFluidWidth && module.is.fluid() ) {
941
- module.set.fluidWidth(calculations);
942
- }
943
- return true;
944
- },
945
-
946
- fluidWidth: function(calculations) {
947
- calculations = calculations || module.get.calculations();
948
- module.debug('Automatically setting element width to parent width', calculations.parent.width);
949
- $popup.css('width', calculations.container.width);
950
- },
951
-
952
- variation: function(variation) {
953
- variation = variation || module.get.variation();
954
- if(variation && module.has.popup() ) {
955
- module.verbose('Adding variation to popup', variation);
956
- $popup.addClass(variation);
957
- }
958
- },
1370
+ // default position relative to element
1371
+ position: 'top left',
959
1372
 
960
- visible: function() {
961
- $module.addClass(className.visible);
962
- }
963
- },
1373
+ // if given position should be used regardless if popup fits
1374
+ forcePosition: false,
964
1375
 
965
- remove: {
966
- loading: function() {
967
- $popup.removeClass(className.loading);
968
- },
969
- variation: function(variation) {
970
- variation = variation || module.get.variation();
971
- if(variation) {
972
- module.verbose('Removing variation', variation);
973
- $popup.removeClass(variation);
974
- }
975
- },
976
- visible: function() {
977
- $module.removeClass(className.visible);
978
- },
979
- attempts: function() {
980
- module.verbose('Resetting all searched positions');
981
- searchDepth = 0;
982
- triedPositions = false;
983
- }
984
- },
1376
+ // name of variation to use
1377
+ variation: '',
985
1378
 
986
- bind: {
987
- events: function() {
988
- module.debug('Binding popup events to module');
989
- if(settings.on == 'click') {
990
- $module
991
- .on(clickEvent + eventNamespace, module.toggle)
992
- ;
993
- }
994
- if(settings.on == 'hover') {
995
- $module
996
- .on('touchstart' + eventNamespace, module.event.touchstart)
997
- ;
998
- }
999
- if( module.get.startEvent() ) {
1000
- $module
1001
- .on(module.get.startEvent() + eventNamespace, module.event.start)
1002
- .on(module.get.endEvent() + eventNamespace, module.event.end)
1003
- ;
1004
- }
1005
- if(settings.target) {
1006
- module.debug('Target set to element', $target);
1007
- }
1008
- $window.on('resize' + elementNamespace, module.event.resize);
1009
- },
1010
- popup: function() {
1011
- module.verbose('Allowing hover events on popup to prevent closing');
1012
- if( $popup && module.has.popup() ) {
1013
- $popup
1014
- .on('mouseenter' + eventNamespace, module.event.start)
1015
- .on('mouseleave' + eventNamespace, module.event.end)
1016
- ;
1017
- }
1018
- },
1019
- close: function() {
1020
- if(settings.hideOnScroll === true || (settings.hideOnScroll == 'auto' && settings.on != 'click')) {
1021
- module.bind.closeOnScroll();
1022
- }
1023
- if(module.is.closable()) {
1024
- module.bind.clickaway();
1025
- }
1026
- else if(settings.on == 'hover' && openedWithTouch) {
1027
- module.bind.touchClose();
1028
- }
1029
- },
1030
- closeOnScroll: function() {
1031
- module.verbose('Binding scroll close event to document');
1032
- $scrollContext
1033
- .one(module.get.scrollEvent() + elementNamespace, module.event.hideGracefully)
1034
- ;
1035
- },
1036
- touchClose: function() {
1037
- module.verbose('Binding popup touchclose event to document');
1038
- $document
1039
- .on('touchstart' + elementNamespace, function(event) {
1040
- module.verbose('Touched away from popup');
1041
- module.event.hideGracefully.call(element, event);
1042
- })
1043
- ;
1044
- },
1045
- clickaway: function() {
1046
- module.verbose('Binding popup close event to document');
1047
- $document
1048
- .on(clickEvent + elementNamespace, function(event) {
1049
- module.verbose('Clicked away from popup');
1050
- module.event.hideGracefully.call(element, event);
1051
- })
1052
- ;
1053
- }
1054
- },
1379
+ // whether popup should be moved to context
1380
+ movePopup: true,
1055
1381
 
1056
- unbind: {
1057
- events: function() {
1058
- $window
1059
- .off(elementNamespace)
1060
- ;
1061
- $module
1062
- .off(eventNamespace)
1063
- ;
1064
- },
1065
- close: function() {
1066
- $document
1067
- .off(elementNamespace)
1068
- ;
1069
- $scrollContext
1070
- .off(elementNamespace)
1071
- ;
1072
- },
1073
- },
1382
+ // element which popup should be relative to
1383
+ target: false,
1074
1384
 
1075
- has: {
1076
- popup: function() {
1077
- return ($popup && $popup.length > 0);
1078
- }
1079
- },
1385
+ // jq selector or element that should be used as popup
1386
+ popup: false,
1080
1387
 
1081
- should: {
1082
- centerArrow: function(calculations) {
1083
- return !module.is.basic() && calculations.target.width <= (settings.arrowPixelsFromEdge * 2);
1084
- },
1085
- },
1388
+ // popup should remain inline next to activator
1389
+ inline: false,
1086
1390
 
1087
- is: {
1088
- closable: function() {
1089
- if(settings.closable == 'auto') {
1090
- return settings.on != 'hover';
1091
- }
1092
- return settings.closable;
1093
- },
1094
- offstage: function(distanceFromBoundary, position) {
1095
- var
1096
- offstage = []
1097
- ;
1098
- // return boundaries that have been surpassed
1099
- $.each(distanceFromBoundary, function(direction, distance) {
1100
- if(distance < -settings.jitter) {
1101
- module.debug('Position exceeds allowable distance from edge', direction, distance, position);
1102
- offstage.push(direction);
1103
- }
1104
- });
1105
- return offstage.length > 0;
1106
- },
1107
- svg: function(element) {
1108
- return module.supports.svg() && (element instanceof SVGGraphicsElement);
1109
- },
1110
- basic: function() {
1111
- return $module.hasClass(className.basic);
1112
- },
1113
- active: function() {
1114
- return $module.hasClass(className.active);
1115
- },
1116
- animating: function() {
1117
- return ($popup !== undefined && $popup.hasClass(className.animating) );
1118
- },
1119
- fluid: function() {
1120
- return ($popup !== undefined && $popup.hasClass(className.fluid));
1121
- },
1122
- visible: function() {
1123
- return ($popup !== undefined && $popup.hasClass(className.popupVisible));
1124
- },
1125
- dropdown: function() {
1126
- return $module.hasClass(className.dropdown);
1127
- },
1128
- hidden: function() {
1129
- return !module.is.visible();
1130
- },
1131
- rtl: function () {
1132
- return $module.attr('dir') === 'rtl' || $module.css('direction') === 'rtl' || $body.attr('dir') === 'rtl' || $body.css('direction') === 'rtl' || $context.attr('dir') === 'rtl' || $context.css('direction') === 'rtl';
1133
- }
1134
- },
1391
+ // popup should be removed from page on hide
1392
+ preserve: false,
1135
1393
 
1136
- reset: function() {
1137
- module.remove.visible();
1138
- if(settings.preserve) {
1139
- if($.fn.transition !== undefined) {
1140
- $popup
1141
- .transition('remove transition')
1142
- ;
1143
- }
1144
- }
1145
- else {
1146
- module.removePopup();
1147
- }
1148
- },
1394
+ // popup should not close when being hovered on
1395
+ hoverable: false,
1149
1396
 
1150
- setting: function(name, value) {
1151
- if( $.isPlainObject(name) ) {
1152
- $.extend(true, settings, name);
1153
- }
1154
- else if(value !== undefined) {
1155
- settings[name] = value;
1156
- }
1157
- else {
1158
- return settings[name];
1159
- }
1160
- },
1161
- internal: function(name, value) {
1162
- if( $.isPlainObject(name) ) {
1163
- $.extend(true, module, name);
1164
- }
1165
- else if(value !== undefined) {
1166
- module[name] = value;
1167
- }
1168
- else {
1169
- return module[name];
1170
- }
1171
- },
1172
- debug: function() {
1173
- if(!settings.silent && settings.debug) {
1174
- if(settings.performance) {
1175
- module.performance.log(arguments);
1176
- }
1177
- else {
1178
- module.debug = Function.prototype.bind.call(console.info, console, settings.name + ':');
1179
- module.debug.apply(console, arguments);
1180
- }
1181
- }
1182
- },
1183
- verbose: function() {
1184
- if(!settings.silent && settings.verbose && settings.debug) {
1185
- if(settings.performance) {
1186
- module.performance.log(arguments);
1187
- }
1188
- else {
1189
- module.verbose = Function.prototype.bind.call(console.info, console, settings.name + ':');
1190
- module.verbose.apply(console, arguments);
1191
- }
1192
- }
1193
- },
1194
- error: function() {
1195
- if(!settings.silent) {
1196
- module.error = Function.prototype.bind.call(console.error, console, settings.name + ':');
1197
- module.error.apply(console, arguments);
1198
- }
1199
- },
1200
- performance: {
1201
- log: function(message) {
1202
- var
1203
- currentTime,
1204
- executionTime,
1205
- previousTime
1206
- ;
1207
- if(settings.performance) {
1208
- currentTime = new Date().getTime();
1209
- previousTime = time || currentTime;
1210
- executionTime = currentTime - previousTime;
1211
- time = currentTime;
1212
- performance.push({
1213
- 'Name' : message[0],
1214
- 'Arguments' : [].slice.call(message, 1) || '',
1215
- 'Element' : element,
1216
- 'Execution Time' : executionTime
1217
- });
1218
- }
1219
- clearTimeout(module.performance.timer);
1220
- module.performance.timer = setTimeout(module.performance.display, 500);
1221
- },
1222
- display: function() {
1223
- var
1224
- title = settings.name + ':',
1225
- totalTime = 0
1226
- ;
1227
- time = false;
1228
- clearTimeout(module.performance.timer);
1229
- $.each(performance, function(index, data) {
1230
- totalTime += data['Execution Time'];
1231
- });
1232
- title += ' ' + totalTime + 'ms';
1233
- if(moduleSelector) {
1234
- title += ' \'' + moduleSelector + '\'';
1235
- }
1236
- if( (console.group !== undefined || console.table !== undefined) && performance.length > 0) {
1237
- console.groupCollapsed(title);
1238
- if(console.table) {
1239
- console.table(performance);
1240
- }
1241
- else {
1242
- $.each(performance, function(index, data) {
1243
- console.log(data['Name'] + ': ' + data['Execution Time']+'ms');
1244
- });
1245
- }
1246
- console.groupEnd();
1247
- }
1248
- performance = [];
1249
- }
1250
- },
1251
- invoke: function(query, passedArguments, context) {
1252
- var
1253
- object = instance,
1254
- maxDepth,
1255
- found,
1256
- response
1257
- ;
1258
- passedArguments = passedArguments || queryArguments;
1259
- context = context || element;
1260
- if(typeof query == 'string' && object !== undefined) {
1261
- query = query.split(/[\. ]/);
1262
- maxDepth = query.length - 1;
1263
- $.each(query, function(depth, value) {
1264
- var camelCaseValue = (depth != maxDepth)
1265
- ? value + query[depth + 1].charAt(0).toUpperCase() + query[depth + 1].slice(1)
1266
- : query
1267
- ;
1268
- if( $.isPlainObject( object[camelCaseValue] ) && (depth != maxDepth) ) {
1269
- object = object[camelCaseValue];
1270
- }
1271
- else if( object[camelCaseValue] !== undefined ) {
1272
- found = object[camelCaseValue];
1273
- return false;
1274
- }
1275
- else if( $.isPlainObject( object[value] ) && (depth != maxDepth) ) {
1276
- object = object[value];
1277
- }
1278
- else if( object[value] !== undefined ) {
1279
- found = object[value];
1280
- return false;
1281
- }
1282
- else {
1283
- return false;
1284
- }
1285
- });
1286
- }
1287
- if ( $.isFunction( found ) ) {
1288
- response = found.apply(context, passedArguments);
1289
- }
1290
- else if(found !== undefined) {
1291
- response = found;
1292
- }
1293
- if(Array.isArray(returnedValue)) {
1294
- returnedValue.push(response);
1295
- }
1296
- else if(returnedValue !== undefined) {
1297
- returnedValue = [returnedValue, response];
1298
- }
1299
- else if(response !== undefined) {
1300
- returnedValue = response;
1301
- }
1302
- return found;
1303
- }
1304
- };
1305
-
1306
- if(methodInvoked) {
1307
- if(instance === undefined) {
1308
- module.initialize();
1309
- }
1310
- module.invoke(query);
1311
- }
1312
- else {
1313
- if(instance !== undefined) {
1314
- instance.invoke('destroy');
1315
- }
1316
- module.initialize();
1317
- }
1318
- })
1319
- ;
1320
-
1321
- return (returnedValue !== undefined)
1322
- ? returnedValue
1323
- : this
1324
- ;
1325
- };
1326
-
1327
- $.fn.popup.settings = {
1328
-
1329
- name : 'Popup',
1330
-
1331
- // module settings
1332
- silent : false,
1333
- debug : false,
1334
- verbose : false,
1335
- performance : true,
1336
- namespace : 'popup',
1337
-
1338
- // whether it should use dom mutation observers
1339
- observeChanges : true,
1340
-
1341
- // callback only when element added to dom
1342
- onCreate : function(){},
1343
-
1344
- // callback before element removed from dom
1345
- onRemove : function(){},
1346
-
1347
- // callback before show animation
1348
- onShow : function(){},
1349
-
1350
- // callback after show animation
1351
- onVisible : function(){},
1352
-
1353
- // callback before hide animation
1354
- onHide : function(){},
1355
-
1356
- // callback when popup cannot be positioned in visible screen
1357
- onUnplaceable : function(){},
1358
-
1359
- // callback after hide animation
1360
- onHidden : function(){},
1361
-
1362
- // when to show popup
1363
- on : 'hover',
1364
-
1365
- // element to use to determine if popup is out of boundary
1366
- boundary : window,
1367
-
1368
- // whether to add touchstart events when using hover
1369
- addTouchEvents : true,
1370
-
1371
- // default position relative to element
1372
- position : 'top left',
1373
-
1374
- // if given position should be used regardless if popup fits
1375
- forcePosition : false,
1376
-
1377
- // name of variation to use
1378
- variation : '',
1379
-
1380
- // whether popup should be moved to context
1381
- movePopup : true,
1382
-
1383
- // element which popup should be relative to
1384
- target : false,
1385
-
1386
- // jq selector or element that should be used as popup
1387
- popup : false,
1388
-
1389
- // popup should remain inline next to activator
1390
- inline : false,
1391
-
1392
- // popup should be removed from page on hide
1393
- preserve : false,
1394
-
1395
- // popup should not close when being hovered on
1396
- hoverable : false,
1397
-
1398
- // explicitly set content
1399
- content : false,
1400
-
1401
- // explicitly set html
1402
- html : false,
1403
-
1404
- // explicitly set title
1405
- title : false,
1406
-
1407
- // whether automatically close on clickaway when on click
1408
- closable : true,
1409
-
1410
- // automatically hide on scroll
1411
- hideOnScroll : 'auto',
1397
+ // explicitly set content
1398
+ content: false,
1399
+
1400
+ // explicitly set html
1401
+ html: false,
1402
+
1403
+ // explicitly set title
1404
+ title: false,
1412
1405
 
1413
- // hide other popups on show
1414
- exclusive : false,
1406
+ // whether automatically close on clickaway when on click
1407
+ closable: true,
1415
1408
 
1416
- // context to attach popups
1417
- context : 'body',
1409
+ // automatically hide on scroll
1410
+ hideOnScroll: 'auto',
1418
1411
 
1419
- // context for binding scroll events
1420
- scrollContext : window,
1412
+ // hide other popups on show
1413
+ exclusive: false,
1421
1414
 
1422
- // position to prefer when calculating new position
1423
- prefer : 'opposite',
1415
+ // context to attach popups
1416
+ context: 'body',
1424
1417
 
1425
- // specify position to appear even if it doesn't fit
1426
- lastResort : false,
1418
+ // context for binding scroll events
1419
+ scrollContext: window,
1427
1420
 
1428
- // number of pixels from edge of popup to pointing arrow center (used from centering)
1429
- arrowPixelsFromEdge: 20,
1421
+ // position to prefer when calculating new position
1422
+ prefer: 'opposite',
1430
1423
 
1431
- // delay used to prevent accidental refiring of animations due to user error
1432
- delay : {
1433
- show : 50,
1434
- hide : 70
1435
- },
1424
+ // specify position to appear even if it doesn't fit
1425
+ lastResort: false,
1436
1426
 
1437
- // whether fluid variation should assign width explicitly
1438
- setFluidWidth : true,
1427
+ // number of pixels from edge of popup to pointing arrow center (used from centering)
1428
+ arrowPixelsFromEdge: 20,
1439
1429
 
1440
- // transition settings
1441
- duration : 200,
1442
- transition : 'scale',
1430
+ // delay used to prevent accidental refiring of animations due to user error
1431
+ delay: {
1432
+ show: 50,
1433
+ hide: 70,
1434
+ },
1435
+
1436
+ // whether fluid variation should assign width explicitly
1437
+ setFluidWidth: true,
1443
1438
 
1444
- // distance away from activating element in px
1445
- distanceAway : 0,
1439
+ // transition settings
1440
+ duration: 200,
1441
+ transition: 'scale',
1446
1442
 
1447
- // number of pixels an element is allowed to be "offstage" for a position to be chosen (allows for rounding)
1448
- jitter : 2,
1443
+ // distance away from activating element in px
1444
+ distanceAway: 0,
1449
1445
 
1450
- // offset on aligning axis from calculated position
1451
- offset : 0,
1446
+ // number of pixels an element is allowed to be "offstage" for a position to be chosen (allows for rounding)
1447
+ jitter: 2,
1452
1448
 
1453
- // maximum times to look for a position before failing (9 positions total)
1454
- maxSearchDepth : 15,
1449
+ // offset on aligning axis from calculated position
1450
+ offset: 0,
1455
1451
 
1456
- error: {
1457
- invalidPosition : 'The position you specified is not a valid position',
1458
- cannotPlace : 'Popup does not fit within the boundaries of the viewport',
1459
- method : 'The method you called is not defined.',
1460
- noTransition : 'This module requires ui transitions <https://github.com/Semantic-Org/UI-Transition>',
1461
- notFound : 'The target or popup you specified does not exist on the page'
1462
- },
1452
+ // maximum times to look for a position before failing (9 positions total)
1453
+ maxSearchDepth: 15,
1463
1454
 
1464
- metadata: {
1465
- activator : 'activator',
1466
- content : 'content',
1467
- html : 'html',
1468
- offset : 'offset',
1469
- position : 'position',
1470
- title : 'title',
1471
- variation : 'variation'
1472
- },
1473
-
1474
- className : {
1475
- active : 'active',
1476
- basic : 'basic',
1477
- animating : 'animating',
1478
- dropdown : 'dropdown',
1479
- fluid : 'fluid',
1480
- loading : 'loading',
1481
- popup : 'ui popup',
1482
- position : 'top left center bottom right',
1483
- visible : 'visible',
1484
- popupVisible : 'visible'
1485
- },
1486
-
1487
- selector : {
1488
- popup : '.ui.popup'
1489
- },
1490
-
1491
- templates: {
1492
- escape: function(string) {
1493
- var
1494
- badChars = /[<>"'`]/g,
1495
- shouldEscape = /[&<>"'`]/,
1496
- escape = {
1497
- "<": "&lt;",
1498
- ">": "&gt;",
1499
- '"': "&quot;",
1500
- "'": "&#x27;",
1501
- "`": "&#x60;"
1455
+ error: {
1456
+ invalidPosition: 'The position you specified is not a valid position',
1457
+ cannotPlace: 'Popup does not fit within the boundaries of the viewport',
1458
+ method: 'The method you called is not defined.',
1459
+ noElement: 'This module requires ui {element}',
1460
+ notFound: 'The target or popup you specified does not exist on the page',
1502
1461
  },
1503
- escapedChar = function(chr) {
1504
- return escape[chr];
1505
- }
1506
- ;
1507
- if(shouldEscape.test(string)) {
1508
- string = string.replace(/&(?![a-z0-9#]{1,12};)/gi, "&amp;");
1509
- return string.replace(badChars, escapedChar);
1510
- }
1511
- return string;
1512
- },
1513
- popup: function(text) {
1514
- var
1515
- html = '',
1516
- escape = $.fn.popup.settings.templates.escape
1517
- ;
1518
- if(typeof text !== undefined) {
1519
- if(typeof text.title !== undefined && text.title) {
1520
- text.title = escape(text.title);
1521
- html += '<div class="header">' + text.title + '</div>';
1522
- }
1523
- if(typeof text.content !== undefined && text.content) {
1524
- text.content = escape(text.content);
1525
- html += '<div class="content">' + text.content + '</div>';
1526
- }
1527
- }
1528
- return html;
1529
- }
1530
- }
1531
1462
 
1532
- };
1463
+ metadata: {
1464
+ activator: 'activator',
1465
+ content: 'content',
1466
+ html: 'html',
1467
+ offset: 'offset',
1468
+ position: 'position',
1469
+ title: 'title',
1470
+ variation: 'variation',
1471
+ },
1472
+
1473
+ className: {
1474
+ active: 'active',
1475
+ basic: 'basic',
1476
+ animating: 'animating',
1477
+ dropdown: 'dropdown',
1478
+ fluid: 'fluid',
1479
+ loading: 'loading',
1480
+ popup: 'ui popup',
1481
+ position: 'top left center bottom right',
1482
+ visible: 'visible',
1483
+ popupVisible: 'visible',
1484
+ },
1485
+
1486
+ selector: {
1487
+ popup: '.ui.popup',
1488
+ },
1489
+
1490
+ templates: {
1491
+ escape: function (string) {
1492
+ var
1493
+ badChars = /["'<>`]/g,
1494
+ shouldEscape = /["&'<>`]/,
1495
+ escape = {
1496
+ '<': '&lt;',
1497
+ '>': '&gt;',
1498
+ '"': '&quot;',
1499
+ "'": '&#x27;',
1500
+ '`': '&#x60;',
1501
+ },
1502
+ escapedChar = function (chr) {
1503
+ return escape[chr];
1504
+ }
1505
+ ;
1506
+ if (shouldEscape.test(string)) {
1507
+ string = string.replace(/&(?![\d#a-z]{1,12};)/gi, '&amp;');
1533
1508
 
1509
+ return string.replace(badChars, escapedChar);
1510
+ }
1511
+
1512
+ return string;
1513
+ },
1514
+ popup: function (text) {
1515
+ var
1516
+ html = '',
1517
+ escape = $.fn.popup.settings.templates.escape
1518
+ ;
1519
+ if (text !== undefined) {
1520
+ if (text.title) {
1521
+ text.title = escape(text.title);
1522
+ html += '<div class="header">' + text.title + '</div>';
1523
+ }
1524
+ if (text.content) {
1525
+ text.content = escape(text.content);
1526
+ html += '<div class="content">' + text.content + '</div>';
1527
+ }
1528
+ }
1529
+
1530
+ return html;
1531
+ },
1532
+ },
1534
1533
 
1535
- })( jQuery, window, document );
1534
+ };
1535
+ })(jQuery, window, document);