Ensure theme consistency when using filebrowser

- Send frio filebrowser result to current frame instead of parent one
This commit is contained in:
Hypolite Petovan 2019-04-25 22:06:27 -04:00
parent 611220cb53
commit a88df9b259
3 changed files with 14 additions and 13 deletions

View file

@ -11,6 +11,7 @@ use Friendica\Core\Renderer;
use Friendica\Core\System; use Friendica\Core\System;
use Friendica\Database\DBA; use Friendica\Database\DBA;
use Friendica\Object\Image; use Friendica\Object\Image;
use Friendica\Util\Strings;
/** /**
* @param App $a * @param App $a
@ -27,6 +28,12 @@ function fbrowser_content(App $a)
exit(); 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"; $template_file = "filebrowser.tpl";
$o = ''; $o = '';

View file

@ -99,7 +99,7 @@ var FileBrowser = {
// Click on album link // Click on album link
$(".fbrowser").on("click", ".folders a, .path a", function(e) { $(".fbrowser").on("click", ".folders a, .path a", function(e) {
e.preventDefault(); e.preventDefault();
var url = baseurl + "/fbrowser/" + FileBrowser.type + "/" + this.dataset.folder + "?mode=none"; var url = baseurl + "/fbrowser/" + FileBrowser.type + "/" + this.dataset.folder + "?mode=none&theme=frio";
FileBrowser.folder = this.dataset.folder; FileBrowser.folder = this.dataset.folder;
FileBrowser.loadContent(url); FileBrowser.loadContent(url);
@ -134,7 +134,7 @@ var FileBrowser = {
console.log(FileBrowser.event, this.dataset.filename, embed, FileBrowser.id); console.log(FileBrowser.event, this.dataset.filename, embed, FileBrowser.id);
parent.$("body").trigger(FileBrowser.event, [ $("body").trigger(FileBrowser.event, [
this.dataset.filename, this.dataset.filename,
embed, embed,
FileBrowser.id, FileBrowser.id,
@ -152,7 +152,7 @@ var FileBrowser = {
e.preventDefault(); e.preventDefault();
FileBrowser.type = this.getAttribute("data-mode"); FileBrowser.type = this.getAttribute("data-mode");
$(".fbrowser").removeClass().addClass("fbrowser " + FileBrowser.type); $(".fbrowser").removeClass().addClass("fbrowser " + FileBrowser.type);
url = baseurl + "/fbrowser/" + FileBrowser.type + "?mode=none"; url = baseurl + "/fbrowser/" + FileBrowser.type + "?mode=none&theme=frio";
FileBrowser.loadContent(url); FileBrowser.loadContent(url);
}); });
@ -183,10 +183,7 @@ var FileBrowser = {
return; return;
} }
// location = baseurl + "/fbrowser/image/?mode=none"+location['hash']; var url = baseurl + "/fbrowser/" + FileBrowser.type + "/" + FileBrowser.folder + "?mode=none&theme=frio";
// location.reload(true);
var url = baseurl + "/fbrowser/" + FileBrowser.type + "/" + FileBrowser.folder + "?mode=none";
// load new content to fbrowser window // load new content to fbrowser window
FileBrowser.loadContent(url); FileBrowser.loadContent(url);
} }
@ -214,10 +211,7 @@ var FileBrowser = {
return; return;
} }
// location = baseurl + "/fbrowser/file/?mode=none"+location['hash']; var url = baseurl + "/fbrowser/" + FileBrowser.type + "?mode=none&theme=frio";
// location.reload(true);
var url = baseurl + "/fbrowser/" + FileBrowser.type + "?mode=none";
// Load new content to fbrowser window // Load new content to fbrowser window
FileBrowser.loadContent(url); FileBrowser.loadContent(url);
} }

View file

@ -120,7 +120,7 @@ Dialog.show = function(url, title) {
Dialog._get_url = function(type, name, id) { Dialog._get_url = function(type, name, id) {
var hash = name; var hash = name;
if (id !== undefined) hash = hash + "-" + id; 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. // Does load the filebrowser into the jot modal.
@ -148,7 +148,7 @@ Dialog._load = function(url) {
var type = $("#fb-type").attr("value"); var type = $("#fb-type").attr("value");
// Try to fetch the hash form the url. // 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 if (match===null) return; //not fbrowser
var hash = match[1]; var hash = match[1];