From c470df6de059f7ebe267fdae8bae3b638c721212 Mon Sep 17 00:00:00 2001 From: Vishmita Date: Mon, 5 Nov 2012 11:23:20 +0530 Subject: [PATCH 01/11] [FIX]Improve code bzr revid: vja@tinyerp.com-20121105055320-jrplij0m8y6y2m3e --- addons/web/static/src/css/base.css | 4 ++++ addons/web/static/src/css/base.sass | 12 ++++++++---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/addons/web/static/src/css/base.css b/addons/web/static/src/css/base.css index 059b51b183e..91793947836 100644 --- a/addons/web/static/src/css/base.css +++ b/addons/web/static/src/css/base.css @@ -475,6 +475,10 @@ max-width: 180px; max-height: 180px; } +.openerp .oe_view_manager_current a.accessactive { + display:inline-block; + text-decoration:none; +} .openerp .oe_view_manager_current .accessactive:first-letter{ text-decoration:underline; text-shadow: 0 1px 1px rgba(0, 0, 0, 0.2); diff --git a/addons/web/static/src/css/base.sass b/addons/web/static/src/css/base.sass index b96321a78f4..0c17735cf7b 100644 --- a/addons/web/static/src/css/base.sass +++ b/addons/web/static/src/css/base.sass @@ -437,10 +437,14 @@ $sheet-padding: 16px .oe_image_medium > img max-width: 180px max-height: 180px - .oe_view_manager_current .accessactive:first-letter - text-decoration: underline - text-shadow: 0 1px 1px rgba(0, 0, 0, 0.2) - font-weight: bold + .openerp .oe_view_manager_current + a.accessactive + display: inline-block + text-decoration: none + .accessactive:first-letter + text-decoration: underline + text-shadow: 0 1px 1px rgba(0, 0, 0, 0.2) + font-weight: bold .oe_button.oe_link @include reset() img From b2965827dc6a43e292e18ec68a18ea5f10824921 Mon Sep 17 00:00:00 2001 From: Vishmita Date: Mon, 5 Nov 2012 12:05:18 +0530 Subject: [PATCH 02/11] [FIX]shortcut should highlight when press SHIFT + ALT. bzr revid: vja@tinyerp.com-20121105063518-ng3qk7ljjxmbtuvi --- addons/web/static/src/js/view_form.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index ed088e50d96..f67ab33d6e8 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -222,8 +222,10 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM }, widgetAccesskey:function(){ $(document).keydown(function(e){ - if(e.keyCode === $.ui.keyCode.ALT) { + if(e.keyCode === $.ui.keyCode.ALT || e.keyCode === $.ui.keyCode.SHIFT && e.altKey) { $("[accesskey]").addClass('accessactive'); + }else { + $("[accesskey]").removeClass('accessactive'); } e.stopPropagation(); }).keyup(function(e){ From d65ab4c01404c0d5ae7d3fede7f3bf7f2e7ff564 Mon Sep 17 00:00:00 2001 From: Vishmita Date: Wed, 7 Nov 2012 18:58:52 +0530 Subject: [PATCH 03/11] [IMP]Improve Code. bzr revid: vja@tinyerp.com-20121107132852-nq4uflsfc1l9o72g --- addons/web/static/src/css/base.css | 7 +++---- addons/web/static/src/css/base.sass | 9 ++++----- addons/web/static/src/js/view_form.js | 20 +++++++++++--------- 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/addons/web/static/src/css/base.css b/addons/web/static/src/css/base.css index 91793947836..a14d0002492 100644 --- a/addons/web/static/src/css/base.css +++ b/addons/web/static/src/css/base.css @@ -475,11 +475,10 @@ max-width: 180px; max-height: 180px; } -.openerp .oe_view_manager_current a.accessactive { - display:inline-block; - text-decoration:none; +.openerp .oe_form_buttons [accesskey] > p { + display:inline; } -.openerp .oe_view_manager_current .accessactive:first-letter{ +.openerp .oe_form_buttons .accessactive { text-decoration:underline; text-shadow: 0 1px 1px rgba(0, 0, 0, 0.2); font-weight:bold; diff --git a/addons/web/static/src/css/base.sass b/addons/web/static/src/css/base.sass index a1bb16d6856..6b768c43f04 100644 --- a/addons/web/static/src/css/base.sass +++ b/addons/web/static/src/css/base.sass @@ -437,11 +437,10 @@ $sheet-padding: 16px .oe_image_medium > img max-width: 180px max-height: 180px - .oe_view_manager_current - a.accessactive - display: inline-block - text-decoration: none - .accessactive:first-letter + .oe_form_buttons + [accesskey] > p + display: inline + .accessactive text-decoration: underline text-shadow: 0 1px 1px rgba(0, 0, 0, 0.2) font-weight: bold diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index 67dbc4b0acf..f9c71e0b316 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -221,16 +221,18 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM return $.when(); }, widgetAccesskey:function(){ - $(document).keydown(function(e){ - if(e.keyCode === $.ui.keyCode.ALT || e.keyCode === $.ui.keyCode.SHIFT && e.altKey) { - $("[accesskey]").addClass('accessactive'); - }else { - $("[accesskey]").removeClass('accessactive'); - } - e.stopPropagation(); - }).keyup(function(e){ - $("[accesskey]").removeClass('accessactive'); + var self = this; + self.$buttons.find("[accesskey]").html(function(i, html){ + return html.replace(/^[^a-zA-Z]*([a-zA-Z])/g, '

$1

'); }); + $(document).keydown(function(e){ + self.$buttons.find("[accesskey] >p").removeClass("accessactive"); + if (e.keyCode === $.ui.keyCode.ALT || e.keyCode === $.ui.keyCode.SHIFT && e.altKey) { + self.$buttons.find("[accesskey] >p").addClass("accessactive"); + } + }).keyup(function(){ + self.$buttons.find("[accesskey] > p").removeClass("accessactive"); + }) }, widgetFocused: function() { // Clear click flag if used to focus a widget From e3ca4012bce49cc375fb8a92cd01a81d79de93c1 Mon Sep 17 00:00:00 2001 From: Vishmita Date: Fri, 16 Nov 2012 14:48:04 +0530 Subject: [PATCH 04/11] [FIX]Minor changes bzr revid: vja@tinyerp.com-20121116091804-3lalobfufyp6yyx4 --- addons/web/static/src/css/base.css | 2 +- addons/web/static/src/js/view_form.js | 39 ++++++++++++++++++++------- addons/web/static/src/xml/base.xml | 8 +++--- 3 files changed, 34 insertions(+), 15 deletions(-) diff --git a/addons/web/static/src/css/base.css b/addons/web/static/src/css/base.css index 5b40b818dc3..f6dfd9f606e 100644 --- a/addons/web/static/src/css/base.css +++ b/addons/web/static/src/css/base.css @@ -471,7 +471,7 @@ .openerp .oe_form_buttons [accesskey] > p { display:inline; } -.openerp .oe_form_buttons .accessactive { +.openerp .oe_form_buttons span.access ,.oe_form_button span.access{ text-decoration:underline; text-shadow: 0 1px 1px rgba(0, 0, 0, 0.2); font-weight:bold; diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index d732d66e0ba..3c0cd5cfb96 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -227,17 +227,36 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM }, widgetAccesskey:function(){ var self = this; - self.$buttons.find("[accesskey]").html(function(i, html){ - return html.replace(/^[^a-zA-Z]*([a-zA-Z])/g, '

$1

'); + $(document).bind('keydown',function(e){ + var list = $(document).find('.oe_form_buttons span button,.oe_form_buttons span a,.oe_application .oe_form_button, oe_list_content.oe_form_field_one2many_list_row_add a'); + list = _.reject(list,function(r){ return $(r).hasClass('oe_form_invisible')}) + var accesskey = _.map(list,function(r){ return $(r).attr('accesskey') }); + _.each(list,function(el,i){ + if (!$(el).attr("accesskey")) { + var text = $(el).text().trim().substr(0,1); + if (_.contains(accesskey.slice(0, i),text)){ + var index = $(el).text().trim().indexOf(text); + var str = $(el).text().trim().substr(index + 1, index + 1); + $(el).attr('accesskey',str); + accesskey[i] = str; + }else { + $(el).attr('accesskey',text); + accesskey[i] = text ; + } + } + }) + if (e.keyCode === e.which) { + _.each(list,function(rl,i){ + $(rl).html(function(i, html){ + return $(rl).text().replace($(rl).attr('accesskey'), '' + $(rl).attr('accesskey') + ''); + }) + }) + }}).keyup(function(){ + var accesskey_list = $(document).find('.oe_form_buttons span button,.oe_form_buttons span a,.oe_application .oe_form_button, oe_list_content.oe_form_field_one2many_list_row_add a'); + accesskey_list.each(function(){ + $(this).find('span.access').removeClass('access'); + }) }); - $(document).keydown(function(e){ - self.$buttons.find("[accesskey] >p").removeClass("accessactive"); - if (e.keyCode === $.ui.keyCode.ALT || e.keyCode === $.ui.keyCode.SHIFT && e.altKey) { - self.$buttons.find("[accesskey] >p").addClass("accessactive"); - } - }).keyup(function(){ - self.$buttons.find("[accesskey] > p").removeClass("accessactive"); - }) }, widgetFocused: function() { // Clear click flag if used to focus a widget diff --git a/addons/web/static/src/xml/base.xml b/addons/web/static/src/xml/base.xml index 22ac56941d7..1c29d3181ef 100644 --- a/addons/web/static/src/xml/base.xml +++ b/addons/web/static/src/xml/base.xml @@ -776,15 +776,15 @@
- +
+ type="button" class="oe_button oe_form_button_create">Create
- + or - Discard + Discard From 367e3a90cc61fdb492d51c26f6a4ba0ad8c8f4ea Mon Sep 17 00:00:00 2001 From: Vishmita Date: Fri, 16 Nov 2012 19:01:11 +0530 Subject: [PATCH 05/11] [FIX]add accesskey for 'add items'. bzr revid: vja@tinyerp.com-20121116133111-joo7ghrvrlqs0f0v --- addons/web/static/src/css/base.css | 2 +- addons/web/static/src/js/view_form.js | 19 ++++++++++--------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/addons/web/static/src/css/base.css b/addons/web/static/src/css/base.css index f6dfd9f606e..3f422fd77a9 100644 --- a/addons/web/static/src/css/base.css +++ b/addons/web/static/src/css/base.css @@ -471,7 +471,7 @@ .openerp .oe_form_buttons [accesskey] > p { display:inline; } -.openerp .oe_form_buttons span.access ,.oe_form_button span.access{ +.openerp .oe_view_manager_current span.access , a.access{ text-decoration:underline; text-shadow: 0 1px 1px rgba(0, 0, 0, 0.2); font-weight:bold; diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index 3c0cd5cfb96..a563f496af2 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -126,6 +126,7 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM self.check_actual_mode(); self.on("change:actual_mode", self, self.init_pager); self.init_pager(); + self.on("change:actual_mode", self, self.widgetAccesskey); self.widgetAccesskey(); }); self.on("load_record", self, self.load_record); @@ -228,10 +229,10 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM widgetAccesskey:function(){ var self = this; $(document).bind('keydown',function(e){ - var list = $(document).find('.oe_form_buttons span button,.oe_form_buttons span a,.oe_application .oe_form_button, oe_list_content.oe_form_field_one2many_list_row_add a'); - list = _.reject(list,function(r){ return $(r).hasClass('oe_form_invisible')}) - var accesskey = _.map(list,function(r){ return $(r).attr('accesskey') }); - _.each(list,function(el,i){ + var list = $(document).find('.oe_form_buttons span:visible button,.oe_form_buttons span a,.oe_application .oe_form_button, .oe_list_content:visible .oe_form_field_one2many_list_row_add > a'); + list = _.reject(list,function(r){ return $(r).hasClass('oe_form_invisible')}) + var accesskey = _.map(list,function(r){ return $(r).attr('accesskey') }); + _.each(list,function(el,i){ if (!$(el).attr("accesskey")) { var text = $(el).text().trim().substr(0,1); if (_.contains(accesskey.slice(0, i),text)){ @@ -244,17 +245,17 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM accesskey[i] = text ; } } - }) - if (e.keyCode === e.which) { + }) + if (e.keyCode === e.which) { _.each(list,function(rl,i){ $(rl).html(function(i, html){ return $(rl).text().replace($(rl).attr('accesskey'), '' + $(rl).attr('accesskey') + ''); }) }) - }}).keyup(function(){ - var accesskey_list = $(document).find('.oe_form_buttons span button,.oe_form_buttons span a,.oe_application .oe_form_button, oe_list_content.oe_form_field_one2many_list_row_add a'); + }}).keyup(function(){ + var accesskey_list = $(document).find('.oe_form_buttons span:visible button,.oe_form_buttons span a,.oe_application .oe_form_button, .oe_list_content:visible .oe_form_field_one2many_list_row_add > a'); accesskey_list.each(function(){ - $(this).find('span.access').removeClass('access'); + $(this).find('.access').removeClass('access'); }) }); }, From a1544bffb429b85f5fd05b4c784489aab2090a7c Mon Sep 17 00:00:00 2001 From: Vishmita Date: Mon, 19 Nov 2012 19:11:24 +0530 Subject: [PATCH 06/11] [FIX]check if first character is special character bzr revid: vja@tinyerp.com-20121119134124-ejaqtquqr7nd9y6z --- addons/web/static/src/js/view_form.js | 31 ++++++++++++--------------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index fc3370bd083..cddf6b30220 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -227,15 +227,13 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM return $.when(); }, widgetAccesskey:function(){ - var self = this; - $(document).bind('keydown',function(e){ - var list = $(document).find('.oe_form_buttons span:visible button,.oe_form_buttons span a,.oe_application .oe_form_button, .oe_list_content:visible .oe_form_field_one2many_list_row_add > a'); - list = _.reject(list,function(r){ return $(r).hasClass('oe_form_invisible')}) - var accesskey = _.map(list,function(r){ return $(r).attr('accesskey') }); - _.each(list,function(el,i){ + var list = $(document).find('.oe_form_buttons span:visible button,.oe_form_buttons span a,.oe_form_button, .oe_list_content:visible .oe_form_field_one2many_list_row_add > a'); + list = _.reject(list,function(r){ return $(r).hasClass('oe_form_invisible')}) + var accesskey = _.map(list,function(r){ return $(r).attr('accesskey')}); + _.each(list,function(el,i){ if (!$(el).attr("accesskey")) { var text = $(el).text().trim().substr(0,1); - if (_.contains(accesskey.slice(0, i),text)){ + if (_.contains(accesskey.slice(0, i),text)|| !(/^[a-z0-9\_]+$/i.test(text))){ var index = $(el).text().trim().indexOf(text); var str = $(el).text().trim().substr(index + 1, index + 1); $(el).attr('accesskey',str); @@ -245,18 +243,17 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM accesskey[i] = text ; } } - }) - if (e.keyCode === e.which) { + }); + $(document).keydown(function(e){ + if (e.keyCode === 18 || e.keycode === 16 && e.altkey) { + _.each(list,function(rl,i){ + $(rl).html(function(i, html){ + return $(rl).text().replace($(rl).attr('accesskey'), '' + $(rl).attr('accesskey') + ''); + })}) + }}).keyup(function(){ _.each(list,function(rl,i){ - $(rl).html(function(i, html){ - return $(rl).text().replace($(rl).attr('accesskey'), '' + $(rl).attr('accesskey') + ''); - }) + $(rl).find('.access').removeClass('access'); }) - }}).keyup(function(){ - var accesskey_list = $(document).find('.oe_form_buttons span:visible button,.oe_form_buttons span a,.oe_application .oe_form_button, .oe_list_content:visible .oe_form_field_one2many_list_row_add > a'); - accesskey_list.each(function(){ - $(this).find('.access').removeClass('access'); - }) }); }, widgetFocused: function() { From 4eae01b9d8d5db369d59ffcc283257d539b7be55 Mon Sep 17 00:00:00 2001 From: Vishmita Date: Tue, 20 Nov 2012 18:14:38 +0530 Subject: [PATCH 07/11] [IMP]Improve code bzr revid: vja@tinyerp.com-20121120124438-c727ibwv4r1kg9qw --- addons/web/static/src/css/base.css | 3 --- addons/web/static/src/js/view_form.js | 27 ++++++++++++++++++--------- 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/addons/web/static/src/css/base.css b/addons/web/static/src/css/base.css index 057a5535a61..3f2eb3fb0ba 100644 --- a/addons/web/static/src/css/base.css +++ b/addons/web/static/src/css/base.css @@ -468,9 +468,6 @@ max-width: 180px; max-height: 180px; } -.openerp .oe_form_buttons [accesskey] > p { - display:inline; -} .openerp .oe_view_manager_current span.access , a.access{ text-decoration:underline; text-shadow: 0 1px 1px rgba(0, 0, 0, 0.2); diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index cddf6b30220..529538548eb 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -123,11 +123,11 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM self.set({actual_mode: self.options.initial_mode}); this.has_been_loaded.done(function() { self.on("change:actual_mode", self, self.check_actual_mode); + self.widgetAccesskey(); self.check_actual_mode(); self.on("change:actual_mode", self, self.init_pager); self.init_pager(); self.on("change:actual_mode", self, self.widgetAccesskey); - self.widgetAccesskey(); }); self.on("load_record", self, self.load_record); this.on('view_loaded', self, self.load_form); @@ -218,7 +218,7 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM self.$el.find(".oe_form_field_status:not(.oe_form_status_clickable)").on('click',function (e) { if(self.get("actual_mode") == "view") { $button.effect('bounce', {distance:18, times: 5}, 150); - e.stopImmediatePropagation(); + e.stopImmediatePropagation(); } }); }) @@ -227,10 +227,14 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM return $.when(); }, widgetAccesskey:function(){ - var list = $(document).find('.oe_form_buttons span:visible button,.oe_form_buttons span a,.oe_form_button, .oe_list_content:visible .oe_form_field_one2many_list_row_add > a'); - list = _.reject(list,function(r){ return $(r).hasClass('oe_form_invisible')}) - var accesskey = _.map(list,function(r){ return $(r).attr('accesskey')}); - _.each(list,function(el,i){ + var list; + $(window).blur(function() {unhighlightAccessKeys()}); + + var highlightAccessKeys = function(){ + list = $(document).find('.oe_form_buttons span:visible button,.oe_form_buttons span a,.oe_form_button, .oe_list_content:visible .oe_form_field_one2many_list_row_add > a') + .not('.oe_form_invisible,.oe_edit_only'); + var accesskey = _.map(list,function(r){ return $(r).attr('accesskey')}); + _.each(list,function(el,i){ if (!$(el).attr("accesskey")) { var text = $(el).text().trim().substr(0,1); if (_.contains(accesskey.slice(0, i),text)|| !(/^[a-z0-9\_]+$/i.test(text))){ @@ -244,17 +248,22 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM } } }); - $(document).keydown(function(e){ - if (e.keyCode === 18 || e.keycode === 16 && e.altkey) { + } + $(document).keydown(function(e){ + highlightAccessKeys(); + if (e.keyCode === 18 || e.keycode === 16 && e.altkey || e.keyCode == 18 && e.shiftKey) { _.each(list,function(rl,i){ $(rl).html(function(i, html){ return $(rl).text().replace($(rl).attr('accesskey'), '' + $(rl).attr('accesskey') + ''); })}) }}).keyup(function(){ + unhighlightAccessKeys(); + }); + var unhighlightAccessKeys = function() { _.each(list,function(rl,i){ $(rl).find('.access').removeClass('access'); }) - }); + }; }, widgetFocused: function() { // Clear click flag if used to focus a widget From f1452efd4291448afd7ee025092962af910d6aa3 Mon Sep 17 00:00:00 2001 From: Vishmita Date: Thu, 22 Nov 2012 19:27:08 +0530 Subject: [PATCH 08/11] [IMP]Minor changes bzr revid: vja@tinyerp.com-20121122135708-nrai59sx5633e3be --- addons/web/static/src/js/view_form.js | 52 +++++++++++++++++---------- 1 file changed, 33 insertions(+), 19 deletions(-) diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index 529538548eb..3f275de356c 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -227,28 +227,42 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM return $.when(); }, widgetAccesskey:function(){ - var list; + var list = []; + var accesskey; $(window).blur(function() {unhighlightAccessKeys()}); - var highlightAccessKeys = function(){ - list = $(document).find('.oe_form_buttons span:visible button,.oe_form_buttons span a,.oe_form_button, .oe_list_content:visible .oe_form_field_one2many_list_row_add > a') + var highlightAccessKeys = function(ins){ + list = $(document).find('.oe_form_buttons span:visible button,.oe_form_buttons span a,.oe_form_button, .oe_list_content:visible .oe_form_field_one2many_list_row_add > a') .not('.oe_form_invisible,.oe_edit_only'); - var accesskey = _.map(list,function(r){ return $(r).attr('accesskey')}); - _.each(list,function(el,i){ - if (!$(el).attr("accesskey")) { - var text = $(el).text().trim().substr(0,1); - if (_.contains(accesskey.slice(0, i),text)|| !(/^[a-z0-9\_]+$/i.test(text))){ - var index = $(el).text().trim().indexOf(text); - var str = $(el).text().trim().substr(index + 1, index + 1); - $(el).attr('accesskey',str); - accesskey[i] = str; - }else { - $(el).attr('accesskey',text); - accesskey[i] = text ; - } - } - }); - } + accesskey = _.map(list, function(r){return $(r).attr('accesskey') }); + + _.each(list,function(el,i){ + if (!$(el).attr("accesskey")) { + accesskey[i] = $(el).text().replace(/\s/g, '').toUpperCase().charAt(0); + if (accesskey[i]) { + var index = 0; + _.each(accesskey, function(key,j){ + + if(_.contains(accesskey,$(el).text().replace(/\s/g, '').toUpperCase().charAt(index))){ + index++; + return false + }else { + accesskey[i] = $(el).text().replace(/\s/g, '').toUpperCase().charAt(index) + $(el).attr("accesskey",$(el).text().replace(/\s/g, '').charAt(index)) + index = 0 + return true + } + return false + }) + }else { + $(el).attr('accesskey',$(el).text().replace(/\s/g, '').charAt(0)); + accesskey[i] = $(el).text().replace(/\s/g, '').toUpperCase().charAt(0); + return true + + } + } + }) + } $(document).keydown(function(e){ highlightAccessKeys(); if (e.keyCode === 18 || e.keycode === 16 && e.altkey || e.keyCode == 18 && e.shiftKey) { From c4cc9240fbc81f912ae8da0eab70cbf20fdad0c4 Mon Sep 17 00:00:00 2001 From: Vishmita Date: Fri, 23 Nov 2012 14:32:21 +0530 Subject: [PATCH 09/11] [IMP]Improve code bzr revid: vja@tinyerp.com-20121123090221-tjd950ju0xsd5e0o --- addons/web/static/src/js/view_form.js | 64 +++++++++++++++------------ 1 file changed, 35 insertions(+), 29 deletions(-) diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index 3f275de356c..860be651efd 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -227,45 +227,51 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM return $.when(); }, widgetAccesskey:function(){ + var self= this; var list = []; - var accesskey; + var accesskey = []; $(window).blur(function() {unhighlightAccessKeys()}); - - var highlightAccessKeys = function(ins){ - list = $(document).find('.oe_form_buttons span:visible button,.oe_form_buttons span a,.oe_form_button, .oe_list_content:visible .oe_form_field_one2many_list_row_add > a') - .not('.oe_form_invisible,.oe_edit_only'); + + var highlightAccessKeys = function(){ + var o2m = $.makeArray($(document).find('.oe_list_content:visible .oe_form_field_one2many_list_row_add > a')) + var list1 = $.makeArray($(document).find('.oe_form_buttons span:visible button,.oe_form_buttons span a,.oe_form_button').not('.oe_form_invisible,.oe_edit_only')); + list = o2m.concat(list1); accesskey = _.map(list, function(r){return $(r).attr('accesskey') }); _.each(list,function(el,i){ if (!$(el).attr("accesskey")) { - accesskey[i] = $(el).text().replace(/\s/g, '').toUpperCase().charAt(0); - if (accesskey[i]) { - var index = 0; - _.each(accesskey, function(key,j){ - - if(_.contains(accesskey,$(el).text().replace(/\s/g, '').toUpperCase().charAt(index))){ - index++; - return false - }else { - accesskey[i] = $(el).text().replace(/\s/g, '').toUpperCase().charAt(index) - $(el).attr("accesskey",$(el).text().replace(/\s/g, '').charAt(index)) - index = 0 - return true - } - return false - }) - }else { - $(el).attr('accesskey',$(el).text().replace(/\s/g, '').charAt(0)); - accesskey[i] = $(el).text().replace(/\s/g, '').toUpperCase().charAt(0); - return true - - } - } + if(! accesskey[i]){ + var index = 0; + _.each(accesskey,function(name,j){ + if (!name) { + accesskey[i] = $(el).text().replace(/\s/g, '').toUpperCase().charAt(0); + return + } else { + if (_.contains(accesskey, $(el).text().replace(/\s/g, '').toUpperCase().charAt(index))) { + index++; + return false; + } else { + if (! accesskey[i]) { + $(el).attr("accesskey",$(el).text().replace(/\s/g, '').charAt(index)) + index = 0 + return true + }else { + $(el).attr("accesskey",accesskey[i]) + } + } + } + return + }) + } + + }else { + $(el).attr("accesskey",accesskey[i]) + } }) } $(document).keydown(function(e){ - highlightAccessKeys(); if (e.keyCode === 18 || e.keycode === 16 && e.altkey || e.keyCode == 18 && e.shiftKey) { + highlightAccessKeys(); _.each(list,function(rl,i){ $(rl).html(function(i, html){ return $(rl).text().replace($(rl).attr('accesskey'), '' + $(rl).attr('accesskey') + ''); From d4fcc2bd2b3e1ecbf938b3ec8e168133aa2681d3 Mon Sep 17 00:00:00 2001 From: Vishmita Date: Fri, 23 Nov 2012 15:12:57 +0530 Subject: [PATCH 10/11] [IMP]Remove unused code bzr revid: vja@tinyerp.com-20121123094257-p7uby3xlhz7ytssw --- addons/web/static/src/js/view_form.js | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/addons/web/static/src/js/view_form.js b/addons/web/static/src/js/view_form.js index 860be651efd..ab32822c1cc 100644 --- a/addons/web/static/src/js/view_form.js +++ b/addons/web/static/src/js/view_form.js @@ -228,22 +228,22 @@ instance.web.FormView = instance.web.View.extend(instance.web.form.FieldManagerM }, widgetAccesskey:function(){ var self= this; - var list = []; - var accesskey = []; + var list,accesskey = []; $(window).blur(function() {unhighlightAccessKeys()}); - + var highlightAccessKeys = function(){ - var o2m = $.makeArray($(document).find('.oe_list_content:visible .oe_form_field_one2many_list_row_add > a')) - var list1 = $.makeArray($(document).find('.oe_form_buttons span:visible button,.oe_form_buttons span a,.oe_form_button').not('.oe_form_invisible,.oe_edit_only')); - list = o2m.concat(list1); + var buttons = _.toArray(self.$el.find('header button:visible,.oe_button_box button:visible')); + var form_button = _.toArray(self.$buttons.find('button:visible,a:visible')); + var o2m = _.toArray($(document).find('.oe_list_content:visible .oe_form_field_one2many_list_row_add > a')) + list = o2m.concat(form_button,buttons); accesskey = _.map(list, function(r){return $(r).attr('accesskey') }); - + _.each(list,function(el,i){ - if (!$(el).attr("accesskey")) { - if(! accesskey[i]){ + if (! $(el).attr("accesskey")) { + if(!accesskey[i]){ var index = 0; - _.each(accesskey,function(name,j){ - if (!name) { + _.each(accesskey,function(_key,j){ + if (!_key){ accesskey[i] = $(el).text().replace(/\s/g, '').toUpperCase().charAt(0); return } else { From 121c952d17679b099b94c4a0246287b2f18f85b0 Mon Sep 17 00:00:00 2001 From: Vishmita Date: Fri, 23 Nov 2012 15:56:18 +0530 Subject: [PATCH 11/11] [fix]Css to sass bzr revid: vja@tinyerp.com-20121123102618-vnfm3tc4ftw3lecu --- addons/web/static/src/css/base.sass | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/addons/web/static/src/css/base.sass b/addons/web/static/src/css/base.sass index e9648e43fe6..a6eccca1852 100644 --- a/addons/web/static/src/css/base.sass +++ b/addons/web/static/src/css/base.sass @@ -432,13 +432,10 @@ $sheet-padding: 16px .oe_image_medium > img max-width: 180px max-height: 180px - .oe_form_buttons - [accesskey] > p - display: inline - .accessactive - text-decoration: underline - text-shadow: 0 1px 1px rgba(0, 0, 0, 0.2) - font-weight: bold + .oe_view_manager_current span.access, a.access + text-decoration: underline + text-shadow: 0 1px 1px rgba(0, 0, 0, 0.2) + font-weight: bold .oe_button.oe_link @include reset() img