Ejemplo n.º 1
0
function createSlider()
{
    include 'header.php';
    \CEOS\Slider\enqueueTransitions();
    wp_enqueue_script('ceos-slider-transition-js', \CEOS\Slider\PLUGIN_PATH_URL . 'scripts/transition.js');
    ?>

	<?php 
    $editID = null;
    if (isset($_GET['edit']) && is_numeric($_GET['edit'])) {
        $editID = $_GET['edit'];
    }
    $editObj = new \CEOS\Slider\Slider();
    $editObj->loadFromDatabase($editID);
    ?>

	<div class="ceos-slider admin-page create-slider-page">
		<form id="create-slider-form" method="POST" action="<?php 
    echo \CEOS\Slider\PLUGIN_PATH_URL;
    ?>
services/push_slider.php" enctype="multipart/form-data">
			<section id="slider-main">
				<header id="main-header">
					<h2 id="page-title">
						<label for="title"><?php 
    echo __('Create new slider');
    ?>
</label>
					</h2>
					<div id="titlediv">
						<input id="title" type="text" maxlength="127" name="title" value="<?php 
    echo $editObj->getTitle();
    ?>
">
					</div>

					<hr />

					<div id="page-header-msg-wrap">
						<?php 
    include 'header_msg.php';
    ?>
					</div>
				</header>

				<div id="slider-content-wrap">
					<h4 id="slider-content-title"><?php 
    echo __('Items');
    ?>
</h4>
					<div id="slider-content-controls">
						<input id="slide-add" type="button" class="button button-primary" value="+">
					</div>
					<ul id="slider-content"></ul>
				</div>
			</section>

			<section id="slider-controls">
				<h4><?php 
    echo __('Settings');
    ?>
</h4>
				
				<input type="hidden" name="id" value="<?php 
    echo $editObj->getID();
    ?>
">
				<input type="hidden" id="remove" name="remove" value="">
				<input type="hidden" id="nonce" name="nonce" value="<?php 
    echo wp_create_nonce(\CEOS\Slider\PLUGIN_PREFIX . '_editslider_' . get_current_user_id());
    ?>
">
				
				<div id="slider-settings">
					<div class="set-row">
						<label class="main" for="opt-transition"><?php 
    echo __('Transition');
    ?>
</label>
						<select id="opt-transition" name="opt-transition">
							<option value="none" <?php 
    echo $editObj->getDefaultTransitionName() == 'none' ? 'selected' : '';
    ?>
><?php 
    echo __('None');
    ?>
</option>
							<?php 
    if (is_array($transitions)) {
        ?>
								<?php 
        foreach ($transitions as $t) {
            ?>
									<option value="<?php 
            echo $t['name'];
            ?>
" <?php 
            echo $editObj->getDefaultTransitionName() == $t['name'] ? 'selected' : '';
            ?>
><?php 
            echo $t['title'];
            ?>
</option>
								<?php 
        }
        ?>
							<?php 
    }
    ?>
						</select>
					</div>
					<div class="set-row">
						<label class="main" for="opt-transition-dur"><?php 
    echo __('Transition duration');
    ?>
</label>
						<input type="number" min="0" step="0.1" id="opt-transition-dur" name="opt-transition-dur" value="<?php 
    echo $editObj->getDefaultTransitionDuration() ? $editObj->getDefaultTransitionDuration() / 1000 : 1;
    ?>
">
						<label for="opt-transition-dur"><?php 
    echo __('sec');
    ?>
</label>
					</div>
					<div class="set-row">
						<label class="main" for="opt-interval"><?php 
    echo __('Slider interval');
    ?>
</label>
						<input type="number" min="1" step="1" id="opt-interval" name="opt-interval" value="<?php 
    echo $editObj->getDefaultInterval() ? $editObj->getDefaultInterval() / 1000 : 7;
    ?>
">
						<label for="opt-interval"><?php 
    echo __('sec');
    ?>
</label>
					</div>
					<div class="set-row">
						<label class="main" for="opt-init-delay"><?php 
    echo __('Initialization delay');
    ?>
</label>
						<input type="number" min="0" step="1" id="opt-init-delay" name="opt-init-delay" value="<?php 
    echo $editObj->getInitializationDelay() ? $editObj->getInitializationDelay() / 1000 : 0;
    ?>
">
						<label for="opt-init-delay"><?php 
    echo __('sec');
    ?>
</label>
					</div>
					<div class="set-row">
						<label class="main" for="opt-initial-item"><?php 
    echo __('Initial item');
    ?>
</label>
						<input type="number" min="0" step="1" id="opt-initial-item" name="opt-initial-item" value="<?php 
    echo $editObj->getInitialItem() ? $editObj->getInitialItem() : 0;
    ?>
">
					</div>
					<hr />
					<div class="set-row">
						<label class="main" for="opt-pause-mouseover"><?php 
    echo __('Pause on mouse over');
    ?>
</label>
						<input type="checkbox" id="opt-pause-mouseover" name="opt-pause-mouseover" value="1" <?php 
    echo $editObj->getPauseOnMouseOver() ? 'checked' : '';
    ?>
>
					</div>
					<div class="set-row">
						<label class="main" for="opt-show-next-prev"><?php 
    echo __('Show Next/Previous controls');
    ?>
</label>
						<input type="checkbox" id="opt-show-next-prev" name="opt-show-next-prev" value="1" <?php 
    echo $editObj->getShowNextPrev() ? 'checked' : '';
    ?>
>
					</div>
					<div class="set-row">
						<label class="main" for="opt-show-nav"><?php 
    echo __('Show navigation controls');
    ?>
</label>
						<input type="checkbox" id="opt-show-nav" name="opt-show-nav" value="1" <?php 
    echo $editObj->getShowNavigation() ? 'checked' : '';
    ?>
>
					</div>
					<div class="set-row">
						<label class="main" for="opt-show-interval"><?php 
    echo __('Show interval');
    ?>
</label>
						<input type="checkbox" id="opt-show-interval" name="opt-show-interval" value="1" <?php 
    echo $editObj->getShowInterval() ? 'checked' : '';
    ?>
>
					</div>
					<div class="set-row">
						<label class="main" for="opt-restart"><?php 
    echo __('Restart when finished');
    ?>
</label>
						<input type="checkbox" id="opt-restart" name="opt-restart" value="1" <?php 
    echo $editObj->getRestart() ? 'checked' : '';
    ?>
>
					</div>

					<hr />
					
					<div class="set-row">
						<h4><?php 
    echo __('Proportions');
    ?>
</h4>
						<div class="set-row inner">
							<span id="prop-width-wrap">
								<label class="main" for="opt-max-width"><?php 
    echo __('Width');
    ?>
</label>
								<input type="number" id="opt-max-width" name="opt-max-width" min="0" step="1" value="<?php 
    echo $editObj->getMaxWidth() ? $editObj->getMaxWidth() : 1920;
    ?>
">
								<label>px</label>
							</span>
							<span id="prop-height-wrap">
								<label class="main" for="opt-max-height"><?php 
    echo __('Height');
    ?>
</label>
								<input type="number" id="opt-max-height" name="opt-max-height" min="0" step="1" value="<?php 
    echo $editObj->getMaxHeight() ? $editObj->getMaxHeight() : 640;
    ?>
">
								<label>px</label>
							</span>
						</div>
						<div class="set-row inner">
							<label class="main" for="opt-aspect-ratio"><?php 
    echo __('Aspect ratio');
    ?>
</label>
							<input type="number" id="opt-aspect-ratio" name="opt-aspect-ratio" min="0" step="0.0001" value="<?php 
    echo $editObj->getAspectRatio() ? $editObj->getAspectRatio() : 0.33;
    ?>
">
						</div>
					</div>
				</div>
				<hr />
				<div id="slider-publish-controls">
					<input id="send-form" type="submit" class="button button-primary" value="<?php 
    echo __('Publish');
    ?>
">
				</div>
			</section>
		</form>
	</div>

	<script type="text/javascript">
		document.addEventListener('DOMContentLoaded', function (){
		<?php 
    for ($i = 0; $i < $editObj->countItems(); $i++) {
        $item = $editObj->getItem($i);
        print 'CEOS.Slider.fillItem({
					id: "' . $item->getID() . '",
					image: "' . $item->getImageSource() . '",
					title: "' . $item->getTitle() . '",
					desc: "' . $item->getDescription() . '",
					url: "' . $item->getURL() . '",
					interval: "' . $item->getInterval() . '",
					transition: "' . $item->getTransitionName() . '",
					transitionDuration: "' . $item->getTransitionDuration() . '"}); ';
    }
    ?>
		})
	</script>

	<?php 
    include 'footer.php';
}