]> git.wh0rd.org Git - tt-rss.git/commitdiff
correct headlines scroll position in moveToPost()
authorAndrew Dolgov <fox@madoka.spb.ru>
Wed, 16 May 2007 03:36:40 +0000 (04:36 +0100)
committerAndrew Dolgov <fox@madoka.spb.ru>
Wed, 16 May 2007 03:36:40 +0000 (04:36 +0100)
functions.js
viewfeed.js

index f922183cc8ecf5e1bbde7fad9b8fa2e6a66bf7d9..eea2515a031e345dbc162bf9a0610327829721e8 100644 (file)
@@ -252,13 +252,13 @@ function hotkey_handler(e) {
                        if (new_feed) viewfeed(new_feed, '');
                }
 
-               if (!is_safari() && (keycode == 78 || keycode == 40)) { // n, down
+               if (keycode == 78 || keycode == 40) { // n, down
                        if (typeof moveToPost != 'undefined') {
                                return moveToPost('next');
                        }
                }
        
-               if (!is_safari() && (keycode == 80 || keycode == 38)) { // p, up
+               if (keycode == 80 || keycode == 38) { // p, up
                        if (typeof moveToPost != 'undefined') {
                                return moveToPost('prev');
                        }
index 622ea6378ab66e58cfe327c5f2f45fa4dd9fc44c..27af8c08edc4d66c30d45f33d8422758d30ca847 100644 (file)
@@ -132,7 +132,8 @@ function article_callback() {
                        
                        } else {
                                debug("article_callback: returned no XML object");
-                               f.innerHTML = "<div class='whiteBox'>" + __('Could not display article (missing XML object)') + "</div>";
+                               /* var f = document.getElementById("content-frame");
+                               f.innerHTML = "<div class='whiteBox'>" + __('Could not display article (missing XML object)') + "</div>"; */
                        }
                } catch (e) {
                        exception_error("article_callback", e);
@@ -180,7 +181,6 @@ function view(id, feed_id, skip_history) {
        
                enableHotkeys();
        
-               active_post_id = id; 
                //setActiveFeedId(feed_id);
 
                var query = "backend.php?op=view&id=" + param_escape(id) +
@@ -193,7 +193,9 @@ function view(id, feed_id, skip_history) {
                        xmlhttp.abort();
                }
 
-               if (cached_article || xmlhttp_ready(xmlhttp)) {
+               if (xmlhttp_ready(xmlhttp)) {
+
+                       active_post_id = id; 
 
                        cleanSelected("headlinesList");
 
@@ -346,6 +348,34 @@ function toggleMark(id) {
 
 }
 
+function correctHeadlinesOffset(id) {
+       
+       try {
+
+               var hlist = document.getElementById("headlinesList");
+               var container = document.getElementById("headlinesInnerContainer");
+               var row = document.getElementById("RROW-" + id);
+       
+               var viewport = container.offsetHeight;
+       
+               var rel_offset_top = row.offsetTop - container.scrollTop;
+               var rel_offset_bottom = row.offsetTop + row.offsetHeight - container.scrollTop;
+       
+               debug("Rtop: " + rel_offset_top + " Rbtm: " + rel_offset_bottom);
+               debug("Vport: " + viewport);
+       
+               if (rel_offset_top <= 0 || rel_offset_top > viewport) {
+                       container.scrollTop = row.offsetTop;
+               } else if (rel_offset_bottom > viewport) {
+                       container.scrollTop = row.offsetTop + row.offsetHeight - viewport;              
+               } 
+
+       } catch (e) {
+               exception_error("correctHeadlinesOffset", e);
+       }
+
+}
+
 function moveToPost(mode) {
 
        // check for combined mode
@@ -354,8 +384,8 @@ function moveToPost(mode) {
 
        var rows = getVisibleHeadlineIds();
 
-       var prev_id;
-       var next_id;
+       var prev_id = false;
+       var next_id = false;
 
        if (!document.getElementById('RROW-' + active_post_id)) {
                active_post_id = false;
@@ -374,13 +404,15 @@ function moveToPost(mode) {
        }
 
        if (mode == "next") {
-               if (next_id != undefined) {
+               if (next_id) {
+                       correctHeadlinesOffset(next_id);
                        view(next_id, getActiveFeedId());
                }
        }
 
        if (mode == "prev") {
-               if ( prev_id != undefined) {
+               if (prev_id) {
+                       correctHeadlinesOffset(prev_id);
                        view(prev_id, getActiveFeedId());
                }
        }