From 4285cd5dc78f26cbcaab470215240f3300de2e66 Mon Sep 17 00:00:00 2001 From: rabuzarus Date: Sat, 21 Apr 2018 14:05:40 +0200 Subject: [PATCH] frio - fix image upload for prv messages --- view/theme/frio/js/filebrowser.js | 1 - view/theme/frio/js/modal.js | 1 + view/theme/frio/js/theme.js | 12 ++++++++++-- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/view/theme/frio/js/filebrowser.js b/view/theme/frio/js/filebrowser.js index 92f1412911..270172072d 100644 --- a/view/theme/frio/js/filebrowser.js +++ b/view/theme/frio/js/filebrowser.js @@ -231,7 +231,6 @@ var FileBrowser = { $(".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) diff --git a/view/theme/frio/js/modal.js b/view/theme/frio/js/modal.js index 2b60049f1d..56df75d7b6 100644 --- a/view/theme/frio/js/modal.js +++ b/view/theme/frio/js/modal.js @@ -152,6 +152,7 @@ Dialog._load = function(url) { var jsbrowser = function() { FileBrowser.init(nickname, type, hash); }; + loadScript("view/js/ajaxupload.js"); loadScript("view/theme/frio/js/filebrowser.js", jsbrowser); }; diff --git a/view/theme/frio/js/theme.js b/view/theme/frio/js/theme.js index a8787a6eb5..859df01613 100644 --- a/view/theme/frio/js/theme.js +++ b/view/theme/frio/js/theme.js @@ -446,8 +446,16 @@ function justifyPhotosAjax() { $('#photo-album-contents').justifiedGallery('norewind').on('jg.complete', function(e){ justifiedGalleryActive = false; }); } +// Load a js script to the html head. function loadScript(url, callback) { - // Adding the script tag to the head as suggested before + // Check if the script is already in the html head. + var oscript = $('head script[src="' + url + '"]'); + + // Delete the old script from head. + if (oscript.length > 0) { + oscript.remove(); + } + // Adding the script tag to the head as suggested before. var head = document.getElementsByTagName('head')[0]; var script = document.createElement('script'); script.type = 'text/javascript'; @@ -458,7 +466,7 @@ function loadScript(url, callback) { script.onreadystatechange = callback; script.onload = callback; - // Fire the loading + // Fire the loading. head.appendChild(script); }