mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-09-24 16:30:27 +08:00
Remove custom combobox (search + select) code because it has been replaced with select2. Pack scripts.
This commit is contained in:
-142
@@ -1,142 +0,0 @@
|
||||
/**
|
||||
* A generic search + select combobox based on jQueryUI button and autocomplete.
|
||||
* Code is derived from http://jqueryui.com/autocomplete/
|
||||
*
|
||||
* Options:
|
||||
* appendTo - element to attach autocomplete options to; default is <body>
|
||||
* size - text input's size; default is 20
|
||||
*/
|
||||
|
||||
(function( $ ) {
|
||||
$.widget( "ui.combobox", {
|
||||
_create: function() {
|
||||
var input,
|
||||
that = this,
|
||||
select = this.element.hide(),
|
||||
selected = select.children( ":selected" ),
|
||||
value = selected.val() ? selected.text() : "",
|
||||
wrapper = this.wrapper = $( "<span>" )
|
||||
.addClass( "ui-combobox" )
|
||||
.insertAfter( select );
|
||||
|
||||
function removeIfInvalid(element) {
|
||||
var value = $( element ).val(),
|
||||
matcher = new RegExp( "^" + $.ui.autocomplete.escapeRegex( value ) + "$", "i" ),
|
||||
valid = false;
|
||||
select.children( "option" ).each(function() {
|
||||
if ( $( this ).text().match( matcher ) ) {
|
||||
this.selected = valid = true;
|
||||
return false;
|
||||
}
|
||||
});
|
||||
if ( !valid ) {
|
||||
// remove invalid value, as it didn't match anything
|
||||
$( element )
|
||||
.val( "" )
|
||||
.attr( "title", value + " didn't match any item" )
|
||||
.tooltip( "open" );
|
||||
select.val( "" );
|
||||
setTimeout(function() {
|
||||
input.tooltip( "close" ).attr( "title", "" );
|
||||
}, 2500 );
|
||||
input.data( "autocomplete" ).term = "";
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
var size = ( this.options.size ? this.options.size : 20 );
|
||||
input = $( "<input>" )
|
||||
.appendTo( wrapper )
|
||||
.val( value )
|
||||
.click( function() {
|
||||
this.select();
|
||||
})
|
||||
.attr( "title", "" )
|
||||
.attr( "size", size )
|
||||
.addClass( "ui-state-default ui-combobox-input" )
|
||||
.autocomplete({
|
||||
appendTo: this.options.appendTo,
|
||||
delay: 0,
|
||||
minLength: 0,
|
||||
source: function( request, response ) {
|
||||
var matcher = new RegExp( $.ui.autocomplete.escapeRegex(request.term), "i" );
|
||||
response( select.children( "option" ).map(function() {
|
||||
var text = $( this ).text();
|
||||
if ( this.value && ( !request.term || matcher.test(text) ) )
|
||||
return {
|
||||
label: text.replace(
|
||||
new RegExp(
|
||||
"(?![^&;]+;)(?!<[^<>]*)(" +
|
||||
$.ui.autocomplete.escapeRegex(request.term) +
|
||||
")(?![^<>]*>)(?![^&;]+;)", "gi"
|
||||
), "<strong>$1</strong>" ),
|
||||
value: text,
|
||||
option: this
|
||||
};
|
||||
}) );
|
||||
},
|
||||
select: function( event, ui ) {
|
||||
ui.item.option.selected = true;
|
||||
that._trigger( "selected", event, {
|
||||
item: ui.item.option
|
||||
});
|
||||
},
|
||||
change: function( event, ui ) {
|
||||
if ( !ui.item )
|
||||
return removeIfInvalid( this );
|
||||
}
|
||||
})
|
||||
.addClass( "ui-widget ui-widget-content ui-corner-left" );
|
||||
|
||||
input.data( "autocomplete" )._renderItem = function( ul, item ) {
|
||||
return $( "<li>" )
|
||||
.data( "item.autocomplete", item )
|
||||
.append( "<a>" + item.label + "</a>" )
|
||||
.appendTo( ul );
|
||||
};
|
||||
|
||||
$( "<a>" )
|
||||
.attr( "tabIndex", -1 )
|
||||
.attr( "title", "Show All Items" )
|
||||
.tooltip()
|
||||
.appendTo( wrapper )
|
||||
.button({
|
||||
icons: {
|
||||
primary: "ui-icon-triangle-1-s"
|
||||
},
|
||||
text: false
|
||||
})
|
||||
.removeClass( "ui-corner-all" )
|
||||
.addClass( "ui-corner-right ui-combobox-toggle" )
|
||||
.click(function() {
|
||||
// close if already visible
|
||||
if ( input.autocomplete( "widget" ).is( ":visible" ) ) {
|
||||
input.autocomplete( "close" );
|
||||
removeIfInvalid( input );
|
||||
return;
|
||||
}
|
||||
|
||||
// work around a bug (likely same cause as #5265)
|
||||
$( this ).blur();
|
||||
|
||||
// pass empty string as value to search for, displaying all results
|
||||
input.autocomplete( "search", "" );
|
||||
input.focus();
|
||||
});
|
||||
|
||||
input
|
||||
.tooltip({
|
||||
position: {
|
||||
of: this.button
|
||||
},
|
||||
tooltipClass: "ui-state-highlight"
|
||||
});
|
||||
},
|
||||
|
||||
destroy: function() {
|
||||
this.wrapper.remove();
|
||||
this.element.show();
|
||||
$.Widget.prototype.destroy.call( this );
|
||||
}
|
||||
});
|
||||
})( jQuery );
|
||||
File diff suppressed because one or more lines are too long
@@ -1 +0,0 @@
|
||||
(function(a){a.widget("ui.combobox",{_create:function(){var c,g=this,b=this.element.hide(),f=b.children(":selected"),h=f.val()?f.text():"",i=this.wrapper=a("<span>").addClass("ui-combobox").insertAfter(b);function e(j){var l=a(j).val(),m=new RegExp("^"+a.ui.autocomplete.escapeRegex(l)+"$","i"),k=false;b.children("option").each(function(){if(a(this).text().match(m)){this.selected=k=true;return false}});if(!k){a(j).val("").attr("title",l+" didn't match any item").tooltip("open");b.val("");setTimeout(function(){c.tooltip("close").attr("title","")},2500);c.data("autocomplete").term="";return false}}var d=(this.options.size?this.options.size:20);c=a("<input>").appendTo(i).val(h).click(function(){this.select()}).attr("title","").attr("size",d).addClass("ui-state-default ui-combobox-input").autocomplete({appendTo:this.options.appendTo,delay:0,minLength:0,source:function(k,j){var l=new RegExp(a.ui.autocomplete.escapeRegex(k.term),"i");j(b.children("option").map(function(){var m=a(this).text();if(this.value&&(!k.term||l.test(m))){return{label:m.replace(new RegExp("(?![^&;]+;)(?!<[^<>]*)("+a.ui.autocomplete.escapeRegex(k.term)+")(?![^<>]*>)(?![^&;]+;)","gi"),"<strong>$1</strong>"),value:m,option:this}}}))},select:function(j,k){k.item.option.selected=true;g._trigger("selected",j,{item:k.item.option})},change:function(j,k){if(!k.item){return e(this)}}}).addClass("ui-widget ui-widget-content ui-corner-left");c.data("autocomplete")._renderItem=function(j,k){return a("<li>").data("item.autocomplete",k).append("<a>"+k.label+"</a>").appendTo(j)};a("<a>").attr("tabIndex",-1).attr("title","Show All Items").tooltip().appendTo(i).button({icons:{primary:"ui-icon-triangle-1-s"},text:false}).removeClass("ui-corner-all").addClass("ui-corner-right ui-combobox-toggle").click(function(){if(c.autocomplete("widget").is(":visible")){c.autocomplete("close");e(c);return}a(this).blur();c.autocomplete("search","");c.focus()});c.tooltip({position:{of:this.button},tooltipClass:"ui-state-highlight"})},destroy:function(){this.wrapper.remove();this.element.show();a.Widget.prototype.destroy.call(this)}})})(jQuery);
|
||||
@@ -1 +1 @@
|
||||
var ui=null;var view=null;var browser_router=null;require(["utils/galaxy.css","libs/jquery/jstorage","libs/jquery/jquery.event.drag","libs/jquery/jquery.event.hover","libs/jquery/jquery.mousewheel","libs/jquery/jquery-ui","libs/jquery/jquery-ui-combobox","libs/farbtastic","libs/jquery/jquery.form","libs/jquery/jquery.rating","mvc/ui"],function(a){a.load_file("static/style/jquery.rating.css");a.load_file("static/style/autocomplete_tagging.css");a.load_file("static/style/jquery-ui/smoothness/jquery-ui.css");a.load_file("static/style/library.css");a.load_file("static/style/trackster.css")});define(["libs/backbone/backbone-relational","viz/visualization","viz/trackster_ui"],function(c,a,b){var d=Backbone.View.extend({initialize:function(){ui=new b.TracksterUI(galaxy_config.root);ui.createButtonMenu();ui.buttonMenu.$el.attr("style","float: right");$("#center .unified-panel-header-inner").append(ui.buttonMenu.$el);$("#right .unified-panel-title").append("Bookmarks");$("#right .unified-panel-icons").append("<a id='add-bookmark-button' class='icon-button menu-button plus-button' href='javascript:void(0);' title='Add bookmark'></a>");$("#right-border").click(function(){view.resize_window()});force_right_panel("hide");if(galaxy_config.app.id){this.view_existing()}else{this.view_new()}},set_up_router:function(e){browser_router=new a.TrackBrowserRouter(e);Backbone.history.start()},view_existing:function(){var e=galaxy_config.app.viz_config;view=ui.create_visualization({container:$("#center .unified-panel-body"),name:e.title,vis_id:e.vis_id,dbkey:e.dbkey},e.viewport,e.tracks,e.bookmarks,true);this.init_editor()},view_new:function(){var e=this;$.ajax({url:galaxy_config.root+"api/genomes?chrom_info=True",data:{},error:function(){alert("Couldn't create new browser.")},success:function(f){show_modal("New Visualization",e.template_view_new(f),{Cancel:function(){window.location=galaxy_config.root+"visualization/list"},Create:function(){e.create_browser($("#new-title").val(),$("#new-dbkey").val())}});if(galaxy_config.app.default_dbkey){$("#new-dbkey option[value='"+galaxy_config.app.default_dbkey+"']").attr("selected",true)}$("#new-title").focus();$("select[name='dbkey']").combobox({appendTo:$("#overlay"),size:40});$("#overlay").css("overflow","auto")}})},template_view_new:function(e){var g='<form id="new-browser-form" action="javascript:void(0);" method="post" onsubmit="return false;"><div class="form-row"><label for="new-title">Browser name:</label><div class="form-row-input"><input type="text" name="title" id="new-title" value="Unnamed"></input></div><div style="clear: both;"></div></div><div class="form-row"><label for="new-dbkey">Reference genome build (dbkey): </label><div class="form-row-input"><select name="dbkey" id="new-dbkey">';for(var f in e){g+='<option value="'+e[f][1]+'">'+e[f][0]+"</option>"}g+='</select></div><div style="clear: both;"></div></div><div class="form-row">Is the build not listed here? <a href="'+galaxy_config.root+'user/dbkeys?use_panels=True">Add a Custom Build</a></div></form>';return g},create_browser:function(f,e){$(document).trigger("convert_to_values");view=ui.create_visualization({container:$("#center .unified-panel-body"),name:f,dbkey:e},galaxy_config.app.gene_region);this.init_editor();view.editor=true;hide_modal()},init_editor:function(){$("#center .unified-panel-title").text(view.name+" ("+view.dbkey+")");if(galaxy_config.app.add_dataset){$.ajax({url:galaxy_config.root+"api/datasets/"+galaxy_config.app.add_dataset,data:{hda_ldda:"hda",data_type:"track_config"},dataType:"json",success:function(e){view.add_drawable(b.object_from_template(e,view,view))}})}$("#add-bookmark-button").click(function(){var f=view.chrom+":"+view.low+"-"+view.high,e="Bookmark description";return ui.add_bookmark(f,e,true)});ui.init_keyboard_nav(view);this.set_up_router({view:view})}});return{GalaxyApp:d}});
|
||||
var ui=null;var view=null;var browser_router=null;require(["utils/galaxy.css","libs/jquery/jstorage","libs/jquery/jquery.event.drag","libs/jquery/jquery.event.hover","libs/jquery/jquery.mousewheel","libs/jquery/jquery-ui","libs/jquery/select2","libs/farbtastic","libs/jquery/jquery.form","libs/jquery/jquery.rating","mvc/ui"],function(a){a.load_file("static/style/jquery.rating.css");a.load_file("static/style/autocomplete_tagging.css");a.load_file("static/style/jquery-ui/smoothness/jquery-ui.css");a.load_file("static/style/library.css");a.load_file("static/style/trackster.css")});define(["libs/backbone/backbone-relational","viz/visualization","viz/trackster_ui"],function(c,a,b){var d=Backbone.View.extend({initialize:function(){ui=new b.TracksterUI(galaxy_config.root);ui.createButtonMenu();ui.buttonMenu.$el.attr("style","float: right");$("#center .unified-panel-header-inner").append(ui.buttonMenu.$el);$("#right .unified-panel-title").append("Bookmarks");$("#right .unified-panel-icons").append("<a id='add-bookmark-button' class='icon-button menu-button plus-button' href='javascript:void(0);' title='Add bookmark'></a>");$("#right-border").click(function(){view.resize_window()});force_right_panel("hide");if(galaxy_config.app.id){this.view_existing()}else{this.view_new()}},set_up_router:function(e){browser_router=new a.TrackBrowserRouter(e);Backbone.history.start()},view_existing:function(){var e=galaxy_config.app.viz_config;view=ui.create_visualization({container:$("#center .unified-panel-body"),name:e.title,vis_id:e.vis_id,dbkey:e.dbkey},e.viewport,e.tracks,e.bookmarks,true);this.init_editor()},view_new:function(){var e=this;$.ajax({url:galaxy_config.root+"api/genomes?chrom_info=True",data:{},error:function(){alert("Couldn't create new browser.")},success:function(f){show_modal("New Visualization",e.template_view_new(f),{Cancel:function(){window.location=galaxy_config.root+"visualization/list"},Create:function(){e.create_browser($("#new-title").val(),$("#new-dbkey").val())}});if(galaxy_config.app.default_dbkey){$("#new-dbkey option[value='"+galaxy_config.app.default_dbkey+"']").attr("selected",true)}$("#new-title").focus();$("select[name='dbkey']").select2();$("#overlay").css("overflow","auto")}})},template_view_new:function(e){var g='<form id="new-browser-form" action="javascript:void(0);" method="post" onsubmit="return false;"><div class="form-row"><label for="new-title">Browser name:</label><div class="form-row-input"><input type="text" name="title" id="new-title" value="Unnamed"></input></div><div style="clear: both;"></div></div><div class="form-row"><label for="new-dbkey">Reference genome build (dbkey): </label><div class="form-row-input"><select name="dbkey" id="new-dbkey">';for(var f in e){g+='<option value="'+e[f][1]+'">'+e[f][0]+"</option>"}g+='</select></div><div style="clear: both;"></div></div><div class="form-row">Is the build not listed here? <a href="'+galaxy_config.root+'user/dbkeys?use_panels=True">Add a Custom Build</a></div></form>';return g},create_browser:function(f,e){$(document).trigger("convert_to_values");view=ui.create_visualization({container:$("#center .unified-panel-body"),name:f,dbkey:e},galaxy_config.app.gene_region);this.init_editor();view.editor=true;hide_modal()},init_editor:function(){$("#center .unified-panel-title").text(view.name+" ("+view.dbkey+")");if(galaxy_config.app.add_dataset){$.ajax({url:galaxy_config.root+"api/datasets/"+galaxy_config.app.add_dataset,data:{hda_ldda:"hda",data_type:"track_config"},dataType:"json",success:function(e){view.add_drawable(b.object_from_template(e,view,view))}})}$("#add-bookmark-button").click(function(){var f=view.chrom+":"+view.low+"-"+view.high,e="Bookmark description";return ui.add_bookmark(f,e,true)});ui.init_keyboard_nav(view);this.set_up_router({view:view})}});return{GalaxyApp:d}});
|
||||
@@ -35,8 +35,7 @@
|
||||
${h.js( "libs/jquery/jstorage", "libs/jquery/jquery.autocomplete", "libs/jquery/jquery.rating",
|
||||
"galaxy.autocom_tagging" )}
|
||||
|
||||
${h.js( "galaxy.panels", "libs/jquery/jstorage", "libs/jquery/jquery.event.drag", "libs/jquery/jquery.event.hover","libs/jquery/jquery.mousewheel", "libs/jquery/jquery-ui", "libs/jquery/jquery-ui-combobox",
|
||||
"libs/require", "libs/farbtastic" )}
|
||||
${h.js( "galaxy.panels", "libs/jquery/jstorage", "libs/jquery/jquery.event.drag", "libs/jquery/jquery.event.hover","libs/jquery/jquery.mousewheel", "libs/jquery/jquery-ui", "libs/require", "libs/farbtastic" )}
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
|
||||
Reference in New Issue
Block a user