<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:t="http://www.participatorypolitics.org/"
      xmlns:i18n="http://www.participatoryculture.org/i18n"
      eventCookie="@@@eventCookie@@@" dtvPlatform="@@@dtvPlatform@@@">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

    <link href="resource:css/main.css" rel="stylesheet" type="text/css" />
    <t:include filename="dynamic.js" />
    <t:include filename="settings.js" />
    <script type="text/javascript" src="resource:templates/osxdnd.js" />
    <t:execOnLoad><![CDATA[

filters.switchNewItemsChannel("new")
sorts.switchUnwatchedFirstChannel("new")
views.nonContainerItems.recomputeFilter(views.newWatchableItems)

def searchFilter(x):
    return filters.matchingItems(x, app.controller.newVideosSearchTerm)

matchingItems = views.uniqueNewWatchableItems.filter(lambda x:searchFilter(x) and x.getFeedURL() != "dtv:singleFeed",sortFunc=sorts.itemSortNew.sort, resort=True)

def updateSearchString(newSearch):
    if len(newSearch) == 0:
        app.controller.newVideosSearchTerm = None
    else:
        app.controller.newVideosSearchTerm = newSearch
    views.uniqueNewWatchableItems.recomputeFilter(matchingItems)

def setSortBy(by, section, handle):
    sorts.itemSortNew.setSortBy(by)
    views.uniqueNewWatchableItems.recomputeSort(matchingItems)
    handle.forceUpdate()

]]>
    </t:execOnLoad>
    <t:execOnUnload><![CDATA[
matchingItems.unlink()
]]>
    </t:execOnUnload>

</head>

<body onkeydown="sendKeyToSearchBox(event);">

<!-- TITLE BAR ************************************************************ -->
<div id="main-titlebar">
    <div id="main-icon" class="noborder"><img src="resource:images/newvideos-icon.png" /></div>
    <h1 id="main-title" i18n:translate="">New</h1>
    <div id="search-box-container">
        <div t:showIf="app.controller.newVideosSearchTerm is None">
            <input id="search-box" type="search" onfocus="onSearchFocus(this)" onblur="endEditSearch()" value="***_('Find')***" />
        </div>
        <div t:showIf="app.controller.newVideosSearchTerm is not None">
            <input id="search-box" type="search" onfocus="onSearchFocus(this)" onblur="endEditSearch()" value="***app.controller.newVideosSearchTerm***" searching="1"/>
        </div>
    </div>
</div>
<!-- / TITLE BAR -->

<div id="main-container">
    <div t:updateForView="matchingItems">
        <div t:hideIf="matchingItems.len() == 0">
            <t:executeTemplate filename="static-tab-sort-bar" 
                itemSort="sorts.itemSortNew"
                section="'main'" />
        </div>
    </div>
    <div id="main-unwatched">
        <div t:repeatForView="matchingItems" t:repeatTemplate='download-item' t:containerDiv="true" />
    </div>	
</div>

</body>
</html>
