display a create own option before a search is performed

This commit is contained in:
tworrall 2011-12-02 20:52:06 +00:00
parent ccd359dc2a
commit 2fb20f1efe
3 changed files with 26 additions and 16 deletions

View file

@ -26,3 +26,8 @@
form#addConceptForm { form#addConceptForm {
display:none; display:none;
} }
form#addConceptForm span#createOwnOne{
float:left;
margin-top:24px
}

View file

@ -55,7 +55,8 @@ var addConceptForm = {
//remove links //remove links
this.removeConceptLinks = $('a.remove'); this.removeConceptLinks = $('a.remove');
this.errors = $('#errors'); this.errors = $('#errors');
this.createOwn = $('#createOwn'); this.createOwn1 = $('#createOwnOne');
this.createOwn2 = $('#createOwnTwo');
this.orSpan = $('span.or') this.orSpan = $('span.or')
}, },
@ -90,7 +91,7 @@ var addConceptForm = {
this.clearSearchResults(); this.clearSearchResults();
// Hide the create own link, add selected button and "or"" span // Hide the create own link, add selected button and "or"" span
this.orSpan.hide(); this.orSpan.hide();
this.createOwn.hide(); this.createOwn2.hide();
this.submit.hide(); this.submit.hide();
//Also clear the search input //Also clear the search input
this.searchTerm.val(""); this.searchTerm.val("");
@ -114,14 +115,17 @@ var addConceptForm = {
clearErrors:function() { clearErrors:function() {
addConceptForm.errors.empty(); addConceptForm.errors.empty();
}, },
showHiddenElements:function() { showHiddenElements:function(results) {
this.orSpan.show(); this.createOwn1.hide();
this.createOwn.show(); if ( results ) {
this.submit.show(); this.orSpan.show();
}, this.createOwn2.show();
showSpanAndCreateOption:function() { this.submit.show();
this.orSpan.show(); }
this.createOwn.show(); else {
this.orSpan.show();
this.createOwn2.show();
}
}, },
showConceptListOnlyView: function() { showConceptListOnlyView: function() {
this.hideForm(); this.hideForm();
@ -131,7 +135,7 @@ var addConceptForm = {
//Get value of search term //Get value of search term
var searchValue = this.searchTerm.val(); var searchValue = this.searchTerm.val();
var checkedVocabSource = $('input:radio[name="source"]:checked'); var checkedVocabSource = $('input:radio[name="source"]:checked');
var createLink = this.createOwn; var hasResults = false;
if(!checkedVocabSource.length) { if(!checkedVocabSource.length) {
addConceptForm.showUncheckedSourceError(); addConceptForm.showUncheckedSourceError();
return; return;
@ -173,10 +177,11 @@ var addConceptForm = {
if(htmlAdd.length) { if(htmlAdd.length) {
$('#selectedConcept').html(htmlAdd); $('#selectedConcept').html(htmlAdd);
if (htmlAdd.indexOf("No search results") >= 0) { if (htmlAdd.indexOf("No search results") >= 0) {
addConceptForm.showSpanAndCreateOption(); addConceptForm.showHiddenElements(hasResults);
} }
else { else {
addConceptForm.showHiddenElements(); hasResults = true;
addConceptForm.showHiddenElements(hasResults);
} }
} }
}); });

View file

@ -90,8 +90,8 @@
</#list> </#list>
<p class="inline-search"> <p class="inline-search">
<input type="text" id="searchTerm" label="Search" class="acSelector" size="35" /> <input type="text" id="searchTerm" label="Search" class="acSelector" size="35" />
&nbsp;<input type="button" class="submit concept-search" id="searchButton" name="searchButton" value="Search"/> <input type="button" class="submit concept-search" id="searchButton" name="searchButton" value="Search"/>&nbsp;
</p> </p><span id="createOwnOne"> or &nbsp;<a href="${userDefinedConceptUrl}" >Create your own concept&nbsp;</a></span>
<input type="hidden" id="conceptNode" name="conceptNode" value=""/> <!-- Field value populated by JavaScript --> <input type="hidden" id="conceptNode" name="conceptNode" value=""/> <!-- Field value populated by JavaScript -->
<input type="hidden" id="conceptLabel" name="conceptLabel" value="" /> <!-- Field value populated by JavaScript --> <input type="hidden" id="conceptLabel" name="conceptLabel" value="" /> <!-- Field value populated by JavaScript -->
<input type="hidden" id="conceptSource" name="conceptSource" value="" /> <!-- Field value populated by JavaScript --> <input type="hidden" id="conceptSource" name="conceptSource" value="" /> <!-- Field value populated by JavaScript -->
@ -107,7 +107,7 @@
<input type="submit" id="submit" name="submit" value="Add Selected Concept" /> <input type="submit" id="submit" name="submit" value="Add Selected Concept" />
</p> </p>
<div id="createOwn"><br /> <div id="createOwnTwo"><br />
<a href="${userDefinedConceptUrl}" > Can't find the concept you want? Create your own.</a> <a href="${userDefinedConceptUrl}" > Can't find the concept you want? Create your own.</a>
</div> </div>