[desktop] refactoring
This commit is contained in:
parent
028c1bd42b
commit
8c5cf7e9f9
|
@ -384,8 +384,6 @@
|
|||
if (!_config.editorConfig.customization) _config.editorConfig.customization = {};
|
||||
_config.editorConfig.customization.about = false;
|
||||
_config.editorConfig.customization.compactHeader = false;
|
||||
|
||||
if ( window.AscDesktopEditor ) window.AscDesktopEditor.execCommand('webapps:events', 'loading');
|
||||
}
|
||||
}
|
||||
})();
|
||||
|
|
|
@ -41,10 +41,16 @@ define([
|
|||
], function () {
|
||||
'use strict';
|
||||
|
||||
var native = window.AscDesktopEditor;
|
||||
!!native && native.execCommand('webapps:features', JSON.stringify({
|
||||
version: '{{PRODUCT_VERSION}}',
|
||||
eventloading: true,
|
||||
titlebuttons: true
|
||||
}));
|
||||
|
||||
var Desktop = function () {
|
||||
var config = {version:'{{PRODUCT_VERSION}}'};
|
||||
var app = window.AscDesktopEditor,
|
||||
webapp = window.DE || window.PE || window.SSE;
|
||||
var webapp = window.DE || window.PE || window.SSE;
|
||||
var titlebuttons;
|
||||
var btnsave_icons = {
|
||||
'btn-save': 'save',
|
||||
|
@ -52,7 +58,7 @@ define([
|
|||
'btn-synch': 'synch' };
|
||||
|
||||
|
||||
if ( !!app ) {
|
||||
if ( !!native ) {
|
||||
window.on_native_message = function (cmd, param) {
|
||||
if (/^style:change/.test(cmd)) {
|
||||
var obj = JSON.parse(param);
|
||||
|
@ -104,7 +110,7 @@ define([
|
|||
}
|
||||
}
|
||||
|
||||
app.execCommand('editor:config', JSON.stringify(opts));
|
||||
native.execCommand('editor:config', JSON.stringify(opts));
|
||||
} else
|
||||
if ( !config.callback_editorconfig ) {
|
||||
config.callback_editorconfig = function() {
|
||||
|
@ -134,8 +140,7 @@ define([
|
|||
}
|
||||
}
|
||||
|
||||
// app.execCommand('window:features', {version: config.version, action: 'request'});
|
||||
app.execCommand('webapps:features', {version: config.version, eventloading:true, titlebuttons:true});
|
||||
native.execCommand('webapps:features', JSON.stringify({version: config.version, eventloading:true, titlebuttons:true}));
|
||||
}
|
||||
|
||||
var _serializeHeaderButton = function(action, config) {
|
||||
|
@ -151,23 +156,23 @@ define([
|
|||
titlebuttons[action].disabled = status;
|
||||
var _buttons = {};
|
||||
_buttons[action] = status;
|
||||
app.execCommand('title:button', JSON.stringify({disabled: _buttons}));
|
||||
native.execCommand('title:button', JSON.stringify({disabled: _buttons}));
|
||||
};
|
||||
|
||||
var _onSaveIconChanged = function (e, opts) {
|
||||
app.execCommand('title:button', JSON.stringify({'icon:changed': {'save': btnsave_icons[opts.next]}}));
|
||||
native.execCommand('title:button', JSON.stringify({'icon:changed': {'save': btnsave_icons[opts.next]}}));
|
||||
};
|
||||
|
||||
var _onModalDialog = function (status) {
|
||||
if ( status == 'open' ) {
|
||||
app.execCommand('title:button', JSON.stringify({disabled: {'all':true}}));
|
||||
native.execCommand('title:button', JSON.stringify({disabled: {'all':true}}));
|
||||
} else {
|
||||
var _buttons = {};
|
||||
for (var i in titlebuttons) {
|
||||
_buttons[i] = titlebuttons[i].disabled;
|
||||
}
|
||||
|
||||
app.execCommand('title:button', JSON.stringify({'disabled': _buttons}));
|
||||
native.execCommand('title:button', JSON.stringify({'disabled': _buttons}));
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -178,13 +183,13 @@ define([
|
|||
if ( config.isDesktopApp ) {
|
||||
Common.NotificationCenter.on('app:ready', function (opts) {
|
||||
_.extend(config, opts);
|
||||
!!app && app.execCommand('doc:onready', '');
|
||||
!!native && native.execCommand('doc:onready', '');
|
||||
|
||||
$('.toolbar').addClass('editor-native-color');
|
||||
});
|
||||
|
||||
Common.NotificationCenter.on('action:undocking', function (opts) {
|
||||
app.execCommand('editor:event', JSON.stringify({action:'undocking', state: opts == 'dock' ? 'dock' : 'undock'}));
|
||||
native.execCommand('editor:event', JSON.stringify({action:'undocking', state: opts == 'dock' ? 'dock' : 'undock'}));
|
||||
});
|
||||
|
||||
Common.NotificationCenter.on('app:face', function (mode) {
|
||||
|
@ -233,19 +238,19 @@ define([
|
|||
}
|
||||
},
|
||||
process: function (opts) {
|
||||
if ( config.isDesktopApp && !!app ) {
|
||||
if ( config.isDesktopApp && !!native ) {
|
||||
if ( opts == 'goback' ) {
|
||||
app.execCommand('go:folder',
|
||||
native.execCommand('go:folder',
|
||||
config.isOffline ? 'offline' : config.customization.goback.url);
|
||||
return true;
|
||||
} else
|
||||
if ( opts == 'preloader:hide' ) {
|
||||
app.execCommand('editor:onready', '');
|
||||
native.execCommand('editor:onready', '');
|
||||
return true;
|
||||
} else
|
||||
if ( opts == 'create:new' ) {
|
||||
if (config.createUrl == 'desktop://create.new') {
|
||||
app.LocalFileCreate(!!window.SSE ? 2 : !!window.PE ? 1 : 0);
|
||||
native.LocalFileCreate(!!window.SSE ? 2 : !!window.PE ? 1 : 0);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -254,8 +259,8 @@ define([
|
|||
return false;
|
||||
},
|
||||
requestClose: function () {
|
||||
if ( config.isDesktopApp && !!app ) {
|
||||
app.execCommand('editor:event', JSON.stringify({action:'close', url: config.customization.goback.url}));
|
||||
if ( config.isDesktopApp && !!native ) {
|
||||
native.execCommand('editor:event', JSON.stringify({action:'close', url: config.customization.goback.url}));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue