j1-template 2020.0.8 → 2020.0.13
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/_includes/themes/j1/blocks/ads/ad.html +64 -0
- data/_includes/themes/j1/blocks/footer/boxes/links_box.proc +1 -1
- data/_includes/themes/j1/layouts/content_generator_blog_archive.html +3 -2
- data/_includes/themes/j1/layouts/content_generator_collection.html +3 -2
- data/_includes/themes/j1/layouts/content_generator_page.html +3 -2
- data/_includes/themes/j1/layouts/content_generator_post.html +12 -12
- data/_includes/themes/j1/layouts/layout_metadata_generator.html +134 -4
- data/_includes/themes/j1/modules/connectors/ad/custom-provider.html +6 -9
- data/_includes/themes/j1/modules/connectors/ad/google-adsense.html +9 -6
- data/_includes/themes/j1/modules/connectors/ads +3 -6
- data/_includes/themes/j1/modules/navigator/generator.html +6 -7
- data/_includes/themes/j1/modules/navigator/procedures/topsearch.proc +10 -5
- data/_includes/themes/j1/procedures/layouts/module_writer.proc +1 -1
- data/_includes/themes/j1/procedures/posts/collate_timeline.proc +7 -7
- data/_layouts/default.html +18 -13
- data/assets/data/authclient.html +18 -8
- data/assets/data/banner.html +23 -23
- data/assets/data/carousel.json +30 -21
- data/assets/data/cookie_consent.html +79 -51
- data/assets/data/footer.html +14 -5
- data/assets/data/galleries.json +90 -81
- data/assets/data/gallery_customizer.html +19 -10
- data/assets/data/mdi_icons.json +55 -1
- data/assets/data/menu.html +14 -7
- data/assets/data/mmenu.html +47 -94
- data/assets/data/mmenu_sidebar.html +40 -44
- data/assets/data/mmenu_toc.html +19 -3
- data/assets/data/panel.html +30 -23
- data/assets/data/quicklinks.html +13 -3
- data/assets/data/{search.yml → search.json} +44 -14
- data/assets/data/ssm.html +20 -9
- data/assets/data/themes.json +17 -6
- data/assets/data/twa_v1.json +7034 -6978
- data/assets/themes/j1/adapter/js/algolia.js +34 -17
- data/assets/themes/j1/adapter/js/attic.js +66 -46
- data/assets/themes/j1/adapter/js/carousel.js +43 -22
- data/assets/themes/j1/adapter/js/clipboard.js +230 -0
- data/assets/themes/j1/adapter/js/cookie_consent.js +21 -4
- data/assets/themes/j1/adapter/js/framer.js +18 -3
- data/assets/themes/j1/adapter/js/gallery_customizer.js +27 -10
- data/assets/themes/j1/adapter/js/j1.js +342 -757
- data/assets/themes/j1/adapter/js/{justified_gallery.js → jf_gallery.js} +64 -38
- data/assets/themes/j1/adapter/js/lightbox.js +20 -3
- data/assets/themes/j1/adapter/js/logger.js +23 -6
- data/assets/themes/j1/adapter/js/mdb.js +167 -0
- data/assets/themes/j1/adapter/js/mmenu.js +33 -30
- data/assets/themes/j1/adapter/js/navigator.js +126 -140
- data/assets/themes/j1/adapter/js/searcher.js +22 -4
- data/assets/themes/j1/adapter/js/ssm.js +84 -63
- data/assets/themes/j1/adapter/js/themer.js +35 -53
- data/assets/themes/j1/adapter/js/toccer.js +29 -14
- data/assets/themes/j1/core/css/theme_extensions.css +120 -1230
- data/assets/themes/j1/core/css/theme_extensions.min.css +1 -1
- data/assets/themes/j1/core/css/uno.css +256 -1288
- data/assets/themes/j1/core/css/uno.min.css +1 -1
- data/assets/themes/j1/core/css/vendor.css +7 -57
- data/assets/themes/j1/core/css/vendor.min.css +2 -2
- data/assets/themes/j1/core/js/template.js +16 -86
- data/assets/themes/j1/core/js/template.js.map +1 -1
- data/assets/themes/j1/core/js/template.min.js +1 -1
- data/assets/themes/j1/extensions/bsDatepicker/css/datepicker.css +203 -0
- data/assets/themes/j1/extensions/bsDatepicker/css/theme/uno.css +235 -0
- data/assets/themes/j1/extensions/bsDatepicker/js/datepicker.js +509 -0
- data/assets/themes/j1/extensions/bsDatepicker/less/datepicker.less +122 -0
- data/assets/themes/j1/extensions/bsThemeSwitcher/js/switcher.js +425 -0
- data/assets/themes/j1/extensions/bsThemeSwitcher/js/switcher.min.js +20 -0
- data/assets/themes/j1/extensions/clipboard/LICENSE +20 -0
- data/assets/themes/j1/extensions/clipboard/css/theme/uno.css +52 -0
- data/assets/themes/j1/extensions/clipboard/css/theme/uno.min.css +52 -0
- data/assets/themes/j1/extensions/clipboard/js/clipboard.js +975 -0
- data/assets/themes/j1/extensions/clipboard/js/clipboard.min.js +7 -0
- data/assets/themes/j1/extensions/{iconify → iconifyAPI}/js/iconify.min.js +0 -0
- data/assets/themes/j1/extensions/iframeResizer/LICENSE +21 -0
- data/assets/themes/j1/extensions/iframeResizer/examples/frame.absolute.html +127 -0
- data/assets/themes/j1/extensions/iframeResizer/examples/frame.content.html +157 -0
- data/assets/themes/j1/extensions/iframeResizer/examples/frame.hover.html +68 -0
- data/assets/themes/j1/extensions/iframeResizer/examples/frame.nested.html +100 -0
- data/assets/themes/j1/extensions/iframeResizer/examples/frame.textarea.html +45 -0
- data/assets/themes/j1/extensions/iframeResizer/examples/frame.tolerance.html +113 -0
- data/assets/themes/j1/extensions/iframeResizer/examples/index.html +83 -0
- data/assets/themes/j1/extensions/iframeResizer/examples/two.html +88 -0
- data/assets/themes/j1/extensions/iframeResizer/js/client/iframeResizer.contentWindow.js +1288 -0
- data/assets/themes/j1/extensions/iframeResizer/js/client/iframeResizer.contentWindow.map +1 -0
- data/assets/themes/j1/extensions/iframeResizer/js/client/iframeResizer.contentWindow.min.js +10 -0
- data/assets/themes/j1/extensions/iframeResizer/js/iframeResizer.js +1390 -0
- data/assets/themes/j1/extensions/iframeResizer/js/iframeResizer.map +1 -0
- data/assets/themes/j1/extensions/iframeResizer/js/iframeResizer.min.js +9 -0
- data/assets/themes/j1/extensions/jqMouseWheel/README.md +76 -0
- data/assets/themes/j1/extensions/jqMouseWheel/js/jquery.mousewheel.js +221 -0
- data/assets/themes/j1/extensions/jqMouseWheel/js/jquery.mousewheel.min.js +9 -0
- data/assets/themes/j1/extensions/{justified_gallery → justifiedGallery}/LICENSE +0 -0
- data/assets/themes/j1/extensions/{justified_gallery → justifiedGallery}/README.md +0 -0
- data/assets/themes/j1/extensions/{justified_gallery → justifiedGallery}/_versions/v3.7.0/css/justifiedGallery.css +0 -0
- data/assets/themes/j1/extensions/{justified_gallery → justifiedGallery}/_versions/v3.7.0/css/justifiedGallery.min.css +0 -0
- data/assets/themes/j1/extensions/{justified_gallery → justifiedGallery}/_versions/v3.7.0/css/theme/uno.css +0 -0
- data/assets/themes/j1/extensions/{justified_gallery → justifiedGallery}/_versions/v3.7.0/js/justifiedGallery.3.7.0.js +0 -0
- data/assets/themes/j1/extensions/{justified_gallery → justifiedGallery}/_versions/v3.7.0/js/justifiedGallery.js +0 -0
- data/assets/themes/j1/extensions/{justified_gallery → justifiedGallery}/_versions/v3.7.0/js/justifiedGallery.min.js +0 -0
- data/assets/themes/j1/extensions/{justified_gallery → justifiedGallery}/_versions/v3.7.0/less/.csslintrc +0 -0
- data/assets/themes/j1/extensions/{justified_gallery → justifiedGallery}/_versions/v3.7.0/less/justifiedGallery.less +0 -0
- data/assets/themes/j1/extensions/{justified_gallery → justifiedGallery}/_versions/v4.0.0/css/justifiedGallery.css +0 -0
- data/assets/themes/j1/extensions/{justified_gallery → justifiedGallery}/_versions/v4.0.0/css/justifiedGallery.min.css +0 -0
- data/assets/themes/j1/extensions/{justified_gallery → justifiedGallery}/_versions/v4.0.0/css/theme/uno.css +0 -0
- data/assets/themes/j1/extensions/{justified_gallery → justifiedGallery}/_versions/v4.0.0/js/jquery.justifiedGallery.js +0 -0
- data/assets/themes/j1/extensions/{justified_gallery → justifiedGallery}/_versions/v4.0.0/js/jquery.justifiedGallery.min.js +0 -0
- data/assets/themes/j1/extensions/{justified_gallery → justifiedGallery}/css/justifiedGallery.css +0 -0
- data/assets/themes/j1/extensions/{justified_gallery → justifiedGallery}/css/justifiedGallery.min.css +0 -0
- data/assets/themes/j1/extensions/{justified_gallery → justifiedGallery}/css/theme/uno.css +0 -0
- data/assets/themes/j1/extensions/{justified_gallery → justifiedGallery}/css/theme/uno.min.css +0 -0
- data/assets/themes/j1/extensions/{justified_gallery → justifiedGallery}/js/justifiedGallery.js +0 -0
- data/assets/themes/j1/extensions/{justified_gallery → justifiedGallery}/js/justifiedGallery.min.js +0 -0
- data/assets/themes/j1/extensions/{light_gallery → lightGallery}/css/core/lg-fb-comment-box.css +0 -0
- data/assets/themes/j1/extensions/{light_gallery → lightGallery}/css/core/lg-fb-comment-box.min.css +0 -0
- data/assets/themes/j1/extensions/{light_gallery → lightGallery}/css/core/lg-transitions.css +0 -0
- data/assets/themes/j1/extensions/{light_gallery → lightGallery}/css/core/lg-transitions.min.css +0 -0
- data/assets/themes/j1/extensions/{light_gallery → lightGallery}/css/core/lightgallery.css +0 -0
- data/assets/themes/j1/extensions/{light_gallery → lightGallery}/css/core/lightgallery.min.css +0 -0
- data/assets/themes/j1/extensions/{light_gallery → lightGallery}/css/fonts/lg.eot +0 -0
- data/assets/themes/j1/extensions/{light_gallery → lightGallery}/css/fonts/lg.svg +0 -0
- data/assets/themes/j1/extensions/{light_gallery → lightGallery}/css/fonts/lg.ttf +0 -0
- data/assets/themes/j1/extensions/{light_gallery → lightGallery}/css/fonts/lg.woff +0 -0
- data/assets/themes/j1/extensions/{light_gallery → lightGallery}/css/img/loading.gif +0 -0
- data/assets/themes/j1/extensions/{light_gallery → lightGallery}/css/img/video-play.png +0 -0
- data/assets/themes/j1/extensions/{light_gallery → lightGallery}/css/img/vimeo-play.png +0 -0
- data/assets/themes/j1/extensions/{light_gallery → lightGallery}/css/img/youtube-play.png +0 -0
- data/assets/themes/j1/extensions/{light_gallery → lightGallery}/css/themes/icons/animation-w.png +0 -0
- data/assets/themes/j1/extensions/{light_gallery → lightGallery}/css/themes/icons/customize-w.png +0 -0
- data/assets/themes/j1/extensions/{light_gallery → lightGallery}/css/themes/icons/dynamic-w.png +0 -0
- data/assets/themes/j1/extensions/{light_gallery → lightGallery}/css/themes/icons/facebook-icon.svg +0 -0
- data/assets/themes/j1/extensions/{light_gallery → lightGallery}/css/themes/icons/googleplus-icon.svg +0 -0
- data/assets/themes/j1/extensions/{light_gallery → lightGallery}/css/themes/icons/html5-w.png +0 -0
- data/assets/themes/j1/extensions/{light_gallery → lightGallery}/css/themes/icons/linked-in.png +0 -0
- data/assets/themes/j1/extensions/{light_gallery → lightGallery}/css/themes/icons/module-w.png +0 -0
- data/assets/themes/j1/extensions/{light_gallery → lightGallery}/css/themes/icons/play-button.png +0 -0
- data/assets/themes/j1/extensions/{light_gallery → lightGallery}/css/themes/icons/responsive-w.png +0 -0
- data/assets/themes/j1/extensions/{light_gallery → lightGallery}/css/themes/icons/thumb-w.png +0 -0
- data/assets/themes/j1/extensions/{light_gallery → lightGallery}/css/themes/icons/touch-w.png +0 -0
- data/assets/themes/j1/extensions/{light_gallery → lightGallery}/css/themes/icons/twitter-icon.svg +0 -0
- data/assets/themes/j1/extensions/{light_gallery → lightGallery}/css/themes/icons/twitter.png +0 -0
- data/assets/themes/j1/extensions/{light_gallery → lightGallery}/css/themes/icons/video1-w.png +0 -0
- data/assets/themes/j1/extensions/{light_gallery → lightGallery}/css/themes/icons/zoom-w.png +0 -0
- data/assets/themes/j1/extensions/{light_gallery → lightGallery}/css/themes/icons/zoom.png +0 -0
- data/assets/themes/j1/extensions/{light_gallery → lightGallery}/css/themes/uno.css +1 -1
- data/assets/themes/j1/extensions/{light_gallery → lightGallery}/css/themes/uno.min.css +1 -1
- data/assets/themes/j1/extensions/{light_gallery → lightGallery}/js/core/lightgallery.js +0 -0
- data/assets/themes/j1/extensions/{light_gallery → lightGallery}/js/core/lightgallery.min.js +0 -0
- data/assets/themes/j1/extensions/{light_gallery → lightGallery}/js/modules/j1/j1-video.js +0 -0
- data/assets/themes/j1/extensions/{light_gallery → lightGallery}/js/modules/j1/j1-video.min.js +0 -0
- data/assets/themes/j1/extensions/{light_gallery → lightGallery}/js/modules/lg-autoplay.js +0 -0
- data/assets/themes/j1/extensions/{light_gallery → lightGallery}/js/modules/lg-autoplay.min.js +0 -0
- data/assets/themes/j1/extensions/{light_gallery → lightGallery}/js/modules/lg-fullscreen.js +0 -0
- data/assets/themes/j1/extensions/{light_gallery → lightGallery}/js/modules/lg-fullscreen.min.js +0 -0
- data/assets/themes/j1/extensions/{light_gallery → lightGallery}/js/modules/lg-hash.js +0 -0
- data/assets/themes/j1/extensions/{light_gallery → lightGallery}/js/modules/lg-hash.min.js +0 -0
- data/assets/themes/j1/extensions/{light_gallery → lightGallery}/js/modules/lg-pager.js +0 -0
- data/assets/themes/j1/extensions/{light_gallery → lightGallery}/js/modules/lg-pager.min.js +0 -0
- data/assets/themes/j1/extensions/{light_gallery → lightGallery}/js/modules/lg-share.js +0 -0
- data/assets/themes/j1/extensions/{light_gallery → lightGallery}/js/modules/lg-share.min.js +0 -0
- data/assets/themes/j1/extensions/{light_gallery → lightGallery}/js/modules/lg-thumbnail.js +0 -0
- data/assets/themes/j1/extensions/{light_gallery → lightGallery}/js/modules/lg-thumbnail.min.js +0 -0
- data/assets/themes/j1/extensions/{light_gallery → lightGallery}/js/modules/lg-video.js +0 -0
- data/assets/themes/j1/extensions/{light_gallery → lightGallery}/js/modules/lg-video.min.js +0 -0
- data/assets/themes/j1/extensions/{light_gallery → lightGallery}/js/modules/lg-zoom.js +0 -0
- data/assets/themes/j1/extensions/{light_gallery → lightGallery}/js/modules/lg-zoom.min.js +0 -0
- data/assets/themes/j1/extensions/lightbox/LICENSE +22 -0
- data/assets/themes/j1/extensions/lightbox/css/lightbox.css +224 -0
- data/assets/themes/j1/extensions/lightbox/css/lightbox.min.css +21 -0
- data/assets/themes/j1/extensions/lightbox/css/theme/uno.css +25 -0
- data/assets/themes/j1/extensions/lightbox/css/theme/uno.min.css +26 -0
- data/{lib/starter_web/assets/images/modules/lightbox → assets/themes/j1/extensions/lightbox/images}/close.png +0 -0
- data/{lib/starter_web/assets/images/modules/lightbox → assets/themes/j1/extensions/lightbox/images}/loading.gif +0 -0
- data/{lib/starter_web/assets/images/modules/lightbox → assets/themes/j1/extensions/lightbox/images}/next.png +0 -0
- data/{lib/starter_web/assets/images/modules/lightbox → assets/themes/j1/extensions/lightbox/images}/prev.png +0 -0
- data/assets/themes/j1/extensions/lightbox/js/lightbox.js +583 -0
- data/assets/themes/j1/extensions/lightbox/js/lightbox.min.js +35 -0
- data/assets/themes/j1/extensions/mmenuLight/css/mmenu.css +392 -0
- data/assets/themes/j1/extensions/mmenuLight/css/mmenu.min.css +393 -0
- data/assets/themes/j1/extensions/mmenuLight/css/theme/uno.css +170 -0
- data/assets/themes/j1/extensions/mmenuLight/css/theme/uno.min.css +169 -0
- data/assets/themes/j1/extensions/mmenuLight/js/mmenu.js +30 -0
- data/assets/themes/j1/extensions/noUISlider/LICENSE +13 -0
- data/assets/themes/j1/extensions/noUISlider/css/nouislider.css +260 -0
- data/assets/themes/j1/extensions/noUISlider/css/nouislider.min.css +1 -0
- data/assets/themes/j1/extensions/noUISlider/js/nouislider.js +2312 -0
- data/assets/themes/j1/extensions/noUISlider/js/nouislider.min.js +3 -0
- data/assets/themes/j1/extensions/twemoji/js/LICENSE +21 -0
- data/assets/themes/j1/extensions/twemoji/js/picker/LICENSE +21 -0
- data/assets/themes/j1/extensions/twemoji/js/picker/twemoji-picker.js +21 -0
- data/assets/themes/j1/extensions/twemoji/js/picker/twemoji-picker.min.js +21 -0
- data/assets/themes/j1/extensions/twemoji/js/twemoji.js +590 -0
- data/assets/themes/j1/extensions/twemoji/js/twemoji.min.js +25 -0
- data/lib/j1/version.rb +3 -3
- data/lib/starter_web/Gemfile +7 -1
- data/lib/starter_web/_config.yml +9 -8
- data/lib/starter_web/_data/_defaults/resources.yml +13 -13
- data/lib/starter_web/_data/blocks/banner.yml +21 -29
- data/lib/starter_web/_data/blocks/footer.yml +10 -3
- data/lib/starter_web/_data/blocks/panel.yml +13 -13
- data/lib/starter_web/_data/layouts/default.yml +10 -0
- data/lib/starter_web/_data/layouts/home.yml +7 -7
- data/lib/starter_web/_data/layouts/page.yml +15 -16
- data/lib/starter_web/_data/modules/advertising.yml +48 -0
- data/lib/starter_web/_data/modules/attics.yml +2 -38
- data/lib/starter_web/_data/modules/cookie_consent.yml +3 -95
- data/lib/starter_web/_data/modules/defaults/attics.yml +16 -15
- data/lib/starter_web/_data/modules/defaults/cookie_consent.yml +75 -12
- data/lib/starter_web/_data/modules/defaults/jekyll_search.yml +9 -9
- data/lib/starter_web/_data/modules/defaults/navigator.yml +56 -21
- data/lib/starter_web/_data/modules/defaults/ssm.yml +3 -3
- data/lib/starter_web/_data/modules/defaults/toccer.yml +4 -8
- data/lib/starter_web/_data/modules/jekyll_search.yml +3 -21
- data/lib/starter_web/_data/modules/navigator.yml +1 -1
- data/lib/starter_web/_data/modules/navigator_menu.yml +4 -0
- data/lib/starter_web/_data/modules/ssm.yml +9 -0
- data/lib/starter_web/_data/modules/themer.yml +2 -3
- data/lib/starter_web/_data/modules/toccer.yml +6 -11
- data/lib/starter_web/_data/resources.yml +240 -112
- data/lib/starter_web/_data/template_settings.yml +117 -6
- data/lib/starter_web/_plugins/asciidoctor-extensions/fab-icon-inline.rb +1 -1
- data/lib/starter_web/_plugins/asciidoctor-extensions/fas-icon-inline.rb +2 -2
- data/lib/starter_web/_plugins/asciidoctor-extensions/iconify-icon-inline.rb +2 -2
- data/lib/starter_web/_plugins/asciidoctor-extensions/mdi-icon-inline.rb +2 -2
- data/lib/starter_web/_plugins/asciidoctor-extensions/twitter-emoji-inline.rb +2 -2
- data/lib/starter_web/_plugins/minifyJS.rb +54 -0
- data/lib/starter_web/_plugins/{uglify.rb → minifyJSON.rb} +15 -9
- data/lib/starter_web/assets/images/modules/attics/admin-dashboard-bootstrap-1280x600.jpg +0 -0
- data/lib/starter_web/assets/images/modules/attics/alex-holyoake-1920x1280.jpg +0 -0
- data/lib/starter_web/assets/images/modules/attics/anaya-katlego-1920x1280.jpg +0 -0
- data/lib/starter_web/assets/images/modules/attics/antonella-lombardi-1920x1280.jpg +0 -0
- data/lib/starter_web/assets/images/modules/attics/antonino-visalli-1920x1280.jpg +0 -0
- data/lib/starter_web/assets/images/modules/attics/banner/library-1920x800-bw.jpg +0 -0
- data/lib/starter_web/assets/images/modules/attics/banner/signpost-1920x800-bw.jpg +0 -0
- data/lib/starter_web/assets/images/modules/attics/banner/water-journal-1280x600.jpg +0 -0
- data/lib/starter_web/assets/images/modules/attics/banner/write-1280x600-bw.jpg +0 -0
- data/lib/starter_web/assets/images/modules/attics/brandon-mowinkel-1920x1280.jpg +0 -0
- data/lib/starter_web/assets/images/modules/attics/building-blocks-1920x1280-bw.jpg +0 -0
- data/lib/starter_web/assets/images/modules/attics/cookies-1920x1200-bw.jpg +0 -0
- data/lib/starter_web/assets/images/modules/attics/daniel-jensen-1920x1280.jpg +0 -0
- data/lib/starter_web/assets/images/modules/attics/giammarco-boscaro-1920x1280.jpg +0 -0
- data/lib/starter_web/assets/images/modules/attics/go-up-1920x1280-bw.jpg +0 -0
- data/lib/starter_web/assets/images/modules/attics/ian-schneider-1920x1280.jpg +0 -0
- data/lib/starter_web/assets/images/modules/attics/ideas-start-here-1920x1280-bw.jpg +0 -0
- data/lib/starter_web/assets/images/modules/attics/jason-rosewell-1920x1280.jpg +0 -0
- data/lib/starter_web/assets/images/modules/attics/jessica-ruscello-1920x1280.jpg +0 -0
- data/lib/starter_web/assets/images/modules/attics/lianhao-1920x1280.jpg +0 -0
- data/lib/starter_web/assets/images/modules/attics/library-1920x1280-bw.jpg +0 -0
- data/lib/starter_web/assets/images/modules/attics/matthaeus-1920x1280.jpg +0 -0
- data/lib/starter_web/assets/images/modules/attics/nousnou-iwasaki-1920x1280.jpg +0 -0
- data/lib/starter_web/assets/images/modules/attics/premium-1920x1280-bw.jpg +0 -0
- data/lib/starter_web/assets/images/modules/attics/robert-v-ruggiero-1920x1280.jpg +0 -0
- data/lib/starter_web/assets/images/modules/attics/romain-vignes-1920x1280.jpg +0 -0
- data/lib/starter_web/assets/images/modules/attics/runner-1920x1200-bw.jpg +0 -0
- data/lib/starter_web/assets/images/modules/attics/spider-web-1920x1200-bw.jpg +0 -0
- data/lib/starter_web/assets/images/modules/attics/the-place-1920x1280-bw.jpg +0 -0
- data/lib/starter_web/assets/images/modules/attics/welcome-1920x1280-bw.jpg +0 -0
- data/lib/starter_web/assets/images/modules/carousel/cats/cat-1.jpg +0 -0
- data/lib/starter_web/assets/images/modules/carousel/mega_cities/andreas-brucker_b.jpg +0 -0
- data/lib/starter_web/assets/images/modules/carousel/mega_cities/denys-nevozhai-1_b.jpg +0 -0
- data/lib/starter_web/assets/images/modules/carousel/mega_cities/denys-nevozhai-2_b.jpg +0 -0
- data/lib/starter_web/assets/images/modules/carousel/mega_cities/luca-bravo_b.jpg +0 -0
- data/lib/starter_web/assets/images/modules/carousel/mega_cities/thomas-tucker_b.jpg +0 -0
- data/lib/starter_web/assets/images/modules/gallery/mega_cities/banter-snaps_b.jpg +0 -0
- data/lib/starter_web/assets/images/modules/gallery/mega_cities/denys-nevozhai-1_b.jpg +0 -0
- data/lib/starter_web/assets/images/modules/gallery/mega_cities/denys-nevozhai-2-bw.jpg +0 -0
- data/lib/starter_web/assets/images/modules/gallery/mega_cities/denys-nevozhai-2_b.jpg +0 -0
- data/lib/starter_web/assets/images/modules/gallery/mega_cities/emmad-mazhari_b.jpg +0 -0
- data/lib/starter_web/assets/images/modules/gallery/mega_cities/ethan-brooke_b.jpg +0 -0
- data/lib/starter_web/assets/images/modules/gallery/mega_cities/federico-rizzarelli_b.jpg +0 -0
- data/lib/starter_web/assets/images/modules/gallery/mega_cities/gints-gailis_b.jpg +0 -0
- data/lib/starter_web/assets/images/modules/gallery/mega_cities/johan-mouchet_b.jpg +0 -0
- data/lib/starter_web/assets/images/modules/gallery/mega_cities/luca-bravo_b.jpg +0 -0
- data/lib/starter_web/assets/images/modules/gallery/mega_cities/oskars-sylwan_b.jpg +0 -0
- data/lib/starter_web/assets/images/modules/gallery/mega_cities/steven-diaz_b.jpg +0 -0
- data/lib/starter_web/assets/images/modules/gallery/mega_cities/thomas-tucker-bw.jpg +0 -0
- data/lib/starter_web/assets/images/modules/gallery/mega_cities/thomas-tucker_b.jpg +0 -0
- data/lib/starter_web/index.html +9 -8
- data/lib/starter_web/package.json +1 -1
- data/lib/starter_web/pages/public/clear_button.adoc +121 -0
- data/lib/starter_web/pages/public/learn/examples/floating_ad.adoc +221 -0
- data/lib/starter_web/pages/public/learn/{floating_sidebar.adoc → examples/floating_div.adoc} +60 -50
- data/lib/starter_web/pages/public/learn/kickstarter/web_in_a_day/000_includes/parts.asciidoc +1 -1
- data/lib/starter_web/pages/public/learn/kickstarter/web_in_a_day/100_meet_and_greet_jekyll.adoc +9 -4
- data/lib/starter_web/pages/public/learn/roundtrip/000_bs_tour_api.adoc +2 -2
- data/lib/starter_web/pages/public/learn/roundtrip/000_includes/documents/410_table_3_column.asciidoc +1 -1
- data/lib/starter_web/pages/public/learn/roundtrip/000_includes/documents/419_advanced_modals_html.asciidoc +5 -5
- data/lib/starter_web/pages/public/learn/roundtrip/100_present_images.adoc +2 -2
- data/lib/starter_web/pages/public/learn/roundtrip/200_typography.adoc +4 -3
- data/lib/starter_web/pages/public/learn/roundtrip/300_icon_fonts.adoc +35 -44
- data/lib/starter_web/pages/public/learn/roundtrip/400_asciidoc_extensions.adoc +1 -1
- data/lib/starter_web/pages/public/learn/roundtrip/420_responsive_tables_extensions.adoc +39 -39
- data/lib/starter_web/pages/public/learn/vtutorials/000_includes/documents/410_table_3_column.asciidoc +1 -1
- data/lib/starter_web/pages/public/learn/whats_up.adoc +1 -0
- data/lib/starter_web/pages/public/panels/intro_panel/panel.adoc +54 -48
- data/lib/starter_web/pages/public/previewer/000_includes/tables/mdi_icons/100_absolute_sizes.asciidoc +1 -1
- data/lib/starter_web/pages/public/previewer/000_includes/tables/mdi_icons/110_bs_grid_sizes.asciidoc +1 -1
- data/lib/starter_web/pages/public/previewer/000_includes/tables/mdi_icons/120_relative_sizes.asciidoc +1 -41
- data/lib/starter_web/pages/public/previewer/000_includes/tables/mdi_icons/200_rotate.asciidoc +1 -1
- data/lib/starter_web/pages/public/previewer/000_includes/tables/mdi_icons/300_flip.asciidoc +1 -1
- data/lib/starter_web/pages/public/previewer/000_includes/tables/mdi_icons/400_spin_pulsed.asciidoc +1 -1
- data/lib/starter_web/pages/public/previewer/000_includes/tables/mdi_icons/500_bw_color_palette.asciidoc +1 -1
- data/lib/starter_web/pages/public/previewer/000_includes/tables/mdi_icons/510_bs_color_palette.asciidoc +1 -1
- data/lib/starter_web/pages/public/previewer/000_includes/tables/mdi_icons/600_md_color_palette.asciidoc +1 -1
- data/lib/starter_web/pages/public/previewer/000_includes/tables/mdi_icons/601_md_color_palette_indigo.asciidoc +1 -1
- data/lib/starter_web/pages/public/previewer/000_includes/tables/mdi_icons/602_md_color_palette_pink.asciidoc +1 -1
- data/lib/starter_web/pages/public/previewer/000_includes/tables/twitter_emoji/100_bs_sizes.asciidoc +1 -1
- data/lib/starter_web/pages/public/previewer/000_includes/tables/twitter_emoji/100_relative_sizes.asciidoc +1 -1
- data/lib/starter_web/pages/public/previewer/000_includes/tables/twitter_emoji/200_rotate.asciidoc +1 -1
- data/lib/starter_web/pages/public/previewer/000_includes/tables/twitter_emoji/300_flip.asciidoc +1 -1
- data/lib/starter_web/pages/public/previewer/000_includes/tables/twitter_emoji/400_spin_pulsed.asciidoc +1 -1
- data/lib/starter_web/pages/public/previewer/bootstrap_theme.adoc +672 -863
- data/lib/starter_web/pages/public/previewer/iframer.adoc +15 -14
- data/lib/starter_web/pages/public/previewer/justified_gallery.html +1 -1
- data/lib/starter_web/pages/public/previewer/mdb_preview/000_includes/attributes.asciidoc +69 -0
- data/lib/starter_web/pages/public/previewer/mdb_preview/000_includes/documents/100_buttons.asciidoc +170 -0
- data/lib/starter_web/pages/public/previewer/mdb_preview/mdb_previewer.adoc +52 -0
- data/lib/starter_web/pages/public/previewer/mdi_icons_preview.adoc +1 -1
- data/lib/starter_web/pages/public/previewer/twitter_emoji_preview.adoc +2 -2
- data/lib/starter_web/utilsrv/_defaults/package.json +1 -1
- data/lib/starter_web/utilsrv/package.json +1 -1
- metadata +148 -105
- data/assets/data/colors.json +0 -42
- data/assets/data/font_sizes.json +0 -42
- data/assets/data/messages.yml +0 -131
- data/assets/themes/j1/extensions/iframe_resizer/examples/frame.absolute.html +0 -86
- data/assets/themes/j1/extensions/iframe_resizer/examples/frame.content.html +0 -58
- data/assets/themes/j1/extensions/iframe_resizer/examples/frame.hover.html +0 -51
- data/assets/themes/j1/extensions/iframe_resizer/examples/frame.nested.html +0 -68
- data/assets/themes/j1/extensions/iframe_resizer/examples/frame.textarea.html +0 -46
- data/assets/themes/j1/extensions/iframe_resizer/examples/frame.tolerance.html +0 -79
- data/assets/themes/j1/extensions/iframe_resizer/examples/index.html +0 -70
- data/assets/themes/j1/extensions/iframe_resizer/examples/two.html +0 -71
- data/assets/themes/j1/extensions/iframe_resizer/js/client/iframeResizer.contentWindow.js +0 -1104
- data/assets/themes/j1/extensions/iframe_resizer/js/client/iframeResizer.contentWindow.map +0 -1
- data/assets/themes/j1/extensions/iframe_resizer/js/client/iframeResizer.contentWindow.min.js +0 -10
- data/assets/themes/j1/extensions/log4javascript/log4javascript.js +0 -5826
- data/assets/themes/j1/extensions/log4javascript/log4javascript.min.js +0 -266
- data/lib/starter_web/assets/images/modules/attics/admin-dashboard-bootstrap-1280x600.png +0 -0
- data/lib/starter_web/assets/images/modules/attics/mae-mu-Vf9gbsLZyf0-unsplash.jpg +0 -0
- data/lib/starter_web/assets/images/modules/attics/mae-mue-1920x1280-v.jpg +0 -0
- data/lib/starter_web/assets/images/modules/attics/mae-mue-1920x1280.jpg +0 -0
@@ -0,0 +1,45 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<meta charset="utf-8" />
|
5
|
+
<title>iFrame message passing test</title>
|
6
|
+
<meta name="description" content="iFrame message passing test" />
|
7
|
+
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
8
|
+
<style>
|
9
|
+
a {
|
10
|
+
float: right;
|
11
|
+
margin-left: 10px;
|
12
|
+
}
|
13
|
+
</style>
|
14
|
+
</head>
|
15
|
+
|
16
|
+
<body>
|
17
|
+
<b>iFrame TextArea Example</b>
|
18
|
+
<a href="frame.content.html">Back to page 1</a>
|
19
|
+
|
20
|
+
<p>
|
21
|
+
Resize the textarea below.
|
22
|
+
</p>
|
23
|
+
|
24
|
+
<textarea id="textArea">Resize me</textarea>
|
25
|
+
|
26
|
+
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
|
27
|
+
<script src="../js/client/iframeResizer.contentWindow.min.js"></script>
|
28
|
+
|
29
|
+
<script>
|
30
|
+
function store() {
|
31
|
+
this.x = this.offsetWidth
|
32
|
+
this.y = this.offsetHeight
|
33
|
+
}
|
34
|
+
|
35
|
+
$('textarea')
|
36
|
+
.each(store)
|
37
|
+
.on('mouseover mouseout', function() {
|
38
|
+
if (this.offsetWidth !== this.x || this.offsetHeight !== this.y) {
|
39
|
+
if ('parentIFrame' in window) parentIFrame.size()
|
40
|
+
store.call(this)
|
41
|
+
}
|
42
|
+
})
|
43
|
+
</script>
|
44
|
+
</body>
|
45
|
+
</html>
|
@@ -0,0 +1,113 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<meta charset="utf-8" />
|
5
|
+
<title>iFrame message passing test</title>
|
6
|
+
<meta name="description" content="iFrame message passing test" />
|
7
|
+
<style>
|
8
|
+
a.back {
|
9
|
+
float: right;
|
10
|
+
margin-left: 8px;
|
11
|
+
}
|
12
|
+
body {
|
13
|
+
border: solid 1px red;
|
14
|
+
}
|
15
|
+
p {
|
16
|
+
padding: 5px 212px 5px 5px;
|
17
|
+
margin: 0 0 5px;
|
18
|
+
}
|
19
|
+
#abs {
|
20
|
+
position: absolute;
|
21
|
+
top: 0;
|
22
|
+
bottom: -10;
|
23
|
+
pxright: 0;
|
24
|
+
width: 200px;
|
25
|
+
height: 101%;
|
26
|
+
background-color: wheat;
|
27
|
+
}
|
28
|
+
a.top {
|
29
|
+
position: absolute;
|
30
|
+
bottom: -10px;
|
31
|
+
right: 0;
|
32
|
+
margin: 5px;
|
33
|
+
}
|
34
|
+
</style>
|
35
|
+
</head>
|
36
|
+
|
37
|
+
<body>
|
38
|
+
<p>
|
39
|
+
<b>iFrame</b>
|
40
|
+
|
41
|
+
<a href="frame.content.html" class="back">Back to page 1</a>
|
42
|
+
|
43
|
+
<a
|
44
|
+
href="#"
|
45
|
+
class="back"
|
46
|
+
onclick="if ('parentIFrame' in window) window.parentIFrame.scrollTo(0,99999999);return false;"
|
47
|
+
>Bottom</a
|
48
|
+
>
|
49
|
+
</p>
|
50
|
+
<p>
|
51
|
+
This page has an absolute position elemnt that take it out side the normal
|
52
|
+
document body, which is marked with a red border on this page. This
|
53
|
+
prevents the normal height calculation, which is based on the body tag
|
54
|
+
from returning the correct height. To work around this you can set the
|
55
|
+
<b>heightCalculationMethod</b> option to use one of the other page height
|
56
|
+
propeties.
|
57
|
+
</p>
|
58
|
+
<p>
|
59
|
+
Use the dropdown to change the sizing method of the page, select the
|
60
|
+
different sizing options to see how the effect the page. Note that they
|
61
|
+
can have different effects in different browsers, so you are normally best
|
62
|
+
off selecting <b>max</b> if you need to change away from the default
|
63
|
+
<b>bodyOffset</b> option.
|
64
|
+
</p>
|
65
|
+
<p>
|
66
|
+
<b>Height Calculation Method</b>
|
67
|
+
<select name="heightCalculationMethod">
|
68
|
+
<option>bodyOffset</option>
|
69
|
+
<option>bodyScroll</option>
|
70
|
+
<option>documentElementOffset</option>
|
71
|
+
<option>documentElementScroll</option>
|
72
|
+
<option>max</option>
|
73
|
+
<option>min</option>
|
74
|
+
<option>grow</option>
|
75
|
+
<option>lowestElement</option>
|
76
|
+
</select>
|
77
|
+
</p>
|
78
|
+
<p>
|
79
|
+
<i
|
80
|
+
>This option should be used sparingly, as the alternate methods can be
|
81
|
+
less acurate at working out the correct page size, can cause screen
|
82
|
+
flicker and can sometimes fail to reduce in size when the frame content
|
83
|
+
changes in browsers that do not support mutationObservers (See
|
84
|
+
<a href="http://caniuse.com/mutationobserver">caniuse.com</a> for
|
85
|
+
details).</i
|
86
|
+
>
|
87
|
+
</p>
|
88
|
+
|
89
|
+
<div id="abs">
|
90
|
+
Absolute positioned element
|
91
|
+
<a
|
92
|
+
href="#"
|
93
|
+
class="top"
|
94
|
+
onclick="if ('parentIFrame' in window) window.parentIFrame.scrollTo(0,0);return false;"
|
95
|
+
>Top</a
|
96
|
+
>
|
97
|
+
</div>
|
98
|
+
|
99
|
+
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
|
100
|
+
<script
|
101
|
+
type="text/javascript"
|
102
|
+
src="../js/client/iframeResizer.contentWindow.min.js"
|
103
|
+
></script>
|
104
|
+
<script>
|
105
|
+
$('select').on('change', function() {
|
106
|
+
if ('parentIFrame' in window) {
|
107
|
+
parentIFrame.setHeightCalculationMethod($(this).val())
|
108
|
+
parentIFrame.size()
|
109
|
+
}
|
110
|
+
})
|
111
|
+
</script>
|
112
|
+
</body>
|
113
|
+
</html>
|
@@ -0,0 +1,83 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<meta charset="utf-8" />
|
5
|
+
<title>iFrame message passing test</title>
|
6
|
+
<meta name="description" content="iFrame message passing test" />
|
7
|
+
<meta name="viewport" content="width=device-width" />
|
8
|
+
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
9
|
+
</head>
|
10
|
+
|
11
|
+
<body>
|
12
|
+
<h2>Automagically resizing iFrame</h2>
|
13
|
+
<p>
|
14
|
+
Resize window or click one of the links in the iFrame to watch it resize.
|
15
|
+
Or try with <a name="anchorParentTest" href="two.html">two iFrames</a>.
|
16
|
+
</p>
|
17
|
+
<div style="margin:20px;">
|
18
|
+
<iframe src="frame.content.html" width="100%" scrolling="no"></iframe>
|
19
|
+
</div>
|
20
|
+
<p id="callback"></p>
|
21
|
+
<div style="margin: 8px 0;font-size:13px;">
|
22
|
+
For details on how this works, see
|
23
|
+
<a href="http://davidjbradshaw.github.io/iframe-resizer/"
|
24
|
+
>http://davidjbradshaw.github.io/iframe-resizer/</a
|
25
|
+
>.
|
26
|
+
</div>
|
27
|
+
|
28
|
+
<!-- MDN PolyFils for IE8 (This is not normally needed if you use the jQuery version) -->
|
29
|
+
<!--[if lte IE 8]>
|
30
|
+
|
31
|
+
<![endif]-->
|
32
|
+
|
33
|
+
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
|
34
|
+
<script type="text/javascript" src="../js/iframeResizer.min.js"></script>
|
35
|
+
<script type="text/javascript">
|
36
|
+
/*
|
37
|
+
* If you do not understand what the code below does, then please just use the
|
38
|
+
* following call in your own code.
|
39
|
+
*
|
40
|
+
* iFrameResize({log:true});
|
41
|
+
*
|
42
|
+
* Once you have it working, set the log option to false.
|
43
|
+
*/
|
44
|
+
|
45
|
+
iFrameResize({
|
46
|
+
log: true, // Enable console logging
|
47
|
+
inPageLinks: true,
|
48
|
+
onResized: function(messageData) {
|
49
|
+
// Callback fn when resize is received
|
50
|
+
$('p#callback').html(
|
51
|
+
'<b>Frame ID:</b> ' +
|
52
|
+
messageData.iframe.id +
|
53
|
+
' <b>Height:</b> ' +
|
54
|
+
messageData.height +
|
55
|
+
' <b>Width:</b> ' +
|
56
|
+
messageData.width +
|
57
|
+
' <b>Event type:</b> ' +
|
58
|
+
messageData.type
|
59
|
+
)
|
60
|
+
},
|
61
|
+
onMessage: function(messageData) {
|
62
|
+
// Callback fn when message is received
|
63
|
+
$('p#callback').html(
|
64
|
+
'<b>Frame ID:</b> ' +
|
65
|
+
messageData.iframe.id +
|
66
|
+
' <b>Message:</b> ' +
|
67
|
+
messageData.message
|
68
|
+
)
|
69
|
+
alert(messageData.message)
|
70
|
+
document
|
71
|
+
.getElementsByTagName('iframe')[0]
|
72
|
+
.iFrameResizer.sendMessage('Hello back from parent page')
|
73
|
+
},
|
74
|
+
onClosed: function(id) {
|
75
|
+
// Callback fn when iFrame is closed
|
76
|
+
$('p#callback').html(
|
77
|
+
'<b>IFrame (</b>' + id + '<b>) removed from page.</b>'
|
78
|
+
)
|
79
|
+
}
|
80
|
+
})
|
81
|
+
</script>
|
82
|
+
</body>
|
83
|
+
</html>
|
@@ -0,0 +1,88 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<meta charset="utf-8" />
|
5
|
+
<title>iFrame message passing test</title>
|
6
|
+
<meta name="description" content="iFrame message passing test" />
|
7
|
+
<meta name="viewport" content="width=device-width" />
|
8
|
+
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
9
|
+
</head>
|
10
|
+
|
11
|
+
<body>
|
12
|
+
<h2>Automagically resizing iFrame</h2>
|
13
|
+
<p>
|
14
|
+
Resize window or click one of the links in the iFrame to watch it resize.
|
15
|
+
Or go back to a
|
16
|
+
<a name="anchorParentTest" href="index.html">single iFrame</a>.
|
17
|
+
</p>
|
18
|
+
<div style="margin:20px;">
|
19
|
+
<iframe
|
20
|
+
src="frame.content.html"
|
21
|
+
width="48%"
|
22
|
+
scrolling="no"
|
23
|
+
style="float:left;margin-right:2%"
|
24
|
+
></iframe>
|
25
|
+
<iframe src="frame.content.html" width="48%" scrolling="no"></iframe>
|
26
|
+
</div>
|
27
|
+
<p id="callback"></p>
|
28
|
+
<div style="margin: 8px 0;font-size:13px;">
|
29
|
+
For details on how this works, see
|
30
|
+
<a href="http://davidjbradshaw.github.io/iframe-resizer/"
|
31
|
+
>http://davidjbradshaw.github.io/iframe-resizer/</a
|
32
|
+
>.
|
33
|
+
</div>
|
34
|
+
|
35
|
+
<!-- MDN PolyFils for IE8 -->
|
36
|
+
<!--[if lte IE 8]>
|
37
|
+
|
38
|
+
<![endif]-->
|
39
|
+
|
40
|
+
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
|
41
|
+
<script type="text/javascript" src="../src/iframeResizer.js"></script>
|
42
|
+
<script type="text/javascript">
|
43
|
+
/*
|
44
|
+
* If you do not understand what the code below does, then please just use the
|
45
|
+
* following call in your own code.
|
46
|
+
*
|
47
|
+
* iFrameResize({log:true});
|
48
|
+
*
|
49
|
+
* Once you have it working, set the log option to false.
|
50
|
+
*/
|
51
|
+
|
52
|
+
iFrameResize({
|
53
|
+
log: true, // Enable console logging
|
54
|
+
enablePublicMethods: true, // Enable methods within iframe hosted page
|
55
|
+
enableInPageLinks: true,
|
56
|
+
onResized: function(messageData) {
|
57
|
+
// Callback fn when resize is received
|
58
|
+
$('p#callback').html(
|
59
|
+
'<b>Frame ID:</b> ' +
|
60
|
+
messageData.iframe.id +
|
61
|
+
' <b>Height:</b> ' +
|
62
|
+
messageData.height +
|
63
|
+
' <b>Width:</b> ' +
|
64
|
+
messageData.width +
|
65
|
+
' <b>Event type:</b> ' +
|
66
|
+
messageData.type
|
67
|
+
)
|
68
|
+
},
|
69
|
+
onMessage: function(messageData) {
|
70
|
+
// Callback fn when message is received
|
71
|
+
$('p#callback').html(
|
72
|
+
'<b>Frame ID:</b> ' +
|
73
|
+
messageData.iframe.id +
|
74
|
+
' <b>Message:</b> ' +
|
75
|
+
messageData.message
|
76
|
+
)
|
77
|
+
alert(messageData.message + ' (' + messageData.iframe.id + ')')
|
78
|
+
},
|
79
|
+
onClosed: function(id) {
|
80
|
+
// Callback fn when iFrame is closed
|
81
|
+
$('p#callback').html(
|
82
|
+
'<b>IFrame (</b>' + id + '<b>) removed from page.</b>'
|
83
|
+
)
|
84
|
+
}
|
85
|
+
})
|
86
|
+
</script>
|
87
|
+
</body>
|
88
|
+
</html>
|
@@ -0,0 +1,1288 @@
|
|
1
|
+
/*
|
2
|
+
* File: iframeResizer.contentWindow.js
|
3
|
+
* Desc: Include this file in any page being loaded into an iframe
|
4
|
+
* to force the iframe to resize to the content size.
|
5
|
+
* Requires: iframeResizer.js on host page.
|
6
|
+
* Doc: https://github.com/davidjbradshaw/iframe-resizer
|
7
|
+
* Author: David J. Bradshaw - dave@bradshaw.net
|
8
|
+
*
|
9
|
+
*/
|
10
|
+
|
11
|
+
// eslint-disable-next-line sonarjs/cognitive-complexity, no-shadow-restricted-names
|
12
|
+
;(function (undefined) {
|
13
|
+
if (typeof window === 'undefined') return // don't run for server side render
|
14
|
+
|
15
|
+
var autoResize = true,
|
16
|
+
base = 10,
|
17
|
+
bodyBackground = '',
|
18
|
+
bodyMargin = 0,
|
19
|
+
bodyMarginStr = '',
|
20
|
+
bodyObserver = null,
|
21
|
+
bodyPadding = '',
|
22
|
+
calculateWidth = false,
|
23
|
+
doubleEventList = { resize: 1, click: 1 },
|
24
|
+
eventCancelTimer = 128,
|
25
|
+
firstRun = true,
|
26
|
+
height = 1,
|
27
|
+
heightCalcModeDefault = 'bodyOffset',
|
28
|
+
heightCalcMode = heightCalcModeDefault,
|
29
|
+
initLock = true,
|
30
|
+
initMsg = '',
|
31
|
+
inPageLinks = {},
|
32
|
+
interval = 32,
|
33
|
+
intervalTimer = null,
|
34
|
+
logging = false,
|
35
|
+
msgID = '[iFrameSizer]', // Must match host page msg ID
|
36
|
+
msgIdLen = msgID.length,
|
37
|
+
myID = '',
|
38
|
+
resetRequiredMethods = {
|
39
|
+
max: 1,
|
40
|
+
min: 1,
|
41
|
+
bodyScroll: 1,
|
42
|
+
documentElementScroll: 1
|
43
|
+
},
|
44
|
+
resizeFrom = 'child',
|
45
|
+
sendPermit = true,
|
46
|
+
target = window.parent,
|
47
|
+
targetOriginDefault = '*',
|
48
|
+
tolerance = 0,
|
49
|
+
triggerLocked = false,
|
50
|
+
triggerLockedTimer = null,
|
51
|
+
throttledTimer = 16,
|
52
|
+
width = 1,
|
53
|
+
widthCalcModeDefault = 'scroll',
|
54
|
+
widthCalcMode = widthCalcModeDefault,
|
55
|
+
win = window,
|
56
|
+
onMessage = function () {
|
57
|
+
warn('onMessage function not defined')
|
58
|
+
},
|
59
|
+
onReady = function () {},
|
60
|
+
onPageInfo = function () {},
|
61
|
+
customCalcMethods = {
|
62
|
+
height: function () {
|
63
|
+
warn('Custom height calculation function not defined')
|
64
|
+
return document.documentElement.offsetHeight
|
65
|
+
},
|
66
|
+
width: function () {
|
67
|
+
warn('Custom width calculation function not defined')
|
68
|
+
return document.body.scrollWidth
|
69
|
+
}
|
70
|
+
},
|
71
|
+
eventHandlersByName = {},
|
72
|
+
passiveSupported = false
|
73
|
+
|
74
|
+
function noop() {}
|
75
|
+
|
76
|
+
try {
|
77
|
+
var options = Object.create(
|
78
|
+
{},
|
79
|
+
{
|
80
|
+
passive: {
|
81
|
+
get: function () {
|
82
|
+
passiveSupported = true
|
83
|
+
}
|
84
|
+
}
|
85
|
+
}
|
86
|
+
)
|
87
|
+
window.addEventListener('test', noop, options)
|
88
|
+
window.removeEventListener('test', noop, options)
|
89
|
+
} catch (error) {
|
90
|
+
/* */
|
91
|
+
}
|
92
|
+
|
93
|
+
function addEventListener(el, evt, func, options) {
|
94
|
+
el.addEventListener(evt, func, passiveSupported ? options || {} : false)
|
95
|
+
}
|
96
|
+
|
97
|
+
function removeEventListener(el, evt, func) {
|
98
|
+
el.removeEventListener(evt, func, false)
|
99
|
+
}
|
100
|
+
|
101
|
+
function capitalizeFirstLetter(string) {
|
102
|
+
return string.charAt(0).toUpperCase() + string.slice(1)
|
103
|
+
}
|
104
|
+
|
105
|
+
// Based on underscore.js
|
106
|
+
function throttle(func) {
|
107
|
+
var context,
|
108
|
+
args,
|
109
|
+
result,
|
110
|
+
timeout = null,
|
111
|
+
previous = 0,
|
112
|
+
later = function () {
|
113
|
+
previous = getNow()
|
114
|
+
timeout = null
|
115
|
+
result = func.apply(context, args)
|
116
|
+
if (!timeout) {
|
117
|
+
// eslint-disable-next-line no-multi-assign
|
118
|
+
context = args = null
|
119
|
+
}
|
120
|
+
}
|
121
|
+
|
122
|
+
return function () {
|
123
|
+
var now = getNow()
|
124
|
+
|
125
|
+
if (!previous) {
|
126
|
+
previous = now
|
127
|
+
}
|
128
|
+
|
129
|
+
var remaining = throttledTimer - (now - previous)
|
130
|
+
|
131
|
+
context = this
|
132
|
+
args = arguments
|
133
|
+
|
134
|
+
if (remaining <= 0 || remaining > throttledTimer) {
|
135
|
+
if (timeout) {
|
136
|
+
clearTimeout(timeout)
|
137
|
+
timeout = null
|
138
|
+
}
|
139
|
+
|
140
|
+
previous = now
|
141
|
+
result = func.apply(context, args)
|
142
|
+
|
143
|
+
if (!timeout) {
|
144
|
+
// eslint-disable-next-line no-multi-assign
|
145
|
+
context = args = null
|
146
|
+
}
|
147
|
+
} else if (!timeout) {
|
148
|
+
timeout = setTimeout(later, remaining)
|
149
|
+
}
|
150
|
+
|
151
|
+
return result
|
152
|
+
}
|
153
|
+
}
|
154
|
+
|
155
|
+
var getNow =
|
156
|
+
Date.now ||
|
157
|
+
function () {
|
158
|
+
/* istanbul ignore next */ // Not testable in PhantonJS
|
159
|
+
return new Date().getTime()
|
160
|
+
}
|
161
|
+
|
162
|
+
function formatLogMsg(msg) {
|
163
|
+
return msgID + '[' + myID + '] ' + msg
|
164
|
+
}
|
165
|
+
|
166
|
+
function log(msg) {
|
167
|
+
if (logging && 'object' === typeof window.console) {
|
168
|
+
// eslint-disable-next-line no-console
|
169
|
+
console.log(formatLogMsg(msg))
|
170
|
+
}
|
171
|
+
}
|
172
|
+
|
173
|
+
function warn(msg) {
|
174
|
+
if ('object' === typeof window.console) {
|
175
|
+
// eslint-disable-next-line no-console
|
176
|
+
console.warn(formatLogMsg(msg))
|
177
|
+
}
|
178
|
+
}
|
179
|
+
|
180
|
+
function init() {
|
181
|
+
readDataFromParent()
|
182
|
+
log('Initialising iFrame (' + location.href + ')')
|
183
|
+
readDataFromPage()
|
184
|
+
setMargin()
|
185
|
+
setBodyStyle('background', bodyBackground)
|
186
|
+
setBodyStyle('padding', bodyPadding)
|
187
|
+
injectClearFixIntoBodyElement()
|
188
|
+
checkHeightMode()
|
189
|
+
checkWidthMode()
|
190
|
+
stopInfiniteResizingOfIFrame()
|
191
|
+
setupPublicMethods()
|
192
|
+
startEventListeners()
|
193
|
+
inPageLinks = setupInPageLinks()
|
194
|
+
sendSize('init', 'Init message from host page')
|
195
|
+
onReady()
|
196
|
+
}
|
197
|
+
|
198
|
+
function readDataFromParent() {
|
199
|
+
function strBool(str) {
|
200
|
+
return 'true' === str
|
201
|
+
}
|
202
|
+
|
203
|
+
var data = initMsg.substr(msgIdLen).split(':')
|
204
|
+
|
205
|
+
myID = data[0]
|
206
|
+
bodyMargin = undefined !== data[1] ? Number(data[1]) : bodyMargin // For V1 compatibility
|
207
|
+
calculateWidth = undefined !== data[2] ? strBool(data[2]) : calculateWidth
|
208
|
+
logging = undefined !== data[3] ? strBool(data[3]) : logging
|
209
|
+
interval = undefined !== data[4] ? Number(data[4]) : interval
|
210
|
+
autoResize = undefined !== data[6] ? strBool(data[6]) : autoResize
|
211
|
+
bodyMarginStr = data[7]
|
212
|
+
heightCalcMode = undefined !== data[8] ? data[8] : heightCalcMode
|
213
|
+
bodyBackground = data[9]
|
214
|
+
bodyPadding = data[10]
|
215
|
+
tolerance = undefined !== data[11] ? Number(data[11]) : tolerance
|
216
|
+
inPageLinks.enable = undefined !== data[12] ? strBool(data[12]) : false
|
217
|
+
resizeFrom = undefined !== data[13] ? data[13] : resizeFrom
|
218
|
+
widthCalcMode = undefined !== data[14] ? data[14] : widthCalcMode
|
219
|
+
}
|
220
|
+
|
221
|
+
function depricate(key) {
|
222
|
+
var splitName = key.split('Callback')
|
223
|
+
|
224
|
+
if (splitName.length === 2) {
|
225
|
+
var name =
|
226
|
+
'on' + splitName[0].charAt(0).toUpperCase() + splitName[0].slice(1)
|
227
|
+
this[name] = this[key]
|
228
|
+
delete this[key]
|
229
|
+
warn(
|
230
|
+
"Deprecated: '" +
|
231
|
+
key +
|
232
|
+
"' has been renamed '" +
|
233
|
+
name +
|
234
|
+
"'. The old method will be removed in the next major version."
|
235
|
+
)
|
236
|
+
}
|
237
|
+
}
|
238
|
+
|
239
|
+
function readDataFromPage() {
|
240
|
+
function readData() {
|
241
|
+
var data = window.iFrameResizer
|
242
|
+
|
243
|
+
log('Reading data from page: ' + JSON.stringify(data))
|
244
|
+
Object.keys(data).forEach(depricate, data)
|
245
|
+
|
246
|
+
onMessage = 'onMessage' in data ? data.onMessage : onMessage
|
247
|
+
onReady = 'onReady' in data ? data.onReady : onReady
|
248
|
+
targetOriginDefault =
|
249
|
+
'targetOrigin' in data ? data.targetOrigin : targetOriginDefault
|
250
|
+
heightCalcMode =
|
251
|
+
'heightCalculationMethod' in data
|
252
|
+
? data.heightCalculationMethod
|
253
|
+
: heightCalcMode
|
254
|
+
widthCalcMode =
|
255
|
+
'widthCalculationMethod' in data
|
256
|
+
? data.widthCalculationMethod
|
257
|
+
: widthCalcMode
|
258
|
+
}
|
259
|
+
|
260
|
+
function setupCustomCalcMethods(calcMode, calcFunc) {
|
261
|
+
if ('function' === typeof calcMode) {
|
262
|
+
log('Setup custom ' + calcFunc + 'CalcMethod')
|
263
|
+
customCalcMethods[calcFunc] = calcMode
|
264
|
+
calcMode = 'custom'
|
265
|
+
}
|
266
|
+
|
267
|
+
return calcMode
|
268
|
+
}
|
269
|
+
|
270
|
+
if (
|
271
|
+
'iFrameResizer' in window &&
|
272
|
+
Object === window.iFrameResizer.constructor
|
273
|
+
) {
|
274
|
+
readData()
|
275
|
+
heightCalcMode = setupCustomCalcMethods(heightCalcMode, 'height')
|
276
|
+
widthCalcMode = setupCustomCalcMethods(widthCalcMode, 'width')
|
277
|
+
}
|
278
|
+
|
279
|
+
log('TargetOrigin for parent set to: ' + targetOriginDefault)
|
280
|
+
}
|
281
|
+
|
282
|
+
function chkCSS(attr, value) {
|
283
|
+
if (-1 !== value.indexOf('-')) {
|
284
|
+
warn('Negative CSS value ignored for ' + attr)
|
285
|
+
value = ''
|
286
|
+
}
|
287
|
+
return value
|
288
|
+
}
|
289
|
+
|
290
|
+
function setBodyStyle(attr, value) {
|
291
|
+
if (undefined !== value && '' !== value && 'null' !== value) {
|
292
|
+
document.body.style[attr] = value
|
293
|
+
log('Body ' + attr + ' set to "' + value + '"')
|
294
|
+
}
|
295
|
+
}
|
296
|
+
|
297
|
+
function setMargin() {
|
298
|
+
// If called via V1 script, convert bodyMargin from int to str
|
299
|
+
if (undefined === bodyMarginStr) {
|
300
|
+
bodyMarginStr = bodyMargin + 'px'
|
301
|
+
}
|
302
|
+
|
303
|
+
setBodyStyle('margin', chkCSS('margin', bodyMarginStr))
|
304
|
+
}
|
305
|
+
|
306
|
+
function stopInfiniteResizingOfIFrame() {
|
307
|
+
document.documentElement.style.height = ''
|
308
|
+
document.body.style.height = ''
|
309
|
+
log('HTML & body height set to "auto"')
|
310
|
+
}
|
311
|
+
|
312
|
+
function manageTriggerEvent(options) {
|
313
|
+
var listener = {
|
314
|
+
add: function (eventName) {
|
315
|
+
function handleEvent() {
|
316
|
+
sendSize(options.eventName, options.eventType)
|
317
|
+
}
|
318
|
+
|
319
|
+
eventHandlersByName[eventName] = handleEvent
|
320
|
+
|
321
|
+
addEventListener(window, eventName, handleEvent, { passive: true })
|
322
|
+
},
|
323
|
+
remove: function (eventName) {
|
324
|
+
var handleEvent = eventHandlersByName[eventName]
|
325
|
+
delete eventHandlersByName[eventName]
|
326
|
+
|
327
|
+
removeEventListener(window, eventName, handleEvent)
|
328
|
+
}
|
329
|
+
}
|
330
|
+
|
331
|
+
if (options.eventNames && Array.prototype.map) {
|
332
|
+
options.eventName = options.eventNames[0]
|
333
|
+
options.eventNames.map(listener[options.method])
|
334
|
+
} else {
|
335
|
+
listener[options.method](options.eventName)
|
336
|
+
}
|
337
|
+
|
338
|
+
log(
|
339
|
+
capitalizeFirstLetter(options.method) +
|
340
|
+
' event listener: ' +
|
341
|
+
options.eventType
|
342
|
+
)
|
343
|
+
}
|
344
|
+
|
345
|
+
function manageEventListeners(method) {
|
346
|
+
manageTriggerEvent({
|
347
|
+
method: method,
|
348
|
+
eventType: 'Animation Start',
|
349
|
+
eventNames: ['animationstart', 'webkitAnimationStart']
|
350
|
+
})
|
351
|
+
manageTriggerEvent({
|
352
|
+
method: method,
|
353
|
+
eventType: 'Animation Iteration',
|
354
|
+
eventNames: ['animationiteration', 'webkitAnimationIteration']
|
355
|
+
})
|
356
|
+
manageTriggerEvent({
|
357
|
+
method: method,
|
358
|
+
eventType: 'Animation End',
|
359
|
+
eventNames: ['animationend', 'webkitAnimationEnd']
|
360
|
+
})
|
361
|
+
manageTriggerEvent({
|
362
|
+
method: method,
|
363
|
+
eventType: 'Input',
|
364
|
+
eventName: 'input'
|
365
|
+
})
|
366
|
+
manageTriggerEvent({
|
367
|
+
method: method,
|
368
|
+
eventType: 'Mouse Up',
|
369
|
+
eventName: 'mouseup'
|
370
|
+
})
|
371
|
+
manageTriggerEvent({
|
372
|
+
method: method,
|
373
|
+
eventType: 'Mouse Down',
|
374
|
+
eventName: 'mousedown'
|
375
|
+
})
|
376
|
+
manageTriggerEvent({
|
377
|
+
method: method,
|
378
|
+
eventType: 'Orientation Change',
|
379
|
+
eventName: 'orientationchange'
|
380
|
+
})
|
381
|
+
manageTriggerEvent({
|
382
|
+
method: method,
|
383
|
+
eventType: 'Print',
|
384
|
+
eventName: ['afterprint', 'beforeprint']
|
385
|
+
})
|
386
|
+
manageTriggerEvent({
|
387
|
+
method: method,
|
388
|
+
eventType: 'Ready State Change',
|
389
|
+
eventName: 'readystatechange'
|
390
|
+
})
|
391
|
+
manageTriggerEvent({
|
392
|
+
method: method,
|
393
|
+
eventType: 'Touch Start',
|
394
|
+
eventName: 'touchstart'
|
395
|
+
})
|
396
|
+
manageTriggerEvent({
|
397
|
+
method: method,
|
398
|
+
eventType: 'Touch End',
|
399
|
+
eventName: 'touchend'
|
400
|
+
})
|
401
|
+
manageTriggerEvent({
|
402
|
+
method: method,
|
403
|
+
eventType: 'Touch Cancel',
|
404
|
+
eventName: 'touchcancel'
|
405
|
+
})
|
406
|
+
manageTriggerEvent({
|
407
|
+
method: method,
|
408
|
+
eventType: 'Transition Start',
|
409
|
+
eventNames: [
|
410
|
+
'transitionstart',
|
411
|
+
'webkitTransitionStart',
|
412
|
+
'MSTransitionStart',
|
413
|
+
'oTransitionStart',
|
414
|
+
'otransitionstart'
|
415
|
+
]
|
416
|
+
})
|
417
|
+
manageTriggerEvent({
|
418
|
+
method: method,
|
419
|
+
eventType: 'Transition Iteration',
|
420
|
+
eventNames: [
|
421
|
+
'transitioniteration',
|
422
|
+
'webkitTransitionIteration',
|
423
|
+
'MSTransitionIteration',
|
424
|
+
'oTransitionIteration',
|
425
|
+
'otransitioniteration'
|
426
|
+
]
|
427
|
+
})
|
428
|
+
manageTriggerEvent({
|
429
|
+
method: method,
|
430
|
+
eventType: 'Transition End',
|
431
|
+
eventNames: [
|
432
|
+
'transitionend',
|
433
|
+
'webkitTransitionEnd',
|
434
|
+
'MSTransitionEnd',
|
435
|
+
'oTransitionEnd',
|
436
|
+
'otransitionend'
|
437
|
+
]
|
438
|
+
})
|
439
|
+
if ('child' === resizeFrom) {
|
440
|
+
manageTriggerEvent({
|
441
|
+
method: method,
|
442
|
+
eventType: 'IFrame Resized',
|
443
|
+
eventName: 'resize'
|
444
|
+
})
|
445
|
+
}
|
446
|
+
}
|
447
|
+
|
448
|
+
function checkCalcMode(calcMode, calcModeDefault, modes, type) {
|
449
|
+
if (calcModeDefault !== calcMode) {
|
450
|
+
if (!(calcMode in modes)) {
|
451
|
+
warn(
|
452
|
+
calcMode + ' is not a valid option for ' + type + 'CalculationMethod.'
|
453
|
+
)
|
454
|
+
calcMode = calcModeDefault
|
455
|
+
}
|
456
|
+
log(type + ' calculation method set to "' + calcMode + '"')
|
457
|
+
}
|
458
|
+
|
459
|
+
return calcMode
|
460
|
+
}
|
461
|
+
|
462
|
+
function checkHeightMode() {
|
463
|
+
heightCalcMode = checkCalcMode(
|
464
|
+
heightCalcMode,
|
465
|
+
heightCalcModeDefault,
|
466
|
+
getHeight,
|
467
|
+
'height'
|
468
|
+
)
|
469
|
+
}
|
470
|
+
|
471
|
+
function checkWidthMode() {
|
472
|
+
widthCalcMode = checkCalcMode(
|
473
|
+
widthCalcMode,
|
474
|
+
widthCalcModeDefault,
|
475
|
+
getWidth,
|
476
|
+
'width'
|
477
|
+
)
|
478
|
+
}
|
479
|
+
|
480
|
+
function startEventListeners() {
|
481
|
+
if (true === autoResize) {
|
482
|
+
manageEventListeners('add')
|
483
|
+
setupMutationObserver()
|
484
|
+
} else {
|
485
|
+
log('Auto Resize disabled')
|
486
|
+
}
|
487
|
+
}
|
488
|
+
|
489
|
+
// function stopMsgsToParent() {
|
490
|
+
// log('Disable outgoing messages')
|
491
|
+
// sendPermit = false
|
492
|
+
// }
|
493
|
+
|
494
|
+
// function removeMsgListener() {
|
495
|
+
// log('Remove event listener: Message')
|
496
|
+
// removeEventListener(window, 'message', receiver)
|
497
|
+
// }
|
498
|
+
|
499
|
+
function disconnectMutationObserver() {
|
500
|
+
if (null !== bodyObserver) {
|
501
|
+
/* istanbul ignore next */ // Not testable in PhantonJS
|
502
|
+
bodyObserver.disconnect()
|
503
|
+
}
|
504
|
+
}
|
505
|
+
|
506
|
+
function stopEventListeners() {
|
507
|
+
manageEventListeners('remove')
|
508
|
+
disconnectMutationObserver()
|
509
|
+
clearInterval(intervalTimer)
|
510
|
+
}
|
511
|
+
|
512
|
+
// function teardown() {
|
513
|
+
// stopMsgsToParent()
|
514
|
+
// removeMsgListener()
|
515
|
+
// if (true === autoResize) stopEventListeners()
|
516
|
+
// }
|
517
|
+
|
518
|
+
function injectClearFixIntoBodyElement() {
|
519
|
+
var clearFix = document.createElement('div')
|
520
|
+
clearFix.style.clear = 'both'
|
521
|
+
// Guard against the following having been globally redefined in CSS.
|
522
|
+
clearFix.style.display = 'block'
|
523
|
+
clearFix.style.height = '0'
|
524
|
+
document.body.appendChild(clearFix)
|
525
|
+
}
|
526
|
+
|
527
|
+
function setupInPageLinks() {
|
528
|
+
function getPagePosition() {
|
529
|
+
return {
|
530
|
+
x:
|
531
|
+
window.pageXOffset !== undefined
|
532
|
+
? window.pageXOffset
|
533
|
+
: document.documentElement.scrollLeft,
|
534
|
+
y:
|
535
|
+
window.pageYOffset !== undefined
|
536
|
+
? window.pageYOffset
|
537
|
+
: document.documentElement.scrollTop
|
538
|
+
}
|
539
|
+
}
|
540
|
+
|
541
|
+
function getElementPosition(el) {
|
542
|
+
var elPosition = el.getBoundingClientRect(),
|
543
|
+
pagePosition = getPagePosition()
|
544
|
+
|
545
|
+
return {
|
546
|
+
x: parseInt(elPosition.left, 10) + parseInt(pagePosition.x, 10),
|
547
|
+
y: parseInt(elPosition.top, 10) + parseInt(pagePosition.y, 10)
|
548
|
+
}
|
549
|
+
}
|
550
|
+
|
551
|
+
function findTarget(location) {
|
552
|
+
function jumpToTarget(target) {
|
553
|
+
var jumpPosition = getElementPosition(target)
|
554
|
+
|
555
|
+
log(
|
556
|
+
'Moving to in page link (#' +
|
557
|
+
hash +
|
558
|
+
') at x: ' +
|
559
|
+
jumpPosition.x +
|
560
|
+
' y: ' +
|
561
|
+
jumpPosition.y
|
562
|
+
)
|
563
|
+
sendMsg(jumpPosition.y, jumpPosition.x, 'scrollToOffset') // X&Y reversed at sendMsg uses height/width
|
564
|
+
}
|
565
|
+
|
566
|
+
var hash = location.split('#')[1] || location, // Remove # if present
|
567
|
+
hashData = decodeURIComponent(hash),
|
568
|
+
target =
|
569
|
+
document.getElementById(hashData) ||
|
570
|
+
document.getElementsByName(hashData)[0]
|
571
|
+
|
572
|
+
if (undefined !== target) {
|
573
|
+
jumpToTarget(target)
|
574
|
+
} else {
|
575
|
+
log(
|
576
|
+
'In page link (#' +
|
577
|
+
hash +
|
578
|
+
') not found in iFrame, so sending to parent'
|
579
|
+
)
|
580
|
+
sendMsg(0, 0, 'inPageLink', '#' + hash)
|
581
|
+
}
|
582
|
+
}
|
583
|
+
|
584
|
+
function checkLocationHash() {
|
585
|
+
if ('' !== location.hash && '#' !== location.hash) {
|
586
|
+
findTarget(location.href)
|
587
|
+
}
|
588
|
+
}
|
589
|
+
|
590
|
+
function bindAnchors() {
|
591
|
+
function setupLink(el) {
|
592
|
+
function linkClicked(e) {
|
593
|
+
e.preventDefault()
|
594
|
+
|
595
|
+
/* jshint validthis:true */
|
596
|
+
findTarget(this.getAttribute('href'))
|
597
|
+
}
|
598
|
+
|
599
|
+
if ('#' !== el.getAttribute('href')) {
|
600
|
+
addEventListener(el, 'click', linkClicked)
|
601
|
+
}
|
602
|
+
}
|
603
|
+
|
604
|
+
Array.prototype.forEach.call(
|
605
|
+
document.querySelectorAll('a[href^="#"]'),
|
606
|
+
setupLink
|
607
|
+
)
|
608
|
+
}
|
609
|
+
|
610
|
+
function bindLocationHash() {
|
611
|
+
addEventListener(window, 'hashchange', checkLocationHash)
|
612
|
+
}
|
613
|
+
|
614
|
+
function initCheck() {
|
615
|
+
// Check if page loaded with location hash after init resize
|
616
|
+
setTimeout(checkLocationHash, eventCancelTimer)
|
617
|
+
}
|
618
|
+
|
619
|
+
function enableInPageLinks() {
|
620
|
+
/* istanbul ignore else */ // Not testable in phantonJS
|
621
|
+
if (Array.prototype.forEach && document.querySelectorAll) {
|
622
|
+
log('Setting up location.hash handlers')
|
623
|
+
bindAnchors()
|
624
|
+
bindLocationHash()
|
625
|
+
initCheck()
|
626
|
+
} else {
|
627
|
+
warn(
|
628
|
+
'In page linking not fully supported in this browser! (See README.md for IE8 workaround)'
|
629
|
+
)
|
630
|
+
}
|
631
|
+
}
|
632
|
+
|
633
|
+
if (inPageLinks.enable) {
|
634
|
+
enableInPageLinks()
|
635
|
+
} else {
|
636
|
+
log('In page linking not enabled')
|
637
|
+
}
|
638
|
+
|
639
|
+
return {
|
640
|
+
findTarget: findTarget
|
641
|
+
}
|
642
|
+
}
|
643
|
+
|
644
|
+
function setupPublicMethods() {
|
645
|
+
log('Enable public methods')
|
646
|
+
|
647
|
+
win.parentIFrame = {
|
648
|
+
autoResize: function autoResizeF(resize) {
|
649
|
+
if (true === resize && false === autoResize) {
|
650
|
+
autoResize = true
|
651
|
+
startEventListeners()
|
652
|
+
} else if (false === resize && true === autoResize) {
|
653
|
+
autoResize = false
|
654
|
+
stopEventListeners()
|
655
|
+
}
|
656
|
+
sendMsg(0, 0, 'autoResize', JSON.stringify(autoResize))
|
657
|
+
return autoResize
|
658
|
+
},
|
659
|
+
|
660
|
+
close: function closeF() {
|
661
|
+
sendMsg(0, 0, 'close')
|
662
|
+
// teardown()
|
663
|
+
},
|
664
|
+
|
665
|
+
getId: function getIdF() {
|
666
|
+
return myID
|
667
|
+
},
|
668
|
+
|
669
|
+
getPageInfo: function getPageInfoF(callback) {
|
670
|
+
if ('function' === typeof callback) {
|
671
|
+
onPageInfo = callback
|
672
|
+
sendMsg(0, 0, 'pageInfo')
|
673
|
+
} else {
|
674
|
+
onPageInfo = function () {}
|
675
|
+
sendMsg(0, 0, 'pageInfoStop')
|
676
|
+
}
|
677
|
+
},
|
678
|
+
|
679
|
+
moveToAnchor: function moveToAnchorF(hash) {
|
680
|
+
inPageLinks.findTarget(hash)
|
681
|
+
},
|
682
|
+
|
683
|
+
reset: function resetF() {
|
684
|
+
resetIFrame('parentIFrame.reset')
|
685
|
+
},
|
686
|
+
|
687
|
+
scrollTo: function scrollToF(x, y) {
|
688
|
+
sendMsg(y, x, 'scrollTo') // X&Y reversed at sendMsg uses height/width
|
689
|
+
},
|
690
|
+
|
691
|
+
scrollToOffset: function scrollToF(x, y) {
|
692
|
+
sendMsg(y, x, 'scrollToOffset') // X&Y reversed at sendMsg uses height/width
|
693
|
+
},
|
694
|
+
|
695
|
+
sendMessage: function sendMessageF(msg, targetOrigin) {
|
696
|
+
sendMsg(0, 0, 'message', JSON.stringify(msg), targetOrigin)
|
697
|
+
},
|
698
|
+
|
699
|
+
setHeightCalculationMethod: function setHeightCalculationMethodF(
|
700
|
+
heightCalculationMethod
|
701
|
+
) {
|
702
|
+
heightCalcMode = heightCalculationMethod
|
703
|
+
checkHeightMode()
|
704
|
+
},
|
705
|
+
|
706
|
+
setWidthCalculationMethod: function setWidthCalculationMethodF(
|
707
|
+
widthCalculationMethod
|
708
|
+
) {
|
709
|
+
widthCalcMode = widthCalculationMethod
|
710
|
+
checkWidthMode()
|
711
|
+
},
|
712
|
+
|
713
|
+
setTargetOrigin: function setTargetOriginF(targetOrigin) {
|
714
|
+
log('Set targetOrigin: ' + targetOrigin)
|
715
|
+
targetOriginDefault = targetOrigin
|
716
|
+
},
|
717
|
+
|
718
|
+
size: function sizeF(customHeight, customWidth) {
|
719
|
+
var valString =
|
720
|
+
'' + (customHeight || '') + (customWidth ? ',' + customWidth : '')
|
721
|
+
sendSize(
|
722
|
+
'size',
|
723
|
+
'parentIFrame.size(' + valString + ')',
|
724
|
+
customHeight,
|
725
|
+
customWidth
|
726
|
+
)
|
727
|
+
}
|
728
|
+
}
|
729
|
+
}
|
730
|
+
|
731
|
+
function initInterval() {
|
732
|
+
if (0 !== interval) {
|
733
|
+
log('setInterval: ' + interval + 'ms')
|
734
|
+
intervalTimer = setInterval(function () {
|
735
|
+
sendSize('interval', 'setInterval: ' + interval)
|
736
|
+
}, Math.abs(interval))
|
737
|
+
}
|
738
|
+
}
|
739
|
+
|
740
|
+
// Not testable in PhantomJS
|
741
|
+
/* istanbul ignore next */
|
742
|
+
function setupBodyMutationObserver() {
|
743
|
+
function addImageLoadListners(mutation) {
|
744
|
+
function addImageLoadListener(element) {
|
745
|
+
if (false === element.complete) {
|
746
|
+
log('Attach listeners to ' + element.src)
|
747
|
+
element.addEventListener('load', imageLoaded, false)
|
748
|
+
element.addEventListener('error', imageError, false)
|
749
|
+
elements.push(element)
|
750
|
+
}
|
751
|
+
}
|
752
|
+
|
753
|
+
if (mutation.type === 'attributes' && mutation.attributeName === 'src') {
|
754
|
+
addImageLoadListener(mutation.target)
|
755
|
+
} else if (mutation.type === 'childList') {
|
756
|
+
Array.prototype.forEach.call(
|
757
|
+
mutation.target.querySelectorAll('img'),
|
758
|
+
addImageLoadListener
|
759
|
+
)
|
760
|
+
}
|
761
|
+
}
|
762
|
+
|
763
|
+
function removeFromArray(element) {
|
764
|
+
elements.splice(elements.indexOf(element), 1)
|
765
|
+
}
|
766
|
+
|
767
|
+
function removeImageLoadListener(element) {
|
768
|
+
log('Remove listeners from ' + element.src)
|
769
|
+
element.removeEventListener('load', imageLoaded, false)
|
770
|
+
element.removeEventListener('error', imageError, false)
|
771
|
+
removeFromArray(element)
|
772
|
+
}
|
773
|
+
|
774
|
+
function imageEventTriggered(event, type, typeDesc) {
|
775
|
+
removeImageLoadListener(event.target)
|
776
|
+
sendSize(type, typeDesc + ': ' + event.target.src, undefined, undefined)
|
777
|
+
}
|
778
|
+
|
779
|
+
function imageLoaded(event) {
|
780
|
+
imageEventTriggered(event, 'imageLoad', 'Image loaded')
|
781
|
+
}
|
782
|
+
|
783
|
+
function imageError(event) {
|
784
|
+
imageEventTriggered(event, 'imageLoadFailed', 'Image load failed')
|
785
|
+
}
|
786
|
+
|
787
|
+
function mutationObserved(mutations) {
|
788
|
+
sendSize(
|
789
|
+
'mutationObserver',
|
790
|
+
'mutationObserver: ' + mutations[0].target + ' ' + mutations[0].type
|
791
|
+
)
|
792
|
+
|
793
|
+
// Deal with WebKit / Blink asyncing image loading when tags are injected into the page
|
794
|
+
mutations.forEach(addImageLoadListners)
|
795
|
+
}
|
796
|
+
|
797
|
+
function createMutationObserver() {
|
798
|
+
var target = document.querySelector('body'),
|
799
|
+
config = {
|
800
|
+
attributes: true,
|
801
|
+
attributeOldValue: false,
|
802
|
+
characterData: true,
|
803
|
+
characterDataOldValue: false,
|
804
|
+
childList: true,
|
805
|
+
subtree: true
|
806
|
+
}
|
807
|
+
|
808
|
+
observer = new MutationObserver(mutationObserved)
|
809
|
+
|
810
|
+
log('Create body MutationObserver')
|
811
|
+
observer.observe(target, config)
|
812
|
+
|
813
|
+
return observer
|
814
|
+
}
|
815
|
+
|
816
|
+
var elements = [],
|
817
|
+
MutationObserver =
|
818
|
+
window.MutationObserver || window.WebKitMutationObserver,
|
819
|
+
observer = createMutationObserver()
|
820
|
+
|
821
|
+
return {
|
822
|
+
disconnect: function () {
|
823
|
+
if ('disconnect' in observer) {
|
824
|
+
log('Disconnect body MutationObserver')
|
825
|
+
observer.disconnect()
|
826
|
+
elements.forEach(removeImageLoadListener)
|
827
|
+
}
|
828
|
+
}
|
829
|
+
}
|
830
|
+
}
|
831
|
+
|
832
|
+
function setupMutationObserver() {
|
833
|
+
var forceIntervalTimer = 0 > interval
|
834
|
+
|
835
|
+
// Not testable in PhantomJS
|
836
|
+
/* istanbul ignore if */ if (
|
837
|
+
window.MutationObserver ||
|
838
|
+
window.WebKitMutationObserver
|
839
|
+
) {
|
840
|
+
if (forceIntervalTimer) {
|
841
|
+
initInterval()
|
842
|
+
} else {
|
843
|
+
bodyObserver = setupBodyMutationObserver()
|
844
|
+
}
|
845
|
+
} else {
|
846
|
+
log('MutationObserver not supported in this browser!')
|
847
|
+
initInterval()
|
848
|
+
}
|
849
|
+
}
|
850
|
+
|
851
|
+
// document.documentElement.offsetHeight is not reliable, so
|
852
|
+
// we have to jump through hoops to get a better value.
|
853
|
+
function getComputedStyle(prop, el) {
|
854
|
+
var retVal = 0
|
855
|
+
el = el || document.body // Not testable in phantonJS
|
856
|
+
|
857
|
+
retVal = document.defaultView.getComputedStyle(el, null)
|
858
|
+
retVal = null !== retVal ? retVal[prop] : 0
|
859
|
+
|
860
|
+
return parseInt(retVal, base)
|
861
|
+
}
|
862
|
+
|
863
|
+
function chkEventThottle(timer) {
|
864
|
+
if (timer > throttledTimer / 2) {
|
865
|
+
throttledTimer = 2 * timer
|
866
|
+
log('Event throttle increased to ' + throttledTimer + 'ms')
|
867
|
+
}
|
868
|
+
}
|
869
|
+
|
870
|
+
// Idea from https://github.com/guardian/iframe-messenger
|
871
|
+
function getMaxElement(side, elements) {
|
872
|
+
var elementsLength = elements.length,
|
873
|
+
elVal = 0,
|
874
|
+
maxVal = 0,
|
875
|
+
Side = capitalizeFirstLetter(side),
|
876
|
+
timer = getNow()
|
877
|
+
|
878
|
+
for (var i = 0; i < elementsLength; i++) {
|
879
|
+
elVal =
|
880
|
+
elements[i].getBoundingClientRect()[side] +
|
881
|
+
getComputedStyle('margin' + Side, elements[i])
|
882
|
+
if (elVal > maxVal) {
|
883
|
+
maxVal = elVal
|
884
|
+
}
|
885
|
+
}
|
886
|
+
|
887
|
+
timer = getNow() - timer
|
888
|
+
|
889
|
+
log('Parsed ' + elementsLength + ' HTML elements')
|
890
|
+
log('Element position calculated in ' + timer + 'ms')
|
891
|
+
|
892
|
+
chkEventThottle(timer)
|
893
|
+
|
894
|
+
return maxVal
|
895
|
+
}
|
896
|
+
|
897
|
+
function getAllMeasurements(dimention) {
|
898
|
+
return [
|
899
|
+
dimention.bodyOffset(),
|
900
|
+
dimention.bodyScroll(),
|
901
|
+
dimention.documentElementOffset(),
|
902
|
+
dimention.documentElementScroll()
|
903
|
+
]
|
904
|
+
}
|
905
|
+
|
906
|
+
function getTaggedElements(side, tag) {
|
907
|
+
function noTaggedElementsFound() {
|
908
|
+
warn('No tagged elements (' + tag + ') found on page')
|
909
|
+
return document.querySelectorAll('body *')
|
910
|
+
}
|
911
|
+
|
912
|
+
var elements = document.querySelectorAll('[' + tag + ']')
|
913
|
+
|
914
|
+
if (0 === elements.length) noTaggedElementsFound()
|
915
|
+
|
916
|
+
return getMaxElement(side, elements)
|
917
|
+
}
|
918
|
+
|
919
|
+
function getAllElements() {
|
920
|
+
return document.querySelectorAll('body *')
|
921
|
+
}
|
922
|
+
|
923
|
+
var getHeight = {
|
924
|
+
bodyOffset: function getBodyOffsetHeight() {
|
925
|
+
return (
|
926
|
+
document.body.offsetHeight +
|
927
|
+
getComputedStyle('marginTop') +
|
928
|
+
getComputedStyle('marginBottom')
|
929
|
+
)
|
930
|
+
},
|
931
|
+
|
932
|
+
offset: function () {
|
933
|
+
return getHeight.bodyOffset() // Backwards compatability
|
934
|
+
},
|
935
|
+
|
936
|
+
bodyScroll: function getBodyScrollHeight() {
|
937
|
+
return document.body.scrollHeight
|
938
|
+
},
|
939
|
+
|
940
|
+
custom: function getCustomWidth() {
|
941
|
+
return customCalcMethods.height()
|
942
|
+
},
|
943
|
+
|
944
|
+
documentElementOffset: function getDEOffsetHeight() {
|
945
|
+
return document.documentElement.offsetHeight
|
946
|
+
},
|
947
|
+
|
948
|
+
documentElementScroll: function getDEScrollHeight() {
|
949
|
+
return document.documentElement.scrollHeight
|
950
|
+
},
|
951
|
+
|
952
|
+
max: function getMaxHeight() {
|
953
|
+
return Math.max.apply(null, getAllMeasurements(getHeight))
|
954
|
+
},
|
955
|
+
|
956
|
+
min: function getMinHeight() {
|
957
|
+
return Math.min.apply(null, getAllMeasurements(getHeight))
|
958
|
+
},
|
959
|
+
|
960
|
+
grow: function growHeight() {
|
961
|
+
return getHeight.max() // Run max without the forced downsizing
|
962
|
+
},
|
963
|
+
|
964
|
+
lowestElement: function getBestHeight() {
|
965
|
+
return Math.max(
|
966
|
+
getHeight.bodyOffset() || getHeight.documentElementOffset(),
|
967
|
+
getMaxElement('bottom', getAllElements())
|
968
|
+
)
|
969
|
+
},
|
970
|
+
|
971
|
+
taggedElement: function getTaggedElementsHeight() {
|
972
|
+
return getTaggedElements('bottom', 'data-iframe-height')
|
973
|
+
}
|
974
|
+
},
|
975
|
+
getWidth = {
|
976
|
+
bodyScroll: function getBodyScrollWidth() {
|
977
|
+
return document.body.scrollWidth
|
978
|
+
},
|
979
|
+
|
980
|
+
bodyOffset: function getBodyOffsetWidth() {
|
981
|
+
return document.body.offsetWidth
|
982
|
+
},
|
983
|
+
|
984
|
+
custom: function getCustomWidth() {
|
985
|
+
return customCalcMethods.width()
|
986
|
+
},
|
987
|
+
|
988
|
+
documentElementScroll: function getDEScrollWidth() {
|
989
|
+
return document.documentElement.scrollWidth
|
990
|
+
},
|
991
|
+
|
992
|
+
documentElementOffset: function getDEOffsetWidth() {
|
993
|
+
return document.documentElement.offsetWidth
|
994
|
+
},
|
995
|
+
|
996
|
+
scroll: function getMaxWidth() {
|
997
|
+
return Math.max(getWidth.bodyScroll(), getWidth.documentElementScroll())
|
998
|
+
},
|
999
|
+
|
1000
|
+
max: function getMaxWidth() {
|
1001
|
+
return Math.max.apply(null, getAllMeasurements(getWidth))
|
1002
|
+
},
|
1003
|
+
|
1004
|
+
min: function getMinWidth() {
|
1005
|
+
return Math.min.apply(null, getAllMeasurements(getWidth))
|
1006
|
+
},
|
1007
|
+
|
1008
|
+
rightMostElement: function rightMostElement() {
|
1009
|
+
return getMaxElement('right', getAllElements())
|
1010
|
+
},
|
1011
|
+
|
1012
|
+
taggedElement: function getTaggedElementsWidth() {
|
1013
|
+
return getTaggedElements('right', 'data-iframe-width')
|
1014
|
+
}
|
1015
|
+
}
|
1016
|
+
|
1017
|
+
function sizeIFrame(
|
1018
|
+
triggerEvent,
|
1019
|
+
triggerEventDesc,
|
1020
|
+
customHeight,
|
1021
|
+
customWidth
|
1022
|
+
) {
|
1023
|
+
function resizeIFrame() {
|
1024
|
+
height = currentHeight
|
1025
|
+
width = currentWidth
|
1026
|
+
|
1027
|
+
sendMsg(height, width, triggerEvent)
|
1028
|
+
}
|
1029
|
+
|
1030
|
+
function isSizeChangeDetected() {
|
1031
|
+
function checkTolarance(a, b) {
|
1032
|
+
var retVal = Math.abs(a - b) <= tolerance
|
1033
|
+
return !retVal
|
1034
|
+
}
|
1035
|
+
|
1036
|
+
currentHeight =
|
1037
|
+
undefined !== customHeight ? customHeight : getHeight[heightCalcMode]()
|
1038
|
+
currentWidth =
|
1039
|
+
undefined !== customWidth ? customWidth : getWidth[widthCalcMode]()
|
1040
|
+
|
1041
|
+
return (
|
1042
|
+
checkTolarance(height, currentHeight) ||
|
1043
|
+
(calculateWidth && checkTolarance(width, currentWidth))
|
1044
|
+
)
|
1045
|
+
}
|
1046
|
+
|
1047
|
+
function isForceResizableEvent() {
|
1048
|
+
return !(triggerEvent in { init: 1, interval: 1, size: 1 })
|
1049
|
+
}
|
1050
|
+
|
1051
|
+
function isForceResizableCalcMode() {
|
1052
|
+
return (
|
1053
|
+
heightCalcMode in resetRequiredMethods ||
|
1054
|
+
(calculateWidth && widthCalcMode in resetRequiredMethods)
|
1055
|
+
)
|
1056
|
+
}
|
1057
|
+
|
1058
|
+
function logIgnored() {
|
1059
|
+
log('No change in size detected')
|
1060
|
+
}
|
1061
|
+
|
1062
|
+
function checkDownSizing() {
|
1063
|
+
if (isForceResizableEvent() && isForceResizableCalcMode()) {
|
1064
|
+
resetIFrame(triggerEventDesc)
|
1065
|
+
} else if (!(triggerEvent in { interval: 1 })) {
|
1066
|
+
logIgnored()
|
1067
|
+
}
|
1068
|
+
}
|
1069
|
+
|
1070
|
+
var currentHeight, currentWidth
|
1071
|
+
|
1072
|
+
if (isSizeChangeDetected() || 'init' === triggerEvent) {
|
1073
|
+
lockTrigger()
|
1074
|
+
resizeIFrame()
|
1075
|
+
} else {
|
1076
|
+
checkDownSizing()
|
1077
|
+
}
|
1078
|
+
}
|
1079
|
+
|
1080
|
+
var sizeIFrameThrottled = throttle(sizeIFrame)
|
1081
|
+
|
1082
|
+
function sendSize(triggerEvent, triggerEventDesc, customHeight, customWidth) {
|
1083
|
+
function recordTrigger() {
|
1084
|
+
if (!(triggerEvent in { reset: 1, resetPage: 1, init: 1 })) {
|
1085
|
+
log('Trigger event: ' + triggerEventDesc)
|
1086
|
+
}
|
1087
|
+
}
|
1088
|
+
|
1089
|
+
function isDoubleFiredEvent() {
|
1090
|
+
return triggerLocked && triggerEvent in doubleEventList
|
1091
|
+
}
|
1092
|
+
|
1093
|
+
if (!isDoubleFiredEvent()) {
|
1094
|
+
recordTrigger()
|
1095
|
+
if (triggerEvent === 'init') {
|
1096
|
+
sizeIFrame(triggerEvent, triggerEventDesc, customHeight, customWidth)
|
1097
|
+
} else {
|
1098
|
+
sizeIFrameThrottled(
|
1099
|
+
triggerEvent,
|
1100
|
+
triggerEventDesc,
|
1101
|
+
customHeight,
|
1102
|
+
customWidth
|
1103
|
+
)
|
1104
|
+
}
|
1105
|
+
} else {
|
1106
|
+
log('Trigger event cancelled: ' + triggerEvent)
|
1107
|
+
}
|
1108
|
+
}
|
1109
|
+
|
1110
|
+
function lockTrigger() {
|
1111
|
+
if (!triggerLocked) {
|
1112
|
+
triggerLocked = true
|
1113
|
+
log('Trigger event lock on')
|
1114
|
+
}
|
1115
|
+
clearTimeout(triggerLockedTimer)
|
1116
|
+
triggerLockedTimer = setTimeout(function () {
|
1117
|
+
triggerLocked = false
|
1118
|
+
log('Trigger event lock off')
|
1119
|
+
log('--')
|
1120
|
+
}, eventCancelTimer)
|
1121
|
+
}
|
1122
|
+
|
1123
|
+
function triggerReset(triggerEvent) {
|
1124
|
+
height = getHeight[heightCalcMode]()
|
1125
|
+
width = getWidth[widthCalcMode]()
|
1126
|
+
|
1127
|
+
sendMsg(height, width, triggerEvent)
|
1128
|
+
}
|
1129
|
+
|
1130
|
+
function resetIFrame(triggerEventDesc) {
|
1131
|
+
var hcm = heightCalcMode
|
1132
|
+
heightCalcMode = heightCalcModeDefault
|
1133
|
+
|
1134
|
+
log('Reset trigger event: ' + triggerEventDesc)
|
1135
|
+
lockTrigger()
|
1136
|
+
triggerReset('reset')
|
1137
|
+
|
1138
|
+
heightCalcMode = hcm
|
1139
|
+
}
|
1140
|
+
|
1141
|
+
function sendMsg(height, width, triggerEvent, msg, targetOrigin) {
|
1142
|
+
function setTargetOrigin() {
|
1143
|
+
if (undefined === targetOrigin) {
|
1144
|
+
targetOrigin = targetOriginDefault
|
1145
|
+
} else {
|
1146
|
+
log('Message targetOrigin: ' + targetOrigin)
|
1147
|
+
}
|
1148
|
+
}
|
1149
|
+
|
1150
|
+
function sendToParent() {
|
1151
|
+
var size = height + ':' + width,
|
1152
|
+
message =
|
1153
|
+
myID +
|
1154
|
+
':' +
|
1155
|
+
size +
|
1156
|
+
':' +
|
1157
|
+
triggerEvent +
|
1158
|
+
(undefined !== msg ? ':' + msg : '')
|
1159
|
+
|
1160
|
+
log('Sending message to host page (' + message + ')')
|
1161
|
+
target.postMessage(msgID + message, targetOrigin)
|
1162
|
+
}
|
1163
|
+
|
1164
|
+
if (true === sendPermit) {
|
1165
|
+
setTargetOrigin()
|
1166
|
+
sendToParent()
|
1167
|
+
}
|
1168
|
+
}
|
1169
|
+
|
1170
|
+
function receiver(event) {
|
1171
|
+
var processRequestFromParent = {
|
1172
|
+
init: function initFromParent() {
|
1173
|
+
initMsg = event.data
|
1174
|
+
target = event.source
|
1175
|
+
|
1176
|
+
init()
|
1177
|
+
firstRun = false
|
1178
|
+
setTimeout(function () {
|
1179
|
+
initLock = false
|
1180
|
+
}, eventCancelTimer)
|
1181
|
+
},
|
1182
|
+
|
1183
|
+
reset: function resetFromParent() {
|
1184
|
+
if (!initLock) {
|
1185
|
+
log('Page size reset by host page')
|
1186
|
+
triggerReset('resetPage')
|
1187
|
+
} else {
|
1188
|
+
log('Page reset ignored by init')
|
1189
|
+
}
|
1190
|
+
},
|
1191
|
+
|
1192
|
+
resize: function resizeFromParent() {
|
1193
|
+
sendSize('resizeParent', 'Parent window requested size check')
|
1194
|
+
},
|
1195
|
+
|
1196
|
+
moveToAnchor: function moveToAnchorF() {
|
1197
|
+
inPageLinks.findTarget(getData())
|
1198
|
+
},
|
1199
|
+
inPageLink: function inPageLinkF() {
|
1200
|
+
this.moveToAnchor()
|
1201
|
+
}, // Backward compatability
|
1202
|
+
|
1203
|
+
pageInfo: function pageInfoFromParent() {
|
1204
|
+
var msgBody = getData()
|
1205
|
+
log('PageInfoFromParent called from parent: ' + msgBody)
|
1206
|
+
onPageInfo(JSON.parse(msgBody))
|
1207
|
+
log(' --')
|
1208
|
+
},
|
1209
|
+
|
1210
|
+
message: function messageFromParent() {
|
1211
|
+
var msgBody = getData()
|
1212
|
+
|
1213
|
+
log('onMessage called from parent: ' + msgBody)
|
1214
|
+
// eslint-disable-next-line sonarjs/no-extra-arguments
|
1215
|
+
onMessage(JSON.parse(msgBody))
|
1216
|
+
log(' --')
|
1217
|
+
}
|
1218
|
+
}
|
1219
|
+
|
1220
|
+
function isMessageForUs() {
|
1221
|
+
return msgID === ('' + event.data).substr(0, msgIdLen) // ''+ Protects against non-string messages
|
1222
|
+
}
|
1223
|
+
|
1224
|
+
function getMessageType() {
|
1225
|
+
return event.data.split(']')[1].split(':')[0]
|
1226
|
+
}
|
1227
|
+
|
1228
|
+
function getData() {
|
1229
|
+
return event.data.substr(event.data.indexOf(':') + 1)
|
1230
|
+
}
|
1231
|
+
|
1232
|
+
function isMiddleTier() {
|
1233
|
+
return (
|
1234
|
+
(!(typeof module !== 'undefined' && module.exports) &&
|
1235
|
+
'iFrameResize' in window) ||
|
1236
|
+
('jQuery' in window && 'iFrameResize' in window.jQuery.prototype)
|
1237
|
+
)
|
1238
|
+
}
|
1239
|
+
|
1240
|
+
function isInitMsg() {
|
1241
|
+
// Test if this message is from a child below us. This is an ugly test, however, updating
|
1242
|
+
// the message format would break backwards compatibity.
|
1243
|
+
return event.data.split(':')[2] in { true: 1, false: 1 }
|
1244
|
+
}
|
1245
|
+
|
1246
|
+
function callFromParent() {
|
1247
|
+
var messageType = getMessageType()
|
1248
|
+
|
1249
|
+
if (messageType in processRequestFromParent) {
|
1250
|
+
processRequestFromParent[messageType]()
|
1251
|
+
} else if (!isMiddleTier() && !isInitMsg()) {
|
1252
|
+
warn('Unexpected message (' + event.data + ')')
|
1253
|
+
}
|
1254
|
+
}
|
1255
|
+
|
1256
|
+
function processMessage() {
|
1257
|
+
if (false === firstRun) {
|
1258
|
+
callFromParent()
|
1259
|
+
} else if (isInitMsg()) {
|
1260
|
+
processRequestFromParent.init()
|
1261
|
+
} else {
|
1262
|
+
log(
|
1263
|
+
'Ignored message of type "' +
|
1264
|
+
getMessageType() +
|
1265
|
+
'". Received before initialization.'
|
1266
|
+
)
|
1267
|
+
}
|
1268
|
+
}
|
1269
|
+
|
1270
|
+
if (isMessageForUs()) {
|
1271
|
+
processMessage()
|
1272
|
+
}
|
1273
|
+
}
|
1274
|
+
|
1275
|
+
// Normally the parent kicks things off when it detects the iFrame has loaded.
|
1276
|
+
// If this script is async-loaded, then tell parent page to retry init.
|
1277
|
+
function chkLateLoaded() {
|
1278
|
+
if ('loading' !== document.readyState) {
|
1279
|
+
window.parent.postMessage('[iFrameResizerChild]Ready', '*')
|
1280
|
+
}
|
1281
|
+
}
|
1282
|
+
|
1283
|
+
addEventListener(window, 'message', receiver)
|
1284
|
+
addEventListener(window, 'readystatechange', chkLateLoaded)
|
1285
|
+
chkLateLoaded()
|
1286
|
+
|
1287
|
+
|
1288
|
+
})()
|