From b63c5f27853aded30c492bdb94a680e5a9c9648b Mon Sep 17 00:00:00 2001 From: Mario Date: Sat, 14 Nov 2020 21:28:50 +0000 Subject: Polling fallback to server sent events. Polling is the default. SSE must be enabled in /admin/site > Advanced > Enable SSE Notifications if desired. --- view/js/main.js | 82 ++++++++++++++++++++++++++++++++++--------------- view/tpl/admin_site.tpl | 1 + view/tpl/head.tpl | 1 + 3 files changed, 59 insertions(+), 25 deletions(-) (limited to 'view') diff --git a/view/js/main.js b/view/js/main.js index 8ceb0b143..560868046 100644 --- a/view/js/main.js +++ b/view/js/main.js @@ -31,6 +31,7 @@ var sse_offset = 0; var sse_type; var sse_partial_result = false; var sse_rmids = []; +var sse_fallback_interval; var page_cache = {}; @@ -94,37 +95,56 @@ $(document).ready(function() { jQuery.timeago.settings.allowFuture = true; - if(typeof(window.SharedWorker) === 'undefined') { - // notifications with multiple tabs open will not work very well in this scenario - var evtSource = new EventSource('/sse'); - evtSource.addEventListener('notifications', function(e) { - var obj = JSON.parse(e.data); - sse_handleNotifications(obj, false, false); - }, false); + if(sse_enabled) { + if(typeof(window.SharedWorker) === 'undefined') { + // notifications with multiple tabs open will not work very well in this scenario + var evtSource = new EventSource('/sse'); - document.addEventListener('visibilitychange', function() { - if (!document.hidden) { - sse_offset = 0; - sse_bs_init(); - } - }, false); + evtSource.addEventListener('notifications', function(e) { + var obj = JSON.parse(e.data); + sse_handleNotifications(obj, false, false); + }, false); - } - else { - var myWorker = new SharedWorker('/view/js/sse_worker.js', localUser); + document.addEventListener('visibilitychange', function() { + if (!document.hidden) { + sse_offset = 0; + sse_bs_init(); + } + }, false); - myWorker.port.onmessage = function(e) { - obj = e.data; - console.log(obj); - sse_handleNotifications(obj, false, false); } + else { + var myWorker = new SharedWorker('/view/js/sse_worker.js', localUser); - myWorker.onerror = function(e) { - myWorker.port.close(); + myWorker.port.onmessage = function(e) { + obj = e.data; + console.log(obj); + sse_handleNotifications(obj, false, false); + } + + myWorker.onerror = function(e) { + myWorker.port.close(); + } + + myWorker.port.start(); } + } + else { + if (!document.hidden) + sse_fallback_interval = setInterval(sse_fallback, updateInterval); - myWorker.port.start(); + document.addEventListener('visibilitychange', function() { + if (document.hidden) { + clearInterval(sse_fallback_interval); + } + else { + sse_offset = 0; + sse_bs_init(); + sse_fallback_interval = setInterval(sse_fallback, updateInterval); + } + + }, false); } $('.notification-link').on('click', { replace: true, followup: false }, sse_bs_notifications); @@ -224,6 +244,8 @@ $(document).ready(function() { cache_next_page(); }); + + }); function getConversationSettings() { @@ -1763,8 +1785,6 @@ function sse_bs_init() { } function sse_bs_counts() { - - if(sse_bs_active) return; @@ -2022,3 +2042,15 @@ function sse_setNotificationsStatus() { } } + +function sse_fallback() { + $.get('/sse', function(obj) { + if(! obj) + return; + + console.log('sse fallback'); + console.log(obj); + + sse_handleNotifications(obj, false, false); + }); +} diff --git a/view/tpl/admin_site.tpl b/view/tpl/admin_site.tpl index 5e10e6eea..8d32ba9a4 100755 --- a/view/tpl/admin_site.tpl +++ b/view/tpl/admin_site.tpl @@ -95,6 +95,7 @@

{{$advanced}}

+ {{include file="field_checkbox.tpl" field=$sse_enabled}} {{include file="field_input.tpl" field=$imagick_path}} {{include file="field_input.tpl" field=$proxy}} {{include file="field_input.tpl" field=$proxyuser}} diff --git a/view/tpl/head.tpl b/view/tpl/head.tpl index bd4cf3747..0d212e029 100755 --- a/view/tpl/head.tpl +++ b/view/tpl/head.tpl @@ -9,6 +9,7 @@ {{$plugins}} -- cgit v1.2.3 From 6c94bbc93fcdbcb729e119bea55f87b5334f650f Mon Sep 17 00:00:00 2001 From: Mario Date: Sat, 21 Nov 2020 20:52:38 +0000 Subject: collase the updated content --- view/js/main.js | 2 ++ 1 file changed, 2 insertions(+) (limited to 'view') diff --git a/view/js/main.js b/view/js/main.js index 5b6431858..0bc4261f5 100644 --- a/view/js/main.js +++ b/view/js/main.js @@ -1168,6 +1168,7 @@ function dolike(ident, verb) { $('#thread-wrapper-' + data.orig_id).replaceWith(data.html); } $('#wall-item-ago-' + data.id + ' .autotime').timeago(); + collapseHeight(); liking = 0; } }); @@ -1388,6 +1389,7 @@ function post_comment(id) { $('#wall-item-comment-wrapper-' + id).before(data.html); $('#wall-item-ago-' + data.id + ' .autotime').timeago(); $('body').css('cursor', 'unset'); + collapseHeight(); commentBusy = false; } -- cgit v1.2.3 From c0adf31da9a0d8f897dc68ab632c736891318ad5 Mon Sep 17 00:00:00 2001 From: Mario Date: Sun, 22 Nov 2020 13:07:03 +0000 Subject: fix like issue with remote channels --- view/js/main.js | 44 +++++++++++++++++++++----------------------- view/tpl/build_query.tpl | 3 +++ 2 files changed, 24 insertions(+), 23 deletions(-) (limited to 'view') diff --git a/view/js/main.js b/view/js/main.js index 0bc4261f5..4c8cd0adf 100644 --- a/view/js/main.js +++ b/view/js/main.js @@ -1149,30 +1149,28 @@ function justifyPhotosAjax(id) { function dolike(ident, verb) { $('#like-rotator-' + ident.toString()).show(); - if(! localUser) { - $.get('like/' + ident.toString() + '?verb=' + verb, updateInit); - } - else { - $.get('like/' + ident.toString() + '?verb=' + verb, function (data) { - data = JSON.parse(data); - if(data.success) { - // this is a bit tricky since the top level thread wrapper wraps the whole thread - if($('#thread-wrapper-' + data.orig_id).hasClass('toplevel_item')) { - var wrapper = $('
').html( data.html ).find('#wall-item-outside-wrapper-' + data.id); - $('#wall-item-outside-wrapper-' + data.orig_id).html(wrapper[0].innerHTML); - // those were not replaced - swap the id - $('#thread-wrapper-' + data.orig_id).attr('id', 'thread-wrapper-' + data.id); - $('#wall-item-outside-wrapper-' + data.orig_id).attr('id', 'wall-item-outside-wrapper-' + data.id); - } - else { - $('#thread-wrapper-' + data.orig_id).replaceWith(data.html); - } - $('#wall-item-ago-' + data.id + ' .autotime').timeago(); - collapseHeight(); - liking = 0; + if(typeof conv_mode == typeof undefined) + conv_mode = ''; + + $.get('like/' + ident.toString() + '?verb=' + verb + '&conv_mode=' + conv_mode, function (data) { + data = JSON.parse(data); + if(data.success) { + // this is a bit tricky since the top level thread wrapper wraps the whole thread + if($('#thread-wrapper-' + data.orig_id).hasClass('toplevel_item')) { + var wrapper = $('
').html( data.html ).find('#wall-item-outside-wrapper-' + data.id); + $('#wall-item-outside-wrapper-' + data.orig_id).html(wrapper[0].innerHTML); + // those were not replaced - swap the id + $('#thread-wrapper-' + data.orig_id).attr('id', 'thread-wrapper-' + data.id); + $('#wall-item-outside-wrapper-' + data.orig_id).attr('id', 'wall-item-outside-wrapper-' + data.id); } - }); - } + else { + $('#thread-wrapper-' + data.orig_id).replaceWith(data.html); + } + $('#wall-item-ago-' + data.id + ' .autotime').timeago(); + collapseHeight(); + liking = 0; + } + }); liking = 1; } diff --git a/view/tpl/build_query.tpl b/view/tpl/build_query.tpl index 69c5e301f..83e756367 100755 --- a/view/tpl/build_query.tpl +++ b/view/tpl/build_query.tpl @@ -2,6 +2,9 @@ var bParam_cmd = "{{$baseurl}}/update/{{$pgtype}}"; + {{if $conv_mode}} + var conv_mode = '{{$conv_mode}}'; + {{/if}} var bParam_uid = {{$uid}}; var bParam_gid = {{$gid}}; -- cgit v1.2.3 From 451468d1297ba41a6c9ea29709444ceb15185bfb Mon Sep 17 00:00:00 2001 From: Mario Date: Sun, 22 Nov 2020 16:37:20 +0000 Subject: fix mod item issue with remote channels --- view/js/main.js | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'view') diff --git a/view/js/main.js b/view/js/main.js index 4c8cd0adf..35b03e03b 100644 --- a/view/js/main.js +++ b/view/js/main.js @@ -1371,25 +1371,25 @@ function post_comment(id) { $('body').css('cursor', 'wait'); $("#comment-preview-inp-" + id).val("0"); + if(typeof conv_mode == typeof undefined) + conv_mode = ''; + + var form_data = $("#comment-edit-form-" + id).serialize(); + $.post( "item", - $("#comment-edit-form-" + id).serialize(), + form_data + '&conv_mode=' + conv_mode, function(data) { if(data.success) { + localStorage.removeItem("comment_body-" + id); $("#comment-edit-preview-" + id).hide(); $("#comment-edit-text-" + id).val('').blur().attr('placeholder', aStr.comment); - - if(! localUser) { - updateInit(); - } - else { - $('#wall-item-comment-wrapper-' + id).before(data.html); - $('#wall-item-ago-' + data.id + ' .autotime').timeago(); - $('body').css('cursor', 'unset'); - collapseHeight(); - commentBusy = false; - } + $('#wall-item-comment-wrapper-' + id).before(data.html); + $('#wall-item-ago-' + data.id + ' .autotime').timeago(); + $('body').css('cursor', 'unset'); + collapseHeight(); + commentBusy = false; var tarea = document.getElementById("comment-edit-text-" + id); if(tarea) { -- cgit v1.2.3 From 34d54fd3099217ccabcd812b1883ee7882caad77 Mon Sep 17 00:00:00 2001 From: Mario Date: Mon, 23 Nov 2020 19:57:28 +0000 Subject: simplify code and fix issue with categories --- view/js/main.js | 1 - 1 file changed, 1 deletion(-) (limited to 'view') diff --git a/view/js/main.js b/view/js/main.js index 35b03e03b..d39e22b1a 100644 --- a/view/js/main.js +++ b/view/js/main.js @@ -1153,7 +1153,6 @@ function dolike(ident, verb) { conv_mode = ''; $.get('like/' + ident.toString() + '?verb=' + verb + '&conv_mode=' + conv_mode, function (data) { - data = JSON.parse(data); if(data.success) { // this is a bit tricky since the top level thread wrapper wraps the whole thread if($('#thread-wrapper-' + data.orig_id).hasClass('toplevel_item')) { -- cgit v1.2.3 From 4419c93d8062794e5c2bbc222699881e5b97fc99 Mon Sep 17 00:00:00 2001 From: Mario Date: Thu, 26 Nov 2020 07:58:57 +0000 Subject: this should not be required anymore --- view/js/main.js | 5 ----- 1 file changed, 5 deletions(-) (limited to 'view') diff --git a/view/js/main.js b/view/js/main.js index d39e22b1a..ca82e3101 100644 --- a/view/js/main.js +++ b/view/js/main.js @@ -1380,7 +1380,6 @@ function post_comment(id) { form_data + '&conv_mode=' + conv_mode, function(data) { if(data.success) { - localStorage.removeItem("comment_body-" + id); $("#comment-edit-preview-" + id).hide(); $("#comment-edit-text-" + id).val('').blur().attr('placeholder', aStr.comment); @@ -1395,10 +1394,6 @@ function post_comment(id) { commentClose(tarea, id); $(document).off( "click.commentOpen"); } - - } - if(data.reload) { - window.location.href=data.reload; } }, "json" -- cgit v1.2.3 From 2a154f8c9a772d61e7dabb5e3fd110ba00cc6007 Mon Sep 17 00:00:00 2001 From: Mario Date: Mon, 14 Dec 2020 11:02:20 +0000 Subject: merge branch files_ng into dev --- view/css/mod_cloud.css | 66 +++++- view/js/acl.js | 4 +- view/js/main.js | 83 ++++--- view/js/mod_cloud.js | 441 ++++++++++++++++++++++++++++---------- view/pdl/mod_cloud.pdl | 1 + view/theme/redbasic/css/style.css | 20 +- view/tpl/breadcrumb.tpl | 11 + view/tpl/categories_widget.tpl | 6 +- view/tpl/cloud_actionspanel.tpl | 15 +- view/tpl/cloud_directory.tpl | 290 ++++++++++++++++++++----- view/tpl/field_select.tpl | 2 +- view/tpl/xchan_vcard.tpl | 31 ++- 12 files changed, 716 insertions(+), 254 deletions(-) create mode 100644 view/tpl/breadcrumb.tpl (limited to 'view') diff --git a/view/css/mod_cloud.css b/view/css/mod_cloud.css index 83deddf8a..8dce7f180 100644 --- a/view/css/mod_cloud.css +++ b/view/css/mod_cloud.css @@ -1,10 +1,14 @@ #files-mkdir-tools, #files-upload-tools, -[id^="perms-panel-"] { +.cloud-tool, +.cloud-multi-tool, +#multi-dbtn-acl, +#multi-dropdown-button { display: none; } -[id^="perms-panel-"] { +.attach-edit-panel, +#attach-multi-edit-panel { padding: 3px 10px 0px 10px !important; } @@ -17,28 +21,40 @@ width: 100%; } -#cloud-index td:nth-child(1){ +#cloud-index td:nth-child(3) a { + display: block; +} + +#cloud-index td:nth-child(1) { padding: 7px 3px 7px 10px; } -#cloud-index td:nth-child(2){ +#cloud-index td:nth-child(6) { + padding: 7px 10px 7px 3px; +} + +#cloud-index td:nth-child(3) { word-break: break-all; } -#cloud-index th:nth-child(8), -#cloud-index td:nth-child(8){ +#cloud-index td:nth-child(4) { + white-space: nowrap; +} + +#cloud-index th:nth-child(7), +#cloud-index td:nth-child(7) { padding: 7px 3px; white-space: nowrap; } -#cloud-index th:nth-child(9), -#cloud-index td:nth-child(9){ - padding: 7px 10px 7px 7px; +#cloud-index th:nth-child(8), +#cloud-index td:nth-child(8) { + padding: 7px 10px; white-space: nowrap; } .cloud-index-tool { - padding: 7px 10px; + padding: 7px 0px; } #files-upload { @@ -52,9 +68,39 @@ box-shadow: inset 0 0px 7px #5cb85c; } +.attach-drop-ok { + background-color: aliceblue !important; +} + +.attach-drop-zone { + border-top-width: 3px; + border-top-style: dashed; + border-top-color: #eee; + border-bottom-width: 3px; + border-bottom-style: dashed; + border-bottom-color: #eee; +} + .upload-progress-bar { background: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mOM2RFTDwAE2QHxFMHIIwAAAABJRU5ErkJggg==') repeat-y; background-size: 0px; padding: 0px !important; height: 3px; } + +.bootstrap-tagsinput input[type=text] { + height: unset; +} + +.bootstrap-tagsinput { + box-shadow: none; +} + +.breadcrumb { + padding: 0px 10px 0px 10px; + margin: 0px 0px 3px 0px; +} + +.breadcrumb-item { + margin: 0px; +} diff --git a/view/js/acl.js b/view/js/acl.js index 940fdaa44..ee6cb062f 100644 --- a/view/js/acl.js +++ b/view/js/acl.js @@ -30,7 +30,7 @@ function ACL(backend_url) { that.custom = $("#acl-custom"); that.acl_select = $("#acl-select"); - // set the initial ACL lists in case the enclosing form gets submitted before the ajax loader completes. + // set the initial ACL lists in case the enclosing form gets submitted before the ajax loader completes. //that.on_submit(); /*events*/ @@ -90,7 +90,7 @@ ACL.prototype.get_form_data = function(event) { } -// no longer called only on submit - call to update whenever a change occurs to the acl list. +// no longer called only on submit - call to update whenever a change occurs to the acl list. ACL.prototype.on_submit = function() { $('.acl-field').remove(); diff --git a/view/js/main.js b/view/js/main.js index ca82e3101..7df705603 100644 --- a/view/js/main.js +++ b/view/js/main.js @@ -44,7 +44,7 @@ if(localStorage.getItem('uid') !== localUser.toString()) { window.onstorage = function(e) { if(e.key === 'uid' && parseInt(e.newValue) !== localUser) { if(window_needs_alert) { - window_needs_alert = false; + window_needs_alert = false; alert("Your identity has changed. Page reload required!"); window.location.reload(); return; @@ -99,12 +99,12 @@ $(document).ready(function() { wordSeparator : aStr['t16'], numbers : aStr['t17'], }; - + jQuery.timeago.settings.allowFuture = true; if(sse_enabled) { if(typeof(window.SharedWorker) === 'undefined') { - // notifications with multiple tabs open will not work very well in this scenario + // notifications with multiple tabs open will not work very well in this scenario var evtSource = new EventSource('/sse'); evtSource.addEventListener('notifications', function(e) { @@ -298,7 +298,7 @@ function handle_comment_form(e) { $('#' + commentElm).addClass('expanded').removeAttr('placeholder'); $('#' + commentElm).attr('tabindex','9'); $('#' + submitElm).attr('tabindex','10'); - + form.find(':not(:visible)').show(); } @@ -452,7 +452,7 @@ function insertCommentAttach(comment,id) { $('body').css('cursor', 'wait'); $('#invisible-comment-upload').trigger('click'); - + return false; } @@ -631,7 +631,7 @@ function updateConvItems(mode,data) { if(mode === 'append') { next = 'threads-end'; } - + if(mode === 'replace') { $('.thread-parent').remove(); // clear existing content } @@ -652,7 +652,7 @@ function updateConvItems(mode,data) { if($('#collapsed-comments-'+itmId).is(':visible')) isVisible = true; - // insert the content according to the mode and first_page + // insert the content according to the mode and first_page // and whether or not the content exists already (overwrite it) if($('#' + ident).length == 0) { @@ -765,7 +765,7 @@ function updateConvItems(mode,data) { } // Setup to determine if the media player is playing. This affects - // some content loading decisions. + // some content loading decisions. $('video').off('playing'); $('video').off('pause'); @@ -1253,24 +1253,25 @@ function dopin(id) { } function dropItem(url, object) { + var confirm = confirmDelete(); + if(confirm) { + var id = url.split('/')[2]; + $('body').css('cursor', 'wait'); + $(object + ', #pinned-wrapper-' + id).css('opacity', 0.33); - var confirm = confirmDelete(); - if(confirm) { - var id = url.split('/')[2]; - $('body').css('cursor', 'wait'); - $(object + ', #pinned-wrapper-' + id).fadeTo('fast', 0.33, function () { - $.get(url).done(function() { - $(object + ', #pinned-wrapper-' + id).remove(); - $('body').css('cursor', 'auto'); - }); - }); - if($('#wall-item-pinned-' + id).length) - $.post('pin/pin', { 'id' : id }); - return true; - } - else { - return false; + $.get(url, function() { + $(object + ', #pinned-wrapper-' + id).remove(); + $('body').css('cursor', 'auto'); + }); + + if($('#wall-item-pinned-' + id).length) + $.post('pin/pin', { 'id' : id }); + + return true; } + else { + return false; + } } function dosubthread(ident) { @@ -1339,18 +1340,6 @@ function lockview(type, id) { }); } -function filestorage(event, nick, id) { - $('#cloud-index-' + last_filestorage_id).removeClass('cloud-index-active'); - $('#perms-panel-' + last_filestorage_id).hide().html(''); - $('#file-edit-' + id).show(); - $.get('filestorage/' + nick + '/' + id + '/edit', function(data) { - $('#cloud-index-' + id).addClass('cloud-index-active'); - $('#perms-panel-' + id).html(data).show(); - $('#file-edit-' + id).hide(); - last_filestorage_id = id; - }); -} - function submitPoll(id) { $.post('vote/' + id, @@ -1473,17 +1462,17 @@ function preview_mail() { } function bin2hex(s) { - // Converts the binary representation of data to hex - // - // version: 812.316 - // discuss at: http://phpjs.org/functions/bin2hex - // + original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net) - // + bugfixed by: Onno Marsman - // + bugfixed by: Linuxworld - // * example 1: bin2hex('Kev'); - // * returns 1: '4b6576' - // * example 2: bin2hex(String.fromCharCode(0x00)); - // * returns 2: '00' + // Converts the binary representation of data to hex + // + // version: 812.316 + // discuss at: http://phpjs.org/functions/bin2hex + // + original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net) + // + bugfixed by: Onno Marsman + // + bugfixed by: Linuxworld + // * example 1: bin2hex('Kev'); + // * returns 1: '4b6576' + // * example 2: bin2hex(String.fromCharCode(0x00)); + // * returns 2: '00' var v,i, f = 0, a = []; s += ''; f = s.length; diff --git a/view/js/mod_cloud.js b/view/js/mod_cloud.js index 031895caf..7f2bdfab7 100644 --- a/view/js/mod_cloud.js +++ b/view/js/mod_cloud.js @@ -3,22 +3,341 @@ */ $(document).ready(function () { + // call initialization file if (window.File && window.FileList && window.FileReader) { UploadInit(); } + + var attach_drop_id; + var attach_draging; + + // Per File Tools + + $('.cloud-tool-perms-btn').on('click', function (e) { + e.preventDefault(); + let id = $(this).data('id'); + activate_id(id); + }); + + $('.cloud-tool-rename-btn').on('click', function (e) { + e.preventDefault(); + let id = $(this).data('id'); + activate_id(id); + $('#cloud-tool-rename-' + id).show(); + }); + + $('.cloud-tool-move-btn').on('click', function (e) { + e.preventDefault(); + let id = $(this).data('id'); + activate_id(id); + $('#cloud-tool-move-' + id).show(); + }); + + $('.cloud-tool-categories-btn').on('click', function (e) { + e.preventDefault(); + let id = $(this).data('id'); + activate_id(id); + $('#id_categories_' + id).tagsinput({ + tagClass: 'badge badge-pill badge-warning text-dark' + }); + $('#cloud-tool-categories-' + id).show(); + }); + + $('.cloud-tool-download-btn').on('click', function (e) { + close_and_deactivate_all_panels(); + }); + + $('.cloud-tool-delete-btn').on('click', function (e) { + e.preventDefault(); + let id = $(this).data('id'); + + close_and_deactivate_all_panels(); + + let confirm = confirmDelete(); + if (confirm) { + $('body').css('cursor', 'wait'); + $('#cloud-index-' + id).css('opacity', 0.33); + + let form = $('#attach_edit_form_' + id).serializeArray(); + form.push({name: 'delete', value: 1}); + + $.post('attach_edit', form, function (data) { + if (data.success) { + $('#cloud-index-' + id + ', #cloud-tools-' + id).remove(); + $('body').css('cursor', 'auto'); + } + return true; + }); + + } + return false; + }); + + $('.cloud-tool-cancel-btn').on('click', function (e) { + e.preventDefault(); + let id = $(this).data('id'); + close_and_deactivate_all_panels(); + $('#attach_edit_form_' + id).trigger('reset'); + $('#id_categories_' + id).tagsinput('destroy'); + }); + + // Per File Tools Eend + + // DnD + + $(document).on('drop', function (e) { + e.preventDefault(); + e.stopPropagation(); + }); + + $(document).on('dragover', function (e) { + e.preventDefault(); + e.stopPropagation(); + }); + + $(document).on('dragleave', function (e) { + e.preventDefault(); + e.stopPropagation(); + }); + + $('.cloud-index.attach-drop').on('drop', function (e) { + + let target = $(this); + let folder = target.data('folder'); + let id = target.data('id'); + + + if(typeof folder === typeof undefined) { + return false; + } + + // Check if it's a file + if (e.dataTransfer.files[0]) { + $('#file-folder').val(folder); + return true; + } + + if(id === attach_drop_id) { + return false; + } + + if(target.hasClass('attach-drop-zone') && attach_draging) { + return false; + } + + target.removeClass('attach-drop-ok'); + + $.post('attach_edit', {'channel_id': channelId, 'dnd': 1, 'attach_id': attach_drop_id, ['newfolder_' + attach_drop_id]: folder }, function (data) { + if (data.success) { + $('#cloud-index-' + attach_drop_id + ', #cloud-tools-' + attach_drop_id).remove(); + attach_drop_id = null; + } + }); + }); + + $('.cloud-index.attach-drop').on('dragover', function (e) { + let target = $(this); + + if(target.hasClass('attach-drop-zone') && attach_draging) { + return false; + } + + target.addClass('attach-drop-ok'); + }); + + $('.cloud-index').on('dragleave', function (e) { + let target = $(this); + target.removeClass('attach-drop-ok'); + }); + + $('.cloud-index').on('dragstart', function (e) { + let target = $(this); + attach_drop_id = target.data('id'); + // dragstart is not fired if a file is draged onto the window + // we use this to distinguish between drags and file drops + attach_draging = true; + }); + + $('.cloud-index').on('dragend', function (e) { + let target = $(this); + target.removeClass('attach-drop-ok'); + attach_draging = false; + }); + + // DnD End + + // Multi Tools + + $('#cloud-multi-tool-select-all').on('change', function (e) { + if ($(this).is(':checked')) { + $('.cloud-multi-tool-checkbox').prop('checked', true); + $('.cloud-index:not(#cloud-index-up)').addClass('cloud-index-selected cloud-index-active'); + $('.cloud-tools').addClass('cloud-index-selected'); + } + else { + $('.cloud-multi-tool-checkbox').prop('checked', false); + $('.cloud-index').removeClass('cloud-index-selected cloud-index-active'); + $('.cloud-tools').removeClass('cloud-index-selected'); + } + + $('.cloud-multi-tool-checkbox').trigger('change'); + }); + + + $('.cloud-multi-tool-checkbox').on('change', function (e) { + let id = $(this).val(); + + if ($(this).is(':checked')) { + $('#cloud-index-' + id).addClass('cloud-index-selected cloud-index-active'); + $('#cloud-tools-' + id).addClass('cloud-index-selected'); + $('').prependTo('#attach_multi_edit_form'); + } + else { + $('#cloud-index-' + id).removeClass('cloud-index-selected cloud-index-active'); + $('#cloud-tools-' + id).removeClass('cloud-index-selected'); + if ($('#cloud-multi-tool-select-all').is(':checked')) + $('#cloud-multi-tool-select-all').prop('checked', false); + + $('#aid_' + id).remove(); + } + + if($('.cloud-multi-tool-checkbox:checked').length) { + close_all_panels(); + $('#cloud-multi-actions').addClass('bg-warning'); + $('#multi-dropdown-button').fadeIn(); + } + else { + $('#cloud-multi-actions').removeClass('bg-warning'); + $('#multi-dropdown-button').fadeOut(); + close_and_deactivate_all_panels(); + disable_multi_acl(); + } + + }); + + $('#cloud-multi-tool-perms-btn').on('click', function (e) { + e.preventDefault(); + + close_all_panels(); + enable_multi_acl(); + + $('#cloud-multi-tool-submit').show(); + }); + + $('#cloud-multi-tool-move-btn').on('click', function (e) { + e.preventDefault(); + + close_all_panels(); + disable_multi_acl(); + + $('#cloud-multi-tool-submit, #cloud-multi-tool-move').show(); + }); + + $('#cloud-multi-tool-categories-btn').on('click', function (e) { + e.preventDefault(); + + close_all_panels(); + disable_multi_acl(); + + $('#id_categories').tagsinput({ + tagClass: 'badge badge-pill badge-warning text-dark' + }); + + $('#cloud-multi-tool-submit, #cloud-multi-tool-categories').show(); + }); + + $('#cloud-multi-tool-delete-btn').on('click', function (e) { + e.preventDefault(); + + let post_data = $('.cloud-multi-tool-checkbox').serializeArray(); + + if(! post_data.length) { + return false; + } + let confirm = confirmDelete(); + if (confirm) { + $('body').css('cursor', 'wait'); + $('.cloud-index-selected').css('opacity', 0.33); + + post_data.push( + { name: 'channel_id', value: channelId }, + { name: 'delete', value: 1}, + ); + + $.post('attach_edit', post_data, function (data) { + if (data.success) { + console.log(data); + $('.cloud-index-selected').remove(); + $('body').css('cursor', 'auto'); + } + return true; + }); + } + return false; + + }); + + $('.cloud-multi-tool-cancel-btn').on('click', function (e) { + e.preventDefault(); + + close_and_deactivate_all_panels(); + disable_multi_acl(); + + $('#attach_multi_edit_form').trigger('reset'); + $('#id_categories').tagsinput('destroy'); + }); + + // Multi Tools End + + // Helper Functions + + function disable_multi_acl() { + $('#multi-perms').val(0); + $('#multi-dbtn-acl, #recurse_container').hide(); + $('#attach-multi-edit-perms').removeClass('btn-group'); + } + + function enable_multi_acl() { + $('#multi-perms').val(1); + $('#multi-dbtn-acl, #recurse_container').show(); + $('#attach-multi-edit-perms').addClass('btn-group'); + } + + function close_all_panels() { + $('.cloud-tool, .cloud-multi-tool').hide(); + } + + function deactivate_all_panels() { + $('.cloud-index').removeClass('cloud-index-active'); + } + + function close_and_deactivate_all_panels() { + close_all_panels(); + deactivate_all_panels(); + } + + function activate_id(id) { + close_and_deactivate_all_panels(); + $('#cloud-multi-tool-select-all, .cloud-multi-tool-checkbox').prop('checked', false).trigger('change'); + + $('#cloud-tool-submit-' + id).show(); + $('#cloud-index-' + id).addClass('cloud-index-active'); + $('#cloud-tool-submit-' + id).show(); + } + }); -// + + + // initialize function UploadInit() { - var fileselect = $("#files-upload"); - var filedrag = $("#cloud-drag-area"); var submit = $("#upload-submit"); var count = 1; + var filedrag = $(".cloud-index.attach-drop"); - $('#invisible-cloud-file-upload').fileupload({ url: 'file_upload', dataType: 'json', @@ -26,8 +345,8 @@ function UploadInit() { maxChunkSize: 4 * 1024 * 1024, add: function(e,data) { - $(data.files).each( function() { this.count = ++ count; prepareHtml(this); }); - + $(data.files).each( function() { this.count = ++ count; prepareHtml(this); }); + var allow_cid = ($('#ajax-upload-files').data('allow_cid') || []); var allow_gid = ($('#ajax-upload-files').data('allow_gid') || []); var deny_cid = ($('#ajax-upload-files').data('deny_cid') || []); @@ -49,7 +368,6 @@ function UploadInit() { }); data.formData = $('#ajax-upload-files').serializeArray(); - data.submit(); }, @@ -58,7 +376,7 @@ function UploadInit() { // there will only be one file, the one we are looking for - $(data.files).each( function() { + $(data.files).each( function() { var idx = this.count; // Dynamically update the percentage complete displayed in the file upload list @@ -70,7 +388,6 @@ function UploadInit() { }, - stop: function(e,data) { window.location.href = window.location.href; } @@ -81,60 +398,17 @@ function UploadInit() { } -// file drag hover -function DragDropUploadFileHover(e) { - e.stopPropagation(); - e.preventDefault(); - e.currentTarget.className = (e.type == "dragover" ? "hover" : ""); -} - -// file selection via drag/drop -function DragDropUploadFileSelectHandler(e) { - // cancel event and hover styling - DragDropUploadFileHover(e); - - // fetch FileList object - var files = e.target.files || e.originalEvent.dataTransfer.files; - - $('.new-upload').remove(); - - // process all File objects - for (var i = 0, f; f = files[i]; i++) { - prepareHtml(f, i); - UploadFile(f, i); - } -} - -// file selection via input -function UploadFileSelectHandler(e) { - // fetch FileList object - if(e.target.id === 'upload-submit') { - e.preventDefault(); - var files = e.data[0].files; - } - if(e.target.id === 'files-upload') { - $('.new-upload').remove(); - var files = e.target.files; - } - // process all File objects - for (var i = 0, f; f = files[i]; i++) { - if(e.target.id === 'files-upload') - prepareHtml(f, i); - if(e.target.id === 'upload-submit') { - UploadFile(f, i); - } - } -} function prepareHtml(f) { var num = f.count - 1; var i = f.count; $('#cloud-index #new-upload-progress-bar-' + num.toString()).after( '' + + '' + '' + '' + f.name + '' + - '' + + '' + '' + formatSizeUnits(f.size) + '' + '' + '' + @@ -199,63 +473,4 @@ function getIconFromType(type) { return iconFromType; } -// upload files -function UploadFile(file, idx) { - - - window.filesToUpload = window.filesToUpload + 1; - - var xhr = new XMLHttpRequest(); - xhr.withCredentials = true; // Include the SESSION cookie info for authentication - - (xhr.upload || xhr).addEventListener('progress', function (e) { - - var done = e.position || e.loaded; - var total = e.totalSize || e.total; - // Dynamically update the percentage complete displayed in the file upload list - $('#upload-progress-' + idx).html(Math.round(done / total * 100) + '%'); - $('#upload-progress-bar-' + idx).css('background-size', Math.round(done / total * 100) + '%'); - - if(done == total) { - $('#upload-progress-' + idx).html('Processing...'); - } - - }); - - - xhr.addEventListener('load', function (e) { - //we could possibly turn the filenames to real links here and add the delete and edit buttons to avoid page reload... - $('#upload-progress-' + idx).html('Ready!'); - - //console.log('xhr upload complete', e); - window.fileUploadsCompleted = window.fileUploadsCompleted + 1; - - // When all the uploads have completed, refresh the page - if (window.filesToUpload > 0 && window.fileUploadsCompleted === window.filesToUpload) { - - window.fileUploadsCompleted = window.filesToUpload = 0; - - // After uploads complete, refresh browser window to display new files - window.location.href = window.location.href; - } - }); - - - xhr.addEventListener('error', function (e) { - $('#upload-progress-' + idx).html('ERROR'); - }); - - // POST to the entire cloud path -// xhr.open('post', 'file_upload', true); - -// var formfields = $("#ajax-upload-files").serializeArray(); - -// var data = new FormData(); -// $.each(formfields, function(i, field) { -// data.append(field.name, field.value); -// }); -// data.append('userfile', file); - -// xhr.send(data); -} diff --git a/view/pdl/mod_cloud.pdl b/view/pdl/mod_cloud.pdl index a5461df50..44ef1e4fc 100644 --- a/view/pdl/mod_cloud.pdl +++ b/view/pdl/mod_cloud.pdl @@ -1,5 +1,6 @@ [region=aside] [widget=vcard][/widget] +[widget=categories][var=files]1[/var][/widget] [/region] [region=right_aside] [widget=notifications][/widget] diff --git a/view/theme/redbasic/css/style.css b/view/theme/redbasic/css/style.css index 545e610b5..7e7f33d8e 100644 --- a/view/theme/redbasic/css/style.css +++ b/view/theme/redbasic/css/style.css @@ -365,7 +365,7 @@ footer { bottom:1px; text-align: right; padding-bottom: 1em; - padding-right: 3em; + padding-right: 3em; } .birthday-today, @@ -484,7 +484,7 @@ footer { .pager_next, .pager-prev, .pager-next, -.pager_n { +.pager_n { border: 1px solid #ccc; background: transparent; padding: 4px; @@ -738,7 +738,7 @@ nav .acpopup { height: auto; overflow: auto; border-bottom: 2px solid #cccccc; padding-bottom: 1em; - margin-bottom: 1em; + margin-bottom: 1em; } .oauthapp img { float: left; @@ -1016,7 +1016,7 @@ th,td { max-width: 19.4em; overflow: hidden; } - + /* mail */ img.mail-conv-sender-photo { @@ -1560,12 +1560,12 @@ blockquote { margin-top:-3px; } -dl.bb-dl > dt { +dl.bb-dl > dt { /* overriding the default dl style from bootstrap, as bootstrap's style of a bold unindented line followed by a plain unindented line is already acheivable in bbcode without dl */ - font-weight: normal; -} + font-weight: normal; +} dl.dl-terms-monospace > dt { font-family: monospace; } dl.dl-terms-bold > dt { font-weight: bold; } dl.dl-terms-italic > dt { font-style: italic; } @@ -1576,7 +1576,7 @@ dl.bb-dl:not(.dl-horizontal) > dd { margin-left: 2em; } dl.bb-dl > dd > li { - /* adding some indent so bullet-list items will line up better with + /* adding some indent so bullet-list items will line up better with dl descriptions if someone wants to be impure and combine them */ margin-left: 1em; } @@ -1815,3 +1815,7 @@ dl.bb-dl > dd > li { span.default-highlight { background-color: yellow; } + +.bootstrap-tagsinput { + width: 100%; +} diff --git a/view/tpl/breadcrumb.tpl b/view/tpl/breadcrumb.tpl new file mode 100644 index 000000000..205b712d9 --- /dev/null +++ b/view/tpl/breadcrumb.tpl @@ -0,0 +1,11 @@ + diff --git a/view/tpl/categories_widget.tpl b/view/tpl/categories_widget.tpl index 1341c652c..fd27dca44 100755 --- a/view/tpl/categories_widget.tpl +++ b/view/tpl/categories_widget.tpl @@ -1,12 +1,12 @@

{{$title}}

{{$desc}}
- + - +
diff --git a/view/tpl/cloud_actionspanel.tpl b/view/tpl/cloud_actionspanel.tpl index 292452cca..65319379f 100644 --- a/view/tpl/cloud_actionspanel.tpl +++ b/view/tpl/cloud_actionspanel.tpl @@ -19,15 +19,16 @@
-
+
{{if $quota.limit || $quota.used}}{{/if}}
- + - {{include file="field_checkbox.tpl" field=$notify}} +
+ You can select files via the upload button or drop them right here or into an existing folder. +
{{if $lockstate}} @@ -41,4 +42,10 @@
+{{if $breadcrumbs_html}} {{$aclselect}} +{{/if}} +{{if $breadcrumbs_html}} +{{$breadcrumbs_html}} +
+{{/if}} diff --git a/view/tpl/cloud_directory.tpl b/view/tpl/cloud_directory.tpl index 90347d274..618de418f 100644 --- a/view/tpl/cloud_directory.tpl +++ b/view/tpl/cloud_directory.tpl @@ -1,84 +1,258 @@ -
-{{if $tiles}} +
+ {{if $tiles}} {{* this is needed to append the upload files in the right order *}}
{{if $parentpath}}
- - -
.. -
+ +
+ .. +
{{/if}} {{foreach $entries as $item}} {{/foreach}}
-{{else}} + {{else}} - - - - + + + + + + - {{if $parentpath}} - - - - - - - + {{if $parentpath}} + + + + - {{/if}} + + + + {{/if}} + {{if $channel_id && $is_owner && $entries.0}} + + + + + + + + + {{/if}} {{* this is needed to append the upload files in the right order *}} - {{foreach $entries as $item}} - - - - {{if $item.is_owner}} - - - - - - {{else}} - {{if $is_admin || $item.is_creator}} - {{/if}} - - - + {{foreach $entries as $item}} + + + + + + + + {{/if}} + + - - + + - - {{/foreach}} + {{/foreach}}
{{$name}}{{*{{$type}}*}}{{* multi tool checkbox *}}{{* icon *}}{{$name}}{{* categories *}}{{* lock icon *}}{{* tools icon *}} {{$size}} {{$lastmod}}
{{*{{$parentpath.icon}}*}}..{{*[{{$parent}}]*}}
..
{{* this is for display consistency *}}
+
+ +
+
+
+ +
+
+ {{if $is_owner}} + + {{else if $is_admin}} + + {{/if}} +
+
+ + + +
+ {{include file="field_select.tpl" field=$newfolder}} + {{include file="field_checkbox.tpl" field=$copy}} +
+
+ {{include file="field_input.tpl" field=$categories}} +
+
+ {{if $is_owner}} + {{include file="field_checkbox.tpl" field=$recurse}} + {{/if}} +
+ +
+ {{if $is_owner}} + + {{/if}} + +
+
+
+
+
{{$item.displayName}}{{$item.attachIcon}}
{{else}}{{/if}}{{*{{$item.type}}*}}{{$item.sizeFormatted}}{{$item.lastmodified}}
+ {{if $channel_id && $is_owner}} +
+ +
+ {{/if}} +
{{$item.name}}{{$item.terms}}{{if $item.lockstate == 'lock'}}{{/if}} + {{if ($item.is_owner || $item.is_creator) && $item.attach_id}} + + {{else}} + {{if ($is_admin || !$item.collection) && $item.attach_id}} + + {{/if}} + {{$item.size_formatted}}{{$item.last_modified}}
+
+ + + +
+ {{include file="field_input.tpl" field=$item.newfilename}} +
+
+ {{include file="field_select.tpl" field=$item.newfolder}} + {{include file="field_checkbox.tpl" field=$item.copy}} +
+
+ {{include file="field_input.tpl" field=$item.categories}} +
+
+ {{if $item.is_owner}} + {{if !$item.collection}}{{include file="field_checkbox.tpl" field=$item.notify}}{{/if}} + {{if $item.collection}}{{include file="field_checkbox.tpl" field=$item.recurse}}{{/if}} + {{/if}} +
+ +
+ {{if $item.is_owner}} + + {{/if}} + +
+
+
+ +
+
{{/if}}
diff --git a/view/tpl/field_select.tpl b/view/tpl/field_select.tpl index 8c3776841..7cc624fab 100755 --- a/view/tpl/field_select.tpl +++ b/view/tpl/field_select.tpl @@ -1,4 +1,4 @@ -
+
-
- -
- - - - -
-
- {{if $lockstate}} - - {{/if}} - +
+
+ + + + + + +
+
+ {{if $lockstate}} + + {{/if}} + +
-
- -
+ +
+
+
-
- {{if $quota.limit || $quota.used}}{{/if}} -
- - - - {{include file="field_checkbox.tpl" field=$notify}} -
- You can select files via the upload button or drop them right here or into an existing folder. -
-
-
- {{if $lockstate}} - - {{/if}} - +
+
+ {{if $quota.limit || $quota.used}}{{/if}} + + + + + {{include file="field_checkbox.tpl" field=$notify}} +
+ You can select files via the upload button or drop them right here or into an existing folder.
-
- -
+
+
+ {{if $lockstate}} + + {{/if}} + +
+
+ +
+
+
{{if $breadcrumbs_html}} {{$aclselect}} -- cgit v1.2.3 From 8188a551f3bf9cb817338241985fe0bd45cafd43 Mon Sep 17 00:00:00 2001 From: Mario Date: Tue, 15 Dec 2020 12:12:38 +0000 Subject: fix regression in files aclselect --- view/tpl/cloud_actionspanel.tpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'view') diff --git a/view/tpl/cloud_actionspanel.tpl b/view/tpl/cloud_actionspanel.tpl index e9f7bbc38..039d19fac 100644 --- a/view/tpl/cloud_actionspanel.tpl +++ b/view/tpl/cloud_actionspanel.tpl @@ -48,7 +48,7 @@

-{{if $breadcrumbs_html}} +{{if $aclselect}} {{$aclselect}} {{/if}} {{if $breadcrumbs_html}} -- cgit v1.2.3 From 27df896a9cb1f713c49e290f2a4e7d9860aff1d5 Mon Sep 17 00:00:00 2001 From: Mario Date: Wed, 16 Dec 2020 08:26:19 +0000 Subject: files_ng: implement lockview --- view/tpl/cloud_directory.tpl | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'view') diff --git a/view/tpl/cloud_directory.tpl b/view/tpl/cloud_directory.tpl index 618de418f..6f70c6bfe 100644 --- a/view/tpl/cloud_directory.tpl +++ b/view/tpl/cloud_directory.tpl @@ -152,7 +152,12 @@ {{$item.name}} {{$item.terms}} - {{if $item.lockstate == 'lock'}}{{/if}} + + {{if $item.lockstate == 'lock'}} + + + {{/if}} + {{if ($item.is_owner || $item.is_creator) && $item.attach_id}} - -- cgit v1.2.3 From b2e80efe3f42c6329be7356580d62ea3525717b8 Mon Sep 17 00:00:00 2001 From: Mario Date: Thu, 17 Dec 2020 10:04:24 +0000 Subject: files_ng: provide bbcode snippets in the info panel --- view/tpl/cloud_directory.tpl | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'view') diff --git a/view/tpl/cloud_directory.tpl b/view/tpl/cloud_directory.tpl index 8fe31767c..a6993fe97 100644 --- a/view/tpl/cloud_directory.tpl +++ b/view/tpl/cloud_directory.tpl @@ -214,13 +214,19 @@
{{if ! $item.collection}}
- - + +
+ {{if $item.embed_bbcode}} +
+ + +
+ {{/if}} {{/if}}
- - + +
@@ -172,23 +173,27 @@ Rename Move or copy Categories - {{if !$item.collection}} {{if $item.is_owner}} {{/if}} + {{if $item.collection}} + Download + {{else}} Download {{/if}} {{$delete}}
{{else}} - {{if ($is_admin || !$item.collection) && $item.attach_id}} + {{if $is_admin || $item.attach_id}} {{/foreach}} @@ -160,25 +160,25 @@ {{/if}} - {{if ($item.is_owner || $item.is_creator) && $item.attach_id}} + {{if ($is_owner || $item.is_creator) && $item.attach_id}}