/*globals $,OC,fileDownloadPath,t,document,odf,alert,require,dojo,runtime,Handlebars */ $.widget('oc.documentGrid', { options : { context : '.documentslist', documents : {}, sessions : {}, members : {} }, render : function(fileId){ var that = this; jQuery.when(this._load(fileId)) .then(function(){ that._render(); documentsMain.renderComplete = true; }); }, _load : function (fileId){ documentsMain.initSession(); }, _render : function (data){ var that = this, documents = data && data.documents || this.options.documents, sessions = data && data.sessions || this.options.sessions, members = data && data.members || this.options.members, hasDocuments = false ; $(this.options.context + ' .document:not(.template,.progress)').remove(); if (documentsMain.loadError) { $(this.options.context).after('
' + '

' + documentsMain.loadErrorMessage + '

' + documentsMain.loadErrorHint + '

' ); return; } } }); $.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 = { isEditorMode : false, isViewerMode: false, ready :false, fileName: null, baseName: null, canShare : false, canEdit: false, loadError : false, loadErrorMessage : '', loadErrorHint : '', renderComplete: false, // false till page is rendered with all required data about the document(s) toolbar : '
', $deferredVersionRestoreAck: null, wopiClientFeatures: null, // generates docKey for given fileId _generateDocKey: function(wopiFileId) { var ocurl = OC.generateUrl('apps/richdocuments/wopi/files/{file_id}', {file_id: wopiFileId}); if (richdocuments_canonical_webroot) { if (!richdocuments_canonical_webroot.startsWith('/')) richdocuments_canonical_webroot = '/' + richdocuments_canonical_webroot; ocurl = ocurl.replace(OC.webroot, richdocuments_canonical_webroot); } return ocurl; }, UI : { /* Editor wrapper HTML */ container : '
' + '
', viewContainer: '
' + '
' + '
', revHistoryContainerTemplate: '
' + '
' + '

Revision History

' + '{{filename}}' + '' + '
' + '
' + '' + '
' + '' + '
', revHistoryItemTemplate: '
  • ' + '' + '{{relativeTimestamp}}' + '' + '' + '
  • ', /* Previous window title */ mainTitle : '', /* Number of revisions already loaded */ revisionsStart: 0, init : function(){ documentsMain.UI.mainTitle = parent.document.title; }, showViewer: function(fileId, title){ // remove previous viewer, if open, and set a new one if (documentsMain.isViewerMode) { $('#revViewer').remove(); $('#revViewerContainer').prepend($('
    ')); } // WOPISrc - URL that loolwsd will access (ie. pointing to ownCloud) var wopiurl = window.location.protocol + '//' + window.location.host + OC.generateUrl('apps/richdocuments/wopi/files/{file_id}', {file_id: fileId}); var wopisrc = encodeURIComponent(wopiurl); // urlsrc - the URL from discovery xml that we access for the particular // document; we add various parameters to that. // The discovery is available at // https://:9980/hosting/discovery var urlsrc = documentsMain.urlsrc + "WOPISrc=" + wopisrc + "&title=" + encodeURIComponent(title) + "&lang=" + OC.getLocale().replace('_', '-') + // loleaflet expects a BCP47 language tag syntax "&permission=readonly"; // access_token - must be passed via a form post var access_token = encodeURIComponent(documentsMain.token); // form to post the access token for WOPISrc var form = '
    ' + '
    '; // iframe that contains the Collabora Online Viewer var frame = '