Files
galaxy/static/scripts/mvc/ui/ui-popover.js
T

2 lines
1.9 KiB
JavaScript

define(["utils/utils"],function(a){var b=Backbone.View.extend({optionsDefault:{with_close:!0,container:"body",title:null,placement:"top"},visible:!1,initialize:function(b){var c=this;this.options=_.defaults(b,this.optionsDefault),this.setElement(this._template(this.options)),this.options.container.parent().append(this.$el),this.options.with_close&&this.$el.find("#close").on("click",function(){c.hide()}),this.uid=a.uid();var c=this;$("body").on("mousedown."+this.uid,function(a){c._hide(a)})},title:function(a){void 0!==a&&this.$el.find(".popover-title-label").html(a)},show:function(){this.$el.show(),this.visible=!0;var a=this._get_placement(this.options.placement);this.$el.css(a)},_get_placement:function(a){var b=this._get_width(this.$el),c=this.$el.height(),d=this.options.container,e=this._get_width(d),f=this._get_height(d),g=d.position(),h=0,i=0;return("top"==a||"bottom"==a)&&(i=g.left-b+(e+b)/2,h="top"==a?g.top-c-5:g.top+f+5),{top:h,left:i}},_get_width:function(a){return a.width()+parseInt(a.css("padding-left"))+parseInt(a.css("padding-right"))},_get_height:function(a){return a.height()+parseInt(a.css("padding-top"))+parseInt(a.css("padding-bottom"))},hide:function(){this.$el.hide(),this.visible=!1},append:function(a){this.$el.find(".popover-content").append(a)},empty:function(){this.$el.find(".popover-content").empty()},remove:function(){$("body").off("mousedown."+this.uid),this.$el.remove()},_hide:function(a){$(this.options.container).is(a.target)||$(this.el).is(a.target)||0!==$(this.el).has(a.target).length||this.hide()},_template:function(a){var b='<div class="ui-popover popover fade '+a.placement+' in"><div class="arrow"></div><div class="popover-title"><div class="popover-title-label">'+a.title+"</div>";return a.with_close&&(b+='<div id="close" class="popover-close fa fa-times-circle"></div>'),b+='</div><div class="popover-content"></div></div>'}});return{View:b}});
//# sourceMappingURL=../../../maps/mvc/ui/ui-popover.js.map