Commit 06a5c330 authored by Julia Radzhabova's avatar Julia Radzhabova

Change api event: "onReady" -> "onAppReady", added "onDocumentReady" event.

parent 1fbf9c9e
...@@ -131,9 +131,11 @@ ...@@ -131,9 +131,11 @@
} }
}, },
events: { events: {
'onReady': <document ready callback>, 'onReady': <application ready callback>, // deprecated
'onAppReady': <application ready callback>,
'onBack': <back to folder callback>, 'onBack': <back to folder callback>,
'onDocumentStateChange': <document state changed callback> 'onDocumentStateChange': <document state changed callback>
'onDocumentReady': <document ready callback>
} }
} }
...@@ -164,9 +166,11 @@ ...@@ -164,9 +166,11 @@
} }
}, },
events: { events: {
'onReady': <document ready callback>, 'onReady': <application ready callback>, // deprecated
'onAppReady': <application ready callback>,
'onBack': <back to folder callback>, 'onBack': <back to folder callback>,
'onError': <error callback>, 'onError': <error callback>,
'onDocumentReady': <document ready callback>
} }
} }
*/ */
...@@ -205,7 +209,7 @@ ...@@ -205,7 +209,7 @@
} }
}; };
var _onReady = function() { var _onAppReady = function() {
if (_config.type === 'mobile') { if (_config.type === 'mobile') {
document.body.onfocus = function(e) { document.body.onfocus = function(e) {
setTimeout(function(){ setTimeout(function(){
...@@ -275,8 +279,8 @@ ...@@ -275,8 +279,8 @@
} else if (msg.event === 'onInternalMessage' && msg.data && msg.data.type == 'localstorage') { } else if (msg.event === 'onInternalMessage' && msg.data && msg.data.type == 'localstorage') {
_callLocalStorage(msg.data.data); _callLocalStorage(msg.data.data);
} else { } else {
if (msg.event === 'onReady') { if (msg.event === 'onAppReady') {
_onReady(); _onAppReady();
} }
if (handler) { if (handler) {
......
...@@ -138,8 +138,9 @@ if (Common === undefined) { ...@@ -138,8 +138,9 @@ if (Common === undefined) {
return { return {
ready: function() { appReady: function() {
_postMessage({ event: 'onReady' }); _postMessage({ event: 'onReady' });
_postMessage({ event: 'onAppReady' });
}, },
requestEditRights: function() { requestEditRights: function() {
...@@ -236,6 +237,10 @@ if (Common === undefined) { ...@@ -236,6 +237,10 @@ if (Common === undefined) {
_postMessage({event: 'onMetaChange', data: meta}); _postMessage({event: 'onMetaChange', data: meta});
}, },
documentReady: function() {
_postMessage({ event: 'onDocumentReady' });
},
on: function(event, handler){ on: function(event, handler){
var localHandler = function(event, data){ var localHandler = function(event, data){
handler.call(me, data) handler.call(me, data)
......
...@@ -77,7 +77,7 @@ define([ ...@@ -77,7 +77,7 @@ define([
user : {id: ('uid-'+Date.now())} user : {id: ('uid-'+Date.now())}
}, },
events: { events: {
'onReady' : function() {}, 'onAppReady' : function() {},
'onDocumentStateChange' : function() {}, 'onDocumentStateChange' : function() {},
'onError' : function() {}, 'onError' : function() {},
'onInternalMessage' : _.bind(this.onInternalMessage, this) 'onInternalMessage' : _.bind(this.onInternalMessage, this)
......
...@@ -77,7 +77,7 @@ define([ ...@@ -77,7 +77,7 @@ define([
user : {id: ('uid-'+Date.now())} user : {id: ('uid-'+Date.now())}
}, },
events: { events: {
'onReady' : function() {}, 'onAppReady' : function() {},
'onDocumentStateChange' : function() {}, 'onDocumentStateChange' : function() {},
'onError' : function() {}, 'onError' : function() {},
'onInternalMessage' : _.bind(this.onInternalMessage, this) 'onInternalMessage' : _.bind(this.onInternalMessage, this)
......
...@@ -209,6 +209,8 @@ var ApplicationController = new(function(){ ...@@ -209,6 +209,8 @@ var ApplicationController = new(function(){
} }
function onDocumentContentReady() { function onDocumentContentReady() {
Common.Gateway.documentReady();
hidePreloader(); hidePreloader();
if ( !embedConfig.shareUrl ) if ( !embedConfig.shareUrl )
...@@ -498,7 +500,7 @@ var ApplicationController = new(function(){ ...@@ -498,7 +500,7 @@ var ApplicationController = new(function(){
Common.Gateway.on('init', loadConfig); Common.Gateway.on('init', loadConfig);
Common.Gateway.on('opendocument', loadDocument); Common.Gateway.on('opendocument', loadDocument);
Common.Gateway.on('showmessage', onExternalMessage); Common.Gateway.on('showmessage', onExternalMessage);
Common.Gateway.ready(); Common.Gateway.appReady();
} }
return me; return me;
......
...@@ -172,7 +172,7 @@ define([ ...@@ -172,7 +172,7 @@ define([
Common.Gateway.on('init', _.bind(this.loadConfig, this)); Common.Gateway.on('init', _.bind(this.loadConfig, this));
Common.Gateway.on('showmessage', _.bind(this.onExternalMessage, this)); Common.Gateway.on('showmessage', _.bind(this.onExternalMessage, this));
Common.Gateway.on('opendocument', _.bind(this.loadDocument, this)); Common.Gateway.on('opendocument', _.bind(this.loadDocument, this));
Common.Gateway.ready(); Common.Gateway.appReady();
// $(window.top).resize(_.bind(this.onDocumentResize, this)); // $(window.top).resize(_.bind(this.onDocumentResize, this));
this.getApplication().getController('Viewport').setApi(this.api); this.getApplication().getController('Viewport').setApi(this.api);
...@@ -749,6 +749,8 @@ define([ ...@@ -749,6 +749,8 @@ define([
if (this._isDocReady) if (this._isDocReady)
return; return;
Common.Gateway.documentReady();
var me = this, var me = this,
value; value;
......
...@@ -167,7 +167,7 @@ define([ ...@@ -167,7 +167,7 @@ define([
Common.Gateway.on('init', _.bind(me.loadConfig, me)); Common.Gateway.on('init', _.bind(me.loadConfig, me));
Common.Gateway.on('showmessage', _.bind(me.onExternalMessage, me)); Common.Gateway.on('showmessage', _.bind(me.onExternalMessage, me));
Common.Gateway.on('opendocument', _.bind(me.loadDocument, me)); Common.Gateway.on('opendocument', _.bind(me.loadDocument, me));
Common.Gateway.ready(); Common.Gateway.appReady();
} }
}, },
...@@ -457,6 +457,8 @@ define([ ...@@ -457,6 +457,8 @@ define([
if (this._isDocReady) if (this._isDocReady)
return; return;
Common.Gateway.documentReady();
if (this._state.openDlg) if (this._state.openDlg)
uiApp.closeModal(this._state.openDlg); uiApp.closeModal(this._state.openDlg);
......
...@@ -211,6 +211,8 @@ var ApplicationController = new(function(){ ...@@ -211,6 +211,8 @@ var ApplicationController = new(function(){
} }
function onDocumentContentReady() { function onDocumentContentReady() {
Common.Gateway.documentReady();
api.ShowThumbnails(false); api.ShowThumbnails(false);
api.asc_DeleteVerticalScroll(); api.asc_DeleteVerticalScroll();
...@@ -574,7 +576,7 @@ var ApplicationController = new(function(){ ...@@ -574,7 +576,7 @@ var ApplicationController = new(function(){
Common.Gateway.on('init', loadConfig); Common.Gateway.on('init', loadConfig);
Common.Gateway.on('opendocument', loadDocument); Common.Gateway.on('opendocument', loadDocument);
Common.Gateway.on('showmessage', onExternalMessage); Common.Gateway.on('showmessage', onExternalMessage);
Common.Gateway.ready(); Common.Gateway.appReady();
} }
return me; return me;
......
...@@ -172,7 +172,7 @@ define([ ...@@ -172,7 +172,7 @@ define([
Common.Gateway.on('init', _.bind(this.loadConfig, this)); Common.Gateway.on('init', _.bind(this.loadConfig, this));
Common.Gateway.on('showmessage', _.bind(this.onExternalMessage, this)); Common.Gateway.on('showmessage', _.bind(this.onExternalMessage, this));
Common.Gateway.on('opendocument', _.bind(this.loadDocument, this)); Common.Gateway.on('opendocument', _.bind(this.loadDocument, this));
Common.Gateway.ready(); Common.Gateway.appReady();
this.getApplication().getController('Viewport').setApi(this.api); this.getApplication().getController('Viewport').setApi(this.api);
this.getApplication().getController('Statusbar').setApi(me.api); this.getApplication().getController('Statusbar').setApi(me.api);
...@@ -555,6 +555,8 @@ define([ ...@@ -555,6 +555,8 @@ define([
if (this._isDocReady) if (this._isDocReady)
return; return;
Common.Gateway.documentReady();
var me = this, var me = this,
value; value;
......
...@@ -168,7 +168,7 @@ define([ ...@@ -168,7 +168,7 @@ define([
Common.Gateway.on('init', _.bind(me.loadConfig, me)); Common.Gateway.on('init', _.bind(me.loadConfig, me));
Common.Gateway.on('showmessage', _.bind(me.onExternalMessage, me)); Common.Gateway.on('showmessage', _.bind(me.onExternalMessage, me));
Common.Gateway.on('opendocument', _.bind(me.loadDocument, me)); Common.Gateway.on('opendocument', _.bind(me.loadDocument, me));
Common.Gateway.ready(); Common.Gateway.appReady();
} }
me.initNames(); me.initNames();
...@@ -443,6 +443,8 @@ define([ ...@@ -443,6 +443,8 @@ define([
if (this._isDocReady) if (this._isDocReady)
return; return;
Common.Gateway.documentReady();
if (this._state.openDlg) if (this._state.openDlg)
uiApp.closeModal(this._state.openDlg); uiApp.closeModal(this._state.openDlg);
......
...@@ -166,6 +166,8 @@ var ApplicationController = new(function(){ ...@@ -166,6 +166,8 @@ var ApplicationController = new(function(){
} }
function onDocumentContentReady() { function onDocumentContentReady() {
Common.Gateway.documentReady();
hidePreloader(); hidePreloader();
if ( !embedConfig.shareUrl ) if ( !embedConfig.shareUrl )
...@@ -520,7 +522,7 @@ var ApplicationController = new(function(){ ...@@ -520,7 +522,7 @@ var ApplicationController = new(function(){
Common.Gateway.on('init', loadConfig); Common.Gateway.on('init', loadConfig);
Common.Gateway.on('opendocument', loadDocument); Common.Gateway.on('opendocument', loadDocument);
Common.Gateway.on('showmessage', onExternalMessage); Common.Gateway.on('showmessage', onExternalMessage);
Common.Gateway.ready(); Common.Gateway.appReady();
} }
return me; return me;
......
...@@ -180,7 +180,7 @@ define([ ...@@ -180,7 +180,7 @@ define([
Common.Gateway.on('showmessage', _.bind(this.onExternalMessage, this)); Common.Gateway.on('showmessage', _.bind(this.onExternalMessage, this));
Common.Gateway.on('opendocument', _.bind(this.loadDocument, this)); Common.Gateway.on('opendocument', _.bind(this.loadDocument, this));
Common.Gateway.on('internalcommand', _.bind(this.onInternalCommand, this)); Common.Gateway.on('internalcommand', _.bind(this.onInternalCommand, this));
Common.Gateway.ready(); Common.Gateway.appReady();
this.getApplication().getController('Viewport').setApi(this.api); this.getApplication().getController('Viewport').setApi(this.api);
...@@ -555,6 +555,8 @@ define([ ...@@ -555,6 +555,8 @@ define([
if (this._isDocReady) if (this._isDocReady)
return; return;
Common.Gateway.documentReady();
var me = this, var me = this,
value; value;
......
...@@ -174,7 +174,7 @@ define([ ...@@ -174,7 +174,7 @@ define([
Common.Gateway.on('init', _.bind(me.loadConfig, me)); Common.Gateway.on('init', _.bind(me.loadConfig, me));
Common.Gateway.on('showmessage', _.bind(me.onExternalMessage, me)); Common.Gateway.on('showmessage', _.bind(me.onExternalMessage, me));
Common.Gateway.on('opendocument', _.bind(me.loadDocument, me)); Common.Gateway.on('opendocument', _.bind(me.loadDocument, me));
Common.Gateway.ready(); Common.Gateway.appReady();
} }
}, },
...@@ -455,6 +455,8 @@ define([ ...@@ -455,6 +455,8 @@ define([
if (this._isDocReady) if (this._isDocReady)
return; return;
Common.Gateway.documentReady();
if (this._state.openDlg) if (this._state.openDlg)
uiApp.closeModal(this._state.openDlg); uiApp.closeModal(this._state.openDlg);
......
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