the-riddle
clone your own copy | download snapshot

Snapshots | iceberg

Inside this repository

template.html
text/html

Download raw (7.8 KB)

<!DOCTYPE HTML>
<html lang="en-us">
<head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8">
<!--     <link rel="stylesheet" href="/main.css" type="text/css" media="all" charset="utf-8"> -->
<!--     <link rel="stylesheet" href="../style.less" type="text/less" media="all"> -->
    <link rel="stylesheet" href="style.css" type="text/css" media="all">
    <title>Regions</title>
</head>
<body>
    <!-- PAGES -->
    <div id="pages">
        <!-- MASTER -->
        <div id="master-page" class="paper">
            <div class="page">
                <div class="header running"></div>
                <section id="master-region" class="body">
                    <div class="main"></div>
                </section>
                <div class="footer"></div>
            </div>
        </div>
    </div>
    <div id="stories">
        <!-- <article id="flow-excursion" data-src="/stories/1-2-2-excursion7.html"></article> -->
        <article id="main" data-src="__story_path__"></article>
    </div>
    <!-- <script type="text/javascript" src="/assets/lib/less-1.3.0.min.js"></script> -->
    <!--<script type="text/javascript" src="/assets/lib/jquery.min.js"></script>-->
    <script type="text/javascript" src="/js/flow.js"></script>
    <!--<script type="text/javascript" src="/setup/setup.js"></script>-->
    <script type="text/javascript" src="/js/stories.js"></script>
    <script type="text/javascript" src="colorify.js"></script>
    <!-- uncomment to activate footnote stacking -->
    <!--<script type="text/javascript" src="stackFootnotes.js"></script>-->
    <script type="text/javascript" src="/assets/js/collapseFootnotes.js"></script>
    <script type="text/javascript" src="/assets/js/typography.js"></script>
    <script type="text/javascript" src="/assets/js/indexNames.js"></script>
    <script type="text/javascript" src="/assets/js/indexKeywords.js"></script>
    <script type="text/javascript">
        ; (function () {
            'use strict';

            if (!(document.webkitGetNamedFlows || document.getNamedFlows)) {
                var polyfill = document.createElement("script");
                polyfill.setAttribute("src", "/assets/lib/css-regions.min.js");
                document.body.appendChild(polyfill);
            }

            document.addEventListener("expand", function () {
                expandAll();
                fitFlow(document.getNamedFlow('main'), document.querySelector('#master-page'), document.querySelector('#pages'), function (node) { return node.classList.contains('paper')});
            }, false);
            
            document.addEventListener("storiesloaded", function () {
                blessAll();
                expandAll();
                window.requestAnimationFrame(function () {
                    var template;

                    document.getNamedFlow('main').addEventListener('regionlayoutcomplete', function () {
                        colorify(".excursion img", [18, 103, 106], function () {
                            colorify(".inlineFootnote img", [18, 103, 106], function () {
                                window.requestAnimationFrame(function () {
                                    var breakNode = document.createElement('span');
                                    breakNode.style.clear = 'both';
                                    breakNode.style.display = 'block';
                                    document.querySelector('article').appendChild(breakNode);
                                    typographicFixes();
                                    
                                    /** patch for footnotes next to a paragraph, which is sent to the next page */
                                    var paragraphs = document.querySelectorAll('p.break-before');
                                    for (var i=0; i < paragraphs.length; i++) {
                                        var p = paragraphs[i],
                                            node = p.previousElementSibling;

                                        while (node && node.classList.contains('inlineFootnote') && node.classList.contains('moved-up')) {
                                            node.classList.add('break-margin');
                                            node = node.previousElementSibling;
                                        }
                                    }

                                    //  fitFlow(document.getNamedFlow('main'), template, document.querySelector('#pages'), function (node) { return node.classList.contains('paper')});

                                    function styleFootnotes (i, callback) {
                                        var ftntRects, footnotes = document.querySelectorAll('.inlineFootnote');

                                        if (i < footnotes.length) {
                                            ftntRects = footnotes[i].getClientRects();
                                            if (ftntRects.length > 1 && ftntRects[0].height < 75) {
                                                var marginTop = parseInt(footnotes[i].style.marginTop);
                                                
                                                if (marginTop > 0) {
                                                    footnotes[i].style.marginTop = parseInt(footnotes[i].style.marginTop) + 20 + 'px';
                                                } else {
                                                    footnotes[i].style.marginTop = ftntRects[0].height + 'px';
                                                    styleFootnotes(i, callback);
                                                }
                                                
                                                i++;
                                                return styleFootnotes(i, callback);
                                            } else {
                                                i++;
                                                return styleFootnotes(i, callback);
                                            }
                                        }

                                        callback();
                                    }

                                    styleFootnotes(0, function () {
                                        
                                        //indexKeywords();
                                        indexNames();
                                    
                                        while(document.querySelector('.paper:last-of-type').querySelector('.main').webkitRegionOverset == 'empty') {
                                            document.querySelector('.paper:last-of-type').remove();
                                        }

                                        if ((document.querySelectorAll('.paper').length % 2) == 1) {
                                            var page = template.cloneNode(true);
                                            page.classList.add('headerless');
                                            document.querySelector('#pages').appendChild(page);
                                        }

                                        document.layoutcomplete = true;
                                    });
                                });
                            });
                        });
                        //window.setTimeout(function() {
                        //    document.layoutcomplete = true;
                        //}, "2000");
                    });

                    template = document.querySelector('#master-page');
                    template.removeAttribute('id');
                    template.remove();
                    
                    fitFlow(document.getNamedFlow('main'), template, document.querySelector('#pages'), function (node) { return node.classList.contains('paper')});

                });
            });
        })();
    </script>
</body>
</html>