From d167089c16e87479beba9f7fca9e0df14b4ab0cd Mon Sep 17 00:00:00 2001 From: Victor Dubiniuk Date: Wed, 30 Apr 2014 14:02:00 +0300 Subject: [PATCH] Move toolbar to widget. Show it early. Ref #224 --- js/documents.js | 69 +++++++++++++++++++++++++++++-------------------- 1 file changed, 41 insertions(+), 28 deletions(-) diff --git a/js/documents.js b/js/documents.js index 9a240763..a583c3b9 100644 --- a/js/documents.js +++ b/js/documents.js @@ -142,6 +142,38 @@ $.widget('oc.documentOverlay', { } }); +$.widget('oc.documentToolbar', { + options : { + innerhtml : '
' + + ' ' + + '
' + + + '' + + ' ' + + ' ' + + ' ' + + '' + }, + _create : function (){ + $(this.element).html(this.options.innerhtml).hide().prependTo(document.body); + }, + show : function (){ + $(this.element).show(); + }, + hide : function(){ + $(this.element).fadeOut('fast'); + $(this.element).html(this.options.innerhtml); + } +}); var documentsMain = { isEditormode : false, @@ -152,26 +184,7 @@ var documentsMain = { ready :false, fileName: null, - UI : { - /* Toolbar HTML */ - toolbar : '
' + - '
' + - '
' + - ' ' + - ' ' + - ' ' + - ' ' + - '' + - '
', - + UI : { /* Editor wrapper HTML */ container : '
' + '
' + @@ -221,12 +234,12 @@ var documentsMain = { $(document.body).attr('id', 'body-login'); $('header,footer,nav').show(); } - // Fade out toolbar - $('#odf-toolbar').fadeOut('fast'); + + documentsMain.toolbar.documentToolbar('hide'); + // Fade out editor $('#mainContainer').fadeOut('fast', function() { $('#mainContainer').remove(); - $('#odf-toolbar').remove(); $('#content').fadeIn('fast'); $(document.body).removeClass('claro'); $('title').text(documentsMain.UI.mainTitle); @@ -284,6 +297,7 @@ var documentsMain = { documentsMain.isGuest = true; if ($("[name='document']").val()){ + documentsMain.toolbar.documentToolbar('show'); documentsMain.prepareSession(); documentsMain.joinSession( $("[name='document']").val() @@ -339,11 +353,9 @@ var documentsMain = { return documentsMain.view(response.id); } - if (!$('#odf-toolbar').length){ - $('header,footer,nav').hide(); - $(document.body).prepend(documentsMain.UI.toolbar); - } - + $('header,footer,nav').hide(); + documentsMain.toolbar.documentToolbar('show'); + if (!response || !response.status || response.status==='error'){ documentsMain.onEditorShutdown(t('documents', 'Failed to load this document. Please check if it can be opened with an external odt editor. This might also mean it has been unshared or deleted recently.')); return; @@ -770,6 +782,7 @@ $(document).ready(function() { documentsMain.docs = $('.documentslist').documentGrid(); documentsMain.overlay = $('
').documentOverlay(); + documentsMain.toolbar = $('
').documentToolbar(); $('.documentslist').on('click', 'li:not(.add-document)', function(event) { event.preventDefault();