1
/*##############################################################################
3
# OpenERP, Open Source Management Solution
4
# Copyright (c) 2010-2012 Elico Corp. All Rights Reserved.
5
# Author: Yannick Gouin <yannick.gouin@elico-corp.com>
7
# This program is free software: you can redistribute it and/or modify
8
# it under the terms of the GNU General Public License as published by
9
# the Free Software Foundation, either version 3 of the License, or
10
# (at your option) any later version.
12
# This program is distributed in the hope that it will be useful,
13
# but WITHOUT ANY WARRANTY; without even the implied warranty of
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
# GNU General Public License for more details.
17
# You should have received a copy of the GNU General Public License
18
# along with this program. If not, see <http://www.gnu.org/licenses/>.
20
##############################################################################
24
/* some keys cannot be overriden, for example
25
* "There is no way to override CTRL-N, CTRL-T, or CTRL-W in Google Chrome since
26
* version 4 of Chrome (shipped in 2010)."
29
$.ctrlshift = function(key, callback, args) {
30
$(document).keydown(function(e) {
31
if(!args) args=[]; // IE barks when args is null
32
if((e.keyCode == key.charCodeAt(0) || e.keyCode == key) && e.ctrlKey && e.shiftKey) {
33
e.preventDefault(); // override the browser shortcut keys
34
callback.apply(this, args);
40
fake_click = function(button) {
41
if($(button).parents('div:hidden').length == 0){
42
if (button.hasAttribute('onclick')) {
46
$(button).trigger('click');
51
//Save the current object
52
$.ctrlshift('S', function() {
54
$('.oe_form_button_save_line').each(function() {
55
if($(this).parents('div:hidden').length == 0){
57
saved = true; // if a line is under edition, save only this line, not the whole object
60
$('.oe_form_button_save_close').each(function() {
61
if(!saved && $(this).parents('div:hidden').length == 0){
66
$('.oe_form_button_save').each(function() {
71
//Save & Edit the current object
72
$.ctrlshift('E', function() {
73
$('.oe_form_button_save_edit').each(function() {
76
$('.oe_form_button_edit').each(function() {
81
//Delete the current object
82
$.ctrlshift('46', function() {
83
$('.oe_form_button_delete').each(function() {
88
//Cancel the modifiactions
89
$.ctrlshift('Z', function() {
90
$('.oe_form_button_cancel').each(function() {
96
$.ctrlshift('C', function() {
97
$('.oe_form_button_create').each(function() {
100
$('.oe_form_button_save_create').each(function() {
105
//Duplicate the current object
106
$.ctrlshift('D', function() {
107
$('.oe_form_button_duplicate').each(function() {
113
$.ctrlshift('13', function() {
114
$('.oe_form_button_search').each(function() {
120
$.ctrlshift('R', function() {
121
$('.oe_form_button_clear').each(function() {
126
//First object (arrow up)
127
$.ctrlshift('38', function(event) {
128
$('.oe_button_pager[action="first"]').each(function() {
133
//Previous object (arrow right)
134
$.ctrlshift('37', function() {
135
$('.oe_button_pager[action="previous"]').each(function() {
140
//Next object (arrow left)
141
$.ctrlshift('39', function() {
142
$('.oe_button_pager[action="next"]').each(function() {
147
//Last object (arrow down)
148
$.ctrlshift('40', function() {
149
$('.oe_button_pager[action="last"]').each(function() {
155
$.ctrlshift('Q', function() {
156
$('.oe_form_button_close').each(function() {