From c64b13537b395d917c69aef99d7632c165d8cf90 Mon Sep 17 00:00:00 2001 From: j Date: Sun, 19 Jan 2020 12:48:03 +0100 Subject: [PATCH] fix html documents preview in dialog --- static/js/documentDialog.js | 5 ++--- static/js/textPanel.js | 21 +++++++++++++++++---- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/static/js/documentDialog.js b/static/js/documentDialog.js index 752bca35..89bc072b 100644 --- a/static/js/documentDialog.js +++ b/static/js/documentDialog.js @@ -201,8 +201,7 @@ pandora.ui.documentDialog = function(options) { zoom: 'fit' }) : item.extension == 'html' - ? pandora.ui.textPanel(item).css({ - }) + ? pandora.$ui.textPanel = pandora.ui.textPanel(item) : Ox.ImageViewer({ area: pandora.user.ui.documents[item.id] ? pandora.user.ui.documents[item.id].position @@ -243,7 +242,7 @@ pandora.ui.documentDialog = function(options) { } function setTitle() { - that.options({title: item.title + '.' + item.extension}); + that.options({title: item.title + (item.extension == 'html' ? '' : '.' + item.extension)}); } that.getItems = function() { diff --git a/static/js/textPanel.js b/static/js/textPanel.js index a7aa4129..c62a435e 100644 --- a/static/js/textPanel.js +++ b/static/js/textPanel.js @@ -1,16 +1,30 @@ 'use strict'; pandora.ui.textPanel = function(text, $toolbar) { + if (Ox.isUndefined(text.text)) { + var that = Ox.Element().append(Ox.LoadingScreen().start()) + pandora.api.getDocument({ + id: text.id, + keys: ['text'] + }, function(result) { + text.text = result.data.text + if (text.text) { + pandora.$ui.textPanel.replaceWith(pandora.$ui.textPanel = pandora.ui.textPanel(text, $toolbar)) + } + }) + return that; + } + var textElement, textEmbed, embedURLs = getEmbedURLs(text.text), that = Ox.SplitPanel({ elements: [ { - element: textElement = pandora.$ui.textElement = pandora.ui.textHTML(text) + element: textElement = pandora.ui.textHTML(text) }, { - element: textEmbed = pandora.ui.textEmbed(textElement), + element: textEmbed = pandora.ui.textEmbed(), collapsed: !embedURLs.length, size: pandora.user.ui.embedSize, resizable: true, @@ -124,7 +138,6 @@ pandora.ui.textPanel = function(text, $toolbar) { 0), position = 100 * scrollTop / Math.max(1, textElement[0].scrollHeight); textElement.scrollTo(position); - window.text = textElement; } that.selectEmbed = function(index, scroll) { @@ -431,7 +444,7 @@ pandora.ui.textHTML = function(text) { }; -pandora.ui.textEmbed = function(textElement) { +pandora.ui.textEmbed = function(textEmbed) { var that = Ox.Element() .bindEvent({