galaxy-dist commit ba6f40c5b3d3: Refactored refresh_on_change javascript code to run in galaxy.base when the page is loaded. Fixed bug with autocomplete_select: when switching from a value within refresh_on_change_values to a value outside of it, the page did not refresh. Removed duplicate code from templates.
# HG changeset patch -- Bitbucket.org # Project galaxy-dist # URL http://bitbucket.org/galaxy/galaxy-dist/overview # User Kanwei Li <kanwei@gmail.com> # Date 1285964434 14400 # Node ID ba6f40c5b3d3ee82aa6719f98f58d4285bcbd66d # Parent 4990d7b95b7273ba7159bfb2db1931a4e74a980a Refactored refresh_on_change javascript code to run in galaxy.base when the page is loaded. Fixed bug with autocomplete_select: when switching from a value within refresh_on_change_values to a value outside of it, the page did not refresh. Removed duplicate code from templates. --- a/templates/requests/common/new_request.mako +++ b/templates/requests/common/new_request.mako @@ -5,31 +5,6 @@ ${render_msg( message, status )} %endif -<script type="text/javascript"> -$( function() { - $( "select[refresh_on_change='true']").change( function() { - var refresh = false; - var refresh_on_change_values = $( this )[0].attributes.getNamedItem( 'refresh_on_change_values' ) - if ( refresh_on_change_values ) { - refresh_on_change_values = refresh_on_change_values.value.split( ',' ); - var last_selected_value = $( this )[0].attributes.getNamedItem( 'last_selected_value' ); - for( i= 0; i < refresh_on_change_values.length; i++ ) { - if ( $( this )[0].value == refresh_on_change_values[i] || ( last_selected_value && last_selected_value.value == refresh_on_change_values[i] ) ){ - refresh = true; - break; - } - } - } - else { - refresh = true; - } - if ( refresh ){ - $( "#new_request" ).submit(); - } - }); -}); -</script> - <%def name="javascripts()"> ${parent.javascripts()} ${h.js("jquery.autocomplete", "autocomplete_tagging" )} --- a/templates/user/register.mako +++ b/templates/user/register.mako @@ -9,30 +9,6 @@ <%def name="javascripts()"> ${parent.javascripts()} - <script type="text/javascript"> - $( function() { - $( "select[refresh_on_change='true']").change( function() { - var refresh = false; - var refresh_on_change_values = $( this )[0].attributes.getNamedItem( 'refresh_on_change_values' ) - if ( refresh_on_change_values ) { - refresh_on_change_values = refresh_on_change_values.value.split( ',' ); - var last_selected_value = $( this )[0].attributes.getNamedItem( 'last_selected_value' ); - for( i= 0; i < refresh_on_change_values.length; i++ ) { - if ( $( this )[0].value == refresh_on_change_values[i] || ( last_selected_value && last_selected_value.value == refresh_on_change_values[i] ) ){ - refresh = true; - break; - } - } - } - else { - refresh = true; - } - if ( refresh ){ - $( "#registration" ).submit(); - } - }); - }); - </script></%def><% --- a/templates/library/common/folder_info.mako +++ b/templates/library/common/folder_info.mako @@ -4,30 +4,6 @@ <%def name="javascripts()"> ${parent.javascripts()} - <script type="text/javascript"> - $( function() { - $( "select[refresh_on_change='true']").change( function() { - var refresh = false; - var refresh_on_change_values = $( this )[0].attributes.getNamedItem( 'refresh_on_change_values' ) - if ( refresh_on_change_values ) { - refresh_on_change_values = refresh_on_change_values.value.split( ',' ); - var last_selected_value = $( this )[0].attributes.getNamedItem( 'last_selected_value' ); - for( i= 0; i < refresh_on_change_values.length; i++ ) { - if ( $( this )[0].value == refresh_on_change_values[i] || ( last_selected_value && last_selected_value.value == refresh_on_change_values[i] ) ){ - refresh = true; - break; - } - } - } - else { - refresh = true; - } - if ( refresh ){ - $( "#edit_info" ).submit(); - } - }); - }); - </script></%def><% --- a/static/scripts/packed/galaxy.base.js +++ b/static/scripts/packed/galaxy.base.js @@ -1,1 +1,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).scrollLeft()+$(window).width()-$(d).width()-20);f=Math.max(f,$(document).scrollLeft()+20);d.css({top:g.pageY-5,left:f});return fa lse};$(b).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)}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("target");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"));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 e=$(this);var h=e.find("option").length;if((h<a)||(h>b)){return}if(e.attr("multiple")==true){return}if(e.hasClass("no-autocomplete")){return}var l=e.attr("value");var c=$("<input type='text' class='text-and-autocomplete-select'></input>");c.attr("size",40);c.attr("name",e.attr("name"));c.attr("id",e.attr("id"));c.click(function(){var m=$(this).val();$(this).val("Loading...");$(this).showAllInCache();$(this).val(m);$(this ).select()});var f=[];var i={};e.children("option").each(function(){var n=$(this).text();var m=$(this).attr("value");f.push(n);i[n]=m;i[m]=m;if(m==l){c.attr("value",n)}});if(l==""||l=="?"){c.attr("value","Click to Search or Select")}if(e.attr("name")=="dbkey"){f=f.sort(naturalSort)}var g={selectFirst:false,autoFill:false,mustMatch:false,matchContains:true,max:b,minChars:0,hideForLessThanMinChars:false};c.autocomplete(f,g);e.replaceWith(c);var k=function(){var n=c.attr("value");var m=i[n];if(m!==null&&m!==undefined){c.attr("value",m)}else{if(l!=""){c.attr("value",l)}else{c.attr("value","?")}}};c.parents("form").submit(function(){k()});$(document).bind("convert_dbkeys",function(){k()});if(e.attr("refresh_on_change")=="true"){var d=e.attr("refresh_on_change_values");if(d!==undefined){d=d.split(",")}var j=function(){var o=c.attr("value");var n=i[o];if(n!==null&&n!==undefined){refresh=false;if(d!==undefined){for(var m=0;m<d.length;m++){if(n==d[m]){refresh=true;break}}}else{refres h=true}if(refresh){c.attr("value",n);c.parents("form").submit()}}};c.bind("result",j);c.keyup(function(m){if(m.keyCode===13){j()}});c.keydown(function(m){if(m.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();retur n})}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>").click(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 reset_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")){$(t his).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")}}function GalaxyAsync(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({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 t o browser.")},success:function(c){var d=window.parent;d.show_modal("Add to Browser:",c,{"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")},Cancel:function(){d.hide_modal()}})}})});$(document).ready(function(){$("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)}); +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).scrollLeft()+$(window).width()-$(d).width()-20);f=Math.max(f,$(document).scrollLeft()+20);d.css({top:g.pageY-5,left:f});return fa lse};$(b).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)}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("target");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"));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(n!==null&&n!==undefined){if($.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})}funct ion 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>").click(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)}}retu rn 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("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}})};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({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 br owser.")},success:function(c){var d=window.parent;d.show_modal("Add to Browser:",c,{"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")},Cancel:function(){d.hide_modal()}})}})});$(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)}); --- a/templates/library/common/library_info.mako +++ b/templates/library/common/library_info.mako @@ -4,30 +4,6 @@ <%def name="javascripts()"> ${parent.javascripts()} - <script type="text/javascript"> - $( function() { - $( "select[refresh_on_change='true']").change( function() { - var refresh = false; - var refresh_on_change_values = $( this )[0].attributes.getNamedItem( 'refresh_on_change_values' ) - if ( refresh_on_change_values ) { - refresh_on_change_values = refresh_on_change_values.value.split( ',' ); - var last_selected_value = $( this )[0].attributes.getNamedItem( 'last_selected_value' ); - for( i= 0; i < refresh_on_change_values.length; i++ ) { - if ( $( this )[0].value == refresh_on_change_values[i] || ( last_selected_value && last_selected_value.value == refresh_on_change_values[i] ) ){ - refresh = true; - break; - } - } - } - else { - refresh = true; - } - if ( refresh ){ - $( "#edit_info" ).submit(); - } - }); - }); - </script></%def><% --- a/templates/tool_form.mako +++ b/templates/tool_form.mako @@ -13,43 +13,24 @@ from galaxy.util.expressions import Expr ${h.css( "base", "autocomplete_tagging" )} ${h.js( "jquery", "galaxy.base", "jquery.autocomplete" )} <script type="text/javascript"> -$( function() { - $( "select[refresh_on_change='true']").change( function() { - var refresh = false; - var refresh_on_change_values = $( this )[0].attributes.getNamedItem( 'refresh_on_change_values' ) - if ( refresh_on_change_values ) { - refresh_on_change_values = refresh_on_change_values.value.split( ',' ); - var last_selected_value = $( this )[0].attributes.getNamedItem( 'last_selected_value' ); - for( i= 0; i < refresh_on_change_values.length; i++ ) { - if ( $( this )[0].value == refresh_on_change_values[i] || ( last_selected_value && last_selected_value.value == refresh_on_change_values[i] ) ){ - refresh = true; - break; - } +$(function() { + $(window).bind("refresh_on_change", function() { + $(':file').each( function() { + var file = $(this); + var file_value = file.val(); + if (file_value) { + // disable file input, since we don't want to upload the file on refresh + var file_name = $(this).attr("name"); + file.attr( { name: 'replaced_file_input_' + file_name, disabled: true } ); + // create a new hidden field which stores the filename and has the original name of the file input + var new_file_input = $('<input type="hidden" />'); + new_file_input.attr( { "value": file_value, "name": file_name } ); + file.after(new_file_input); } - } - else { - refresh = true; - } - if ( refresh ){ - $( ':file' ).each( function() { - var file_value = $( this )[0].value; - if ( file_value ) { - //disable file input, since we don't want to upload the file on refresh - var file_name = $( this )[0].name; - $( this )[0].name = 'replaced_file_input_' + file_name - $( this )[0].disable = true; - //create a new hidden field which stores the filename and has the original name of the file input - var new_file_input = document.createElement( 'input' ); - new_file_input.type = 'hidden'; - new_file_input.value = file_value; - new_file_input.name = file_name; - document.getElementById( 'tool_form' ).appendChild( new_file_input ); - } - } ); - $( "#tool_form" ).submit(); - } - }); + }); + }); }); + %if not add_frame.debug: if( window.name != "galaxy_main" ) { location.replace( '${h.url_for( controller='root', action='index', tool_id=tool.id )}' ); --- a/templates/requests/common/find.mako +++ b/templates/requests/common/find.mako @@ -5,31 +5,6 @@ ${render_msg( message, status )} %endif -<script type="text/javascript"> -$( function() { - $( "select[refresh_on_change='true']").change( function() { - var refresh = false; - var refresh_on_change_values = $( this )[0].attributes.getNamedItem( 'refresh_on_change_values' ) - if ( refresh_on_change_values ) { - refresh_on_change_values = refresh_on_change_values.value.split( ',' ); - var last_selected_value = $( this )[0].attributes.getNamedItem( 'last_selected_value' ); - for( i= 0; i < refresh_on_change_values.length; i++ ) { - if ( $( this )[0].value == refresh_on_change_values[i] || ( last_selected_value && last_selected_value.value == refresh_on_change_values[i] ) ){ - refresh = true; - break; - } - } - } - else { - refresh = true; - } - if ( refresh ){ - $( "#find_request" ).submit(); - } - }); -}); -</script> - <%def name="javascripts()"> ${parent.javascripts()} ${h.js("jquery.autocomplete", "autocomplete_tagging" )} --- a/static/scripts/galaxy.base.js +++ b/static/scripts/galaxy.base.js @@ -119,7 +119,7 @@ function make_popup_menus() { } // Alphanumeric/natural sort fn -function naturalSort(a, b){ +function naturalSort(a, b) { // setup temp-scope variables for comparison evauluation var re = /(-?[0-9\.]+)/g, x = a.toString().toLowerCase() || '', @@ -249,45 +249,24 @@ function replace_big_select_inputs(min_l $(document).bind("convert_dbkeys", function() { submit_hook(); } ); // If select is refresh on change, mirror this behavior. - if (select_elt.attr('refresh_on_change') == 'true') - { + if (select_elt.attr('refresh_on_change') == 'true') { // Get refresh vals. - var refresh_vals = select_elt.attr('refresh_on_change_values'); - if (refresh_vals !== undefined) - refresh_vals = refresh_vals.split(","); - + 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) + 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() - { - // - // If value entered can be matched to value, do so and refresh by submitting parent form. - // - + var try_refresh_fn = function() { // Get new value and see if it can be matched. - var cur_value = text_input_elt.attr('value'); - var new_value = select_mapping[cur_value]; - if (new_value !== null && new_value !== undefined) - { - // Do refresh if new value is refresh value or if there are no refresh values. - refresh = false; - if (refresh_vals !== undefined) - { - for (var i= 0; i < refresh_vals.length; i++ ) - if (new_value == refresh_vals[i]) - { - refresh = true; - break; - } + var new_value = select_mapping[text_input_elt.attr('value')]; + if (new_value !== null && new_value !== undefined) { + if ($.inArray(new_value, ref_on_change_vals) === -1 && $.inArray(last_selected_value, ref_on_change_vals) === -1) { + return; } - else - // Refresh for all values. - refresh = true; - - if (refresh) - { - text_input_elt.attr('value', new_value); - text_input_elt.parents('form').submit(); - } + text_input_elt.attr('value', new_value); + $(window).trigger("refresh_on_change"); + text_input_elt.parents('form').submit(); } }; @@ -295,15 +274,17 @@ function replace_big_select_inputs(min_l // case a user may have manually entered a value that needs to be refreshed). text_input_elt.bind("result", try_refresh_fn); text_input_elt.keyup( function(e) { - if ( e.keyCode === 13 ) // Return key + if (e.keyCode === 13) { // Return key try_refresh_fn(); + } }); - // Disable return key so that it does not submit the form automatically. This is done because elememnt should behave like a + // Disable return key so that it does not submit the form automatically. This is done because element should behave like a // select (enter = select), not text input (enter = submit form). text_input_elt.keydown( function(e) { - if ( e.keyCode === 13 ) // Return key + if (e.keyCode === 13) { // Return key return false; + } }); } }); @@ -482,13 +463,13 @@ function commatize( number ) { } // Reset tool search to start state. -function reset_tool_search( initValue ) -{ +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); + } // Remove classes that indicate searching is active. $(this).removeClass("search_active"); @@ -499,18 +480,18 @@ function reset_tool_search( initValue ) tool_menu_frame.find(".toolTitle").show(); tool_menu_frame.find(".toolPanelLabel").show(); tool_menu_frame.find(".toolSectionWrapper").each( function() { - if ($(this).attr('id') != 'recently_used_wrapper') + if ($(this).attr('id') != 'recently_used_wrapper') { // Default action. $(this).show(); - else if ($(this).hasClass("user_pref_visible")) + } else if ($(this).hasClass("user_pref_visible")) { $(this).show(); + } }); tool_menu_frame.find("#search-no-results").hide(); // Reset search input. tool_menu_frame.find("#search-spinner").hide(); - if (initValue) - { + if (initValue) { var search_input = tool_menu_frame.find("#tool-search-query"); search_input.val("search tools"); search_input.css("font-style", "italic"); @@ -518,20 +499,17 @@ function reset_tool_search( initValue ) } // Create GalaxyAsync object. -function GalaxyAsync(log_action) -{ +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; +GalaxyAsync.prototype.set_func_url = function( func_name, url ) { + this.url_dict[func_name] = url; }; // Set user preference asynchronously. -GalaxyAsync.prototype.set_user_pref = function( pref_name, pref_value ) -{ +GalaxyAsync.prototype.set_user_pref = function( pref_name, pref_value ) { // Get URL. var url = this.url_dict[arguments.callee]; if (url === undefined) { return false; } @@ -544,8 +522,7 @@ GalaxyAsync.prototype.set_user_pref = fu }; // Log user action asynchronously. -GalaxyAsync.prototype.log_user_action = function( action, context, params ) -{ +GalaxyAsync.prototype.log_user_action = function( action, context, params ) { if (!this.log_action) { return; } // Get URL. @@ -588,7 +565,24 @@ GalaxyAsync.prototype.log_user_action = }); + $(document).ready( function() { + $("select[refresh_on_change='true']").change( function() { + var select_field = $(this), + select_val = select_field.val(), + refresh = false, + ref_on_change_vals = select_field.attr("refresh_on_change_values"); + if (ref_on_change_vals) { + ref_on_change_vals = ref_on_change_vals.split(','); + var last_selected_value = select_field.attr("last_selected_value"); + if ($.inArray(select_val, ref_on_change_vals) === -1 && $.inArray(last_selected_value, ref_on_change_vals) === -1) { + return; + } + } + $(window).trigger("refresh_on_change"); + select_field.get(0).form.submit(); + }); + // Links with confirmation $( "a[confirm]" ).click( function() { return confirm( $(this).attr("confirm") ); --- a/templates/requests/common/edit_request.mako +++ b/templates/requests/common/edit_request.mako @@ -5,31 +5,6 @@ ${render_msg( message, status )} %endif -<script type="text/javascript"> -$( function() { - $( "select[refresh_on_change='true']").change( function() { - var refresh = false; - var refresh_on_change_values = $( this )[0].attributes.getNamedItem( 'refresh_on_change_values' ) - if ( refresh_on_change_values ) { - refresh_on_change_values = refresh_on_change_values.value.split( ',' ); - var last_selected_value = $( this )[0].attributes.getNamedItem( 'last_selected_value' ); - for( i= 0; i < refresh_on_change_values.length; i++ ) { - if ( $( this )[0].value == refresh_on_change_values[i] || ( last_selected_value && last_selected_value.value == refresh_on_change_values[i] ) ){ - refresh = true; - break; - } - } - } - else { - refresh = true; - } - if ( refresh ){ - $( "#edit_request" ).submit(); - } - }); -}); -</script> - <br/><br/><ul class="manage-table-actions"> --- a/templates/webapps/galaxy/user/info.mako +++ b/templates/webapps/galaxy/user/info.mako @@ -2,31 +2,6 @@ <%namespace file="/user/info.mako" import="render_user_info" /><%namespace file="/message.mako" import="render_msg" /> -<script type="text/javascript"> -$( function() { - $( "select[refresh_on_change='true']").change( function() { - var refresh = false; - var refresh_on_change_values = $( this )[0].attributes.getNamedItem( 'refresh_on_change_values' ) - if ( refresh_on_change_values ) { - refresh_on_change_values = refresh_on_change_values.value.split( ',' ); - var last_selected_value = $( this )[0].attributes.getNamedItem( 'last_selected_value' ); - for( i= 0; i < refresh_on_change_values.length; i++ ) { - if ( $( this )[0].value == refresh_on_change_values[i] || ( last_selected_value && last_selected_value.value == refresh_on_change_values[i] ) ){ - refresh = true; - break; - } - } - } - else { - refresh = true; - } - if ( refresh ){ - $( "#user_info" ).submit(); - } - }); -}); -</script> - %if message: ${render_msg( message, status )} %endif --- a/templates/admin/forms/edit_form.mako +++ b/templates/admin/forms/edit_form.mako @@ -6,31 +6,6 @@ %endif <script type="text/javascript"> -$( function() { - $( "select[refresh_on_change='true']").change( function() { - var refresh = false; - var refresh_on_change_values = $( this )[0].attributes.getNamedItem( 'refresh_on_change_values' ) - if ( refresh_on_change_values ) { - refresh_on_change_values = refresh_on_change_values.value.split( ',' ); - var last_selected_value = $( this )[0].attributes.getNamedItem( 'last_selected_value' ); - for( i= 0; i < refresh_on_change_values.length; i++ ) { - if ( $( this )[0].value == refresh_on_change_values[i] || ( last_selected_value && last_selected_value.value == refresh_on_change_values[i] ) ){ - refresh = true; - break; - } - } - } - else { - refresh = true; - } - if ( refresh ){ - $( "#edit_form" ).submit(); - } - }); -}); -</script> - -<script type="text/javascript"> $(document).ready(function(){ //hide the all of the element with class msg_body $(".msg_body").hide(); --- a/templates/library/common/upload.mako +++ b/templates/library/common/upload.mako @@ -14,31 +14,6 @@ <%def name="javascripts()"> ${parent.javascripts()} ${h.js("jquery.autocomplete", "autocomplete_tagging" )} - - <script type="text/javascript"> - $( function() { - $( "select[refresh_on_change='true']").change( function() { - var refresh = false; - var refresh_on_change_values = $( this )[0].attributes.getNamedItem( 'refresh_on_change_values' ) - if ( refresh_on_change_values ) { - refresh_on_change_values = refresh_on_change_values.value.split( ',' ); - var last_selected_value = $( this )[0].attributes.getNamedItem( 'last_selected_value' ); - for( i= 0; i < refresh_on_change_values.length; i++ ) { - if ( $( this )[0].value == refresh_on_change_values[i] || ( last_selected_value && last_selected_value.value == refresh_on_change_values[i] ) ){ - refresh = true; - break; - } - } - } - else { - refresh = true; - } - if ( refresh ){ - $( "#upload_library_dataset" ).submit(); - } - }); - }); - </script></%def><%def name="stylesheets()"> --- a/templates/library/common/ldda_edit_info.mako +++ b/templates/library/common/ldda_edit_info.mako @@ -6,30 +6,6 @@ <%def name="javascripts()"> ${parent.javascripts()} ${h.js("jquery.autocomplete", "autocomplete_tagging" )} - <script type="text/javascript"> - $( function() { - $( "select[refresh_on_change='true']").change( function() { - var refresh = false; - var refresh_on_change_values = $( this )[0].attributes.getNamedItem( 'refresh_on_change_values' ) - if ( refresh_on_change_values ) { - refresh_on_change_values = refresh_on_change_values.value.split( ',' ); - var last_selected_value = $( this )[0].attributes.getNamedItem( 'last_selected_value' ); - for( i= 0; i < refresh_on_change_values.length; i++ ) { - if ( $( this )[0].value == refresh_on_change_values[i] || ( last_selected_value && last_selected_value.value == refresh_on_change_values[i] ) ){ - refresh = true; - break; - } - } - } - else { - refresh = true; - } - if ( refresh ){ - $( "#edit_info" ).submit(); - } - }); - }); - </script></%def><%def name="stylesheets()"> --- a/templates/library/common/library_dataset_info.mako +++ b/templates/library/common/library_dataset_info.mako @@ -4,30 +4,6 @@ <%def name="javascripts()"> ${parent.javascripts()} - <script type="text/javascript"> - $( function() { - $( "select[refresh_on_change='true']").change( function() { - var refresh = false; - var refresh_on_change_values = $( this )[0].attributes.getNamedItem( 'refresh_on_change_values' ) - if ( refresh_on_change_values ) { - refresh_on_change_values = refresh_on_change_values.value.split( ',' ); - var last_selected_value = $( this )[0].attributes.getNamedItem( 'last_selected_value' ); - for( i= 0; i < refresh_on_change_values.length; i++ ) { - if ( $( this )[0].value == refresh_on_change_values[i] || ( last_selected_value && last_selected_value.value == refresh_on_change_values[i] ) ){ - refresh = true; - break; - } - } - } - else { - refresh = true; - } - if ( refresh ){ - $( "#edit_info" ).submit(); - } - }); - }); - </script></%def> %if library_dataset == library_dataset.library_dataset_dataset_association.library_dataset: --- a/templates/requests/common/show_request.mako +++ b/templates/requests/common/show_request.mako @@ -19,29 +19,6 @@ <%def name="javascripts()"> ${parent.javascripts()} <script type="text/javascript"> - $( function() { - $( "select[refresh_on_change='true']").change( function() { - var refresh = false; - var refresh_on_change_values = $( this )[0].attributes.getNamedItem( 'refresh_on_change_values' ) - if ( refresh_on_change_values ) { - refresh_on_change_values = refresh_on_change_values.value.split( ',' ); - var last_selected_value = $( this )[0].attributes.getNamedItem( 'last_selected_value' ); - for( i= 0; i < refresh_on_change_values.length; i++ ) { - if ( $( this )[0].value == refresh_on_change_values[i] || ( last_selected_value && last_selected_value.value == refresh_on_change_values[i] ) ){ - refresh = true; - break; - } - } - } - else { - refresh = true; - } - if ( refresh ){ - $( "#show_request" ).submit(); - } - }); - }); - function showContent(vThis) { // http://www.javascriptjunkie.com --- a/templates/library/common/select_template.mako +++ b/templates/library/common/select_template.mako @@ -5,30 +5,6 @@ from galaxy.web.form_builder import CheckboxField inheritable_check_box = CheckboxField( 'inheritable' ) %> -<script type="text/javascript"> -$( function() { - $( "select[refresh_on_change='true']").change( function() { - var refresh = false; - var refresh_on_change_values = $( this )[0].attributes.getNamedItem( 'refresh_on_change_values' ) - if ( refresh_on_change_values ) { - refresh_on_change_values = refresh_on_change_values.value.split( ',' ); - var last_selected_value = $( this )[0].attributes.getNamedItem( 'last_selected_value' ); - for( i= 0; i < refresh_on_change_values.length; i++ ) { - if ( $( this )[0].value == refresh_on_change_values[i] || ( last_selected_value && last_selected_value.value == refresh_on_change_values[i] ) ){ - refresh = true; - break; - } - } - } - else { - refresh = true; - } - if ( refresh ){ - $( "#select_template" ).submit(); - } - }); -}); -</script><br/><br/><ul class="manage-table-actions"> --- a/templates/library/common/ldda_info.mako +++ b/templates/library/common/ldda_info.mako @@ -25,30 +25,6 @@ <%def name="javascripts()"> ${parent.javascripts()} - <script type="text/javascript"> - $( function() { - $( "select[refresh_on_change='true']").change( function() { - var refresh = false; - var refresh_on_change_values = $( this )[0].attributes.getNamedItem( 'refresh_on_change_values' ) - if ( refresh_on_change_values ) { - refresh_on_change_values = refresh_on_change_values.value.split( ',' ); - var last_selected_value = $( this )[0].attributes.getNamedItem( 'last_selected_value' ); - for( i= 0; i < refresh_on_change_values.length; i++ ) { - if ( $( this )[0].value == refresh_on_change_values[i] || ( last_selected_value && last_selected_value.value == refresh_on_change_values[i] ) ){ - refresh = true; - break; - } - } - } - else { - refresh = true; - } - if ( refresh ){ - $( "#edit_info" ).submit(); - } - }); - }); - </script></%def> %if current_version:
participants (1)
-
commits-noreply@bitbucket.org