mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-10-13 00:44:55 +08:00
2 lines
2.2 KiB
JavaScript
2 lines
2.2 KiB
JavaScript
define(["utils/utils"],function(a){var b=Backbone.View.extend({initialize:function(b){this.options=a.merge(b,{content:"No content available.",onchange:null,ondblclick:null,onconfirm:null,cls:"ui-table",selectable:!0,cls_tr:""}),this.setElement(this._template()),this.$thead=this.$("thead"),this.$tbody=this.$("tbody"),this.$tmessage=this.$("tmessage"),this.row=this._row(),this.row_count=0},events:{click:"_onclick",dblclick:"_ondblclick"},addHeader:function(a){this.row.append($("<th/>").append(a))},appendHeader:function(){this.$thead.append(this.row),this.row=$("<tr/>")},add:function(a,b,c){var d=$("<td/>");b&&d.css("width",b),c&&d.css("text-align",c),this.row.append(d.append(a))},append:function(a,b){this._commit(a,b,!1)},prepend:function(a,b){this._commit(a,b,!0)},get:function(a){return this.$("#"+a)},del:function(a){var b=this.$tbody.find("#"+a);b.length>0&&(b.remove(),this.row_count--,this._refresh())},delAll:function(){this.$tbody.empty(),this.row_count=0,this._refresh()},value:function(a){if(this.options.selectable){this.before=this.$tbody.find(".current").attr("id"),void 0!==a&&(this.$tbody.find("tr").removeClass("current"),a&&this.$tbody.find("#"+a).addClass("current"));var b=this.$tbody.find(".current").attr("id");return void 0===b?null:(b!=this.before&&this.options.onchange&&this.options.onchange(a),b)}},size:function(){return this.$tbody.find("tr").length},_commit:function(a,b,c){this.del(a),this.row.attr("id",a),c?this.$tbody.prepend(this.row):this.$tbody.append(this.row),b&&(this.row.hide(),this.row.fadeIn()),this.row=this._row(),this.row_count++,this._refresh()},_row:function(){return $('<tr class="'+this.options.cls_tr+'"></tr>')},_onclick:function(a){var b=this.value(),c=$(a.target).closest("tr").attr("id");""!=c&&c&&b!=c&&(this.options.onconfirm?this.options.onconfirm(c):this.value(c))},_ondblclick:function(){var a=this.value();a&&this.options.ondblclick&&this.options.ondblclick(a)},_refresh:function(){0==this.row_count?this.$tmessage.show():this.$tmessage.hide()},_template:function(){return'<div><table class="'+this.options.cls+'"><thead/><tbody/></table><tmessage>'+this.options.content+"</tmessage><div>"}});return{View:b}});
|
|
//# sourceMappingURL=../../../maps/mvc/ui/ui-table.js.map
|