galaxy-dist commit 4053c425b536: No longer pre-generate menus on page load for popup-style menus. Instead, create menu dynamically when needed, greatly improving load time especially on data libraries with large number of potential menus.
# HG changeset patch -- Bitbucket.org # Project galaxy-dist # URL http://bitbucket.org/galaxy/galaxy-dist/overview # User Kanwei Li <kanwei@gmail.com> # Date 1288748718 14400 # Node ID 4053c425b536b9878f6f8bdfac75453adec7bdf3 # Parent e000a6800e1cbfa15a190bb2aff90a5956882a43 No longer pre-generate menus on page load for popup-style menus. Instead, create menu dynamically when needed, greatly improving load time especially on data libraries with large number of potential menus. Remove the creation of a background element that closes the active menu clicked. Instead, bind an event to close active menus to the document object of current and all other framesets. Tested in IE. Update Tool Search/Recently Used code to reflect new changes. Made some small tweaks to pass JSlint --- a/templates/root/index.mako +++ b/templates/root/index.mako @@ -46,10 +46,8 @@ "Export to File": function() { galaxy_main.location = "${h.url_for( controller='history', action='export_archive' )}"; }, - "Delete": function() - { - if ( confirm( "Really delete the current history?" ) ) - { + "Delete": function() { + if ( confirm( "Really delete the current history?" ) ) { galaxy_main.location = "${h.url_for( controller='history', action='delete_current' )}"; } }, @@ -59,98 +57,108 @@ } }); + var menu_options = {}; // Holds dictionary of { label: toggle_fn } + + SHOW_TOOL = "Show Tool Search"; + HIDE_TOOL = "Hide Tool Search"; + SHOW_RECENT = "Show Recently Used"; + HIDE_RECENT = "Hide Recently Used"; + + var toggle_tool_search_fn = function() { + // Show/hide menu and update vars, user preferences. + var menu = $("#galaxy_tools").contents().find('#tool-search'), + pref_value, menu_option_text, old_text; + if (menu.is(":visible")) { + // Hide menu. + pref_value = "False"; + menu_option_text = SHOW_TOOL; + old_text = HIDE_TOOL; + + // Reset search. + reset_tool_search(true); + } else { + // Show menu. + pref_value = "True"; + menu_option_text = HIDE_TOOL; + old_text = SHOW_TOOL; + } + menu.toggle(); + + // Update menu option. + delete menu_options[old_text]; + menu_options[menu_option_text] = toggle_tool_search_fn; + make_popupmenu( $("#tools-options-button"), menu_options ); + galaxy_async.set_user_pref("show_tool_search", pref_value); + }; + + var toggle_recently_used_fn = function() { + // Show/hide menu. + var ru_menu = $('#galaxy_tools').contents().find('#recently_used_wrapper'), + ru_menu_body = ru_menu.find(".toolSectionBody"), + pref_value, old_text, menu_option_text; + if (ru_menu.hasClass("user_pref_visible")) { + // Hide menu. + ru_menu_body.slideUp(); + ru_menu.slideUp(); + + // Set vars used below and in tool menu frame. + pref_value = "False"; + old_text = HIDE_RECENT; + menu_option_text = SHOW_RECENT; + } else { + // "Show" menu. + if (!$('#galaxy_tools').contents().find('#tool-search-query').hasClass("search_active")) { + // Default. + ru_menu.slideDown(); + } else { + // Search active: tf there are matching tools in RU menu, show menu. + if ( ru_menu.find(".toolTitle.search_match").length !== 0 ) { + ru_menu.slideDown(); + ru_menu_body.slideDown(); + } + } + // Set vars used below and in tool menu frame. + pref_value = "True"; + old_text = SHOW_RECENT; + menu_option_text = HIDE_RECENT; + } + + // Update menu class and option. + ru_menu.toggleClass("user_pref_hidden user_pref_visible"); + delete menu_options[old_text]; + menu_options[menu_option_text] = toggle_recently_used_fn; + make_popupmenu( $("#tools-options-button"), menu_options ); + galaxy_async.set_user_pref("show_recently_used_menu", pref_value); + }; + // Init tool options. - make_popupmenu( $("#tools-options-button"), { - ## Search tools menu item. - %if trans.app.toolbox_search.enabled: - <% - show_tool_search = False - if trans.user: - show_tool_search = trans.user.preferences.get( "show_tool_search", "False" ) - - if show_tool_search == "True": - initial_text = "Hide Search" - else: - initial_text = "Search Tools" - %> - "${initial_text}": function() { - // Show/hide menu and update vars, user preferences. - var menu = $("#galaxy_tools").contents().find('#tool-search'); - if (menu.is(":visible")) - { - // Hide menu. - pref_value = "False"; - menu_option_text = "Search Tools"; - menu.toggle(); - - // Reset search. - reset_tool_search(true); - } - else - { - // Show menu. - pref_value = "True"; - menu_option_text = "Hide Search"; - menu.toggle(); - } - - // Update menu option. - $("#tools-options-button-menu").find("li").eq(0).text(menu_option_text); - - galaxy_async.set_user_pref("show_tool_search", pref_value); - }, - %endif - ## Recently used tools menu. - %if trans.user: - <% - if trans.user.preferences.get( 'show_recently_used_menu', 'False' ) == 'True': - action = "Hide" - else: - action = "Show" - %> - "${action} Recently Used": function() { - // Show/hide menu. - var ru_menu = $('#galaxy_tools').contents().find('#recently_used_wrapper'); - var ru_menu_body = ru_menu.find(".toolSectionBody"); - var pref_value = null; - var menu_option_text = null; - if (ru_menu.hasClass("user_pref_visible")) - { - // Hide menu. - ru_menu_body.slideUp(); - ru_menu.slideUp(); - - // Set vars used below and in tool menu frame. - pref_value = "False"; - menu_option_text = "Show Recently Used"; - } - else - { - // "Show" menu. - if (!$('#galaxy_tools').contents().find('#tool-search-query').hasClass("search_active")) - // Default. - ru_menu.slideDown(); - else - // Search active: tf there are matching tools in RU menu, show menu. - if ( ru_menu.find(".toolTitle.search_match").length != 0 ) - { - ru_menu.slideDown(); - ru_menu_body.slideDown(); - } - - // Set vars used below and in tool menu frame. - pref_value = "True"; - menu_option_text = "Hide Recently Used"; - } - - // Update menu class and option. - ru_menu.toggleClass("user_pref_hidden user_pref_visible"); - $("#tools-options-button-menu").find("li").eq(1).text(menu_option_text); - - galaxy_async.set_user_pref("show_recently_used_menu", pref_value); - } - %endif - }); + ## Search tools menu item. + %if trans.app.toolbox_search.enabled: + <% + show_tool_search = False + if trans.user: + show_tool_search = trans.user.preferences.get( "show_tool_search", "False" ) + + if show_tool_search == "True": + action = "HIDE_TOOL" + else: + action = "SHOW_TOOL" + %> + menu_options[ ${action} ] = toggle_tool_search_fn; + %endif + ## Recently used tools menu. + %if trans.user: + <% + if trans.user.preferences.get( 'show_recently_used_menu', 'False' ) == 'True': + action = "HIDE_RECENT" + else: + action = "SHOW_RECENT" + %> + menu_options[ ${action} ] = toggle_recently_used_fn; + %endif + + + make_popupmenu( $("#tools-options-button"), menu_options ); }); </script></%def> --- a/static/scripts/galaxy.base.js +++ b/static/scripts/galaxy.base.js @@ -7,7 +7,7 @@ if (!Array.indexOf) { } } return -1; - } + }; } // Returns the number of keys (elements) in an array/dictionary. @@ -39,93 +39,89 @@ function obj_length(obj) { }); }; -function ensure_popup_helper() { - // And the helper below the popup menus - if ( $( "#popup-helper" ).length === 0 ) { - $( "<div id='popup-helper'/>" ).css( { - background: 'white', opacity: 0, zIndex: 15000, - position: 'absolute', top: 0, left: 0, width: '100%', height: '100%' - } ).appendTo( "body" ).hide(); - } -} - -function attach_popupmenu( button_element, wrapper ) { - var clean = function() { - wrapper.unbind().hide(); - $("#popup-helper").unbind( "click.popupmenu" ).hide(); - // $(document).unbind( "click.popupmenu" ); - }; - var click_handler = function( e ) { - // var o = $(button_element).offset(); - $("#popup-helper").bind( "click.popupmenu", clean ).show(); - // $(document).bind( "click.popupmenu", clean ); - // Show off screen to get size right - wrapper.click( clean ).css( { left: 0, top: -1000 } ).show(); - // console.log( e.pageX, $(document).scrollLeft() + $(window).width(), $(menu_element).width() ); - var x = e.pageX - wrapper.width() / 2 ; - x = Math.min( x, $(document).scrollLeft() + $(window).width() - $(wrapper).width() - 20 ); - x = Math.max( x, $(document).scrollLeft() + 20 ); - // console.log( e.pageX, $(document).scrollLeft() + $(window).width(), $(menu_element).width() ); - - - wrapper.css( { - top: e.pageY - 5, - left: x - } ); - return false; - }; - $(button_element).bind("click", click_handler); +// Toggle popup menu options using regular expression on option names. +function show_hide_popupmenu_options( menu, option_name_re, show ) { + show = (show === undefined ? true : show ); + var re = new RegExp(option_name_re); + $(menu).find("li").each( function() { + if ( re.exec($(this).text()) ) { + if (show) { + $(this).show(); + } else { + $(this).hide(); + } + } + }); } function make_popupmenu( button_element, options ) { - ensure_popup_helper(); - // var container_element = $(button_element); - // if ( container_element.parent().hasClass( "combo-button" ) ) { - // container_element = container_element.parent(); - // } - // container_element).css( "position", "relative" ); - var menu_element = $( "<ul id='" + button_element.attr('id') + "-menu'></ul>" ); - if (obj_length(options) <= 0) { - $("<li/>").html("No options").appendTo(menu_element); - } - $.each( options, function( k, v ) { - if (v) { - $("<li/>").html(k).click(v).appendTo(menu_element); - } else { - $("<li class='head'/>").html(k).appendTo(menu_element); - } + button_element.bind("click.show_popup", function(e) { + // Close existing visible menus + $(".popmenu-wrapper").remove(); + + + // Need setTimeouts so clicks don't interfere with each other + setTimeout( function() { + // Dynamically generate the wrapper holding all the selectable options of the menu. + var menu_element = $( "<ul id='" + button_element.attr('id') + "-menu'></ul>" ); + if (obj_length(options) <= 0) { + $("<li>No Options.</li>").appendTo(menu_element); + } + $.each( options, function( k, v ) { + if (v) { + $("<li/>").html(k).click(v).appendTo(menu_element); + } else { + $("<li class='head'/>").html(k).appendTo(menu_element); + } + }); + var wrapper = $( "<div class='popmenu-wrapper' style='position: absolute;left: 0; top: -1000;'>" ); + wrapper.append( menu_element ) + .append( "<div class='overlay-border'>" ) + .appendTo( "body" ); + + var x = e.pageX - wrapper.width() / 2 ; + x = Math.min( x, $(document).scrollLeft() + $(window).width() - $(wrapper).width() - 20 ); + x = Math.max( x, $(document).scrollLeft() + 20 ); + + wrapper.css( { + top: e.pageY - 5, + left: x + } ); + }, 10); + + setTimeout( function() { + // Bind click event to current window and all frames to remove any visible menus + // Bind to document object instead of window object for IE compat + var close_popup = function(el) { + $(el).bind("click.close_popup", function() { + $(".popmenu-wrapper").remove(); + el.unbind("click.close_popup"); + }); + }; + close_popup( $(window.document) ); // Current frame + close_popup( $(window.top.document) ); // Parent frame + for (var frame_id = window.top.frames.length; frame_id--;) { // Sibling frames + var frame = $(window.top.frames[frame_id].document); + close_popup(frame); + } + }, 50); + + return false; }); - var wrapper = $( "<div class='popmenu-wrapper'>" ); - wrapper.append( menu_element ) - .append( "<div class='overlay-border'>" ) - .css( "position", "absolute" ) - .appendTo( "body" ) - .hide(); - attach_popupmenu( button_element, wrapper ); - return menu_element; -} - -// Toggle popup menu options using regular expression on option names. -function show_hide_popupmenu_options( menu, option_name_re, show ) { - var show = (show === undefined ? true : show ); - var re = new RegExp(option_name_re); - $(menu).find("li").each( function() { - if ( re.exec( $(this).text() ) ) - if (show) - $(this).show(); - else - $(this).hide(); - }); + } function make_popup_menus() { jQuery( "div[popupmenu]" ).each( function() { var options = {}; - $(this).find( "a" ).each( function() { - var confirmtext = $(this).attr( "confirm" ), - href = $(this).attr( "href" ), - target = $(this).attr( "target" ); - options[ $(this).text() ] = function() { + var menu = $(this); + menu.find( "a" ).each( function() { + var link = $(this), + link_dom = link.get(0); + var confirmtext = link_dom.getAttribute( "confirm" ), + href = link_dom.getAttribute( "href" ), + target = link_dom.getAttribute( "target" ); + options[ link.text() ] = function() { if ( !confirmtext || confirm( confirmtext ) ) { var f = window; if ( target == "_parent" ) { @@ -137,14 +133,18 @@ function make_popup_menus() { } }; }); - var b = $( "#" + $(this).attr( 'popupmenu' ) ); - b.find("a").bind("click", function(e) { + var box = $( "#" + menu.attr( 'popupmenu' ) ); + + // For menus with clickable link text, make clicking on the link go through instead + // of activating the popup menu + box.find("a").bind("click", function(e) { e.stopPropagation(); // Stop bubbling so clicking on the link goes through return true; }); - make_popupmenu( b, options ); - $(this).remove(); - b.addClass( "popup" ).show(); + + make_popupmenu(box, options); + box.addClass("popup"); + menu.remove(); }); } @@ -160,15 +160,17 @@ function naturalSort(a, b) { xD = (new Date(x)).getTime(), yD = xD ? (new Date(y)).getTime() : null; // natural sorting of dates - if ( yD ) - if ( xD < yD ) return -1; - else if ( xD > yD ) return 1; + if ( yD ) { + if ( xD < yD ) { return -1; } + else if ( xD > yD ) { return 1; } + } // natural sorting through split numeric strings and default strings - for( var cLoc = 0, numS = Math.max(xN.length, yN.length); cLoc < numS; cLoc++ ) { + var oFxNcL, oFyNcL; + for ( var cLoc = 0, numS = Math.max(xN.length, yN.length); cLoc < numS; cLoc++ ) { oFxNcL = parseFloat(xN[cLoc]) || xN[cLoc]; oFyNcL = parseFloat(yN[cLoc]) || yN[cLoc]; - if (oFxNcL < oFyNcL) return -1; - else if (oFxNcL > oFyNcL) return 1; + if (oFxNcL < oFyNcL) { return -1; } + else if (oFxNcL > oFyNcL) { return 1; } } return 0; } @@ -176,14 +178,17 @@ function naturalSort(a, b) { // Replace select box with a text input box + autocomplete. function replace_big_select_inputs(min_length, max_length) { // To do replace, jQuery's autocomplete plugin must be loaded. - if (!jQuery().autocomplete) + if (!jQuery().autocomplete) { return; + } // Set default for min_length and max_length - if (min_length === undefined) + if (min_length === undefined) { min_length = 20; - if (max_length === undefined) + } + if (max_length === undefined) { max_length = 3000; + } $('select').each( function() { var select_elt = $(this); @@ -194,7 +199,7 @@ function replace_big_select_inputs(min_l } // Skip multi-select because widget cannot handle multi-select. - if (select_elt.attr('multiple') == true) { + if (select_elt.attr('multiple') === true) { return; } @@ -240,13 +245,14 @@ function replace_big_select_inputs(min_l }); // Set initial text if it's empty. - if ( start_value == '' || start_value == '?') { + if ( start_value === '' || start_value === '?') { text_input_elt.attr('value', 'Click to Search or Select'); } // Sort dbkey options list only. - if (select_elt.attr('name') == 'dbkey') + if (select_elt.attr('name') == 'dbkey') { select_options = select_options.sort(naturalSort); + } // Do autocomplete. var autocomplete_options = { selectFirst: false, autoFill: false, mustMatch: false, matchContains: true, max: max_length, minChars : 0, hideForLessThanMinChars : false }; @@ -265,7 +271,7 @@ function replace_big_select_inputs(min_l } else { // If there is a non-empty start value, use that; otherwise unknown. - if (start_value != "") { + if (start_value !== "") { text_input_elt.attr('value', start_value); } else { // This is needed to make the DB key work. @@ -283,9 +289,9 @@ function replace_big_select_inputs(min_l // Get refresh vals. var ref_on_change_vals = select_elt.attr('refresh_on_change_values'), last_selected_value = select_elt.attr("last_selected_value"); - if (ref_on_change_vals !== undefined) + if (ref_on_change_vals !== undefined) { ref_on_change_vals = ref_on_change_vals.split(','); - + } // Function that attempts to refresh based on the value in the text element. var try_refresh_fn = function() { // Get new value and see if it can be matched. @@ -371,10 +377,11 @@ function async_save_text(click_to_edit_e }, success: function(processed_text) { // Set new text and call finish method. - if (processed_text != "") + if (processed_text !== "") { text_elt.text(processed_text); - else + } else { text_elt.html("<em>None</em>"); + } if (on_finish) { on_finish(t); } @@ -415,15 +422,16 @@ function init_history_items(historywrapp // If Mozilla, hide scrollbars in hidden items since they cause animation bugs if ( $.browser.mozilla ) { $( "div.historyItemBody" ).each( function() { - if ( ! $(this).is( ":visible" ) ) $(this).find( "pre.peek" ).css( "overflow", "hidden" ); - }) + if ( !$(this).is(":visible") ) { $(this).find( "pre.peek" ).css( "overflow", "hidden" ); } + }); } historywrapper.each( function() { - var id = this.id; - var body = $(this).children( "div.historyItemBody" ); - var peek = body.find( "pre.peek" ) + var id = this.id, + body = $(this).children( "div.historyItemBody" ), + peek = body.find( "pre.peek" ); $(this).find( ".historyItemTitleBar > .historyItemTitle" ).wrap( "<a href='javascript:void(0);'></a>" ).click( function() { + var prefs; if ( body.is(":visible") ) { // Hiding stuff here if ( $.browser.mozilla ) { peek.css( "overflow", "hidden" ); } @@ -431,7 +439,7 @@ function init_history_items(historywrapp if (!nochanges) { // Ignore embedded item actions // Save setting - var prefs = $.jStore.store("history_expand_state"); + prefs = $.jStore.store("history_expand_state"); if (prefs) { delete prefs[id]; $.jStore.store("history_expand_state", prefs); @@ -445,7 +453,7 @@ function init_history_items(historywrapp if (!nochanges) { // Save setting - var prefs = $.jStore.store("history_expand_state"); + prefs = $.jStore.store("history_expand_state"); if (prefs === undefined) { prefs = {}; } prefs[id] = true; $.jStore.store("history_expand_state", prefs); @@ -470,7 +478,7 @@ function init_history_items(historywrapp }); $.jStore.store("history_expand_state", prefs); }).show(); - } + }; if (noinit) { action(); @@ -497,7 +505,7 @@ function reset_tool_search( initValue ) // Function may be called in top frame or in tool_menu_frame; // in either case, get the tool menu frame. var tool_menu_frame = $("#galaxy_tools").contents(); - if (tool_menu_frame.length == 0) { + if (tool_menu_frame.length === 0) { tool_menu_frame = $(document); } @@ -532,7 +540,7 @@ function reset_tool_search( initValue ) var GalaxyAsync = function(log_action) { this.url_dict = {}; this.log_action = (log_action === undefined ? false : log_action); -} +}; GalaxyAsync.prototype.set_func_url = function( func_name, url ) { this.url_dict[func_name] = url; @@ -566,36 +574,6 @@ GalaxyAsync.prototype.log_user_action = }); }; -// Add to trackster browser functionality -$(".trackster-add").live("click", function() { - var dataset = this, - dataset_jquery = $(this); - $.ajax({ - url: dataset_jquery.attr("data-url"), - dataType: "html", - error: function() { alert( "Could not add this dataset to browser." ); }, - success: function(table_html) { - var parent = window.parent; - parent.show_modal("Add to Browser:", table_html, { - "Cancel": function() { - parent.hide_modal(); - }, - "Insert into selected": function() { - $(parent.document).find('input[name=id]:checked').each(function() { - var vis_id = $(this).val(); - parent.location = dataset_jquery.attr("action-url") + "&id=" + vis_id; - }); - }, - "Insert into new browser": function() { - parent.location = dataset_jquery.attr("new-url"); - } - }); - } - }); -}); - - - $(document).ready( function() { $("select[refresh_on_change='true']").change( function() { var select_field = $(this), --- a/static/scripts/packed/galaxy.base.js +++ b/static/scripts/packed/galaxy.base.js @@ -1,1 +1,1 @@ -if(!Array.indexOf){Array.prototype.indexOf=function(c){for(var b=0,a=this.length;b<a;b++){if(this[b]==c){return b}}return -1}}function obj_length(c){if(c.length!==undefined){return c.length}var b=0;for(var a in c){b++}return b}$.fn.makeAbsolute=function(a){return this.each(function(){var b=$(this);var c=b.position();b.css({position:"absolute",marginLeft:0,marginTop:0,top:c.top,left:c.left,right:$(window).width()-(c.left+b.width())});if(a){b.remove().appendTo("body")}})};function ensure_popup_helper(){if($("#popup-helper").length===0){$("<div id='popup-helper'/>").css({background:"white",opacity:0,zIndex:15000,position:"absolute",top:0,left:0,width:"100%",height:"100%"}).appendTo("body").hide()}}function attach_popupmenu(b,d){var a=function(){d.unbind().hide();$("#popup-helper").unbind("click.popupmenu").hide()};var c=function(g){$("#popup-helper").bind("click.popupmenu",a).show();d.click(a).css({left:0,top:-1000}).show();var f=g.pageX-d.width()/2;f=Math.min(f,$(document).scr ollLeft()+$(window).width()-$(d).width()-20);f=Math.max(f,$(document).scrollLeft()+20);d.css({top:g.pageY-5,left:f});return false};$(b).bind("click",c)}function make_popupmenu(c,b){ensure_popup_helper();var a=$("<ul id='"+c.attr("id")+"-menu'></ul>");if(obj_length(b)<=0){$("<li/>").html("No options").appendTo(a)}$.each(b,function(f,e){if(e){$("<li/>").html(f).click(e).appendTo(a)}else{$("<li class='head'/>").html(f).appendTo(a)}});var d=$("<div class='popmenu-wrapper'>");d.append(a).append("<div class='overlay-border'>").css("position","absolute").appendTo("body").hide();attach_popupmenu(c,d);return a}function show_hide_popupmenu_options(d,c,a){var a=(a===undefined?true:a);var b=new RegExp(c);$(d).find("li").each(function(){if(b.exec($(this).text())){if(a){$(this).show()}else{$(this).hide()}}})}function make_popup_menus(){jQuery("div[popupmenu]").each(function(){var c={};$(this).find("a").each(function(){var b=$(this).attr("confirm"),d=$(this).attr("href"),e=$(this).attr("ta rget");c[$(this).text()]=function(){if(!b||confirm(b)){var g=window;if(e=="_parent"){g=window.parent}else{if(e=="_top"){g=window.top}}g.location=d}}});var a=$("#"+$(this).attr("popupmenu"));a.find("a").bind("click",function(b){b.stopPropagation();return true});make_popupmenu(a,c);$(this).remove();a.addClass("popup").show()})}function naturalSort(i,g){var n=/(-?[0-9\.]+)/g,j=i.toString().toLowerCase()||"",f=g.toString().toLowerCase()||"",k=String.fromCharCode(0),l=j.replace(n,k+"$1"+k).split(k),e=f.replace(n,k+"$1"+k).split(k),d=(new Date(j)).getTime(),m=d?(new Date(f)).getTime():null;if(m){if(d<m){return -1}else{if(d>m){return 1}}}for(var h=0,c=Math.max(l.length,e.length);h<c;h++){oFxNcL=parseFloat(l[h])||l[h];oFyNcL=parseFloat(e[h])||e[h];if(oFxNcL<oFyNcL){return -1}else{if(oFxNcL>oFyNcL){return 1}}}return 0}function replace_big_select_inputs(a,b){if(!jQuery().autocomplete){return}if(a===undefined){a=20}if(b===undefined){b=3000}$("select").each(function(){var d=$(this);var g=d.find("option").length;if((g<a)||(g>b)){return}if(d.attr("multiple")==true){return}if(d.hasClass("no-autocomplete")){return}var m=d.attr("value");var c=$("<input type='text' class='text-and-autocomplete-select'></input>");c.attr("size",40);c.attr("name",d.attr("name"));c.attr("id",d.attr("id"));c.click(function(){var n=$(this).val();$(this).val("Loading...");$(this).showAllInCache();$(this).val(n);$(this).select()});var e=[];var i={};d.children("option").each(function(){var o=$(this).text();var n=$(this).attr("value");e.push(o);i[o]=n;i[n]=n;if(n==m){c.attr("value",o)}});if(m==""||m=="?"){c.attr("value","Click to Search or Select")}if(d.attr("name")=="dbkey"){e=e.sort(naturalSort)}var f={selectFirst:false,autoFill:false,mustMatch:false,matchContains:true,max:b,minChars:0,hideForLessThanMinChars:false};c.autocomplete(e,f);d.replaceWith(c);var k=function(){var o=c.attr("value");var n=i[o];if(n!==null&&n!==undefined){c.attr("value",n)}else{if(m!=""){c.attr("value",m)}else{c. attr("value","?")}}};c.parents("form").submit(function(){k()});$(document).bind("convert_dbkeys",function(){k()});if(d.attr("refresh_on_change")=="true"){var h=d.attr("refresh_on_change_values"),l=d.attr("last_selected_value");if(h!==undefined){h=h.split(",")}var j=function(){var n=i[c.attr("value")];if(l!==n&&n!==null&&n!==undefined){if(h!==undefined&&$.inArray(n,h)===-1&&$.inArray(l,h)===-1){return}c.attr("value",n);$(window).trigger("refresh_on_change");c.parents("form").submit()}};c.bind("result",j);c.keyup(function(n){if(n.keyCode===13){j()}});c.keydown(function(n){if(n.keyCode===13){return false}})}})}function async_save_text(d,f,e,a,c,h,i,g,b){if(c===undefined){c=30}if(i===undefined){i=4}$("#"+d).live("click",function(){if($("#renaming-active").length>0){return}var l=$("#"+f),k=l.text(),j;if(h){j=$("<textarea></textarea>").attr({rows:i,cols:c}).text($.trim(k))}else{j=$("<input type='text'></input>").attr({value:$.trim(k),size:c})}j.attr("id","renaming-active");j.blur( function(){$(this).remove();l.show();if(b){b(j)}});j.keyup(function(n){if(n.keyCode===27){$(this).trigger("blur")}else{if(n.keyCode===13){var m={};m[a]=$(this).val();$(this).trigger("blur");$.ajax({url:e,data:m,error:function(){alert("Text editing for elt "+f+" failed")},success:function(o){if(o!=""){l.text(o)}else{l.html("<em>None</em>")}if(b){b(j)}}})}}});if(g){g(j)}l.hide();j.insertAfter(l);j.focus();j.select();return})}function init_history_items(d,a,c){var b=function(){try{var e=$.jStore.store("history_expand_state");if(e){for(var g in e){$("#"+g+" div.historyItemBody").show()}}}catch(f){$.jStore.remove("history_expand_state")}if($.browser.mozilla){$("div.historyItemBody").each(function(){if(!$(this).is(":visible")){$(this).find("pre.peek").css("overflow","hidden")}})}d.each(function(){var j=this.id;var h=$(this).children("div.historyItemBody");var i=h.find("pre.peek");$(this).find(".historyItemTitleBar > .historyItemTitle").wrap("<a href='javascript:void(0);'></a>").cl ick(function(){if(h.is(":visible")){if($.browser.mozilla){i.css("overflow","hidden")}h.slideUp("fast");if(!c){var k=$.jStore.store("history_expand_state");if(k){delete k[j];$.jStore.store("history_expand_state",k)}}}else{h.slideDown("fast",function(){if($.browser.mozilla){i.css("overflow","auto")}});if(!c){var k=$.jStore.store("history_expand_state");if(k===undefined){k={}}k[j]=true;$.jStore.store("history_expand_state",k)}}return false})});$("#top-links > a.toggle").click(function(){var h=$.jStore.store("history_expand_state");if(h===undefined){h={}}$("div.historyItemBody:visible").each(function(){if($.browser.mozilla){$(this).find("pre.peek").css("overflow","hidden")}$(this).slideUp("fast");if(h){delete h[$(this).parent().attr("id")]}});$.jStore.store("history_expand_state",h)}).show()};if(a){b()}else{$.jStore.init("galaxy");$.jStore.engineReady(function(){b()})}}function commatize(b){b+="";var a=/(\d+)(\d{3})/;while(a.test(b)){b=b.replace(a,"$1,$2")}return b}function rese t_tool_search(a){var c=$("#galaxy_tools").contents();if(c.length==0){c=$(document)}$(this).removeClass("search_active");c.find(".toolTitle").removeClass("search_match");c.find(".toolSectionBody").hide();c.find(".toolTitle").show();c.find(".toolPanelLabel").show();c.find(".toolSectionWrapper").each(function(){if($(this).attr("id")!="recently_used_wrapper"){$(this).show()}else{if($(this).hasClass("user_pref_visible")){$(this).show()}}});c.find("#search-no-results").hide();c.find("#search-spinner").hide();if(a){var b=c.find("#tool-search-query");b.val("search tools");b.css("font-style","italic")}}var GalaxyAsync=function(a){this.url_dict={};this.log_action=(a===undefined?false:a)};GalaxyAsync.prototype.set_func_url=function(a,b){this.url_dict[a]=b};GalaxyAsync.prototype.set_user_pref=function(a,b){var c=this.url_dict[arguments.callee];if(c===undefined){return false}$.ajax({url:c,data:{pref_name:a,pref_value:b},error:function(){return false},success:function(){return true}})};Ga laxyAsync.prototype.log_user_action=function(c,b,d){if(!this.log_action){return}var a=this.url_dict[arguments.callee];if(a===undefined){return false}$.ajax({url:a,data:{action:c,context:b,params:d},error:function(){return false},success:function(){return true}})};$(".trackster-add").live("click",function(){var b=this,a=$(this);$.ajax({url:a.attr("data-url"),dataType:"html",error:function(){alert("Could not add this dataset to browser.")},success:function(c){var d=window.parent;d.show_modal("Add to Browser:",c,{Cancel:function(){d.hide_modal()},"Insert into selected":function(){$(d.document).find("input[name=id]:checked").each(function(){var e=$(this).val();d.location=a.attr("action-url")+"&id="+e})},"Insert into new browser":function(){d.location=a.attr("new-url")}})}})});$(document).ready(function(){$("select[refresh_on_change='true']").change(function(){var a=$(this),e=a.val(),d=false,c=a.attr("refresh_on_change_values");if(c){c=c.split(",");var b=a.attr("last_selected_val ue");if($.inArray(e,c)===-1&&$.inArray(b,c)===-1){return}}$(window).trigger("refresh_on_change");a.get(0).form.submit()});$("a[confirm]").click(function(){return confirm($(this).attr("confirm"))});if($.fn.tipsy){$(".tooltip").tipsy({gravity:"s"})}make_popup_menus();replace_big_select_inputs(20,1500)}); +if(!Array.indexOf){Array.prototype.indexOf=function(c){for(var b=0,a=this.length;b<a;b++){if(this[b]==c){return b}}return -1}}function obj_length(c){if(c.length!==undefined){return c.length}var b=0;for(var a in c){b++}return b}$.fn.makeAbsolute=function(a){return this.each(function(){var b=$(this);var c=b.position();b.css({position:"absolute",marginLeft:0,marginTop:0,top:c.top,left:c.left,right:$(window).width()-(c.left+b.width())});if(a){b.remove().appendTo("body")}})};function show_hide_popupmenu_options(d,c,a){a=(a===undefined?true:a);var b=new RegExp(c);$(d).find("li").each(function(){if(b.exec($(this).text())){if(a){$(this).show()}else{$(this).hide()}}})}function make_popupmenu(b,a){b.bind("click.show_popup",function(c){$(".popmenu-wrapper").remove();setTimeout(function(){var e=$("<ul id='"+b.attr("id")+"-menu'></ul>");if(obj_length(a)<=0){$("<li>No Options.</li>").appendTo(e)}$.each(a,function(h,g){if(g){$("<li/>").html(h).click(g).appendTo(e)}else{$("<li class='head'/
").html(h).appendTo(e)}});var f=$("<div class='popmenu-wrapper' style='position: absolute;left: 0; top: -1000;'>");f.append(e).append("<div class='overlay-border'>").appendTo("body");var d=c.pageX-f.width()/2;d=Math.min(d,$(document).scrollLeft()+$(window).width()-$(f).width()-20);d=Math.max(d,$(document).scrollLeft()+20);f.css({top:c.pageY-5,left:d})},10);setTimeout(function(){var e=function(g){$(g).bind("click.close_popup",function(){$(".popmenu-wrapper").remove();g.unbind("click.close_popup")})};e($(window.document));e($(window.top.document));for(var d=window.top.frames.length;d--;){var f=$(window.top.frames[d].document);e(f)}},50);return false})}function make_popup_menus(){jQuery("div[popupmenu]").each(function(){var a={};var c=$(this);c.find("a").each(function(){var f=$(this),h=f.get(0);var d=h.getAttribute("confirm"),e=h.getAttribute("href"),g=h.getAttribute("target");a[f.text()]=function(){if(!d||confirm(d)){var i=window;if(g=="_parent"){i=window.parent}else{if(g=="_ top"){i=window.top}}i.location=e}}});var b=$("#"+c.attr("popupmenu"));b.find("a").bind("click",function(d){d.stopPropagation();return true});make_popupmenu(b,a);b.addClass("popup");c.remove()})}function naturalSort(j,h){var p=/(-?[0-9\.]+)/g,k=j.toString().toLowerCase()||"",g=h.toString().toLowerCase()||"",l=String.fromCharCode(0),n=k.replace(p,l+"$1"+l).split(l),e=g.replace(p,l+"$1"+l).split(l),d=(new Date(k)).getTime(),o=d?(new Date(g)).getTime():null;if(o){if(d<o){return -1}else{if(d>o){return 1}}}var m,f;for(var i=0,c=Math.max(n.length,e.length);i<c;i++){m=parseFloat(n[i])||n[i];f=parseFloat(e[i])||e[i];if(m<f){return -1}else{if(m>f){return 1}}}return 0}function replace_big_select_inputs(a,b){if(!jQuery().autocomplete){return}if(a===undefined){a=20}if(b===undefined){b=3000}$("select").each(function(){var d=$(this);var g=d.find("option").length;if((g<a)||(g>b)){return}if(d.attr("multiple")===true){return}if(d.hasClass("no-autocomplete")){return}var m=d.attr("value");var c =$("<input type='text' class='text-and-autocomplete-select'></input>");c.attr("size",40);c.attr("name",d.attr("name"));c.attr("id",d.attr("id"));c.click(function(){var n=$(this).val();$(this).val("Loading...");$(this).showAllInCache();$(this).val(n);$(this).select()});var e=[];var i={};d.children("option").each(function(){var o=$(this).text();var n=$(this).attr("value");e.push(o);i[o]=n;i[n]=n;if(n==m){c.attr("value",o)}});if(m===""||m==="?"){c.attr("value","Click to Search or Select")}if(d.attr("name")=="dbkey"){e=e.sort(naturalSort)}var f={selectFirst:false,autoFill:false,mustMatch:false,matchContains:true,max:b,minChars:0,hideForLessThanMinChars:false};c.autocomplete(e,f);d.replaceWith(c);var k=function(){var o=c.attr("value");var n=i[o];if(n!==null&&n!==undefined){c.attr("value",n)}else{if(m!==""){c.attr("value",m)}else{c.attr("value","?")}}};c.parents("form").submit(function(){k()});$(document).bind("convert_dbkeys",function(){k()});if(d.attr("refresh_on_change")=="true "){var h=d.attr("refresh_on_change_values"),l=d.attr("last_selected_value");if(h!==undefined){h=h.split(",")}var j=function(){var n=i[c.attr("value")];if(l!==n&&n!==null&&n!==undefined){if(h!==undefined&&$.inArray(n,h)===-1&&$.inArray(l,h)===-1){return}c.attr("value",n);$(window).trigger("refresh_on_change");c.parents("form").submit()}};c.bind("result",j);c.keyup(function(n){if(n.keyCode===13){j()}});c.keydown(function(n){if(n.keyCode===13){return false}})}})}function async_save_text(d,f,e,a,c,h,i,g,b){if(c===undefined){c=30}if(i===undefined){i=4}$("#"+d).live("click",function(){if($("#renaming-active").length>0){return}var l=$("#"+f),k=l.text(),j;if(h){j=$("<textarea></textarea>").attr({rows:i,cols:c}).text($.trim(k))}else{j=$("<input type='text'></input>").attr({value:$.trim(k),size:c})}j.attr("id","renaming-active");j.blur(function(){$(this).remove();l.show();if(b){b(j)}});j.keyup(function(n){if(n.keyCode===27){$(this).trigger("blur")}else{if(n.keyCode===13){var m={};m[a] =$(this).val();$(this).trigger("blur");$.ajax({url:e,data:m,error:function(){alert("Text editing for elt "+f+" failed")},success:function(o){if(o!==""){l.text(o)}else{l.html("<em>None</em>")}if(b){b(j)}}})}}});if(g){g(j)}l.hide();j.insertAfter(l);j.focus();j.select();return})}function init_history_items(d,a,c){var b=function(){try{var e=$.jStore.store("history_expand_state");if(e){for(var g in e){$("#"+g+" div.historyItemBody").show()}}}catch(f){$.jStore.remove("history_expand_state")}if($.browser.mozilla){$("div.historyItemBody").each(function(){if(!$(this).is(":visible")){$(this).find("pre.peek").css("overflow","hidden")}})}d.each(function(){var j=this.id,h=$(this).children("div.historyItemBody"),i=h.find("pre.peek");$(this).find(".historyItemTitleBar > .historyItemTitle").wrap("<a href='javascript:void(0);'></a>").click(function(){var k;if(h.is(":visible")){if($.browser.mozilla){i.css("overflow","hidden")}h.slideUp("fast");if(!c){k=$.jStore.store("history_expand_state");i f(k){delete k[j];$.jStore.store("history_expand_state",k)}}}else{h.slideDown("fast",function(){if($.browser.mozilla){i.css("overflow","auto")}});if(!c){k=$.jStore.store("history_expand_state");if(k===undefined){k={}}k[j]=true;$.jStore.store("history_expand_state",k)}}return false})});$("#top-links > a.toggle").click(function(){var h=$.jStore.store("history_expand_state");if(h===undefined){h={}}$("div.historyItemBody:visible").each(function(){if($.browser.mozilla){$(this).find("pre.peek").css("overflow","hidden")}$(this).slideUp("fast");if(h){delete h[$(this).parent().attr("id")]}});$.jStore.store("history_expand_state",h)}).show()};if(a){b()}else{$.jStore.init("galaxy");$.jStore.engineReady(function(){b()})}}function commatize(b){b+="";var a=/(\d+)(\d{3})/;while(a.test(b)){b=b.replace(a,"$1,$2")}return b}function reset_tool_search(a){var c=$("#galaxy_tools").contents();if(c.length===0){c=$(document)}$(this).removeClass("search_active");c.find(".toolTitle").removeClass("searc h_match");c.find(".toolSectionBody").hide();c.find(".toolTitle").show();c.find(".toolPanelLabel").show();c.find(".toolSectionWrapper").each(function(){if($(this).attr("id")!="recently_used_wrapper"){$(this).show()}else{if($(this).hasClass("user_pref_visible")){$(this).show()}}});c.find("#search-no-results").hide();c.find("#search-spinner").hide();if(a){var b=c.find("#tool-search-query");b.val("search tools");b.css("font-style","italic")}}var GalaxyAsync=function(a){this.url_dict={};this.log_action=(a===undefined?false:a)};GalaxyAsync.prototype.set_func_url=function(a,b){this.url_dict[a]=b};GalaxyAsync.prototype.set_user_pref=function(a,b){var c=this.url_dict[arguments.callee];if(c===undefined){return false}$.ajax({url:c,data:{pref_name:a,pref_value:b},error:function(){return false},success:function(){return true}})};GalaxyAsync.prototype.log_user_action=function(c,b,d){if(!this.log_action){return}var a=this.url_dict[arguments.callee];if(a===undefined){return false}$.ajax({ur l:a,data:{action:c,context:b,params:d},error:function(){return false},success:function(){return true}})};$(document).ready(function(){$("select[refresh_on_change='true']").change(function(){var a=$(this),e=a.val(),d=false,c=a.attr("refresh_on_change_values");if(c){c=c.split(",");var b=a.attr("last_selected_value");if($.inArray(e,c)===-1&&$.inArray(b,c)===-1){return}}$(window).trigger("refresh_on_change");a.get(0).form.submit()});$("a[confirm]").click(function(){return confirm($(this).attr("confirm"))});if($.fn.tipsy){$(".tooltip").tipsy({gravity:"s"})}make_popup_menus();replace_big_select_inputs(20,1500)});
participants (1)
-
commits-noreply@bitbucket.org