<?php
// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) exit;
function AMVG_import_videos_page() {?>
<meta name="referrer" content="no-referrer"/>
<div id="wp-script">
    <div class="content-tabs">
        <div class="row">
            <div class="col-xs-12 padding-top-10 padding-bottom-10">
                <div class="logo"><h2><a href="https://www.wp-script.com" target="_blank"><img class="panda" src="<?php echo WPSCORE_URL; ?>admin/assets/images/logo-wp-script.svg" width="250"/></a></h2></div>
            </div>
        </div>

        <?php WPSCORE()->display_tabs();?>

        <div class="tab-content">
            <div class="tab-pane fade in active" id="import-videos">
                <div>
                    <ul class="list-inline">
                        <li class="active"><a href="admin.php?page=amvg-import-videos"><i class="fa fa-cloud-download"></i> <?php _e('Import videos', AMVG_LANG); ?></a></li>
                        <li>|</li>
                        <li><a href="admin.php?page=amvg-options"><i class="fa fa-wrench"></i> <?php _e('Options', AMVG_LANG); ?></a></li>
                    </ul>
                </div>

                <div v-cloak class="padding-top-15">

                    <div class="row text-center v-cloak--block">
                        <div class="col-xs-12 loading"><p><i class="fa fa-cog fa-spin fa-2x fa-fw" aria-hidden="true"></i><br><?php _e('Loading Page', AMVG_LANG); ?>...</span></p></div>
                    </div>

                    <div class="v-cloak--hidden">

                        <!--**************-->
                        <!-- LOADING DATA -->
                        <!--**************-->
                        <template v-if="loading.loadingData">
                            <div class="row text-center">
                                <div class="col-xs-12 loading"><p><i class="fa fa-cog fa-spin-reverse fa-2x fa-fw" aria-hidden="true"></i><br><?php _e('Loading Data', AMVG_LANG); ?>...</span></p></div>
                            </div>
                        </template>
                        <transition name="fade">
                            <div v-if="dataLoaded">

                                <!-- search videos block -->
                                <div class="row">
                                    <div class="col-xs-12">
                                    <h3>
                                            <template v-if="searchFromFeed">
                                                    <div class="text-center" v-if="searchingVideos">
                                                        <?php _e('Searching new videos from this Saved Feed', AMVG_LANG);?>: <img class="border-radius-4" v-bind:src="'https://res.cloudinary.com/themabiz/image/upload/wpscript/sources/' + selectedPartnerObject.id + '.jpg'" v-bind:alt="selectedPartnerObject.name"> / {{selectedKW != '' && selectedKW != undefined ? 'Keyword "' + selectedKW + '"':'Category "' + selectedPartnerCatName + '"'}}
                                                        <br><br>
                                                        <i class="fa fa-spinner fa-pulse fa-3x" aria-hidden="true"></i>
                                                    </div>
                                                    <div v-else>
                                                        <i class="fa fa-search" aria-hidden="true"></i> {{videosCounter}} <?php _e('new videos found from this Saved Feed', AMVG_LANG);?>: <img class="border-radius-4" v-bind:src="'https://res.cloudinary.com/themabiz/image/upload/wpscript/sources/' + selectedPartnerObject.id + '.jpg'" v-bind:alt="selectedPartnerObject.name"> / {{selectedKW != '' && selectedKW != undefined ? 'Keyword "' + selectedKW + '"':'Category "' + selectedPartnerCatName + '"'}}
                                                    </div>
                                            </template>
                                            <template v-else>
                                                <i class="fa fa-search" aria-hidden="true"></i> <?php _e('Search videos to import', AMVG_LANG); ?>
                                            </template>
                                        </h3>
                                        <div v-show="!searchFromFeed" id="block-search">
                                            <div id="step1" class="block-white block-white-first">
                                                <div class="form-inline">
                                                    <span class="step">1</span>
                                                    <label for="partner_select"><?php _e('Select a partner among', AMVG_LANG); ?> <strong>{{filteredPartnersCounter}}/{{allPartnersCounter}}</strong> :</label>
                                                    <bootstrap-select id="partner_select" v-model="selectedPartner" v-bind:options="{'width':'fit', 'liveSearch':true, 'noneSelectedText':'<?php _e('No partner found', AMVG_LANG); ?>'}">
                                                        <option v-for="(partner, index) in filteredPartners" v-bind:value="partner.id" v-bind:key="partner.id" v-bind:class="[partner.is_configured ? 'partner-configured':'partner-not-configured']" v-if="partner.show">
                                                            {{partner.name}}
                                                        </option>
                                                    </bootstrap-select>
                                                    <button v-bind:disabled="searchingVideos" v-bind:class="[selectedPartnerObject.is_configured ? 'btn-default':'btn-info']" data-toggle="modal" data-target="#partner-options-modal" class="btn"><span v-if="selectedPartnerObject.hasOwnProperty('options')"><i class="fa fa-cog" aria-hidden="true"></i> <?php _e('Configure', AMVG_LANG); ?></span><span v-else><i class="fa fa-info-circle" aria-hidden="true"></i> <span class="hidden-xs"><?php _e('About', AMVG_LANG); ?></span></span> <strong class="sponsor-name">{{selectedPartnerObject.name}}</strong></button>
                                                    <div class="modal fade partner-config" id="partner-options-modal" tabindex="-1" role="dialog" aria-hidden="true">
                                                        <div class="modal-dialog modal-lg">
                                                            <div class="modal-content">
                                                                <div class="modal-body">
                                                                    <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
                                                                    <div v-show="!partnerConfigLoading" v-html="selectedPartnerConfig"></div>
                                                                    <div class="tab-pane active">
                                                                        <div class="row margin-bottom-20">
                                                                            <div class="col-xs-12">
                                                                                <a style="text-align: right;" v-bind:href="'https://www.wp-script.com/partners/' + selectedPartnerObject.id" target="_blank"><img class="border-radius-4" v-bind:src="'https://res.cloudinary.com/themabiz/image/upload/wpscript/sources/' + selectedPartnerObject.id + '.jpg'" v-bind:alt="selectedPartnerObject.name"/></a>
                                                                                <a class="btn btn-info btn-large create-account" v-bind:href="'https://www.wp-script.com/register/' + selectedPartnerObject.id" v-bind:title="'<?php _e('Click here to get an affiliate ID from', AMVG_LANG);?>' + selectedPartnerObject.name" target="_blank"><?php _e('Click here to get an affiliate ID from', AMVG_LANG);?> {{selectedPartnerObject.name}} <i class="fa fa-external-link" aria-hidden="true"></i></a>
                                                                                <ul class="nav nav-tabs padding-top-15" role="tablist">
                                                                                    <li v-if="selectedPartnerObject.options" class="active"><a href="#partner-configuration" role="tab" data-toggle="tab"><i class="fa fa-cog" aria-hidden="true"></i><?php _e('Configuration', AMVG_LANG);?></a></li>
                                                                                    <li v-bind:class="{active:!selectedPartnerObject.options}"><a href="#partner-informations" role="tab" data-toggle="tab"><i class="fa fa-info-circle" aria-hidden="true"></i> <?php _e('Informations', AMVG_LANG);?></a></li>
                                                                                </ul>
                                                                                <div class="tab-content">
                                                                                    <div v-if="selectedPartnerObject.options" role="tabpanel" class="tab-pane active" id="partner-configuration">
                                                                                            <partner-options v-bind:data="selectedPartnerObject.options" v-bind:selected-partner-object="selectedPartnerObject" ></partner-options>
                                                                                    </div>
                                                                                    <div role="tabpanel" class="tab-pane" v-bind:class="{active:!selectedPartnerObject.options}" id="partner-informations">
                                                                                        <div class="row padding-bottom-20 about">
                                                                                            <div class="col-xs-12 col-md-8">
                                                                                                <h4><?php _e('Description', AMVG_LANG);?></h4>
                                                                                                <p>{{selectedPartnerObject.description}}</p>
                                                                                                <br />
                                                                                                <h4><?php _e('Niches', AMVG_LANG);?></h4>
                                                                                                <template v-for="cat in selectedPartnerObject.categories">
                                                                                                    <template v-if="cat.sub_cats">
                                                                                                        <h5>{{cat.name}}</h5>
                                                                                                        <template v-for="sub_cat in cat.sub_cats">
                                                                                                            <span class="label label-default">{{sub_cat.name}}</span>{{String.fromCharCode(13)}}
                                                                                                        </template>
                                                                                                    </template>
                                                                                                    <span v-else class="label label-default">{{cat.name}}</span>{{String.fromCharCode(13)}}
                                                                                                </template>
                                                                                            </div>
                                                                                            <div class="col-xs-12 col-md-4">
                                                                                                <h4><?php _e('Videos Details', AMVG_LANG);?></h4>
                                                                                                <ul>
                                                                                                    <li><strong><?php _e('Language(s)', AMVG_LANG);?></strong>: {{selectedPartnerObject.filters.language.join(', ')}}</li>
                                                                                                    <li><strong><?php _e('HTTPS ready', AMVG_LANG);?></strong>: {{selectedPartnerObject.filters.https === true ? '<?php _e("Yes", AMVG_LANG);?>':'<?php _e("No", AMVG_LANG);?>'}}</li>
                                                                                                    <li><strong><?php _e('Mobile ready', AMVG_LANG);?></strong>: {{selectedPartnerObject.filters.mobile_ready === true ? '<?php _e("Yes", AMVG_LANG);?>':'<?php _e("No", AMVG_LANG);?>'}}</li>
                                                                                                    <li><strong><?php _e('Mobile Redirection', AMVG_LANG);?></strong>: {{selectedPartnerObject.filters.mobile_redirect === true ? '<?php _e("Yes", AMVG_LANG);?>':'<?php _e("No", AMVG_LANG);?>'}}</li>
                                                                                                    <li><strong><?php _e('Multiple Thumbnails', AMVG_LANG);?></strong>: {{selectedPartnerObject.filters.multithumbs === true ? '<?php _e("Yes", AMVG_LANG);?>':'<?php _e("No", AMVG_LANG);?>'}}</li>
                                                                                                    <li><strong><?php _e('Orientation(s)', AMVG_LANG);?></strong>: {{selectedPartnerObject.filters.orientation.join(', ')}}</li>
                                                                                                    <li><strong><?php _e('Actors List', AMVG_LANG);?></strong>: {{selectedPartnerObject.filters.orientation.actors === true ? '<?php _e("Yes", AMVG_LANG);?>':'<?php _e("No", AMVG_LANG);?>'}}</li>
                                                                                                </ul>
                                                                                                <h4><?php _e('Payment Details', AMVG_LANG);?></h4>
                                                                                                <ul>
                                                                                                    <li><strong><?php _e('Devise(s)', AMVG_LANG);?></strong>: {{selectedPartnerObject.filters.devise.join(', ')}}</li>
                                                                                                    <li><strong><?php _e('Payment(s)', AMVG_LANG);?></strong>: {{selectedPartnerObject.filters.payment.join(', ')}}</li>
                                                                                                    <li><strong><?php _e('Program(s)', AMVG_LANG);?></strong>: {{selectedPartnerObject.filters.program.join(', ')}}</li>
                                                                                                </ul>
                                                                                            </div>
                                                                                        </div>
                                                                                    </div>
                                                                                </div>
                                                                            </div>
                                                                        </div>
                                                                    </div>
                                                                    <div class="clearfix"></div>
                                                                </div>
                                                            </div>
                                                            <!-- /.modal-content -->
                                                        </div>
                                                        <!-- /.modal-dialog -->
                                                    </div>
                                                    <!-- /.modal -->

                                                    <div class="btn-group pull-right .visible-md .visible-lg" role="group" aria-label="">
                                                        <button v-bind:disabled="searchingVideos" v-on:click.prevent="togglePartnersFilters" class="btn btn-default" rel="tooltip" data-placement="top" v-bind:data-original-title="partnersFiltersCounter + ' filter(s) enabled'"><i class="fa fa-filter" aria-hidden="true"></i> <span class="hidden-xs"><?php _e('Filter Partners', AMVG_LANG); ?></span> ({{partnersFiltersCounter}}) <span class="caret"></span></button>
                                                        <bootstrap-select id="sort_partners" v-model="sortPartners" v-bind:disabled="searchingVideos" v-bind:options="{'width':'fit'}">
                                                            <option value="popularity"><?php _e('Sort by popularity', AMVG_LANG);?></option>
                                                            <option value="alpha"><?php _e('Sort by alphabetical order', AMVG_LANG);?></option>
                                                        </bootstrap-select>
                                                    </div>
                                                </div>
                                                <transition name="fade">
                                                    <div v-show="showPartnersFilters" class="well no-margin margin-top-20 padding-bottom-10">
                                                        <button v-on:click.prevent="togglePartnersFilters" type="button" class="close" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                                                        <p><i class="fa fa-filter" aria-hidden="true"></i> <?php _e('Too many partners? Use filters below. Partners select box above will be refreshed.', AMVG_LANG); ?></p>
                                                        <div class="row">
                                                            <div class="col-xs-12 col-sm-4 col-md-2">
                                                                <div class="form-group">
                                                                    <small><?php _e('Language', AMVG_LANG); ?>:</small>
                                                                    <bootstrap-select v-model="partnersFilters.language" v-bind:options="{'width':'fit'}">
                                                                        <option value=""><?php _e('All', AMVG_LANG); ?></option>
                                                                        <option value="US"><?php _e('US', AMVG_LANG); ?></option>
                                                                        <option value="FR"><?php _e('FR', AMVG_LANG); ?></option>
                                                                    </bootstrap-select>
                                                                </div>
                                                            </div>                                                        
                                                            <div class="col-xs-12 col-sm-4 col-md-2">
                                                                <div class="form-group">
                                                                    <small><?php _e('Orientation', AMVG_LANG); ?>:</small>
                                                                    <bootstrap-select v-model="partnersFilters.orientation" v-bind:options="{'width':'fit'}">
                                                                        <option value=""><?php _e('All', AMVG_LANG); ?></option>
                                                                        <option value="Straight"><?php _e('Straight', AMVG_LANG); ?></option>
                                                                        <option value="Gay"><?php _e('Gay', AMVG_LANG); ?></option>
                                                                        <option value="Shemale"><?php _e('Shemale', AMVG_LANG); ?></option>
                                                                    </bootstrap-select>
                                                                </div>
                                                            </div>
                                                            <div class="col-xs-12 col-sm-4 col-md-2">
                                                                <div class="form-group">
                                                                    <small><?php _e('HTTPS Ready', AMVG_LANG); ?>:</small>
                                                                    <bootstrap-select v-model="partnersFilters.https" v-bind:options="{'width':'fit'}">
                                                                        <option value=""><?php _e('All', AMVG_LANG); ?></option>
                                                                        <option value="1"><?php _e('Yes', AMVG_LANG); ?></option>
                                                                        <option value="0"><?php _e('No', AMVG_LANG); ?></option>
                                                                    </bootstrap-select>
                                                                </div>
                                                            </div>
                                                            <div class="col-xs-12 col-sm-4 col-md-2">
                                                                <div class="form-group">
                                                                    <small><?php _e('Thumbs Rotation Ready', AMVG_LANG); ?>:</small>
                                                                    <bootstrap-select v-model="partnersFilters.multithumbs" v-bind:options="{'width':'fit'}">
                                                                        <option value=""><?php _e('All', AMVG_LANG); ?></option>
                                                                        <option value="1"><?php _e('Yes', AMVG_LANG); ?></option>
                                                                        <option value="0"><?php _e('No', AMVG_LANG); ?></option>
                                                                    </bootstrap-select>
                                                                </div>
                                                            </div>
                                                        </div>
                                                    </div>
                                                </transition>
                                            </div>
                                            <div id="step-2">
                                                <div class="block-white sponsor-not-configured" v-show="!selectedPartnerObject.is_configured">
                                                    <div class="alert alert-info no-margin">
                                                        <a href="#" data-toggle="modal" data-target="#partner-config-modal" rel="tooltip" data-placement="top" v-bind:data-original-title="'Add your ' + selectedPartnerObject.name + ' ID to track conversions, see their informations and more...'" v-bind:disabled="searchingVideos"><i class="fa fa-cog" aria-hidden="true"></i> <?php _e('Configure', AMVG_LANG); ?> <strong>{{selectedPartnerObject.name}}</strong></a> <?php _e('to use it', AMVG_LANG); ?>.
                                                    </div>
                                                </div>
                                                <div class="block-white sponsor-configured" v-show="selectedPartnerObject.is_configured">
                                                    <div class="form-inline">
                                                        <span class="step">2</span>
                                                        <label for="partner_select"><?php _e('Select a category from', AMVG_LANG); ?> <img class="border-radius-4" v-bind:src="'https://res.cloudinary.com/themabiz/image/upload/wpscript/sources/' + selectedPartnerObject.id + '.jpg'" v-bind:alt="selectedPartnerObject.name"> :</label>
                                                        <i v-show="partnerCatsLoading" class="fa fa-spinner fa-pulse"></i>
                                                        <div v-show="!partnerCatsLoading" style="display:inline;">
                                                            <partner-cats-select v-model="selectedCat" id="cat_s_select" v-bind:data="partnerCats" v-bind:options="{'width':'fit', 'liveSearch':true}"></partner-cats-select>
                                                        </div>
                                                        <span id="kw-search" v-show="selectedPartnerObject.filters.search_by == 'keyword'">
                                                        <strong>- <?php _e('OR', AMVG_LANG); ?> -</strong> <?php _e('Enter some keywords', AMVG_LANG); ?>: <input v-model="selectedKW" v-bind:disabled="searchingVideos" v-on:keyup.enter.prevent="searchVideos('create')" id="kw_s" type="text" placeholder="<?php _e('eg. ebony lesbian', AMVG_LANG); ?>" name="kw_s" class="form-control" style="width:250px;">
                                                        </span>
                                                    </div>
                                                </div>
                                            </div>
                                            <div id="step-3" class="block-white sponsor-configured block-white-last" v-show="selectedPartnerObject.is_configured">
                                                <span class="step">3</span>
                                                <span v-show="videosHasBeenSearched">
                                                    <button class="btn btn-default disabled"  ><i class="fa fa-check" aria-hidden="true"></i> <?php _e('Search done!', AMVG_LANG); ?></button>
                                                </span>
                                                <button v-show="!searchingVideos && !videosHasBeenSearched" v-on:click.prevent="searchVideos('create')" class="btn btn-info" v-bind:class="searchBtnClass" v-bind:disabled="searchBtnClass == 'disabled'" rel="tooltip" data-placement="top" v-bind:data-original-title="searchButtonTooltip"><i class="fa fa-search" aria-hidden="true"></i> <?php _e('Search videos', AMVG_LANG); ?></button>
                                                <button v-show="searchingVideos" disabled="disabled" class="btn btn-info"><i class="fa fa-spinner fa-pulse" aria-hidden="true"></i> <?php _e('Searching videos...', AMVG_LANG); ?></button>
                                                <small><i class="fa fa-info-circle" aria-hidden="true"></i> <?php printf(__('Each search displays up to %s unique videos at a time and excludes any videos already imported.', AMVG_LANG), '{{data.videosLimit}}'); ?></small>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                                <!-- / search videos block -->

                                <!-- results success block -->
                                <div class="row">
                                    <div class="col-xs-12" v-show="videosCounter <= 0 && videosHasBeenSearched">
                                        <div v-if="videosSearchedErrors.code" class="alert alert-danger margin-top-10 text-center alert-dismissible" role="alert">
                                            <button type="button" class="close" v-on:click.prevent="resetSearch" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                                            <p><i class="fa fa-exclamation-triangle" aria-hidden="true"></i> <strong>{{videosSearchedErrors.code}}</strong><br>{{videosSearchedErrors.message}}<br>-<br>{{videosSearchedErrors.solution}}</p>
                                            <p>
                                                <button class="btn btn-danger margin-top-10" v-on:click.prevent="resetSearch"><?php _e('Close', AMVG_LANG);?></button>
                                            </p>
                                        </div>
                                        <div v-else class="alert alert-info margin-top-10 text-center alert-dismissible" role="alert">
                                            <button type="button" class="close" v-on:click.prevent="resetSearch" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                                            <p><i class="fa fa-meh-o" aria-hidden="true"></i> <strong><?php _e('No video found', AMVG_LANG);?></strong><br>
                                                <?php _e('All videos may have been already imported for the current search or via other imports with', AMVG_LANG);?> {{selectedPartnerObject.name}}<br>
                                                - <?php _e('OR', AMVG_LANG);?> -<br>
                                                <?php _e('There is unfortunately no video for this search', AMVG_LANG);?>
                                            </p>
                                            <p>
                                                <button class="btn btn-info margin-top-10" v-on:click.prevent="resetSearch"><?php _e('Close', AMVG_LANG);?></button>
                                            </p>
                                        </div>
                                    </div>
                                    <transition name="fade">
                                        <div v-show="videosCounter > 0" id="videos-found" class="col-xs-12 margin-top-10">
                                            <div id="sticky-space" class="col-xs-12"></div>
                                            <div id="videos-found-header" class="col-xs-12">
                                                <div id="videos-found-header-block" class="margin-bottom-10">
                                                    <div class="form-inline">
                                                        <div id="videos-found-header-left" class="pull-left">
                                                            <button v-bind:disabled="importingVideos" v-on:click.prevent="toogleAllVideos" class="btn btn-default" id="bulk-checked" rel="0"><i class="fa" v-bind:class="[allVideosChecked ? 'fa-check-square-o':'fa-square-o']"></i> <span v-if="!allVideosChecked"><?php _e('Check all videos', AMVG_LANG);?></span><span v-else><?php _e('Uncheck all videos', AMVG_LANG);?></span></button>
                                                            <span v-show="!firstImport">
                                                                <button  v-on:click.prevent="importVideos" v-bind:class="importBtnClass" v-bind:disabled="importBtnClass == 'disabled'" type="submit" class="btn btn-success" rel="tooltip" data-placement="top" v-bind:data-original-title="importButtonTooltip">
                                                                    <span v-if="importingVideos">
                                                                        <i class="fa fa-spinner fa-pulse"></i> {{savedCheckedVideosCounter - checkedVideosCounter}}/{{savedCheckedVideosCounter}} <?php _e('videos imported in', AMVG_LANG);?> {{selectedWPCatName}}
                                                                    </span>
                                                                    <span v-else>
                                                                        <i class="fa fa-cloud-download"></i> <?php _e('Import', AMVG_LANG);?> {{checkedVideosCounter}} <?php _e('videos in', AMVG_LANG);?> {{selectedWPCatName}}
                                                                    </span>
                                                                </button>
                                                                    <button v-bind:disabled="importingVideos" class="btn btn-info" v-on:click.prevent="searchVideos('update')" rel="tooltip" data-placement="top" data-original-title="<?php _e('Hide current imported videos and search new videos', AMVG_LANG);?>"><i class="fa fa-refresh" aria-hidden="true"></i> <?php _e('Refresh search results', AMVG_LANG);?></button>
                                                            </span>
                                                            <span v-show="firstImport">
                                                                <bootstrap-select id="cat_wp_select" v-model="selectedWPCat" v-bind:options="{'width':'fit', 'liveSearch':true}">
                                                                    <option value="0">- <?php _e('Select a WordPress category', AMVG_LANG); ?> -</option>
                                                                    <option data-divider="true"></option>
                                                                    <option value="+"><strong>+ <?php _e('Add a new category', AMVG_LANG); ?></strong></option>
                                                                    <option data-divider="true"></option>
                                                                    <option v-for="(WPCat, index) in data.WPCats" v-bind:value="WPCat.term_id" v-bind:key="WPCat.term_id">
                                                                        {{WPCat.name}}
                                                                    </option>
                                                                </bootstrap-select>
                                                                <button v-on:click.prevent="importVideos" v-bind:class="importBtnClass" type="submit" class="btn btn-success" rel="tooltip" data-placement="top" v-bind:data-original-title="importButtonTooltip">
                                                                    <span v-if="importingVideos">
                                                                        <i class="fa fa-spinner fa-pulse"></i> {{savedCheckedVideosCounter - checkedVideosCounter}}/{{savedCheckedVideosCounter}} <?php _e('videos imported in', AMVG_LANG);?> {{selectedWPCatName}}
                                                                    </span>
                                                                    <span v-else>
                                                                        <i class="fa fa-cloud-download"></i> <?php _e('Import', AMVG_LANG);?> {{checkedVideosCounter}} <?php _e('videos in', AMVG_LANG);?> {{selectedWPCatName}}
                                                                    </span>
                                                                </button>
                                                            </span>
                                                        </div>
                                                        <div class="pull-right">
                                                            <div id="display-type" class="btn-group">
                                                                <button class="btn btn-default" v-bind:class="{'active':displayType == 'cards'}" v-on:click="updateDisplayType('cards')"><i class="fa fa-th" aria-hidden="true"></i></button>
                                                                <button class="btn btn-default" v-bind:class="{'active':displayType == 'lists'}" v-on:click="updateDisplayType('lists')"><i class="fa fa-list-ul" aria-hidden="true"></i></button>
                                                            </div>
                                                            <button v-show="videosHasBeenSearched" v-on:click.prevent="resetSearch" v-bind:disabled="importingVideos" class="btn btn-danger"><span class="fa fa-times" aria-hidden="true"></span></button>
                                                        </div>
                                                    </div>
                                                    <div class="clearfix"></div>
                                                </div>
                                                <div class="progress">
                                                    <div class="progress-bar progress-bar-success" role="progressbar" v-bind:aria-valuenow="importProgress" aria-valuemin="0" aria-valuemax="100" v-bind:style="'width:' + importProgress + '%;'">
                                                    <span><i aria-hidden="true" class="fa fa-check"></i> <?php _e('Import done!', AMVG_LANG); ?></span>
                                                    </div>
                                                </div>

                                                <div v-if="!selectedPartnerObject.filters.https && siteIsHttps" class="row margin-top-0 margin-bottom-10">
                                                    <div class="col-xs-12">
                                                        <div class="alert alert-danger text-center margin-bottom-0" role="alert">
                                                            <p><i class="fa fa-exclamation-triangle" aria-hidden="true"></i> <strong>{{selectedPartnerObject.name}} <?php _e('videos does NOT work with SSL (HTTPS://)', AMVG_LANG); ?></strong></p>
                                                        </div>
                                                    </div>
                                                </div>

                                            </div>
                                            <div id="videos" class="row" v-bind:class="displayType">
                                                <template v-if="displayType == 'cards'">
                                                    <div v-for="(video, index) in videos" class="col-xs-12 col-sm-6 col-md-3 col-lg-2 item-cards" v-bind:key="video.id">
                                                        <div class="video" v-bind:class="{'grabbed': video.grabbed, 'checked': video.checked}" >
                                                            <div class="video-img" v-on:click.prevent="setCurrentVideo(video, index)">
                                                                <img class="img-responsive" src="<?php echo AMVG_URL;?>admin/assets/img/loading-thumb.gif" v-img="video.thumb_url" data-toggle="modal" data-target="#video-preview-modal" v-bind:alt="video.title" />
                                                                <span class="video-duration" data-toggle="modal" data-target="#video-preview-modal">{{video.duration | timeFormat}}</span>
                                                            </div>
                                                            <h4>{{video.title}}</h4>
                                                            <div class="btn-group btn-group-justified" v-if="!video.grabbed">
                                                                <div class="btn-group">
                                                                    <button v-on:click.prevent="toggleVideo(index, 'list')" class="btn text-center" v-bind:class="[video.checked ? 'btn-success':'btn-default']"><i class="fa-lg" v-bind:class="[video.checked ? 'fa fa-check-square-o':'fa fa-square-o']" aria-hidden="true"></i></button>
                                                                </div>
                                                                <div class="btn-group">
                                                                    <button v-on:click.prevent="setCurrentVideo(video, index)" type="button" class="btn btn-default text-center video-preview" data-toggle="modal" data-target="#video-preview-modal">
                                                                        <i class="fa fa-pencil" aria-hidden="true"></i>
                                                                    </button>
                                                                </div>
                                                            </div>
                                                            <button v-else class="btn text-center btn-block disabled"><?php _e('Video imported', AMVG_LANG);?></button>
                                                        </div>
                                                    </div>
                                                </template>
                                                <template v-else>
                                                    <div class="col-xs-12">
                                                        <div class="panel panel-default margin-bottom-10">
                                                            <table class="table table-striped table-hover table-bordered">
                                                                <tr>
                                                                    <th width="35"></th>
                                                                    <th width="100"><?php _e('Thumb', AMVG_LANG); ?></th>
                                                                    <th><?php _e('Title', AMVG_LANG); ?></th>
                                                                    <th><?php _e('Description', AMVG_LANG); ?></th>
                                                                    <th><?php _e('Tags and Actors', AMVG_LANG); ?></th>
                                                                </tr>
                                                                <tr v-for="(video, index) in videos" v-bind:key="video.id" class="item-list" v-bind:class="{'success':video.checked, 'grabbed':video.grabbed}">
                                                                    <td v-if="!video.grabbed" class="item-list-toggle" width="35" v-on:click.prevent="toggleVideo(index, 'list')">
                                                                        <i class="fa-lg" v-bind:class="[video.checked ? 'fa fa-check-square-o text-success':'fa fa-square-o']" aria-hidden="true"></i>
                                                                    </td>
                                                                    <td v-else class="item-list-toggle" width="35"></td>
                                                                    <td width="100">
                                                                        <img v-if="!video.grabbed" width="100" v-on:click.prevent="setCurrentVideo(video, index)" class="pointer" src="<?php echo AMVG_URL;?>admin/assets/img/loading-thumb.gif" v-img="video.thumb_url" data-toggle="modal" data-target="#video-preview-modal" v-bind:alt="video.title" />
                                                                        <img v-else width="100"  src="<?php echo AMVG_URL;?>admin/assets/img/loading-thumb.gif" v-img="video.thumb_url" v-bind:alt="video.title" />
                                                                    </td>
                                                                    <template v-if="video.grabbed">
                                                                        <td colspan="3" class="video-td-imported"><?php _e('Video imported', AMVG_LANG); ?></td>
                                                                    </template>
                                                                    <template v-else>
                                                                        <td>
                                                                            <div class="margin-bottom-5"><input type="text" name="" v-model="video.title" v-bind:disabled="video.grabbed" class="form-control" placeholder="<?php _e('Title', AMVG_LANG); ?>..."></div>
                                                                            <template v-if="video.duration"><i class="fa fa-clock-o" aria-hidden="true"></i> <small>{{video.duration | timeFormat}}</small></template>
                                                                        </td>
                                                                        <td>
                                                                            <textarea placeholder="<?php _e('Description', AMVG_LANG); ?>..." name="" v-model="video.desc" v-bind:disabled="video.grabbed" class="form-control"></textarea>
                                                                        </td>
                                                                        <td>
                                                                            <div class="input-group margin-bottom-8">
                                                                                <span class="input-group-addon"><i class="fa fa-users" aria-hidden="true"></i> <small><?php _e('Actors', AMVG_LANG); ?></small></span>
                                                                                <input type="text" name="actors" class="form-control" v-model="video.actors" v-bind:disabled="video.grabbed" placeholder="insert actors separated by a comma" aria-describedby="actors">
                                                                            </div>
                                                                            <div class="input-group">
                                                                                <span class="input-group-addon" id="tags"><i class="fa fa-tags" aria-hidden="true"></i> <small><?php _e('Tags', AMVG_LANG); ?></small></span>
                                                                                <input type="text" name="tags" class="form-control" v-model="video.tags" v-bind:disabled="video.grabbed" placeholder="insert tags separated by a comma" aria-describedby="tags">
                                                                            </div>
                                                                        </td>
                                                                    </template>
                                                                </tr>
                                                            </table>
                                                        </div>
                                                    </div>
                                                </template>
                                            </div>
                                            <div class="clear"></div>

                                            <!-- Create WP Cat Modal -->
                                            <div class="modal fade" id="add-wp-cat-modal">
                                            <div class="modal-dialog" role="document">
                                                <div class="modal-content">
                                                <div class="modal-header">
                                                <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only"><?php _e('Close', AMVG_LANG); ?></span></button>
                                                <h4 class="modal-title"><?php _e('Add a new WordPress Category', AMVG_LANG);?></h4>
                                                </div>
                                                <div class="modal-body">
                                                    <div class="row">
                                                    <div class="col-xs-12 margin-bottom-5">
                                                        <div class="input-group">
                                                            <span class="input-group-addon" id="new_category_name"><?php _e('Name', AMVG_LANG); ?></span>
                                                            <input type="text" name="new_category_name" class="form-control" v-model="newWpCategoryName" placeholder="New category name" aria-describedby="new category name">
                                                        </div>
                                                    </div>
                                                    </div>
                                                </div>
                                                <div class="modal-footer">
                                                    <div class="row">
                                                    <div class="col-xs-12">
                                                        <button class="btn btn-default" data-dismiss="modal">Cancel</button>
                                                        <button class="btn btn-primary" v-bind:class="{'disabled': !newWpCategoryName || addingNewWpCategory}" v-on:click="addNewWpCategory">
                                                        <template v-if="addingNewWpCategory">
                                                            <i class="fa fa-spinner fa-pulse"></i> <?php _e('Adding', AMVG_LANG); ?> {{newWpCategoryName}}
                                                        </template>
                                                        <template v-else>
                                                            <?php _e('Add New Category', AMVG_LANG); ?>
                                                        </template>
                                                        </button>
                                                    </div>
                                                    </div>
                                                </div>
                                                </div>
                                            </div>
                                            </div>
                                            <!-- /Create WP Cat Modal -->

                                            <!-- Video Modal -->
                                            <div class="modal fade" id="video-preview-modal" tabindex="-1" role="dialog">
                                                <div class="modal-dialog">
                                                    <div class="modal-content">
                                                        <div class="modal-header">
                                                            <div class="row">
                                                                <div class="col-xs-11">
                                                                <input type="text" name="" v-model="currentVideo.title" v-bind:disabled="currentVideo.grabbed" class="form-control" placeholder="<?php _e('Title', AMVG_LANG); ?>...">
                                                                </div>
                                                                <div class="col-xs-1">
                                                                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                                                                </div>
                                                            </div>
                                                        </div>
                                                        <div class="modal-body" v-bind:key="currentVideo.id">
                                                            <div class="row">
                                                                <div class="col-xs-12">
                                                                    <ul class="nav nav-tabs padding-top-15" role="tablist">
                                                                        <li class="active"><a href="#current-video-data" role="tab" data-toggle="tab"><i class="fa fa-youtube-play" aria-hidden="true"></i> <?php _e('Video data', AMVG_LANG);?></a></li>
                                                                        <li v-if="currentVideo.thumbs_urls != ''"><a href="#current-video-thumbs" role="tab" data-toggle="tab"><i class="fa fa-picture-o" aria-hidden="true"></i></span> <?php _e('Thumbnails', AMVG_LANG);?></a></li>
                                                                    </ul>
                                                                    <div class="tab-content">
                                                                        <div role="tabpanel" class="tab-pane active" id="current-video-data">
                                                                            <div class="row">
                                                                                <div class="col-xs-12">
                                                                                    <div v-if="!selectedPartnerObject.filters.https && siteIsHttps" class="text-center text-danger">
                                                                                        <img class="img-responsive" v-bind:src="currentVideo.thumb_url">
                                                                                        <div class="alert alert-danger text-center margin-top-10 margin-bottom-0" role="alert">
                                                                                            <p><i class="fa fa-exclamation-triangle" aria-hidden="true"></i> <strong>{{selectedPartnerObject.name}} <?php _e('videos does NOT work with SSL (HTTPS://)', AMVG_LANG); ?></strong></p>
                                                                                        </div>
                                                                                    </div>
                                                                                    <template v-else>
                                                                                        <div v-if="currentVideoUrl != ''" class="embed-responsive embed-responsive-16by9">
                                                                                            <video controls class="embed-responsive-item" v-bind:poster="currentVideo.thumb_url">
                                                                                                <source v-bind:src="currentVideoUrl">
                                                                                            </video>
                                                                                        </div>
                                                                                        <div v-if="currentVideoUrl == '' && currentVideoEmbed != ''" v-html="currentVideoEmbed" class="embed-responsive embed-responsive-16by9"></div>
                                                                                    </template>
                                                                                </div>
                                                                            </div>
                                                                            <div class="row padding-top-15">
                                                                                <div class="col-xs-12 form-horizontal">
                                                                                    <div class="form-group">
                                                                                        <label for="actors" class="col-sm-2 control-label">Actors:</label>
                                                                                        <div class="col-sm-10">
                                                                                            <input type="text" id="actors" name="actors" class="form-control" v-model="currentVideo.actors" v-bind:disabled="currentVideo.grabbed" placeholder="insert actors separated by a comma">
                                                                                        </div>
                                                                                    </div>
                                                                                    <div class="form-group">
                                                                                        <label for="tags" class="col-sm-2 control-label">Tags:</label>
                                                                                        <div class="col-sm-10">
                                                                                            <input type="text" name="tags" class="form-control" v-model="currentVideo.tags" v-bind:disabled="currentVideo.grabbed" placeholder="insert tags separated by a comma">
                                                                                        </div>
                                                                                    </div>
                                                                                </div>
                                                                            </div>
                                                                            <div class="row">
                                                                                <div class="col-xs-12">
                                                                                    <textarea placeholder="<?php _e('Description', AMVG_LANG); ?>..." rows="5" name="" v-model="currentVideo.desc" v-bind:disabled="currentVideo.grabbed" class="form-control"></textarea>
                                                                                </div>
                                                                            </div>
                                                                        </div>
                                                                        <div role="tabpanel" class="tab-pane" id="current-video-thumbs">
                                                                            <div v-if="currentVideo.thumbs_urls != ''" class="row">
                                                                                <transition name="fade" mode="out-in">
                                                                                    <div v-if="expandedThumb == ''" key="allThumbs"> 
                                                                                    <div v-for="thumb in currentVideo.thumbs_urls" v-bind:key="thumb" class="col-xs-6 col-md-3 item">
                                                                                        <img class="img-responsive thumbnail" v-bind:src="thumb" v-on:click="showThumb(thumb)">
                                                                                    </div>
                                                                                    </div>
                                                                                
                                                                                    <div v-if="expandedThumb != ''" class="col-xs-12 item" key="expandedThumb">
                                                                                    <img class="img-responsive thumbnail" v-bind:src="expandedThumb" v-on:click="hideThumb">
                                                                                    </div>
                                                                                </transition>
                                                                            </div>
                                                                        </div>
                                                                    </div>
                                                                </div>
                                                            </div>
                                                        </div>
                                                        <div class="modal-footer">
                                                            <div class="row">
                                                                <div class="col-xs-3 col-md-3">
                                                                    <button v-on:click.prevent="prevVideoModal(currentVideo.index)" type="button" class="btn btn-default btn-block"><i class="fa fa-arrow-left"></i></button>
                                                                </div>
                                                                <div class="col-xs-6 col-md-6">
                                                                    <button v-if="!currentVideo.grabbed" v-on:click.prevent="toggleVideo(currentVideo.index, 'modal')" type="button" class="btn btn-block" v-bind:class="[currentVideo.checked ? 'btn-success':'btn-default']"><i class="fa-lg" v-bind:class="[currentVideo.checked ? 'fa fa-check-square-o':'fa fa-square-o']" aria-hidden="true"></i> <span v-if="!currentVideo.checked"><?php _e('Check this video', AMVG_LANG); ?></span><span v-else><?php _e('Uncheck this video', AMVG_LANG); ?></span></button>
                                                                    <button v-else type="button" class="btn btn-default btn-block" disabled><?php _e('Video grabbed', AMVG_LANG); ?></button>
                                                                </div>
                                                                <div class="col-xs-3 col-md-3">
                                                                    <button v-on:click.prevent="nextVideoModal(currentVideo.index)" type="button" class="btn btn-default btn-block"><i class="fa fa-arrow-right"></i></button>
                                                                </div>
                                                            </div>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
                                            <!--/ video modal-->
                                        </div>
                                    </transition>
                                </div>
                                <!-- /results success block -->

                                <!-- feeds block -->
                                <div id="feeds" class="margin-top-80">
                                    <div class="row">
                                        <div class="col-xs-12">
                                            <h3>
                                                <i class="fa fa-th-list" aria-hidden="true"></i>  <?php _e('Saved Feeds', AMVG_LANG); ?> ({{data.feeds.length}})
                                            </h3>
                                            <span class="form-inline">
                                                <input v-if="data.feeds.length > 0" type="text" class="form-control" placeholder="filter feeds" v-model="feedsFilter">
                                                <paginate-links for="feeds" v-bind:hide-single-page="true" v-bind:simple="{prev: 'Prev', next: 'Next'}" v-bind:classes="{'ul': 'pagination'}"></paginate-links>
                                                <small> - <a href="#" v-on:click.prevent="toggleSavedSearchesHelp"><?php _e('What are Saved Feeds?', AMVG_LANG);?></a></small>
                                            </span>
                                        </div>
                                    </div>
                                    <div class="row">
                                        <div class="col-xs-12">
                                            <div v-show="showSavedSearchesHelp" class="alert alert-info margin-bottom-10">
                                                <button v-on:click.prevent="toggleSavedSearchesHelp" type="button" class="close" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                                                <p><?php _e('Whenever you import videos from a new search, a Feed is saved. A Feed is a saved state, keeping your current search linked to the selected WordPress category. Your feeds are listed just bellow, providing informations and actions for each one.', AMVG_LANG);?></p>
                                            </div>
                                        </div>
                                    </div>

                                    <paginate name="feeds" v-bind:list="filteredFeeds" v-bind:per="12" class="row" id="feeds-list" tag="div">
                                        <feed v-if="data.feeds.length > 0" v-for="(feed, index) in paginated('feeds')" v-bind:key="index" v-bind:feed="feed" v-bind:wp-cats="data.WPCats" v-bind:partner-cat-name="getPartnerCatName(feed.partner_id, feed.partner_cat)" v-bind:delete-feed-id="deleteFeedId" v-bind:partners="data.partners" v-bind:smt-is-loading="smtIsLoading" v-bind:auto-import-enabled='data.autoImportEnabled' @confirm-feed-deletion="confirmFeedDeletion" @search-videos="searchVideos"></feed>
                                    </paginate>
                                    <p v-if="data.feeds.length == 0"><?php _e('No feed has been saved yet', AMVG_LANG);?></p>

                                    <!-- delete modal -->
                                    <div class="modal fade" id="delete-modal" tabindex="-1" role="dialog" aria-hidden="true">
                                        <div class="modal-dialog modal-lg">
                                            <div class="modal-content">
                                                <div class="modal-header">
                                                    <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only"><?php _e('Close', AMVG_LANG); ?></span></button>
                                                    <h4 class="modal-title ajax-msg-title"><i class="fa fa-exclamation-triangle" aria-hidden="true"></i> <?php _e('Delete feed confirmation', AMVG_LANG); ?></h4>
                                                </div>
                                                <div class="modal-body ajax-body">

                                                    <div class="ajax-content">
                                                        <p><?php _e('Do you really want to delete this feed? All videos from this feed will be removed.', AMVG_LANG); ?></p>

                                                        <p class="delete-buttons">
                                                        <button class="btn btn-danger action-delete" v-bind:disabled="loading.deleteFeed" v-on:click.prevent="deleteFeed"><i class="fa fa-trash-o" v-bind:class="[loading.deleteFeed ? 'fa-spinner fa-pulse':'fa-trash-o']" aria-hidden="true"></i> <span v-if="!loading.deleteFeed"><?php _e('Delete this feed', AMVG_LANG); ?></span><span v-else><?php _e('Deleting feed', AMVG_LANG); ?></span></button>&nbsp;&nbsp;&nbsp;&nbsp;<button class="btn btn-default" v-bind:disabled="loading.deleteFeed" data-dismiss="modal"><?php _e('Cancel', AMVG_LANG); ?></button></p>
                                                    </div>

                                                    <div class="clearfix"></div>
                                                </div>
                                            </div><!-- /.modal-content -->
                                        </div><!-- /.modal-dialog -->
                                    </div><!-- /.modal -->
                                    <!-- .delete modal -->
                                </div>
                            </div>
                        </transition>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<?php }
