<$mt:setvar name="page_title" value="<__trans phrase="Manage Assets">"$>
<mt:setvarblock name="system_msg">
    <mt:if name="saved_deleted">
        <mtapp:statusmsg
            id="saved-deleted"
            class="success">
            <__trans phrase="You have successfully deleted the asset(s).">
        </mtapp:statusmsg>
    </mt:if>
    <mt:if name="ext_from">
        <mt:if name="ext_to">
            <mtapp:statusmsg
                id="extension-changed"
                class="success">
                <__trans phrase="Extension changed from [_1] to [_2]" params="<mt:var name="ext_from">%%<mt:var name="ext_to">" escape="html">
            </mtapp:statusmsg>
        </mt:if>
    </mt:if>
</mt:setvarblock>

<mt:if name="can_create_post">
<mt:setvarblock name="content_header">
    <ul class="action-link-list">
        <li><a href="<$mt:var name="mt_url"$>?__mode=start_upload&amp;blog_id=<$mt:var name="blog_id"$>" class="icon-left icon-create"><__trans phrase="New Asset"></a></li>
    <ul>
</mt:setvarblock>
</mt:if>

<mt:setvarblock name="related_content">
    <mtapp:widget
        id="quickfilters"
        label="<__trans phrase="Quickfilters">">
        <$MTApp:ListFilters$>
    </mtapp:widget>
    <$mtapp:PageActions$>
</mt:setvarblock>
<mt:setvarblock name="html_body_footer">
    <$mt:include name="include/display_options.tmpl"$>
</mt:setvarblock>
<mt:setvarblock name="html_head" append="1">
<script type="text/javascript">
/* <![CDATA[ */
function enableFilterButton() {
    jQuery('#filter-button').css('display', 'inline');
}

function toggleFilter() {
    if (jQuery('#filter-title').toggle().css('display') == 'none') {
        <mt:unless name="filter">setFilterCol('class');</mt:unless>
    }
    jQuery('#filter-select').toggle();
}

function setFilterCol(choice) {
    if (!jQuery('#filter-select').length) return;
    if (choice != 'none') {
        jQuery('#filter-select span').not('.buttons').hide();
        jQuery('#filter-'+choice).show().addClass('filter-'+choice);
        jQuery('#filter-col').val(choice);
        jQuery('#filter-text-col').html('<strong>'+jQuery('#filter-col option:selected').text()+'</strong>');
    }
}

var tableSelect;
function init() {
    tableSelect = new TC.TableSelect( "asset-listing-table" );
    tableSelect.rowSelect = true;

    setFilterCol(<mt:if name="filter">'<mt:var name="filter" escape="js">'<mt:else>'none'</mt:if>);<mt:if name="filter">
    setFilterVal('<mt:var name="filter_val" escape="js">');</mt:if>
}
/* ]]> */
</script>
</mt:setvarblock>
<mt:setvarblock name="list_filter_form">
<form id="filter-form" method="get" action="<mt:var name="mt_url">">
    <input type="hidden" name="__mode" value="list_asset" />
    <mt:if name="edit_blog_id">
    <input type="hidden" name="blog_id" value="<mt:var name="edit_blog_id">" />
    </mt:if>
    <input id="filter" type="hidden" name="filter" value="" />
    <input id="filter_val" type="hidden" name="filter_val" value="" />
</form>
<div class="listing-filter">
    <div class="listing-filter-inner inner pkg">
        <form id="filter-select-form" method="get" action="<mt:var name="mt_url">" onsubmit="return execFilter(this)">
            <div class="filter">
                <div id="filter-title">
            <mt:if name="filter_key">
                <strong><__trans phrase="Showing only: [_1]" params="<mt:var name="filter_label">"></strong>
                <a class="filter-link" href="<mt:var name="script_url">?__mode=<mt:var name="mode" escape="url"><mt:if name="blog_id">&amp;blog_id=<mt:var name="blog_id"></mt:if>">[ <__trans phrase="Remove filter"> ]</a>
            <mt:else>
                <mt:unless name="filter">
                        <strong><__trans phrase="All [_1]" params="<$mt:var name="object_label_plural"$>"></strong>
                        <a href="javascript:void(0)" onclick="toggleFilter()" class="filter-link">[ <__trans phrase="change"> ]</a>
                <mt:else>
                        <strong><a href="javascript:void(0)" onclick="toggleFilter()"><__trans phrase="[_1] where [_2] is [_3]" params='<$mt:var name="object_label_plural"$>%%<span id="filter-text-col">&nbsp;</span>%%<span id="filter-text-val"></span>'></a></strong>
                        <a class="filter-link" href="<mt:var name="script_url">?__mode=<mt:var name="mode" escape="url"><mt:if name="blog_id">&amp;blog_id=<mt:var name="blog_id"></mt:if><mt:if name="is_power_edit">&amp;is_power_edit=1</mt:if>">[ <__trans phrase="Remove filter"> ]</a>
                </mt:unless>
            </mt:if>
                </div>
                <div id="filter-select" style="display: none">
                    <__trans phrase="Show only assets where">
                    <!-- filter form starts -->
                        <select id="filter-col" name="filter" onchange="setFilterCol(this.options[this.selectedIndex].value);enableFilterButton()">
                            <option value="class"><__trans phrase="type"></option>
                            <option value="exacttag"><__trans phrase="tag (exact match)"></option>
                            <option value="normalizedtag"><__trans phrase="tag (fuzzy match)"></option>
                        </select>
                        <__trans phrase="is">
                        <span id="filter-class" style="display: none">
                            <select id="class-val" name="filter_val" onchange="enableFilterButton()">
            <mt:loop name="class_loop">
                                <option value="<mt:var name="class_id">"><mt:var name="class_label" escape="html"></option>
            </mt:loop>
                            </select>
                        </span>
                        <span id="filter-exacttag" style="display: none">
                            <input type="text" id="exacttag-val" name="filter_val" value="<mt:if name="filter_col_exacttag"><mt:var name="filter_val" escape="html"></mt:if><mt:if name="filter_col_normalizedtag"><mt:var name="filter_val" escape="html"></mt:if>" onchange="enableFilterButton()" onkeypress="enableFilterButton()" />
                        </span>
                        <span id="filter-normalizedtag" style="display: none">
                            <input type="text" id="normalizedtag-val" name="filter_val" value="<mt:if name="filter_col_exacttag"><mt:var name="filter_val" escape="html"></mt:if><mt:if name="filter_col_normalizedtag"><mt:var name="filter_val" escape="html"></mt:if>" onchange="enableFilterButton()" onkeypress="enableFilterButton()" />
                        </span>
                    <!-- filter form ends -->
                    <span class="buttons">
                        <button
                            id="filter-button"
                            onclick="return execFilter(getByID('filter-select-form'))"
                            type="submit"
                            ><__trans phrase="Filter"></button>
                        <button href="javascript:void(0)"
                            onclick="toggleFilter(); return false;"
                            type="submit"
                            ><__trans phrase="Cancel"></button>
                    </span>
                </div>
            </div>
        </form>
    </div>
</div>
</mt:setvarblock>

<$mt:include name="include/header.tmpl" id="header_include"$>

<$mt:var name="list_filter_form"$>

<mt:include name="include/asset_table.tmpl">
<mt:setvarblock name="jq_js_include" append="1">
    init();
    jQuery.mtCheckbox();
</mt:setvarblock>
<mt:include name="include/footer.tmpl">
