Skip to content

Commit 80a4cae

Browse files
committed
Merge pull request #70 from dingoblog/comment_js
Optimize front-end JS script
2 parents d02c275 + 2d45be3 commit 80a4cae

File tree

2 files changed

+9
-5
lines changed

2 files changed

+9
-5
lines changed

view/default/assets/src/js/home.js

+5-3
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,17 @@ function initComment() {
4141
tpl.find(".comment-name").attr("href", json.comment.website).text(json.comment.author);
4242
tpl.find(".comment-reply").attr("rel", json.comment.id);
4343
tpl.find(".comment-content").html("<p>" + json.comment.content + "</p>");
44-
var date = new Date(json.comment.create_time);
4544
tpl.find(".comment-message").html("Your comment is awaiting moderation.");
4645
tpl.attr("id", "comment-" + json.comment.id);
4746
if (json.comment.status == "approved") {
4847
tpl.find(".comment-check").remove();
4948
}
5049
var parentId = $('#comment-parent').val();
51-
tpl.insertAfter($('#comment-' + parentId));
50+
if (parentId === '0') {
51+
$('#comment-list').append(tpl);
52+
} else {
53+
tpl.insertAfter($('#comment-' + parentId));
54+
}
5255
$('#comment-cancel').trigger("click");
5356
$('#comment-content').val("");
5457
} else {
@@ -62,7 +65,6 @@ function initComment() {
6265
form.removeClass("hide").insertAfter($(this));
6366
$('#comment-show').hide();
6467
$('#comment-parent').val(id);
65-
$('#comment-form').removeClass("hide");
6668
$('.cancel-reply').show();
6769
var top = parentComment.offset().top;
6870
$('body,html').animate({scrollTop: top}, 500);

view/default/assets/src/js/navbar.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,16 @@ $(document).ready(function () {
22
$('#mobile-nav-trigger').click(function (el) {
33
el.preventDefault();
44

5+
var nav = $('#nav');
6+
57
if ($(this).hasClass('active')) {
68
$(this).removeClass('active');
79
$(this).html('Show Navigation');
8-
$('#nav ul.nav').slideUp('fast').removeClass('active');
10+
nav.find('ul.nav').slideUp('fast').removeClass('active');
911
} else {
1012
$(this).addClass('active');
1113
$(this).html('Close Navigation');
12-
$('#nav ul.nav').slideDown('fast').addClass('active');
14+
nav.find('ul.nav').slideDown('fast').addClass('active');
1315
}
1416
});
1517
});

0 commit comments

Comments
 (0)