remove spaces at the end of lines

This commit is contained in:
Mihai Varga 2015-10-29 19:05:36 +02:00
parent aac766d9f6
commit 7593ec613f

View File

@ -7,11 +7,11 @@ $.widget('oc.documentGrid', {
sessions : {}, sessions : {},
members : {} members : {}
}, },
_create : function (){ _create : function (){
}, },
render : function(){ render : function(){
var that = this; var that = this;
jQuery.when(this._load()) jQuery.when(this._load())
@ -19,7 +19,7 @@ $.widget('oc.documentGrid', {
that._render(); that._render();
}); });
}, },
add : function(document) { add : function(document) {
var docElem = $(this.options.context + ' .template').clone(), var docElem = $(this.options.context + ' .template').clone(),
a = docElem.find('a') a = docElem.find('a')
@ -32,9 +32,9 @@ $.widget('oc.documentGrid', {
.attr('original-title', document.path) .attr('original-title', document.path)
.find('label').text(document.name) .find('label').text(document.name)
; ;
docElem.appendTo(this.options.context).show(); docElem.appendTo(this.options.context).show();
//Preview //Preview
var previewURL, var previewURL,
urlSpec = { urlSpec = {
@ -48,7 +48,7 @@ $.widget('oc.documentGrid', {
if ( $('#isPublic').length ) { if ( $('#isPublic').length ) {
urlSpec.t = $('#dirToken').val(); urlSpec.t = $('#dirToken').val();
} }
if (!urlSpec.x) { if (!urlSpec.x) {
urlSpec.x = $('#filestable').data('preview-x'); urlSpec.x = $('#filestable').data('preview-x');
} }
@ -60,21 +60,21 @@ $.widget('oc.documentGrid', {
previewURL = OC.generateUrl('/core/preview.png?') + $.param(urlSpec); previewURL = OC.generateUrl('/core/preview.png?') + $.param(urlSpec);
previewURL = previewURL.replace('(', '%28').replace(')', '%29'); previewURL = previewURL.replace('(', '%28').replace(')', '%29');
if ( $('#previews_enabled').length && document.hasPreview) { if ( $('#previews_enabled').length && document.hasPreview) {
var img = new Image(); var img = new Image();
img.onload = function(){ img.onload = function(){
var ready = function (node){ var ready = function (node){
return function(path){ return function(path){
node.css('background-image', 'url("'+ path +'")'); node.css('background-image', 'url("'+ path +'")');
}; };
}(a); }(a);
ready(previewURL); ready(previewURL);
}; };
img.src = previewURL; img.src = previewURL;
} }
}, },
_load : function (){ _load : function (){
var that = this; var that = this;
var def = new $.Deferred(); var def = new $.Deferred();
@ -90,7 +90,7 @@ $.widget('oc.documentGrid', {
}); });
return def; return def;
}, },
_render : function (data){ _render : function (data){
var that = this, var that = this,
documents = data && data.documents || this.options.documents, documents = data && data.documents || this.options.documents,
@ -98,14 +98,14 @@ $.widget('oc.documentGrid', {
members = data && data.members || this.options.members, members = data && data.members || this.options.members,
hasDocuments = false hasDocuments = false
; ;
$(this.options.context + ' .document:not(.template,.progress)').remove(); $(this.options.context + ' .document:not(.template,.progress)').remove();
$.each(documents, function(i, document){ $.each(documents, function(i, document){
hasDocuments = true; hasDocuments = true;
that.add(document); that.add(document);
}); });
$.each(sessions, function(i, session){ $.each(sessions, function(i, session){
if (members[session.es_id].length > 0) { if (members[session.es_id].length > 0) {
var docElem = $(that.options.context + ' .document[data-id="'+session.file_id+'"]'); var docElem = $(that.options.context + ' .document[data-id="'+session.file_id+'"]');
@ -118,7 +118,7 @@ $.widget('oc.documentGrid', {
} }
} }
}); });
if (!hasDocuments){ if (!hasDocuments){
$(this.options.context).before('<div id="emptycontent">' $(this.options.context).before('<div id="emptycontent">'
+ t('documents', 'No documents were found. Upload or create a document to get started!') + t('documents', 'No documents were found. Upload or create a document to get started!')
@ -157,19 +157,19 @@ var documentsMain = {
url: null, url: null,
canShare : false, canShare : false,
toolbar : '<div id="ocToolbar"><div id="ocToolbarInside"></div><span id="toolbar" class="claro"></span></div>', toolbar : '<div id="ocToolbar"><div id="ocToolbarInside"></div><span id="toolbar" class="claro"></span></div>',
UI : { UI : {
/* Editor wrapper HTML */ /* Editor wrapper HTML */
container : '<div id="mainContainer" class="claro">' + container : '<div id="mainContainer" class="claro">' +
'</div>', '</div>',
/* Previous window title */ /* Previous window title */
mainTitle : '', mainTitle : '',
init : function(){ init : function(){
documentsMain.UI.mainTitle = $('title').text(); documentsMain.UI.mainTitle = $('title').text();
}, },
showEditor : function(title){ showEditor : function(title){
var self = this; var self = this;
if (documentsMain.isGuest){ if (documentsMain.isGuest){
@ -198,14 +198,14 @@ var documentsMain = {
}); });
}); });
}, },
hideEditor : function(){ hideEditor : function(){
if (documentsMain.isGuest){ if (documentsMain.isGuest){
// !Login page mess wih WebODF toolbars // !Login page mess wih WebODF toolbars
$(document.body).attr('id', 'body-login'); $(document.body).attr('id', 'body-login');
$('footer,nav').show(); $('footer,nav').show();
} }
// Fade out editor // Fade out editor
$('#mainContainer').fadeOut('fast', function() { $('#mainContainer').fadeOut('fast', function() {
$('#mainContainer').remove(); $('#mainContainer').remove();
@ -214,17 +214,17 @@ var documentsMain = {
$('title').text(documentsMain.UI.mainTitle); $('title').text(documentsMain.UI.mainTitle);
}); });
}, },
showSave : function (){ showSave : function (){
$('#odf-close').hide(); $('#odf-close').hide();
$('#saving-document').show(); $('#saving-document').show();
}, },
hideSave : function(){ hideSave : function(){
$('#saving-document').hide(); $('#saving-document').hide();
$('#odf-close').show(); $('#odf-close').show();
}, },
showProgress : function(message){ showProgress : function(message){
if (!message){ if (!message){
message = '&nbsp;'; message = '&nbsp;';
@ -232,38 +232,38 @@ var documentsMain = {
$('.documentslist .progress div').text(message); $('.documentslist .progress div').text(message);
$('.documentslist .progress').show(); $('.documentslist .progress').show();
}, },
hideProgress : function(){ hideProgress : function(){
$('.documentslist .progress').hide(); $('.documentslist .progress').hide();
}, },
showLostConnection : function(){ showLostConnection : function(){
$('#memberList .memberListButton').css({opacity : 0.3}); $('#memberList .memberListButton').css({opacity : 0.3});
$('#ocToolbar').children(':not(#document-title)').hide(); $('#ocToolbar').children(':not(#document-title)').hide();
$('<div id="connection-lost"></div>').prependTo('#memberList'); $('<div id="connection-lost"></div>').prependTo('#memberList');
$('<div id="warning-connection-lost">' + t('documents', 'No connection to server. Trying to reconnect.') +'<img src="'+ OC.imagePath('core', 'loading-dark.gif') +'" alt="" /></div>').prependTo('#ocToolbar'); $('<div id="warning-connection-lost">' + t('documents', 'No connection to server. Trying to reconnect.') +'<img src="'+ OC.imagePath('core', 'loading-dark.gif') +'" alt="" /></div>').prependTo('#ocToolbar');
}, },
hideLostConnection : function() { hideLostConnection : function() {
$('#connection-lost,#warning-connection-lost').remove(); $('#connection-lost,#warning-connection-lost').remove();
$('#ocToolbar').children(':not(#document-title,#saving-document)').show(); $('#ocToolbar').children(':not(#document-title,#saving-document)').show();
$('#memberList .memberListButton').css({opacity : 1}); $('#memberList .memberListButton').css({opacity : 1});
}, },
notify : function(message){ notify : function(message){
OC.Notification.show(message); OC.Notification.show(message);
setTimeout(OC.Notification.hide, 10000); setTimeout(OC.Notification.hide, 10000);
} }
}, },
onStartup: function() { onStartup: function() {
var fileId; var fileId;
documentsMain.useUnstable = $('#webodf-unstable').val()==='true'; documentsMain.useUnstable = $('#webodf-unstable').val()==='true';
documentsMain.UI.init(); documentsMain.UI.init();
if (!OC.currentUser){ if (!OC.currentUser){
documentsMain.isGuest = true; documentsMain.isGuest = true;
if ($("[name='document']").val()){ if ($("[name='document']").val()){
$(documentsMain.toolbar).appendTo('#header'); $(documentsMain.toolbar).appendTo('#header');
documentsMain.prepareSession(); documentsMain.prepareSession();
@ -276,12 +276,12 @@ var documentsMain = {
// Does anything indicate that we need to autostart a session? // Does anything indicate that we need to autostart a session?
fileId = parent.location.hash.replace(/\W*/g, ''); fileId = parent.location.hash.replace(/\W*/g, '');
} }
documentsMain.show(); documentsMain.show();
if (fileId){ if (fileId){
documentsMain.overlay.documentOverlay('show'); documentsMain.overlay.documentOverlay('show');
} }
OC.addScript('documents', '3rdparty/webodf/webodf-debug').done(function() { OC.addScript('documents', '3rdparty/webodf/webodf-debug').done(function() {
// preload stuff in the background // preload stuff in the background
require({}, ["dojo/ready"], function(ready) { require({}, ["dojo/ready"], function(ready) {
@ -298,45 +298,45 @@ var documentsMain = {
}); });
}); });
}, },
prepareSession : function(){ prepareSession : function(){
documentsMain.isEditorMode = true; documentsMain.isEditorMode = true;
documentsMain.overlay.documentOverlay('show'); 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.");
}); });
$(window).on("unload", documentsMain.onTerminate); $(window).on("unload", documentsMain.onTerminate);
}, },
prepareGrid : function(){ prepareGrid : function(){
documentsMain.isEditorMode = false; documentsMain.isEditorMode = false;
documentsMain.overlay.documentOverlay('hide'); documentsMain.overlay.documentOverlay('hide');
}, },
initSession: function(response) { initSession: function(response) {
if(response && (response.id && !response.es_id)){ if(response && (response.id && !response.es_id)){
return documentsMain.view(response.id); return documentsMain.view(response.id);
} }
$('footer,nav').hide(); $('footer,nav').hide();
$(documentsMain.toolbar).appendTo('#header'); $(documentsMain.toolbar).appendTo('#header');
if (!response || !response.status || response.status==='error'){ 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.')); 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; return;
} }
//Wait for 3 sec if editor is still loading //Wait for 3 sec if editor is still loading
if (!documentsMain.ready){ if (!documentsMain.ready){
setTimeout(function(){ documentsMain.initSession(response); }, 3000); setTimeout(function(){ documentsMain.initSession(response); }, 3000);
console.log('Waiting for the editor to start...'); console.log('Waiting for the editor to start...');
return; return;
} }
var pollUrl = documentsMain.isGuest var pollUrl = documentsMain.isGuest
? OC.generateUrl('apps/documents/session/guest/poll/{token}', {'token' : $("[name='document']").val()}) ? OC.generateUrl('apps/documents/session/guest/poll/{token}', {'token' : $("[name='document']").val()})
: OC.generateUrl('apps/documents/session/user/poll'), : OC.generateUrl('apps/documents/session/user/poll'),
saveUrl = documentsMain.isGuest saveUrl = documentsMain.isGuest
? OC.generateUrl('apps/documents/session/guest/save/{token}', {'token' : $("[name='document']").val()}) ? OC.generateUrl('apps/documents/session/guest/save/{token}', {'token' : $("[name='document']").val()})
: OC.generateUrl('apps/documents/session/user/save') : OC.generateUrl('apps/documents/session/user/save')
; ;
@ -345,10 +345,10 @@ var documentsMain = {
/*require({ }, ["owncloud/ServerFactory", "webodf/editor/Editor"], function (ServerFactory, Editor) {*/ /*require({ }, ["owncloud/ServerFactory", "webodf/editor/Editor"], function (ServerFactory, Editor) {*/
// fade out file list and show WebODF canvas // fade out file list and show WebODF canvas
$('#content-wrapper').fadeOut('fast').promise().done(function() { $('#content-wrapper').fadeOut('fast').promise().done(function() {
documentsMain.fileId = response.file_id; documentsMain.fileId = response.file_id;
documentsMain.fileName = response.title; documentsMain.fileName = response.title;
documentsMain.esId = response.es_id; documentsMain.esId = response.es_id;
documentsMain.memberId = response.member_id; documentsMain.memberId = response.member_id;
@ -373,7 +373,7 @@ var documentsMain = {
}, },
documentsMain.webodfServerInstance, serverFactory documentsMain.webodfServerInstance, serverFactory
); );
documentsMain.webodfEditorInstance.addEventListener(Editor.EVENT_BEFORESAVETOFILE, documentsMain.UI.showSave); documentsMain.webodfEditorInstance.addEventListener(Editor.EVENT_BEFORESAVETOFILE, documentsMain.UI.showSave);
documentsMain.webodfEditorInstance.addEventListener(Editor.EVENT_SAVEDTOFILE, documentsMain.UI.hideSave); documentsMain.webodfEditorInstance.addEventListener(Editor.EVENT_SAVEDTOFILE, documentsMain.UI.hideSave);
documentsMain.webodfEditorInstance.addEventListener(Editor.EVENT_ERROR, documentsMain.onEditorShutdown); documentsMain.webodfEditorInstance.addEventListener(Editor.EVENT_ERROR, documentsMain.onEditorShutdown);
@ -394,7 +394,7 @@ var documentsMain = {
}); });
/*});*/ /*});*/
}, },
joinSession: function(fileId) { joinSession: function(fileId) {
console.log('joining session '+fileId); console.log('joining session '+fileId);
@ -410,7 +410,7 @@ var documentsMain = {
documentsMain.initSession documentsMain.initSession
); );
}, },
view : function(id){ view : function(id){
OC.addScript('documents', 'viewer/viewer', function() { OC.addScript('documents', 'viewer/viewer', function() {
documentsMain.prepareGrid(); documentsMain.prepareGrid();
@ -421,7 +421,7 @@ var documentsMain = {
odfViewer.onView(path); odfViewer.onView(path);
}); });
}, },
onCreate: function(event){ onCreate: function(event){
event.preventDefault(); event.preventDefault();
var docElem = $('.documentslist .template').clone(); var docElem = $('.documentslist .template').clone();
@ -443,16 +443,16 @@ var documentsMain = {
documentsMain.show(); documentsMain.show();
} }
} }
); );
}, },
changeNick: function(memberId, name, node){ changeNick: function(memberId, name, node){
var url = OC.generateUrl('apps/documents/ajax/user/rename'); var url = OC.generateUrl('apps/documents/ajax/user/rename');
$.ajax({ $.ajax({
url: url, url: url,
type: "POST", type: "POST",
data: JSON.stringify({ data: JSON.stringify({
name : name, name : name,
memberId : memberId memberId : memberId
}), }),
@ -468,7 +468,7 @@ var documentsMain = {
} }
}); });
}, },
onNickChange: function(memberId, fullNameNode){ onNickChange: function(memberId, fullNameNode){
if (!documentsMain.isGuest || memberId !== documentsMain.memberId){ if (!documentsMain.isGuest || memberId !== documentsMain.memberId){
return; return;
@ -476,7 +476,7 @@ var documentsMain = {
if ($(fullNameNode.parentNode).children('input').length !== 0){ if ($(fullNameNode.parentNode).children('input').length !== 0){
return; return;
} }
var input = $('<input type="text"/>').val($(fullNameNode).attr('fullname')); var input = $('<input type="text"/>').val($(fullNameNode).attr('fullname'));
$(fullNameNode.parentNode).append(input); $(fullNameNode.parentNode).append(input);
$(fullNameNode).hide(); $(fullNameNode).hide();
@ -583,11 +583,11 @@ var documentsMain = {
} catch (e){ } catch (e){
documentsMain.UI.hideEditor(); documentsMain.UI.hideEditor();
} }
documentsMain.show(); documentsMain.show();
$('footer,nav').show(); $('footer,nav').show();
}, },
onClose: function() { onClose: function() {
if (!documentsMain.isEditorMode){ if (!documentsMain.isEditorMode){
@ -609,16 +609,16 @@ var documentsMain = {
} else { } else {
url = OC.generateUrl('apps/documents/ajax/user/disconnect', {}); url = OC.generateUrl('apps/documents/ajax/user/disconnect', {});
} }
$.post(url, { $.post(url, {
memberId : documentsMain.memberId, memberId : documentsMain.memberId,
esId: documentsMain.esId esId: documentsMain.esId
}); });
documentsMain.show(); documentsMain.show();
}); });
}, },
onTerminate: function(){ onTerminate: function(){
var url = ''; var url = '';
if (documentsMain.isGuest){ if (documentsMain.isGuest){
@ -634,7 +634,7 @@ var documentsMain = {
async: false // Should be sync to complete before the page is closed async: false // Should be sync to complete before the page is closed
}); });
documentsMain.webodfEditorInstance.endEditing(); documentsMain.webodfEditorInstance.endEditing();
documentsMain.webodfEditorInstance.closeSession(function() { documentsMain.webodfEditorInstance.closeSession(function() {
if (documentsMain.isGuest){ if (documentsMain.isGuest){
@ -643,7 +643,7 @@ var documentsMain = {
documentsMain.webodfEditorInstance.destroy(documentsMain.UI.hideEditor); documentsMain.webodfEditorInstance.destroy(documentsMain.UI.hideEditor);
}); });
}, },
show: function(){ show: function(){
if (documentsMain.isGuest){ if (documentsMain.isGuest){
return; return;
@ -695,7 +695,7 @@ var Files = Files || {
} }
return true; return true;
}, },
updateStorageStatistics: function(){} updateStorageStatistics: function(){}
}, },
FileList = FileList || {}; FileList = FileList || {};
@ -707,22 +707,22 @@ FileList.getCurrentDirectory = function(){
$(document).ready(function() { $(document).ready(function() {
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(); documentsMain.overlay = $('<div id="documents-overlay" class="icon-loading"></div><div id="documents-overlay-below" class="icon-loading-dark"></div>').documentOverlay();
$('li.document a').tipsy({fade: true, live: true}); $('li.document a').tipsy({fade: true, live: true});
$('.documentslist').on('click', 'li:not(.add-document)', function(event) { $('.documentslist').on('click', 'li:not(.add-document)', function(event) {
event.preventDefault(); event.preventDefault();
if (documentsMain.isEditorMode){ if (documentsMain.isEditorMode){
return; return;
} }
documentsMain.prepareSession(); documentsMain.prepareSession();
if ($(this).attr('data-id')){ if ($(this).attr('data-id')){
documentsMain.joinSession($(this).attr('data-id')); documentsMain.joinSession($(this).attr('data-id'));
} }
}); });
$('.add-document').on('click', '.add', documentsMain.onCreate); $('.add-document').on('click', '.add', documentsMain.onCreate);
var file_upload_start = $('#file_upload_start'); var file_upload_start = $('#file_upload_start');