Files
galaxy/static/scripts/layout/modal.js
T

1 line
2.7 KiB
JavaScript

define("layout/modal",["exports","jquery"],function(t,o){"use strict";function i(){d.hide()}Object.defineProperty(t,"__esModule",{value:!0});var e=function(t){return t&&t.__esModule?t:{default:t}}(o).default,s=function(t){this.$overlay=t.overlay,this.$dialog=t.dialog,this.$header=this.$dialog.find(".modal-header"),this.$body=this.$dialog.find(".modal-body"),this.$footer=this.$dialog.find(".modal-footer"),this.$backdrop=t.backdrop,this.$header.find(".close").on("click",e.proxy(this.hide,this))};e.extend(s.prototype,{setContent:function(t){this.$header.hide(),t.title&&(this.$header.find(".title").html(t.title),this.$header.show()),t.closeButton?(this.$header.find(".close").show(),this.$header.show()):this.$header.find(".close").hide(),this.$footer.hide();var o=this.$footer.find(".buttons").html("");t.buttons&&(e.each(t.buttons,function(t,i){o.append(e("<button></button> ").text(t).click(i)).append(" ")}),this.$footer.show());var i=this.$footer.find(".extra_buttons").html("");t.extra_buttons&&(e.each(t.extra_buttons,function(t,o){i.append(e("<button></button>").text(t).click(o)).append(" ")}),this.$footer.show());var s=t.body;"progress"==s&&(s=e("<div class='progress progress-striped active'><div class='progress-bar' style='width: 100%'></div></div>")),this.$body.html(s)},show:function(t,o){this.$dialog.is(":visible")||(t.backdrop?this.$backdrop.addClass("in"):this.$backdrop.removeClass("in"),this.$overlay.show(),this.$dialog.show(),this.$overlay.addClass("in"),this.$body.css("min-width",this.$body.width()),this.$body.css("max-height",e(window).height()-this.$footer.outerHeight()-this.$header.outerHeight()-parseInt(this.$dialog.css("padding-top"),10)-parseInt(this.$dialog.css("padding-bottom"),10))),o&&o()},hide:function(){var t=this;t.$dialog.fadeOut(function(){t.$overlay.hide(),t.$backdrop.removeClass("in"),t.$body.children().remove(),t.$body.css("min-width",void 0)})}});var d;e(function(){d=new s({overlay:e("#top-modal"),dialog:e("#top-modal-dialog"),backdrop:e("#top-modal-backdrop")})}),t.default={Modal:s,hide_modal:i,show_modal:function(t,o,i,e,s){d.setContent({title:t,body:o,buttons:i,extra_buttons:e}),d.show({backdrop:!0},s)},show_message:function(t,o,i,e,s){d.setContent({title:t,body:o,buttons:i,extra_buttons:e}),d.show({backdrop:!1},s)},show_in_overlay:function(t){var o=t.width||"600",s=t.height||"400",a=t.scroll||"auto";e("#overlay-background").bind("click.overlay",function(){i(),e("#overlay-background").unbind("click.overlay")}),d.setContent({closeButton:!0,title:"&nbsp;",body:e("<div style='margin: -5px;'><iframe style='margin: 0; padding: 0;' src='"+t.url+"' width='"+o+"' height='"+s+"' scrolling='"+a+"' frameborder='0'></iframe></div>")}),d.show({backdrop:!0})}}});