Commit eda987fc authored by Vincent Bechu's avatar Vincent Bechu

[erp5_officejs] Fix pdf view, add parse on dataURI

parent 4c5ddb18
......@@ -76,7 +76,13 @@
return jIO.util.readBlobAsDataURL(blob);
})
.push(function (result) {
data = result.target.result;
if (result.target.result.split('data:')[1] === '') {
data = '';
} else {
data = result.target.result.split(
/data:application\/.*;base64,/
)[1];
}
return gadget.getDeclaredGadget('form_view');
})
.push(function (form_gadget) {
......
......@@ -233,7 +233,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>961.10686.10882.5973</string> </value>
<value> <string>961.12114.30061.24797</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -251,7 +251,7 @@
</tuple>
<state>
<tuple>
<float>1501855020.28</float>
<float>1501861765.33</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -5,13 +5,6 @@
"use strict";
rJS(window)
.ready(function (gadget) {
gadget.props = {};
return gadget.getElement()
.push(function (element) {
gadget.props.element = element;
});
})
.declareMethod("render", function (options) {
[].forEach.call(window.document.head.querySelectorAll("base"), function (el) {
// XXX GadgetField adds <base> tag to fit to the parent page location, it's BAD to remove them.
......@@ -20,10 +13,17 @@
// we break all dynamic links. So, deleting <base> is required.
window.document.head.removeChild(el);
});
this.props.key = options.key;
var raw = window.atob(options.value);
var rawLength = raw.length;
var array = new Uint8Array(new ArrayBuffer(rawLength));
return this.changeState({
value: options.value,
key: options.key
});
})
.onStateChange(function () {
var gadget = this,
raw = window.atob(gadget.state.value),
rawLength = raw.length,
array = new Uint8Array(new ArrayBuffer(rawLength));
for (var i = 0; i < rawLength; i++) {
array[i] = raw.charCodeAt(i);
......@@ -32,14 +32,14 @@
webViewerLoad(array);
// hide few buttons for now
this.props.element.querySelector('#viewBookmark').hidden = true;
this.props.element.querySelector('#documentProperties').hidden = true;
this.props.element.querySelector('#documentProperties').hidden = true;
gadget.element.querySelector('#viewBookmark').hidden = true;
gadget.element.querySelector('#documentProperties').hidden = true;
gadget.element.querySelector('#documentProperties').hidden = true;
return;
})
.declareMethod("getContent", function () {
var form_data = {};
var self = this;
var gadget = this;
return new RSVP.Queue()
.push(function () {
if (PDFViewerApplication.pdfDocument) {
......@@ -61,7 +61,7 @@
});
})
.push(function (evt) {
form_data[self.props.key] = evt.target.result;
form_data[gadget.state.key] = evt.target.result;
return form_data;
});
});
......
......@@ -233,7 +233,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>961.2133.47184.12219</string> </value>
<value> <string>961.12202.20585.38980</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -251,7 +251,7 @@
</tuple>
<state>
<tuple>
<float>1501257080.78</float>
<float>1501861642.39</float>
<string>UTC</string>
</tuple>
</state>
......
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