<?php
/* @var $this SliderController */
/* @var $model Slider */
$this->breadcrumbs = array(
    'Sliders' => array('admin'),
    $model->title,
);
$this->menu = array(
    array('label' => 'Manage Slider', 'url' => array('admin')),
    array('label' => 'Create Slider', 'url' => array('create')),
    array('label' => 'Update Slider', 'url' => array('update', 'id' => $model->id)),
    array('label' => 'Delete Slider', 'url' => '#', 'linkOptions' => array('submit' => array('delete', 'id' => $model->id), 'confirm' => 'Are you sure you want to delete this item?')),
);
?>
<div class="page-header"><h1>View Slider: <?php echo $model->title; ?></h1></div>
<?php if (count($sliderImages)): ?>
    <?php
    $baseUrl = Yii::app()->baseUrl;
    ?>
    <div id="ajax-flashes" class="ajax-flashes"></div>
    <div class="col-xs-12">
        <div class="form-actions">
            <?php
            // Add a Submit button to send data to the controller
            echo CHtml::ajaxButton(Yii::t('admin', 'Save'), array('slider/order', 'slider_id' => $model->id), array(
                'type' => 'POST',
                'data' => array(
                    // Turn the Javascript array into a PHP-friendly string
                    'Order' => 'js:$("ul#sortable").sortable("toArray")',
                    Yii::app()->request->csrfTokenName => Yii::app()->request->getCsrfToken(),
                ),
                'success' => 'js:function(data) {
                                            jQuery(".ajax-flashes").append(data);
                                            jQuery(".page-loader").hide();
                                    }',
                    ), array(
                'class' => 'btn btn-primary',
                'onClick' => 'jQuery(".page-loader").show();'));
            ?>
            <span class="note"> <?php echo Yii::t('admin', 'Click "Save" After reordering the images inside this album.'); ?></span>
        </div>
        <div class="space"></div>
    </div>

    <div class="thumb-container">

        <?php
        $items = array();
        foreach ($sliderImages as $image) {
            $items[$image->id] = $this->renderPartial('/sliderImages/_updateForm', array('model' => $image), true);
        }
        $this->widget('zii.widgets.jui.CJuiSortable', array(
            'id' => 'sortable',
            'htmlOptions' => array('class' => 'col-xs-12'),
            'items' => $items,
            'options' => array(
                'cursor' => 'n-resize',
            ),
        ));
        ?>
        <?php echo $this->renderPartial('/sliderImages/_pageSelectDialog', array('model' => $image)); ?>
    </div>
    <?php
else:
    echo Yii::t('zii', 'No results found.');
endif;
?>