1
0
Fork 0
mirror of https://github.com/Oreolek/ifhub.club.git synced 2024-07-01 05:55:02 +03:00

fix comment jquery

This commit is contained in:
Mzhelskiy Maxim 2011-08-09 07:45:04 +00:00
parent 5dc5cffb7b
commit e737a62ebf
3 changed files with 76 additions and 11 deletions

View file

@ -44,6 +44,7 @@ ls.comments = (function ($) {
$('#comment-button-submit').attr('disabled', 'disabled');
ls.ajax(this.options.type[targetType].url_add, formObj.serializeJSON(), function(result){
$('#comment-button-submit').removeAttr('disabled');
if (!result) {
this.enableFormComment();
ls.msg.error('Error','Please try again later');
@ -59,7 +60,6 @@ ls.comments = (function ($) {
// Load new comments
this.load(targetId, targetType, result.sCommentId, true);
}
$('#comment-button-submit').attr('disabled', '');
}.bind(this));
}
@ -231,6 +231,38 @@ ls.comments = (function ($) {
this.scrollToComment(pid);
return false;
}
// Сворачивание комментариев
this.checkFolding = function() {
$(".folding").each(function(index, element){
if ($(element).parent(".comment").next(".comment-wrapper").length == 0) {
$(element).hide();
} else {
$(element).show();
}
});
return false;
}
this.expandComment = function(folding) {
$(folding).removeClass("folded").parent().nextAll(".comment-wrapper").show();
}
this.collapseComment = function(folding) {
$(folding).addClass("folded").parent().nextAll(".comment-wrapper").hide();
}
this.expandCommentAll = function() {
$.each($(".folding"),function(k,v){
this.expandComment(v);
}.bind(this))
}
this.collapseCommentAll = function() {
$.each($(".folding"),function(k,v){
this.collapseComment(v);
}.bind(this))
}
this.init = function() {
this.initEvent();
@ -249,12 +281,20 @@ ls.comments = (function ($) {
return false;
}
});
$(".folding").click(function(e){
if ($(e.target).hasClass("folded")) {
this.expandComment(e.target);
} else {
this.collapseComment(e.target);
}
}.bind(this));
}
return this;
}).call(ls.comments || {},jQuery);
$(document).ready(function(){
jQuery(document).ready(function(){
ls.comments.init();
});

View file

@ -12,8 +12,8 @@
{if $sTargetType=='topic'}
<a href="{router page='rss'}comments/{$iTargetId}/" class="rss">RSS</a>
{/if}
<a href="#" onclick="lsCmtTree.collapseNodeAll(); return false;" onfocus="blur();">{$aLang.comment_collapse}</a> /
<a href="#" onclick="lsCmtTree.expandNodeAll(); return false;" onfocus="blur();">{$aLang.comment_expand}</a>
<a href="#" onclick="ls.comments.collapseCommentAll(); return false;" onfocus="blur();">{$aLang.comment_collapse}</a> /
<a href="#" onclick="ls.comments.expandCommentAll(); return false;" onfocus="blur();">{$aLang.comment_expand}</a>
</div>
<a name="comments"></a>
@ -106,7 +106,7 @@
<script type="text/javascript">
jQuery(document).ready(function($){
ls.lang.load({lang_load name="panel_b,panel_i,panel_u,panel_s,panel_url,panel_url_promt,panel_code,panel_video,panel_image,panel_cut,panel_quote,panel_list,panel_list_ul,panel_list_ol,panel_title,panel_clear_tags,panel_video_promt,panel_list_li"});
// Ïîäêëþ÷àåì ðåäàêòîð
// Подключаем редактор
$('#form_comment_text').markItUp(getMarkitupCommentSettings());
});
</script>

View file

@ -44,6 +44,7 @@ ls.comments = (function ($) {
$('#comment-button-submit').attr('disabled', 'disabled');
ls.ajax(this.options.type[targetType].url_add, formObj.serializeJSON(), function(result){
$('#comment-button-submit').removeAttr('disabled');
if (!result) {
this.enableFormComment();
ls.msg.error('Error','Please try again later');
@ -59,7 +60,6 @@ ls.comments = (function ($) {
// Load new comments
this.load(targetId, targetType, result.sCommentId, true);
}
$('#comment-button-submit').attr('disabled', '');
}.bind(this));
}
@ -240,12 +240,33 @@ ls.comments = (function ($) {
$(".folding").each(function(index, element){
if ($(element).parent(".comment").next(".comment-wrapper").length == 0) {
$(element).hide();
} else {
$(element).show();
}
});
return false;
}
this.expandComment = function(folding) {
$(folding).removeClass("folded").parent().nextAll(".comment-wrapper").show();
}
this.collapseComment = function(folding) {
$(folding).addClass("folded").parent().nextAll(".comment-wrapper").hide();
}
this.expandCommentAll = function() {
$.each($(".folding"),function(k,v){
this.expandComment(v);
}.bind(this))
}
this.collapseCommentAll = function() {
$.each($(".folding"),function(k,v){
this.collapseComment(v);
}.bind(this))
}
this.init = function() {
this.initEvent();
this.calcNewComments();
@ -264,16 +285,20 @@ ls.comments = (function ($) {
return false;
}
});
$(".folding").click(function(e){
if ($(e.target).hasClass("folded")) {
this.expandComment(e.target);
} else {
this.collapseComment(e.target);
}
}.bind(this));
}
return this;
}).call(ls.comments || {},jQuery);
$(document).ready(function(){
jQuery(document).ready(function(){
ls.comments.init();
$(".folding").click(function(){
$(this).toggleClass("folded").parent().nextAll(".comment-wrapper").toggle();
});
});