classic_js

NAML documentation   Watch a video
   Usages of this macro
... in content_open_links_in_new_window.naml
1
2
3
4
5
6
7
8
9
10
<override_macro name="classic_js">
    <n.overridden/>
    <script type="text/javascript">
        $(document).ready(function() {
            $('a[link="external"]').each(function() {
                $(this).attr('target','_blank');
            });
        });
    </script>
</override_macro>
Overrides default macro
... in topic.naml
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
<macro name="classic_js">
    <script type="text/javascript">
        var _hash = Nabble.hash();
        if (_hash) {
            (function(){
                var post = _hash.substr(2);
                var allPosts = [<n.compress
Macro
Parameters: text
.all_posts_js_array
Macro
/>];
                var allURLs = [<n.compress
Macro
Parameters: text
.all_urls_js_array
Macro
/>];
                var iPost = allPosts.indexOf(parseInt(post));
                var lower = <n.default
Binary
Namespace: BasicNamespace
Parameters: to, text
. to="0"><n.classic_index_record
Macro
Requires: servlet
/></n.default.>;
                var upper = lower + <n.classic_rows_per_page
Macro
/>;
<![CDATA[
                if (iPost != -1 && (iPost < lower || iPost >= upper))
]]>
                    location.replace(allURLs[Math.floor(iPost/<n.classic_rows_per_page
Macro
/>)]+_hash);
            })();
        }
 
        $(document).ready(function() {
            var rootId = '<n.page_node
Binary
Namespace: NodePageNamespace
Parameters: do
.id
Binary
Namespace: NodeNamespace
/>';
<![CDATA[
            var currentPostId = rootId;
            var isChangingViews = _hash == '#none';
            if (_hash && !isChangingViews)
                currentPostId = _hash.substr(2);
 
            Nabble.hideQuotes();
 
            function scrollToSelectedPost() {
                var $arrow = $('#red-arrow'+currentPostId).show();
                if ($arrow.size() > 0) {
                    var isRootPost = currentPostId == rootId;
                    if (Nabble.isEmbedded) {
                        if (Nabble.canScroll()) scrollTo(0, 0);
                        var y = isChangingViews? null : isRootPost? 1 : $arrow.parents('div.classic-row').offset().top;
                        Nabble.resizeFrames('', y);
                    } else if (Nabble.canScroll() && !isRootPost) {
                        var yPos = $arrow.offset().top;
                        scrollTo(0,yPos-20);
                    }
                } else {
                    if (Nabble.isEmbedded && Nabble.canScroll()) {
                        Nabble.resizeFrames('', 1);
                    } else {
                        var tb = $('div.top-bar').get(0);
                        if (tb)
                            tb.scrollIntoView();
                    }
                }
            };
            $(window).load(scrollToSelectedPost);
 
            if (Nabble.isEmbedded) {
                $('div.message-text img').load(Nabble.resizeFrames);
            }
]]>
        });
    </script>
</macro>