j1-template 2020.0.22 → 2020.0.24

Sign up to get free protection for your applications and to get access to all the features.
Files changed (266) hide show
  1. checksums.yaml +4 -4
  2. data/_includes/themes/j1/layouts/content_generator_page.html +1 -1
  3. data/_includes/themes/j1/layouts/content_generator_post.html +63 -161
  4. data/_includes/themes/j1/modules/connectors/ad/google-adsense.html +14 -0
  5. data/_includes/themes/j1/modules/connectors/analytic/google-analytics.html +1 -3
  6. data/_includes/themes/j1/modules/connectors/comment/disqus.html +37 -24
  7. data/_includes/themes/j1/modules/navigator/generator.html +8 -3
  8. data/_includes/themes/j1/modules/navigator/procedures/topsearch.proc +36 -26
  9. data/_includes/themes/j1/procedures/layouts/module_writer.proc +1 -1
  10. data/_includes/themes/j1/procedures/posts/create_series_header.proc +9 -5
  11. data/assets/data/banner.html +1 -1
  12. data/assets/data/fam.html +124 -0
  13. data/assets/data/mmenu_sidebar.html +3 -3
  14. data/assets/data/panel.html +9 -9
  15. data/assets/data/quicklinks.html +13 -13
  16. data/assets/error_pages/HTTP204.html +1 -0
  17. data/assets/error_pages/HTTP400.html +3 -2
  18. data/assets/error_pages/HTTP401.html +3 -2
  19. data/assets/error_pages/HTTP403.html +3 -2
  20. data/assets/error_pages/HTTP404.html +3 -2
  21. data/assets/error_pages/HTTP500.html +3 -2
  22. data/assets/error_pages/HTTP501.html +3 -2
  23. data/assets/error_pages/HTTP502.html +3 -2
  24. data/assets/error_pages/HTTP503.html +3 -2
  25. data/assets/error_pages/HTTP520.html +3 -2
  26. data/assets/error_pages/HTTP521.html +3 -2
  27. data/assets/error_pages/HTTP533.html +3 -2
  28. data/assets/themes/j1/adapter/js/{ssm.js → fam.js} +248 -138
  29. data/assets/themes/j1/adapter/js/framer.js +72 -56
  30. data/assets/themes/j1/adapter/js/gallery_customizer.js +2 -1
  31. data/assets/themes/j1/adapter/js/j1.js +8 -2
  32. data/assets/themes/j1/adapter/js/{searcher.js → lunr_search.js} +68 -65
  33. data/assets/themes/j1/adapter/js/toccer.js +62 -30
  34. data/assets/themes/j1/core/css/bootstrap.css +7154 -0
  35. data/assets/themes/j1/core/css/bootstrap.min.css +6 -0
  36. data/assets/themes/j1/core/css/custom.scss +28 -0
  37. data/assets/themes/j1/core/css/globals.css +14523 -0
  38. data/assets/themes/j1/core/css/globals.min.css +1 -0
  39. data/assets/themes/j1/core/css/globals.scss +28 -0
  40. data/assets/themes/j1/core/css/theme_extensions.css +11558 -0
  41. data/assets/themes/j1/core/css/theme_extensions.min.css +1 -0
  42. data/assets/themes/j1/core/css/themes/bootstrap/bootstrap.css +7 -4
  43. data/assets/themes/j1/core/css/themes/bootstrap/bootstrap.min.css +2 -2
  44. data/assets/themes/j1/core/css/themes/uno-dark/bootstrap.css +7 -4
  45. data/assets/themes/j1/core/css/themes/uno-dark/bootstrap.min.css +2 -2
  46. data/assets/themes/j1/core/css/themes/uno-light/bootstrap.css +514 -417
  47. data/assets/themes/j1/core/css/themes/uno-light/bootstrap.min.css +2 -2
  48. data/assets/themes/j1/core/css/uno.css +11823 -0
  49. data/assets/themes/j1/core/css/uno.min.css +1 -0
  50. data/assets/themes/j1/core/css/uno.scss +28 -0
  51. data/assets/themes/j1/core/css/vendor.css +5 -4
  52. data/assets/themes/j1/core/css/vendor.min.css +1 -1
  53. data/assets/themes/j1/core/css/vendor.scss +28 -0
  54. data/assets/themes/j1/core/js/template.js +6 -11
  55. data/assets/themes/j1/core/js/template.js.map +1 -1
  56. data/assets/themes/j1/core/js/template.min.js +1 -1
  57. data/assets/themes/j1/modules/bmd/js/bootstrap-material-design.js +6 -0
  58. data/assets/themes/j1/modules/cash/js/cash.js +1374 -0
  59. data/assets/themes/j1/modules/cash/js/cash.min.js +42 -0
  60. data/assets/themes/j1/modules/fam/css/uno/fam.css +369 -0
  61. data/assets/themes/j1/modules/fam/js/fam.js +477 -0
  62. data/assets/themes/j1/modules/iframeResizer/examples/frame.nested.html +1 -1
  63. data/assets/themes/j1/modules/iframeResizer/js/{iframeResizer.js → resizer.js} +0 -0
  64. data/assets/themes/j1/modules/iframeResizer/js/{iframeResizer.map → resizer.map} +0 -0
  65. data/assets/themes/j1/modules/iframeResizer/js/{iframeResizer.min.js → resizer.min.js} +0 -0
  66. data/assets/themes/j1/modules/jquery/js/require.js +2145 -0
  67. data/assets/themes/j1/modules/jquery/js/require.min.js +5 -0
  68. data/assets/themes/j1/modules/lunrSearch/css/lunr_search.css +32 -0
  69. data/assets/themes/j1/modules/lunrSearch/css/lunr_search.min.css +25 -0
  70. data/assets/themes/j1/modules/lunrSearch/js/dateformat.js +125 -0
  71. data/assets/themes/j1/modules/lunrSearch/js/dateformat.min.js +14 -0
  72. data/assets/themes/j1/modules/lunrSearch/js/lunr.js +3475 -0
  73. data/assets/themes/j1/modules/lunrSearch/js/lunr.min.js +51 -0
  74. data/assets/themes/j1/modules/lunrSearch/js/lunr_search.js +184 -0
  75. data/assets/themes/j1/modules/lunrSearch/js/lunr_search.min.js +17 -0
  76. data/assets/themes/j1/modules/lunrSearch/js/mustache.js +772 -0
  77. data/assets/themes/j1/modules/lunrSearch/js/mustache.min.js +772 -0
  78. data/assets/themes/j1/modules/lunrSearch/js/uri.js +2340 -0
  79. data/assets/themes/j1/modules/lunrSearch/js/uri.min.js +93 -0
  80. data/assets/themes/j1/modules/materialize/js/anime.js +1283 -0
  81. data/assets/themes/j1/modules/materialize/js/anime.min.js +34 -0
  82. data/assets/themes/j1/modules/materialize/js/autocomplete.js +450 -0
  83. data/assets/themes/j1/modules/materialize/js/buttons.js +409 -0
  84. data/assets/themes/j1/modules/materialize/js/cards.js +40 -0
  85. data/assets/themes/j1/modules/materialize/js/carousel.js +717 -0
  86. data/assets/themes/j1/modules/materialize/js/cash-dom.js +1044 -0
  87. data/assets/themes/j1/modules/materialize/js/cash.js +960 -0
  88. data/assets/themes/j1/modules/materialize/js/characterCounter.js +136 -0
  89. data/assets/themes/j1/modules/materialize/js/chips.js +481 -0
  90. data/assets/themes/j1/modules/materialize/js/collapsible.js +275 -0
  91. data/assets/themes/j1/modules/materialize/js/component.js +44 -0
  92. data/assets/themes/j1/modules/materialize/js/datepicker.js +975 -0
  93. data/assets/themes/j1/modules/materialize/js/dropdown.js +617 -0
  94. data/assets/themes/j1/modules/materialize/js/forms.js +275 -0
  95. data/assets/themes/j1/modules/materialize/js/global.js +427 -0
  96. data/assets/themes/j1/modules/materialize/js/materialbox.js +453 -0
  97. data/assets/themes/j1/modules/materialize/js/modal.js +382 -0
  98. data/assets/themes/j1/modules/materialize/js/parallax.js +138 -0
  99. data/assets/themes/j1/modules/materialize/js/pushpin.js +145 -0
  100. data/assets/themes/j1/modules/materialize/js/range.js +263 -0
  101. data/assets/themes/j1/modules/materialize/js/ripple.js +335 -0
  102. data/assets/themes/j1/modules/materialize/js/scrollspy.js +295 -0
  103. data/assets/themes/j1/modules/materialize/js/select.js +432 -0
  104. data/assets/themes/j1/modules/materialize/js/sidenav.js +580 -0
  105. data/assets/themes/j1/modules/materialize/js/slider.js +359 -0
  106. data/assets/themes/j1/modules/materialize/js/tabs.js +402 -0
  107. data/assets/themes/j1/modules/materialize/js/tapTarget.js +314 -0
  108. data/assets/themes/j1/modules/materialize/js/timepicker.js +647 -0
  109. data/assets/themes/j1/modules/materialize/js/toasts.js +310 -0
  110. data/assets/themes/j1/modules/materialize/js/tooltip.js +303 -0
  111. data/assets/themes/j1/modules/materialize/js/waves.js +335 -0
  112. data/assets/themes/j1/modules/materialize/scss/components/_badges.scss +55 -0
  113. data/assets/themes/j1/modules/materialize/scss/components/_buttons.scss +322 -0
  114. data/assets/themes/j1/modules/materialize/scss/components/_cards.scss +195 -0
  115. data/assets/themes/j1/modules/materialize/scss/components/_carousel.scss +90 -0
  116. data/assets/themes/j1/modules/materialize/scss/components/_chips.scss +90 -0
  117. data/assets/themes/j1/modules/materialize/scss/components/_collapsible.scss +91 -0
  118. data/assets/themes/j1/modules/materialize/scss/components/_color-classes.scss +32 -0
  119. data/assets/themes/j1/modules/materialize/scss/components/_color-variables.scss +370 -0
  120. data/assets/themes/j1/modules/materialize/scss/components/_datepicker.scss +191 -0
  121. data/assets/themes/j1/modules/materialize/scss/components/_dropdown.scss +85 -0
  122. data/assets/themes/j1/modules/materialize/scss/components/_global.scss +769 -0
  123. data/assets/themes/j1/modules/materialize/scss/components/_grid.scss +156 -0
  124. data/assets/themes/j1/modules/materialize/scss/components/_icons-material-design.scss +5 -0
  125. data/assets/themes/j1/modules/materialize/scss/components/_materialbox.scss +43 -0
  126. data/assets/themes/j1/modules/materialize/scss/components/_modal.scss +94 -0
  127. data/assets/themes/j1/modules/materialize/scss/components/_navbar.scss +208 -0
  128. data/assets/themes/j1/modules/materialize/scss/components/_normalize.scss +447 -0
  129. data/assets/themes/j1/modules/materialize/scss/components/_preloader.scss +334 -0
  130. data/assets/themes/j1/modules/materialize/scss/components/_pulse.scss +34 -0
  131. data/assets/themes/j1/modules/materialize/scss/components/_sidenav.scss +216 -0
  132. data/assets/themes/j1/modules/materialize/scss/components/_slider.scss +92 -0
  133. data/assets/themes/j1/modules/materialize/scss/components/_table_of_contents.scss +33 -0
  134. data/assets/themes/j1/modules/materialize/scss/components/_tabs.scss +99 -0
  135. data/assets/themes/j1/modules/materialize/scss/components/_tapTarget.scss +103 -0
  136. data/assets/themes/j1/modules/materialize/scss/components/_timepicker.scss +183 -0
  137. data/assets/themes/j1/modules/materialize/scss/components/_toast.scss +58 -0
  138. data/assets/themes/j1/modules/materialize/scss/components/_tooltip.scss +32 -0
  139. data/assets/themes/j1/modules/materialize/scss/components/_transitions.scss +13 -0
  140. data/assets/themes/j1/modules/materialize/scss/components/_typography.scss +60 -0
  141. data/assets/themes/j1/modules/materialize/scss/components/_variables.scss +349 -0
  142. data/assets/themes/j1/modules/materialize/scss/components/_waves.scss +114 -0
  143. data/assets/themes/j1/modules/materialize/scss/components/forms/_checkboxes.scss +200 -0
  144. data/assets/themes/j1/modules/materialize/scss/components/forms/_file-input.scss +44 -0
  145. data/assets/themes/j1/modules/materialize/scss/components/forms/_forms.scss +22 -0
  146. data/assets/themes/j1/modules/materialize/scss/components/forms/_input-fields.scss +354 -0
  147. data/assets/themes/j1/modules/materialize/scss/components/forms/_radio-buttons.scss +115 -0
  148. data/assets/themes/j1/modules/materialize/scss/components/forms/_range.scss +161 -0
  149. data/assets/themes/j1/modules/materialize/scss/components/forms/_select.scss +180 -0
  150. data/assets/themes/j1/modules/materialize/scss/components/forms/_switches.scss +89 -0
  151. data/assets/themes/j1/modules/materialize/scss/materialize.scss +41 -0
  152. data/assets/themes/j1/modules/{bsThemeSwitcher → themeSwitcher}/js/switcher.js +0 -0
  153. data/assets/themes/j1/modules/{bsThemeSwitcher → themeSwitcher}/js/switcher.min.js +0 -0
  154. data/lib/j1/version.rb +1 -1
  155. data/lib/starter_web/Gemfile +12 -16
  156. data/lib/starter_web/_config.yml +95 -21
  157. data/lib/starter_web/_data/blocks/banner.yml +1 -1
  158. data/lib/starter_web/_data/blocks/panel.yml +6 -6
  159. data/lib/starter_web/_data/j1_config.yml +7 -6
  160. data/lib/starter_web/_data/layouts/home.yml +13 -3
  161. data/lib/starter_web/_data/layouts/page.yml +10 -0
  162. data/lib/starter_web/_data/layouts/post.yml +10 -0
  163. data/lib/starter_web/_data/modules/defaults/{ssm.yml → fam.yml} +12 -15
  164. data/lib/starter_web/_data/modules/defaults/lunr_search.yml +171 -0
  165. data/lib/starter_web/_data/modules/defaults/navigator.yml +4 -4
  166. data/lib/starter_web/_data/modules/defaults/toccer.yml +4 -2
  167. data/lib/starter_web/_data/modules/fam.yml +158 -0
  168. data/lib/starter_web/_data/modules/{back2top.yml → lunr_search.yml} +15 -9
  169. data/lib/starter_web/_data/modules/navigator.yml +2 -2
  170. data/lib/starter_web/_data/modules/navigator_menu.yml +57 -6
  171. data/lib/starter_web/_data/modules/toccer.yml +0 -73
  172. data/lib/starter_web/_data/resources.yml +151 -104
  173. data/lib/starter_web/_includes/attributes.asciidoc +2 -2
  174. data/lib/starter_web/_includes/breadcrumbs.html +11 -0
  175. data/lib/starter_web/_plugins/debug.rb +0 -1
  176. data/lib/starter_web/_plugins/filters.rb +0 -1
  177. data/lib/starter_web/_plugins/{lorem-inline.rb → lorem_inline.rb} +1 -2
  178. data/lib/starter_web/_plugins/lunr_index.rb +313 -0
  179. data/lib/starter_web/_plugins/prettify.rb +0 -3
  180. data/lib/starter_web/_plugins/simple_search_filter.rb +0 -1
  181. data/lib/starter_web/_plugins/symlink_watcher.rb +2 -3
  182. data/lib/starter_web/assets/images/modules/attics/banner/lunr-banner-1280x800.jpg +0 -0
  183. data/lib/starter_web/assets/images/pages/winlogbeat/coordinate-map.png +0 -0
  184. data/lib/starter_web/assets/images/pages/winlogbeat/kibana-powershell.jpg +0 -0
  185. data/lib/starter_web/assets/images/pages/winlogbeat/option_ignore_outgoing.png +0 -0
  186. data/lib/starter_web/assets/images/pages/winlogbeat/winlogbeat-dashboard.png +0 -0
  187. data/lib/starter_web/collections/posts/public/featured/_posts/2018-05-01-confusion-about-base-url.adoc +2 -4
  188. data/lib/starter_web/collections/posts/public/featured/_posts/2019-05-01-top-open-source-static-site-generators.adoc +4 -2
  189. data/lib/starter_web/collections/posts/public/featured/_posts/2019-06-01-about-cookies.adoc +3 -2
  190. data/lib/starter_web/collections/posts/public/series/_posts/2018-11-01-docker-using-shared-folders.adoc +5 -4
  191. data/lib/starter_web/collections/posts/public/series/_posts/2020-01-01-post-test-series.adoc +144 -0
  192. data/lib/starter_web/collections/posts/public/series/_posts/2020-01-02-post-test-series.adoc +146 -0
  193. data/lib/starter_web/collections/posts/public/series/_posts/2020-01-03-post-test-series.adoc +146 -0
  194. data/lib/starter_web/collections/posts/public/series/_posts/2020-01-04-post-test-series.adoc +146 -0
  195. data/lib/starter_web/collections/posts/public/test_posts/_posts/2020-09-11-test_post.adoc +2 -4
  196. data/lib/starter_web/collections/posts/public/wikipedia/_posts/2016-11-20-minneapolis.adoc +2 -3
  197. data/lib/starter_web/collections/posts/public/wikipedia/_posts/2016-11-24-narcisse-snake-dens.adoc +2 -7
  198. data/lib/starter_web/collections/posts/public/wikipedia/_posts/2016-11-26-columbia-river.adoc +2 -6
  199. data/lib/starter_web/index.html +16 -10
  200. data/lib/starter_web/package.json +5 -2
  201. data/lib/starter_web/pages/public/about/about_site.adoc +0 -2
  202. data/lib/starter_web/pages/public/about/become_a_patron.adoc +1 -3
  203. data/lib/starter_web/pages/public/blog/navigator/archive.html +8 -1
  204. data/lib/starter_web/pages/public/blog/navigator/archive/categoryview.html +7 -3
  205. data/lib/starter_web/pages/public/blog/navigator/archive/dateview.html +8 -1
  206. data/lib/starter_web/pages/public/blog/navigator/archive/tagview.html +7 -2
  207. data/lib/starter_web/pages/public/blog/navigator/index.html +6 -2
  208. data/lib/starter_web/pages/public/learn/kickstarter/web_in_a_day/100_meet_and_greet_jekyll.adoc +3 -4
  209. data/lib/starter_web/pages/public/learn/kickstarter/web_in_a_day/200_preparations.adoc +3 -4
  210. data/lib/starter_web/pages/public/learn/kickstarter/web_in_a_day/300_first_awesome_web.adoc +3 -4
  211. data/lib/starter_web/pages/public/learn/roundtrip/100_present_images.adoc +25 -20
  212. data/lib/starter_web/pages/public/learn/roundtrip/100_present_videos.adoc +14 -12
  213. data/lib/starter_web/pages/public/learn/roundtrip/200_typography.adoc +20 -20
  214. data/lib/starter_web/pages/public/learn/roundtrip/300_icon_fonts.adoc +13 -8
  215. data/lib/starter_web/pages/public/learn/roundtrip/400_asciidoc_extensions.adoc +14 -9
  216. data/lib/starter_web/pages/public/learn/roundtrip/410_bs_modals_extentions.adoc +9 -6
  217. data/lib/starter_web/pages/public/learn/roundtrip/420_responsive_tables_extensions.adoc +62 -8
  218. data/lib/starter_web/pages/public/learn/roundtrip/500_themes.adoc +9 -7
  219. data/lib/starter_web/pages/public/learn/roundtrip/600_lunr.adoc +237 -0
  220. data/lib/starter_web/pages/public/learn/roundtrip/610_fam.adoc +302 -0
  221. data/lib/starter_web/pages/public/learn/where_to_go.adoc +3 -7
  222. data/lib/starter_web/pages/public/legal/de/100_impress.adoc +3 -2
  223. data/lib/starter_web/pages/public/legal/de/200_terms_of_use.adoc +2 -1
  224. data/lib/starter_web/pages/public/legal/de/300_privacy.adoc +2 -1
  225. data/lib/starter_web/pages/public/legal/de/400_license_agreement.adoc +2 -1
  226. data/lib/starter_web/pages/public/legal/de/500_support.adoc +2 -1
  227. data/lib/starter_web/pages/public/legal/en/000_copyright.adoc +30 -27
  228. data/lib/starter_web/pages/public/legal/en/100_impress.adoc +8 -5
  229. data/lib/starter_web/pages/public/legal/en/200_terms_of_use.adoc +12 -8
  230. data/lib/starter_web/pages/public/legal/en/300_privacy.adoc +7 -0
  231. data/lib/starter_web/pages/public/legal/en/400_license_agreement.adoc +8 -1
  232. data/lib/starter_web/pages/public/legal/en/500_support.adoc +8 -1
  233. data/lib/starter_web/pages/public/previewer/bootstrap_theme.adoc +3 -1
  234. data/lib/starter_web/pages/public/previewer/iframer.adoc +36 -28
  235. data/lib/starter_web/pages/public/previewer/justified_gallery.html +2 -1
  236. data/lib/starter_web/pages/public/previewer/mdi_icons_preview.adoc +2 -1
  237. data/lib/starter_web/pages/public/previewer/rouge.adoc +4 -2
  238. data/lib/starter_web/pages/public/previewer/twitter_emoji_preview.adoc +2 -1
  239. data/lib/starter_web/pages/public/test_pages/breadcrumbs_tester.adoc +62 -0
  240. data/lib/starter_web/pages/public/test_pages/deck_of_posts.adoc +3 -0
  241. data/lib/starter_web/pages/public/test_pages/floating_actions_button.adoc +523 -0
  242. data/lib/starter_web/pages/public/test_pages/floating_ad.adoc +1 -0
  243. data/lib/starter_web/pages/public/test_pages/floating_div.adoc +1 -0
  244. data/lib/starter_web/pages/public/test_pages/lunr_tester.adoc +89 -0
  245. data/lib/starter_web/pages/public/test_pages/nav_pagination_tester.adoc +1 -0
  246. data/lib/starter_web/pages/public/test_pages/page_attribute_tester.adoc +1 -0
  247. data/lib/starter_web/pages/public/test_pages/responsive_images.adoc +3 -2
  248. data/lib/starter_web/pages/public/test_pages/responsive_tables.adoc +1 -0
  249. data/lib/starter_web/pages/public/test_pages/toccer_tester.adoc +2245 -0
  250. data/lib/starter_web/utilsrv/_defaults/package.json +1 -1
  251. data/lib/starter_web/utilsrv/package.json +1 -1
  252. metadata +137 -29
  253. data/assets/data/search.json +0 -165
  254. data/assets/data/ssm.html +0 -242
  255. data/assets/themes/j1/adapter/js/back2top.js +0 -231
  256. data/assets/themes/j1/modules/jekyllSearch/js/simple-jekyll-search.js +0 -468
  257. data/assets/themes/j1/modules/jekyllSearch/js/simple-jekyll-search.min.js +0 -6
  258. data/assets/themes/j1/modules/tocbot/css/theme/uno.css +0 -95
  259. data/assets/themes/j1/modules/tocbot/css/theme/uno.min.css +0 -15
  260. data/assets/themes/j1/modules/tocbot/css/tocbot.css +0 -75
  261. data/assets/themes/j1/modules/tocbot/css/tocbot.min.css +0 -19
  262. data/assets/themes/j1/modules/tocbot/js/tocbot.js +0 -19
  263. data/assets/themes/j1/modules/tocbot/js/tocbot.min.js +0 -19
  264. data/lib/starter_web/_data/modules/defaults/back2top.yml +0 -146
  265. data/lib/starter_web/_data/modules/defaults/stickybits.yml +0 -36
  266. data/lib/starter_web/_data/modules/ssm.yml +0 -142
@@ -0,0 +1,310 @@
1
+ (function($, anim) {
2
+ 'use strict';
3
+
4
+ let _defaults = {
5
+ html: '',
6
+ displayLength: 4000,
7
+ inDuration: 300,
8
+ outDuration: 375,
9
+ classes: '',
10
+ completeCallback: null,
11
+ activationPercent: 0.8
12
+ };
13
+
14
+ class Toast {
15
+ constructor(options) {
16
+ /**
17
+ * Options for the toast
18
+ * @member Toast#options
19
+ */
20
+ this.options = $.extend({}, Toast.defaults, options);
21
+ this.message = this.options.html;
22
+
23
+ /**
24
+ * Describes current pan state toast
25
+ * @type {Boolean}
26
+ */
27
+ this.panning = false;
28
+
29
+ /**
30
+ * Time remaining until toast is removed
31
+ */
32
+ this.timeRemaining = this.options.displayLength;
33
+
34
+ if (Toast._toasts.length === 0) {
35
+ Toast._createContainer();
36
+ }
37
+
38
+ // Create new toast
39
+ Toast._toasts.push(this);
40
+ let toastElement = this._createToast();
41
+ toastElement.M_Toast = this;
42
+ this.el = toastElement;
43
+ this.$el = $(toastElement);
44
+ this._animateIn();
45
+ this._setTimer();
46
+ }
47
+
48
+ static get defaults() {
49
+ return _defaults;
50
+ }
51
+
52
+ /**
53
+ * Get Instance
54
+ */
55
+ static getInstance(el) {
56
+ let domElem = !!el.jquery ? el[0] : el;
57
+ return domElem.M_Toast;
58
+ }
59
+
60
+ /**
61
+ * Append toast container and add event handlers
62
+ */
63
+ static _createContainer() {
64
+ let container = document.createElement('div');
65
+ container.setAttribute('id', 'toast-container');
66
+
67
+ // Add event handler
68
+ container.addEventListener('touchstart', Toast._onDragStart);
69
+ container.addEventListener('touchmove', Toast._onDragMove);
70
+ container.addEventListener('touchend', Toast._onDragEnd);
71
+
72
+ container.addEventListener('mousedown', Toast._onDragStart);
73
+ document.addEventListener('mousemove', Toast._onDragMove);
74
+ document.addEventListener('mouseup', Toast._onDragEnd);
75
+
76
+ document.body.appendChild(container);
77
+ Toast._container = container;
78
+ }
79
+
80
+ /**
81
+ * Remove toast container and event handlers
82
+ */
83
+ static _removeContainer() {
84
+ // Add event handler
85
+ document.removeEventListener('mousemove', Toast._onDragMove);
86
+ document.removeEventListener('mouseup', Toast._onDragEnd);
87
+
88
+ $(Toast._container).remove();
89
+ Toast._container = null;
90
+ }
91
+
92
+ /**
93
+ * Begin drag handler
94
+ * @param {Event} e
95
+ */
96
+ static _onDragStart(e) {
97
+ if (e.target && $(e.target).closest('.toast').length) {
98
+ let $toast = $(e.target).closest('.toast');
99
+ let toast = $toast[0].M_Toast;
100
+ toast.panning = true;
101
+ Toast._draggedToast = toast;
102
+ toast.el.classList.add('panning');
103
+ toast.el.style.transition = '';
104
+ toast.startingXPos = Toast._xPos(e);
105
+ toast.time = Date.now();
106
+ toast.xPos = Toast._xPos(e);
107
+ }
108
+ }
109
+
110
+ /**
111
+ * Drag move handler
112
+ * @param {Event} e
113
+ */
114
+ static _onDragMove(e) {
115
+ if (!!Toast._draggedToast) {
116
+ e.preventDefault();
117
+ let toast = Toast._draggedToast;
118
+ toast.deltaX = Math.abs(toast.xPos - Toast._xPos(e));
119
+ toast.xPos = Toast._xPos(e);
120
+ toast.velocityX = toast.deltaX / (Date.now() - toast.time);
121
+ toast.time = Date.now();
122
+
123
+ let totalDeltaX = toast.xPos - toast.startingXPos;
124
+ let activationDistance = toast.el.offsetWidth * toast.options.activationPercent;
125
+ toast.el.style.transform = `translateX(${totalDeltaX}px)`;
126
+ toast.el.style.opacity = 1 - Math.abs(totalDeltaX / activationDistance);
127
+ }
128
+ }
129
+
130
+ /**
131
+ * End drag handler
132
+ */
133
+ static _onDragEnd() {
134
+ if (!!Toast._draggedToast) {
135
+ let toast = Toast._draggedToast;
136
+ toast.panning = false;
137
+ toast.el.classList.remove('panning');
138
+
139
+ let totalDeltaX = toast.xPos - toast.startingXPos;
140
+ let activationDistance = toast.el.offsetWidth * toast.options.activationPercent;
141
+ let shouldBeDismissed = Math.abs(totalDeltaX) > activationDistance || toast.velocityX > 1;
142
+
143
+ // Remove toast
144
+ if (shouldBeDismissed) {
145
+ toast.wasSwiped = true;
146
+ toast.dismiss();
147
+
148
+ // Animate toast back to original position
149
+ } else {
150
+ toast.el.style.transition = 'transform .2s, opacity .2s';
151
+ toast.el.style.transform = '';
152
+ toast.el.style.opacity = '';
153
+ }
154
+ Toast._draggedToast = null;
155
+ }
156
+ }
157
+
158
+ /**
159
+ * Get x position of mouse or touch event
160
+ * @param {Event} e
161
+ */
162
+ static _xPos(e) {
163
+ if (e.targetTouches && e.targetTouches.length >= 1) {
164
+ return e.targetTouches[0].clientX;
165
+ }
166
+ // mouse event
167
+ return e.clientX;
168
+ }
169
+
170
+ /**
171
+ * Remove all toasts
172
+ */
173
+ static dismissAll() {
174
+ for (let toastIndex in Toast._toasts) {
175
+ Toast._toasts[toastIndex].dismiss();
176
+ }
177
+ }
178
+
179
+ /**
180
+ * Create toast and append it to toast container
181
+ */
182
+ _createToast() {
183
+ let toast = document.createElement('div');
184
+ toast.classList.add('toast');
185
+
186
+ // Add custom classes onto toast
187
+ if (!!this.options.classes.length) {
188
+ $(toast).addClass(this.options.classes);
189
+ }
190
+
191
+ // Set content
192
+ if (
193
+ typeof HTMLElement === 'object'
194
+ ? this.message instanceof HTMLElement
195
+ : this.message &&
196
+ typeof this.message === 'object' &&
197
+ this.message !== null &&
198
+ this.message.nodeType === 1 &&
199
+ typeof this.message.nodeName === 'string'
200
+ ) {
201
+ toast.appendChild(this.message);
202
+
203
+ // Check if it is jQuery object
204
+ } else if (!!this.message.jquery) {
205
+ $(toast).append(this.message[0]);
206
+
207
+ // Insert as html;
208
+ } else {
209
+ toast.innerHTML = this.message;
210
+ }
211
+
212
+ // Append toasft
213
+ Toast._container.appendChild(toast);
214
+ return toast;
215
+ }
216
+
217
+ /**
218
+ * Animate in toast
219
+ */
220
+ _animateIn() {
221
+ // Animate toast in
222
+ anim({
223
+ targets: this.el,
224
+ top: 0,
225
+ opacity: 1,
226
+ duration: this.options.inDuration,
227
+ easing: 'easeOutCubic'
228
+ });
229
+ }
230
+
231
+ /**
232
+ * Create setInterval which automatically removes toast when timeRemaining >= 0
233
+ * has been reached
234
+ */
235
+ _setTimer() {
236
+ if (this.timeRemaining !== Infinity) {
237
+ this.counterInterval = setInterval(() => {
238
+ // If toast is not being dragged, decrease its time remaining
239
+ if (!this.panning) {
240
+ this.timeRemaining -= 20;
241
+ }
242
+
243
+ // Animate toast out
244
+ if (this.timeRemaining <= 0) {
245
+ this.dismiss();
246
+ }
247
+ }, 20);
248
+ }
249
+ }
250
+
251
+ /**
252
+ * Dismiss toast with animation
253
+ */
254
+ dismiss() {
255
+ window.clearInterval(this.counterInterval);
256
+ let activationDistance = this.el.offsetWidth * this.options.activationPercent;
257
+
258
+ if (this.wasSwiped) {
259
+ this.el.style.transition = 'transform .05s, opacity .05s';
260
+ this.el.style.transform = `translateX(${activationDistance}px)`;
261
+ this.el.style.opacity = 0;
262
+ }
263
+
264
+ anim({
265
+ targets: this.el,
266
+ opacity: 0,
267
+ marginTop: -40,
268
+ duration: this.options.outDuration,
269
+ easing: 'easeOutExpo',
270
+ complete: () => {
271
+ // Call the optional callback
272
+ if (typeof this.options.completeCallback === 'function') {
273
+ this.options.completeCallback();
274
+ }
275
+ // Remove toast from DOM
276
+ this.$el.remove();
277
+ Toast._toasts.splice(Toast._toasts.indexOf(this), 1);
278
+ if (Toast._toasts.length === 0) {
279
+ Toast._removeContainer();
280
+ }
281
+ }
282
+ });
283
+ }
284
+ }
285
+
286
+ /**
287
+ * @static
288
+ * @memberof Toast
289
+ * @type {Array.<Toast>}
290
+ */
291
+ Toast._toasts = [];
292
+
293
+ /**
294
+ * @static
295
+ * @memberof Toast
296
+ */
297
+ Toast._container = null;
298
+
299
+ /**
300
+ * @static
301
+ * @memberof Toast
302
+ * @type {Toast}
303
+ */
304
+ Toast._draggedToast = null;
305
+
306
+ M.Toast = Toast;
307
+ M.toast = function(options) {
308
+ return new Toast(options);
309
+ };
310
+ })(cash, M.anime);
@@ -0,0 +1,303 @@
1
+ (function($, anim) {
2
+ 'use strict';
3
+
4
+ let _defaults = {
5
+ exitDelay: 200,
6
+ enterDelay: 0,
7
+ html: null,
8
+ margin: 5,
9
+ inDuration: 250,
10
+ outDuration: 200,
11
+ position: 'bottom',
12
+ transitionMovement: 10
13
+ };
14
+
15
+ /**
16
+ * @class
17
+ *
18
+ */
19
+ class Tooltip extends Component {
20
+ /**
21
+ * Construct Tooltip instance
22
+ * @constructor
23
+ * @param {Element} el
24
+ * @param {Object} options
25
+ */
26
+ constructor(el, options) {
27
+ super(Tooltip, el, options);
28
+
29
+ this.el.M_Tooltip = this;
30
+ this.options = $.extend({}, Tooltip.defaults, options);
31
+
32
+ this.isOpen = false;
33
+ this.isHovered = false;
34
+ this.isFocused = false;
35
+ this._appendTooltipEl();
36
+ this._setupEventHandlers();
37
+ }
38
+
39
+ static get defaults() {
40
+ return _defaults;
41
+ }
42
+
43
+ static init(els, options) {
44
+ return super.init(this, els, options);
45
+ }
46
+
47
+ /**
48
+ * Get Instance
49
+ */
50
+ static getInstance(el) {
51
+ let domElem = !!el.jquery ? el[0] : el;
52
+ return domElem.M_Tooltip;
53
+ }
54
+
55
+ /**
56
+ * Teardown component
57
+ */
58
+ destroy() {
59
+ $(this.tooltipEl).remove();
60
+ this._removeEventHandlers();
61
+ this.el.M_Tooltip = undefined;
62
+ }
63
+
64
+ _appendTooltipEl() {
65
+ let tooltipEl = document.createElement('div');
66
+ tooltipEl.classList.add('material-tooltip');
67
+ this.tooltipEl = tooltipEl;
68
+
69
+ let tooltipContentEl = document.createElement('div');
70
+ tooltipContentEl.classList.add('tooltip-content');
71
+ tooltipContentEl.innerHTML = this.options.html;
72
+ tooltipEl.appendChild(tooltipContentEl);
73
+ document.body.appendChild(tooltipEl);
74
+ }
75
+
76
+ _updateTooltipContent() {
77
+ this.tooltipEl.querySelector('.tooltip-content').innerHTML = this.options.html;
78
+ }
79
+
80
+ _setupEventHandlers() {
81
+ this._handleMouseEnterBound = this._handleMouseEnter.bind(this);
82
+ this._handleMouseLeaveBound = this._handleMouseLeave.bind(this);
83
+ this._handleFocusBound = this._handleFocus.bind(this);
84
+ this._handleBlurBound = this._handleBlur.bind(this);
85
+ this.el.addEventListener('mouseenter', this._handleMouseEnterBound);
86
+ this.el.addEventListener('mouseleave', this._handleMouseLeaveBound);
87
+ this.el.addEventListener('focus', this._handleFocusBound, true);
88
+ this.el.addEventListener('blur', this._handleBlurBound, true);
89
+ }
90
+
91
+ _removeEventHandlers() {
92
+ this.el.removeEventListener('mouseenter', this._handleMouseEnterBound);
93
+ this.el.removeEventListener('mouseleave', this._handleMouseLeaveBound);
94
+ this.el.removeEventListener('focus', this._handleFocusBound, true);
95
+ this.el.removeEventListener('blur', this._handleBlurBound, true);
96
+ }
97
+
98
+ open(isManual) {
99
+ if (this.isOpen) {
100
+ return;
101
+ }
102
+ isManual = isManual === undefined ? true : undefined; // Default value true
103
+ this.isOpen = true;
104
+ // Update tooltip content with HTML attribute options
105
+ this.options = $.extend({}, this.options, this._getAttributeOptions());
106
+ this._updateTooltipContent();
107
+ this._setEnterDelayTimeout(isManual);
108
+ }
109
+
110
+ close() {
111
+ if (!this.isOpen) {
112
+ return;
113
+ }
114
+
115
+ this.isHovered = false;
116
+ this.isFocused = false;
117
+ this.isOpen = false;
118
+ this._setExitDelayTimeout();
119
+ }
120
+
121
+ /**
122
+ * Create timeout which delays when the tooltip closes
123
+ */
124
+ _setExitDelayTimeout() {
125
+ clearTimeout(this._exitDelayTimeout);
126
+
127
+ this._exitDelayTimeout = setTimeout(() => {
128
+ if (this.isHovered || this.isFocused) {
129
+ return;
130
+ }
131
+
132
+ this._animateOut();
133
+ }, this.options.exitDelay);
134
+ }
135
+
136
+ /**
137
+ * Create timeout which delays when the toast closes
138
+ */
139
+ _setEnterDelayTimeout(isManual) {
140
+ clearTimeout(this._enterDelayTimeout);
141
+
142
+ this._enterDelayTimeout = setTimeout(() => {
143
+ if (!this.isHovered && !this.isFocused && !isManual) {
144
+ return;
145
+ }
146
+
147
+ this._animateIn();
148
+ }, this.options.enterDelay);
149
+ }
150
+
151
+ _positionTooltip() {
152
+ let origin = this.el,
153
+ tooltip = this.tooltipEl,
154
+ originHeight = origin.offsetHeight,
155
+ originWidth = origin.offsetWidth,
156
+ tooltipHeight = tooltip.offsetHeight,
157
+ tooltipWidth = tooltip.offsetWidth,
158
+ newCoordinates,
159
+ margin = this.options.margin,
160
+ targetTop,
161
+ targetLeft;
162
+
163
+ (this.xMovement = 0), (this.yMovement = 0);
164
+
165
+ targetTop = origin.getBoundingClientRect().top + M.getDocumentScrollTop();
166
+ targetLeft = origin.getBoundingClientRect().left + M.getDocumentScrollLeft();
167
+
168
+ if (this.options.position === 'top') {
169
+ targetTop += -tooltipHeight - margin;
170
+ targetLeft += originWidth / 2 - tooltipWidth / 2;
171
+ this.yMovement = -this.options.transitionMovement;
172
+ } else if (this.options.position === 'right') {
173
+ targetTop += originHeight / 2 - tooltipHeight / 2;
174
+ targetLeft += originWidth + margin;
175
+ this.xMovement = this.options.transitionMovement;
176
+ } else if (this.options.position === 'left') {
177
+ targetTop += originHeight / 2 - tooltipHeight / 2;
178
+ targetLeft += -tooltipWidth - margin;
179
+ this.xMovement = -this.options.transitionMovement;
180
+ } else {
181
+ targetTop += originHeight + margin;
182
+ targetLeft += originWidth / 2 - tooltipWidth / 2;
183
+ this.yMovement = this.options.transitionMovement;
184
+ }
185
+
186
+ newCoordinates = this._repositionWithinScreen(
187
+ targetLeft,
188
+ targetTop,
189
+ tooltipWidth,
190
+ tooltipHeight
191
+ );
192
+ $(tooltip).css({
193
+ top: newCoordinates.y + 'px',
194
+ left: newCoordinates.x + 'px'
195
+ });
196
+ }
197
+
198
+ _repositionWithinScreen(x, y, width, height) {
199
+ let scrollLeft = M.getDocumentScrollLeft();
200
+ let scrollTop = M.getDocumentScrollTop();
201
+ let newX = x - scrollLeft;
202
+ let newY = y - scrollTop;
203
+
204
+ let bounding = {
205
+ left: newX,
206
+ top: newY,
207
+ width: width,
208
+ height: height
209
+ };
210
+
211
+ let offset = this.options.margin + this.options.transitionMovement;
212
+ let edges = M.checkWithinContainer(document.body, bounding, offset);
213
+
214
+ if (edges.left) {
215
+ newX = offset;
216
+ } else if (edges.right) {
217
+ newX -= newX + width - window.innerWidth;
218
+ }
219
+
220
+ if (edges.top) {
221
+ newY = offset;
222
+ } else if (edges.bottom) {
223
+ newY -= newY + height - window.innerHeight;
224
+ }
225
+
226
+ return {
227
+ x: newX + scrollLeft,
228
+ y: newY + scrollTop
229
+ };
230
+ }
231
+
232
+ _animateIn() {
233
+ this._positionTooltip();
234
+ this.tooltipEl.style.visibility = 'visible';
235
+ anim.remove(this.tooltipEl);
236
+ anim({
237
+ targets: this.tooltipEl,
238
+ opacity: 1,
239
+ translateX: this.xMovement,
240
+ translateY: this.yMovement,
241
+ duration: this.options.inDuration,
242
+ easing: 'easeOutCubic'
243
+ });
244
+ }
245
+
246
+ _animateOut() {
247
+ anim.remove(this.tooltipEl);
248
+ anim({
249
+ targets: this.tooltipEl,
250
+ opacity: 0,
251
+ translateX: 0,
252
+ translateY: 0,
253
+ duration: this.options.outDuration,
254
+ easing: 'easeOutCubic'
255
+ });
256
+ }
257
+
258
+ _handleMouseEnter() {
259
+ this.isHovered = true;
260
+ this.isFocused = false; // Allows close of tooltip when opened by focus.
261
+ this.open(false);
262
+ }
263
+
264
+ _handleMouseLeave() {
265
+ this.isHovered = false;
266
+ this.isFocused = false; // Allows close of tooltip when opened by focus.
267
+ this.close();
268
+ }
269
+
270
+ _handleFocus() {
271
+ if (M.tabPressed) {
272
+ this.isFocused = true;
273
+ this.open(false);
274
+ }
275
+ }
276
+
277
+ _handleBlur() {
278
+ this.isFocused = false;
279
+ this.close();
280
+ }
281
+
282
+ _getAttributeOptions() {
283
+ let attributeOptions = {};
284
+ let tooltipTextOption = this.el.getAttribute('data-tooltip');
285
+ let positionOption = this.el.getAttribute('data-position');
286
+
287
+ if (tooltipTextOption) {
288
+ attributeOptions.html = tooltipTextOption;
289
+ }
290
+
291
+ if (positionOption) {
292
+ attributeOptions.position = positionOption;
293
+ }
294
+ return attributeOptions;
295
+ }
296
+ }
297
+
298
+ M.Tooltip = Tooltip;
299
+
300
+ if (M.jQueryLoaded) {
301
+ M.initializeJqueryWrapper(Tooltip, 'tooltip', 'M_Tooltip');
302
+ }
303
+ })(cash, M.anime);