From 012f486eb6cc11cd2b3871e5c70f40e812ecf647 Mon Sep 17 00:00:00 2001 From: Philipp Date: Sun, 27 Nov 2022 01:33:13 +0100 Subject: [PATCH] Adhere feedback --- src/Module/Media/Attachment/Browser.php | 2 +- src/Module/Media/Photo/Browser.php | 2 +- .../media/browser.js} | 34 +++++----- .../media/{filebrowser.tpl => browser.tpl} | 4 +- view/theme/frio/js/modal.js | 4 +- .../media/{filebrowser.js => browser.js} | 66 +++++++++---------- .../media/{filebrowser.tpl => browser.tpl} | 0 7 files changed, 56 insertions(+), 56 deletions(-) rename view/js/{media/filebrowser.js => module/media/browser.js} (79%) rename view/templates/media/{filebrowser.tpl => browser.tpl} (87%) rename view/theme/frio/js/module/media/{filebrowser.js => browser.js} (78%) rename view/theme/frio/templates/media/{filebrowser.tpl => browser.tpl} (100%) diff --git a/src/Module/Media/Attachment/Browser.php b/src/Module/Media/Attachment/Browser.php index 50e0b7f803..de9f7f4fc9 100644 --- a/src/Module/Media/Attachment/Browser.php +++ b/src/Module/Media/Attachment/Browser.php @@ -69,7 +69,7 @@ class Browser extends BaseModule $fileArray = array_map([$this, 'map_files'], $files); - $tpl = Renderer::getMarkupTemplate('media/filebrowser.tpl'); + $tpl = Renderer::getMarkupTemplate('media/browser.tpl'); $output = Renderer::replaceMacros($tpl, [ '$type' => 'attachment', '$path' => ['' => $this->t('Files')], diff --git a/src/Module/Media/Photo/Browser.php b/src/Module/Media/Photo/Browser.php index 76b9db3a51..0df19d0098 100644 --- a/src/Module/Media/Photo/Browser.php +++ b/src/Module/Media/Photo/Browser.php @@ -79,7 +79,7 @@ class Browser extends BaseModule $photosArray = array_map([$this, 'map_files'], $photos); - $tpl = Renderer::getMarkupTemplate('media/filebrowser.tpl'); + $tpl = Renderer::getMarkupTemplate('media/browser.tpl'); $output = Renderer::replaceMacros($tpl, [ '$type' => 'photo', '$path' => $path, diff --git a/view/js/media/filebrowser.js b/view/js/module/media/browser.js similarity index 79% rename from view/js/media/filebrowser.js rename to view/js/module/media/browser.js index 5055b1d8e6..7790e2588b 100644 --- a/view/js/media/filebrowser.js +++ b/view/js/module/media/browser.js @@ -51,23 +51,23 @@ * $(id).value = bbcode; * }); **/ -const FileBrowser = { +const Browser = { nickname: '', type: '', event: '', id: null, init: function (nickname, type) { - FileBrowser.nickname = nickname; - FileBrowser.type = type; - FileBrowser.event = 'fbrowser.' + type; + Browser.nickname = nickname; + Browser.type = type; + Browser.event = 'fbrowser.' + type; if (location['hash'] !== '') { const h = location['hash'].replace('#', ''); - FileBrowser.event = FileBrowser.event + '.' + h.split('-')[0]; - FileBrowser.id = h.split('-')[1]; + Browser.event = Browser.event + '.' + h.split('-')[0]; + 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) { e.preventDefault(); @@ -76,7 +76,7 @@ const FileBrowser = { $('.folders a, .path a').on('click', function (e) { e.preventDefault(); - location.href = FileBrowser._getUrl("minimal", location['hash'], this.dataset.folder); + location.href = Browser._getUrl("minimal", location['hash'], this.dataset.folder); location.reload(); }); @@ -84,17 +84,17 @@ const FileBrowser = { e.preventDefault(); let embed = ''; - if (FileBrowser.type === "photo") { + if (Browser.type === "photo") { 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]'; } - console.log(FileBrowser.event, this.dataset.filename, embed, FileBrowser.id); - parent.$('body').trigger(FileBrowser.event, [ + console.log(Browser.event, this.dataset.filename, embed, Browser.id); + parent.$('body').trigger(Browser.event, [ this.dataset.filename, embed, - FileBrowser.id + Browser.id ]); }); @@ -117,7 +117,7 @@ const FileBrowser = { $('#profile-rotator').hide(); return; } - location.href = FileBrowser._getUrl("minimal", location['hash']); + location.href = Browser._getUrl("minimal", location['hash']); location.reload(); } } @@ -142,7 +142,7 @@ const FileBrowser = { $('#profile-rotator').hide(); return; } - location.href = FileBrowser._getUrl("minimal", location['hash']); + location.href = Browser._getUrl("minimal", location['hash']); location.reload(); } } @@ -151,9 +151,9 @@ const FileBrowser = { }, _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) : ''; - return 'media/' + FileBrowser.type + '/browser' + folderUrl + '?mode=' + mode + hash; + return 'media/' + Browser.type + '/browser' + folderUrl + '?mode=' + mode + hash; } }; // @license-end diff --git a/view/templates/media/filebrowser.tpl b/view/templates/media/browser.tpl similarity index 87% rename from view/templates/media/filebrowser.tpl rename to view/templates/media/browser.tpl index 6c087a62be..749c2bea7e 100644 --- a/view/templates/media/filebrowser.tpl +++ b/view/templates/media/browser.tpl @@ -2,10 +2,10 @@ This is the template used by mod/fbrowser.php --> - +
diff --git a/view/theme/frio/js/modal.js b/view/theme/frio/js/modal.js index ed256450cc..c3c4009b05 100644 --- a/view/theme/frio/js/modal.js +++ b/view/theme/frio/js/modal.js @@ -166,8 +166,8 @@ Dialog._load = function (url) { // Initialize the filebrowser. loadScript("view/js/ajaxupload.js"); - loadScript("view/theme/frio/js/module/media/filebrowser.js", function () { - FileBrowser.init(filebrowser.dataset.nickname, filebrowser.dataset.type, match[1]); + loadScript("view/theme/frio/js/module/media/browser.js", function () { + Browser.init(filebrowser.dataset.nickname, filebrowser.dataset.type, match[1]); }); }; diff --git a/view/theme/frio/js/module/media/filebrowser.js b/view/theme/frio/js/module/media/browser.js similarity index 78% rename from view/theme/frio/js/module/media/filebrowser.js rename to view/theme/frio/js/module/media/browser.js index 802c440989..c89f426ebd 100644 --- a/view/theme/frio/js/module/media/filebrowser.js +++ b/view/theme/frio/js/module/media/browser.js @@ -59,11 +59,11 @@ * the frio theme.and bootstrap modals * * The original file is under: - * js/filebrowser.js + * js/module/media/browser.js * */ -var FileBrowser = { +var Browser = { nickname: '', type: '', event: '', @@ -71,24 +71,24 @@ var FileBrowser = { id: null, init: function (nickname, type, hash) { - FileBrowser.nickname = nickname; - FileBrowser.type = type; - FileBrowser.event = 'fbrowser.' + type; + Browser.nickname = nickname; + Browser.type = type; + Browser.event = 'fbrowser.' + type; if (hash !== '') { const h = hash.replace('#', ''); const destination = h.split('-')[0]; - FileBrowser.id = h.split('-')[1]; - FileBrowser.event = FileBrowser.event + '.' + destination; + Browser.id = h.split('-')[1]; + Browser.event = Browser.event + '.' + destination; if (destination === 'comment') { // 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) { e.preventDefault(); @@ -98,10 +98,10 @@ var FileBrowser = { // Click on album link $('.fbrowser').on('click', '.folders button, .path button', function (e) { e.preventDefault(); - let url = FileBrowser._getUrl("none", this.dataset.folder); - FileBrowser.folder = this.dataset.folder; + let url = Browser._getUrl("none", this.dataset.folder); + Browser.folder = this.dataset.folder; - FileBrowser.loadContent(url); + Browser.loadContent(url); }); //Embed on click @@ -109,10 +109,10 @@ var FileBrowser = { e.preventDefault(); let embed = ''; - if (FileBrowser.type === 'photo') { + if (Browser.type === 'photo') { 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]'; } @@ -122,18 +122,18 @@ var FileBrowser = { // As for now we insert pieces of this function here if (commentElm !== null && typeof commentElm !== 'undefined') { if (commentElm.value === '') { - $('#comment-edit-text-' + FileBrowser.id) + $('#comment-edit-text-' + Browser.id) .addClass('comment-edit-text-full') .removeClass('comment-edit-text-empty'); - $('#comment-edit-submit-wrapper-' + FileBrowser.id).show(); - $('#comment-edit-text-' + FileBrowser.id).attr('tabindex', '9'); - $('#comment-edit-submit-' + FileBrowser.id).attr('tabindex', '10'); + $('#comment-edit-submit-wrapper-' + Browser.id).show(); + $('#comment-edit-text-' + Browser.id).attr('tabindex', '9'); + $('#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 $('#modal').modal('hide'); @@ -144,12 +144,12 @@ var FileBrowser = { // EventListener for switching between photo and file mode $('.fbrowser').on('click', '.fbswitcher .btn', function (e) { e.preventDefault(); - FileBrowser.type = this.getAttribute('data-mode'); + Browser.type = this.getAttribute('data-mode'); $('.fbrowser') .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( 'upload-photo', { - action: 'media/photo/upload?response=json&album=' + encodeURIComponent(FileBrowser.folder), + action: 'media/photo/upload?response=json&album=' + encodeURIComponent(Browser.folder), name: 'userfile', responseType: 'json', onSubmit: function (file, ext) { @@ -177,7 +177,7 @@ var FileBrowser = { return; } // load new content to fbrowser window - FileBrowser.loadContent(FileBrowser._getUrl("none")); + Browser.loadContent(Browser._getUrl("none")); }, }); } @@ -204,7 +204,7 @@ var FileBrowser = { return; } // 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 postLoad: function () { - FileBrowser.initGallery(); + Browser.initGallery(); $('.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 - FileBrowser.uploadButtons(); + Browser.uploadButtons(); }, // Load new content (e.g. change photo album) @@ -229,7 +229,7 @@ var FileBrowser = { $('.profile-rotator-wrapper').hide(); if (textStatus === 'success') { $(".fbrowser_content").show(); - FileBrowser.postLoad(); + Browser.postLoad(); } }); }, @@ -244,9 +244,9 @@ var FileBrowser = { }, _getUrl: function (mode, folder) { - let folderValue = folder !== undefined ? folder : FileBrowser.folder; + let folderValue = folder !== undefined ? folder : Browser.folder; 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 diff --git a/view/theme/frio/templates/media/filebrowser.tpl b/view/theme/frio/templates/media/browser.tpl similarity index 100% rename from view/theme/frio/templates/media/filebrowser.tpl rename to view/theme/frio/templates/media/browser.tpl