mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-09-24 16:30:27 +08:00
2 lines
1.9 KiB
JavaScript
2 lines
1.9 KiB
JavaScript
define(["utils/utils","mvc/ui/ui-portlet","mvc/ui/ui-misc"],function(a,b,c){var d=Backbone.View.extend({initialize:function(b){this.list={},this.options=a.merge(b,{title:"Repeat",empty_text:"Not available.",max:null,min:null}),this.button_new=new c.ButtonIcon({icon:"fa-plus",title:"Insert "+this.options.title,tooltip:"Add new "+this.options.title+" block",cls:"ui-button-icon ui-clear-float form-repeat-add",onclick:function(){b.onnew&&b.onnew()}}),this.setElement($("<div/>").append(this.$list=$("<div/>")).append($("<div/>").append(this.button_new.$el)))},size:function(){return _.size(this.list)},add:function(a){if(!a.id||this.list[a.id])return void Galaxy.emit.debug("form-repeat::add()","Duplicate or invalid repeat block id.");var d=new c.ButtonIcon({icon:"fa-trash-o",tooltip:"Delete this repeat block",cls:"ui-button-icon-plain form-repeat-delete",onclick:function(){a.ondel&&a.ondel()}}),e=new b.View({id:a.id,title:"placeholder",cls:a.cls||"ui-portlet-repeat",operations:{button_delete:d}});e.append(a.$el),e.$el.addClass("section-row").hide(),this.list[a.id]=e,this.$list.append(e.$el.fadeIn("fast")),this.options.max>0&&this.size()>=this.options.max&&this.button_new.disable(),this._refresh()},del:function(a){return this.list[a]?(this.$list.find("#"+a).remove(),delete this.list[a],this.button_new.enable(),void this._refresh()):void Galaxy.emit.debug("form-repeat::del()","Invalid repeat block id.")},delAll:function(){for(var a in this.list)this.del(a)},hideOptions:function(){this.button_new.$el.hide(),_.each(this.list,function(a){a.hideOperation("button_delete")}),_.isEmpty(this.list)&&this.$el.append($("<div/>").addClass("ui-form-info").html(this.options.empty_text))},_refresh:function(){var a=0;for(var b in this.list){var c=this.list[b];c.title(++a+": "+this.options.title),c[this.size()>this.options.min?"showOperation":"hideOperation"]("button_delete")}}});return{View:d}});
|
|
//# sourceMappingURL=../../../maps/mvc/form/form-repeat.js.map
|