]> git.mxchange.org Git - friendica.git/commitdiff
Ensure theme consistency when using filebrowser
authorHypolite Petovan <hypolite@mrpetovan.com>
Fri, 26 Apr 2019 02:06:27 +0000 (22:06 -0400)
committerHypolite Petovan <hypolite@mrpetovan.com>
Thu, 2 May 2019 13:52:48 +0000 (09:52 -0400)
- Send frio filebrowser result to current frame instead of parent one

mod/fbrowser.php
view/theme/frio/js/filebrowser.js
view/theme/frio/js/modal.js

index 559896acb13932ea6c690b4dd93d6dca0a385ef2..faff17381ba565b9894b971a42bf9545e01adf6e 100644 (file)
@@ -11,6 +11,7 @@ use Friendica\Core\Renderer;
 use Friendica\Core\System;
 use Friendica\Database\DBA;
 use Friendica\Object\Image;
+use Friendica\Util\Strings;
 
 /**
  * @param App $a
@@ -27,6 +28,12 @@ function fbrowser_content(App $a)
                exit();
        }
 
+       // Needed to match the correct template in a module that uses a different theme than the user/site/default
+       $theme = Strings::sanitizeFilePathItem(defaults($_GET, 'theme', null));
+       if ($theme && is_file("view/theme/$theme/config.php")) {
+               $a->setCurrentTheme($theme);
+       }
+
        $template_file = "filebrowser.tpl";
 
        $o = '';
index 40c0fbb7443bb9daecd3c7f4cd47f1da166548a9..16d60b61d1014585c781a99a47f16a61b624f978 100644 (file)
@@ -99,7 +99,7 @@ var FileBrowser = {
                // Click on album link\r
                $(".fbrowser").on("click", ".folders a, .path a", function(e) {\r
                        e.preventDefault();\r
-                       var url = baseurl + "/fbrowser/" + FileBrowser.type + "/" + this.dataset.folder + "?mode=none";\r
+                       var url = baseurl + "/fbrowser/" + FileBrowser.type + "/" + this.dataset.folder + "?mode=none&theme=frio";\r
                        FileBrowser.folder = this.dataset.folder;\r
 \r
                        FileBrowser.loadContent(url);\r
@@ -134,7 +134,7 @@ var FileBrowser = {
 \r
                        console.log(FileBrowser.event, this.dataset.filename, embed, FileBrowser.id);\r
 \r
-                       parent.$("body").trigger(FileBrowser.event, [\r
+                       $("body").trigger(FileBrowser.event, [\r
                                this.dataset.filename,\r
                                embed,\r
                                FileBrowser.id,\r
@@ -152,7 +152,7 @@ var FileBrowser = {
                        e.preventDefault();\r
                        FileBrowser.type = this.getAttribute("data-mode");\r
                        $(".fbrowser").removeClass().addClass("fbrowser " + FileBrowser.type);\r
-                       url = baseurl + "/fbrowser/" + FileBrowser.type + "?mode=none";\r
+                       url = baseurl + "/fbrowser/" + FileBrowser.type + "?mode=none&theme=frio";\r
 \r
                        FileBrowser.loadContent(url);\r
                });\r
@@ -183,10 +183,7 @@ var FileBrowser = {
                                                        return;\r
                                                }\r
 \r
-//                                             location = baseurl + "/fbrowser/image/?mode=none"+location['hash'];\r
-//                                             location.reload(true);\r
-\r
-                                               var url = baseurl + "/fbrowser/" + FileBrowser.type + "/" + FileBrowser.folder + "?mode=none";\r
+                                               var url = baseurl + "/fbrowser/" + FileBrowser.type + "/" + FileBrowser.folder + "?mode=none&theme=frio";\r
                                                // load new content to fbrowser window\r
                                                FileBrowser.loadContent(url);\r
                                        }\r
@@ -214,10 +211,7 @@ var FileBrowser = {
                                                        return;\r
                                                }\r
 \r
-//                                             location = baseurl + "/fbrowser/file/?mode=none"+location['hash'];\r
-//                                             location.reload(true);\r
-\r
-                                               var url = baseurl + "/fbrowser/" + FileBrowser.type + "?mode=none";\r
+                                               var url = baseurl + "/fbrowser/" + FileBrowser.type + "?mode=none&theme=frio";\r
                                                // Load new content to fbrowser window\r
                                                FileBrowser.loadContent(url);\r
                                        }\r
index 1c5314c4b410b6052a86830b44e867ffe01dddaf..ab263bc2ab76cb19082e7990b0d710fb56096fa4 100644 (file)
@@ -120,7 +120,7 @@ Dialog.show = function(url, title) {
 Dialog._get_url = function(type, name, id) {
        var hash = name;
        if (id !== undefined) hash = hash + "-" + id;
-       return "fbrowser/"+type+"/?mode=none#"+hash;
+       return "fbrowser/"+type+"/?mode=none&theme=frio#"+hash;
 };
 
 // Does load the filebrowser into the jot modal.
@@ -148,7 +148,7 @@ Dialog._load = function(url) {
        var type = $("#fb-type").attr("value");
 
        // Try to fetch the hash form the url.
-       var match = url.match(/fbrowser\/[a-z]+\/\?mode=none(.*)/);
+       var match = url.match(/fbrowser\/[a-z]+\/.*(#.*)/);
        if (match===null) return; //not fbrowser
        var hash = match[1];