define([ 'jquery', '/common/toolbar3.js', 'json.sortify', '/bower_components/nthen/index.js', '/common/sframe-common.js', '/common/common-interface.js', '/common/common-hash.js', '/common/common-util.js', '/api/config', '/customize/messages.js', '/customize/application_config.js', '/bower_components/chainpad/chainpad.dist.js', '/file/file-crypto.js', '/bower_components/tweetnacl/nacl-fast.min.js', '/bower_components/file-saver/FileSaver.min.js', 'css!/bower_components/bootstrap/dist/css/bootstrap.min.css', 'less!/bower_components/components-font-awesome/css/font-awesome.min.css', 'less!/customize/src/less2/main.less', ], function ( $, Toolbar, JSONSortify, nThen, SFCommon, UI, Hash, Util, ApiConfig, Messages, AppConfig, ChainPad, FileCrypto) { var saveAs = window.saveAs; var Nacl = window.nacl; var APP = window.APP = { $: $ }; var stringify = function (obj) { return JSONSortify(obj); }; var toolbar; var andThen = function (common) { var readOnly = false; var locked = false; var config = {}; var hashes = []; var getFileType = function () { var type = common.getMetadataMgr().getPrivateData().ooType; var title = common.getMetadataMgr().getMetadataLazy().title; var file = {}; switch(type) { case 'oodoc': file.type = 'docx'; file.title = title + '.docx' || 'document.docx'; file.doc = 'text'; break; case 'oocell': file.type = 'xlsx'; file.title = title + '.xlsx' || 'spreadsheet.xlsx'; file.doc = 'spreadsheet'; break; case 'ooslide': file.type = 'pptx'; file.title = titl + '.pptx' || 'presentation.pptx'; file.doc = 'presentation'; break; } return file; }; var startOO = function (blob, file) { if (APP.ooconfig) { return void console.error('already started'); } var url = URL.createObjectURL(blob); var lock = locked !== common.getMetadataMgr().getNetfluxId(); // Config APP.ooconfig = { "document": { "fileType": file.type, "key": "fresh", "title": file.title, "url": url, "permissions": { "download": false, // FIXME: download/export is not working, so we use false // to remove the button } }, "documentType": file.doc, "editorConfig": { customization: { chat: false, logo: { url: "/bounce/#" + encodeURIComponent('https://www.onlyoffice.com') } }, "user": { "id": "", //"c0c3bf82-20d7-4663-bf6d-7fa39c598b1d", "name": "", //"John Smith" }, "mode": readOnly || lock ? "view" : "edit" }, "events": { "onDocumentStateChange": function (evt) { if (evt.data) { console.log('in change (local)'); return; } console.log("in change (remote)"); }, "onReady": function(/*evt*/) { var $tb = $('iframe[name="frameEditor"]').contents().find('head'); var css = '#id-toolbar-full .toolbar-group:nth-child(2), #id-toolbar-full .separator:nth-child(3) { display: none; }' + '#fm-btn-save { display: none !important; }' + '#header { display: none !important; }'; $('