Move overlay into widget. Fix some quirks

This commit is contained in:
Victor Dubiniuk 2014-04-30 13:20:36 +03:00
parent 444903e472
commit 04b2ebc780
2 changed files with 47 additions and 32 deletions

View File

@ -121,7 +121,11 @@
} }
#odf-toolbar #dropdown{ #odf-toolbar #dropdown{
right:auto; right: auto;
}
#body-user #document-title #header{
height: 32px;
} }
#document-title{ #document-title{
@ -138,6 +142,7 @@
float:left; float:left;
height: 24px; height: 24px;
width: 80px; width: 80px;
margin: 3px;
background-size:80px 24px; background-size:80px 24px;
} }
@ -169,7 +174,7 @@
#documents-overlay, #documents-overlay-below{ #documents-overlay, #documents-overlay-below{
position: fixed; position: fixed;
top: 36px; top: 32px;
left: 0; left: 0;
width: 100%; width: 100%;
height: 100%; height: 100%;
@ -227,9 +232,7 @@
top: 87px; top: 87px;
} }
/* override WebODF styling here */ /* override WebODF styling here */
#mainContainer #collaboration{ #mainContainer #collaboration{
float:right;position: relative;z-index: 1; float:right;position: relative;z-index: 1;
width: 70px;padding:5px; width: 70px;padding:5px;

View File

@ -127,6 +127,21 @@ $.widget('oc.documentGrid', {
} }
}); });
$.widget('oc.documentOverlay', {
options : {
parent : 'document.body'
},
_create : function (){
$(this.element).hide().appendTo(document.body);
},
show : function(){
$(this.element).fadeIn('fast');
},
hide : function(){
$(this.element).fadeOut('fast');
}
});
var documentsMain = { var documentsMain = {
isEditormode : false, isEditormode : false,
@ -138,15 +153,12 @@ var documentsMain = {
fileName: null, fileName: null,
UI : { UI : {
/* Overlay HTML */
overlay : '<div id="documents-overlay" class="icon-loading"></div> <div id="documents-overlay-below" class="icon-loading-dark"></div>',
/* Toolbar HTML */ /* Toolbar HTML */
toolbar : '<div id="odf-toolbar" class="dijitToolbar">' + toolbar : '<div id="odf-toolbar" class="dijitToolbar">' +
' <div id="document-title" class="icon-noise">' + ' <div id="document-title" class="icon-noise">' +
'<div class="logo-wide"></div>' + '<div id="header"><div class="logo-wide"></div>' +
'<div id="document-title-container">&nbsp;</div>' + '<div id="document-title-container">&nbsp;</div>' +
'</div>' + '</div></div>' +
' <span id="toolbar" class="claro">' + ' <span id="toolbar" class="claro">' +
' <button id="odf-invite" class="drop hidden">' + ' <button id="odf-invite" class="drop hidden">' +
t('documents', 'Share') + t('documents', 'Share') +
@ -181,21 +193,13 @@ var documentsMain = {
mainTitle : '', mainTitle : '',
init : function(){ init : function(){
$(documentsMain.UI.overlay).hide().appendTo(document.body);
documentsMain.UI.mainTitle = $('title').text(); documentsMain.UI.mainTitle = $('title').text();
}, },
showOverlay : function(){
$('#documents-overlay,#documents-overlay-below').fadeIn('fast');
},
hideOverlay : function(){
$('#documents-overlay,#documents-overlay-below').fadeOut('fast');
},
showEditor : function(title, canShare){ showEditor : function(title, canShare){
if (documentsMain.isGuest){ if (documentsMain.isGuest){
// !Login page mess wih WebODF toolbars // !Login page mess wih WebODF toolbars
$(document.body).attr('id', 'body-user');
} }
$('#document-title-container').text(title); $('#document-title-container').text(title);
@ -212,6 +216,11 @@ var documentsMain = {
}, },
hideEditor : function(){ hideEditor : function(){
if (documentsMain.isGuest){
// !Login page mess wih WebODF toolbars
$(document.body).attr('id', 'body-login');
$('header,footer,nav').show();
}
// Fade out toolbar // Fade out toolbar
$('#odf-toolbar').fadeOut('fast'); $('#odf-toolbar').fadeOut('fast');
// Fade out editor // Fade out editor
@ -288,7 +297,7 @@ var documentsMain = {
documentsMain.show(); documentsMain.show();
if (fileId){ if (fileId){
documentsMain.UI.showOverlay(); documentsMain.overlay.documentOverlay('show');
} }
var webodfSource = (oc_debug === true) ? 'webodf-debug' : 'webodf'; var webodfSource = (oc_debug === true) ? 'webodf-debug' : 'webodf';
@ -311,7 +320,7 @@ var documentsMain = {
prepareSession : function(){ prepareSession : function(){
documentsMain.isEditorMode = true; documentsMain.isEditorMode = true;
documentsMain.UI.showOverlay(); documentsMain.overlay.documentOverlay('show');
$(window).on('beforeunload', function(){ $(window).on('beforeunload', function(){
return t('documents', "Leaving this page in Editor mode might cause unsaved data. It is recommended to use 'Close' button instead."); return t('documents', "Leaving this page in Editor mode might cause unsaved data. It is recommended to use 'Close' button instead.");
}); });
@ -320,7 +329,7 @@ var documentsMain = {
prepareGrid : function(){ prepareGrid : function(){
documentsMain.isEditorMode = false; documentsMain.isEditorMode = false;
documentsMain.UI.hideOverlay(); documentsMain.overlay.documentOverlay('hide');
}, },
initSession: function(response) { initSession: function(response) {
@ -382,7 +391,7 @@ var documentsMain = {
// load the document and get called back when it's live // load the document and get called back when it's live
documentsMain.webodfEditorInstance.openSession(documentsMain.esId, documentsMain.memberId, function() { documentsMain.webodfEditorInstance.openSession(documentsMain.esId, documentsMain.memberId, function() {
documentsMain.webodfEditorInstance.startEditing(); documentsMain.webodfEditorInstance.startEditing();
documentsMain.UI.hideOverlay(); documentsMain.overlay.documentOverlay('hide');
parent.location.hash = response.file_id; parent.location.hash = response.file_id;
}); });
}); });
@ -758,7 +767,10 @@ FileList.getCurrentDirectory = function(){
$(document).ready(function() { $(document).ready(function() {
"use strict"; "use strict";
documentsMain.docs = $('.documentslist').documentGrid(); documentsMain.docs = $('.documentslist').documentGrid();
documentsMain.overlay = $('<div id="documents-overlay" class="icon-loading"></div><div id="documents-overlay-below" class="icon-loading-dark"></div>').documentOverlay();
$('.documentslist').on('click', 'li:not(.add-document)', function(event) { $('.documentslist').on('click', 'li:not(.add-document)', function(event) {
event.preventDefault(); event.preventDefault();