diff options
author | Bernhard Posselt <nukeawhale@gmail.com> | 2012-08-16 03:27:07 +0200 |
---|---|---|
committer | Bernhard Posselt <nukeawhale@gmail.com> | 2012-08-16 03:27:07 +0200 |
commit | 6dcf152409c21f883e3082068bab75dc10a7fa39 (patch) | |
tree | 5008c69494b618178ad3504c3d4e3f18b4952ac1 /js | |
parent | 0ca106420e921582459cbaba9b520ed50e7b4a91 (diff) |
added basics for drag and drop
Diffstat (limited to 'js')
-rw-r--r-- | js/news.js | 41 |
1 files changed, 40 insertions, 1 deletions
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')); }); |