diff options
-rw-r--r-- | ajax/movefeedtofolder.php | 23 | ||||
-rw-r--r-- | css/news.css | 14 | ||||
-rw-r--r-- | js/news.js | 41 | ||||
-rw-r--r-- | templates/main.php | 2 |
4 files changed, 76 insertions, 4 deletions
diff --git a/ajax/movefeedtofolder.php b/ajax/movefeedtofolder.php new file mode 100644 index 000000000..e4a78d28a --- /dev/null +++ b/ajax/movefeedtofolder.php @@ -0,0 +1,23 @@ +<?php +/** +* ownCloud - News app +* +* @author Bernhard Posselt +* Copyright (c) 2012 - Bernhard Posselt <nukeawhale@gmail.com> +* +* This file is licensed under the Affero General Public License version 3 or later. +* See the COPYING-README file +* +*/ + +// Check if we are a user +OCP\JSON::checkLoggedIn(); +OCP\JSON::checkAppEnabled('news'); +OCP\JSON::callCheck(); + +$folderId = $_POST['folderId']; +$itemId = $_POST['itemId']; + +// TODO: save + +OCP\JSON::success();
\ No newline at end of file diff --git a/css/news.css b/css/news.css index 94d886813..2ba2b87bb 100644 --- a/css/news.css +++ b/css/news.css @@ -166,11 +166,15 @@ div.feed_controls { -moz-box-sizing: border-box; } - #feeds ul { + #feeds > ul { height: 100%; overflow: auto; } + .dnd_over { + background-color: #ffcc00 !important; + background-image: none !important; + } #feeds .subscriptions, #feeds .subscriptions:hover { background-image: url('%appswebroot%/news/img/icon.svg'); @@ -209,6 +213,7 @@ div.feed_controls { -moz-transition: background-color 200ms ease 0s; transition: background-color 200ms ease 0s; background-color: #f1f1f1; + z-index: 1; } #feeds li.feed a { @@ -304,6 +309,8 @@ div.feed_controls { padding: 0; border: 0; border-bottom: 1px solid #bbb; + position: relative; + z-index: 1; } #feeds li.collapsable_container.open { @@ -331,6 +338,8 @@ div.feed_controls { #feeds li.collapsable_container.open > ul { margin: 0 8px 8px 8px; + position: relative; + z-index: 1; } #feeds li.collapsable_container > ul > li { @@ -343,7 +352,8 @@ div.feed_controls { } #feeds div.collapsable { - position: relative; + position: relative; + z-index: 1; border-radius: 5px; } diff --git a/js/news.js b/js/news.js index bba97f11d..e17565b85 100644 --- a/js/news.js +++ b/js/news.js @@ -334,6 +334,33 @@ News={ } }); }, + moveToFolder:function(folder, item){ + var folderId = $(folder).data('id'); + var itemId = $(item).data('id'); + if($(item).parent().parent().data('id') == folderId){ + // FIXME uncomment the return and remove the following lines + // in the if part to prevent dropping in the same folder + // return; + folderId = 0; + $('#feeds > ul').append(item); + } else { + $(folder).children('ul').append(item); + } + + transformCollapsableTrigger(); + + data = { + folderId: folderId, + itemId: itemId + }; + $.post(OC.filePath('news', 'ajax', 'movefeedtofolder.php'), data, function(jsondata){ + if(jsondata.status != 'success'){ + OC.dialogs.alert(t('news', 'Error while saving the item in a folder'), t('news', 'Error')); + window.location.reload(); + } + }); + return false; + }, // this array is used to store ids to prevent sending too // many posts when scrolling. the structure is: feed_id: boolean processing:{}, @@ -587,7 +614,19 @@ function transformCollapsableTrigger() { } function setupFeedList() { - + $('.feed').draggable({ + revert: true, + stack: '> li', + zIndex: 1000, + axis: 'y', + }); + $('.collapsable_container').droppable({ + accept: '.feed', + hoverClass: 'dnd_over', + drop: function(event, ui){ + return News.Feed.moveToFolder(this, ui.draggable); + } + }); $('.feed').click(function() { News.Feed.load($(this).attr('data-id')); }); diff --git a/templates/main.php b/templates/main.php index 606f9fa76..d895e04fb 100644 --- a/templates/main.php +++ b/templates/main.php @@ -11,7 +11,7 @@ echo $this->inc("part.items.header"); <div id="leftcontent" class="leftcontent"> <div id="feeds"> - <ul> + <ul data-id="0"> <li data-id="-2" class="subscriptions folder"><a href="#" ><?php echo $l->t('New articles'); ?></a></li> <li data-id="-1" class="starred folder"><a href="#" ><?php echo $l->t('Starred'); ?></a></li> <?php echo $this->inc("part.feeds"); ?> |