From 997429c22813408e15c73ec0ff127f0cc1a9b994 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Fri, 19 Nov 2010 20:18:20 +0300 Subject: [PATCH] add experimental support for feedlist popup menu --- FeedTree.js | 26 +++++++++++++++++++++++++- modules/backend-rpc.php | 2 +- tt-rss.js | 29 +++++++++++++++++++++++++---- 3 files changed, 51 insertions(+), 6 deletions(-) diff --git a/FeedTree.js b/FeedTree.js index f4a88e331..f01fd24cf 100644 --- a/FeedTree.js +++ b/FeedTree.js @@ -2,6 +2,7 @@ dojo.provide("fox.FeedTree"); dojo.provide("fox.FeedStoreModel"); dojo.require("dijit.Tree"); +dojo.require("dijit.Menu"); dojo.declare("fox.FeedStoreModel", dijit.tree.ForestStoreModel, { getItemById: function(id) { @@ -45,10 +46,33 @@ dojo.declare("fox.FeedStoreModel", dijit.tree.ForestStoreModel, { dojo.declare("fox.FeedTree", dijit.Tree, { _createTreeNode: function(args) { var tnode = new dijit._TreeNode(args); - + if (args.item.icon) tnode.iconNode.src = args.item.icon[0]; + var id = args.item.id[0]; + var bare_id = parseInt(id.substr(id.indexOf(':')+1)); + + if (id.match("FEED:") && bare_id > 0) { + var menu = new dijit.Menu(); + menu.row_id = bare_id; + + menu.addChild(new dijit.MenuItem({ + label: __("Edit feed"), + onClick: function() { + editFeedDlg(this.getParent().row_id); + }})); + + menu.addChild(new dijit.MenuItem({ + label: __("Update feed"), + onClick: function() { + scheduleFeedUpdate(this.getParent().row_id, false); + }})); + + menu.bindDomNode(tnode.domNode); + tnode._menu = menu; + } + //tnode.labelNode.innerHTML = args.label; return tnode; }, diff --git a/modules/backend-rpc.php b/modules/backend-rpc.php index d241df494..65f689a36 100644 --- a/modules/backend-rpc.php +++ b/modules/backend-rpc.php @@ -962,7 +962,7 @@ if ($subop == "scheduleFeedUpdate") { $feed_id = db_escape_string($_REQUEST["id"]); - $is_cat = db_escape_string($_REQUEST['is_cat']); + $is_cat = db_escape_string($_REQUEST['is_cat']) == 'true'; $message = __("Your request could not be completed."); diff --git a/tt-rss.js b/tt-rss.js index 56105167e..af9f46726 100644 --- a/tt-rss.js +++ b/tt-rss.js @@ -115,11 +115,28 @@ function updateFeedList() { 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"); + +// var node = dijit.byId("feedTree")._itemNodesMap['FEED:-2'][0].domNode +// menu.bindDomNode(node); + loading_set_progress(25); }); @@ -1100,17 +1117,21 @@ function handle_rpc_reply(transport, scheduled_call) { return true; } -function scheduleFeedUpdate() { +function scheduleFeedUpdate(id, is_cat) { try { + if (!id) { + id = getActiveFeedId(); + is_cat = activeFeedIsCat(); + } - if (!getActiveFeedId()) { + if (!id) { alert(__("Please select some feed first.")); return; } var query = "?op=rpc&subop=scheduleFeedUpdate&id=" + - param_escape(getActiveFeedId()) + - "&is_cat=" + param_escape(activeFeedIsCat()); + param_escape(id) + + "&is_cat=" + param_escape(is_cat); console.log(query);