//个人动态 $(function(){ function init_editor(params){ var editor = params.kindutil.create(params.textarea, { resizeType : 1,minWidth:"1px",width:"100%",height:"80px", items:['emoticons'], afterChange:function(){//按键事件 nh_check_field({content:this,contentmsg:params.contentmsg,textarea:params.textarea}); }, afterCreate:function(){ var toolbar = $("div[class='ke-toolbar']",params.div_form); $(".ke-outline>.ke-toolbar-icon",toolbar).append('表情'); params.toolbar_container.append(toolbar); } }).loadPlugin('paste'); return editor; } function nh_check_field(params){ var result=true; if(params.content!=undefined){ if(params.content.isEmpty()){ result=false; } if(params.content.html()!=params.textarea.html() || params.issubmit==true){ params.textarea.html(params.content.html()); params.content.sync(); if(params.content.isEmpty()){ params.contentmsg.html('内容不能为空'); params.contentmsg.css({color:'#ff0000'}); }else{ params.contentmsg.html('填写正确'); params.contentmsg.css({color:'#008000'}); } params.contentmsg.show(); } } return result; } function init_form(params){ params.form.submit(function(){ var flag = false; if(params.form.attr('data-remote') != undefined ){ flag = true } var is_checked = nh_check_field({ issubmit:true, content:params.editor, contentmsg:params.contentmsg, textarea:params.textarea }); if(is_checked){ if(flag){ return true; }else{ $(this)[0].submit(); return false; } } return false; }); } function nh_reset_form(params){ params.form[0].reset(); params.textarea.empty(); if(params.editor != undefined){ params.editor.html(params.textarea.html()); } params.contentmsg.hide(); } KindEditor.ready(function(K){ $("a[nhname='reply_btn']").live('click',function(){ var params = {}; params.kindutil = K; params.container = $(this).parent().parent('div'); params.div_form = $("div[nhname='div_form']",params.container); params.form = $("form",params.div_form); params.textarea = $("textarea[name='user_notes']",params.div_form); params.textarea.prev('div').css("height","60px"); params.contentmsg = $("p[nhname='contentmsg']",params.div_form); params.toolbar_container = $("div[nhname='toolbar_container']",params.div_form); params.cancel_btn = $("a[nhname='cancel_btn']",params.div_form); params.submit_btn = $("a[nhname='submit_btn']",params.div_form); if(params.textarea.data('init') == undefined){ params.editor = init_editor(params); init_form(params); params.cancel_btn.click(function(){ nh_reset_form(params); toggleAndSettingWordsVal(params.div_form, params.textarea); }); params.submit_btn.click(function(){ params.form.submit(); }); params.textarea.data('init',1); } params.cancel_btn.click(); setTimeout(function(){ if(!params.div_form.is(':hidden')){ params.textarea.show(); params.textarea.focus(); params.textarea.hide(); } },300); }); $("a[nhname='sub_reply_btn']").live('click',function(){ var params = {}; params.kindutil = K; params.container = $(this).parent().parent('div'); params.div_form = $("div[nhname='sub_div_form']",params.container); params.form = $("form",params.div_form); params.textarea = $("textarea[name='user_notes']",params.div_form); params.textarea.prev('div').css("height","60px"); params.contentmsg = $("p[nhname='sub_contentmsg']",params.div_form); params.toolbar_container = $("div[nhname='sub_toolbar_container']",params.div_form); params.cancel_btn = $("a[nhname='sub_cancel_btn']",params.div_form); params.submit_btn = $("a[nhname='sub_submit_btn']",params.div_form); if(params.textarea.data('init') == undefined){ params.editor = init_editor(params); init_form(params); params.cancel_btn.click(function(){ nh_reset_form(params); toggleAndSettingWordsVal(params.div_form, params.textarea); }); params.submit_btn.click(function(){ params.form.submit(); }); params.textarea.data('init',1); } params.cancel_btn.click(); setTimeout(function(){ if(!params.div_form.is(':hidden')){ params.textarea.show(); params.textarea.focus(); params.textarea.hide(); } },300); }); $("div[nhname='new_message']").each(function(){ var params = {}; params.kindutil = K; params.div_form = $(this); params.form = $("form",params.div_form); if(params.form==undefined || params.form.length==0){ return; } params.textarea = $("textarea[nhname='new_message_textarea']",params.div_form); params.contentmsg = $("p[nhname='contentmsg']",params.div_form); params.toolbar_container = $("div[nhname='toolbar_container']",params.div_form); params.cancel_btn = $("#new_message_cancel_btn"); params.submit_btn = $("#new_message_submit_btn"); if(params.textarea.data('init') == undefined){ params.editor = init_editor(params); init_form(params); params.cancel_btn.click(function(){ nh_reset_form(params); }); params.submit_btn.click(function(){ params.form.submit(); }); params.textarea.data('init',1); $(this).show(); } }); }); }); function init_list_more_div(params){ var p=params; p.exbtn.click(function(){ var isclose = p.container.data('isclose'); var hasmore = p.container.data('hasmore'); if(isclose == '1'){ $("div[nhname='rec']",p.container).show(); p.container.data('isclose','0'); change_status_4_list_more_div(params); return; } if(hasmore == '0'){ change_status_4_list_more_div(params,'get'); return; } var url = p.container.data('url'); if($("div[nhname='rec']",p.container).length > 0){ var lastid = $("div[nhname='rec']",p.container).filter(':last').data('id'); url += "?lastid="+lastid; var lasttime = $("div[nhname='rec']",p.container).filter(':last').data('time'); if(lasttime != undefined){ url += "&lasttime="+lasttime; } } $.ajax( {url:url,dataType:'text',success:function(data){ var html = $("