sns_store.js 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. $(function(){
  2. //展示和隐藏评论列表
  3. $("[nc_type='sd_commentbtn']").live('click',function(){
  4. var $this = $(this);
  5. $.get('index.php?act=index&op=login', function(result){
  6. if(result=='0'){
  7. login_dialog();
  8. }else{
  9. var data = $this.attr('data-param');
  10. eval("data = "+data);
  11. //隐藏转发模块
  12. $('#forward_'+data.txtid).hide();
  13. if($('#tracereply_'+data.txtid).css("display")=='none'){
  14. //加载评论列表
  15. $("#tracereply_"+data.txtid).load('index.php?act=store_snshome&op=commenttop&id='+data.txtid);
  16. $('#tracereply_'+data.txtid).show();
  17. }else{
  18. $('#tracereply_'+data.txtid).hide();
  19. }
  20. return false;
  21. }
  22. });
  23. });
  24. //评论提交
  25. $("[nc_type='scommentbtn']").live('click',function(){
  26. var data = $(this).attr('data-param');
  27. eval("data = "+data);
  28. if($("#commentform_"+data.txtid).valid()){
  29. var cookienum = $.cookie(COOKIE_PRE+'commentnum');
  30. cookienum = parseInt(cookienum);
  31. if(cookienum >= MAX_RECORDNUM && $("#commentseccode"+data.txtid).css('display')=="none"){
  32. //显示验证码
  33. $("#commentseccode"+data.txtid).show();
  34. var nchash = $("#commentseccode"+data.txtid).find("[name='nchash']").val();
  35. $("#commentseccode"+data.txtid).find("[name='codeimage']").attr('src','index.php?act=seccode&op=makecode&nchash='+nchash+'&t=' + Math.random());
  36. }else if(cookienum >= MAX_RECORDNUM && $("#commentseccode"+data.txtid).find("[name='captcha']").val() == ''){
  37. showDialog('请填写验证码');
  38. }else{
  39. ajaxpost('commentform_'+data.txtid, '', '', 'onerror');
  40. //隐藏验证码
  41. $("#commentseccode"+data.txtid).hide();
  42. $("#commentseccode"+data.txtid).find("[name='codeimage']").attr('src','');
  43. $("#commentseccode"+data.txtid).find("[name='captcha']").val('');
  44. }
  45. }
  46. return false;
  47. });
  48. //删除评论
  49. $("[nc_type='scomment_del']").live('click',function(){
  50. var obj = $(this);
  51. showDialog('您确定要删除该信息吗?','confirm', '', function(){
  52. var data_str = $(obj).attr('data-param');
  53. eval("data_str = "+data_str);
  54. ajax_get_confirm('','index.php?act=store_snshome&op=delcomment&scid='+data_str.scid+'&stid='+data_str.stid);
  55. return false;
  56. });
  57. });
  58. //展示和隐藏转发表单
  59. $("[nc_type='sd_forwardbtn']").live('click',function(){
  60. var $this = $(this);
  61. $.get('index.php?act=index&op=login', function(result){
  62. if(result=='0'){
  63. login_dialog();
  64. }else{
  65. var data = $this.attr('data-param');
  66. eval("data = "+data);
  67. //隐藏评论模块
  68. $('#tracereply_'+data.txtid).hide();
  69. if($('#forward_'+data.txtid).css("display")=='none'){
  70. $('#forward_'+data.txtid).show();
  71. //添加字数提示
  72. if($("#forwardcharcount"+data.txtid).html() == ''){
  73. $("#content_forward"+data.txtid).charCount({
  74. allowed: 140,
  75. warning: 10,
  76. counterContainerID:'forwardcharcount'+data.txtid,
  77. firstCounterText:'还可以输入',
  78. endCounterText:'字',
  79. errorCounterText:'已经超出'
  80. });
  81. }
  82. //绑定表单验证
  83. $('#forwardform_'+data.txtid).validate({
  84. errorPlacement: function(error, element){
  85. element.next('.error').append(error);
  86. },
  87. rules : {
  88. forwardcontent : {
  89. maxlength : 140
  90. }
  91. },
  92. messages : {
  93. forwardcontent : {
  94. maxlength: '不能超过140字'
  95. }
  96. }
  97. });
  98. }else{
  99. $('#forward_'+data.txtid).hide();
  100. }
  101. return false;
  102. }
  103. });
  104. });
  105. //转发提交
  106. $("[nc_type='s_forwardbtn']").live('click',function(){
  107. var data = $(this).attr('data-param');
  108. var form = $(this).parents('form:first');
  109. var seccode = $("#forwardseccode"+data.txtid);
  110. eval("data = "+data);
  111. if(form.valid()){
  112. var cookienum = $.cookie(COOKIE_PRE+'forwardnum');
  113. cookienum = parseInt(cookienum);
  114. if(!isNaN(cookienum) && cookienum >= MAX_RECORDNUM){
  115. if (seccode.css('display') == 'none') {
  116. //显示验证码
  117. seccode.show();
  118. var nchash = seccode.find("[name='nchash']").val();
  119. seccode.find("[name='codeimage']").attr('src','index.php?act=seccode&op=makecode&nchash='+nchash+'&t=' + Math.random());
  120. } else if(seccode.find("[name='captcha']").val() == ''){
  121. showDialog('请填写验证码');
  122. }
  123. }else{
  124. ajaxpost('forwardform_'+data.txtid, '', '', 'onerror');
  125. //隐藏验证码
  126. seccode.hide().find("[name='codeimage']").attr('src','').end().find("[name='captcha']").val('');
  127. //隐藏表单
  128. $('#forward_'+data.txtid).hide();
  129. $('#content_forward'+data.txtid).val('');
  130. }
  131. }
  132. return false;
  133. });
  134. //删除动态
  135. $("[nc_type='sd_del']").live('click',function(){
  136. var data_str = $(this).attr('data-param');
  137. eval("data_str = "+data_str);
  138. var url = "index.php?act=store_snshome&op=deltrace&id="+data_str.txtid;
  139. showDialog('您确定要删除该信息吗?','confirm', '', function(){
  140. ajaxget(url);
  141. return false;
  142. });
  143. });
  144. // 查看大图
  145. $('[nc_type="thumb-image"]').die().live('click',function(){
  146. src = $(this).find('img').attr('src');
  147. max_src = src.replace('_240.', '_1280.');
  148. $(this).parent().hide().next().children('[nc_type="origin-image"]').append('<img src="'+max_src+'" />').end().show();
  149. });
  150. $('[nc_type="origin-image"]').die().live('click',function(){
  151. $(this).html('').parent().hide().prev().show();
  152. });
  153. });