1 line
81 KiB
JavaScript
1 line
81 KiB
JavaScript
|
|
var bt_tools={commandConnectionPool:{},table:function(a){function b(c){this.config=c;this.$load()}b.prototype={style_list:[],event_list:{},checkbox_list:[],batch_active:{},event_rows_model:{},data:[],page:"",column:[],batch_thread:[],random:bt.get_random(5),init:false,checked:false,$load:function(){var d=this,c=$('<input type="checkbox" id="checked_'+d.random+'" style="font-size:0;position:fixed;left:-9999999px;"/>');if(this.config.init){this.config.init(this)}$(this.config.el).addClass("bt_table").append(c);c.focus(function(){d.checked=true;return false}).blur(function(e){d.checked=false;if(d.checked_blur){d.checked_blur(e)}});if(this.config.minWidth){this.style_list.push({className:this.config.el+" table",css:("min-width:"+this.config.minWidth)})}if(this.config.tootls){this.$reader_tootls(this.config.tootls)}else{console.log(this.config.height);if($(d.config.el+".divtable").length===0){$(d.config.el).append('<div class="divtable mtb10" style="heigth:'+(this.config.height||"auto")+'"></div>')}}this.$reader_content();if(d.config.url!==undefined){this.$refresh_table_list()}else{if(this.config.data!==undefined){this.$reader_content(this.config.data)}else{alert(lan["public"].miss_data_or_url)}}if(this.config.methods){$.extend(this,this.config.methods)}},$refresh_table_list:function(d){var c=this,e;if(d){e=bt.load(lan.database.get_data)}this.$http(function(g,f){if(d){e.close()}c.$reader_content(g,f)})},$active_focus:function(d){var c=this;$("#checked_"+c.random).focus();this.checked_blur=function(e){setTimeout(function(){if(d){d(e)}delete c.checked_blur},200)}},$reader_content:function(u,h){var v=this,r="",c="",q=0,g=this.config.column,f={},n=$(v.config.el+" .checkbox_"+v.random);u=u||[];this.data=u;if(n.length){n.removeClass("active selected");v.checkbox_list=[];v.$set_batch_view()}do{var k=u[q],m=0;if(u.length>0){c+="<tr>"}for(var p=0;p<g.length;p++){var s=g[p];if($.isEmptyObject(s)){m++;continue}if(q===0&&!this.init){if(!this.init){this.style_list.push(this.$dynamic_merge_style(s,p-m))}var d="sort_"+this.random+"",l="checkbox_"+this.random,o=s.sortValue||"desc";r+="<th><span "+(s.sort?'class="not-select '+d+(s.sortValue?" sort-active":"")+' cursor-pointer"':"")+' data-index="'+p+'" '+(s.sort?'data-sort="'+o+'"':"")+">"+(s.type=="checkbox"?'<label><i class="cust—checkbox cursor-pointer '+l+'" data-checkbox="all"></i><input type="checkbox" class="cust—checkbox-input"></label>':"<span>"+s.title+"</span>")+(s.sort?'<span class="glyphicon glyphicon-triangle-'+(o=="desc"?"bottom":"top")+' ml5"></span>':"")+"</span></th>";if(q===0){if(!f[d]&&s.sort){f[d]={event:this.config.sortEvent,eventType:"click",type:"sort"}}if(!f[l]){f[l]={event:s.checked,eventType:"click",type:"checkbox"}}}}if(k!==undefined){var t="",e="event-"+s.fid+"-"+this.random;if(s.template){t=v.$custom_template_render(s,k,p)}else{t=this.$reader_column_type(s,k);f=$.extend(f,t[1]);t=t[0]}c+="<td><span "+(s["class"]?'class="'+s["class"]+'"':"")+" "+(s.tips?'title="'+s.tips+'"':"")+">"+t+"</span></td>";if(q===0){if(!f[e]&&s.event){f[e]={event:s.event,eventType:"click",type:"rows"}}}}}if(u.length>0){c+="</tr>"}if(u.length==0){c+='<tr><td colspan="'+(g.length-m)+'" style="text-align:center;">'+(this.config["default"]||lan["public"].empty)+"</td></tr>"}q++}while(q<u.length);if(!this.init){this.$style_bind(this.style_list)}this.$event_bind(f);if(!this.init){$(this.config.el+" .divtable").append('<table class="table table-hover"><thead>'+r+"</thead><tbody>"+c+"</tbody></table></div></div>")}else{$(this.config.el+" .divtable tbody").html(c);if(this.config.page&&h){$(this.config.el+" .page").replaceWith(this.$reader_page(this.config.page,h))}}this.init=true;if(this.config.success){this.config.success(this)}},$custom_template_render:function(g,h,d){var e="event-"+g.fid+"-"+this.random,f=g.template(h,d),c=$(f);if(c.length>0){template=c.addClass(e)[0].outerHTML}else{if(g.type==="text"){template='<span class="'+e+'">'+f+"</span>"}else{template='<a href="javascript:;" class="btlink '+e+'">'+f+"</a>"}}return template},$modify_row_data:function(e){this.event_rows_model.rows=$.
|