hotkey actions: toggle_expand, collapse_article: check if element exists

before acting on it (closes #815)
This commit is contained in:
Andrew Dolgov 2014-10-26 10:25:16 +04:00
parent 110ce72a72
commit 98cbae8dfa
1 changed files with 16 additions and 10 deletions

View File

@ -302,21 +302,27 @@ function init() {
hotkey_actions["collapse_article"] = function() { hotkey_actions["collapse_article"] = function() {
var id = getActiveArticleId(); var id = getActiveArticleId();
var elem = $("CICD-"+id); var elem = $("CICD-"+id);
if(elem.visible()) {
cdmCollapseArticle(null, id); if (elem) {
} if (elem.visible()) {
else { cdmCollapseArticle(null, id);
cdmExpandArticle(id); }
else {
cdmExpandArticle(id);
}
} }
}; };
hotkey_actions["toggle_expand"] = function() { hotkey_actions["toggle_expand"] = function() {
var id = getActiveArticleId(); var id = getActiveArticleId();
var elem = $("CICD-"+id); var elem = $("CICD-"+id);
if(elem.visible()) {
cdmCollapseArticle(null, id, false); if (elem) {
} if (elem.visible()) {
else { cdmCollapseArticle(null, id, false);
cdmExpandArticle(id); }
else {
cdmExpandArticle(id);
}
} }
}; };
hotkey_actions["search_dialog"] = function() { hotkey_actions["search_dialog"] = function() {