implement labels submenu; rework init process so that feedlist_init depends on feedTree being loaded
This commit is contained in:
parent
bc372fe30f
commit
1beea80017
11
FeedTree.js
11
FeedTree.js
|
@ -5,6 +5,17 @@ dojo.require("dijit.Tree");
|
||||||
dojo.require("dijit.Menu");
|
dojo.require("dijit.Menu");
|
||||||
|
|
||||||
dojo.declare("fox.FeedStoreModel", dijit.tree.ForestStoreModel, {
|
dojo.declare("fox.FeedStoreModel", dijit.tree.ForestStoreModel, {
|
||||||
|
getItemsInCategory: function (id) {
|
||||||
|
if (!this.store._itemsByIdentity) return undefined;
|
||||||
|
|
||||||
|
cat = this.store._itemsByIdentity['CAT:' + id];
|
||||||
|
|
||||||
|
if (cat && cat.items)
|
||||||
|
return cat.items;
|
||||||
|
else
|
||||||
|
return undefined;
|
||||||
|
|
||||||
|
},
|
||||||
getItemById: function(id) {
|
getItemById: function(id) {
|
||||||
return this.store._itemsByIdentity[id];
|
return this.store._itemsByIdentity[id];
|
||||||
},
|
},
|
||||||
|
|
|
@ -133,6 +133,7 @@ function updateFeedList() {
|
||||||
var tmph = dojo.connect(tree, 'onLoad', function() {
|
var tmph = dojo.connect(tree, 'onLoad', function() {
|
||||||
dojo.disconnect(tmph);
|
dojo.disconnect(tmph);
|
||||||
Element.hide("feedlistLoading");
|
Element.hide("feedlistLoading");
|
||||||
|
feedlist_init();
|
||||||
|
|
||||||
// var node = dijit.byId("feedTree")._itemNodesMap['FEED:-2'][0].domNode
|
// var node = dijit.byId("feedTree")._itemNodesMap['FEED:-2'][0].domNode
|
||||||
// menu.bindDomNode(node);
|
// menu.bindDomNode(node);
|
||||||
|
@ -328,7 +329,6 @@ function init_second_stage() {
|
||||||
if (has_local_storage())
|
if (has_local_storage())
|
||||||
localStorage.clear();
|
localStorage.clear();
|
||||||
|
|
||||||
feedlist_init();
|
|
||||||
setTimeout("timeout()", 3000);
|
setTimeout("timeout()", 3000);
|
||||||
|
|
||||||
console.log("second stage ok");
|
console.log("second stage ok");
|
||||||
|
|
44
viewfeed.js
44
viewfeed.js
|
@ -669,10 +669,10 @@ function toggleUnread(id, cmode, effect) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function selectionRemoveLabel(id) {
|
function selectionRemoveLabel(id, ids) {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
var ids = getSelectedArticleIds2();
|
if (!ids) var ids = getSelectedArticleIds2();
|
||||||
|
|
||||||
if (ids.length == 0) {
|
if (ids.length == 0) {
|
||||||
alert(__("No articles are selected."));
|
alert(__("No articles are selected."));
|
||||||
|
@ -707,10 +707,10 @@ function selectionRemoveLabel(id) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function selectionAssignLabel(id) {
|
function selectionAssignLabel(id, ids) {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
var ids = getSelectedArticleIds2();
|
if (!ids) ids = getSelectedArticleIds2();
|
||||||
|
|
||||||
if (ids.length == 0) {
|
if (ids.length == 0) {
|
||||||
alert(__("No articles are selected."));
|
alert(__("No articles are selected."));
|
||||||
|
@ -2265,7 +2265,9 @@ function initHeadlinesMenu() {
|
||||||
label: __("View in a new tab"),
|
label: __("View in a new tab"),
|
||||||
onClick: function(event) {
|
onClick: function(event) {
|
||||||
hlOpenInNewTab(event, this.getParent().callerRowId);
|
hlOpenInNewTab(event, this.getParent().callerRowId);
|
||||||
}}));
|
}}));
|
||||||
|
|
||||||
|
menu.addChild(new dijit.MenuSeparator());
|
||||||
|
|
||||||
menu.addChild(new dijit.MenuItem({
|
menu.addChild(new dijit.MenuItem({
|
||||||
label: __("Open original article"),
|
label: __("Open original article"),
|
||||||
|
@ -2273,6 +2275,38 @@ function initHeadlinesMenu() {
|
||||||
openArticleInNewWindow(this.getParent().callerRowId);
|
openArticleInNewWindow(this.getParent().callerRowId);
|
||||||
}}));
|
}}));
|
||||||
|
|
||||||
|
var labels = dijit.byId("feedTree").model.getItemsInCategory(-2);
|
||||||
|
|
||||||
|
if (labels) {
|
||||||
|
|
||||||
|
menu.addChild(new dijit.MenuSeparator());
|
||||||
|
|
||||||
|
var labelsMenu = new dijit.Menu({ownerMenu: menu});
|
||||||
|
|
||||||
|
labels.each(function(label) {
|
||||||
|
var id = label.id[0];
|
||||||
|
var bare_id = id.substr(id.indexOf(":")+1);
|
||||||
|
var name = label.name[0];
|
||||||
|
|
||||||
|
bare_id = -11-bare_id;
|
||||||
|
|
||||||
|
labelsMenu.addChild(new dijit.MenuItem({
|
||||||
|
label: name,
|
||||||
|
labelId: bare_id,
|
||||||
|
onClick: function(event) {
|
||||||
|
//console.log(this.labelId);
|
||||||
|
//console.log(this.getParent().ownerMenu.callerRowId);
|
||||||
|
selectionAssignLabel(this.labelId,
|
||||||
|
[this.getParent().ownerMenu.callerRowId]);
|
||||||
|
}}));
|
||||||
|
});
|
||||||
|
|
||||||
|
menu.addChild(new dijit.PopupMenuItem({
|
||||||
|
label: __("Labels"),
|
||||||
|
popup: labelsMenu,
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
menu.startup();
|
menu.startup();
|
||||||
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|
Loading…
Reference in New Issue