2018-02-27 05:18:36 -06:00
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// pgAdmin 4 - PostgreSQL Tools
|
|
|
|
//
|
2019-01-02 04:24:12 -06:00
|
|
|
// Copyright (C) 2013 - 2019, The pgAdmin Development Team
|
2018-02-27 05:18:36 -06:00
|
|
|
// This software is released under the PostgreSQL Licence
|
|
|
|
//
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2018-07-25 01:40:46 -05:00
|
|
|
import _ from 'underscore';
|
|
|
|
|
2018-02-27 05:18:36 -06:00
|
|
|
export function parseShortcutValue(obj) {
|
|
|
|
var shortcut = '';
|
|
|
|
if (obj.alt) { shortcut += 'alt+'; }
|
|
|
|
if (obj.shift) { shortcut += 'shift+'; }
|
|
|
|
if (obj.control) { shortcut += 'ctrl+'; }
|
2018-05-02 01:13:42 -05:00
|
|
|
shortcut += obj.key.char.toLowerCase();
|
2018-02-27 05:18:36 -06:00
|
|
|
return shortcut;
|
|
|
|
}
|
|
|
|
|
|
|
|
export function findAndSetFocus(container) {
|
|
|
|
if (container.length == 0) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
setTimeout(function() {
|
|
|
|
var first_el = container
|
|
|
|
.find('button.fa-plus:first');
|
|
|
|
|
|
|
|
if (first_el.length == 0) {
|
|
|
|
first_el = container
|
|
|
|
.find('.pgadmin-controls:first>input:enabled,.CodeMirror-scroll');
|
|
|
|
}
|
|
|
|
|
|
|
|
if(first_el.length > 0) {
|
|
|
|
first_el[0].focus();
|
|
|
|
} else {
|
|
|
|
container[0].focus();
|
|
|
|
}
|
|
|
|
}, 200);
|
|
|
|
}
|
2018-07-25 01:40:46 -05:00
|
|
|
|
|
|
|
let isValidData = (data) => (!_.isUndefined(data) && !_.isNull(data));
|
|
|
|
let isFunction = (fn) => (_.isFunction(fn));
|
|
|
|
let isString = (str) => (_.isString(str));
|
|
|
|
|
|
|
|
export {
|
|
|
|
isValidData, isFunction, isString,
|
|
|
|
};
|