From b13eb01d3c690baf406b87e457956d1de88f2d02 Mon Sep 17 00:00:00 2001 From: rabuzarus <> Date: Wed, 11 May 2016 16:04:11 +0200 Subject: [PATCH] item deletion: use js to delete items. so we don't have to reload the page --- css/style.css | 16 ++++++++++++++++ js/textedit.js | 15 +++++++++++++++ js/theme.js | 15 +++++++++++++++ templates/jot-header.tpl | 24 ++++++++++++++++++++++-- templates/search_item.tpl | 4 ++-- templates/threaded_conversation.tpl | 4 ++-- templates/wall_thread.tpl | 4 ++-- 7 files changed, 74 insertions(+), 8 deletions(-) diff --git a/css/style.css b/css/style.css index 949c9eef85..942b89b550 100644 --- a/css/style.css +++ b/css/style.css @@ -84,6 +84,22 @@ iframe, img { line-height: 1.5; } +a#item-delete-selected { + cursor: pointer; + color: white; + position: fixed; + z-index: 49; + right: 20px; + top: 100px; + opacity: 0.8; + font-size: 2.9em; + padding: 0 12px 0 12px; + border-radius: 10px; + background-color: $link_color; + line-height: 1.5; + display: none; +} + /* * Overwriting and Extend Bootstrap */ diff --git a/js/textedit.js b/js/textedit.js index f9944d5ff7..40b49685a7 100644 --- a/js/textedit.js +++ b/js/textedit.js @@ -178,3 +178,18 @@ function qCommentInsert(obj,id) { } function confirmDelete() { return confirm(aStr.delitem); } + +function dropItem(url, object) { + var confirm = confirmDelete(); + if(confirm) { + $('body').css('cursor', 'wait'); + $(object).fadeTo('fast', 0.33, function () { + $.get(url).done(function() { + $(object).remove(); + $('body').css('cursor', 'auto'); + }); + }); + } +} + + \ No newline at end of file diff --git a/js/theme.js b/js/theme.js index 1fa89c00b9..5cc5e49f02 100644 --- a/js/theme.js +++ b/js/theme.js @@ -68,6 +68,21 @@ $(document).ready(function(){ if( $("#jot-popup").is(":hidden")) $("#topbar-second > .container > #navbar-button #jotOpen").hide(); } + // show bulk deletion button at network page if checkbox is checked + $('input.item-select').change(function(){ + + if($(this).is(':checked')) { + $("a#item-delete-selected").fadeTo('slow', 1); + $("a#item-delete-selected").show(); + } else { + $("a#item-delete-selected").fadeTo('slow', 0, function(){ + $("a#item-delete-selected").hide(); + }); + + } + + }); + // add search-headding to the scecond navbar if( $(".search-headding")) { $(".search-headding").appendTo("#topbar-second > .container > #tabmenu"); diff --git a/templates/jot-header.tpl b/templates/jot-header.tpl index f5b50b5595..5b826f45e2 100644 --- a/templates/jot-header.tpl +++ b/templates/jot-header.tpl @@ -204,26 +204,46 @@ function enableOnUser(){ **/ }); - function deleteCheckedItems() { if(confirm('{{$delitems}}')) { var checkedstr = ''; + var ItemsToDelete = {}; $("#item-delete-selected").hide(); $('#item-delete-selected-rotator').show(); + $('body').css('cursor', 'wait'); $('.item-select').each( function() { if($(this).is(':checked')) { if(checkedstr.length != 0) { checkedstr = checkedstr + ',' + $(this).val(); + var deleteItem = this.closest(".wall-item-container"); + ItemsToDelete[deleteItem.id] = deleteItem; } else { checkedstr = $(this).val(); } + + // Get the corresponding item container + var deleteItem = this.closest(".wall-item-container"); + ItemsToDelete[deleteItem.id] = deleteItem; } }); + + // Fade the the the container from the items we want to delete + for(var key in ItemsToDelete) { + $(ItemsToDelete[key]).fadeTo('fast', 0.33); + }; + $.post('item', { dropitems: checkedstr }, function(data) { - window.location.reload(); + }).done(function() { + // Loop through the ItemsToDelete Object and remove + // corresponding item div + for(var key in ItemsToDelete) { + $(ItemsToDelete[key]).remove(); + } + $('body').css('cursor', 'auto'); + $('#item-delete-selected-rotator').hide(); }); } } diff --git a/templates/search_item.tpl b/templates/search_item.tpl index da5b0d8e98..d2f0b23785 100644 --- a/templates/search_item.tpl +++ b/templates/search_item.tpl @@ -19,7 +19,7 @@
diff --git a/templates/threaded_conversation.tpl b/templates/threaded_conversation.tpl index 48a3f4ed6c..f60ce345a8 100644 --- a/templates/threaded_conversation.tpl +++ b/templates/threaded_conversation.tpl @@ -16,8 +16,8 @@ {{if $dropping}} - - {{$dropping}} + + {{/if}} diff --git a/templates/wall_thread.tpl b/templates/wall_thread.tpl index eaeb23c98e..3fa53764d0 100644 --- a/templates/wall_thread.tpl +++ b/templates/wall_thread.tpl @@ -90,7 +90,7 @@ as the value of $top_child_total (this is done at the end of this file) {{if $item.edpost}} {{* edit the posting *}}