resize_headlines: add exception handling

This commit is contained in:
Andrew Dolgov 2008-05-20 11:41:00 +01:00
parent f74cfded6f
commit e8f7d7264c
1 changed files with 67 additions and 61 deletions

128
tt-rss.js
View File

@ -361,71 +361,77 @@ function init() {
function resize_headlines(delta_x, delta_y) {
debug("resize_headlines: " + delta_x + ":" + delta_y);
try {
var h_frame = document.getElementById("headlines-frame");
var c_frame = document.getElementById("content-frame");
var f_frame = document.getElementById("footer");
var feeds_frame = document.getElementById("feeds-holder");
var resize_grab = document.getElementById("resize-grabber");
if (!c_frame || !h_frame) return;
if (feeds_frame && getInitParam("theme") == "compat") {
feeds_frame.style.bottom = f_frame.offsetHeight + "px";
}
if (getInitParam("theme") == "3pane") {
if (delta_x != undefined) {
if (c_frame.offsetLeft - delta_x > feeds_frame.offsetWidth + feeds_frame.offsetLeft + 100 && c_frame.offsetWidth + delta_x > 100) {
hor_offset = hor_offset + delta_x;
debug("resize_headlines: " + delta_x + ":" + delta_y);
var h_frame = document.getElementById("headlines-frame");
var c_frame = document.getElementById("content-frame");
var f_frame = document.getElementById("footer");
var feeds_frame = document.getElementById("feeds-holder");
var resize_grab = document.getElementById("resize-grabber");
if (!c_frame || !h_frame) return;
if (feeds_frame && getInitParam("theme") == "compat") {
feeds_frame.style.bottom = f_frame.offsetHeight + "px";
}
if (getInitParam("theme") == "3pane") {
if (delta_x != undefined) {
if (c_frame.offsetLeft - delta_x > feeds_frame.offsetWidth + feeds_frame.offsetLeft + 100 && c_frame.offsetWidth + delta_x > 100) {
hor_offset = hor_offset + delta_x;
}
}
debug("resize_headlines: HOR-mode: " + hor_offset);
c_frame.style.width = (400 + hor_offset) + "px";
h_frame.style.right = c_frame.offsetWidth - 1 + "px";
resize_grab.style.top = (h_frame.offsetTop + h_frame.offsetHeight - 60) + "px";
resize_grab.style.left = (h_frame.offsetLeft + h_frame.offsetWidth -
4) + "px";
resize_grab.style.display = "block";
} else {
if (delta_y != undefined) {
if (c_frame.offsetHeight + delta_y > 100 && h_frame.offsetHeight - delta_y > 100) {
ver_offset = ver_offset + delta_y;
}
}
debug("resize_headlines: VER-mode: " + ver_offset);
h_frame.style.height = (300 - ver_offset) + "px";
c_frame.style.top = (h_frame.offsetTop + h_frame.offsetHeight + 1) + "px";
h_frame.style.height = h_frame.offsetHeight + "px";
var theme_c = 0;
if (getInitParam("theme") == "graycube") theme_c = 1;
resize_grab.style.top = (h_frame.offsetTop + h_frame.offsetHeight -
4 - theme_c) + "px";
resize_grab.style.display = "block";
}
if (getInitParam("cookie_lifetime") != 0) {
setCookie("ttrss_offset_ver", ver_offset,
getInitParam("cookie_lifetime"));
setCookie("ttrss_offset_hor", hor_offset,
getInitParam("cookie_lifetime"));
} else {
setCookie("ttrss_offset_ver", ver_offset);
setCookie("ttrss_offset_hor", hor_offset);
}
debug("resize_headlines: HOR-mode: " + hor_offset);
c_frame.style.width = (400 + hor_offset) + "px";
h_frame.style.right = c_frame.offsetWidth - 1 + "px";
resize_grab.style.top = (h_frame.offsetTop + h_frame.offsetHeight - 60) + "px";
resize_grab.style.left = (h_frame.offsetLeft + h_frame.offsetWidth -
4) + "px";
resize_grab.style.display = "block";
} else {
if (delta_y != undefined) {
if (c_frame.offsetHeight + delta_y > 100 && h_frame.offsetHeight - delta_y > 100) {
ver_offset = ver_offset + delta_y;
}
}
debug("resize_headlines: VER-mode: " + ver_offset);
h_frame.style.height = (300 - ver_offset) + "px";
c_frame.style.top = (h_frame.offsetTop + h_frame.offsetHeight + 1) + "px";
h_frame.style.height = h_frame.offsetHeight + "px";
var theme_c = 0;
if (getInitParam("theme") == "graycube") theme_c = 1;
resize_grab.style.top = (h_frame.offsetTop + h_frame.offsetHeight -
4 - theme_c) + "px";
resize_grab.style.display = "block";
}
if (getInitParam("cookie_lifetime") != 0) {
setCookie("ttrss_offset_ver", ver_offset,
getInitParam("cookie_lifetime"));
setCookie("ttrss_offset_hor", hor_offset,
getInitParam("cookie_lifetime"));
} else {
setCookie("ttrss_offset_ver", ver_offset);
setCookie("ttrss_offset_hor", hor_offset);
} catch (e) {
exception_error("resize_headlines", e);
}
}