_.Module.define({path:"common/component/PostorService",requires:[],sub:{_dataPostor:{ie:"utf-8",kw:"",fid:"",tid:"",vcode_md5:"",floor_num:"",quote_id:"",rich_text:1,tbs:"",content:"\u5185\u5bb9"},_isPosting:false,_postorUrl:{thread:"/f/commit/thread/add",reply:"/f/commit/post/add"},initial:function(a){},isCanPost:function(d){var b={login:false,canPost:0,noUn:false,isBlock:false,forbidFlag:0};var e=$.extend(true,b,d);if(!e.login){return{canPost:false,type:"login"}}if(e.login&&e.canPost==1&&e.noUn){return{canPost:false,type:"noUn"}}if(e.login&&e.canPost!=1){var a=parseInt(e.forbidFlag),c="";switch(a){case 1:c="login";break;case 2:c="old";break;case 3:c="balv";break;case 4:c="bawu";break;case 5:c="law";break}if(c==""&&!e.isBlock){c="isBlock"}return{canPos:false,type:c}}if(e.login&&e.canPost==1&&!e.noUn){return{canPost:true}}},genericRich:function(c){switch(c.type){case"smiley":var a=c.height,b=c.width;return'<img pic_type="" class="BDE_Smiley" src="'+c.src+'" height="'+a+'" width="'+b+'">';case"configSmile":var a=c.height,b=c.width;return'<img pic_type="" class="BDE_Smiley2" src="'+c.src+'" height="'+a+'" width="'+b+'" text="'+c.text+'">';break}},postHandler:function(c){var a=this;if(this._isPosting){return}this._isPosting=true;var b=c.url;if(!c.url){b=this._postorUrl[c.type]}c.data.new_vcode=1;c.data.tag=11;this.post(b,c.data,function(d){a.showAddResult(d,c.success,c.error,c.context,c)})},captchaHandler:function(c,b){var a=this;_.Module.use("common/component/CaptchaDialog",{message:c.data.vcode.str_reason,vCode:c.data.vcode.captcha_vcode_str,vCodeType:c.data.vcode.captcha_code_type,forumName:b.data.kw,forumId:b.data.fid,isAnonymous:b.data.anonymous,postType:b.type,paramsCallback:function(){var d=b.data;var e={content:d.content,title:d.title};if(b.type=="reply"){e.tid=PageData.thread.id}return e}},function(d){a.captchaDialog=d;d.bind("onclose",function(){d.hide();if(b.captchaCloseCallback){b.captchaCloseCallback()}return false});d.bind("onaccept",function(){var e=b.data;e.vcode=d.getInputValue();e.vcode_md5=d.getVCode();a.postHandler(b)});d.show()})},_showErrorTip:function(a,d){var b='<div style="margin: 0px 30px 0px 30px;font-size:14px;line-height:20px;text-align:left;font-family: "\u5b8b\u4f53";"><table style="width:90%"><tbody><tr><td width="60">'+a.image+'</td><td valign="middle" style="font-size:20px;line-height:22px;font-family: "\u9ed1\u4f53";">'+a.subMessage+"</td></tr></tbody></table>"+a.message+"</div>";var c=$.dialog.alert(b,a.dialogSet);c.bind("onclose",d)},showAddResult:function(g,e,d,a,c){Thread_add_result.init(g);var f=Thread_add_result.resultNo;var h=this;if(f==0){e(g.data,a);h._isPosting=false}else{var i=Thread_add_result.getMessage();if(Thread_add_result.isNeedWaitForCheck()){var b={image:'<img style="border:none;" src="http://static.tieba.baidu.com/tb/img/messageFace.gif">',subMessage:"\u7b49\u5f85\u5ba1\u6838...",message:i,dialogSet:{width:380,height:105,title:"\u53d1\u8868\u8d34\u5b50"}};h._showErrorTip(b,function(){h.trigger("onCheckError");return true});h._isPosting=false;return}if(Thread_add_result.isNeedBindPhone()){return}if(f==40){h.captchaHandler(g,c);h._isPosting=false}else{var b={image:'<img style="border:none;" src="http://static.tieba.baidu.com/tb/img/errorFace.gif">',subMessage:"\u53d1\u8d34\u5931\u8d25",message:i,dialogSet:{width:410,height:95,title:"\u53d1\u8868\u8d34\u5b50"}};h._showErrorTip(b,function(){h.trigger("onError",[i,f]);return true});h._isPosting=false}}},post:function(a,b,d,c){$.ajax({type:"post",async:true,dataType:"json",url:a,data:b,success:function(e){if(d){d(e)}}})}}});