Commit 3f510201 authored by Boris Kocherov's avatar Boris Kocherov

gadget mode changes

parent e1fbce79
......@@ -31,222 +31,3 @@
*
*/
if (Common === undefined) {
var Common = {};
}
Common.Gateway = new(function() {
var me = this,
$me = $(me);
var commandMap = {
'init': function(data) {
$me.trigger('init', data);
},
'openDocument': function(data) {
$me.trigger('opendocument', data);
},
'showMessage': function(data) {
$me.trigger('showmessage', data);
},
'applyEditRights': function(data) {
$me.trigger('applyeditrights', data);
},
'processSaveResult': function(data) {
$me.trigger('processsaveresult', data);
},
'processRightsChange': function(data) {
$me.trigger('processrightschange', data);
},
'refreshHistory': function(data) {
$me.trigger('refreshhistory', data);
},
'setHistoryData': function(data) {
$me.trigger('sethistorydata', data);
},
'setEmailAddresses': function(data) {
$me.trigger('setemailaddresses', data);
},
'processMailMerge': function(data) {
$me.trigger('processmailmerge', data);
},
'downloadAs': function() {
$me.trigger('downloadas');
},
'processMouse': function(data) {
$me.trigger('processmouse', data);
},
'internalCommand': function(data) {
$me.trigger('internalcommand', data);
},
'resetFocus': function(data) {
$me.trigger('resetfocus', data);
}
};
var _postMessage = function(msg) {
// TODO: specify explicit origin
if (window.parent && window.JSON) {
msg.frameEditorId = window.frameEditorId;
window.parent.postMessage(window.JSON.stringify(msg), "*");
}
};
var _onMessage = function(msg) {
// TODO: check message origin
var data = msg.data;
if (Object.prototype.toString.apply(data) !== '[object String]' || !window.JSON) {
return;
}
var cmd, handler;
try {
cmd = window.JSON.parse(data)
} catch(e) {
cmd = '';
}
if (cmd) {
handler = commandMap[cmd.command];
if (handler) {
handler.call(this, cmd.data);
}
}
};
var fn = function(e) { _onMessage(e); };
if (window.attachEvent) {
window.attachEvent('onmessage', fn);
} else {
window.addEventListener('message', fn, false);
}
return {
appReady: function() {
_postMessage({ event: 'onAppReady' });
},
requestEditRights: function() {
_postMessage({ event: 'onRequestEditRights' });
},
requestHistory: function() {
_postMessage({ event: 'onRequestHistory' });
},
requestHistoryData: function(revision) {
_postMessage({
event: 'onRequestHistoryData',
data: revision
});
},
requestRestore: function(version, url) {
_postMessage({
event: 'onRequestRestore',
data: {
version: version,
url: url
}
});
},
requestEmailAddresses: function() {
_postMessage({ event: 'onRequestEmailAddresses' });
},
requestStartMailMerge: function() {
_postMessage({event: 'onRequestStartMailMerge'});
},
requestHistoryClose: function(revision) {
_postMessage({event: 'onRequestHistoryClose'});
},
reportError: function(code, description) {
_postMessage({
event: 'onError',
data: {
errorCode: code,
errorDescription: description
}
});
},
sendInfo: function(info) {
_postMessage({
event: 'onInfo',
data: info
});
},
setDocumentModified: function(modified) {
_postMessage({
event: 'onDocumentStateChange',
data: modified
});
},
internalMessage: function(type, data) {
_postMessage({
event: 'onInternalMessage',
data: {
type: type,
data: data
}
});
},
updateVersion: function() {
_postMessage({ event: 'onOutdatedVersion' });
},
downloadAs: function(url) {
_postMessage({
event: 'onDownloadAs',
data: url
});
},
collaborativeChanges: function() {
_postMessage({event: 'onCollaborativeChanges'});
},
requestRename: function(title) {
_postMessage({event: 'onRequestRename', data: title});
},
metaChange: function(meta) {
_postMessage({event: 'onMetaChange', data: meta});
},
documentReady: function() {
_postMessage({ event: 'onDocumentReady' });
},
on: function(event, handler){
var localHandler = function(event, data){
handler.call(me, data)
};
$me.on(event, localHandler);
}
}
})();
......@@ -55,8 +55,8 @@ define([
isRetina = window.devicePixelRatio > 1,
thumbCanvas = document.createElement('canvas'),
thumbContext = thumbCanvas.getContext('2d'),
thumbPath = '../../../../sdkjs/common/Images/fonts_thumbnail.png',
thumbPath2x = '../../../../sdkjs/common/Images/fonts_thumbnail@2x.png',
thumbPath = './onlyoffice/fonts/Images/fonts_thumbnail.png',
thumbPath2x = './onlyoffice/fonts/Images/fonts_thumbnail@2x.png',
listItemHeight = 36;
if (typeof window['AscDesktopEditor'] === 'object') {
......
/** `css` is a requirejs plugin
that loads a css file and inject it into a page.
note that this loader will return immediately,
regardless of whether the browser had finished parsing the stylesheet.
this css loader is implemented for file optimization and depedency managment
*/
define({
load: function (name, require, load, config) {
"use strict";
function inject(filename)
{
var head = document.getElementsByTagName('head')[0];
var link = document.createElement('link');
link.href = filename;
link.rel = 'stylesheet';
link.type = 'text/css';
head.appendChild(link);
}
if (typeof(document) !== 'undefined') {
inject(requirejs.toUrl(name));
}
load(true);
}
});
......@@ -43,7 +43,7 @@ var reqerr;
require.config({
// The shim config allows us to configure dependencies for
// scripts that do not call define() to register a module
baseUrl: '../../',
baseUrl: Common.Gateway.props.base_url + 'web-apps/apps/',
paths: {
jquery : '../vendor/jquery/jquery',
underscore : '../vendor/underscore/underscore',
......@@ -56,9 +56,9 @@ require.config({
sockjs : '../vendor/sockjs/sockjs.min',
jszip : '../vendor/jszip/jszip.min',
jsziputils : '../vendor/jszip-utils/jszip-utils.min',
allfonts : '../../sdkjs/common/AllFonts',
jsrsasign : '../vendor/jsrsasign/jsrsasign-latest-all-min',
allfonts : '../../../onlyoffice/fonts/AllFonts',
sdk : '../../sdkjs/word/sdk-all-min',
api : 'api/documents/api',
core : 'common/main/lib/core/application',
notification : 'common/main/lib/core/NotificationCenter',
keymaster : 'common/main/lib/core/keymaster',
......@@ -132,10 +132,10 @@ require([
'bootstrap',
'core',
'sdk',
'api',
'analytics',
'gateway',
'locale'
'locale',
'css!documenteditor/main/resources/css/app.css'
], function (Backbone, Bootstrap, Core) {
Backbone.history.start();
......
......@@ -43,7 +43,7 @@ var reqerr;
require.config({
// The shim config allows us to configure dependencies for
// scripts that do not call define() to register a module
baseUrl: '../../',
baseUrl: Common.Gateway.props.base_url + 'web-apps/apps/',
paths: {
jquery : '../vendor/jquery/jquery',
underscore : '../vendor/underscore/underscore',
......@@ -54,9 +54,11 @@ require.config({
jmousewheel : '../vendor/perfect-scrollbar/src/jquery.mousewheel',
xregexp : '../vendor/xregexp/xregexp-all-min',
sockjs : '../vendor/sockjs/sockjs.min',
allfonts : '../../sdkjs/common/AllFonts',
jszip : '../vendor/jszip/jszip.min',
jsziputils : '../vendor/jszip-utils/jszip-utils.min',
jsrsasign : '../vendor/jsrsasign/jsrsasign-latest-all-min',
allfonts : '../../../onlyoffice/fonts/AllFonts',
sdk : '../../sdkjs/slide/sdk-all-min',
api : 'api/documents/api',
core : 'common/main/lib/core/application',
notification : 'common/main/lib/core/NotificationCenter',
keymaster : 'common/main/lib/core/keymaster',
......@@ -127,10 +129,10 @@ require([
'bootstrap',
'core',
'sdk',
'api',
'analytics',
'gateway',
'locale'
'locale',
'css!presentationeditor/main/resources/css/app.css'
], function (Backbone, Bootstrap, Core) {
Backbone.history.start();
......
......@@ -147,7 +147,7 @@ define([
if (this.api){
this.api.SetDrawingFreeze(true);
this.api.SetThemesPath("../../../../sdkjs/slide/themes/");
this.api.SetThemesPath("onlyoffice/sdkjs/slide/themes/");
this.api.asc_registerCallback('asc_onError', _.bind(this.onError, this));
this.api.asc_registerCallback('asc_onDocumentContentReady', _.bind(this.onDocumentContentReady, this));
......
/*! see LICENCE for Simplified BSD Licence */
/*jslint browser:true, indent:2*/
/*global define, require*/ // Require.JS
/*global Promise*/ // ES6 native Promise
define(function () {
'use strict';
var isPromise;
isPromise = function (obj) {
if (!obj || typeof obj !== 'object') {
return false;
}
if (window.Promise && obj instanceof Promise) {
return true;
}
return typeof obj.then === 'function';
};
return {
/**
* @param {String} name This is the name of the desired resource module.
* @param {Function} req Provides a "require" to load other modules.
* @param {Function} load Pass the module's result to this function.
* @param {Object} config Provides the optimizer's configuration.
*/
load: function (name, req, load) { // , config
// TODO: check config.isBuild\
// TODO: call load.fromText() if necessary to eval JavaScript text
req([name], function (result) {
var onReject, onResolve, complete;
onReject = function () {
load.error.apply(null, arguments);
};
onResolve = function () {
load.apply(null, arguments);
};
if (isPromise(result)) {
// If the promise supports "done" (not all do), we want to use that to
// terminate the promise chain and expose any exceptions.
complete = result.done || result.then;
if (typeof result.fail === 'function') {
complete.call(result, onResolve);
result.fail(onReject);
} else {
// native Promises don't have `fail` (thanks @nfeldman)
complete.call(result, onResolve, onReject);
}
} else {
load(result);
}
});
}/*,
write: function () {
// TODO: what needs to be done for write() ??
}, */
/* pluginBuilder: function () {
// TODO: what needs to be done for pluginBuilder() ??
} */
/*
* Note: we explicitly do NOT implement normalize(), as the simpler
* default implementation is sufficient for current use cases.
*/
};
});
/*global window, rJS, RSVP, DocsAPI, console, document,
Common, require, jIO, URL, FileReader, atob, ArrayBuffer,
Uint8Array, XMLHttpRequest, Blob, Rusha*/
"use strict";
define([
'sdk_files',
'jquery',
'underscore',
'allfonts',
'xregexp',
'sockjs',
'jsziputils',
'jsrsasign'
], function(config_file) {
return new RSVP.Queue()
.push(function () {
return jIO.util.ajax({
type: "GET",
dataType: "json",
url: "onlyoffice/sdkjs/build/configs/" + config_file
});
})
.push(function (response) {
var script_src = "",
queue = new RSVP.Queue(),
list = response.target.response.compile.sdk.min;
function loadScript(src) {
return new RSVP.Promise(function (resolve, reject) {
var s;
s = document.createElement('script');
s.src = src;
s.onload = resolve;
s.onerror = reject;
document.head.appendChild(s);
});
}
list.concat(response.target.response
.compile.sdk.desktop.min).forEach(function (url) {
url = url.replace('../', 'onlyoffice/sdkjs/');
queue
.push(function () {
return jIO.util.ajax({
type: "GET",
url: url
});
})
.push(function (result) {
script_src += "\n" + result.target.response;
});
});
queue.push(function () {
var url = URL.createObjectURL(new Blob([script_src], {type: "text/javascript"}));
return loadScript(url);
}).push(undefined, function (error) {
console.log(error);
throw error;
});
return queue;
});
});
......@@ -43,7 +43,7 @@ var reqerr;
require.config({
// The shim config allows us to configure dependencies for
// scripts that do not call define() to register a module
baseUrl: '../../',
baseUrl: Common.Gateway.props.base_url + 'web-apps/apps/',
paths: {
jquery : '../vendor/jquery/jquery',
underscore : '../vendor/underscore/underscore',
......@@ -56,9 +56,9 @@ require.config({
sockjs : '../vendor/sockjs/sockjs.min',
jszip : '../vendor/jszip/jszip.min',
jsziputils : '../vendor/jszip-utils/jszip-utils.min',
allfonts : '../../sdkjs/common/AllFonts',
jsrsasign : '../vendor/jsrsasign/jsrsasign-latest-all-min',
allfonts : '../../../onlyoffice/fonts/AllFonts',
sdk : '../../sdkjs/cell/sdk-all-min',
api : 'api/documents/api',
core : 'common/main/lib/core/application',
notification : 'common/main/lib/core/NotificationCenter',
keymaster : 'common/main/lib/core/keymaster',
......@@ -131,10 +131,11 @@ require([
'bootstrap',
'core',
'sdk',
'api',
'analytics',
'gateway',
'locale'
'locale',
'css!../../sdkjs/cell/css/main.css',
'css!spreadsheeteditor/main/resources/css/app.css'
], function (Backbone, Bootstrap, Core) {
Backbone.history.start();
......
......@@ -33,6 +33,8 @@
define([
], function () {
'use strict';
var FormulaResourcePath = Common.Gateway.props.base_url +
'web-apps/apps/spreadsheeteditor/main/resources/formula-lang/';
SSE.Views = SSE.Views || {};
......@@ -71,7 +73,7 @@ define([
try {
var xhrObj = _createXMLHTTPObject();
if (xhrObj && lang) {
xhrObj.open('GET', 'resources/formula-lang/' + lang + '.json', false);
xhrObj.open('GET', FormulaResourcePath + lang + '.json', false);
xhrObj.send('');
langJson[lang] = eval("(" + xhrObj.responseText + ")");
return langJson[lang];
......@@ -95,12 +97,12 @@ define([
try {
var xhrObj = _createXMLHTTPObject();
if (xhrObj && lang) {
xhrObj.open('GET', 'resources/formula-lang/' + lang + '_desc.json', false);
xhrObj.open('GET', FormulaResourcePath + lang + '_desc.json', false);
xhrObj.send('');
if (xhrObj.status == 200)
langDescJson[lang] = eval("(" + xhrObj.responseText + ")");
else {
xhrObj.open('GET', 'resources/formula-lang/en_desc.json', false);
xhrObj.open('GET', FormulaResourcePath + 'en_desc.json', false);
xhrObj.send('');
langDescJson[lang] = eval("(" + xhrObj.responseText + ")");
}
......
<!DOCTYPE html>
<html>
<head>
<base href="./">
<title>OFFICE Document Editor</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=IE8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no">
<meta name="description" content="" />
<meta name="keywords" content="" />
<style type="text/css">
.loadmask {
left: 0;
top: 0;
position: absolute;
height: 100%;
width: 100%;
overflow: hidden;
border: none;
background-color: #f4f4f4;
z-index: 100;
}
.loader-page {
width: 100%;
height: 170px;
bottom: 42%;
margin-bottom: 50px;
position: absolute;
text-align: center;
}
.loader-page-text {
width: 100%;
bottom: 42%;
position: absolute;
text-align: center;
color: #888;
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
line-height: 20px;
}
.loader-page-text-loading {
font-size: 14px;
}
.loader-page-text-customer {
font-size: 16px;
margin-bottom: 5px;
}
</style>
<script src="rsvp.js" type="text/javascript"></script>
<script src="renderjs.js" type="text/javascript"></script>
<script src="jio.js" type="text/javascript"></script>
<script src="zipfilestorage-with-jszip.js" type="text/javascript"></script>
<script src="onlyoffice/web-apps/vendor/requirejs/require.js" type="text/javascript"></script>
<script src="./onlyoffice.gadget.js" type="text/javascript"></script>
</head>
<body>
<div id="loading-mask" class="loadmask">
<div class="loader-page">
<div class="loader-page-text">
<div class="loader-page-text-customer">OFFICE</div>
<div class="loader-page-text-loading">Loading...</div>
</div>
</div>
</div>
<div id="viewport"></div>
</body>
</html>
\ No newline at end of file
/*global window, rJS, RSVP, DocsAPI, console, document,
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 = {};
}
var DocsAPI = {DocEditor: {}};
DocsAPI.DocEditor.version = function () {
return null;
};
(function (rJS, RSVP, require, jIO) {
var rusha = new Rusha();
function hexdigest(blob) {
return new RSVP.Queue()
.push(function () {
return jIO.util.readBlobAsArrayBuffer(blob)
.then(function (evt) {
return rusha.digest(evt.target.result);
});
});
}
function display_error(gadget, error) {
var display_error_element;
display_error_element = gadget.props.element;
display_error_element.innerHTML =
'<br/><p style="color: red"></p><br/><br/>';
display_error_element.querySelector('p').textContent = error;
console.error(error);
throw error;
}
function dataURLtoBlob(url) {
if (url === 'data:') {
return new Blob();
}
var byteString = atob(url.split(',')[1]),
mimeString = url.split(',')[0].split(':')[1].split(';')[0],
ab = new ArrayBuffer(byteString.length),
ia = new Uint8Array(ab),
i;
for (i = 0; i < byteString.length; i += 1) {
ia[i] = byteString.charCodeAt(i);
}
return new Blob([ab], {type: mimeString});
}
rJS(window)
.ready(function (g) {
g.props = {
save_defer: null,
handlers: {}
};
})
.ready(function (g) {
return g.getElement()
.push(function (element) {
g.props.element = element;
return {};
});
})
.declareAcquiredMethod("triggerSubmit", "triggerSubmit")
.declareAcquiredMethod("triggerMaximize", "triggerMaximize")
.declareAcquiredMethod('getSetting', 'getSetting')
.declareMethod("jio_getAttachment", function (docId, attId, opt) {
var g = this,
queue;
if (attId === 'body.txt') {
opt = 'asText';
if (!docId) {
docId = '/';
}
} else {
if (!docId) {
docId = '/media/';
}
}
queue = g.props.value_zip_storage.getAttachment(docId, attId)
.push(function (blob) {
var data;
if (opt === "asText") {
data = jIO.util.readBlobAsText(blob)
.then(function (evt) {
return evt.target.result;
});
} else if (opt === "asBlobURL") {
data = URL.createObjectURL(blob);
} else if (opt === "asDataURL") {
data = new RSVP.Promise(function (resolve, reject) {
var reader = new FileReader();
reader.addEventListener('load', function () {
resolve(reader.result);
});
reader.addEventListener('error', reject);
reader.readAsDataURL(blob);
});
} else {
data = blob;
}
return data;
});
return queue;
})
.declareMethod("jio_putAttachment", function (docId, atId, data) {
var g = this,
zip = g.props.value_zip_storage,
queue,
content_type,
start = data.slice(0, 5);
if (!docId) {
docId = '/media/';
}
if (typeof data === 'string' && start === "data:") {
data = dataURLtoBlob(data);
}
if (atId) {
queue = zip.putAttachment(docId, atId, data)
.push(undefined, function (error) {
if (error.status_code === 404) {
// make dir
return zip.put(docId, {})
.push(function () {
return zip.putAttachment(docId, atId, data);
});
}
throw error;
});
} else {
queue = hexdigest(data)
.push(function (digest) {
content_type = data.type;
if (!content_type) {
content_type = "application/binary";
}
content_type = content_type.split('/');
atId = content_type[0] + ',' + digest +
'.' + content_type[1];
return zip.allAttachments(docId)
.push(undefined, function (error) {
if (error.status_code === 404) {
// make dir
return zip.put(docId, {});
}
throw error;
})
.push(function (list) {
if (list.hasOwnProperty(atId)) {
return {};
}
return zip.putAttachment(docId, atId, data);
});
})
.push(function () {
return atId;
});
}
return queue;
})
// methods emulating Gateway used for connection with ooffice begin.
.declareMethod('appReady', function () {
var g = this;
console.log('appReady');
g.props.handlers.init({
config: {
lang: 'en',
canAutosave: false,
canCoAuthoring: false,
canBackToFolder: true,
canCreateNew: false,
canAnalytics: false,
customization: {
about: false,
feedback: false
}
}
});
g.props.handlers.opendocument({
doc: {
key: g.props.jio_key,
//title: g.props.doc.title || "",
//fileType: undefined,
//vkey: undefined,
url: "_offline_",
permissions: {
edit: true,
download: true,
reader: true
}
}
});
})
.declareMethod('documentReady', function () {
console.log();
})
.declareMethod('goBack', function (new_window) {
})
.declareMethod('requestEditRights', function () {
var g = this;
g.props.handlers.applyEditRights({
allowed: true,
message: ""
});
})
.declareMethod('requestHistory', function () {
})
.declareMethod('requestHistoryData', function (revision) {
})
.declareMethod('requestHistoryClose', function () {
})
.declareMethod('reportError', function (code, description) {
console.log(['reportError', code, description]);
})
.declareMethod('sendInfo', function (info) {
console.log(['sendInfo', info]);
})
.declareMethod('setDocumentModified', function (modified) {
})
.declareMethod('internalMessage', function (event_name, data) {
console.log(['internalMessage', event_name, data]);
})
.declareMethod('updateVersion', function () {
})
.declareMethod('on', function (event_name, handler) {
var g = this;
g.props.handlers[event_name] = handler;
})
// methods emulating Gateway used for connection with ooffice end.
.declareMethod('render', function (options) {
console.log('begin render');
var g = this,
queue = new RSVP.Queue();
return queue
.push(function () {
return g.getSetting('portal_type');
})
.push(undefined, function (error) {
return "";
})
.push(function (portal_type) {
var value, documentType, magic;
portal_type = portal_type || options.portal_type;
g.props.binary_loader = false;
g.props.jio_key = options.jio_key;
g.props.key = options.key || "text_content";
g.props.documentType = portal_type.toLowerCase();
value = options.value;
if (value === "data:" ||
g.props.value === "data:application/octet-stream;base64," ||
value === undefined) {
// fix empty value
value = "";
}
if (value) {
if (value.slice === undefined) {
throw "not suported type of variable containing the document: " +
typeof value;
}
if (value.slice(0, 5) === "data:") {
value = atob(value.split(',')[1]);
}
}
if (value) {
switch (value.slice(0, 4)) {
case "PK\x03\x04":
case "PK\x05\x06":
g.props.value_zip_storage = jIO.createJIO({
type: "zipfile",
file: value
});
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 error;
})
.push(jIO.util.readBlobAsText)
.push(function (evt) {
return evt.target.result;
});
}
}
g.props.value = value;
if (!g.props.documentType && value === "") {
throw "can not create empty document " +
"because portal_type is unknown";
}
if (value) {
magic = g.props.value.slice(0, 4);
switch (magic) {
case 'XLSY':
documentType = "spreadsheet";
break;
case 'PPTY':
documentType = "presentation";
break;
case 'DOCY':
documentType = "text";
break;
default:
throw "can not detect document type by magic: " + magic;
}
if (g.props.documentType) {
if (documentType !== g.props.documentType) {
throw "editor not fit the document type";
}
} else {
//set editor type by documentType
g.props.documentType = documentType;
}
}
})
.push(function () {
var app_url, sdk_deps = ["promise!sdk_async_loader"];
if (!g.props.value_zip_storage) {
g.props.value_zip_storage = jIO.createJIO({type: "zipfile"});
}
switch (g.props.documentType) {
case 'spreadsheet':
app_url = "web-apps/apps/spreadsheeteditor/main/app.js";
define("sdk_files", [], function () {
return "webexcel.json";
});
sdk_deps.push('window!Xmla');
break;
case 'text':
app_url = "web-apps/apps/documenteditor/main/app.js";
define("sdk_files", [], function () {
return "webword.json";
});
break;
case 'presentation':
app_url = "web-apps/apps/presentationeditor/main/app.js";
define("sdk_files", [], function () {
return "webpowerpoint.json";
});
break;
}
Common.Gateway = g;
require.onError = function (error) {
console.error(error);
};
require.config({catchError:true});
if (g.props.binary_loader) {
g.props.base_url = "onlyoffice-bin/";
} else {
g.props.base_url = "onlyoffice/";
define("sdk", sdk_deps, function () {
});
}
app_url = g.props.base_url + app_url;
function loadScript(src) {
return new RSVP.Promise(function (resolve, reject) {
var s;
s = document.createElement('script');
s.src = src;
s.onload = resolve;
s.onerror = reject;
document.head.appendChild(s);
});
}
return loadScript(app_url);
})
.push(undefined, function (error) {
display_error(g, error);
});
})
.declareMethod('getContent', function () {
var g = this,
zip = g.props.value_zip_storage,
queue = new RSVP.Queue(),
save_defer = RSVP.defer();
g.props.save_defer = save_defer;
g.props.handlers.save();
return queue.push(function () {
return save_defer.promise;
})
.push(function (data) {
if (data) {
var body = data[g.props.key];
return zip.putAttachment('/', 'body.txt', body);
}
})
.push(function () {
return zip.getAttachment('/', '/');
})
.push(function (zip_blob) {
return jIO.util.readBlobAsDataURL(zip_blob);
})
.push(function (evt) {
var data = {};
data[g.props.key] = evt.target.result;
return data;
});
});
}(rJS, RSVP, require, jIO));
\ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
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