]> git.mxchange.org Git - friendica.git/commitdiff
Adhere feedback
authorPhilipp <admin@philipp.info>
Sun, 27 Nov 2022 00:33:13 +0000 (01:33 +0100)
committerPhilipp <admin@philipp.info>
Sun, 27 Nov 2022 00:34:59 +0000 (01:34 +0100)
src/Module/Media/Attachment/Browser.php
src/Module/Media/Photo/Browser.php
view/js/media/filebrowser.js [deleted file]
view/js/module/media/browser.js [new file with mode: 0644]
view/templates/media/browser.tpl [new file with mode: 0644]
view/templates/media/filebrowser.tpl [deleted file]
view/theme/frio/js/modal.js
view/theme/frio/js/module/media/browser.js [new file with mode: 0644]
view/theme/frio/js/module/media/filebrowser.js [deleted file]
view/theme/frio/templates/media/browser.tpl [new file with mode: 0644]
view/theme/frio/templates/media/filebrowser.tpl [deleted file]

index 50e0b7f803c35e8ec34d94d8b4a562f42767adc2..de9f7f4fc99023fd854f10b76bd44c648e0b6dc6 100644 (file)
@@ -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')],
index 76b9db3a516e937ade31e8eeb57079c72c8c6bf0..0df19d0098331826d085dc09f1a7a0c90238d345 100644 (file)
@@ -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/media/filebrowser.js
deleted file mode 100644 (file)
index 5055b1d..0000000
+++ /dev/null
@@ -1,159 +0,0 @@
-// @license magnet:?xt=urn:btih:0b31508aeb0634b347b8270c7bee4d411b5d4109&dn=agpl-3.0.txt AGPLv3-or-later
-/**
- * Filebrowser - Friendica Communications Server
- *
- * Copyright (c) 2010-2021, the Friendica project
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This code handle user interaction for image/file upload/browser dialog.
- * Is loaded from filebrowser_plain.tpl
- *
- * To load filebrowser in colorbox, call
- *
- *      Dialog.doImageBrowser(eventname, id);
- *
- * or
- *
- *      Dialog.doFileBrowser(eventname, id);
- *
- * where:
- *
- *             eventname: event name to catch return value
- *             id: id returned to event handler
- *
- * When user select an item, an event in fired in parent page, on body element
- * The event is named
- *
- *             fbrowser.<type>.[<eventname>]
- *
- * <type> will be one of "image" or "file", and the event handler will
- * get the following params:
- *
- *             filename: filename of item chosen by user
- *             embed: bbcode to embed element into posts
- *             id: id from caller code
- *
- * example:
- *
- *             // open dialog for select an image for a textarea with id "myeditor"
- *             var id="myeditor";
- *             Dialog.doImageBrowser("example", id);
- *
- *             // setup event handler to get user selection
- *             $("body").on("fbrowser.image.example", function(event, filename, bbcode, id) {
- *                     // close colorbox
- *                     $.colorbox.close();
- *                     // replace textarea text with bbcode
- *                     $(id).value = bbcode;
- *             });
- **/
-const FileBrowser = {
-       nickname: '',
-       type: '',
-       event: '',
-       id: null,
-
-       init: function (nickname, type) {
-               FileBrowser.nickname = nickname;
-               FileBrowser.type = type;
-               FileBrowser.event = 'fbrowser.' + type;
-               if (location['hash'] !== '') {
-                       const h = location['hash'].replace('#', '');
-                       FileBrowser.event = FileBrowser.event + '.' + h.split('-')[0];
-                       FileBrowser.id = h.split('-')[1];
-               }
-
-               console.log('FileBrowser:', nickname, type, FileBrowser.event, FileBrowser.id);
-
-               $('.error a.close').on('click', function (e) {
-                       e.preventDefault();
-                       $('.error').addClass('hidden');
-               });
-
-               $('.folders a, .path a').on('click', function (e) {
-                       e.preventDefault();
-                       location.href = FileBrowser._getUrl("minimal", location['hash'], this.dataset.folder);
-                       location.reload();
-               });
-
-               $(".photo-album-photo-link").on('click', function (e) {
-                       e.preventDefault();
-
-                       let embed = '';
-                       if (FileBrowser.type === "photo") {
-                               embed = '[url=' + this.dataset.link + '][img=' + this.dataset.img + ']' + this.dataset.alt + '[/img][/url]';
-                       }
-                       if (FileBrowser.type === "attachment") {
-                               embed = '[attachment]' + this.dataset.link + '[/attachment]';
-                       }
-                       console.log(FileBrowser.event, this.dataset.filename, embed, FileBrowser.id);
-                       parent.$('body').trigger(FileBrowser.event, [
-                               this.dataset.filename,
-                               embed,
-                               FileBrowser.id
-                       ]);
-
-               });
-
-               if ($('#upload-photo').length) {
-                       new window.AjaxUpload(
-                               'upload-photo',
-                               {
-                                       action: 'media/photo/upload?response=json',
-                                       name: 'userfile',
-                                       responseType: 'json',
-                                       onSubmit: function (file, ext) {
-                                               $('#profile-rotator').show();
-                                               $('.error').addClass('hidden');
-                                       },
-                                       onComplete: function (file, response) {
-                                               if (response['error'] !== undefined) {
-                                                       $('.error span').html(response['error']);
-                                                       $('.error').removeClass('hidden');
-                                                       $('#profile-rotator').hide();
-                                                       return;
-                                               }
-                                               location.href = FileBrowser._getUrl("minimal", location['hash']);
-                                               location.reload();
-                                       }
-                               }
-                       );
-               }
-
-               if ($('#upload-attachment').length)     {
-                       new window.AjaxUpload(
-                               'upload-attachment',
-                               {
-                                       action: 'media/attachment/upload?response=json',
-                                       name: 'userfile',
-                                       responseType: 'json',
-                                       onSubmit: function (file, ext) {
-                                               $('#profile-rotator').show();
-                                               $('.error').addClass('hidden');
-                                       },
-                                       onComplete: function (file, response) {
-                                               if (response['error'] !== undefined) {
-                                                       $('.error span').html(response['error']);
-                                                       $('.error').removeClass('hidden');
-                                                       $('#profile-rotator').hide();
-                                                       return;
-                                               }
-                                               location.href = FileBrowser._getUrl("minimal", location['hash']);
-                                               location.reload();
-                                       }
-                               }
-                       );
-               }
-       },
-
-       _getUrl: function (mode, hash, folder) {
-               let folderValue = folder !== undefined ? folder : FileBrowser.folder;
-               let folderUrl = folderValue !== undefined ? '/' + encodeURIComponent(folderValue) : '';
-               return 'media/' + FileBrowser.type + '/browser' + folderUrl + '?mode=' + mode + hash;
-       }
-};
-// @license-end
diff --git a/view/js/module/media/browser.js b/view/js/module/media/browser.js
new file mode 100644 (file)
index 0000000..7790e25
--- /dev/null
@@ -0,0 +1,159 @@
+// @license magnet:?xt=urn:btih:0b31508aeb0634b347b8270c7bee4d411b5d4109&dn=agpl-3.0.txt AGPLv3-or-later
+/**
+ * Filebrowser - Friendica Communications Server
+ *
+ * Copyright (c) 2010-2021, the Friendica project
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This code handle user interaction for image/file upload/browser dialog.
+ * Is loaded from filebrowser_plain.tpl
+ *
+ * To load filebrowser in colorbox, call
+ *
+ *      Dialog.doImageBrowser(eventname, id);
+ *
+ * or
+ *
+ *      Dialog.doFileBrowser(eventname, id);
+ *
+ * where:
+ *
+ *             eventname: event name to catch return value
+ *             id: id returned to event handler
+ *
+ * When user select an item, an event in fired in parent page, on body element
+ * The event is named
+ *
+ *             fbrowser.<type>.[<eventname>]
+ *
+ * <type> will be one of "image" or "file", and the event handler will
+ * get the following params:
+ *
+ *             filename: filename of item chosen by user
+ *             embed: bbcode to embed element into posts
+ *             id: id from caller code
+ *
+ * example:
+ *
+ *             // open dialog for select an image for a textarea with id "myeditor"
+ *             var id="myeditor";
+ *             Dialog.doImageBrowser("example", id);
+ *
+ *             // setup event handler to get user selection
+ *             $("body").on("fbrowser.image.example", function(event, filename, bbcode, id) {
+ *                     // close colorbox
+ *                     $.colorbox.close();
+ *                     // replace textarea text with bbcode
+ *                     $(id).value = bbcode;
+ *             });
+ **/
+const Browser = {
+       nickname: '',
+       type: '',
+       event: '',
+       id: null,
+
+       init: function (nickname, type) {
+               Browser.nickname = nickname;
+               Browser.type = type;
+               Browser.event = 'fbrowser.' + type;
+               if (location['hash'] !== '') {
+                       const h = location['hash'].replace('#', '');
+                       Browser.event = Browser.event + '.' + h.split('-')[0];
+                       Browser.id = h.split('-')[1];
+               }
+
+               console.log('FileBrowser:', nickname, type, Browser.event, Browser.id);
+
+               $('.error a.close').on('click', function (e) {
+                       e.preventDefault();
+                       $('.error').addClass('hidden');
+               });
+
+               $('.folders a, .path a').on('click', function (e) {
+                       e.preventDefault();
+                       location.href = Browser._getUrl("minimal", location['hash'], this.dataset.folder);
+                       location.reload();
+               });
+
+               $(".photo-album-photo-link").on('click', function (e) {
+                       e.preventDefault();
+
+                       let embed = '';
+                       if (Browser.type === "photo") {
+                               embed = '[url=' + this.dataset.link + '][img=' + this.dataset.img + ']' + this.dataset.alt + '[/img][/url]';
+                       }
+                       if (Browser.type === "attachment") {
+                               embed = '[attachment]' + this.dataset.link + '[/attachment]';
+                       }
+                       console.log(Browser.event, this.dataset.filename, embed, Browser.id);
+                       parent.$('body').trigger(Browser.event, [
+                               this.dataset.filename,
+                               embed,
+                               Browser.id
+                       ]);
+
+               });
+
+               if ($('#upload-photo').length) {
+                       new window.AjaxUpload(
+                               'upload-photo',
+                               {
+                                       action: 'media/photo/upload?response=json',
+                                       name: 'userfile',
+                                       responseType: 'json',
+                                       onSubmit: function (file, ext) {
+                                               $('#profile-rotator').show();
+                                               $('.error').addClass('hidden');
+                                       },
+                                       onComplete: function (file, response) {
+                                               if (response['error'] !== undefined) {
+                                                       $('.error span').html(response['error']);
+                                                       $('.error').removeClass('hidden');
+                                                       $('#profile-rotator').hide();
+                                                       return;
+                                               }
+                                               location.href = Browser._getUrl("minimal", location['hash']);
+                                               location.reload();
+                                       }
+                               }
+                       );
+               }
+
+               if ($('#upload-attachment').length)     {
+                       new window.AjaxUpload(
+                               'upload-attachment',
+                               {
+                                       action: 'media/attachment/upload?response=json',
+                                       name: 'userfile',
+                                       responseType: 'json',
+                                       onSubmit: function (file, ext) {
+                                               $('#profile-rotator').show();
+                                               $('.error').addClass('hidden');
+                                       },
+                                       onComplete: function (file, response) {
+                                               if (response['error'] !== undefined) {
+                                                       $('.error span').html(response['error']);
+                                                       $('.error').removeClass('hidden');
+                                                       $('#profile-rotator').hide();
+                                                       return;
+                                               }
+                                               location.href = Browser._getUrl("minimal", location['hash']);
+                                               location.reload();
+                                       }
+                               }
+                       );
+               }
+       },
+
+       _getUrl: function (mode, hash, folder) {
+               let folderValue = folder !== undefined ? folder : Browser.folder;
+               let folderUrl = folderValue !== undefined ? '/' + encodeURIComponent(folderValue) : '';
+               return 'media/' + Browser.type + '/browser' + folderUrl + '?mode=' + mode + hash;
+       }
+};
+// @license-end
diff --git a/view/templates/media/browser.tpl b/view/templates/media/browser.tpl
new file mode 100644 (file)
index 0000000..749c2be
--- /dev/null
@@ -0,0 +1,51 @@
+<!--
+       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/module/media/browser.js?v={{$smarty.const.FRIENDICA_VERSION}}"></script>
+<script>
+       $(function() {
+               Browser.init("{{$nickname}}", "{{$type}}");
+       });
+</script>
+<div class="fbrowser {{$type}}">
+       <div class="error hidden">
+               <span></span> <a href="#" class='close'>X</a>
+       </div>
+
+       <div class="path">
+               {{foreach $path as $folder => $name}}
+                       <a href="#" data-folder="{{$folder}}">{{$name}}</a>
+               {{/foreach}}
+       </div>
+
+       {{if $folders }}
+       <div class="folders">
+               <ul>
+               {{foreach $folders as $folder}}
+                       <li><a href="#" data-folder="{{$folder}}">{{$folder}}</a></li>
+               {{/foreach}}
+               </ul>
+       </div>
+       {{/if}}
+
+       <div class="list">
+               {{foreach $files as $f}}
+               <div class="photo-album-image-wrapper">
+                       <a href="#" class="photo-album-photo-link" data-link="{{$f.0}}" data-filename="{{$f.1}}" data-img="{{$f.2}}" data-alt="{{$f.3}}">
+                               <img alt="{{$f.3}}" src="{{$f.1}}">
+                               <p>{{$f.1}}</p>
+                       </a>
+               </div>
+               {{/foreach}}
+       </div>
+
+       <div class="upload">
+               <button id="upload-{{$type}}"><img id="profile-rotator" src="images/rotator.gif" alt="{{$wait}}" title="{{$wait}}" style="display: none;" /> {{$upload}}</button>
+       </div>
+</div>
+
+
+       </body>
+
+</html>
diff --git a/view/templates/media/filebrowser.tpl b/view/templates/media/filebrowser.tpl
deleted file mode 100644 (file)
index 6c087a6..0000000
+++ /dev/null
@@ -1,51 +0,0 @@
-<!--
-       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/module/media/filebrowser.js?v={{$smarty.const.FRIENDICA_VERSION}}"></script>
-<script>
-       $(function() {
-               FileBrowser.init("{{$nickname}}", "{{$type}}");
-       });
-</script>
-<div class="fbrowser {{$type}}">
-       <div class="error hidden">
-               <span></span> <a href="#" class='close'>X</a>
-       </div>
-
-       <div class="path">
-               {{foreach $path as $folder => $name}}
-                       <a href="#" data-folder="{{$folder}}">{{$name}}</a>
-               {{/foreach}}
-       </div>
-
-       {{if $folders }}
-       <div class="folders">
-               <ul>
-               {{foreach $folders as $folder}}
-                       <li><a href="#" data-folder="{{$folder}}">{{$folder}}</a></li>
-               {{/foreach}}
-               </ul>
-       </div>
-       {{/if}}
-
-       <div class="list">
-               {{foreach $files as $f}}
-               <div class="photo-album-image-wrapper">
-                       <a href="#" class="photo-album-photo-link" data-link="{{$f.0}}" data-filename="{{$f.1}}" data-img="{{$f.2}}" data-alt="{{$f.3}}">
-                               <img alt="{{$f.3}}" src="{{$f.1}}">
-                               <p>{{$f.1}}</p>
-                       </a>
-               </div>
-               {{/foreach}}
-       </div>
-
-       <div class="upload">
-               <button id="upload-{{$type}}"><img id="profile-rotator" src="images/rotator.gif" alt="{{$wait}}" title="{{$wait}}" style="display: none;" /> {{$upload}}</button>
-       </div>
-</div>
-
-
-       </body>
-
-</html>
index ed256450cc93ea8bb9cd96e422141b9e92fdce22..c3c4009b055f3fdca296821df93d29e0073792d2 100644 (file)
@@ -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/browser.js b/view/theme/frio/js/module/media/browser.js
new file mode 100644 (file)
index 0000000..c89f426
--- /dev/null
@@ -0,0 +1,252 @@
+// @license magnet:?xt=urn:btih:0b31508aeb0634b347b8270c7bee4d411b5d4109&dn=agpl-3.0.txt AGPLv3-or-later
+/**
+ * Filebrowser - Friendica Communications Server
+ *
+ * Copyright (c) 2010-2021, the Friendica project
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This code handle user interaction for photo/file upload/browser dialog.
+ * Is loaded from filebrowser_plain.tpl
+ *
+ * To load filebrowser in colorbox, call
+ *
+ *      Dialog.doImageBrowser(eventname, id);
+ *
+ * or
+ *
+ *      Dialog.doFileBrowser(eventname, id);
+ *
+ * where:
+ *
+ *             eventname: event name to catch return value
+ *             id: id returned to event handler
+ *
+ * When user select an item, an event in fired in parent page, on body element
+ * The event is named
+ *
+ *             fbrowser.<type>.[<eventname>]
+ *
+ * <type> will be one of "image" or "file", and the event handler will
+ * get the following params:
+ *
+ *             filename: filename of item chosen by user
+ *             embed: bbcode to embed element into posts
+ *             id: id from caller code
+ *
+ * example:
+ *
+ *             // open dialog for select an image for a textarea with id "myeditor"
+ *             var id="myeditor";
+ *             Dialog.doImageBrowser("example", id);
+ *
+ *             // setup event handler to get user selection
+ *             $("body").on("fbrowser.image.example", function(event, filename, bbcode, id) {
+ *                     // close colorbox
+ *                     $.colorbox.close();
+ *                     // replace textarea text with bbcode
+ *                     $(id).value = bbcode;
+ *             });
+ **/
+
+/*
+ * IMPORTANT
+ *
+ *  This is a modified version to work with
+ *  the frio theme.and bootstrap modals
+ *
+ *  The original file is under:
+ *  js/module/media/browser.js
+ *
+ */
+
+var Browser = {
+       nickname: '',
+       type: '',
+       event: '',
+       folder: '',
+       id: null,
+
+       init: function (nickname, type, hash) {
+               Browser.nickname = nickname;
+               Browser.type = type;
+               Browser.event = 'fbrowser.' + type;
+
+               if (hash !== '') {
+                       const h = hash.replace('#', '');
+                       const destination = h.split('-')[0];
+                       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-' + Browser.id);
+                       }
+               }
+
+               console.log('FileBrowser: ' + nickname, type, Browser.event, Browser.id);
+
+               Browser.postLoad();
+
+               $('.error .close').on('click', function (e) {
+                       e.preventDefault();
+                       $('.error').addClass('hidden');
+               });
+
+               // Click on album link
+               $('.fbrowser').on('click', '.folders button, .path button', function (e) {
+                       e.preventDefault();
+                       let url = Browser._getUrl("none", this.dataset.folder);
+                       Browser.folder = this.dataset.folder;
+
+                       Browser.loadContent(url);
+               });
+
+               //Embed on click
+               $('.fbrowser').on('click', '.photo-album-photo-link', function (e) {
+                       e.preventDefault();
+
+                       let embed = '';
+                       if (Browser.type === 'photo') {
+                               embed = '[url=' + this.dataset.link + '][img=' + this.dataset.img + ']' + this.dataset.alt + '[/img][/url]';
+                       }
+                       if (Browser.type === 'attachment') {
+                               embed = '[attachment]' + this.dataset.link + '[/attachment]';
+                       }
+
+                       // Delete prefilled Text of the comment input
+                       // Note: not the best solution but function commentOpenUI don't
+                       // work as expected (we need a way to wait until commentOpenUI would be finished).
+                       // As for now we insert pieces of this function here
+                       if (commentElm !== null && typeof commentElm !== 'undefined') {
+                               if (commentElm.value === '') {
+                                       $('#comment-edit-text-' + Browser.id)
+                                               .addClass('comment-edit-text-full')
+                                               .removeClass('comment-edit-text-empty');
+                                       $('#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(Browser.event, this.dataset.filename, embed, Browser.id);
+
+                       $('body').trigger(Browser.event, [this.dataset.filename, embed, Browser.id, this.dataset.img]);
+
+                       // Close model
+                       $('#modal').modal('hide');
+                       // Update autosize for this textarea
+                       autosize.update($('.text-autosize'));
+               });
+
+               // EventListener for switching between photo and file mode
+               $('.fbrowser').on('click', '.fbswitcher .btn', function (e) {
+                       e.preventDefault();
+                       Browser.type = this.getAttribute('data-mode');
+                       $('.fbrowser')
+                               .removeClass()
+                               .addClass('fbrowser ' + Browser.type);
+
+                       Browser.loadContent(Browser._getUrl("none"));
+               });
+       },
+
+       // Initialize the AjaxUpload for the upload buttons
+       uploadButtons: function () {
+               if ($('#upload-photo').length) {
+                       //AjaxUpload for photos
+                       new window.AjaxUpload(
+                               'upload-photo',
+                               {
+                                       action: 'media/photo/upload?response=json&album=' + encodeURIComponent(Browser.folder),
+                                       name: 'userfile',
+                                       responseType: 'json',
+                                       onSubmit: function (file, ext) {
+                                               $('.fbrowser-content').hide();
+                                               $('.fbrowser .profile-rotator-wrapper').show();
+                                               $('.error').addClass('hidden');
+                                       },
+                                       onComplete: function (file, response) {
+                                               if (response['error'] !== undefined) {
+                                                       $('.error span').html(response['error']);
+                                                       $('.error').removeClass('hidden');
+                                                       $('.fbrowser .profile-rotator-wrapper').hide();
+                                                       $('.fbrowser-content').show();
+                                                       return;
+                                               }
+                                               // load new content to fbrowser window
+                                               Browser.loadContent(Browser._getUrl("none"));
+                                       },
+                               });
+               }
+
+               if ($('#upload-attachment').length) {
+                       //AjaxUpload for files
+                       new window.AjaxUpload(
+                               'upload-attachment',
+                               {
+                                       action: 'media/attachment/upload?response=json',
+                                       name: 'userfile',
+                                       responseType: 'json',
+                                       onSubmit: function (file, ext) {
+                                               $('.fbrowser-content').hide();
+                                               $('.fbrowser .profile-rotator-wrapper').show();
+                                               $('.error').addClass('hidden');
+                                       },
+                                       onComplete: function (file, response) {
+                                               if (response["error"] !== undefined) {
+                                                       $('.error span').html(response['error']);
+                                                       $('.error').removeClass('hidden');
+                                                       $('.fbrowser .profile-rotator-wrapper').hide();
+                                                       $('.fbrowser-content').show();
+                                                       return;
+                                               }
+                                               // Load new content to fbrowser window
+                                               Browser.loadContent(Browser._getUrl("none"));
+                                       },
+                               });
+               }
+       },
+
+       // Stuff which should be executed if no content was loaded
+       postLoad: function () {
+               Browser.initGallery();
+               $('.fbrowser .fbswitcher .btn').removeClass('active');
+               $('.fbrowser .fbswitcher [data-mode=' + Browser.type + ']').addClass('active');
+               // We need to add the AjaxUpload to the button
+               Browser.uploadButtons();
+       },
+
+       // Load new content (e.g. change photo album)
+       loadContent: function (url) {
+               $('.fbrowser-content').hide();
+               $('.fbrowser .profile-rotator-wrapper').show();
+
+               // load new content to fbrowser window
+               $('.fbrowser').load(url, function (responseText, textStatus) {
+                       $('.profile-rotator-wrapper').hide();
+                       if (textStatus === 'success') {
+                               $(".fbrowser_content").show();
+                               Browser.postLoad();
+                       }
+               });
+       },
+
+       // Initialize justified Gallery
+       initGallery: function () {
+               $('.fbrowser.photo .fbrowser-content-container').justifiedGallery({
+                       rowHeight: 80,
+                       margins: 4,
+                       border: 0,
+               });
+       },
+
+       _getUrl: function (mode, folder) {
+               let folderValue = folder !== undefined ? folder : Browser.folder;
+               let folderUrl = folderValue !== undefined ? '/' + encodeURIComponent(folderValue) : '';
+               return 'media/' + Browser.type + '/browser' + folderUrl + '?mode=' + mode + "&theme=frio";
+       }
+};
+// @license-end
diff --git a/view/theme/frio/js/module/media/filebrowser.js b/view/theme/frio/js/module/media/filebrowser.js
deleted file mode 100644 (file)
index 802c440..0000000
+++ /dev/null
@@ -1,252 +0,0 @@
-// @license magnet:?xt=urn:btih:0b31508aeb0634b347b8270c7bee4d411b5d4109&dn=agpl-3.0.txt AGPLv3-or-later
-/**
- * Filebrowser - Friendica Communications Server
- *
- * Copyright (c) 2010-2021, the Friendica project
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This code handle user interaction for photo/file upload/browser dialog.
- * Is loaded from filebrowser_plain.tpl
- *
- * To load filebrowser in colorbox, call
- *
- *      Dialog.doImageBrowser(eventname, id);
- *
- * or
- *
- *      Dialog.doFileBrowser(eventname, id);
- *
- * where:
- *
- *             eventname: event name to catch return value
- *             id: id returned to event handler
- *
- * When user select an item, an event in fired in parent page, on body element
- * The event is named
- *
- *             fbrowser.<type>.[<eventname>]
- *
- * <type> will be one of "image" or "file", and the event handler will
- * get the following params:
- *
- *             filename: filename of item chosen by user
- *             embed: bbcode to embed element into posts
- *             id: id from caller code
- *
- * example:
- *
- *             // open dialog for select an image for a textarea with id "myeditor"
- *             var id="myeditor";
- *             Dialog.doImageBrowser("example", id);
- *
- *             // setup event handler to get user selection
- *             $("body").on("fbrowser.image.example", function(event, filename, bbcode, id) {
- *                     // close colorbox
- *                     $.colorbox.close();
- *                     // replace textarea text with bbcode
- *                     $(id).value = bbcode;
- *             });
- **/
-
-/*
- * IMPORTANT
- *
- *  This is a modified version to work with
- *  the frio theme.and bootstrap modals
- *
- *  The original file is under:
- *  js/filebrowser.js
- *
- */
-
-var FileBrowser = {
-       nickname: '',
-       type: '',
-       event: '',
-       folder: '',
-       id: null,
-
-       init: function (nickname, type, hash) {
-               FileBrowser.nickname = nickname;
-               FileBrowser.type = type;
-               FileBrowser.event = 'fbrowser.' + type;
-
-               if (hash !== '') {
-                       const h = hash.replace('#', '');
-                       const destination = h.split('-')[0];
-                       FileBrowser.id = h.split('-')[1];
-                       FileBrowser.event = FileBrowser.event + '.' + destination;
-                       if (destination === 'comment') {
-                               // Get the comment textinput field
-                               var commentElm = document.getElementById('comment-edit-text-' + FileBrowser.id);
-                       }
-               }
-
-               console.log('FileBrowser: ' + nickname, type, FileBrowser.event, FileBrowser.id);
-
-               FileBrowser.postLoad();
-
-               $('.error .close').on('click', function (e) {
-                       e.preventDefault();
-                       $('.error').addClass('hidden');
-               });
-
-               // 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;
-
-                       FileBrowser.loadContent(url);
-               });
-
-               //Embed on click
-               $('.fbrowser').on('click', '.photo-album-photo-link', function (e) {
-                       e.preventDefault();
-
-                       let embed = '';
-                       if (FileBrowser.type === 'photo') {
-                               embed = '[url=' + this.dataset.link + '][img=' + this.dataset.img + ']' + this.dataset.alt + '[/img][/url]';
-                       }
-                       if (FileBrowser.type === 'attachment') {
-                               embed = '[attachment]' + this.dataset.link + '[/attachment]';
-                       }
-
-                       // Delete prefilled Text of the comment input
-                       // Note: not the best solution but function commentOpenUI don't
-                       // work as expected (we need a way to wait until commentOpenUI would be finished).
-                       // As for now we insert pieces of this function here
-                       if (commentElm !== null && typeof commentElm !== 'undefined') {
-                               if (commentElm.value === '') {
-                                       $('#comment-edit-text-' + FileBrowser.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');
-                               }
-                       }
-
-                       console.log(FileBrowser.event, this.dataset.filename, embed, FileBrowser.id);
-
-                       $('body').trigger(FileBrowser.event, [this.dataset.filename, embed, FileBrowser.id, this.dataset.img]);
-
-                       // Close model
-                       $('#modal').modal('hide');
-                       // Update autosize for this textarea
-                       autosize.update($('.text-autosize'));
-               });
-
-               // EventListener for switching between photo and file mode
-               $('.fbrowser').on('click', '.fbswitcher .btn', function (e) {
-                       e.preventDefault();
-                       FileBrowser.type = this.getAttribute('data-mode');
-                       $('.fbrowser')
-                               .removeClass()
-                               .addClass('fbrowser ' + FileBrowser.type);
-
-                       FileBrowser.loadContent(FileBrowser._getUrl("none"));
-               });
-       },
-
-       // Initialize the AjaxUpload for the upload buttons
-       uploadButtons: function () {
-               if ($('#upload-photo').length) {
-                       //AjaxUpload for photos
-                       new window.AjaxUpload(
-                               'upload-photo',
-                               {
-                                       action: 'media/photo/upload?response=json&album=' + encodeURIComponent(FileBrowser.folder),
-                                       name: 'userfile',
-                                       responseType: 'json',
-                                       onSubmit: function (file, ext) {
-                                               $('.fbrowser-content').hide();
-                                               $('.fbrowser .profile-rotator-wrapper').show();
-                                               $('.error').addClass('hidden');
-                                       },
-                                       onComplete: function (file, response) {
-                                               if (response['error'] !== undefined) {
-                                                       $('.error span').html(response['error']);
-                                                       $('.error').removeClass('hidden');
-                                                       $('.fbrowser .profile-rotator-wrapper').hide();
-                                                       $('.fbrowser-content').show();
-                                                       return;
-                                               }
-                                               // load new content to fbrowser window
-                                               FileBrowser.loadContent(FileBrowser._getUrl("none"));
-                                       },
-                               });
-               }
-
-               if ($('#upload-attachment').length) {
-                       //AjaxUpload for files
-                       new window.AjaxUpload(
-                               'upload-attachment',
-                               {
-                                       action: 'media/attachment/upload?response=json',
-                                       name: 'userfile',
-                                       responseType: 'json',
-                                       onSubmit: function (file, ext) {
-                                               $('.fbrowser-content').hide();
-                                               $('.fbrowser .profile-rotator-wrapper').show();
-                                               $('.error').addClass('hidden');
-                                       },
-                                       onComplete: function (file, response) {
-                                               if (response["error"] !== undefined) {
-                                                       $('.error span').html(response['error']);
-                                                       $('.error').removeClass('hidden');
-                                                       $('.fbrowser .profile-rotator-wrapper').hide();
-                                                       $('.fbrowser-content').show();
-                                                       return;
-                                               }
-                                               // Load new content to fbrowser window
-                                               FileBrowser.loadContent(FileBrowser._getUrl("none"));
-                                       },
-                               });
-               }
-       },
-
-       // Stuff which should be executed if no content was loaded
-       postLoad: function () {
-               FileBrowser.initGallery();
-               $('.fbrowser .fbswitcher .btn').removeClass('active');
-               $('.fbrowser .fbswitcher [data-mode=' + FileBrowser.type + ']').addClass('active');
-               // We need to add the AjaxUpload to the button
-               FileBrowser.uploadButtons();
-       },
-
-       // Load new content (e.g. change photo album)
-       loadContent: function (url) {
-               $('.fbrowser-content').hide();
-               $('.fbrowser .profile-rotator-wrapper').show();
-
-               // load new content to fbrowser window
-               $('.fbrowser').load(url, function (responseText, textStatus) {
-                       $('.profile-rotator-wrapper').hide();
-                       if (textStatus === 'success') {
-                               $(".fbrowser_content").show();
-                               FileBrowser.postLoad();
-                       }
-               });
-       },
-
-       // Initialize justified Gallery
-       initGallery: function () {
-               $('.fbrowser.photo .fbrowser-content-container').justifiedGallery({
-                       rowHeight: 80,
-                       margins: 4,
-                       border: 0,
-               });
-       },
-
-       _getUrl: function (mode, folder) {
-               let folderValue = folder !== undefined ? folder : FileBrowser.folder;
-               let folderUrl = folderValue !== undefined ? '/' + encodeURIComponent(folderValue) : '';
-               return 'media/' + FileBrowser.type + '/browser' + folderUrl + '?mode=' + mode + "&theme=frio";
-       }
-};
-// @license-end
diff --git a/view/theme/frio/templates/media/browser.tpl b/view/theme/frio/templates/media/browser.tpl
new file mode 100644 (file)
index 0000000..71974ee
--- /dev/null
@@ -0,0 +1,64 @@
+<!--
+       This is the template used by mod/fbrowser.php
+-->
+<div id="filebrowser" class="fbrowser {{$type}}" data-nickname="{{$nickname}}" data-type="{{$type}}">
+       <div class="fbrowser-content">
+               <div class="error hidden">
+                       <span></span> <button type="button" class="btn btn-link close" aria-label="Close">X</button>
+               </div>
+
+               {{* The breadcrumb navigation *}}
+               <ol class="path breadcrumb" aria-label="Breadcrumb" role="menu">
+               {{foreach $path as $folder => $name}}
+                       <li role="presentation">
+                               <button type="button" class="btn btn-link" data-folder="{{$folder}}" role="menuitem">{{$name}}</button>
+                       </li>
+               {{/foreach}}
+
+                       {{* Switch between image and file mode *}}
+                       <div class="fbswitcher btn-group btn-group-xs pull-right" aria-label="Switch between photo and attachment mode">
+                               <button type="button" class="btn btn-default" data-mode="photo" aria-label="Photo Mode"><i class="fa fa-picture-o" aria-hidden="true"></i></button>
+                               <button type="button" class="btn btn-default" data-mode="attachment" aria-label="Attachment Mode"><i class="fa fa-file-o" aria-hidden="true"></i></button>
+                       </div>
+               </ol>
+
+               <div class="media">
+
+                       {{* List of photo albums *}}
+                       {{if $folders }}
+                       <div class="folders media-left" role="navigation" aria-label="Album Navigation">
+                               <ul role="menu">
+                                       {{foreach $folders as $folder}}
+                                       <li role="presentation">
+                                               <button type="button" data-folder="{{$folder}}" role="menuitem">{{$folder}}</button>
+                                       </li>
+                                       {{/foreach}}
+                               </ul>
+                       </div>
+                       {{/if}}
+
+                       {{* The main content (images or files) *}}
+                       <div class="list {{$type}} media-body" role="main" aria-label="Browser Content">
+                               <div class="fbrowser-content-container">
+                                       {{foreach $files as $f}}
+                                       <div class="photo-album-image-wrapper">
+                                               <a href="#" class="photo-album-photo-link" data-link="{{$f.0}}" data-filename="{{$f.1}}" data-img="{{$f.2}}" data-alt="{{$f.3}}">
+                                                       <img src="{{$f.2}}" alt="{{$f.1}}">
+                                                       <p>{{$f.1}}</p>
+                                               </a>
+                                       </div>
+                                       {{/foreach}}
+                               </div>
+                       </div>
+               </div>
+
+               <div class="upload">
+                       <button id="upload-{{$type}}" type="button" class="btn btn-primary">{{$upload}}</button>
+               </div>
+       </div>
+
+       {{* This part contains the conent loader icon which is visible when new conent is loaded *}}
+       <div class="profile-rotator-wrapper" aria-hidden="true" style="display: none;">
+               <i class="fa fa-circle-o-notch fa-spin" aria-hidden="true"></i>
+       </div>
+</div>
diff --git a/view/theme/frio/templates/media/filebrowser.tpl b/view/theme/frio/templates/media/filebrowser.tpl
deleted file mode 100644 (file)
index 71974ee..0000000
+++ /dev/null
@@ -1,64 +0,0 @@
-<!--
-       This is the template used by mod/fbrowser.php
--->
-<div id="filebrowser" class="fbrowser {{$type}}" data-nickname="{{$nickname}}" data-type="{{$type}}">
-       <div class="fbrowser-content">
-               <div class="error hidden">
-                       <span></span> <button type="button" class="btn btn-link close" aria-label="Close">X</button>
-               </div>
-
-               {{* The breadcrumb navigation *}}
-               <ol class="path breadcrumb" aria-label="Breadcrumb" role="menu">
-               {{foreach $path as $folder => $name}}
-                       <li role="presentation">
-                               <button type="button" class="btn btn-link" data-folder="{{$folder}}" role="menuitem">{{$name}}</button>
-                       </li>
-               {{/foreach}}
-
-                       {{* Switch between image and file mode *}}
-                       <div class="fbswitcher btn-group btn-group-xs pull-right" aria-label="Switch between photo and attachment mode">
-                               <button type="button" class="btn btn-default" data-mode="photo" aria-label="Photo Mode"><i class="fa fa-picture-o" aria-hidden="true"></i></button>
-                               <button type="button" class="btn btn-default" data-mode="attachment" aria-label="Attachment Mode"><i class="fa fa-file-o" aria-hidden="true"></i></button>
-                       </div>
-               </ol>
-
-               <div class="media">
-
-                       {{* List of photo albums *}}
-                       {{if $folders }}
-                       <div class="folders media-left" role="navigation" aria-label="Album Navigation">
-                               <ul role="menu">
-                                       {{foreach $folders as $folder}}
-                                       <li role="presentation">
-                                               <button type="button" data-folder="{{$folder}}" role="menuitem">{{$folder}}</button>
-                                       </li>
-                                       {{/foreach}}
-                               </ul>
-                       </div>
-                       {{/if}}
-
-                       {{* The main content (images or files) *}}
-                       <div class="list {{$type}} media-body" role="main" aria-label="Browser Content">
-                               <div class="fbrowser-content-container">
-                                       {{foreach $files as $f}}
-                                       <div class="photo-album-image-wrapper">
-                                               <a href="#" class="photo-album-photo-link" data-link="{{$f.0}}" data-filename="{{$f.1}}" data-img="{{$f.2}}" data-alt="{{$f.3}}">
-                                                       <img src="{{$f.2}}" alt="{{$f.1}}">
-                                                       <p>{{$f.1}}</p>
-                                               </a>
-                                       </div>
-                                       {{/foreach}}
-                               </div>
-                       </div>
-               </div>
-
-               <div class="upload">
-                       <button id="upload-{{$type}}" type="button" class="btn btn-primary">{{$upload}}</button>
-               </div>
-       </div>
-
-       {{* This part contains the conent loader icon which is visible when new conent is loaded *}}
-       <div class="profile-rotator-wrapper" aria-hidden="true" style="display: none;">
-               <i class="fa fa-circle-o-notch fa-spin" aria-hidden="true"></i>
-       </div>
-</div>