diff options
| author | Vishmita <vja@tinyerp.com> | 2012-11-16 14:48:04 +0530 |
|---|---|---|
| committer | Vishmita <vja@tinyerp.com> | 2012-11-16 14:48:04 +0530 |
| commit | e3ca4012bce49cc375fb8a92cd01a81d79de93c1 (patch) | |
| tree | 341a2774e17563598418732bb81157ebc7aee6cb /addons/web/static/src/js/view_form.js | |
| parent | f3b04597054361b1809354c7206605189e066b53 (diff) | |
[FIX]Minor changes
bzr revid: vja@tinyerp.com-20121116091804-3lalobfufyp6yyx4
Diffstat (limited to 'addons/web/static/src/js/view_form.js')
| -rw-r--r-- | addons/web/static/src/js/view_form.js | 39 |
1 files changed, 29 insertions, 10 deletions
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, '<p>$1</p>'); + $(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'), '<span class ="access">' + $(rl).attr('accesskey') + '</span>'); + }) + }) + }}).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 |
