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
This diff is collapsed.
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