/* globals FileList, OCA.Files.fileActions, oc_debug */ var odfViewer = { isDocuments : false, supportedMimesReadWrite: [ 'application/vnd.oasis.opendocument.text', 'application/vnd.oasis.opendocument.spreadsheet', 'application/vnd.oasis.opendocument.graphics', 'application/vnd.oasis.opendocument.presentation', 'application/vnd.lotus-wordpro', 'image/svg+xml', 'application/vnd.visio', 'application/vnd.wordperfect', 'application/msonenote', 'application/msword', 'application/rtf', 'text/rtf', 'text/plain', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'application/vnd.openxmlformats-officedocument.wordprocessingml.template', 'application/vnd.ms-word.document.macroEnabled.12', 'application/vnd.ms-word.template.macroEnabled.12', 'application/vnd.ms-excel', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', 'application/vnd.openxmlformats-officedocument.spreadsheetml.template', 'application/vnd.ms-excel.sheet.macroEnabled.12', 'application/vnd.ms-excel.template.macroEnabled.12', 'application/vnd.ms-excel.addin.macroEnabled.12', 'application/vnd.ms-excel.sheet.binary.macroEnabled.12', 'application/vnd.ms-powerpoint', 'application/vnd.openxmlformats-officedocument.presentationml.presentation', 'application/vnd.openxmlformats-officedocument.presentationml.template', 'application/vnd.openxmlformats-officedocument.presentationml.slideshow', 'application/vnd.ms-powerpoint.addin.macroEnabled.12', 'application/vnd.ms-powerpoint.presentation.macroEnabled.12', 'application/vnd.ms-powerpoint.template.macroEnabled.12', 'application/vnd.ms-powerpoint.slideshow.macroEnabled.12' ], register : function() { var i, mimeReadOnly, mimeReadWrite; for (i = 0; i < odfViewer.supportedMimesReadWrite.length; ++i) { mimeReadOnly = odfViewer.supportedMimesReadWrite[i]; OCA.Files.fileActions.register(mimeReadOnly, 'View', OC.PERMISSION_READ, '', odfViewer.onEdit); OCA.Files.fileActions.setDefault(mimeReadOnly, 'View'); } for (i = 0; i < odfViewer.supportedMimesReadWrite.length; ++i) { mimeReadWrite = odfViewer.supportedMimesReadWrite[i]; OCA.Files.fileActions.register( mimeReadWrite, 'Edit', OC.PERMISSION_UPDATE, OC.imagePath('core', 'actions/rename'), odfViewer.onEdit, t('richdocuments', 'Edit') ); OCA.Files.fileActions.register( mimeReadWrite, 'View', OC.PERMISSION_READ, OC.imagePath('core', 'actions/rename'), odfViewer.onEdit, t('richdocuments', 'View') ); OCA.Files.fileActions.setDefault(mimeReadWrite, 'View'); OCA.Files.fileActions.setDefault(mimeReadWrite, 'Edit'); } }, dispatch : function(filename){ odfViewer.onEdit(filename); }, onEdit : function(fileName, context) { if(context) { var fileDir = context.dir; var fileId = context.$file.attr('data-id'); } var viewer; if($('#isPublic').val() === '1') { viewer = OC.generateUrl( 'apps/richdocuments/public?shareToken={shareToken}&fileName={fileName}&requesttoken={requesttoken}', { shareToken: $('#sharingToken').val(), fileName: fileName, dir: fileDir, requesttoken: OC.requestToken } ); } else { viewer = OC.generateUrl( 'apps/richdocuments/index?fileId={fileId}_{dir}&requesttoken={requesttoken}', { fileId: fileId, dir: fileDir, requesttoken: OC.requestToken } ); } if(context) { FileList.setViewerMode(true); } var $iframe = $('