From 0f12ead5dd6d7d72e741ce0aadf222341ce94f3b Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Tue, 26 Mar 2013 20:24:03 +0400 Subject: [PATCH] digest: add barebones smartphone mode --- plugins/digest/digest.js | 34 +++- plugins/digest/digest_body.php | 22 ++- plugins/digest/mobile.css | 345 +++++++++++++++++++++++++++++++++ 3 files changed, 390 insertions(+), 11 deletions(-) create mode 100644 plugins/digest/mobile.css diff --git a/plugins/digest/digest.js b/plugins/digest/digest.js index c8a08648..6d90a9c8 100644 --- a/plugins/digest/digest.js +++ b/plugins/digest/digest.js @@ -2,6 +2,7 @@ var last_feeds = []; var init_params = {}; var hotkeys_map = false; var hotkey_prefix = false; +var mobile_mode = false; var _active_feed_id = false; var _update_timeout = false; @@ -122,7 +123,7 @@ function set_selected_article(article_id) { }); } catch (e) { - exception_error("mark_selected_feed", e); + exception_error("set_selected_article", e); } } @@ -141,7 +142,7 @@ function set_selected_feed(feed_id) { _active_feed_id = feed_id; } catch (e) { - exception_error("mark_selected_feed", e); + exception_error("set_selected_feed", e); } } @@ -298,6 +299,20 @@ function view(article_id) { } } +function close_feed() { + $("headlines").removeClassName("move"); + + if (mobile_mode) set_selected_feed(false); +} + +function go_back() { + if ($("article").hasClassName("visible")) { + close_article(); + } else { + close_feed(); + } +} + function close_article() { $("content").removeClassName("move"); $("article").removeClassName("visible"); @@ -306,6 +321,8 @@ function close_article() { function viewfeed(feed_id, offset, replace, no_effects, no_indicator, callback) { try { + $("headlines").addClassName("move"); + if (!feed_id) feed_id = _active_feed_id; if (offset == undefined) offset = 0; if (replace == undefined) replace = (offset == 0); @@ -659,17 +676,20 @@ function init_second_stage() { document.onkeydown = hotkey_handler; - window.setTimeout('viewfeed(-4)', 100); - _update_timeout = window.setTimeout('update()', 5*1000); - } }); + if (!mobile_mode) + window.setTimeout('viewfeed(-4)', 100); + _update_timeout = window.setTimeout('update()', 5*1000); + } }); } catch (e) { exception_error("init_second_stage", e); } } -function init() { +function init(mobile) { try { + mobile_mode = mobile; + new Ajax.Request("backend.php", { parameters: {op: "rpc", method: "sanityCheck"}, onComplete: function(transport) { @@ -858,7 +878,7 @@ function hotkey_handler(e) { switch (keycode) { case 27: // esc - close_article(); + go_back(); return false; } diff --git a/plugins/digest/digest_body.php b/plugins/digest/digest_body.php index 0dbe40b9..e7434fe7 100644 --- a/plugins/digest/digest_body.php +++ b/plugins/digest/digest_body.php @@ -7,7 +7,21 @@ Tiny Tiny RSS - + isMobile() || @$_REQUEST['mode'] == 'mobile') { + $_SESSION["digest_mobile"] = 1; + echo stylesheet_tag("plugins/digest/mobile.css"); + } else { + $_SESSION["digest_mobile"] = 0; + echo stylesheet_tag("plugins/digest/digest.css"); + } + ?> + + @@ -33,7 +47,7 @@ @@ -51,8 +65,8 @@