Merge lp:~openerp-dev/openerp-web/trunk-improve-shortcutkeys-bth into lp:openerp-web

Proposed by Bhumi Thakkar (Open ERP)
Status: Needs review
Proposed branch: lp:~openerp-dev/openerp-web/trunk-improve-shortcutkeys-bth
Merge into: lp:openerp-web
Diff against target: 226 lines (+139/-9)
5 files modified
addons/web/static/src/css/base.css (+3/-1)
addons/web/static/src/css/base.sass (+4/-0)
addons/web/static/src/js/chrome.js (+124/-0)
addons/web/static/src/xml/base.xml (+6/-6)
addons/web_kanban/static/src/xml/web_kanban.xml (+2/-2)
To merge this branch: bzr merge lp:~openerp-dev/openerp-web/trunk-improve-shortcutkeys-bth
Reviewer Review Type Date Requested Status
OpenERP R&D Web Team Pending
Review via email: mp+178266@code.launchpad.net

Description of the change

Hello,

    Highlight shortcut keys by underline when press alt key.
Added shortcut keys for following:

1. Switch view (k - kanban, l - list, f - form, r - calendar, g - graph, n - gantt)
2. Formview Buttons, Listview header buttons, Kanbanview header buttons, Gantt header buttons
3. Pager on Formview ('<' - previous record & '>' - next record)
4. Sidebar buttons (p - Print, m - more, a - attachments)

Thanks.

To post a comment you must log in.
3794. By Bhumi Thakkar (Open ERP)

[IMP]If index is less than button's text's length then add accesskey into element.

Unmerged revisions

3794. By Bhumi Thakkar (Open ERP)

[IMP]If index is less than button's text's length then add accesskey into element.

3793. By Bhumi Thakkar (Open ERP)

[IMP]Improved code because on presskey event first-letter not working with firefox browser.

3792. By Bhumi Thakkar (Open ERP)

[MERGE]Merge lp:openerp-web.

3791. By Bhumi Thakkar (Open ERP)

[IMP]Improved code and add shortcuts for sidebar buttons.

3790. By Bhumi Thakkar (Open ERP)

[IMP]Add shortcut keys for throughout.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'addons/web/static/src/css/base.css'
2--- addons/web/static/src/css/base.css 2013-07-02 14:53:52 +0000
3+++ addons/web/static/src/css/base.css 2013-08-02 11:28:27 +0000
4@@ -3210,7 +3210,9 @@
5 float: right;
6 color: #333333;
7 }
8-
9+.accesshighlight:first-letter, .highlight {
10+ text-decoration: underline;
11+}
12 @-moz-document url-prefix() {
13 .openerp .oe_view_manager .oe_view_manager_switch li {
14 line-height: 21px;
15
16=== modified file 'addons/web/static/src/css/base.sass'
17--- addons/web/static/src/css/base.sass 2013-07-02 14:53:52 +0000
18+++ addons/web/static/src/css/base.sass 2013-08-02 11:28:27 +0000
19@@ -2531,6 +2531,10 @@
20 float: right
21 color: #333
22 // }}}
23+
24+.accesshighlight:first-letter, .highlight
25+ text-decoration: underline
26+
27 @-moz-document url-prefix()
28 .openerp
29 .oe_view_manager .oe_view_manager_switch li
30
31=== modified file 'addons/web/static/src/js/chrome.js'
32--- addons/web/static/src/js/chrome.js 2013-07-25 10:33:01 +0000
33+++ addons/web/static/src/js/chrome.js 2013-08-02 11:28:27 +0000
34@@ -5,6 +5,130 @@
35 var QWeb = instance.web.qweb,
36 _t = instance.web._t;
37
38+$(document).keydown(function(e) {
39+ if (e.keyCode === 18 || e.keycode === 16 && e.altkey || e.keyCode == 18 && e.shiftKey) {
40+ highlightAccessKeys();
41+ }
42+}).keyup(function() {
43+ unhighlightAccessKeys();
44+});
45+/* replace character with span tag into exist element */
46+function replaceHtml(key, el) {
47+ $(el).html($(el).text().replace(key, '<span class ="highlight">' + key + '</span>'))
48+}
49+/*
50+ * find accesskey is assigned to anyother element. if assigned then find nextone character else assign.
51+ * */
52+function addkey(key, el, index, flag) {
53+ if ($.inArray(key,this.keys) == -1) {
54+ $(el).attr('accesskey', key);
55+ if (index == 0) {
56+ replaceHtml($(el).attr('accesskey').toUpperCase(), el);
57+ } else {
58+ if (flag) keyval = key;
59+ else keyval = key.toLowerCase();
60+ replaceHtml(keyval, el);
61+ }
62+ this.keys.push(key);
63+ } else {
64+ index++;
65+ val = $(el).text().replace(/\s/g, '').charAt(index);
66+ conval = $(el).text().replace(/\s/g, '').charAt(index).toUpperCase();
67+ key = $(el).text().replace(/\s/g, '').charAt(index).toUpperCase();
68+ if(index < ($.trim($(el).text()).length + 1)){
69+ addkey(key, el, index, val == conval);
70+ }
71+ }
72+}
73+/*
74+ * highlightAccesskeys() - find element which has accesskey attribute and also element which has to assign accesskey attribute
75+ * */
76+function highlightAccessKeys() {
77+ var keys = [];
78+ // accesskey for switch view
79+ _.each($('.oe_view_manager_current > table').find('ul.oe_view_manager_switch li'), function (el) {
80+ if ($(el).find('a').data('view-type') == 'kanban') {
81+ $(el).find('a').attr('accesskey', 'k');
82+ $(el).addClass('highlight');
83+ keys.push('K');
84+ } else if ($(el).find('a').data('view-type') == 'list') {
85+ $(el).find('a').attr('accesskey', 'l');
86+ $(el).addClass('highlight');
87+ keys.push('L');
88+ } else if ($(el).find('a').data('view-type') == 'form') {
89+ $(el).find('a').attr('accesskey', 'f');
90+ $(el).addClass('highlight');
91+ keys.push('F');
92+ } else if ($(el).find('a').data('view-type') == 'calendar') {
93+ $(el).find('a').attr('accesskey', 'r');
94+ $(el).addClass('highlight');
95+ keys.push('R');
96+ } else if ($(el).find('a').data('view-type') == 'graph') {
97+ $(el).find('a').attr('accesskey', 'g');
98+ $(el).addClass('highlight');
99+ keys.push('G');
100+ } else if ($(el).find('a').data('view-type') == 'gantt') {
101+ $(el).find('a').attr('accesskey', 'n');
102+ $(el).addClass('highlight');
103+ keys.push('N');
104+ }
105+ });
106+ // accesskey for pager
107+ _.each($('ul.oe_pager_group:visible li'), function (el) {
108+ if ($(el).find('a').data('pager-action') == 'previous'){
109+ $(el).find('a').attr('accesskey','<');
110+ }else {
111+ $(el).find('a').attr('accesskey','>');
112+ }
113+ });
114+
115+ // accesskey for header
116+ $hedaer = $('.oe_view_manager_current > table');
117+
118+ _.each($($hedaer).find('.oe_view_manager_buttons > div'), function(el) {
119+ if ($(el).css('display') == 'block') {
120+ if ($('a.oe_kanban_add_column:visible').length == 0){
121+ $('a.oe_kanban_add_column').removeAttr('accesskey')
122+ } else {
123+ $('a.oe_kanban_add_column:visible').attr('accesskey','a');
124+ }
125+ _.each($(el).find('button[accesskey]'), function (btn) {
126+ replaceHtml($(btn).attr('accesskey').toUpperCase(), btn);
127+ keys.push($(btn).attr('accesskey').toUpperCase())
128+ });
129+ _.each($(el).find('a[accesskey]:visible'), function ($a) {
130+ replaceHtml($($a).attr('accesskey').toUpperCase(), $a);
131+ keys.push($($a).attr('accesskey').toUpperCase())
132+ });
133+ }
134+ });
135+
136+ // sidebar menu
137+ _.each($hedaer.find('.oe_view_manager_sidebar').find('button[accesskey]'), function (el) {
138+ replaceHtml($(el).attr('accesskey').toUpperCase(), el);
139+ keys.push($(el).attr('accesskey'));
140+ });
141+
142+ this.keys = keys;
143+
144+ // accesskey for body
145+ _.each ($('.oe_view_manager_body > div:not(.oe_view_manager_view_kanban)'), function(el) {
146+ if ($(el).css('display') == 'block') {
147+ _.each($(el).find('button:not(.oe_form_invisible):visible'), function (el) {
148+ var index = 0;
149+ if (!$(el).hasClass('oe_follower') && !$(el).hasClass('oe_link') && !$(el).hasClass('oe_i')) {
150+ key = $(el).text().replace(/\s/g, '').charAt(0).toUpperCase();
151+ if (key)
152+ addkey(key, el, index);
153+ }
154+ });
155+ }
156+ });
157+}
158+function unhighlightAccessKeys() {
159+ $('span.highlight').removeClass('highlight');
160+ $('li.highlight').removeClass('highlight');
161+}
162 instance.web.Notification = instance.web.Widget.extend({
163 template: 'Notification',
164 init: function() {
165
166=== modified file 'addons/web/static/src/xml/base.xml'
167--- addons/web/static/src/xml/base.xml 2013-07-25 15:31:14 +0000
168+++ addons/web/static/src/xml/base.xml 2013-08-02 11:28:27 +0000
169@@ -621,7 +621,7 @@
170 <div class="oe_sidebar">
171 <t t-foreach="widget.sections" t-as="section">
172 <div class="oe_form_dropdown_section">
173- <button class="oe_dropdown_toggle oe_dropdown_arrow">
174+ <button class="oe_dropdown_toggle oe_dropdown_arrow" t-att-accesskey="section.label[0]">
175 <t t-if="section.name == 'files'" t-raw="widget.items[section.name].length || ''"/>
176 <t t-esc="section.label"/>
177 </button>
178@@ -747,7 +747,7 @@
179 <t t-name="ListView.buttons">
180 <div class="oe_list_buttons">
181 <t t-if="!widget.no_leaf and widget.options.action_buttons !== false and widget.options.addable and widget.is_action_enabled('create')">
182- <button type="button" class="oe_button oe_list_add oe_highlight">
183+ <button type="button" class="oe_button oe_list_add oe_highlight" accesskey="c">
184 <t t-esc="widget.options.addable"/>
185 </button>
186 </t>
187@@ -828,15 +828,15 @@
188 <span class="oe_form_buttons_view">
189 <!-- required for the bounce effect on button -->
190 <div t-if="widget.is_action_enabled('edit')" style="display: inline-block;">
191- <button type="button" class="oe_button oe_form_button_edit" accesskey="E">Edit</button>
192+ <button type="button" class="oe_button oe_form_button_edit" accesskey="e">Edit</button>
193 </div>
194 <button t-if="widget.is_action_enabled('create')"
195- type="button" class="oe_button oe_form_button_create" accesskey="C">Create</button>
196+ type="button" class="oe_button oe_form_button_create" accesskey="c">Create</button>
197 </span>
198 <span class="oe_form_buttons_edit">
199- <button type="button" class="oe_button oe_form_button_save oe_highlight" accesskey="S">Save</button>
200+ <button type="button" class="oe_button oe_form_button_save oe_highlight" accesskey="s">Save</button>
201 <span class="oe_fade">or</span>
202- <a href="#" class="oe_bold oe_form_button_cancel" accesskey="D">Discard</a>
203+ <a href="#" class="oe_bold oe_form_button_cancel" accesskey="d">Discard</a>
204 </span>
205 </t>
206 </div>
207
208=== modified file 'addons/web_kanban/static/src/xml/web_kanban.xml'
209--- addons/web_kanban/static/src/xml/web_kanban.xml 2013-03-20 13:09:31 +0000
210+++ addons/web_kanban/static/src/xml/web_kanban.xml 2013-08-02 11:28:27 +0000
211@@ -15,13 +15,13 @@
212 <div t-name="KanbanView.buttons" class="oe_kanban_buttons">
213 <t t-if="widget.options.action_buttons !== false">
214 <t t-if="widget.is_action_enabled('create')">
215- <button type="button" class="oe_kanban_button_new oe_highlight">
216+ <button type="button" class="oe_kanban_button_new oe_highlight" accesskey="c">
217 <t t-esc="widget.options.create_text || _t('Create')"/>
218 </button>
219 <span class="oe_alternative" style="display: none">
220 <span class="oe_fade">or</span>
221 <div class="oe_bounce_container">
222- <a href="#" class="oe_bold oe_kanban_add_column">Add a new column</a>
223+ <a href="#" class="oe_bold oe_kanban_add_column" accesskey="a">Add a new column</a>
224 </div>
225 </span>
226 </t>