define(["ember","text!./table-tmpl.hbs","./audio"],function(a,b,c){return a.View.extend({layout:a.Handlebars.compile(b),classNames:["topic-table","topic-table-default"],classNameBindings:["styleClasses"],styleClasses:function(){return"topic-table-"+this.get("model.properties.TopictypeCode").toLowerCase()}.property(),captionHeight:function(){if(!this.get("model.data.Summary"))return 0;var a=parseInt(.15*this.get("model.style.height"));return a>=50?50:25>=a?25:a}.property("model.style.height"),captionStyle:function(){return"height:%@px;".fmt(this.get("captionHeight"))}.property("captionHeight"),mainHeight:function(){return this.get("model.style.height")-this.get("captionHeight")}.property("model.style.height"),mainStyle:function(){return"height:%@px;".fmt(this.get("mainHeight"))}.property("mainHeight"),initialize:function(){this.get("model.data.AideoUrl")&&this.set("audio",c.create({src:this.get("model.data.AideoUrl")}))}.on("init"),table:function(){var a=this,b=this.get("model.properties"),c=this.get("model.data.resource")||this.get("model.properties.rows"),d={thead:[],tbody:[]};return c&&0!=c.length&&c.sortBy("RowName").forEach(function(c,e){var f=[];if(d.tbody.push({className:"row-"+e,cells:f}),f.push({type:"text",mode:"empty",data:{resource:c.get("RowName")}}),0==e&&d.thead.push({data:"评论项"}),("TableAssess"==b.get("TopictypeCode")||"TableMultiple"==b.get("TopictypeCode"))&&(0==e&&d.thead.push({data:"评论"}),f.push({type:"text",mode:"empty",data:{resource:c.get("RowContent")}})),"TableScore"==b.get("TopictypeCode")||"TableMultiple"==b.get("TopictypeCode")){0==e&&d.thead.push({data:"得分"});for(var g=new Array(c.get("TotalScore")),h=a.get("model.data.resource")?parseInt(c.get("Score")):c.get("TotalScore")-1,i=0;h>i;i++)g[i]=1;f.push({type:"score",data:g})}d.thead.forEach(function(a,b){a.className="col-"+b})}),d}.property("model.properties.rows","model.data.resource")})});