vapid 0.1.0

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