#874: Jump Menu widget
-------------------------+--------------------------------------------------
 Reporter:  fredlin      |       Owner:  anonymous
     Type:  enhancement  |      Status:  new      
 Priority:  normal       |   Milestone:           
Component:  CherryPy     |     Version:  0.9a5    
 Severity:  normal       |    Keywords:  jump menu
-------------------------+--------------------------------------------------
 select a host from the menu, the page will be redirect to that link.

 Dreamweaver Users may familiar with this widget.


 {{{
 #!python
 from turbogears.widgets.base import JSSource

 class JumpMenuField(SelectionField):
     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 = {}

 class JumpMenuFieldDesc(CoreWD):
     name = "Jump Menu Field"
     for_widget = JumpMenuField("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
-~----------~----~----~----~------~----~------~--~---

Reply via email to