Comments: Only load JS for post/edit comments if we can actually comment
This commit is contained in:
@@ -73,32 +73,6 @@
|
|||||||
| {% block comment_scripts %}
|
| {% block comment_scripts %}
|
||||||
script.
|
script.
|
||||||
|
|
||||||
// If there's a comment link in the URL, scroll there
|
|
||||||
function scrollToLinkedComment() {
|
|
||||||
var scrollToId = location.hash;
|
|
||||||
if (scrollToId.length <= 1) return;
|
|
||||||
|
|
||||||
$(scrollToId)
|
|
||||||
.addClass('comment-linked')
|
|
||||||
.scrollHere();
|
|
||||||
}
|
|
||||||
$(scrollToLinkedComment);
|
|
||||||
|
|
||||||
|
|
||||||
$('#comment_field').autoResize();
|
|
||||||
|
|
||||||
// Initialize Markdown to later convert comment as we type
|
|
||||||
var convert = new Markdown.getSanitizingConverter();
|
|
||||||
Markdown.Extra.init(convert);
|
|
||||||
convert = convert.makeHtml;
|
|
||||||
|
|
||||||
// Submit new comment
|
|
||||||
$(document)
|
|
||||||
.off('click','body .comment-action-submit')
|
|
||||||
.on( 'click','body .comment-action-submit', function(e){
|
|
||||||
post_comment($(this));
|
|
||||||
});
|
|
||||||
|
|
||||||
{% if show_comments %}
|
{% if show_comments %}
|
||||||
$('body')
|
$('body')
|
||||||
.off('pillar:comment-posted')
|
.off('pillar:comment-posted')
|
||||||
@@ -111,9 +85,37 @@ script.
|
|||||||
$('#' + comment_node_id).scrollHere();
|
$('#' + comment_node_id).scrollHere();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// If there's a comment link in the URL, scroll there
|
||||||
|
function scrollToLinkedComment() {
|
||||||
|
var scrollToId = location.hash;
|
||||||
|
if (scrollToId.length <= 1) return;
|
||||||
|
|
||||||
|
$(scrollToId)
|
||||||
|
.addClass('comment-linked')
|
||||||
|
.scrollHere();
|
||||||
|
}
|
||||||
|
$(scrollToLinkedComment);
|
||||||
|
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
|
||||||
|
{% if can_post_comments %}
|
||||||
|
|
||||||
|
// If we can actually comment, load the tools to do it
|
||||||
|
|
||||||
|
// Initialize Markdown to later convert comment as we type
|
||||||
|
var convert = new Markdown.getSanitizingConverter();
|
||||||
|
Markdown.Extra.init(convert);
|
||||||
|
convert = convert.makeHtml;
|
||||||
|
|
||||||
|
// Submit new comment
|
||||||
|
$(document)
|
||||||
|
.off('click','body .comment-action-submit')
|
||||||
|
.on( 'click','body .comment-action-submit', function(e){
|
||||||
|
post_comment($(this));
|
||||||
|
});
|
||||||
|
|
||||||
// Writing comment
|
// Writing comment
|
||||||
// Markdown convert as we type in the textarea
|
// Markdown convert as we type in the textarea
|
||||||
$(document)
|
$(document)
|
||||||
@@ -142,6 +144,9 @@ script.
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Autoresize the textarea as we type
|
||||||
|
$('#comment_field').autoResize();
|
||||||
|
|
||||||
|
|
||||||
// Edit comment
|
// Edit comment
|
||||||
// Enter edit mode
|
// Enter edit mode
|
||||||
@@ -218,4 +223,6 @@ script.
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
| {% endblock %}
|
| {% endblock %}
|
||||||
|
Reference in New Issue
Block a user