[common] debug

This commit is contained in:
Maxim Kadushkin 2020-07-31 20:34:55 +03:00
parent d1add672c5
commit 82dc591fd0
3 changed files with 66 additions and 7 deletions

View file

@ -31,8 +31,8 @@
* *
*/ */
if (Common === undefined) { if (window.Common === undefined) {
var Common = {}; window.Common = {};
} }
Common.Gateway = new(function() { Common.Gateway = new(function() {

View file

@ -37,7 +37,8 @@
*/ */
define([ define([
'core' 'core',
'backbone'
], function () { ], function () {
'use strict'; 'use strict';
@ -56,6 +57,16 @@ define([
'btn-save': 'save', 'btn-save': 'save',
'btn-save-coauth': 'coauth', 'btn-save-coauth': 'coauth',
'btn-synch': 'synch' }; 'btn-synch': 'synch' };
var _supported = [
Asc.c_oAscFileType.TXT,
Asc.c_oAscFileType.ODT,
Asc.c_oAscFileType.DOCX,
Asc.c_oAscFileType.HTML,
Asc.c_oAscFileType.PDF,
Asc.c_oAscFileType.PDFA,
Asc.c_oAscFileType.DOTX,
Asc.c_oAscFileType.OTT
];
if ( !!native ) { if ( !!native ) {
@ -141,6 +152,37 @@ define([
} }
}; };
window.onupdaterecents = function (params) {
var filemenu = webapp.getController('LeftMenu').getView('LeftMenu').getMenu('file');
if ( !filemenu.panels['recent'] ) {
var store = filemenu.panels['recent'].viewRecentPicker.store;
}
var _re_name = /([^\\/]+\.[a-zA-Z0-9]{3,})$/;
var _recent = [];
params.forEach(function(file) {
if ( _supported.includes(file.type) && _re_name.test(file.path) &&
store && !store.findWhere('id', file.id) )
{
var name = _re_name.exec(file.path)[1];
var model = {
url: file.path,
id: file.id,
title: name,
folder: file.path.slice(0, file.path.length - name.length - 1),
fileType: file.type,
};
_recent.push(model);
}
});
if ( _recent.length )
if ( !store )
filemenu.panels['recent'] = (new webapp.Views.FileMenuPanels.RecentFiles({menu:filemenu, recent: _recent})).render();
else store.add(_recent);
};
window.on_native_message('editor:config', 'request'); window.on_native_message('editor:config', 'request');
if ( !!window.native_message_cmd ) { if ( !!window.native_message_cmd ) {
for ( var c in window.native_message_cmd ) { for ( var c in window.native_message_cmd ) {
@ -207,6 +249,8 @@ define([
maincontroller.warningDocumentIsLocked(); maincontroller.warningDocumentIsLocked();
} }
} }
native.LocalFileRecents();
}); });
Common.NotificationCenter.on('action:undocking', function (opts) { Common.NotificationCenter.on('action:undocking', function (opts) {

View file

@ -38,7 +38,18 @@ if (Common.Utils === undefined) {
Common.Utils = {}; Common.Utils = {};
} }
Common.Utils = _.extend(new(function() { function _extend_object(dest, source) {
if ( typeof _ != "undefined" ) {
return _.extend({}, dest, source);
} else
if ( !!Object ) {
return Object.assign({}, dest, source);
}
return source;
}
var utils = new(function() {
var userAgent = navigator.userAgent.toLowerCase(), var userAgent = navigator.userAgent.toLowerCase(),
check = function(regex){ check = function(regex){
return regex.test(userAgent); return regex.test(userAgent);
@ -221,7 +232,9 @@ Common.Utils = _.extend(new(function() {
croppedGeometry: function() {return {left:0, top: Common.Utils.InternalSettings.get('window-inactive-area-top'), croppedGeometry: function() {return {left:0, top: Common.Utils.InternalSettings.get('window-inactive-area-top'),
width: me.innerWidth, height: me.innerHeight - Common.Utils.InternalSettings.get('window-inactive-area-top')}} width: me.innerWidth, height: me.innerHeight - Common.Utils.InternalSettings.get('window-inactive-area-top')}}
} }
})(), Common.Utils || {}); })();
Common.Utils = _extend_object(Common.Utils, utils);
Common.Utils.ThemeColor = new(function() { Common.Utils.ThemeColor = new(function() {
return { return {
@ -306,7 +319,7 @@ Common.Utils.ThemeColor = new(function() {
} }
})(); })();
Common.Utils.Metric = _.extend( new(function() { var metrics = new(function() {
var me = this; var me = this;
me.c_MetricUnits = { me.c_MetricUnits = {
@ -377,7 +390,9 @@ Common.Utils.Metric = _.extend( new(function() {
return value; return value;
} }
} }
})(), Common.Utils.Metric || {}); })();
Common.Utils.Metric = _extend_object(Common.Utils.Metric, metrics);
Common.Utils.RGBColor = function(colorString) { Common.Utils.RGBColor = function(colorString) {
var r, g, b; var r, g, b;