Related questions block disappear when the user is not in the title field.
git-svn-id: http://svn.osqa.net/svnroot/osqa/trunk@525
0cfe37f9-358a-4d5e-be75-
b63607b5c754
$(currentSideBar).fadeIn('slow');
}
$(currentSideBar).fadeIn('slow');
}
$(function () {
$('div#editor_side_bar').hide();
$('div#tags_side_bar').hide();
$(function () {
$('div#editor_side_bar').hide();
$('div#tags_side_bar').hide();
var results_cache = {};
function reload_suggestions_box(e) {
var results_cache = {};
function reload_suggestions_box(e) {
+ var relatedQuestionsDiv = $('#ask-related-questions');
var q = $input.val().replace(/^\s+|\s+$/g,"");
var q = $input.val().replace(/^\s+|\s+$/g,"");
- if (q.length == 0) {
- $('#ask-related-questions').html('');
+ if(q.length == 0) {
+ close_suggestions_box();
+ relatedQuestionsDiv.html('');
+ } else if(relatedQuestionsDiv[0].style.height == 0 || relatedQuestionsDiv[0].style.height == '0px') {
+ relatedQuestionsDiv.animate({'height':'150'}, 350);
}
if (results_cache[q] && results_cache[q] != '') {
}
if (results_cache[q] && results_cache[q] != '') {
- $('#ask-related-questions').html(results_cache[q]);
+ relatedQuestionsDiv.html(results_cache[q]);
+ if(data.length == 0) {
+ relatedQuestionsDiv.html('<br /><br /><div align="center">No questions like this have been found.</div>');
+ return;
+ }
+
var html = '';
for (var i = 0; i < data.length; i++) {
var item = template.replace(new RegExp('%URL%', 'g'), data[i].url)
var html = '';
for (var i = 0; i < data.length; i++) {
var item = template.replace(new RegExp('%URL%', 'g'), data[i].url)
- $('#ask-related-questions').html(html);
+ relatedQuestionsDiv.html(html);
}
}, 'json');
return false;
}
}
}, 'json');
return false;
}
+ function close_suggestions_box() {
+ $('#ask-related-questions').animate({'height':'0'},350, function() {
+ $('#ask-related-questions').html('');
+ });
+ }
+
$input.keyup(reload_suggestions_box);
$input.keyup(reload_suggestions_box);
+ $input.focus(reload_suggestions_box);
+ $input.blur(close_suggestions_box);
+
+ // for chrome
+ $input.keydown(focus_on_question);
+ function focus_on_question(e) {
+ var is_chrome = navigator.userAgent.toLowerCase().indexOf('chrome') > -1;
+
+ if(e.keyCode == 9 && is_chrome) {
+ $('#editor')[0].focus();
+ }
+ }
});
\ No newline at end of file
});
\ No newline at end of file