changed checkbox logic in find.js

This commit is contained in:
Devin Howard 2013-02-21 21:37:00 -05:00
parent fcc1a6968c
commit e2c28da81e

View file

@ -202,19 +202,19 @@ $(document).ready(function() {
$('#topic_by_name_input').typing({ $('#topic_by_name_input').typing({
start: function (event, $elem) { start: function (event, $elem) {
// grab the checkboxes to see if the search is on the canvas, in the commons, or both // grab the checkboxes to see if the search is on the canvas, in the commons, or both
onCanvasChecked = $("#onCanvas").attr('checked'); onCanvasChecked = $("#onCanvas").is(':checked');
inCommonsChecked = $("#inCommons").attr('checked'); inCommonsChecked = $("#inCommons").is(':checked');
clearFoundData(); clearFoundData();
// only have the autocomplete enabled if they are searching in the commons // only have the autocomplete enabled if they are searching in the commons
if (onCanvasChecked == "checked" && inCommonsChecked == "checked"){ if (onCanvasChecked && inCommonsChecked){
$('#topic_by_name_input').autocomplete( "option", "disabled", true ); $('#topic_by_name_input').autocomplete( "option", "disabled", true );
} }
else if (onCanvasChecked == "checked"){ else if (onCanvasChecked){
setTimeout(function(){showAll();},0); setTimeout(function(){showAll();},0);
$('#topic_by_name_input').autocomplete( "option", "disabled", true ); $('#topic_by_name_input').autocomplete( "option", "disabled", true );
} }
else if (inCommonsChecked == "checked"){ else if (inCommonsChecked){
$('#topic_by_name_input').autocomplete( "option", "disabled", true ); $('#topic_by_name_input').autocomplete( "option", "disabled", true );
} }
else { else {
@ -223,31 +223,23 @@ $(document).ready(function() {
}, },
stop: function (event, $elem) { stop: function (event, $elem) {
// grab the checkboxes to see if the search is on the canvas, in the commons, or both // grab the checkboxes to see if the search is on the canvas, in the commons, or both
onCanvasChecked = $("#onCanvas").attr('checked'); onCanvasChecked = $("#onCanvas").is(':checked');
inCommonsChecked = $("#inCommons").attr('checked'); inCommonsChecked = $("#inCommons").is(':checked');
var topicName = $('#topic_by_name_input').val(); var topicName = $('#topic_by_name_input').val();
// run a search on the canvas or in the commons or both // run a search on the canvas or in the commons (or both)
if (onCanvasChecked == "checked" && inCommonsChecked == "checked") { if (onCanvasChecked) {
setTimeout(function() {onCanvasSearch(topicName,null,null);}, 0); setTimeout(function() {
onCanvasSearch(topicName, null, null);
}, 0);
}
if (inCommonsChecked) {
$('#topicsByName').val(topicName); $('#topicsByName').val(topicName);
$('#topicsByUser').val(""); $('#topicsByUser').val("");
$('#topicsByMap').val(""); $('#topicsByMap').val("");
$('#get_topics_form').submit(); $('#get_topics_form').submit();
} }
else if (onCanvasChecked == "checked") {
setTimeout(function(){onCanvasSearch(topicName,null,null);},0);
}
else if (inCommonsChecked == "checked") {
$('#topicsByName').val(topicName);
$('#topicsByUser').val("");
$('#topicsByMap').val("");
$('#get_topics_form').submit();
}
else {
//do nothing
}
if (topicName == "") { if (topicName == "") {
clearFoundData(); clearFoundData();
} }