ajax_posts_js

NAML documentation   Watch a video
   Usages of this macro
The source code below doesn't have navigation links because no usage has been compiled yet. Navigation links depend on how and where the macro is used, so first you may try finding all usages of "ajax_posts_js".
... in topic.naml
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
<macro name="ajax_posts_js" parameters="view_name">
    <script type="text/javascript">
        var historyLength = history.length;
        var loadedPosts = [];
        var allPosts = [<n.compress.all_posts_js_array/>];
 
        function setPostHover($e) {
            $e.hover(
                function(){ $(this).addClass('post-hover'); },
                function(){ $(this).removeClass('post-hover'); });
        };
 
        var lastPostId = <n.page_node.last_node.id/>;
<![CDATA[
        Nabble.markUnreadPosts = function(lastVisitedId) {
            if (lastVisitedId == null)
                $('div.clickable-row').css('font-weight','bold');
            if (lastVisitedId == lastPostId)
                return;
            else {
                for (var i = 0; i < allPosts.length; i++) {
                    if (allPosts[i] > lastVisitedId) {
                        $('#clickable-row'+allPosts[i]).css('font-weight','bold');
                    }
                }
            }
        };
 
        $(document).ready(function() {
            var $dummy = $('div.clickable-row');
            setPostHover($dummy);
            $dummy.click(function(){
                var postId = $(this).attr('post-id');
                Nabble.loadPost(postId);
            });
 
            /* Code to open initial post */
            (function() {
            var _hash = Nabble.hash();
                var postId = allPosts[0];
                if (_hash && _hash != '#none')
                    postId = parseInt(_hash.substr(2));
                else if (_hash == '#none')
                    postId = allPosts.length == 1? allPosts[0] : null;
                if (postId) {
                    if (allPosts.indexOf(postId) >= 0) {
                        var $dummy = $('#clickable-row'+postId);
                        $dummy.click();
                    }
                }
            })();
        });
]]>
 
        var isFirst = true;
        Nabble.loadPost = function(nodeId) {
            if (loadedPosts.indexOf(nodeId) == -1) {
                $('#loading'+nodeId).show("fast");
                var url = "/"+"template/NamlServlet.jtp?macro=ajax_post&view=<n.view_name/>&node="+nodeId;
                $.get(url, function(data) {
                    $('#clickable-row'+nodeId).replaceWith(data);
 
                    var $dummy = $('#clickable-row'+nodeId);
                    var $full = $('#full-row'+nodeId);
 
                    /* Click event that collapses the post  */
                    $full.children('div.full-row-header').click(function(e){
                        var t = e.target;
                        if (t == this || $(t).hasClass('close') || (t.nodeName != 'A' && t.nodeName != 'IMG')) {
                            $full.slideUp("normal", function() {
                                $dummy.show();
                                Nabble.resizeFrames();
                            });
                        }
                    });
 
                    /* Click event that expands the post  */
                    $dummy.click(function() {
                        $dummy.hide();
                        $full.slideDown('normal',Nabble.resizeFrames);
                    });
                    setPostHover($dummy);
 
                    var $msg = $('#message'+nodeId);
                    if (Nabble.isEmbedded) {
                        $('img',$msg).load(Nabble.resizeFrames);
                    }
                    Nabble.searchHighlight($msg);
 
                    <n.ajax_post_custom_scripts/>
 
                    $full.slideDown('normal',function(){
                        Nabble.hideQuotes(this);
                        if (isFirst) {
                            var isRootPost = nodeId == allPosts[0];
                            if (Nabble.isEmbedded) {
                                if (Nabble.canScroll()) scrollTo(0,0);
                                var y = isRootPost? 1 : $full.offset().top-30;
                                Nabble.resizeFrames('', y);
                            } else {
                                scrollTo(0,0);
                                if (!isRootPost)
                                    scrollBy(0,$full.offset().top);
                            }
                            isFirst = false;
                        }
                    });
                    loadedPosts.push(nodeId);
                });
            }
        };
    </script>
    <n.call_later value="[n.page_node.id/]" param="markUnreadPosts"/>
</macro>