[ADD] enable accesskeys (=shortcuts)

They are translatable (changes in npybabel.py), a visual hint for the
shortcuts to use will be added by a yet-to-be-written web module.

bzr revid: hbrunn@therp.nl-20120717075152-gz2ktbme3k388vd6
This commit is contained in:
Holger Brunn 2012-07-17 09:51:52 +02:00
parent 8cd7293033
commit 30ba281af0
3 changed files with 13 additions and 11 deletions

View File

@ -600,7 +600,7 @@ instance.web.qweb.preprocess_node = function() {
break;
case 1:
// Element
var attr, attrs = ['label', 'title', 'alt', 'placeholder'];
var attr, attrs = ['label', 'title', 'alt', 'placeholder', 'accesskey'];
while (attr = attrs.pop()) {
if (this.attributes[attr]) {
this.attributes[attr] = instance.web._t(this.attributes[attr]);

View File

@ -685,11 +685,11 @@
<div t-name="FormView.buttons" class="oe_form_buttons">
<t t-if="widget.options.action_buttons !== false">
<span class="oe_form_buttons_view">
<button type="button" class="oe_button oe_form_button_edit">Edit</button>
<button type="button" class="oe_button oe_form_button_create">Create</button>
<button type="button" class="oe_button oe_form_button_edit" accesskey="E">Edit</button>
<button type="button" class="oe_button oe_form_button_create" accesskey="C">Create</button>
</span>
<span class="oe_form_buttons_edit">
<button type="button" class="oe_button oe_form_button_save oe_highlight">Save</button> <span class="oe_fade">or</span> <a href="#" class="oe_bold oe_form_button_cancel">Discard</a>
<button type="button" class="oe_button oe_form_button_save oe_highlight" accesskey="S">Save</button> <span class="oe_fade">or</span> <a href="#" class="oe_bold oe_form_button_cancel" accesskey="D">Discard</a>
</span>
</t>
</div>
@ -775,7 +775,7 @@
<div class="oe_clear">
<ul t-attf-class="oe_notebook #{classnames}">
<li t-foreach="pages" t-as="page" t-att-modifiers="page.modifiers">
<a t-attf-href="##{page.id}">
<a t-attf-href="##{page.id}" t-att-accesskey="page.accesskey">
<t t-esc="page.string"/>
</a>
</li>
@ -1118,7 +1118,8 @@
<button type="button" class="oe_button oe_form_button"
t-att-style="widget.node.attrs.style"
t-att-tabindex="widget.node.attrs.tabindex"
t-att-autofocus="widget.node.attrs.autofocus">
t-att-autofocus="widget.node.attrs.autofocus"
t-att-accesskey="widget.node.attrs.accesskey">
<img t-if="widget.node.attrs.icon" t-att-src="_s + '/web/static/src/img/icons/' + widget.node.attrs.icon + '.png'" width="16" height="16"/>
<span t-if="widget.string"><t t-esc="widget.string"/></span>
</button>

View File

@ -93,9 +93,10 @@ def extract_qweb(fileobj, keywords, comment_tags, options):
:rtype: ``iterator``
"""
result = []
def handle_text(text, lineno):
def handle_text(text, lineno, name=None):
text = (text or "").strip()
if len(text) > 1: # Avoid mono-char tokens like ':' ',' etc.
if len(text) > 1 or name in ['accesskey']:
# Avoid mono-char tokens like ':' ',' etc but keep accesskeys
result.append((lineno, None, text, [TRANSLATION_FLAG_COMMENT]))
# not using elementTree.iterparse because we need to skip sub-trees in case
@ -106,10 +107,10 @@ def extract_qweb(fileobj, keywords, comment_tags, options):
if "t-js" not in el.attrib and \
not ("t-jquery" in el.attrib and "t-operation" not in el.attrib) and \
not ("t-translation" in el.attrib and el.attrib["t-translation"].strip() == "off"):
handle_text(el.text, el.sourceline)
for att in ('title', 'alt', 'label', 'placeholder'):
handle_text(el.text, el.sourceline, el.tag)
for att in ('title', 'alt', 'label', 'placeholder', 'accesskey'):
if att in el.attrib:
handle_text(el.attrib[att], el.sourceline)
handle_text(el.attrib[att], el.sourceline, att)
iter_elements(el)
handle_text(el.tail, el.sourceline)