<div class="subnav ng-scope themes-manager">
    <h3 class="subnav__page-title" translate>Theme Manager</h3>
    <div class="subnav__button-stack--square-buttons">
        <form
            action="#"
            method="post"
            enctype="multipart/form-data"
            ng-if="!self.hasReachedThemesLimit() && !self.isSolo()">
            <label class="navbtn sd-create-btn" for="uploadAThemeFile" title="{{ 'New Theme' | translate }}">
                <i class="svg-icon-plus"></i>
                <span class="circle"></span>
            </label>
            <input
                type="file"
                name="uploadAThemeFile"
                id="uploadAThemeFile"
                onchange="angular.element(this).controller().uploadThemeFile(this)">
        </form>

        <button
            ng-if="self.hasReachedThemesLimit()"
            class="navbtn sd-create-btn"
            ng-click="self.showUpgradeModal()" title="{{ 'New Theme' | translate }}">
            <i class="svg-icon-plus"></i>
            <span class="circle"></span>
        </button>
    </div>
</div>

<section class="main-section themelist">
    <div class="loading-indicator" ng-show="self.loading"><span translate>loading</span></div>
    <div class="list-container">
        <div ng-if="!self.getNotificationCookie('notification1')">
            <div
                ng-if="!self.isSolo()"
                class="alert alert-info alert--margin-left"
                role="alert">
                <button type="button" class="close" data-dismiss="alert" aria-label="Close" ng-click="self.setNotificationCookie('notification1','customize_theme')"><i class="icon-close-small"></i></button>
                You want to customize a Live Blog theme? All you need is someone in your team with frontend development skills, a download of the <a href="https://github.com/liveblog/generator-liveblog-theme" target="_blank">theme generator</a> and with a good read of our <a href="https://wiki.sourcefabric.org/display/LIVEBLOG/Live+Blog+themes" target="_blank">documentation in the Wiki</a> - you can easily introduce a theme extension matching the exact needs of your organisation.
            </div>
        </div>
        <div ng-if="!self.getNotificationCookie('notification2')">
            <div
                ng-if="!self.isSolo()"
                class="alert alert-error alert--margin-left"
                role="alert">
                <button type="button" class="close" data-dismiss="alert" aria-label="Close" ng-click="self.setNotificationCookie('notification2','AMP_theme')"><i class="icon-close-small"></i></button>
                Be aware that the Liveblog 3 AMP theme does not yet support all Live Blog features and post types.
            </div>
        </div>


        <!-- LIST VIEW -->
        <script type="text/ng-template" id="themeTree">
            <ul>
                <li ng-init="theme=self.getTheme(themeName)">
                    <div class="theme card" ng-class="{'default': self.isDefaultTheme(theme)}">
                        <figure class="media" ng-click="theme.screenshot_url && self.openThemePreview(theme)" ng-class="{'no-screenshot': !theme.screenshot_url}">
                            <div if-background-image="{{theme.screenshot_url}}"></div>
                            <div ng-if="theme.screenshot_url" class="overlay big-icon-search"></div>
                        </figure>
                        <div class="content">
                            <h3>{{ ::theme.label }}</h3>
                            <dl>
                                <dt>{{ ::'Version' | translate }}:</dt>
                                <dd>{{ ::theme.version }}</dd>
                                <dt>{{ ::'Author' | translate }}:</dt>
                                <dd>
                                    <div ng-if="theme.author.email && !theme.author.url">
                                        <a href="mailto:{{theme.author.email}}?subject={{theme.label}}" target="_blank">{{ ::theme.author.name }}</a>
                                    </div>
                                    <div ng-if="theme.author.url">
                                        <a href="{{theme.author.url}}" ng-show="theme.author.email">{{ ::theme.author.name }}</a>
                                    </div>
                                    <div ng-if="!theme.author.email && !theme.author.url">
                                        {{ ::theme.author.name }}
                                    </div>
                                </dd>
                                <dt ng-if="!self.isSolo()">{{ ::'Sources' | translate }}:</dt>
                                <dd ng-if="!self.isSolo() && theme.repository.url | githubUrlFromGit">
                                    <div ng-if="!theme.repository.url">unavailable</div>
                                    <a href="{{::theme.repository.url | githubUrlFromGit}}/archive/master.zip"
                                       ng-if="theme.repository.url"
                                       target="_blank"> <i class="icon-download"></i></a>
                                    <a href="{{::theme.repository.url | githubUrlFromGit}}"
                                       ng-if="theme.repository.url"
                                       target="_blank">Github</a>
                                </dd>
                                <dd ng-if="!self.isSolo() && theme.repository.url | stashUrlFromGit">
                                    <div ng-if="!theme.repository.url">unavailable</div>
                                    <a href="{{::theme.repository.url | stashUrlFromGit}}/archive?format=zip"
                                       ng-if="theme.repository.url"
                                       target="_blank"> <i class="icon-download"></i></a>
                                    <a href="{{::(theme.repository.url | stashUrlFromGit).replace('rest/api/latest/','')}}"
                                       ng-if="theme.repository.url"
                                       target="_blank">Stash</a>
                                </dd>
                                <dt>{{ ::'No. of blogs using theme' | translate }}:</dt>
                                <dd>
                                    <a ng-click="self.openThemeBlogsModal(theme)" ng-if="theme.blogs_count > 0">
                                        <span translate translate-n="::theme.blogs_count" translate-plural="<span data-name='noOfBlogs'>{{::theme.blogs_count}}</span> blogs">
                                        <span data-name='noOfBlogs'>1 blog</span></span>
                                    </a>
                                    <span ng-if="theme.blogs_count === 0"><span data-name='noOfBlogs'>0</span> <span translate>blogs</span></span>
                                </dd>
                                <dt>{{ ::'Copyright' | translate }}:</dt>
                                <dd>{{ ::theme.license }}</dd>
                            </dl>
                        </div>
                        <div class="side">
                            <div ng-style="{'visibility': (self.isDefaultTheme(theme) && 'hidden') || 'visible'}">
                                <button ng-disabled="self.hasChildren(theme)" ng-click="self.removeTheme(theme)" class="btn btn-default pull-right" type="button" translate>Remove</button>
                                <button ng-if="!theme.abstract" ng-click="self.makeDefault(theme)" class="btn btn--primary pull-right" type="button" translate>Make default</button>
                            </div>
                            <button ng-click="self.openThemeSettings(theme)" class="btn btn-default pull-right" type="button" translate>Settings</button>
                        </div>
                        <div class="default-theme" ng-show="self.isDefaultTheme(theme)"></div>
                    </div>
                    <ng-include ng-repeat="(themeName, themeChildren) in themeChildren" src="'themeTree'"></ng-include>
                </li>
            </ul>
        </script>
        <ng-include ng-repeat="(themeName, themeChildren) in self.themesHierachy" src="'themeTree'"></ng-include>
    </div>
</section>
<div sd-modal="" data-model="self.themeBlogsModal" class="theme-blogs-modal" macro-team="">
    <div class="modal-header" ng-class="{'modal-header-blogs': !self.selectedBlog}">
        <button class="close" ng-click="self.closeThemeBlogsModal()"><i class="icon-close-small"></i></button>
        <div ng-hide="self.selectedBlog">
            <h3 translate>List of blogs using theme</h3>
            <h2>{{self.selectedTheme.label}}</h2>
        </div>
    </div>
    <div class="modal-body">
        <div  ng-hide="self.selectedBlog">
            <ul class="theme-blogs">
                <li ng-repeat="blog in self.selectedTheme.blogs" ng-click="self.switchBlogPreview(blog)">
                    {{ blog.title }}
                    <a ng-href="{{ blog.iframe_url }}" target="_blank"><i class="icon-share"></i></a>
                </li>
            </ul>
        </div>
        <div ng-show="self.selectedBlog">
            <iframe width="100%" height="715" ng-if="self.selectedBlog.iframe_url" ng-src="{{ self.selectedBlog.iframe_url }}" frameborder="0" allowfullscreen></iframe>
        </div>
    </div>
    <div class="modal-footer">
        <button type="button" class="btn btn-default" translate ng-click="self.closeThemeBlogsModal()">Cancel</button>
    </div>
</div>

<div sd-modal="" data-model="self.themePreviewModal" class="theme-preview-modal" macro-team="">
    <div class="modal__header">
        <button class="modal__close pull-right" ng-click="self.themePreviewModal = false"><i class="icon-close-small"></i></button>
    </div>
    <div class="modal__body">
        <img ng-src="{{self.themePreviewModalTheme.screenshot_url}}"
            full-height
            full-height-use-max-height="true"
            full-height-offset-bottom="50"/>
    </div>
</div>

<div sd-modal="" data-model="self.upgradeModal">
    <div class="modal__header">
        <button class="modad__close pull-right" ng-click="self.closeUpgradeModal()">
            <i class="icon-close-small"></i>
        </button>
        <h3>Sorry</h3>
    </div>
    <div class="modal__body">
      <p>You have reached the maximum number of themes on your Live Blog plan. You can either:</p>
      <ul>
        <li>1. Remove an existing theme or</li>
        <li>2. Subscribe to a bigger plan.</li>
      </ul>
      <br/>
      <p>To remove a theme from your Live Blog instance, click on the burger menu on the top left and open the Theme Manager. You can now delete a theme by clicking on the “Remove” button.</p>
      <p>Want to upgrade to a plan more suitable to your needs? Email us at <a href="{{self.mailto}}">upgrade@liveblog.pro</a> and tell us when and how we can best contact you to take your order.</p>
    </div>
</div>

<div
    theme-settings-modal
    theme="self.themeSettingsModalTheme"
    modal-opened="self.themeSettingsModal"
    ng-if="self.themeSettingsModal"
    theme-names="self.themeNames"></div>