from mako import runtime, filters, cache
UNDEFINED = runtime.UNDEFINED
__M_dict_builtin = dict
__M_locals_builtin = locals
_magic_number = 5
_modified_time = 1287725326.7005551
_template_filename='templates/root/index.mako'
_template_uri='root/index.mako'
_template_cache=cache.Cache(__name__, _modified_time)
_source_encoding=None
_exports = ['init', 'left_panel', 'center_panel', 'late_javascripts', 'right_panel']


def _mako_get_namespace(context, name):
    try:
        return context.namespaces[(__name__, name)]
    except KeyError:
        _mako_generate_namespaces(context)
        return context.namespaces[(__name__, name)]
def _mako_generate_namespaces(context):
    pass
def _mako_inherit(template, context):
    _mako_generate_namespaces(context)
    return runtime._inherit_from(context, u'/webapps/galaxy/base_panels.mako', _template_uri)
def render_body(context,**pageargs):
    context.caller_stack._push_frame()
    try:
        __M_locals = __M_dict_builtin(pageargs=pageargs)
        __M_writer = context.writer()
        # SOURCE LINE 1
        __M_writer(u'\n\n')
        # SOURCE LINE 156
        __M_writer(u'\n\n')
        # SOURCE LINE 176
        __M_writer(u'\n\n')
        # SOURCE LINE 190
        __M_writer(u'\n\n')
        # SOURCE LINE 212
        __M_writer(u'\n\n')
        # SOURCE LINE 226
        __M_writer(u'\n')
        return ''
    finally:
        context.caller_stack._pop_frame()


def render_init(context):
    context.caller_stack._push_frame()
    try:
        self = context.get('self', UNDEFINED)
        trans = context.get('trans', UNDEFINED)
        __M_writer = context.writer()
        # SOURCE LINE 158
        __M_writer(u'\n')
        # SOURCE LINE 159

        if trans.app.config.cloud_controller_instance:
                self.has_left_panel=False
                self.has_right_panel=False
                self.active_view="cloud"
        else:
                self.has_left_panel=True
                self.has_right_panel=True
                self.active_view="analysis"
        
        
        # SOURCE LINE 168
        __M_writer(u'\n')
        # SOURCE LINE 169
        if trans.app.config.require_login and not trans.user:
            # SOURCE LINE 170
            __M_writer(u'    <script type="text/javascript">\n        if ( window != top ) {\n            top.location.href = location.href;\n        }\n    </script>\n')
        return ''
    finally:
        context.caller_stack._pop_frame()


def render_left_panel(context):
    context.caller_stack._push_frame()
    try:
        h = context.get('h', UNDEFINED)
        _ = context.get('_', UNDEFINED)
        n_ = context.get('n_', UNDEFINED)
        __M_writer = context.writer()
        # SOURCE LINE 178
        __M_writer(u'\n    <div class="unified-panel-header" unselectable="on">\n        <div class=\'unified-panel-header-inner\'>\n            <div style="float: right">\n                <a class=\'panel-header-button popup\' id="tools-options-button" href="#">')
        # SOURCE LINE 182
        __M_writer(unicode(_('Options')))
        __M_writer(u'</a>\n            </div>\n            ')
        # SOURCE LINE 184
        __M_writer(unicode(n_('Tools')))
        __M_writer(u'\n        </div>\n    </div>\n    <div class="unified-panel-body" style="overflow: hidden;">\n        <iframe name="galaxy_tools" id="galaxy_tools" src="')
        # SOURCE LINE 188
        __M_writer(unicode(h.url_for( controller='root', action='tool_menu' )))
        __M_writer(u'" frameborder="0" style="position: absolute; margin: 0; border: 0 none; height: 100%; width: 100%;"> </iframe>\n    </div>\n')
        return ''
    finally:
        context.caller_stack._pop_frame()


def render_center_panel(context):
    context.caller_stack._push_frame()
    try:
        tool_id = context.get('tool_id', UNDEFINED)
        m_c = context.get('m_c', UNDEFINED)
        h = context.get('h', UNDEFINED)
        m_a = context.get('m_a', UNDEFINED)
        workflow_id = context.get('workflow_id', UNDEFINED)
        trans = context.get('trans', UNDEFINED)
        __M_writer = context.writer()
        # SOURCE LINE 192
        __M_writer(u'\n\n')
        # SOURCE LINE 195
        __M_writer(u'    ')

        if trans.app.config.require_login and not trans.user:
            center_url = h.url_for( controller='user', action='login' )
        elif tool_id is not None:
            center_url = h.url_for( 'tool_runner', tool_id=tool_id, from_noframe=True )
        elif workflow_id is not None:
            center_url = h.url_for( controller='workflow', action='run', id=workflow_id )
        elif m_c is not None:
            center_url = h.url_for( controller=m_c, action=m_a )
        elif trans.app.config.cloud_controller_instance:
            center_url = h.url_for( controller='cloud', action='list' )
        else:
            center_url = h.url_for( '/static/welcome.html' )
        
        
        # SOURCE LINE 208
        __M_writer(u'\n    \n    <iframe name="galaxy_main" id="galaxy_main" frameborder="0" style="position: absolute; width: 100%; height: 100%;" src="')
        # SOURCE LINE 210
        __M_writer(unicode(center_url))
        __M_writer(u'"> </iframe>\n\n')
        return ''
    finally:
        context.caller_stack._pop_frame()


def render_late_javascripts(context):
    context.caller_stack._push_frame()
    try:
        h = context.get('h', UNDEFINED)
        trans = context.get('trans', UNDEFINED)
        parent = context.get('parent', UNDEFINED)
        __M_writer = context.writer()
        # SOURCE LINE 3
        __M_writer(u'\n    ')
        # SOURCE LINE 4
        __M_writer(unicode(parent.late_javascripts()))
        __M_writer(u'\n    <script type="text/javascript">\n    // Set up GalaxyAsync object.\n    var galaxy_async = new GalaxyAsync();\n    galaxy_async.set_func_url(galaxy_async.set_user_pref, "')
        # SOURCE LINE 8
        __M_writer(unicode(h.url_for( controller='user', action='set_user_pref_async' )))
        __M_writer(u'");\n    \n    $(function(){\n        // Init history options.\n        $("#history-options-button").css( "position", "relative" );\n        make_popupmenu( $("#history-options-button"), {\n            "History Lists": null,\n            "Saved Histories": function() {\n                galaxy_main.location = "')
        # SOURCE LINE 16
        __M_writer(unicode(h.url_for( controller='history', action='list')))
        __M_writer(u'";\n            },\n            "Histories Shared with Me": function() {\n                galaxy_main.location = "')
        # SOURCE LINE 19
        __M_writer(unicode(h.url_for( controller='history', action='list_shared')))
        __M_writer(u'";\n            },\n            "Current History": null,\n            "Create New": function() {\n                galaxy_history.location = "')
        # SOURCE LINE 23
        __M_writer(unicode(h.url_for( controller='root', action='history_new' )))
        __M_writer(u'";\n            },\n            "Clone": function() {\n                galaxy_main.location = "')
        # SOURCE LINE 26
        __M_writer(unicode(h.url_for( controller='history', action='clone')))
        __M_writer(u'";\n            },\n            "Share or Publish": function() {\n                galaxy_main.location = "')
        # SOURCE LINE 29
        __M_writer(unicode(h.url_for( controller='history', action='sharing' )))
        __M_writer(u'";\n            },\n            "Extract Workflow": function() {\n                galaxy_main.location = "')
        # SOURCE LINE 32
        __M_writer(unicode(h.url_for( controller='workflow', action='build_from_current_history' )))
        __M_writer(u'";\n            },\n            "Dataset Security": function() {\n                galaxy_main.location = "')
        # SOURCE LINE 35
        __M_writer(unicode(h.url_for( controller='root', action='history_set_default_permissions' )))
        __M_writer(u'";\n            },\n            "Show Deleted Datasets": function() {\n                galaxy_history.location = "')
        # SOURCE LINE 38
        __M_writer(unicode(h.url_for( controller='root', action='history', show_deleted=True)))
        __M_writer(u'";\n            },\n            "Show Hidden Datasets": function() {\n                galaxy_history.location = "')
        # SOURCE LINE 41
        __M_writer(unicode(h.url_for( controller='root', action='history', show_hidden=True)))
        __M_writer(u'";\n            },\n            "Show structure": function() {\n                galaxy_main.location = "')
        # SOURCE LINE 44
        __M_writer(unicode(h.url_for( controller='history', action='display_structured' )))
        __M_writer(u'";\n            },\n            "Export to File": function() {\n                galaxy_main.location = "')
        # SOURCE LINE 47
        __M_writer(unicode(h.url_for( controller='history', action='export_archive' )))
        __M_writer(u'";\n            },\n            "Delete": function()\n            {\n                if ( confirm( "Really delete the current history?" ) )\n                {\n                    galaxy_main.location = "')
        # SOURCE LINE 53
        __M_writer(unicode(h.url_for( controller='history', action='delete_current' )))
        __M_writer(u'";\n                }\n            },\n')
        # SOURCE LINE 60
        __M_writer(u'        });\n        \n        // Init tool options.\n        make_popupmenu( $("#tools-options-button"), {\n')
        # SOURCE LINE 65
        if trans.app.toolbox_search.enabled:
            # SOURCE LINE 66
            __M_writer(u'                ')
 
            show_tool_search = False
            if trans.user:
                show_tool_search = trans.user.preferences.get( "show_tool_search", "False" )
                
            if show_tool_search == "True":
                initial_text = "Hide Search"
            else:
                initial_text = "Search Tools"
                            
            
            # SOURCE LINE 75
            __M_writer(u'\n                "')
            # SOURCE LINE 76
            __M_writer(unicode(initial_text))
            __M_writer(u'": function() {\n                    // Show/hide menu and update vars, user preferences.\n                    var menu = $("#galaxy_tools").contents().find(\'#tool-search\');\n                    if (menu.is(":visible"))\n                    {\n                        // Hide menu.\n                        pref_value = "False";\n                        menu_option_text = "Search Tools";\n                        menu.toggle();\n                        \n                        // Reset search.\n                        reset_tool_search(true);\n                    }\n                    else\n                    {\n                        // Show menu.\n                        pref_value = "True";\n                        menu_option_text = "Hide Search";\n                        menu.toggle();\n                    }\n            \n                    // Update menu option.\n                    $("#tools-options-button-menu").find("li").eq(0).text(menu_option_text);\n            \n                    galaxy_async.set_user_pref("show_tool_search", pref_value);\n                },\n')
        # SOURCE LINE 104
        if trans.user:
            # SOURCE LINE 105
            __M_writer(u'                ')

            if trans.user.preferences.get( 'show_recently_used_menu', 'False' ) == 'True':
                action = "Hide"
            else:
                action = "Show"
                            
            
            # SOURCE LINE 110
            __M_writer(u'\n                "')
            # SOURCE LINE 111
            __M_writer(unicode(action))
            __M_writer(u' Recently Used": function() {\n                    // Show/hide menu.\n                    var ru_menu = $(\'#galaxy_tools\').contents().find(\'#recently_used_wrapper\');\n                    var ru_menu_body = ru_menu.find(".toolSectionBody");\n                    var pref_value = null;\n                    var menu_option_text = null;\n                    if (ru_menu.hasClass("user_pref_visible"))\n                    {\n                        // Hide menu.\n                        ru_menu_body.slideUp();\n                        ru_menu.slideUp();\n                        \n                        // Set vars used below and in tool menu frame.\n                        pref_value = "False";\n                        menu_option_text = "Show Recently Used";\n                    }\n                    else\n                    {\n                        // "Show" menu.\n                        if (!$(\'#galaxy_tools\').contents().find(\'#tool-search-query\').hasClass("search_active"))\n                            // Default.\n                            ru_menu.slideDown();\n                        else\n                            // Search active: tf there are matching tools in RU menu, show menu.\n                            if ( ru_menu.find(".toolTitle.search_match").length != 0 )\n                            {\n                                ru_menu.slideDown();\n                                ru_menu_body.slideDown();\n                            }\n                        \n                        // Set vars used below and in tool menu frame.\n                        pref_value = "True";\n                        menu_option_text = "Hide Recently Used";\n                    }\n                 \n                    // Update menu class and option.\n                    ru_menu.toggleClass("user_pref_hidden user_pref_visible");\n                    $("#tools-options-button-menu").find("li").eq(1).text(menu_option_text);\n\n                    galaxy_async.set_user_pref("show_recently_used_menu", pref_value);\n                }\n')
        # SOURCE LINE 153
        __M_writer(u'        });\n    });\n    </script>\n')
        return ''
    finally:
        context.caller_stack._pop_frame()


def render_right_panel(context):
    context.caller_stack._push_frame()
    try:
        h = context.get('h', UNDEFINED)
        _ = context.get('_', UNDEFINED)
        __M_writer = context.writer()
        # SOURCE LINE 214
        __M_writer(u'\n    <div class="unified-panel-header" unselectable="on">\n        <div class="unified-panel-header-inner">\n            <div style="float: right">\n                <a id="history-options-button" class=\'panel-header-button popup\' href="')
        # SOURCE LINE 218
        __M_writer(unicode(h.url_for( controller='root', action='history_options' )))
        __M_writer(u'" target="galaxy_main">')
        __M_writer(unicode(_('Options')))
        __M_writer(u'</a>\n            </div>\n            <div class="panel-header-text">')
        # SOURCE LINE 220
        __M_writer(unicode(_('History')))
        __M_writer(u'</div>\n        </div>\n    </div>\n    <div class="unified-panel-body" style="overflow: hidden;">\n        <iframe name="galaxy_history" width="100%" height="100%" frameborder="0" style="position: absolute; margin: 0; border: 0 none; height: 100%;" src="')
        # SOURCE LINE 224
        __M_writer(unicode(h.url_for( controller='root', action='history' )))
        __M_writer(u'"></iframe>\n    </div>\n')
        return ''
    finally:
        context.caller_stack._pop_frame()


