#874: Jump Menu widget
-------------------------+--------------------------------------------------
Reporter: fredlin | Owner: anonymous
Type: enhancement | Status: new
Priority: normal | Milestone:
Component: Widgets | Version: 0.9a6
Severity: normal | Resolution:
Keywords: jump menu |
-------------------------+--------------------------------------------------
Comment (by fredlin):
Revised one
{{{
#!python
from turbogears.widgets import JSSource, SelectionField,CoreWD
class JumpMenu(SelectionField):
"""
Choose a link from the menu,
the page will be redirect to the selected link.
"""
js = JSSource("""
<!--
function TG_jumpMenu(targ,f,restore){
eval(targ+".location='"+f.options[f.selectedIndex].value+"'");
if (restore) f.selectedIndex=0;
}
//-->
""")
template = """
<select xmlns:py="http://purl.org/kid/ns#"
name="${name}"
class="${field_class}"
id="${field_id}"
onchange="TG_jumpMenu('parent',this,0)"
py:attrs="attrs"
>
<optgroup py:for="group, options in grouped_options"
label="${group}"
py:strip="not group"
>
<option py:for="value, desc, attrs in options"
value="${value}"
py:attrs="attrs"
py:content="desc"
/>
</optgroup>
</select>
"""
javascript = [js]
_selected_verb = 'selected'
params = ["attrs"]
params_doc = {'attrs' : 'Dictionary containing extra (X)HTML
attributes for'
' the select tag'}
attrs = {}
#jumpmenu = JumpMenu()
class JumpMenuDesc(CoreWD):
name = "Jump Menu"
for_widget = JumpMenu("your_jump_menu_field",
options=[('http://www.python.org', "Python"),
('http://www.turbogears.org',
"TurboGears"),
('http://www.python.org/pypi', "Cheese
Shop"),
('http://www.pythonware.com/daily/',
"Daily Python")],
#default='http://www.turbogears.org'
)
}}}
--
Ticket URL: <http://trac.turbogears.org/turbogears/ticket/874>
TurboGears <http://www.turbogears.org/>
TurboGears front-to-back web development
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"TurboGears Tickets" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/turbogears-tickets
-~----------~----~----~----~------~----~------~--~---