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

2 lines
2.6 KiB
JavaScript

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