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

merge with Vincent Bechu @vincentB work

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