PageRenderTime 24ms CodeModel.GetById 18ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

/templates/form.mako

https://bitbucket.org/cistrome/cistrome-harvard/
Mako | 110 lines | 101 code | 9 blank | 0 comment | 8 complexity | d010b9026b75fd6fd7410534b07548a2 MD5 | raw file
  1<%!
  2    def inherit(context):
  3        if context.get('use_panels'):
  4            if context.get('webapp'):
  5                webapp = context.get('webapp')
  6            else:
  7                webapp = 'galaxy'
  8            return '/webapps/%s/base_panels.mako' % webapp
  9        else:
 10            return '/base.mako'
 11%>
 12<%inherit file="${inherit(context)}"/>
 13<% _=n_ %>
 14
 15<%def name="init()">
 16<%
 17    self.has_left_panel=False
 18    self.has_right_panel=False
 19    self.active_view=active_view
 20    self.message_box_visible=False
 21%>
 22</%def>
 23
 24
 25<%def name="title()">${form.title}</%def>
 26
 27<%def name="javascripts()">
 28    ${parent.javascripts()}
 29    ${h.js("libs/jquery/jquery.autocomplete")}
 30    <script type="text/javascript">
 31        $(function(){
 32            $("input:text:first").focus();
 33        })
 34    </script>
 35</%def>
 36
 37<%def name="stylesheets()">
 38    ${parent.stylesheets()}
 39    ${h.css("autocomplete_tagging")}
 40</%def>
 41
 42<%def name="center_panel()">
 43    ${render_form( )}
 44</%def>
 45
 46<%def name="body()">
 47    ${render_form( )}
 48</%def>
 49
 50<%def name="render_form()">
 51    %if header:
 52        ${header}
 53    %endif
 54    
 55    <div class="form" style="margin: 1em">
 56        <div class="form-title">${util.unicodify( form.title )}</div>
 57        <div class="form-body">
 58        <%
 59            has_file_input = False
 60            for input in form.inputs:
 61                if input.type == 'file':
 62                    has_file_input = True
 63                    break
 64        %>
 65        <form name="${form.name}" action="${form.action}" method="post" 
 66        %if has_file_input:
 67             enctype="multipart/form-data"
 68        %endif
 69        >
 70            %for input in form.inputs:
 71                <%
 72                cls = "form-row"
 73                if input.error:
 74                    cls += " form-row-error"
 75                %>
 76                <div class="${cls}">
 77                %if input.use_label:
 78                  <label>
 79                      ${_(input.label)}:
 80                  </label>
 81                %endif
 82                <div class="form-row-input">
 83                    %if input.type == 'textarea':
 84                        <textarea name="${input.name}">${input.value}</textarea>
 85                    %elif input.type == 'select':
 86                        <select name="${input.name}">
 87                            %for (name, value) in input.options:
 88                                <option value="${value}">${name}</option>
 89                            %endfor
 90                        </select>
 91                    %else:
 92                        <input type="${input.type}" name="${input.name}" value="${input.value}">
 93                    %endif      
 94                </div>
 95                %if input.error:
 96                    <div class="form-row-error-message">${input.error}</div>
 97                %endif
 98                %if input.help:
 99                    <div class="toolParamHelp" style="clear: both;">
100                        ${input.help}
101                    </div>
102                %endif
103                <div style="clear: both"></div>
104        </div>
105        %endfor
106        <div class="form-row"><input type="submit" value="${form.submit_text}"></div>
107        </form>
108        </div>
109    </div>
110</%def>