/*global window, rJS, DocsAPI, _*/ /*jslint nomen: true, maxlen:80, indent:2*/ (function (rJS, DocsAPI, _) { "use strict"; // Document Editor event handlers //function onRequestHistory() { // docEditor.refreshHistory({ // 'currentVersion': 3, // 'history': [ // { // 'user': { // id: '8952d4ee-e8a5-42bf-86f0-6cd77801ec15', // name: 'РўР°С‚СЊСЏРЅР° Р©РµСЂР±Р°РєРѕРІР°' // }, // 'changes': null, // 'created': '1/18/2015 6:38 PM', // 'version': 1, // 'version_group': 1, // 'key': 'wyX9AwRq_677SWKjhfk=' // }, // { // 'user': { // id: '8952d4ee-e8a5-42bf-86f0-6cd77801ec15', // name: 'РўР°С‚СЊСЏРЅР° Р©РµСЂР±Р°РєРѕРІР°' // }, // 'changes': [ // { // 'user': { // id: '8952d4ee-e8a5-42bf-86f0-6cd77801ec15', // name: 'РўР°С‚СЊСЏРЅР° Р©РµСЂР±Р°РєРѕРІР°' // }, // 'created': '1/19/2015 6:30 PM' // }, // { // 'user': { // 'userid': '8952d4ee-e8a5-42bf-11f0-6cd77801ec15', // 'username': 'РђР»РµРєСЃР°РЅРґСЂ РўСЂРѕС„РёРјРѕРІ' // }, // 'created': '1/19/2015 6:32 PM' // }, // { // 'user': { // id: '8952d4ee-e8a5-42bf-86f0-6cd77801ec15', // name: 'РўР°С‚СЊСЏРЅР° Р©РµСЂР±Р°РєРѕРІР°' // }, // 'created': '1/19/2015 6:38 PM' // } // ], // 'created': '2/19/2015 6:38 PM', // 'version': 2, // 'version_group': 1, // 'key': 'wyX9AwRq_677SWKjhfk=' // }, // { // 'user': { // id: '895255ee-e8a5-42bf-86f0-6cd77801ec15', // name: 'Me' // }, // 'changes': null, // 'created': '2/21/2015 6:38 PM', // 'version': 3, // 'version_group': 2, // 'key': 'wyX9AwRq_677SWKjhfk=' // }, // { // 'user': { // id: '8952d4ee-e8a5-42bf-11f0-6cd77801ec15', // name: 'РђР»РµРєСЃР°РЅРґСЂ РўСЂРѕС„РёРјРѕРІ' // }, // 'changes': null, // 'created': '2/22/2015 6:37 PM', // 'version': 4, // 'version_group': 3, // 'key': 'wyX9AwRq_677SWKjhfk=' // }, // { // 'user': { // id: '8952d4ee-e8a5-42bf-11f0-6cd33801ec15', // name: 'Р›РµРѕРЅРёРґ РћСЂР»РѕРІ' // }, // 'changes': null, // 'created': '2/24/2015 6:29 PM', // 'version': 5, // 'version_group': 3, // 'key': 'wyX9AwRq_677SWKjhfk=' // }] // }); //} // //function onRequestHistoryData(revision) { // docEditor.setHistoryData( // { // 'version': revision.data, // 'url': 'http://isa2', // 'urlDiff': 'http://isa2' // } // ); //} // //function onRequestHistoryClose() { // // reload page //} // function onDocEditorReady(event) { if (event.target) { console.log('Ready! Editor: ', event.target); } } function onDocumentStateChange(event) { var isModified = event.data; console.log(isModified); } function onError(event) { console.log(event.data); // critical error happened // examine event.data.errorCode and event.data.errorDescription for details } rJS(window) .ready(function (g) { g.props = {}; }) .ready(function (g) { return g.getElement() .push(function (element) { g.props.cfg = { mode: 'edit', lang: 'en', canCoAuthoring: false, canBackToFolder: true, canCreateNew: true, createUrl: 'http://www.example.com/create', user: { id: 'uid-901', name: 'Hamish Mitchell' }, recent: [ { title: 'Memory.docx', url: 'http://onlyoffice.com', folder: 'Document Editor' }, { title: 'Description.doc', url: 'http://onlyoffice.com', folder: 'Document Editor' }, { title: 'DocEditor_right.xsl', url: 'http://onlyoffice.com', folder: 'Spreadsheet Editor' }, { title: 'api.rtf', url: 'http://onlyoffice.com', folder: 'Unnamed folder' } ], templates: [ { name: 'Contracts', icon: '../../api/documents/resources/templates/contracts.png' }, { name: 'Letter', icon: '../../api/documents/resources/templates/letter.png' }, { name: 'List', icon: '../../api/documents/resources/templates/list.png' }, { name: 'Plan', icon: '../../api/documents/resources/templates/plan.png' } ], embedded: { embedUrl: 'http://onlyoffice.com/embed', fullscreenUrl: 'http://onlyoffice.com/fullscreen', saveUrl: 'http://onlyoffice.com/download', shareUrl: 'http://tl.com/72b4la97', toolbarDocked: 'top' }, customization: { //logoUrl: 'header logo url', // default size 88 x 30 //logoUrlEmbedded: 'header logo url', // default size 88 x 30 //backgroundColor: '#ffffff', //textColor: '#ff0000', //customer: { // name: 'SuperPuper', // address: 'New-York, 125f-25', // mail: 'support@gmail.com', // www: 'www.superpuper.com', // info: 'Some info', // logo:'https://img.imgsmail.ru/r/default/portal/0.1.29/logo.png' //}, //goback: {text: 'Go To London'} about: true, feedback: true } }; g.props.element = element; }); }) .declareAcquiredMethod("submitContent", "triggerSubmit") .declareAcquiredMethod("maximize", "triggerMaximize") .declareMethod('render', function (options) { console.log(options.value); this.props.docEditor = new DocsAPI.DocEditor('oospreadsheet_gadget', { //type: urlParams['type'], width: '100%', height: '100%', //documentType: urlParams['doctype'], document: { //key: undefined, //url: undefined, title: options.title, //fileType: undefined, //vkey: undefined, data: options.value || "", permissions: { edit: true, download: true, reader: true } }, editorConfig: this.props.cfg, events: { 'onReady': onDocEditorReady, 'onBack': _.bind(function (event) { this.maximize(); }, this), 'onDocumentStateChange': onDocumentStateChange, 'onRequestEditRights': _.bind(function (event) { // occurs whenever the user tryes to enter edit mode this.props.docEditor.applyEditRights(true, "Someone is editing this document right now." + " Please try again later."); }, this), //'onRequestHistory': onRequestHistory, //'onRequestHistoryData': onRequestHistoryData, //'onRequestHistoryClose': onRequestHistoryClose, 'onSave': _.bind(function (event) { this.props.data = event.data; this.submitContent(); return true; // if you want to async save process return false // and call api.processSaveResult when ready }, this), 'onError': onError } }); this.props.key = options.key || "text_content"; return {}; }) .declareMethod('getContent', function () { var result = {}; result[this.props.key] = this.props.data; return result; }); }(rJS, DocsAPI, _));