]> git.wh0rd.org - tt-rss.git/blobdiff - js/tt-rss.js
shorten_expanded: also hide embedded attachments behind wrapper
[tt-rss.git] / js / tt-rss.js
index ed305a8bbd9d19758fa9d4c7c390f1f4f60def93..3f65a2cea0eff9f2227540538b14f5c1feb7ce83 100644 (file)
@@ -41,72 +41,76 @@ function setActiveFeedId(id, is_cat) {
 
 
 function updateFeedList() {
+       try {
+               Element.show("feedlistLoading");
 
-       Element.show("feedlistLoading");
-
-       resetCounterCache();
-
-       if (dijit.byId("feedTree")) {
-               dijit.byId("feedTree").destroyRecursive();
-       }
-
-       var store = new dojo.data.ItemFileWriteStore({
-         url: "backend.php?op=pref_feeds&method=getfeedtree&mode=2"});
-
-       var treeModel = new fox.FeedStoreModel({
-               store: store,
-               query: {
-                       "type": getInitParam('enable_feed_cats') == 1 ? "category" : "feed"
-               },
-               rootId: "root",
-               rootLabel: "Feeds",
-               childrenAttrs: ["items"]
-       });
-
-       var tree = new fox.FeedTree({
-       model: treeModel,
-       onClick: function (item, node) {
-               var id = String(item.id);
-               var is_cat = id.match("^CAT:");
-               var feed = id.substr(id.indexOf(":")+1);
-               viewfeed({feed: feed, is_cat: is_cat});
-               return false;
-       },
-       openOnClick: false,
-       showRoot: false,
-       persist: true,
-       id: "feedTree",
-       }, "feedTree");
-
-/*             var menu = new dijit.Menu({id: 'feedMenu'});
-
-       menu.addChild(new dijit.MenuItem({
-          label: "Simple menu item"
-       }));
-
-//             menu.bindDomNode(tree.domNode); */
-
-       var tmph = dojo.connect(dijit.byId('feedMenu'), '_openMyself', function (event) {
-               console.log(dijit.getEnclosingWidget(event.target));
-               dojo.disconnect(tmph);
-       });
-
-       $("feeds-holder").appendChild(tree.domNode);
-
-       var tmph = dojo.connect(tree, 'onLoad', function() {
-               dojo.disconnect(tmph);
-               Element.hide("feedlistLoading");
-
-               try {
-                       feedlist_init();
+               resetCounterCache();
 
-                       loading_set_progress(25);
-               } catch (e) {
-                       exception_error(e);
+               if (dijit.byId("feedTree")) {
+                       dijit.byId("feedTree").destroyRecursive();
                }
-       });
 
-       tree.startup();
+               var store = new dojo.data.ItemFileWriteStore({
+                       url: "backend.php?op=pref_feeds&method=getfeedtree&mode=2"
+               });
+
+               var treeModel = new fox.FeedStoreModel({
+                       store: store,
+                       query: {
+                               "type": getInitParam('enable_feed_cats') == 1 ? "category" : "feed"
+                       },
+                       rootId: "root",
+                       rootLabel: "Feeds",
+                       childrenAttrs: ["items"]
+               });
+
+               var tree = new fox.FeedTree({
+                       model: treeModel,
+                       onClick: function (item, node) {
+                               var id = String(item.id);
+                               var is_cat = id.match("^CAT:");
+                               var feed = id.substr(id.indexOf(":") + 1);
+                               viewfeed({feed: feed, is_cat: is_cat});
+                               return false;
+                       },
+                       openOnClick: false,
+                       showRoot: false,
+                       persist: true,
+                       id: "feedTree",
+               }, "feedTree");
+
+               /*              var menu = new dijit.Menu({id: 'feedMenu'});
+
+                menu.addChild(new dijit.MenuItem({
+                label: "Simple menu item"
+                }));
+
+                //             menu.bindDomNode(tree.domNode); */
+
+               var tmph = dojo.connect(dijit.byId('feedMenu'), '_openMyself', function (event) {
+                       console.log(dijit.getEnclosingWidget(event.target));
+                       dojo.disconnect(tmph);
+               });
+
+               $("feeds-holder").appendChild(tree.domNode);
+
+               var tmph = dojo.connect(tree, 'onLoad', function () {
+                       dojo.disconnect(tmph);
+                       Element.hide("feedlistLoading");
+
+                       try {
+                               feedlist_init();
+
+                               loading_set_progress(25);
+                       } catch (e) {
+                               exception_error(e);
+                       }
+               });
+
+               tree.startup();
+       } catch (e) {
+               exception_error(e);
+       }
 }
 
 function catchupAllFeeds() {
@@ -144,7 +148,7 @@ function viewCurrentFeed(method) {
 
 function timeout() {
        if (getInitParam("bw_limit") != "1") {
-               request_counters();
+               request_counters(true);
                setTimeout(timeout, 60*1000);
        }
 }
@@ -156,7 +160,7 @@ function search() {
        if (dijit.byId("searchDlg"))
                dijit.byId("searchDlg").destroyRecursive();
 
-       dialog = new dijit.Dialog({
+       var dialog = new dijit.Dialog({
                id: "searchDlg",
                title: __("Search"),
                style: "width: 600px",
@@ -224,6 +228,7 @@ function init() {
                        "dijit/form/Form",
                        "dijit/form/RadioButton",
                        "dijit/form/Select",
+               "dijit/form/MultiSelect",
                        "dijit/form/SimpleTextarea",
                        "dijit/form/TextBox",
                        "dijit/form/ComboBox",
@@ -240,6 +245,7 @@ function init() {
                        "dijit/tree/dndSource",
                        "dijit/tree/ForestStoreModel",
                        "dojo/data/ItemFileWriteStore",
+                       "fox/FeedStoreModel",
                        "fox/FeedTree" ], function (dojo, ready, parser) {
 
                        ready(function() {
@@ -360,7 +366,6 @@ function init_hotkey_actions() {
        hotkey_actions["open_in_new_window"] = function() {
                if (getActiveArticleId()) {
                        openArticleInNewWindow(getActiveArticleId());
-                       return;
                }
        };
        hotkey_actions["catchup_below"] = function() {
@@ -370,13 +375,9 @@ function init_hotkey_actions() {
                catchupRelativeToArticle(0);
        };
        hotkey_actions["article_scroll_down"] = function() {
-               var ctr = $("content_insert") ? $("content_insert") : $("headlines-frame");
-
                scrollArticle(40);
        };
        hotkey_actions["article_scroll_up"] = function() {
-               var ctr = $("content_insert") ? $("content_insert") : $("headlines-frame");
-
                scrollArticle(-40);
        };
        hotkey_actions["close_article"] = function() {
@@ -610,7 +611,7 @@ function init_second_stage() {
        dijit.getEnclosingWidget(toolbar.order_by).attr('value',
                getInitParam("default_view_order_by"));
 
-       feeds_sort_by_unread = getInitParam("feeds_sort_by_unread") == 1;
+       var feeds_sort_by_unread = getInitParam("feeds_sort_by_unread") == 1;
 
        var hash_feed_id = hash_get('f');
        var hash_feed_is_cat = hash_get('c') == "1";
@@ -628,8 +629,8 @@ function init_second_stage() {
        var hotkeys = getInitParam("hotkeys");
        var tmp = [];
 
-       for (sequence in hotkeys[1]) {
-               filtered = sequence.replace(/\|.*$/, "");
+       for (var sequence in hotkeys[1]) {
+               var filtered = sequence.replace(/\|.*$/, "");
                tmp[filtered] = hotkeys[1][sequence];
        }
 
@@ -752,7 +753,7 @@ function parse_runtime_info(data) {
 
        //console.log("parsing runtime info...");
 
-       for (k in data) {
+       for (var k in data) {
                var v = data[k];
 
 //             console.log("RI: " + k + " => " + v);
@@ -847,26 +848,15 @@ function hotkey_handler(e) {
        if (e.target.nodeName == "INPUT" || e.target.nodeName == "TEXTAREA") return;
 
        var keycode = false;
-       var shift_key = false;
-       var ctrl_key = false;
-       var alt_key = false;
-       var meta_key = false;
 
        var cmdline = $('cmdline');
 
-       shift_key = e.shiftKey;
-       ctrl_key = e.ctrlKey;
-       alt_key = e.altKey;
-       meta_key = e.metaKey;
-
        if (window.event) {
                keycode = window.event.keyCode;
        } else if (e) {
                keycode = e.which;
        }
 
-       var keychar = String.fromCharCode(keycode);
-
        if (keycode == 27) { // escape
                hotkey_prefix = false;
        }
@@ -874,9 +864,8 @@ function hotkey_handler(e) {
        if (keycode == 16) return; // ignore lone shift
        if (keycode == 17) return; // ignore lone ctrl
 
-       keychar = keychar.toLowerCase();
-
        var hotkeys = getInitParam("hotkeys");
+       var keychar = String.fromCharCode(keycode).toLowerCase();
 
        if (!hotkey_prefix && hotkeys[0].indexOf(keychar) != -1) {
 
@@ -889,6 +878,9 @@ function hotkey_handler(e) {
                cmdline.innerHTML = keychar;
                Element.show(cmdline);
 
+               e.stopPropagation();
+
+               // returning false here literally disables ctrl-c in browser lol (because C is a valid prefix)
                return true;
        }
 
@@ -897,10 +889,10 @@ function hotkey_handler(e) {
        var hotkey = keychar.search(/[a-zA-Z0-9]/) != -1 ? keychar : "(" + keycode + ")";
 
        // ensure ^*char notation
-       if (shift_key) hotkey = "*" + hotkey;
-       if (ctrl_key) hotkey = "^" + hotkey;
-       if (alt_key) hotkey = "+" + hotkey;
-       if (meta_key) hotkey = "%" + hotkey;
+       if (e.shiftKey) hotkey = "*" + hotkey;
+       if (e.ctrlKey) hotkey = "^" + hotkey;
+       if (e.altKey) hotkey = "+" + hotkey;
+       if (e.metaKey) hotkey = "%" + hotkey;
 
        hotkey = hotkey_prefix ? hotkey_prefix + " " + hotkey : hotkey;
        hotkey_prefix = false;
@@ -908,7 +900,7 @@ function hotkey_handler(e) {
        var hotkey_action = false;
        var hotkeys = getInitParam("hotkeys");
 
-       for (sequence in hotkeys[1]) {
+       for (var sequence in hotkeys[1]) {
                if (sequence == hotkey) {
                        hotkey_action = hotkeys[1][sequence];
                        break;
@@ -919,6 +911,7 @@ function hotkey_handler(e) {
 
        if (action != null) {
                action();
+               e.stopPropagation();
                return false;
        }
 }
@@ -1025,7 +1018,7 @@ function handle_rpc_json(transport, scheduled_call) {
 function switchPanelMode(wide) {
        if (isCdmMode()) return;
 
-       article_id = getActiveArticleId();
+       var article_id = getActiveArticleId();
 
        if (wide) {
                dijit.byId("headlines-wrap-inner").attr("design", 'sidebar');
@@ -1084,11 +1077,11 @@ function update_random_feed() {
 }
 
 function hash_get(key) {
-       kv = window.location.hash.substring(1).toQueryParams();
+       var kv = window.location.hash.substring(1).toQueryParams();
        return kv[key];
 }
 function hash_set(key, value) {
-       kv = window.location.hash.substring(1).toQueryParams();
+       var kv = window.location.hash.substring(1).toQueryParams();
        kv[key] = value;
        window.location.hash = $H(kv).toQueryString();
 }