]> git.wh0rd.org - tt-rss.git/commitdiff
mobile: fix page to page navigation
authorAndrew Dolgov <fox@bah.org.ru>
Thu, 17 Dec 2009 17:35:49 +0000 (20:35 +0300)
committerAndrew Dolgov <fox@bah.org.ru>
Thu, 17 Dec 2009 17:35:49 +0000 (20:35 +0300)
lib/iui/iui.js
mobile/article.php
mobile/feed.php
mobile/functions.php
mobile/index.php

index 6001b27bcc6210f66d4855938124dbcb30b18b2b..d47cbddb25581797991902a2b3fb227faed3a9fa 100644 (file)
@@ -203,7 +203,7 @@ addEventListener("click", function(event)
                        iui.showPage($(link.hash.substr(1)));
                        setTimeout(unselect, 500);
                }
-               else if (link == $("backButton")) {
+               if (link == $("backButton")) {
                        history.back();
                } else if (link.getAttribute("type") == "submit")
                {
@@ -233,7 +233,10 @@ addEventListener("click", function(event)
                else if (!link.target)
                {
                        link.setAttribute("selected", "progress");
-                       iui.showPageByHref(link.href, null, null, null, unselect);
+
+                       var backwards = link.getAttribute("backwards");
+
+                       iui.showPageByHref(link.href, null, null, null, unselect, backwards);
                }
                else
                        return;
@@ -361,6 +364,25 @@ function updatePage(page, fromPage)
                else
                        backButton.style.display = "none";
        }        
+
+
+       var backButton = $("myBackButton");
+       if (backButton)
+       {
+               var label = page.getAttribute("myBackLabel");
+
+               if (label)
+               {
+                       backButton.style.display = "inline";
+                       backButton.innerHTML = label;
+                       backButton.href = page.getAttribute("myBackHref");
+                       backButton.target = page.getAttribute("myBackTarget");
+                       backButton.setAttribute("backwards", "true");
+               }
+               else
+                       backButton.style.display = "none";
+       }        
+
 }
 
 function slidePages(fromPage, toPage, backwards)
index 28fef041f2fed37cf082b80ca6c01e59ed17395f..2379e9395949e58be5629c78c6335781c3db2e66 100644 (file)
@@ -22,7 +22,8 @@
 
        $id = db_escape_string($_REQUEST["id"]);
        $feed_id = db_escape_string($_REQUEST["feed"]);
+       $cat_id = db_escape_string($_REQUEST["cat"]);
 
-       render_article($link, $id, $feed_id);
+       render_article($link, $id, $feed_id, $cat_id);
 ?>
 
index c729cc341fcdeee18f500da46dbe05a57fa1ab1a..610dd6adf88cb8066258fd80499d3fdb6587b64f 100644 (file)
@@ -20,8 +20,9 @@
 
        login_sequence($link, true);
 
-       $feed = db_escape_string($_REQUEST["id"]);
+       $feed_id = db_escape_string($_REQUEST["id"]);
+       $cat_id = db_escape_string($_REQUEST["cat"]);
 
-       render_headlines_list($link, $feed);
+       render_headlines_list($link, $feed_id, $cat_id);
 ?>
 
index bc458213447f71e859fb44025865434f99801980..b7b842b6579be209ecf39d035000b4c73e2dae81 100644 (file)
                
                $title = getCategoryTitle($link, $cat_id);
 
-               print "<ul id='cat-$cat_id' title='$title'>";
+               print "<ul id='cat-$cat_id' title='$title' myBackLabel='Feeds'
+                       myBackHref='index.php' myBackTarget='_self'>";
 
-               print "<li><a href='#cat-actions'>".__('Actions...')."</a></li>";
+//             print "<li><a href='#cat-actions'>".__('Actions...')."</a></li>";
 
                while ($line = db_fetch_assoc($result)) {
                        $id = $line["id"];
                        $unread = $line["unread"];
 
-                       $unread = rand(0, 100);
+//                     $unread = rand(0, 100);
 
                        if ($unread > 0) {
                                $line["title"] = $line["title"] . " ($unread)";
@@ -56,7 +57,7 @@
                                $icon_url = "../images/blank_icon.gif";
                        }
 
-                       print "<li class='$class'><a href='feed.php?id=$id'>" . 
+                       print "<li class='$class'><a href='feed.php?id=$id&cat=$cat_id'>" . 
                                "<img class='tinyIcon' src='$icon_url'/>".                              
                                $line["title"] . "</a></li>";
                }
                print "</ul>";
        }
 
-       function render_headlines_list($link, $feed_id, $is_cat = false) {
+       function render_headlines_list($link, $feed_id, $cat_id) {
 
                $feed_id = $feed_id;
                $limit = 30;
                $filter = '';
-               $is_cat = $is_cat;
+               $is_cat = false;
                $view_mode = 'adaptive';
 
                /* do not rely on params below */
                $result = $qfh_ret[0];
                $feed_title = $qfh_ret[1];
 
-               print "<ul id=\"feed-$feed_id\" title=\"$feed_title\" selected=\"true\">";
+               $cat_title = getCategoryTitle($link, $cat_id);
+
+               print "<ul id=\"feed-$feed_id\" title=\"$feed_title\" selected=\"true\"
+                       myBackLabel='$cat_title' myBackHref='cat.php?id=$cat_id'>";
 
                while ($line = db_fetch_assoc($result)) {
                        $id = $line["id"];
                                $class = 'oldItem';
                        }
 
-                       print "<li class='$class'><a href='article.php?id=$id&feed=$feed_id'>";
+                       print "<li class='$class'>
+                               <a href='article.php?id=$id&feed=$feed_id&cat=$cat_id'>";
                        print $line["title"];
                        print "</a></li>";
 
 
        }
 
-       function render_article($link, $id, $feed_id) {
+       function render_article($link, $id, $feed_id, $cat_id) {
 
                $query = "SELECT title,link,content,feed_id,comments,int_id,
                        marked,unread,published,
 
                $result = db_query($link, $query);
 
-               $line = db_fetch_assoc($result);
-
-               if (get_pref($link, 'HEADLINES_SMART_DATE')) {
-                       $updated_fmt = smart_date_time(strtotime($line["updated"]));
-               } else {
-                       $short_date = get_pref($link, 'SHORT_DATE_FORMAT');
-                       $updated_fmt = date($short_date, strtotime($line["updated"]));
-               }                               
-
-               $title = $line["title"];
-               $link = $line["link"];
-
-               print "<div class=\"panel\" id=\"article-$id\" title=\"$title\" 
-                       selected=\"true\">";
-
-//             print "<h2><a target='_blank' href='$link'>$title</a></h2>";
-
-               print "<fieldset>";
-
-               print "<div class=\"row\">";
-               print "<label id='title'><a target='_blank' href='$link'>$title</a></label>";
-               print "</div>";
+               if (db_num_rows($result) != 0) {
 
-               $is_starred = (sql_bool_to_bool($line["marked"])) ? "true" : "false";
-               $is_published = (sql_bool_to_bool($line["published"])) ? "true" : "false";
+                       $line = db_fetch_assoc($result);
 
-               print "<div class=\"row\">
-                <label>Starred</label>
-                <div class=\"toggle\" onclick=\"toggleMarked($id, this)\" toggled=\"$is_starred\"><span class=\"thumb\"></span><span class=\"toggleOn\">ON</span><span class=\"toggleOff\">OFF</span></div>
-            </div>";
-
-               print "<div class=\"row\">
-                <label>Published</label>
-                <div class=\"toggle\" onclick=\"togglePublished($id, this)\" toggled=\"$is_published\"><span class=\"thumb\"></span><span class=\"toggleOn\">ON</span><span class=\"toggleOff\">OFF</span></div>
-            </div>";
-
-
-               print "<div class=\"row\">";
-               print "<label id='updated'>Updated:</label>";
-               print "<input enabled='false' name='updated' disabled value='$updated_fmt'/>";
-               print "</div>";
-
-               print "</fieldset>";
-
-               print "<p>";
-               print $line["content"];
-               print "</p>";
+                       $tmp_result = db_query($link, "UPDATE ttrss_user_entries 
+                               SET unread = false,last_read = NOW() 
+                               WHERE ref_id = '$id'
+                               AND owner_uid = " . $_SESSION["uid"]);
 
+                       if (get_pref($link, 'HEADLINES_SMART_DATE')) {
+                               $updated_fmt = smart_date_time(strtotime($line["updated"]));
+                       } else {
+                               $short_date = get_pref($link, 'SHORT_DATE_FORMAT');
+                               $updated_fmt = date($short_date, strtotime($line["updated"]));
+                       }                               
+       
+                       $title = $line["title"];
+                       $article_link = $line["link"];
+       
+                       $feed_title = getFeedTitle($link, $feed_id, false);
+       
+                       print "<div class=\"panel\" id=\"article-$id\" title=\"$title\" 
+                               selected=\"true\"
+                               myBackLabel='$feed_title' myBackHref='feed.php?id=$feed_id&cat=$cat_id'>";
+       
+       //              print "<h2><a target='_blank' href='$link'>$title</a></h2>";
+       
+                       print "<fieldset>";
+       
+                       print "<div class=\"row\">";
+                       print "<label id='title'><a target='_blank' href='$article_link'>$title</a></label>";
+                       print "</div>";
+       
+                       $is_starred = (sql_bool_to_bool($line["marked"])) ? "true" : "false";
+                       $is_published = (sql_bool_to_bool($line["published"])) ? "true" : "false";
+       
+                       print "<div class=\"row\">
+                       <label>Starred</label>
+                       <div class=\"toggle\" onclick=\"toggleMarked($id, this)\" toggled=\"$is_starred\"><span class=\"thumb\"></span><span class=\"toggleOn\">ON</span><span class=\"toggleOff\">OFF</span></div>
+                   </div>";
+       
+                       print "<div class=\"row\">
+                       <label>Published</label>
+                       <div class=\"toggle\" onclick=\"togglePublished($id, this)\" toggled=\"$is_published\"><span class=\"thumb\"></span><span class=\"toggleOn\">ON</span><span class=\"toggleOff\">OFF</span></div>
+                   </div>";
+       
+       
+                       print "<div class=\"row\">";
+                       print "<label id='updated'>Updated:</label>";
+                       print "<input enabled='false' name='updated' disabled value='$updated_fmt'/>";
+                       print "</div>";
+       
+                       print "</fieldset>";
+       
+                       print "<p>";
+                       print $line["content"];
+                       print "</p>";
+       
+                       print "</div>";
 
-               print "</div>";
+               }
 
        }
 ?>
index a2c51093ce47532495f15df27d3c577627c379d2..4d5cf1e9cbb1c790a93a0caa79b031d7de59ae88 100644 (file)
                color : gray;
        }
 
+       #myBackButton {
+           display: none;
+           left: 6px;
+           right: auto;
+           padding: 0;
+           max-width: 55px;
+           border-width: 0 8px 0 14px;
+           -webkit-border-image: url(../lib/iui/backButton.png) 0 8 0 14;
+       }
+
        img.tinyIcon {
                max-width : 16px;
                max-height : 16px;
        function togglePublished(id, elem) {
                alert(id + " => " + elem.getAttribute('toggled'));
        }
-
 </script>
 
 <body>
     <div class="toolbar">
         <h1 id="pageTitle"></h1>
-                 <a id="backButton" class="button" href="#"></a>
+                 <a id="myBackButton" class="button" href="#"></a>
         <a class="button"  target="_self" href="logout.php">Logout</a>
     </div>