diff options
author | Bernhard Posselt <nukeawhale@gmail.com> | 2012-08-31 19:52:53 +0200 |
---|---|---|
committer | Bernhard Posselt <nukeawhale@gmail.com> | 2012-09-01 00:31:39 +0200 |
commit | 9b0ccc5641aa49d6b41a846d9c63bfc5746efe88 (patch) | |
tree | b87b8ea9390a353c4d497719f722fa117b36b67b /js | |
parent | 3876f38f3cb82545c075026ab0b149e00bd9eaef (diff) |
wired removing and adding of feeds
Diffstat (limited to 'js')
-rw-r--r-- | js/items.js | 2 | ||||
-rw-r--r-- | js/menu.js | 21 | ||||
-rw-r--r-- | js/news.js | 56 |
3 files changed, 39 insertions, 40 deletions
diff --git a/js/items.js b/js/items.js index 87242de13..b3bd46ca3 100644 --- a/js/items.js +++ b/js/items.js @@ -56,7 +56,7 @@ var t = t || function(app, string){ return string; }; // mock translation for lo onSuccessCallback(); } else { OC.dialogs.alert(t('news', 'Error while loading the feed'), t('news', 'Error')); - this._$articleList.children('ul').show(); + self._$articleList.children('ul').show(); } self._$articleList.removeClass('loading'); }); diff --git a/js/menu.js b/js/menu.js index 7e5170573..f302f6ae4 100644 --- a/js/menu.js +++ b/js/menu.js @@ -152,7 +152,8 @@ var News = News || {}; } var $html; - var icon = 'url("' + data.icon + '")'; + var icon; + switch(type){ case MenuNodeType.Feed: $html = this._$mockFeed.clone(); @@ -166,7 +167,9 @@ var News = News || {}; } $html.children('.title').html(data.title); - $html.children('.title').css('background-image', icon); + if(data.icon !== undefined){ + $html.children('.title').css('background-image', 'url("' + data.icon + '")'); + } $html.children('.unread_items_counter').html(data.unreadCount); $html.attr('data-id', id); $html.children('ul').attr('data-id', id); @@ -249,6 +252,7 @@ var News = News || {}; Menu.prototype.setShowAll = function(showAll){ this._showAll = showAll; this.triggerHideRead(); + this._load(this._activeFeedType, this._activeFeedId); }; /** @@ -378,11 +382,11 @@ var News = News || {}; }); $listItem.children('.buttons').children('.feeds_delete').click(function(){ - self._delete(MenuNodeType.Folder, id); + self._delete(MenuNodeType.Feed, id); }); $listItem.children('.buttons').children('.feeds_markread').click(function(){ - self._markRead(MenuNodeType.Folder, id); + self._markRead(MenuNodeType.Feed, id); }); $listItem.draggable({ @@ -401,11 +405,12 @@ var News = News || {}; * @param $listItem the jquery list element */ Menu.prototype._bindStarred = function($listItem){ + var self = this; this._setUnreadCount(MenuNodeType.Starred, 0, this._getAndRemoveUnreadCount($listItem)); $listItem.children('.title').click(function(){ - self._load(MenuNodeType.Starred, id); + self._load(MenuNodeType.Starred, -1); return false; }); @@ -416,13 +421,14 @@ var News = News || {}; * @param $listItem the jquery list element */ Menu.prototype._bindSubscriptions = function($listItem){ + var self = this; $listItem.children('.title').click(function(){ - self._load(MenuNodeType.Subscriptions, id); + self._load(MenuNodeType.Subscriptions, -2); return false; }); $listItem.children('.feeds_markread').click(function(){ - self._markRead(MenuNodeType.Folder, id); + self._markRead(MenuNodeType.Subscriptions, 0); }); }; @@ -477,6 +483,7 @@ var News = News || {}; if(type === self._activeFeedType && id === self._activeFeedId){ window.location.reload(); } + self._resetOpenFolders(); } else{ OC.dialogs.alert(jsondata.data.message, t('news', 'Error')); } diff --git a/js/news.js b/js/news.js index 57c70a066..e7ae6e643 100644 --- a/js/news.js +++ b/js/news.js @@ -62,13 +62,14 @@ News = { $.post(url, { name: displayname, parentid: folderid }, function(jsondata){ if(jsondata.status == 'success'){ - // if we got a parent folder - if(folderid > 0){ - $('.collapsable_container[data-id="' + folderid + '"] > ul').append(jsondata.data.listfolder); - } else { - $('#feeds > ul').append(jsondata.data.listfolder); - } - setupFeedList(); + // FIXME: this should receive json by default + var $folder = $(jsondata.data.listfolder); + var title = $folder.children('.title').html(); + var id = $folder.data('id'); + var data = { + title: title + }; + News.Objects.Menu.addNode(0, News.MenuNodeType.Folder, id, data); $('#addfolder_dialog').dialog('destroy').remove(); } else { OC.dialogs.alert(jsondata.data.message, t('news', 'Error')); @@ -107,24 +108,22 @@ News = { if($('#firstrun').length > 0){ window.location.reload(); } else { - if(jsondata.status == 'success'){ - if(folderid > 0){ - $('.collapsable_container[data-id="' + folderid + '"] > ul').append(jsondata.data.listfeed); - } else { - $('#feeds > ul').append(jsondata.data.listfeed); - } - setupFeedList(); - News.Feed.load(jsondata.data.feedid); - - //$('#ui-dialog-title-addfeed_dialog').html('Feed added. Do you want to add another feed?') - - /* - OC.dialogs.confirm(t('news', ), t('news', 'Feed added!'), function(answer) { - if(!answer) { - $('#addfeed_dialog').dialog('destroy').remove(); - $('ul.accordion').before(jsondata.data.part_newfeed); - } - });*/ + if(jsondata.status == 'success'){ + // FIXME: this should receive json by default + var $feed = $(jsondata.data.listfeed); + var title = $feed.children('.title').html(); + var icon = $feed.css('background-image').replace(/url\(|\)$/ig, ""); + var unreadCount = $feed.children('.unread_items_count').html(); + var id = $feed.data('id'); + var data = { + title: title, + unreadCount: unreadCount, + icon: icon + }; + News.Objects.Menu.addNode(folderid, News.MenuNodeType.Feed, id, data); + News.Objects.Menu._load(News.MenuNodeType.Feed, jsondata.data.feedid); + + $('#addfeed_dialog').dialog('destroy').remove(); } else { OC.dialogs.alert(jsondata.data.message, t('news', 'Error')); } @@ -141,16 +140,9 @@ News = { } }); }, - load:function(feedId) { - - }, - - }, - - } |