From df45c13f622d01241ac96b2f16cb964ba688d72c Mon Sep 17 00:00:00 2001 From: zotlabs Date: Tue, 28 Nov 2017 14:30:46 -0800 Subject: first integration attempt with /cloud and blueimp uploader --- view/js/mod_cloud.js | 27 +++++++++++++++++++++++++++ view/tpl/cloud.tpl | 5 +++++ 2 files changed, 32 insertions(+) diff --git a/view/js/mod_cloud.js b/view/js/mod_cloud.js index 8af90863e..32aae2029 100644 --- a/view/js/mod_cloud.js +++ b/view/js/mod_cloud.js @@ -17,6 +17,33 @@ function UploadInit() { var filedrag = $("#cloud-drag-area"); var submit = $("#upload-submit"); + + $('#invisible-cloud-file-upload').fileupload({ + url: 'file_upload', + dataType: 'json', + // dropZone: $('#profile-jot-text'), + maxChunkSize: 4 * 1024 * 1024, + add: function(e,data) { + $('#profile-rotator').show(); + data.submit(); + }, + done: function(e,data) { + addeditortext(data.result.message); + $('#jot-media').val($('#jot-media').val() + data.result.message); + }, + stop: function(e,data) { + preview_post(); + $('#profile-rotator').hide(); + }, + }); + + $('#files-upload').click(function(event) { event.preventDefault(); $('#invisible-cloud-file-upload').trigger('click'); return false;}); + + + + + + // is XHR2 available? var xhr = new XMLHttpRequest(); if (xhr.upload) { diff --git a/view/tpl/cloud.tpl b/view/tpl/cloud.tpl index d1567af9f..ccd59d81a 100644 --- a/view/tpl/cloud.tpl +++ b/view/tpl/cloud.tpl @@ -1,3 +1,8 @@ + + + + +
{{include file="cloud_header.tpl"}} {{include file="cloud_directory.tpl"}} -- cgit v1.2.3 From 76703dee8481075a44b254a548bb29b49530d0ad Mon Sep 17 00:00:00 2001 From: zotlabs Date: Tue, 28 Nov 2017 17:37:18 -0800 Subject: more chunk work --- Zotlabs/Module/File_upload.php | 5 +++-- include/attach.php | 2 +- view/js/mod_cloud.js | 44 ++++++++++++++++++++++------------------- view/tpl/cloud_actionspanel.tpl | 2 +- 4 files changed, 29 insertions(+), 24 deletions(-) diff --git a/Zotlabs/Module/File_upload.php b/Zotlabs/Module/File_upload.php index 296dab708..e2a6d45e5 100644 --- a/Zotlabs/Module/File_upload.php +++ b/Zotlabs/Module/File_upload.php @@ -10,7 +10,8 @@ class File_upload extends \Zotlabs\Web\Controller { function post() { - // logger('file upload: ' . print_r($_REQUEST,true)); + logger('file upload: ' . print_r($_REQUEST,true)); + logger('file upload: ' . print_r($_FILES,true)); $channel = (($_REQUEST['channick']) ? channelx_by_nick($_REQUEST['channick']) : null); @@ -56,7 +57,7 @@ class File_upload extends \Zotlabs\Web\Controller { if(array_key_exists('HTTP_CONTENT_RANGE',$_SERVER)) { $pm = preg_match('/bytes (\d*)\-(\d*)\/(\d*)/',$_SERVER['HTTP_CONTENT_RANGE'],$matches); if($pm) { - // logger('Content-Range: ' . print_r($matches,true)); + logger('Content-Range: ' . print_r($matches,true)); $partial = true; } } diff --git a/include/attach.php b/include/attach.php index 5b4c24f6f..86c792ed9 100644 --- a/include/attach.php +++ b/include/attach.php @@ -2506,7 +2506,7 @@ function save_chunk($channel,$start,$end,$len) { } if(($len - 1) == $end) { unlink($tmp_path); - $result['name'] = $_FILES['files']['tmp_name']; + $result['name'] = $_FILES['files']['name']; $result['type'] = $_FILES['files']['type']; $result['tmp_name'] = $new_path; $result['error'] = 0; diff --git a/view/js/mod_cloud.js b/view/js/mod_cloud.js index 32aae2029..25f40e5a5 100644 --- a/view/js/mod_cloud.js +++ b/view/js/mod_cloud.js @@ -18,26 +18,28 @@ function UploadInit() { var submit = $("#upload-submit"); - $('#invisible-cloud-file-upload').fileupload({ + $('#files-upload').fileupload({ url: 'file_upload', dataType: 'json', - // dropZone: $('#profile-jot-text'), - maxChunkSize: 4 * 1024 * 1024, + dropZone: filedrag, + maxChunkSize: 100000, // 4 * 1024 * 1024, + add: function(e,data) { $('#profile-rotator').show(); data.submit(); }, - done: function(e,data) { - addeditortext(data.result.message); - $('#jot-media').val($('#jot-media').val() + data.result.message); - }, - stop: function(e,data) { - preview_post(); - $('#profile-rotator').hide(); - }, + +// done: function(e,data) { +// addeditortext(data.result.message); +// $('#jot-media').val($('#jot-media').val() + data.result.message); +// }, +// stop: function(e,data) { +// preview_post(); +// $('#profile-rotator').hide(); +// }, }); - $('#files-upload').click(function(event) { event.preventDefault(); $('#invisible-cloud-file-upload').trigger('click'); return false;}); +// $('#files-upload').click(function(event) { event.preventDefault(); $('#invisible-cloud-file-upload').trigger('click'); return false;}); @@ -185,6 +187,8 @@ function getIconFromType(type) { // upload files function UploadFile(file, idx) { + return; + window.filesToUpload = window.filesToUpload + 1; var xhr = new XMLHttpRequest(); @@ -229,15 +233,15 @@ function UploadFile(file, idx) { }); // POST to the entire cloud path - xhr.open('post', 'file_upload', true); +// xhr.open('post', 'file_upload', true); - var formfields = $("#ajax-upload-files").serializeArray(); +// 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); +// var data = new FormData(); +// $.each(formfields, function(i, field) { +// data.append(field.name, field.value); +// }); +// data.append('userfile', file); - xhr.send(data); +// xhr.send(data); } diff --git a/view/tpl/cloud_actionspanel.tpl b/view/tpl/cloud_actionspanel.tpl index fc3e7f82f..489632a4a 100644 --- a/view/tpl/cloud_actionspanel.tpl +++ b/view/tpl/cloud_actionspanel.tpl @@ -25,7 +25,7 @@ - + {{include file="field_checkbox.tpl" field=$notify}}
-- cgit v1.2.3 From e1a209a3da3913666c00398d3f9e249856a72e69 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Tue, 28 Nov 2017 18:01:04 -0800 Subject: more chunk work --- view/js/mod_cloud.js | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/view/js/mod_cloud.js b/view/js/mod_cloud.js index 25f40e5a5..1a473ac75 100644 --- a/view/js/mod_cloud.js +++ b/view/js/mod_cloud.js @@ -25,8 +25,7 @@ function UploadInit() { maxChunkSize: 100000, // 4 * 1024 * 1024, add: function(e,data) { - $('#profile-rotator').show(); - data.submit(); +// data.submit(); }, // done: function(e,data) { @@ -47,24 +46,24 @@ function UploadInit() { // is XHR2 available? - var xhr = new XMLHttpRequest(); - if (xhr.upload) { +// var xhr = new XMLHttpRequest(); +// if (xhr.upload) { // file select - fileselect.attr("multiple", 'multiple'); - fileselect.on("change", UploadFileSelectHandler); +// fileselect.attr("multiple", 'multiple'); +// fileselect.on("change", UploadFileSelectHandler); // file submit - submit.on("click", fileselect, UploadFileSelectHandler); +// submit.on("click", fileselect, UploadFileSelectHandler); // file drop - filedrag.on("dragover", DragDropUploadFileHover); - filedrag.on("dragleave", DragDropUploadFileHover); - filedrag.on("drop", DragDropUploadFileSelectHandler); - } +// filedrag.on("dragover", DragDropUploadFileHover); +// filedrag.on("dragleave", DragDropUploadFileHover); +// filedrag.on("drop", DragDropUploadFileSelectHandler); +// } - window.filesToUpload = 0; - window.fileUploadsCompleted = 0; +// window.filesToUpload = 0; +// window.fileUploadsCompleted = 0; } // file drag hover -- cgit v1.2.3 From e47c08ed72acd82ef455588f5dec3269a8030037 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Tue, 28 Nov 2017 20:40:01 -0800 Subject: more chunk --- view/js/mod_cloud.js | 8 ++++++-- view/tpl/cloud.tpl | 1 - view/tpl/cloud_actionspanel.tpl | 2 +- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/view/js/mod_cloud.js b/view/js/mod_cloud.js index 1a473ac75..3a82c701f 100644 --- a/view/js/mod_cloud.js +++ b/view/js/mod_cloud.js @@ -24,9 +24,13 @@ function UploadInit() { dropZone: filedrag, maxChunkSize: 100000, // 4 * 1024 * 1024, - add: function(e,data) { +// add: function(e,data) { // data.submit(); - }, +// }, + +// submit: function(e,data) { +// data.submit(); +// }, // done: function(e,data) { // addeditortext(data.result.message); diff --git a/view/tpl/cloud.tpl b/view/tpl/cloud.tpl index ccd59d81a..e7237c7e6 100644 --- a/view/tpl/cloud.tpl +++ b/view/tpl/cloud.tpl @@ -1,7 +1,6 @@ -
{{include file="cloud_header.tpl"}} diff --git a/view/tpl/cloud_actionspanel.tpl b/view/tpl/cloud_actionspanel.tpl index 489632a4a..71ba2f687 100644 --- a/view/tpl/cloud_actionspanel.tpl +++ b/view/tpl/cloud_actionspanel.tpl @@ -25,7 +25,7 @@ - + {{include file="field_checkbox.tpl" field=$notify}}
-- cgit v1.2.3 From d59c1bb6bf36419344dc355113e56c2254cbcbfa Mon Sep 17 00:00:00 2001 From: zotlabs Date: Wed, 29 Nov 2017 18:34:16 -0800 Subject: more chunk stuff --- view/js/mod_cloud.js | 6 +++--- view/tpl/cloud_actionspanel.tpl | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/view/js/mod_cloud.js b/view/js/mod_cloud.js index 3a82c701f..e9e8e9241 100644 --- a/view/js/mod_cloud.js +++ b/view/js/mod_cloud.js @@ -28,9 +28,9 @@ function UploadInit() { // data.submit(); // }, -// submit: function(e,data) { -// data.submit(); -// }, + submit: function(e,data) { + e.preventDefault(); + }, // done: function(e,data) { // addeditortext(data.result.message); diff --git a/view/tpl/cloud_actionspanel.tpl b/view/tpl/cloud_actionspanel.tpl index 71ba2f687..2eed5b18b 100644 --- a/view/tpl/cloud_actionspanel.tpl +++ b/view/tpl/cloud_actionspanel.tpl @@ -25,7 +25,7 @@ - + {{include file="field_checkbox.tpl" field=$notify}}
-- cgit v1.2.3 From cce2b08e6bcb16b1c9fde13b2597ce66fc0c45d6 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Thu, 30 Nov 2017 15:28:53 -0800 Subject: progress on chunked uploads in /cloud --- view/js/mod_cloud.js | 18 +++++++++--------- view/tpl/cloud_actionspanel.tpl | 7 ++++--- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/view/js/mod_cloud.js b/view/js/mod_cloud.js index e9e8e9241..2215a9df9 100644 --- a/view/js/mod_cloud.js +++ b/view/js/mod_cloud.js @@ -18,20 +18,21 @@ function UploadInit() { var submit = $("#upload-submit"); - $('#files-upload').fileupload({ + $('#invisible-cloud-file-upload').fileupload({ url: 'file_upload', dataType: 'json', dropZone: filedrag, + formData: $('#ajax-upload-files').serializeArray(), maxChunkSize: 100000, // 4 * 1024 * 1024, -// add: function(e,data) { -// data.submit(); -// }, - - submit: function(e,data) { - e.preventDefault(); + add: function(e,data) { + data.submit(); }, +// submit: function(e,data) { +// e.preventDefault(); +// }, + // done: function(e,data) { // addeditortext(data.result.message); // $('#jot-media').val($('#jot-media').val() + data.result.message); @@ -42,7 +43,7 @@ function UploadInit() { // }, }); -// $('#files-upload').click(function(event) { event.preventDefault(); $('#invisible-cloud-file-upload').trigger('click'); return false;}); + $('#upload-submit').click(function(event) { event.preventDefault(); $('#invisible-cloud-file-upload').trigger('click'); return false;}); @@ -190,7 +191,6 @@ function getIconFromType(type) { // upload files function UploadFile(file, idx) { - return; window.filesToUpload = window.filesToUpload + 1; diff --git a/view/tpl/cloud_actionspanel.tpl b/view/tpl/cloud_actionspanel.tpl index 2eed5b18b..8d39a8383 100644 --- a/view/tpl/cloud_actionspanel.tpl +++ b/view/tpl/cloud_actionspanel.tpl @@ -1,3 +1,4 @@ +
@@ -24,8 +25,8 @@ - - + {{include file="field_checkbox.tpl" field=$notify}}
@@ -34,7 +35,7 @@ {{/if}} - +
-- cgit v1.2.3 From cc0d53e6959f333d26003af64439b2fd8a8d665c Mon Sep 17 00:00:00 2001 From: zotlabs Date: Thu, 30 Nov 2017 16:24:18 -0800 Subject: made it to prepareHtml --- view/js/mod_cloud.js | 8 +++++--- view/tpl/cloud_directory.tpl | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/view/js/mod_cloud.js b/view/js/mod_cloud.js index 2215a9df9..0756c34e3 100644 --- a/view/js/mod_cloud.js +++ b/view/js/mod_cloud.js @@ -16,7 +16,7 @@ function UploadInit() { var fileselect = $("#files-upload"); var filedrag = $("#cloud-drag-area"); var submit = $("#upload-submit"); - + var count = 1; $('#invisible-cloud-file-upload').fileupload({ url: 'file_upload', @@ -26,6 +26,7 @@ function UploadInit() { maxChunkSize: 100000, // 4 * 1024 * 1024, add: function(e,data) { + $(data.files).each( function() { this.count = ++ count; prepareHtml(this) }); data.submit(); }, @@ -117,8 +118,9 @@ function UploadFileSelectHandler(e) { } } -function prepareHtml(f, i) { - var num = i - 1; +function prepareHtml(f) { + var num = f.count - 1; + var i = f.count; $('#cloud-index #new-upload-progress-bar-' + num.toString()).after( '' + '' + diff --git a/view/tpl/cloud_directory.tpl b/view/tpl/cloud_directory.tpl index 88b6bf563..7017df344 100644 --- a/view/tpl/cloud_directory.tpl +++ b/view/tpl/cloud_directory.tpl @@ -52,7 +52,7 @@ {{/if}} - {{* this is needed to append the upload files in the right order *}} + {{* this is needed to append the upload files in the right order *}} {{foreach $entries as $item}} -- cgit v1.2.3 From 0e8e0b48b3fd6f4d6d0dd60039743371930af08d Mon Sep 17 00:00:00 2001 From: zotlabs Date: Thu, 30 Nov 2017 19:05:24 -0800 Subject: more or less working chunked uploads on /cloud now. --- Zotlabs/Module/File_upload.php | 2 ++ view/js/mod_cloud.js | 50 ++++++++++++++++------------------------- view/tpl/cloud_actionspanel.tpl | 2 +- 3 files changed, 22 insertions(+), 32 deletions(-) diff --git a/Zotlabs/Module/File_upload.php b/Zotlabs/Module/File_upload.php index e2a6d45e5..90761fa9c 100644 --- a/Zotlabs/Module/File_upload.php +++ b/Zotlabs/Module/File_upload.php @@ -64,6 +64,8 @@ class File_upload extends \Zotlabs\Web\Controller { if($partial) { $x = save_chunk($channel,$matches[1],$matches[2],$matches[3]); + +logger('save_chunk: ' . print_r($x,true)); if($x['partial']) { header('Range: bytes=0-' . (($x['length']) ? $x['length'] - 1 : 0)); json_return_and_die($result); diff --git a/view/js/mod_cloud.js b/view/js/mod_cloud.js index 0756c34e3..9f2a007f3 100644 --- a/view/js/mod_cloud.js +++ b/view/js/mod_cloud.js @@ -18,58 +18,46 @@ function UploadInit() { var submit = $("#upload-submit"); var count = 1; + $('#invisible-cloud-file-upload').fileupload({ url: 'file_upload', dataType: 'json', dropZone: filedrag, formData: $('#ajax-upload-files').serializeArray(), - maxChunkSize: 100000, // 4 * 1024 * 1024, + 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); }); + data.submit(); }, -// submit: function(e,data) { -// e.preventDefault(); -// }, - -// done: function(e,data) { -// addeditortext(data.result.message); -// $('#jot-media').val($('#jot-media').val() + data.result.message); -// }, -// stop: function(e,data) { -// preview_post(); -// $('#profile-rotator').hide(); -// }, - }); - $('#upload-submit').click(function(event) { event.preventDefault(); $('#invisible-cloud-file-upload').trigger('click'); return false;}); + progress: function(e,data) { + + // there will only be one file, the one we are looking for + $(data.files).each( function() { + var idx = this.count; + // Dynamically update the percentage complete displayed in the file upload list + $('#upload-progress-' + idx).html(Math.round(data.loaded / data.total * 100) + '%'); + $('#upload-progress-bar-' + idx).css('background-size', Math.round(data.loaded / data.total * 100) + '%'); + }); + }, - // is XHR2 available? -// var xhr = new XMLHttpRequest(); -// if (xhr.upload) { - // file select -// fileselect.attr("multiple", 'multiple'); -// fileselect.on("change", UploadFileSelectHandler); + stop: function(e,data) { + window.location.href = window.location.href; + } - // file submit -// submit.on("click", fileselect, UploadFileSelectHandler); + }); - // file drop -// filedrag.on("dragover", DragDropUploadFileHover); -// filedrag.on("dragleave", DragDropUploadFileHover); -// filedrag.on("drop", DragDropUploadFileSelectHandler); -// } + $('#upload-submit').click(function(event) { event.preventDefault(); $('#invisible-cloud-file-upload').trigger('click'); return false;}); -// window.filesToUpload = 0; -// window.fileUploadsCompleted = 0; } // file drag hover diff --git a/view/tpl/cloud_actionspanel.tpl b/view/tpl/cloud_actionspanel.tpl index 8d39a8383..6b876d2ac 100644 --- a/view/tpl/cloud_actionspanel.tpl +++ b/view/tpl/cloud_actionspanel.tpl @@ -21,7 +21,7 @@
{{if $quota.limit || $quota.used}}{{/if}} -
+ -- cgit v1.2.3 From 3d8de8cf0af99e1f2b263667a96e8185c055fb82 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Thu, 30 Nov 2017 19:11:26 -0800 Subject: remove logging line --- Zotlabs/Module/File_upload.php | 1 - 1 file changed, 1 deletion(-) diff --git a/Zotlabs/Module/File_upload.php b/Zotlabs/Module/File_upload.php index 90761fa9c..4d1cc4cda 100644 --- a/Zotlabs/Module/File_upload.php +++ b/Zotlabs/Module/File_upload.php @@ -65,7 +65,6 @@ class File_upload extends \Zotlabs\Web\Controller { if($partial) { $x = save_chunk($channel,$matches[1],$matches[2],$matches[3]); -logger('save_chunk: ' . print_r($x,true)); if($x['partial']) { header('Range: bytes=0-' . (($x['length']) ? $x['length'] - 1 : 0)); json_return_and_die($result); -- cgit v1.2.3 From 3b6d7e306656f1263b80430fbcfdb413bf99ead9 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Thu, 30 Nov 2017 21:40:37 -0800 Subject: make sure we get a file upload progress indicator in the tiles view. --- view/tpl/cloud_directory.tpl | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/view/tpl/cloud_directory.tpl b/view/tpl/cloud_directory.tpl index 7017df344..ad3caff88 100644 --- a/view/tpl/cloud_directory.tpl +++ b/view/tpl/cloud_directory.tpl @@ -1,8 +1,12 @@
{{if $tiles}} + + {{* this is needed to append the upload files in the right order *}} +
{{if $parentpath}}
+
-- cgit v1.2.3 From dcad9ce26a0de72ba3ad5b86ddb62298598ac380 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Fri, 1 Dec 2017 21:00:39 +0100 Subject: add a filter for notification to show new posts only --- Zotlabs/Lib/Enotify.php | 2 ++ Zotlabs/Widget/Notifications.php | 15 +++++++++------ view/js/main.js | 14 ++++++++++---- view/tpl/notifications_widget.tpl | 23 +++++++++++++++++++---- 4 files changed, 40 insertions(+), 14 deletions(-) diff --git a/Zotlabs/Lib/Enotify.php b/Zotlabs/Lib/Enotify.php index 697b57b6a..a7b4f28e8 100644 --- a/Zotlabs/Lib/Enotify.php +++ b/Zotlabs/Lib/Enotify.php @@ -804,6 +804,8 @@ class Enotify { 'when' => relative_date($item['created']), 'class' => (intval($item['item_unseen']) ? 'notify-unseen' : 'notify-seen'), 'b64mid' => ((in_array($item['verb'], [ACTIVITY_LIKE, ACTIVITY_DISLIKE])) ? 'b64.' . base64url_encode($item['thr_parent']) : 'b64.' . base64url_encode($item['mid'])), + 'notify_id' => 'undefined', + 'thread_top' => (($item['item_thread_top']) ? true : false), 'message' => strip_tags(bbcode($itemem_text)) ); diff --git a/Zotlabs/Widget/Notifications.php b/Zotlabs/Widget/Notifications.php index 191f2afb6..450d3565e 100644 --- a/Zotlabs/Widget/Notifications.php +++ b/Zotlabs/Widget/Notifications.php @@ -20,8 +20,10 @@ class Notifications { 'label' => t('View your network activity') ], 'markall' => [ - 'url' => '#', 'label' => t('Mark all notifications read') + ], + 'filter' => [ + 'label' => t('Show new posts only') ] ]; @@ -36,8 +38,10 @@ class Notifications { 'label' => t('View your home activity') ], 'markall' => [ - 'url' => '#', 'label' => t('Mark all notifications seen') + ], + 'filter' => [ + 'label' => t('Show new posts only') ] ]; @@ -52,7 +56,6 @@ class Notifications { 'label' => t('View your private mails') ], 'markall' => [ - 'url' => '#', 'label' => t('Mark all messages seen') ] ]; @@ -68,7 +71,6 @@ class Notifications { 'label' => t('View events') ], 'markall' => [ - 'url' => '#', 'label' => t('Mark all events seen') ] ]; @@ -104,7 +106,6 @@ class Notifications { 'label' => t('View all notices') ], 'markall' => [ - 'url' => '#', 'label' => t('Mark all notices seen') ] ]; @@ -132,8 +133,10 @@ class Notifications { 'label' => t('View the public stream') ], 'markall' => [ - 'url' => '#', 'label' => t('Mark all notifications seen') + ], + 'filter' => [ + 'label' => t('Show new posts only') ] ]; } diff --git a/view/js/main.js b/view/js/main.js index 888934ea8..11a09b647 100644 --- a/view/js/main.js +++ b/view/js/main.js @@ -874,6 +874,7 @@ function notify_popup_loader(notifyType) { var notifications_tpl= unescape($("#nav-notifications-template[rel=template]").html()); var notifications_all = unescape($('
').append( $("#nav-" + notifyType + "-see-all").clone() ).html()); //outerHtml hack var notifications_mark = unescape($('
').append( $("#nav-" + notifyType + "-mark-all").clone() ).html()); //outerHtml hack + var notifications_tt_only = unescape($('
').append( $("#tt-" + notifyType + "-only").clone() ).html()); //outerHtml hack var notifications_empty = unescape($("#nav-" + notifyType + "-menu").html()); var notify_menu = $("#nav-" + notifyType + "-menu"); @@ -885,14 +886,15 @@ function notify_popup_loader(notifyType) { window.location.href=window.location.href; } - $("#navbar-" + notifyType + "-menu").html(notifications_all + notifications_mark); - $("#nav-" + notifyType + "-menu").html(notifications_all + notifications_mark); + $("#navbar-" + notifyType + "-menu").html(notifications_all + notifications_mark + notifications_tt_only); + $("#nav-" + notifyType + "-menu").html(notifications_all + notifications_mark + notifications_tt_only); + $("." + notifyType + "-update").html(data.notify.length); $(data.notify).each(function() { - html = navbar_notifications_tpl.format(this.notify_link,this.photo,this.name,this.message,this.when,this.hclass,this.b64mid,this.notify_id); + html = navbar_notifications_tpl.format(this.notify_link,this.photo,this.name,this.message,this.when,this.hclass,this.b64mid,this.notify_id,this.thread_top); $("#navbar-" + notifyType + "-menu").append(html); - html = notifications_tpl.format(this.notify_link,this.photo,this.name,this.message,this.when,this.hclass,this.b64mid,this.notify_id); + html = notifications_tpl.format(this.notify_link,this.photo,this.name,this.message,this.when,this.hclass,this.b64mid,this.notify_id,this.thread_top); $("#nav-" + notifyType + "-menu").append(html); }); @@ -901,8 +903,12 @@ function notify_popup_loader(notifyType) { $(el).attr('src', $(el).data("src")); $(el).removeAttr("data-src"); }); + + if($('#tt-' + notifyType + '-only').hasClass('active')) + $('#nav-' + notifyType + '-menu [data-thread_top=false]').hide(); }); + setTimeout(function() { if(notify_menu.hasClass('show')) { console.log('updating ' + notifyType + ' notifications...'); diff --git a/view/tpl/notifications_widget.tpl b/view/tpl/notifications_widget.tpl index 18f3ef12d..90f03faf0 100644 --- a/view/tpl/notifications_widget.tpl +++ b/view/tpl/notifications_widget.tpl @@ -22,7 +22,7 @@ }); {{if $module == 'display' || $module == 'hq'}} - $(document).on('click touch', '.notification', function(e) { + $(document).on('click', '.notification', function(e) { var b64mid = $(this).data('b64mid'); var notify_id = $(this).data('notify_id'); var path = $(this)[0].pathname.substr(1,7); @@ -53,6 +53,16 @@ }); {{/if}} + {{foreach $notifications as $notification}} + {{if $notification.filter}} + $(document).on('click', '#tt-{{$notification.type}}-only', function(e) { + e.preventDefault(); + $('#nav-{{$notification.type}}-menu [data-thread_top=false]').toggle(); + $(this).toggleClass('active'); + }); + {{/if}} + {{/foreach}} + function getData(b64mid, notify_id) { $('.thread-wrapper').remove(); bParam_mid = b64mid; @@ -72,7 +82,7 @@