Changeset 597

Show
Ignore:
Timestamp:
21-06-10 11:20:04 (4 years ago)
Author:
duh
Message:

- improved ontology chooser
-- the button (showHide element) did not hide when a search did not yield results
-- the ontology chooser ignores shortcut form submits by ignoring the ENTER key

Location:
trunk/web-app/js
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • trunk/web-app/js/ontology-chooser.js

    r591 r597  
    6767 
    6868    /** 
    69      * initialize the ontology autocompleter 
     69     * initialize the ontology autocomplete 
    7070     * @param element 
    7171     */ 
     
    8080        var target_property = values[2]; 
    8181        if (ontology_id == "all") { ontology_id = ""; } 
     82 
     83        // ignore ENTER key in inputElement so the form cannot 
     84        // be submitted by pressing the ENTER key 
     85        inputElement.bind('keypress', function(e) { 
     86            if (e.keyCode == 13) return false; 
     87        }); 
    8288 
    8389        // http://bioportal.bioontology.org/search/json_search/?q=musculus 
     
    113119                        // hide spinner 
    114120                        inputElement.css({ 'background': 'none' }); 
     121 
     122                        // hide button? 
     123                        if (!data.data && that.options.showHide) { 
     124                            that.options.showHide.hide();     
     125                        } 
    115126 
    116127                        // response callback 
  • trunk/web-app/js/ontology-chooser.min.js

    r591 r597  
    1 function OntologyChooser(){}OntologyChooser.prototype={cache:[],options:{minLength:3,showHide:null,spinner:"../images/spinner.gif"},init:function(a){var b=this;if(a){$.each(a,function(c,d){b.options[c]=d})}if(this.options.showHide){this.options.showHide.hide()}$("input[rel*='ontology']").each(function(){b.initAutocomplete(this)})},initAutocomplete:function(d){var f=this;var g=$(d);var e=false;var c=g.attr("rel").split("-");var b=c[1];var a=c[2];if(b=="all"){b=""}g.autocomplete({minLength:f.options.minLength,delay:300,search:function(h,i){if(f.options.spinner){g.css({background:"url("+f.options.spinner+") no-repeat right top"})}e=false},source:function(j,h){var k=$.trim(j.term);var i="http://bioportal.bioontology.org/search/json_search/"+b+"?q="+j.term+"&response=json&callback=?";if(f.cache[k]){g.css({background:"none"});h(f.cache[k])}else{$.getJSON(i,function(m){var l=f.parseData(m.data);f.cache[k]=l;g.css({background:"none"});h(f.parseData(m.data))})}},select:function(i,j){e=true;var h=g;f.setInputValue(h,"concept_id",j.item.concept_id);f.setInputValue(h,"ontology_id",j.item.ontology_id);f.setInputValue(h,"full_id",j.item.full_id);h.removeClass("error");if(f.options.showHide){f.options.showHide.show()}},close:function(i,j){if(!e){var h=g;g.val("");f.setInputValue(h,"concept_id","");f.setInputValue(h,"ontology_id","");f.setInputValue(h,"full_id","");h.addClass("error")}}})},setInputValue:function(e,c,d){var a=e.attr("name")+"-"+c;var b=e.parent().find("input[name='"+a+"']");if(b.size()>0){$(b[0]).val(d)}else{e.after('<input type="hidden" name="'+a+'" value="'+d+'"/>')}},parseData:function(d){var a=[];var c=d.split("~!~");for(var b=0;b<c.length;b++){var f=$.trim(c[b]);if(f){var e=f.split("|");a[a.length]={value:e[0],label:e[0]+' <span class="about">('+e[2]+')</span> <span class="from">from: '+e[(e.length-1)]+"</span>",preferred_name:e[0],concept_id:e[1],ontology_id:e[3],full_id:e[4]}}}return a}}; 
     1function OntologyChooser(){}OntologyChooser.prototype={cache:[],options:{minLength:3,showHide:null,spinner:"../images/spinner.gif"},init:function(a){var b=this;if(a){$.each(a,function(c,d){b.options[c]=d})}if(this.options.showHide){this.options.showHide.hide()}$("input[rel*='ontology']").each(function(){b.initAutocomplete(this)})},initAutocomplete:function(d){var f=this;var g=$(d);var e=false;var c=g.attr("rel").split("-");var b=c[1];var a=c[2];if(b=="all"){b=""}g.bind("keypress",function(h){if(h.keyCode==13){return false}});g.autocomplete({minLength:f.options.minLength,delay:300,search:function(h,i){if(f.options.spinner){g.css({background:"url("+f.options.spinner+") no-repeat right top"})}e=false},source:function(j,h){var k=$.trim(j.term);var i="http://bioportal.bioontology.org/search/json_search/"+b+"?q="+j.term+"&response=json&callback=?";if(f.cache[k]){g.css({background:"none"});h(f.cache[k])}else{$.getJSON(i,function(m){var l=f.parseData(m.data);f.cache[k]=l;g.css({background:"none"});if(!m.data&&f.options.showHide){f.options.showHide.hide()}h(f.parseData(m.data))})}},select:function(i,j){e=true;var h=g;f.setInputValue(h,"concept_id",j.item.concept_id);f.setInputValue(h,"ontology_id",j.item.ontology_id);f.setInputValue(h,"full_id",j.item.full_id);h.removeClass("error");if(f.options.showHide){f.options.showHide.show()}},close:function(i,j){if(!e){var h=g;g.val("");f.setInputValue(h,"concept_id","");f.setInputValue(h,"ontology_id","");f.setInputValue(h,"full_id","");h.addClass("error")}}})},setInputValue:function(e,c,d){var a=e.attr("name")+"-"+c;var b=e.parent().find("input[name='"+a+"']");if(b.size()>0){$(b[0]).val(d)}else{e.after('<input type="hidden" name="'+a+'" value="'+d+'"/>')}},parseData:function(d){var a=[];var c=d.split("~!~");for(var b=0;b<c.length;b++){var f=$.trim(c[b]);if(f){var e=f.split("|");a[a.length]={value:e[0],label:e[0]+' <span class="about">('+e[2]+')</span> <span class="from">from: '+e[(e.length-1)]+"</span>",preferred_name:e[0],concept_id:e[1],ontology_id:e[3],full_id:e[4]}}}return a}};