1
0
Fork 0
mirror of https://github.com/Oreolek/ifhub.club.git synced 2024-07-05 16:04:24 +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'); $('#comment-button-submit').attr('disabled', 'disabled');
ls.ajax(this.options.type[targetType].url_add, formObj.serializeJSON(), function(result){ ls.ajax(this.options.type[targetType].url_add, formObj.serializeJSON(), function(result){
$('#comment-button-submit').removeAttr('disabled');
if (!result) { if (!result) {
this.enableFormComment(); this.enableFormComment();
ls.msg.error('Error','Please try again later'); ls.msg.error('Error','Please try again later');
@ -59,7 +60,6 @@ ls.comments = (function ($) {
// Load new comments // Load new comments
this.load(targetId, targetType, result.sCommentId, true); this.load(targetId, targetType, result.sCommentId, true);
} }
$('#comment-button-submit').attr('disabled', '');
}.bind(this)); }.bind(this));
} }
@ -232,6 +232,38 @@ ls.comments = (function ($) {
return false; 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.init = function() {
this.initEvent(); this.initEvent();
this.calcNewComments(); this.calcNewComments();
@ -249,12 +281,20 @@ ls.comments = (function ($) {
return false; return false;
} }
}); });
$(".folding").click(function(e){
if ($(e.target).hasClass("folded")) {
this.expandComment(e.target);
} else {
this.collapseComment(e.target);
}
}.bind(this));
} }
return this; return this;
}).call(ls.comments || {},jQuery); }).call(ls.comments || {},jQuery);
$(document).ready(function(){ jQuery(document).ready(function(){
ls.comments.init(); ls.comments.init();
}); });

View file

@ -12,8 +12,8 @@
{if $sTargetType=='topic'} {if $sTargetType=='topic'}
<a href="{router page='rss'}comments/{$iTargetId}/" class="rss">RSS</a> <a href="{router page='rss'}comments/{$iTargetId}/" class="rss">RSS</a>
{/if} {/if}
<a href="#" onclick="lsCmtTree.collapseNodeAll(); return false;" onfocus="blur();">{$aLang.comment_collapse}</a> / <a href="#" onclick="ls.comments.collapseCommentAll(); 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.expandCommentAll(); return false;" onfocus="blur();">{$aLang.comment_expand}</a>
</div> </div>
<a name="comments"></a> <a name="comments"></a>
@ -106,7 +106,7 @@
<script type="text/javascript"> <script type="text/javascript">
jQuery(document).ready(function($){ 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"}); 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()); $('#form_comment_text').markItUp(getMarkitupCommentSettings());
}); });
</script> </script>

View file

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