Commit 18a7a768 authored by Boris Kocherov's avatar Boris Kocherov

merge with Vincent Bechu @vincentB work

parent 4c97aacf
......@@ -2,6 +2,7 @@
Common, require, jIO, URL, FileReader, atob, ArrayBuffer,
Uint8Array, XMLHttpRequest, Blob, Rusha*/
/*jslint nomen: true, maxlen:80, indent:2*/
"use strict";
if (Common === undefined) {
var Common = {};
}
......@@ -11,7 +12,6 @@ DocsAPI.DocEditor.version = function() {
};
(function (rJS, RSVP, require, jIO) {
"use strict";
var rusha = new Rusha();
......@@ -65,7 +65,6 @@ DocsAPI.DocEditor.version = function() {
})
.declareAcquiredMethod("triggerSubmit", "triggerSubmit")
.declareAcquiredMethod("triggerMaximize", "triggerMaximize")
.declareAcquiredMethod("setFillStyle", "setFillStyle")
.declareAcquiredMethod('getSetting', 'getSetting')
.declareMethod("jio_getAttachment", function (docId, attId, opt) {
var g = this,
......@@ -138,8 +137,8 @@ DocsAPI.DocEditor.version = function() {
content_type = "application/binary";
}
content_type = content_type.split('/');
atId = content_type[0] + ',' + digest
+ '.' + content_type[1];
atId = content_type[0] + ',' + digest +
'.' + content_type[1];
return zip.allAttachments(docId)
.push(undefined, function (error) {
if (error.status_code === 404) {
......@@ -199,13 +198,7 @@ DocsAPI.DocEditor.version = function() {
console.log();
})
.declareMethod('goBack', function (new_window) {
var g = this;
g.triggerMaximize()
.push(function (size) {
var iframe = g.props.element.querySelector('iframe');
iframe.style.height = size.height;
iframe.style.width = size.width;
});
return;
})
.declareMethod('requestEditRights', function () {
var g = this;
......@@ -256,7 +249,9 @@ DocsAPI.DocEditor.version = function() {
g.props.key = options.key || "text_content";
g.props.documentType = portal_type.toLowerCase();
value = options.value;
if (value === "data:" || value === undefined) {
if (value === "data:" ||
g.props.value === "data:application/octet-stream;base64," ||
value === undefined) {
// fix empty value
value = "";
}
......@@ -280,7 +275,8 @@ DocsAPI.DocEditor.version = function() {
return g.props.value_zip_storage.getAttachment('/', 'body.txt')
.push(undefined, function (error) {
if (error.status_code === 404) {
throw 'not supported format of document: "' + value.slice(0, 100) + '"';
throw 'not supported format of document: "' +
value.slice(0, 100) + '"';
}
throw error;
})
......@@ -293,10 +289,15 @@ DocsAPI.DocEditor.version = function() {
return value;
})
.push(function (value) {
var magic, documentType;
var magic, documentType,
sdkPath,
nameSpace,
backboneControllers,
styles;
g.props.value = value;
if (!g.props.documentType && value === "") {
throw "can not create empty document because portal_type is unknown";
throw "can not create empty document " +
"because portal_type is unknown";
}
if (value) {
magic = g.props.value.slice(0, 4);
......@@ -318,24 +319,13 @@ DocsAPI.DocEditor.version = function() {
throw "editor not fit the document type";
}
} else {
//set editor type by docuementType
//set editor type by documentType
g.props.documentType = documentType;
}
}
if (!g.props.value_zip_storage) {
g.props.value_zip_storage = jIO.createJIO({type: "zipfile"});
}
return g.setFillStyle();
})
.push(function (size) {
var element = g.props.element,
sdkPath,
nameSpace,
backboneControllers,
styles;
element.style.height = size.height;
element.style.width = size.width;
// g.fullscreen();
switch (g.props.documentType) {
case 'spreadsheet':
sdkPath = 'cell';
......@@ -670,8 +660,10 @@ DocsAPI.DocEditor.version = function() {
return save_defer.promise;
})
.push(function (data) {
var body = data[g.props.key];
return zip.putAttachment('/', 'body.txt', body);
if (data) {
var body = data[g.props.key];
return zip.putAttachment('/', 'body.txt', body);
}
})
.push(function () {
return zip.getAttachment('/', '/');
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment