Files
galaxy/static/scripts/ui/popupmenu.js
T

2 lines
1.7 KiB
JavaScript

define(["jquery"],function(a){"use_strict";function b(a,b){var c=a.data("menu_options");a.data("menu_options",b),c||a.bind("click.show_popup",function(b){return d(".popmenu-wrapper").remove(),setTimeout(function(){var c=d("<ul class='dropdown-menu' id='"+a.attr("id")+"-menu'></ul>"),e=a.data("menu_options");_.size(e)<=0&&d("<li>No Options.</li>").appendTo(c),d.each(e,function(a,b){if(b){var e=b.action||b;c.append(d("<li></li>").append(d("<a>").attr("href",b.url).html(a).click(e)))}else c.append(d("<li></li>").addClass("head").append(d("<a href='#'></a>").html(a)))});var f=d("<div class='popmenu-wrapper' style='position: absolute;left: 0; top: -1000;'></div>").append(c).appendTo("body"),g=b.pageX-f.width()/2;g=Math.min(g,d(document).scrollLeft()+d(window).width()-d(f).width()-5),g=Math.max(g,d(document).scrollLeft()+5),f.css({top:b.pageY,left:g})},10),setTimeout(function(){var a=function(a){d(a).bind("click.close_popup",function(){d(".popmenu-wrapper").remove(),a.unbind("click.close_popup")})};a(d(window.document)),a(d(window.top.document));for(var b=window.top.frames.length;b--;){var c=d(window.top.frames[b].document);a(c)}},50),!1})}function c(a){a=a||document,d(a).find("div[popupmenu]").each(function(){var c={},e=d(this);e.find("a").each(function(){var a=d(this),b=a.get(0),e=b.getAttribute("confirm"),f=b.getAttribute("href"),g=b.getAttribute("target");c[a.text()]=f?{url:f,action:function(b){if(!e||confirm(e)){if(g)return window.open(f,g),!1;a.click()}else b.preventDefault()}}:null});var f=d(a).find("#"+e.attr("popupmenu"));f.find("a").bind("click",function(a){return a.stopPropagation(),!0}),b(f,c),f.addClass("popup"),e.remove()})}var d=a;return{make_popupmenu:b,make_popup_menus:c}});
//# sourceMappingURL=../../maps/ui/popupmenu.js.map