[gen] Buttons can now be stretched to fit the size of the inner label.

This commit is contained in:
Gaetan Delannay 2014-04-20 19:22:40 +02:00
parent 2b1fc85512
commit 822e1a7c63
32 changed files with 91 additions and 61 deletions

View file

@ -211,15 +211,10 @@ class Table:
# Some base layouts to use, for fields and pages -------------------------------
# The default layouts for pages.
defaultPageLayouts = {
'view': Table('w|-b|', align="center"),
'edit': Table('w|-b|', width=None)}
'view': Table('w-b'), 'edit': Table('w-b', width=None)}
# A layout for pages, containing the page summary.
summaryPageLayouts = {'view': Table('s-w|-b|', align="center"),
'edit': Table('w|-b|', width=None)}
widePageLayouts = {
'view': Table('w|-b|', align="center"),
'edit': Table('w|-b|')
}
summaryPageLayouts = {'view': Table('s-w-b'), 'edit': Table('w-b', width=None)}
widePageLayouts = {'view': Table('w-b'), 'edit': Table('w-b')}
centeredPageLayouts = {
'view': Table('w|-b|', align="center"),
'edit': Table('w|-b|', width=None, align='center')

View file

@ -1352,4 +1352,15 @@ class ToolMixin(BaseMixin):
"s.parentNode.insertBefore(ga, s);\n" \
"})();\n" % gaId
return code
def getButtonWidth(self, label):
'''Determine button width, in pixels, corresponding to the button
p_label.'''
l = len(label)
if l < 10:
width = '130px'
else:
# Consider 1 char = 6 pixels wide.
width = '%dpx' % (130 + ((l-10)*4))
return 'width:%s' % width
# ------------------------------------------------------------------------------

View file

@ -855,7 +855,7 @@ class BaseMixin:
can't trigger, but for which he needs to know for what reason he
can't trigger it;
* if p_includeNotShowable is True, it includes transitions for which
show=False. Indeed, because "showability" is only a GUI concern,
show=False. Indeed, because "showability" is only a UI concern,
and not a security concern, in some cases it has sense to set
includeNotShowable=True, because those transitions are triggerable
from a security point of view.

BIN
gen/ui/action.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 566 B

BIN
gen/ui/add.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 240 B

View file

@ -66,9 +66,11 @@ img { border: 0; vertical-align: middle }
background-color: #dbdde1; font-weight: bold }
.navigate td { padding: 4px 9px }
.login { margin: 3px; color: black }
input.button { border-width: 0 !important; color: #666666; height: 24px;
width: 150px; cursor:pointer; font-size: 90%; padding: 1px 0 0 10px;
background-color: transparent !important }
input.button { color: #666666; height: 20px; width: 130px;
cursor:pointer; font-size: 90%; padding-left: 10px;
background-color: white; background-repeat: no-repeat;
background-position: 5% 25%; box-shadow: 2px 2px 2px #888888}
.fakeButton { background-color: #e6e6e6 !important ; cursor:help !important }
.buttons { margin-left: 4px }
.message { position: absolute; top: -40px; left: 50%; font-size: 90%;
width: 600px; border: 1px #F0C36D solid; padding: 6px;

Binary file not shown.

Before

Width:  |  Height:  |  Size: 669 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 312 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 877 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 374 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 773 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 315 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 325 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 637 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 478 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 691 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.4 KiB

After

Width:  |  Height:  |  Size: 747 B

Before After
Before After

Binary file not shown.

Before

Width:  |  Height:  |  Size: 360 B

After

Width:  |  Height:  |  Size: 259 B

Before After
Before After

BIN
gen/ui/fake.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 657 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 327 B

After

Width:  |  Height:  |  Size: 288 B

Before After
Before After

BIN
gen/ui/next.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 229 B

BIN
gen/ui/previous.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 225 B

BIN
gen/ui/save.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 513 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 191 B

BIN
gen/ui/transition.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 653 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 359 B

After

Width:  |  Height:  |  Size: 256 B

Before After
Before After

Binary file not shown.

Before

Width:  |  Height:  |  Size: 316 B

After

Width:  |  Height:  |  Size: 243 B

Before After
Before After

View file

@ -192,7 +192,9 @@ class ToolWrapper(AbstractWrapper):
<!-- Create a new object from a web form. -->
<input type="button" class="button"
if="mayCreate and ('form' in createMeans)"
style=":url('buttonAdd', bg=True)" value=":_('query_create')"
var2="label=_('query_create')" value=":label"
style=":'%s; %s' % (url('add', bg=True), \
ztool.getButtonWidth(label))"
onclick=":'goto(%s)' % \
q('%s/do?action=Create&amp;className=%s' % \
(toolUrl, className))"/>
@ -209,7 +211,7 @@ class ToolWrapper(AbstractWrapper):
<td><input type="text" size="14" name="w_SearchableText"
class="inputSearch"/></td>
<td>
<input type="image" class="clickable" src=":url('search.gif')"
<input type="image" class="clickable" src=":url('search')"
title=":_('search_button')"/></td>
</tr>
</table>
@ -521,8 +523,10 @@ class ToolWrapper(AbstractWrapper):
<!-- Submit button -->
<p align=":dright"><br/>
<input type="submit" class="button" value=":_('search_button')"
style=":url('buttonSearch', bg=True)"/>
<input type="submit" class="button" var="label=_('search_button')"
value=":label"
style=":'%s; %s' % (url('search', bg=True), \
ztool.getButtonWidth(label))"/>
</p>
</form>
</x>''', template=AbstractWrapper.pxTemplate, hook='content')

View file

@ -370,7 +370,7 @@ class AbstractWrapper(object):
<!-- Input field for storing the comment coming from the popup -->
<textarea id="comment" name="comment" cols="30" rows="3"
style="display:none"></textarea>
<table>
<table cellpadding="0" cellspacing="0">
<tr valign="middle">
<td align=":dright" for="transition in transitions">
<!-- Render a transition or a group of transitions. -->
@ -448,31 +448,36 @@ class AbstractWrapper(object):
pageInfo=phaseObj.pagesInfo[page]">
<tr valign="top">
<!-- Previous -->
<td if="previousPage and pageInfo.showPrevious">
<td if="previousPage and pageInfo.showPrevious"
var2="label=_('page_previous');
buttonWidth=ztool.getButtonWidth(label)">
<!-- Button on the edit page -->
<x if="isEdit">
<input type="button" class="button" value=":_('page_previous')"
<input type="button" class="button" value=":label"
onClick="submitAppyForm('previous')"
style=":url('buttonPrevious', bg=True)"/>
style=":'%s; %s' % (url('previous', bg=True), buttonWidth)"/>
<input type="hidden" name="previousPage" value=":previousPage"/>
</x>
<!-- Button on the view page -->
<input if="not isEdit" type="button" class="button"
value=":_('page_previous')"
style=":url('buttonPrevious', bg=True)"
<input if="not isEdit" type="button" class="button" value=":label"
style=":'%s; %s' % (url('previous', bg=True), buttonWidth)"
onclick=":'goto(%s)' % q(zobj.getUrl(page=previousPage))"/>
</td>
<!-- Save -->
<td if="isEdit and pageInfo.showSave">
<input type="button" class="button" onClick="submitAppyForm('save')"
style=":url('buttonSave', bg=True)" value=":_('object_save')"/>
var="label=_('object_save')" value=":label"
style=":'%s; %s' % (url('save', bg=True), \
ztool.getButtonWidth(label))" />
</td>
<!-- Cancel -->
<td if="isEdit and pageInfo.showCancel">
<input type="button" class="button" onClick="submitAppyForm('cancel')"
style=":url('buttonCancel', bg=True)" value=":_('object_cancel')"/>
var="label=_('object_cancel')" value=":label"
style=":'%s; %s' % (url('cancel', bg=True), \
ztool.getButtonWidth(label))"/>
</td>
<td if="not isEdit"
@ -482,7 +487,9 @@ class AbstractWrapper(object):
<!-- Edit -->
<input type="button" class="button" if="editable and not locked"
style=":url('buttonEdit', bg=True)" value=":_('object_edit')"
var="label=_('object_edit')" value=":label"
style=":'%s; %s' % (url('edit', bg=True), \
ztool.getButtonWidth(label))"
onclick=":'goto(%s)' % q(zobj.getUrl(mode='edit', page=page))"/>
<!-- Locked -->
@ -496,20 +503,23 @@ class AbstractWrapper(object):
<a if="editable and locked and user.has_role('Manager')">
<img class="clickable" title=":_('page_unlock')"
src=":url('unlockBig')"
onclick=":'onUnlockPage(%s,%s)' % (q(zobj.UID()), q(page))"/></a>
onclick=":'onUnlockPage(%s,%s)' % (q(zobj.id), q(page))"/></a>
</td>
<!-- Next -->
<td if="nextPage and pageInfo.showNext">
<td if="nextPage and pageInfo.showNext"
var2="label=_('page_next');
buttonWidth=ztool.getButtonWidth(label)">
<!-- Button on the edit page -->
<x if="isEdit">
<input type="button" class="button" onClick="submitAppyForm('next')"
style=":url('buttonNext', bg=True)" value=":_('page_next')"/>
style=":'%s; %s' % (url('next', bg=True), buttonWidth)"
value=":label"/>
<input type="hidden" name="nextPage" value=":nextPage"/>
</x>
<!-- Button on the view page -->
<input if="not isEdit" type="button" class="button"
style=":url('buttonNext', bg=True)" value=":_('page_next')"
<input if="not isEdit" type="button" class="button" value=":label"
style=":'%s; %s' % (url('next', bg=True), buttonWidth)"
onclick=":'goto(%s)' % q(zobj.getUrl(page=nextPage))"/>
</td>