<?php
/**
 * @var $_class N2SmartsliderBackendSliderView
 */
N2JS::addStaticGroup(N2LIBRARYASSETS . "/dist/MorphSVGPlugin.min.js", 'gsap-MorphSVGPlugin');


$postedSliderData            = (array)N2Post::getVar('slider', false);
$postedSliderData['desktop'] = 1; // Shape divider does not work if slider is not visible.
$postedSliderData['playWhenVisible'] = 0;

$slider     = new N2SmartSliderManager($sliderId, false, array(
    'disableResponsive'     => true,
    'addDummySlidesIfEmpty' => true,
    'extend'                => array('sliderData' => $postedSliderData)
));
$sliderHTML = $slider->render();
?>

<style type="text/css">

#n2-admin {
    margin: 0 !important;
    overflow: hidden;
}

body {
    background-color: #e9edf0;
}

html, body {
    height: 100%;
}

.n2-ss-device-zoomer {
    position: absolute;
    left: 50%;
    top: 0;
    margin-left: -140px;
    z-index: 10;
}

.n2-form {
    margin-bottom: 0;
}

.n2-form-tab {
    margin: 0;
    border-width: 0 0 1px 0;
}

.n2-fullapp {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

.n2-fullapp .n2-fullapp-content {
    flex: 1 1 auto;
    overflow: auto;
    min-height: 0;
}

.updated, .notice-success, .notice-info {
    display: none;
}

<?php N2Platform::adminHideCSS(); ?>
</style>

<?php

$externals = N2SmartSliderSettings::get('external-css-files');
if (!empty($externals)) {
    $externals = explode("\n", $externals);
    foreach ($externals AS $external) {
        echo "<link rel='stylesheet' href='" . $external . "' type='text/css' media='all' />";
    }
}

$folder = NEXTEND_SMARTSLIDER_ASSETS . '/shapedivider/';

$files     = N2Filesystem::files($folder);
$extension = 'svg';
$types     = array();
for ($i = 0; $i < count($files); $i++) {
    $pathInfo = pathinfo($files[$i]);
    if (isset($pathInfo['extension']) && $pathInfo['extension'] == $extension) {
        $types['simple-' . $pathInfo['filename']] = file_get_contents($folder . $files[$i]);
    }
}

$folder .= 'bicolor/';
$files  = N2Filesystem::files($folder);
for ($i = 0; $i < count($files); $i++) {
    $pathInfo = pathinfo($files[$i]);
    if (isset($pathInfo['extension']) && $pathInfo['extension'] == $extension) {
        $types['bi-' . $pathInfo['filename']] = file_get_contents($folder . $files[$i]);
    }
}

N2JS::addFirstCode("    
new N2Classes.ShapeDividerAdminManager(" . $sliderId . ", " . json_encode($types) . ");
");
?>
<div class="n2-fullapp">
<div class="n2-fullapp-header">
<?php
N2Html::topBar(array(
    "fixTo"        => false,
    "expert"       => false,
    "notification" => false,
    'back'         => '<div class="n2-blue-logo-bg n2-logo n2-lightbox-heading n2-h2">' . n2_('Shape divider') . '</div>',
    'middle'       => '<div class="n2-ss-device-zoomer">
                <div id="n2-ss-devices" class="n2-ss-devices-compact">
                    <div class="n2-controls-panel n2-table n2-table-auto">
                        <div class="n2-tr">
                        </div>
                    </div>
                </div>
                <div id="n2-ss-zoom">
                    <div class="n2-ss-slider-zoom-container">
                        <i class="n2-i n2-i-minus"></i>
                        <i class="n2-i n2-i-plus"></i>

                        <div class="n2-ss-slider-zoom-bg"></div>

                        <div class="n2-ss-slider-zoom-1"></div>

                        <div id="n2-ss-slider-zoom"></div>
                    </div>
                </div>

                </div>',
    "actions"      => array(
        N2Html::tag('a', array(
            'href'  => $this->appType->router->createUrl(array(
                "sliders/index"
            )),
            'id'    => 'n2-ss-form-cancel',
            'class' => 'n2-button n2-button-normal n2-button-l n2-radius-s n2-button-red n2-h4 n2-b n2-uc',
        ), n2_('Cancel')),
        N2Html::tag('a', array(
            'href'  => '#',
            'id'    => 'n2-ss-form-save',
            'class' => 'n2-button n2-button-normal n2-button-l n2-radius-s n2-button-green n2-h4 n2-b n2-uc',
        ), n2_('Set'))
    )
));

N2SmartsliderSlidersModel::renderShapeDividerForm();
?>
</div>

<div class="n2-fullapp-content n2-scrollable">
<div class="n2-ss-container-device" style="border-width:0;"><?php
    echo $sliderHTML;
    ?></div>
<div class="n2-clear"></div>

</div>
</div>
<?php
