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