﻿
Ext.onReady(

	function(){ 

		Ext.QuickTips.init(); // 要使用HtmlEditor,必须要有这个调用
	
		var edt = new Ext.form.HtmlEditor(
		
			{
			id:'UIFeedBackEditor',
			hideLabel: true,
			enableSourceEdit:false,
			height:280,
			name: 'content', // 内容的form名,
			value: Ext.util.Format.htmlDecode('')
			// 初始值
			}
		);
		
		edt.render('EditPanel');
				
	}
)

function Save(){

    if(Ext.get('UIGuestName').dom.value==""){Ext.Msg.alert('失败','请填写你的称呼^_^!');return;}
    if(Ext.getCmp('UIFeedBackEditor').getDoc().body.innerHTML.trim()==""){Ext.Msg.alert('失败','留言内容为空不太好吧^_^!');return;}
    Ext.Ajax.request(
        {
             url:'WSCBF107.asmx/PublishFeedBack',
             method:'Post',
             params:{
                 itemId:Ext.get('ItemId').dom.value,
                 guestName:Ext.get('UIGuestName').dom.value,
                 feedbackContent:Ext.getCmp("UIFeedBackEditor").getValue()
             },
             success:function(req){
                 //Ext.Msg.alert('成功','发布成功');
                 Ext.get('FeedBackPanel')
                 
                 var ir = document.createElement("div");
                 
                 var iimg = document.createElement("img");                 
                 iimg.setAttribute("src","pic/note_yellow.gif");
                 
                 var ig = document.createElement("span");
                 ig.appendChild(document.createTextNode(Ext.get('UIGuestName').dom.value));
                 
                 var today = new Date();
                 var id = document.createElement("span");
                 id.appendChild(
                    document.createTextNode(
                      today.toLocaleString().replace("年","-").replace("月","-").replace("日","")
                    )
                 );
                                  
                 var ic=document.createElement("div");
                 ic.innerHTML=Ext.getCmp("UIFeedBackEditor").getValue();
                                  
                 iimg.setAttribute("class", "feedbackImg");
                 ig.setAttribute("class", "feedbackGuestName");
                 id.setAttribute("class","feedbackDate"); 
                 ic.setAttribute("class","feedbackContent"); 
                 ir.setAttribute("class","feedbackRow");
                                                  
                 ir.appendChild(iimg);
                 ir.appendChild(ig);
                 ir.appendChild(id);
                 ir.appendChild(ic);
                                                                                  
                 Ext.get('SelfFeedbackPanel').dom.insertBefore(ir,Ext.get('SelfFeedbackPanel').dom.firstChild);
                 
             }
             ,
            failure: function(req) {
                Ext.Msg.alert('错误', req.responseText);
            } 
        }
    );   
}
