summaryrefslogtreecommitdiffstats
path: root/js/menu.js
diff options
context:
space:
mode:
authorBernhard Posselt <nukeawhale@gmail.com>2012-08-31 20:11:25 +0200
committerBernhard Posselt <nukeawhale@gmail.com>2012-09-01 00:31:39 +0200
commit798a2001ba698b6e7daeb1254253edbaedc1c59f (patch)
tree4d8c5c43b63dae114f049caf2f73845c9d23b7b5 /js/menu.js
parent9b0ccc5641aa49d6b41a846d9c63bfc5746efe88 (diff)
fixed adding feeds
Diffstat (limited to 'js/menu.js')
-rw-r--r--js/menu.js49
1 files changed, 30 insertions, 19 deletions
diff --git a/js/menu.js b/js/menu.js
index f302f6ae4..74bd337d4 100644
--- a/js/menu.js
+++ b/js/menu.js
@@ -74,6 +74,12 @@ trigger this manually, use:
menu.triggerHideRead();
+If you want to load a feed or folder directly, use
+
+ var id = 2;
+ var type = News.MenuNodeType.Folder;
+ menu.load(type, id);
+
*/
var News = News || {};
@@ -140,11 +146,14 @@ var News = News || {};
* {title: '', icon: 'img/png.png', 'unreadCount': 3}
*/
Menu.prototype.addNode = function(parentId, type, id, data){
+ parentId = parseInt(parentId);
+ id = parseInt(id);
+
var $parentNode;
if(parseInt(parentId) === 0){
$parentNode = this._$root;
} else {
- $parentNode = this._getNodeFromTypeAndId(type, id).children('ul');
+ $parentNode = this._getNodeFromTypeAndId(MenuNodeType.Folder, parentId).children('ul');
// every folder we add to should be opened again
$parentNode.parent().addClass('open');
$parentNode.show();
@@ -195,6 +204,7 @@ var News = News || {};
*/
Menu.prototype.updateNode = function(type, id, data){
var $node = this._getNodeFromTypeAndId(type, id);
+ id = parseInt(id);
if(data.title !== undefined){
$node.children('.title').html(data.title);
@@ -211,6 +221,7 @@ var News = News || {};
* @param id the id
*/
Menu.prototype.removeNode = function(type, id){
+ id = parseInt(id);
var $node = this._getNodeFromTypeAndId(type, id);
$node.remove();
};
@@ -252,7 +263,7 @@ var News = News || {};
Menu.prototype.setShowAll = function(showAll){
this._showAll = showAll;
this.triggerHideRead();
- this._load(this._activeFeedType, this._activeFeedId);
+ this.load(this._activeFeedType, this._activeFeedId);
};
/**
@@ -263,6 +274,19 @@ var News = News || {};
};
/**
+ * Loads a new feed into the right content
+ * @param type the type (MenuNodeType)
+ * @param id the id
+ */
+ Menu.prototype.load = function(type, id){
+ var self = this;
+ this._items.load(type, id, function(){
+ self._setActiveFeed(type, id);
+ self.triggerHideRead();
+ });
+ };
+
+ /**
* Binds the menu on an existing menu
* @param css Selector the selector to get the element with jquery
*/
@@ -340,7 +364,7 @@ var News = News || {};
this._bindDroppable($listItem.children('ul'));
$listItem.children('.title').click(function(){
- self._load(MenuNodeType.Folder, id);
+ self.load(MenuNodeType.Folder, id);
return false;
});
@@ -376,7 +400,7 @@ var News = News || {};
if($(this).hasClass('noclick')){
$(this).removeClass('noclick');
} else {
- self._load(MenuNodeType.Feed, id);
+ self.load(MenuNodeType.Feed, id);
}
return false;
});
@@ -410,7 +434,7 @@ var News = News || {};
this._getAndRemoveUnreadCount($listItem));
$listItem.children('.title').click(function(){
- self._load(MenuNodeType.Starred, -1);
+ self.load(MenuNodeType.Starred, -1);
return false;
});
@@ -423,7 +447,7 @@ var News = News || {};
Menu.prototype._bindSubscriptions = function($listItem){
var self = this;
$listItem.children('.title').click(function(){
- self._load(MenuNodeType.Subscriptions, -2);
+ self.load(MenuNodeType.Subscriptions, -2);
return false;
});
@@ -433,19 +457,6 @@ var News = News || {};
};
/**
- * Loads a new feed into the right content
- * @param type the type (MenuNodeType)
- * @param id the id
- */
- Menu.prototype._load = function(type, id){
- var self = this;
- this._items.load(type, id, function(){
- self._setActiveFeed(type, id);
- self.triggerHideRead();
- });
- };
-
- /**
* Deletes a feed
* @param type the type (MenuNodeType)
* @param id the id