style: Spaces to tabs, missing semicolons

This commit is contained in:
Faris Ansari 2019-06-28 14:06:09 +05:30
parent 057a7e21a1
commit c2ad767887
5 changed files with 74 additions and 74 deletions

View file

@ -272,7 +272,7 @@ frappe.ui.form.ControlTextEditor = frappe.ui.form.ControlCode.extend({
return +className.replace(/[^\d]/g, '');
},
set_focus() {
this.quill.focus();
}
set_focus() {
this.quill.focus();
}
});

View file

@ -754,65 +754,65 @@ frappe.views.ListView = class ListView extends frappe.views.BaseList {
this.setup_like();
this.setup_realtime_updates();
this.setup_action_handler();
this.setup_keyboard_navigation();
}
this.setup_keyboard_navigation();
}
setup_keyboard_navigation() {
let focus_first_row = () => {
this.$result.find('.list-row-container:first').focus();
}
let focus_next = () => {
$(document.activeElement).next().focus();
}
let focus_prev = () => {
$(document.activeElement).prev().focus();
}
let list_row_focused = () => {
return $(document.activeElement).is('.list-row-container');
}
let check_row = ($row) => {
let $input = $row.find('input[type=checkbox]');
$input.click();
}
setup_keyboard_navigation() {
let focus_first_row = () => {
this.$result.find('.list-row-container:first').focus();
};
let focus_next = () => {
$(document.activeElement).next().focus();
};
let focus_prev = () => {
$(document.activeElement).prev().focus();
};
let list_row_focused = () => {
return $(document.activeElement).is('.list-row-container');
};
let check_row = ($row) => {
let $input = $row.find('input[type=checkbox]');
$input.click();
};
$(document).on('keydown', (e) => {
let { UP, DOWN, ENTER, SPACE } = frappe.ui.keyCode;
let key = frappe.ui.keys.get_key(e);
if (![UP, DOWN, ENTER, SPACE].includes(e.which)) return;
if (!this.page.wrapper.is(':visible')) return;
let $list_row = list_row_focused() ? $(document.activeElement) : null;
$(document).on('keydown', (e) => {
let { UP, DOWN, ENTER, SPACE } = frappe.ui.keyCode;
let key = frappe.ui.keys.get_key(e);
if (![UP, DOWN, ENTER, SPACE].includes(e.which)) return;
if (!this.page.wrapper.is(':visible')) return;
let $list_row = list_row_focused() ? $(document.activeElement) : null;
if ([UP, DOWN].includes(e.which)) {
e.preventDefault();
if ([UP, DOWN].includes(e.which)) {
e.preventDefault();
if (!$list_row) {
focus_first_row();
} else {
if (key === 'shift+down') {
check_row($list_row);
focus_next();
} else if (key === 'shift+up') {
check_row($list_row);
focus_prev();
} else if (key === 'down') {
focus_next();
} else if (key === 'up') {
focus_prev();
}
}
return;
}
if (!$list_row) {
focus_first_row();
} else {
if (key === 'shift+down') {
check_row($list_row);
focus_next();
} else if (key === 'shift+up') {
check_row($list_row);
focus_prev();
} else if (key === 'down') {
focus_next();
} else if (key === 'up') {
focus_prev();
}
}
return;
}
if ($list_row) {
e.preventDefault();
if (key === 'enter') {
$list_row.find('a[data-name]')[0].click();
} else if (key === 'space') {
check_row($list_row);
}
}
});
}
if ($list_row) {
e.preventDefault();
if (key === 'enter') {
$list_row.find('a[data-name]')[0].click();
} else if (key === 'space') {
check_row($list_row);
}
}
});
}
setup_filterable() {
// filterable events

View file

@ -43,11 +43,11 @@ frappe.ui.keys.bind_shortcut_group_event = () => {
}
if (key && e.altKey) {
let shortcut = get_shortcut_for_key(key);
if (shortcut) {
e.preventDefault();
shortcut.$target[0].click();
}
let shortcut = get_shortcut_for_key(key);
if (shortcut) {
e.preventDefault();
shortcut.$target[0].click();
}
highlight_alt_shortcuts();
}
});
@ -69,7 +69,7 @@ function get_shortcut_for_key(key) {
let shortcuts = shortcut_group_list
.filter(shortcut_group => key in shortcut_group.shortcuts_dict)
.map(shortcut_group => shortcut_group.shortcuts_dict[key])
.filter(shortcut => shortcut.$target.is(':visible'))
.filter(shortcut => shortcut.$target.is(':visible'));
let shortcut = null;
@ -164,7 +164,7 @@ frappe.ui.keys.AltShortcutGroup = class AltShortcutGroup {
is_taken(letter) {
let is_in_global_shortcut = frappe.ui.keys.standard_shortcuts
.filter(s => !s.page)
.some(s => s.shortcut === `alt+${letter}`);
.some(s => s.shortcut === `alt+${letter}`);
return letter in this.shortcuts_dict || is_in_global_shortcut;
}
}
};

View file

@ -154,11 +154,11 @@ frappe.ui.keys.add_shortcut('alt+h', function(e) {
}, __('Help'));
frappe.ui.keys.on('escape', function(e) {
close_grid_and_dialog();
close_grid_and_dialog();
});
frappe.ui.keys.on('esc', function(e) {
close_grid_and_dialog();
close_grid_and_dialog();
});
frappe.ui.keys.on('enter', function(e) {
@ -177,7 +177,7 @@ frappe.ui.keys.on('ctrl+up', function(e) {
grid_row && grid_row.toggle_view(false, function() { grid_row.open_prev() });
});
frappe.ui.keys.add_shortcut('shift+ctrl+r', function(e) {
frappe.ui.keys.add_shortcut('shift+ctrl+r', function() {
frappe.ui.toolbar.clear_cache();
}, __('Clear Cache and Reload'));
@ -238,7 +238,7 @@ function close_grid_and_dialog() {
// blur when escape is pressed on dropdowns
$(document).on('keydown', '.dropdown-toggle', (e) => {
if (e.which === frappe.ui.keyCode.ESCAPE) {
$(e.currentTarget).blur();
}
})
if (e.which === frappe.ui.keyCode.ESCAPE) {
$(e.currentTarget).blur();
}
});

View file

@ -130,9 +130,9 @@ frappe.ui.Page = Class.extend({
let menu_btn = this.menu_btn_group.find('button');
frappe.ui.keys
.get_shortcut_group(this.page_actions[0])
.add(menu_btn, menu_btn.find('.menu-btn-group-label'));
.add(menu_btn, menu_btn.find('.menu-btn-group-label'));
let action_btn = this.actions_btn_group.find('button');
let action_btn = this.actions_btn_group.find('button');
frappe.ui.keys
.get_shortcut_group(this.page_actions[0])
.add(action_btn, action_btn.find('.actions-btn-group-label'));