<?php
/**
 * @var $_class N2SmartsliderBackendSliderView
 */


$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-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' />";
    }
}
N2JS::addStaticGroup(NEXTEND_SMARTSLIDER_ASSETS . '/dist/particles.min.js', 'particles');


$folder    = NEXTEND_SMARTSLIDER_ASSETS . '/js/particlejs/presets/';
$files     = N2Filesystem::files($folder);
$extension = 'json';

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

N2JS::addFirstCode("    
new N2Classes.ParticleAdminManager(" . $sliderId . ", " . json_encode($types) . ");
");
?>

<div class="n2-fullapp">
<div class="n2-fullapp-header">
<?php
N2Html::topBar(array(
    "expert"       => false,
    "notification" => false,
    'back'         => '<div class="n2-blue-logo-bg n2-logo n2-lightbox-heading n2-h2">' . n2_('Particle effect') . '</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::renderParticleForm();
?>

</div>

<div class="n2-fullapp-content">

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

    <div class="n2-clear"></div>
</div>
</div>
<?php
