Adhere feedback

This commit is contained in:
Philipp 2022-11-27 01:33:13 +01:00
parent e6933a28da
commit 012f486eb6
No known key found for this signature in database
GPG key ID: 24A7501396EB5432
7 changed files with 56 additions and 56 deletions

View file

@ -69,7 +69,7 @@ class Browser extends BaseModule
$fileArray = array_map([$this, 'map_files'], $files); $fileArray = array_map([$this, 'map_files'], $files);
$tpl = Renderer::getMarkupTemplate('media/filebrowser.tpl'); $tpl = Renderer::getMarkupTemplate('media/browser.tpl');
$output = Renderer::replaceMacros($tpl, [ $output = Renderer::replaceMacros($tpl, [
'$type' => 'attachment', '$type' => 'attachment',
'$path' => ['' => $this->t('Files')], '$path' => ['' => $this->t('Files')],

View file

@ -79,7 +79,7 @@ class Browser extends BaseModule
$photosArray = array_map([$this, 'map_files'], $photos); $photosArray = array_map([$this, 'map_files'], $photos);
$tpl = Renderer::getMarkupTemplate('media/filebrowser.tpl'); $tpl = Renderer::getMarkupTemplate('media/browser.tpl');
$output = Renderer::replaceMacros($tpl, [ $output = Renderer::replaceMacros($tpl, [
'$type' => 'photo', '$type' => 'photo',
'$path' => $path, '$path' => $path,

View file

@ -51,23 +51,23 @@
* $(id).value = bbcode; * $(id).value = bbcode;
* }); * });
**/ **/
const FileBrowser = { const Browser = {
nickname: '', nickname: '',
type: '', type: '',
event: '', event: '',
id: null, id: null,
init: function (nickname, type) { init: function (nickname, type) {
FileBrowser.nickname = nickname; Browser.nickname = nickname;
FileBrowser.type = type; Browser.type = type;
FileBrowser.event = 'fbrowser.' + type; Browser.event = 'fbrowser.' + type;
if (location['hash'] !== '') { if (location['hash'] !== '') {
const h = location['hash'].replace('#', ''); const h = location['hash'].replace('#', '');
FileBrowser.event = FileBrowser.event + '.' + h.split('-')[0]; Browser.event = Browser.event + '.' + h.split('-')[0];
FileBrowser.id = h.split('-')[1]; Browser.id = h.split('-')[1];
} }
console.log('FileBrowser:', nickname, type, FileBrowser.event, FileBrowser.id); console.log('FileBrowser:', nickname, type, Browser.event, Browser.id);
$('.error a.close').on('click', function (e) { $('.error a.close').on('click', function (e) {
e.preventDefault(); e.preventDefault();
@ -76,7 +76,7 @@ const FileBrowser = {
$('.folders a, .path a').on('click', function (e) { $('.folders a, .path a').on('click', function (e) {
e.preventDefault(); e.preventDefault();
location.href = FileBrowser._getUrl("minimal", location['hash'], this.dataset.folder); location.href = Browser._getUrl("minimal", location['hash'], this.dataset.folder);
location.reload(); location.reload();
}); });
@ -84,17 +84,17 @@ const FileBrowser = {
e.preventDefault(); e.preventDefault();
let embed = ''; let embed = '';
if (FileBrowser.type === "photo") { if (Browser.type === "photo") {
embed = '[url=' + this.dataset.link + '][img=' + this.dataset.img + ']' + this.dataset.alt + '[/img][/url]'; embed = '[url=' + this.dataset.link + '][img=' + this.dataset.img + ']' + this.dataset.alt + '[/img][/url]';
} }
if (FileBrowser.type === "attachment") { if (Browser.type === "attachment") {
embed = '[attachment]' + this.dataset.link + '[/attachment]'; embed = '[attachment]' + this.dataset.link + '[/attachment]';
} }
console.log(FileBrowser.event, this.dataset.filename, embed, FileBrowser.id); console.log(Browser.event, this.dataset.filename, embed, Browser.id);
parent.$('body').trigger(FileBrowser.event, [ parent.$('body').trigger(Browser.event, [
this.dataset.filename, this.dataset.filename,
embed, embed,
FileBrowser.id Browser.id
]); ]);
}); });
@ -117,7 +117,7 @@ const FileBrowser = {
$('#profile-rotator').hide(); $('#profile-rotator').hide();
return; return;
} }
location.href = FileBrowser._getUrl("minimal", location['hash']); location.href = Browser._getUrl("minimal", location['hash']);
location.reload(); location.reload();
} }
} }
@ -142,7 +142,7 @@ const FileBrowser = {
$('#profile-rotator').hide(); $('#profile-rotator').hide();
return; return;
} }
location.href = FileBrowser._getUrl("minimal", location['hash']); location.href = Browser._getUrl("minimal", location['hash']);
location.reload(); location.reload();
} }
} }
@ -151,9 +151,9 @@ const FileBrowser = {
}, },
_getUrl: function (mode, hash, folder) { _getUrl: function (mode, hash, folder) {
let folderValue = folder !== undefined ? folder : FileBrowser.folder; let folderValue = folder !== undefined ? folder : Browser.folder;
let folderUrl = folderValue !== undefined ? '/' + encodeURIComponent(folderValue) : ''; let folderUrl = folderValue !== undefined ? '/' + encodeURIComponent(folderValue) : '';
return 'media/' + FileBrowser.type + '/browser' + folderUrl + '?mode=' + mode + hash; return 'media/' + Browser.type + '/browser' + folderUrl + '?mode=' + mode + hash;
} }
}; };
// @license-end // @license-end

View file

@ -2,10 +2,10 @@
This is the template used by mod/fbrowser.php This is the template used by mod/fbrowser.php
--> -->
<script type="text/javascript" src="view/js/ajaxupload.js?v={{$smarty.const.FRIENDICA_VERSION}}"></script> <script type="text/javascript" src="view/js/ajaxupload.js?v={{$smarty.const.FRIENDICA_VERSION}}"></script>
<script type="text/javascript" src="view/js/module/media/filebrowser.js?v={{$smarty.const.FRIENDICA_VERSION}}"></script> <script type="text/javascript" src="view/js/module/media/browser.js?v={{$smarty.const.FRIENDICA_VERSION}}"></script>
<script> <script>
$(function() { $(function() {
FileBrowser.init("{{$nickname}}", "{{$type}}"); Browser.init("{{$nickname}}", "{{$type}}");
}); });
</script> </script>
<div class="fbrowser {{$type}}"> <div class="fbrowser {{$type}}">

View file

@ -166,8 +166,8 @@ Dialog._load = function (url) {
// Initialize the filebrowser. // Initialize the filebrowser.
loadScript("view/js/ajaxupload.js"); loadScript("view/js/ajaxupload.js");
loadScript("view/theme/frio/js/module/media/filebrowser.js", function () { loadScript("view/theme/frio/js/module/media/browser.js", function () {
FileBrowser.init(filebrowser.dataset.nickname, filebrowser.dataset.type, match[1]); Browser.init(filebrowser.dataset.nickname, filebrowser.dataset.type, match[1]);
}); });
}; };

View file

@ -59,11 +59,11 @@
* the frio theme.and bootstrap modals * the frio theme.and bootstrap modals
* *
* The original file is under: * The original file is under:
* js/filebrowser.js * js/module/media/browser.js
* *
*/ */
var FileBrowser = { var Browser = {
nickname: '', nickname: '',
type: '', type: '',
event: '', event: '',
@ -71,24 +71,24 @@ var FileBrowser = {
id: null, id: null,
init: function (nickname, type, hash) { init: function (nickname, type, hash) {
FileBrowser.nickname = nickname; Browser.nickname = nickname;
FileBrowser.type = type; Browser.type = type;
FileBrowser.event = 'fbrowser.' + type; Browser.event = 'fbrowser.' + type;
if (hash !== '') { if (hash !== '') {
const h = hash.replace('#', ''); const h = hash.replace('#', '');
const destination = h.split('-')[0]; const destination = h.split('-')[0];
FileBrowser.id = h.split('-')[1]; Browser.id = h.split('-')[1];
FileBrowser.event = FileBrowser.event + '.' + destination; Browser.event = Browser.event + '.' + destination;
if (destination === 'comment') { if (destination === 'comment') {
// Get the comment textinput field // Get the comment textinput field
var commentElm = document.getElementById('comment-edit-text-' + FileBrowser.id); var commentElm = document.getElementById('comment-edit-text-' + Browser.id);
} }
} }
console.log('FileBrowser: ' + nickname, type, FileBrowser.event, FileBrowser.id); console.log('FileBrowser: ' + nickname, type, Browser.event, Browser.id);
FileBrowser.postLoad(); Browser.postLoad();
$('.error .close').on('click', function (e) { $('.error .close').on('click', function (e) {
e.preventDefault(); e.preventDefault();
@ -98,10 +98,10 @@ var FileBrowser = {
// Click on album link // Click on album link
$('.fbrowser').on('click', '.folders button, .path button', function (e) { $('.fbrowser').on('click', '.folders button, .path button', function (e) {
e.preventDefault(); e.preventDefault();
let url = FileBrowser._getUrl("none", this.dataset.folder); let url = Browser._getUrl("none", this.dataset.folder);
FileBrowser.folder = this.dataset.folder; Browser.folder = this.dataset.folder;
FileBrowser.loadContent(url); Browser.loadContent(url);
}); });
//Embed on click //Embed on click
@ -109,10 +109,10 @@ var FileBrowser = {
e.preventDefault(); e.preventDefault();
let embed = ''; let embed = '';
if (FileBrowser.type === 'photo') { if (Browser.type === 'photo') {
embed = '[url=' + this.dataset.link + '][img=' + this.dataset.img + ']' + this.dataset.alt + '[/img][/url]'; embed = '[url=' + this.dataset.link + '][img=' + this.dataset.img + ']' + this.dataset.alt + '[/img][/url]';
} }
if (FileBrowser.type === 'attachment') { if (Browser.type === 'attachment') {
embed = '[attachment]' + this.dataset.link + '[/attachment]'; embed = '[attachment]' + this.dataset.link + '[/attachment]';
} }
@ -122,18 +122,18 @@ var FileBrowser = {
// As for now we insert pieces of this function here // As for now we insert pieces of this function here
if (commentElm !== null && typeof commentElm !== 'undefined') { if (commentElm !== null && typeof commentElm !== 'undefined') {
if (commentElm.value === '') { if (commentElm.value === '') {
$('#comment-edit-text-' + FileBrowser.id) $('#comment-edit-text-' + Browser.id)
.addClass('comment-edit-text-full') .addClass('comment-edit-text-full')
.removeClass('comment-edit-text-empty'); .removeClass('comment-edit-text-empty');
$('#comment-edit-submit-wrapper-' + FileBrowser.id).show(); $('#comment-edit-submit-wrapper-' + Browser.id).show();
$('#comment-edit-text-' + FileBrowser.id).attr('tabindex', '9'); $('#comment-edit-text-' + Browser.id).attr('tabindex', '9');
$('#comment-edit-submit-' + FileBrowser.id).attr('tabindex', '10'); $('#comment-edit-submit-' + Browser.id).attr('tabindex', '10');
} }
} }
console.log(FileBrowser.event, this.dataset.filename, embed, FileBrowser.id); console.log(Browser.event, this.dataset.filename, embed, Browser.id);
$('body').trigger(FileBrowser.event, [this.dataset.filename, embed, FileBrowser.id, this.dataset.img]); $('body').trigger(Browser.event, [this.dataset.filename, embed, Browser.id, this.dataset.img]);
// Close model // Close model
$('#modal').modal('hide'); $('#modal').modal('hide');
@ -144,12 +144,12 @@ var FileBrowser = {
// EventListener for switching between photo and file mode // EventListener for switching between photo and file mode
$('.fbrowser').on('click', '.fbswitcher .btn', function (e) { $('.fbrowser').on('click', '.fbswitcher .btn', function (e) {
e.preventDefault(); e.preventDefault();
FileBrowser.type = this.getAttribute('data-mode'); Browser.type = this.getAttribute('data-mode');
$('.fbrowser') $('.fbrowser')
.removeClass() .removeClass()
.addClass('fbrowser ' + FileBrowser.type); .addClass('fbrowser ' + Browser.type);
FileBrowser.loadContent(FileBrowser._getUrl("none")); Browser.loadContent(Browser._getUrl("none"));
}); });
}, },
@ -160,7 +160,7 @@ var FileBrowser = {
new window.AjaxUpload( new window.AjaxUpload(
'upload-photo', 'upload-photo',
{ {
action: 'media/photo/upload?response=json&album=' + encodeURIComponent(FileBrowser.folder), action: 'media/photo/upload?response=json&album=' + encodeURIComponent(Browser.folder),
name: 'userfile', name: 'userfile',
responseType: 'json', responseType: 'json',
onSubmit: function (file, ext) { onSubmit: function (file, ext) {
@ -177,7 +177,7 @@ var FileBrowser = {
return; return;
} }
// load new content to fbrowser window // load new content to fbrowser window
FileBrowser.loadContent(FileBrowser._getUrl("none")); Browser.loadContent(Browser._getUrl("none"));
}, },
}); });
} }
@ -204,7 +204,7 @@ var FileBrowser = {
return; return;
} }
// Load new content to fbrowser window // Load new content to fbrowser window
FileBrowser.loadContent(FileBrowser._getUrl("none")); Browser.loadContent(Browser._getUrl("none"));
}, },
}); });
} }
@ -212,11 +212,11 @@ var FileBrowser = {
// Stuff which should be executed if no content was loaded // Stuff which should be executed if no content was loaded
postLoad: function () { postLoad: function () {
FileBrowser.initGallery(); Browser.initGallery();
$('.fbrowser .fbswitcher .btn').removeClass('active'); $('.fbrowser .fbswitcher .btn').removeClass('active');
$('.fbrowser .fbswitcher [data-mode=' + FileBrowser.type + ']').addClass('active'); $('.fbrowser .fbswitcher [data-mode=' + Browser.type + ']').addClass('active');
// We need to add the AjaxUpload to the button // We need to add the AjaxUpload to the button
FileBrowser.uploadButtons(); Browser.uploadButtons();
}, },
// Load new content (e.g. change photo album) // Load new content (e.g. change photo album)
@ -229,7 +229,7 @@ var FileBrowser = {
$('.profile-rotator-wrapper').hide(); $('.profile-rotator-wrapper').hide();
if (textStatus === 'success') { if (textStatus === 'success') {
$(".fbrowser_content").show(); $(".fbrowser_content").show();
FileBrowser.postLoad(); Browser.postLoad();
} }
}); });
}, },
@ -244,9 +244,9 @@ var FileBrowser = {
}, },
_getUrl: function (mode, folder) { _getUrl: function (mode, folder) {
let folderValue = folder !== undefined ? folder : FileBrowser.folder; let folderValue = folder !== undefined ? folder : Browser.folder;
let folderUrl = folderValue !== undefined ? '/' + encodeURIComponent(folderValue) : ''; let folderUrl = folderValue !== undefined ? '/' + encodeURIComponent(folderValue) : '';
return 'media/' + FileBrowser.type + '/browser' + folderUrl + '?mode=' + mode + "&theme=frio"; return 'media/' + Browser.type + '/browser' + folderUrl + '?mode=' + mode + "&theme=frio";
} }
}; };
// @license-end // @license-end