<?php $__env->startSection('head'); ?>
    <script type="text/javascript">
        App.Binder.bindTinymce();
    
        $(function() {
            var firstTime = true;

            var sitemapSelect = $("#cms_gal_sm_id");
            var sitemapItemSelect = $("#cms_gal_smi_id");

            var sitemapChange = function() {
                sitemapSelect.addClass('disabled');

                var data = {"core_sm_id": sitemapSelect.val()};

                $.ajax({
                    url: xhrSitemapItemsUrl,
                    data: data,
                    dataType: "json"
                }).done(function(response) {
                    sitemapItemSelect.select2('data', null);
                    sitemapItemSelect.html('');

                    $.each(response, function(id, row) {
                        if(currentSideMenu != row.value && firstTime == true) {
                            sitemapItemSelect.append($("<option>").attr('value', row.value).html(row.name));
                        } else {
                            sitemapItemSelect.append($("<option selected=\"selected\">").attr('value', row.value).html(row.name));
                        }
                    });

                    sitemapItemSelect.trigger('change');
                }).always(function() {
                    sitemapSelect.removeClass('disabled');
                    firstTime = false;
                });
            };

            sitemapChange();
            sitemapSelect.bind("change", sitemapChange);

            var attachSideMenuChange = function() {
                var sideMenuCheckbox = $("#cms_gal_attach_side_menu");

                if(sideMenuCheckbox.prop("checked") == true) {
                    $("#side-menu-form-group").show();
                } else {
                    $("#side-menu-form-group").hide();
                }
            };

            attachSideMenuChange();
            $("#cms_gal_attach_side_menu").bind("change", attachSideMenuChange);
        });
    </script>
<?php $__env->stopSection(); ?>

<?php $__env->startSection('content'); ?>
    <?php echo HTML::widgetBox(['name' => $gallery ? trans('Gallery::common.edit_gallery') : trans('Gallery::common.add_gallery'), 'icon' => 'icon-picture']); ?>


        <?php echo Former::populate($gallery); ?>

        
        <?php echo Former::open(); ?>


            <?php echo Former::hidden('cms_gal_lang')->forceValue($language); ?>


            <?php echo Former::text('cms_gal_name')->star(); ?>


            <?php echo Former::checkbox('cms_gal_active')->check(); ?>


            <?php echo Former::select('cms_gal_layout')->class('select2')->options($layouts)->star(); ?>


            <?php echo Former::text('cms_gal_thumbnail_width')->star(); ?>


            <?php echo Former::textarea('cms_gal_description')->class('tinymce'); ?>


            <?php if(! is_null($gallery) && ! is_null($gallery->cms_gal_smi_id)): ?>
                <?php echo Former::checkbox('cms_gal_attach_side_menu')->check(); ?>

            <?php else: ?>
                <?php echo Former::checkbox('cms_gal_attach_side_menu'); ?>

            <?php endif; ?>
            <div id="side-menu-form-group">
                <?php echo Former::select('cms_gal_sm_id')->fromQuery($sitemaps, 'core_sm_name', 'core_sm_id'); ?>


                <?php echo Former::select('cms_gal_smi_id')->class('select2'); ?>

            </div>

            <?php echo Former::text('cms_gal_meta_keywords'); ?>


            <?php echo Former::text('cms_gal_meta_description'); ?>


            <?php echo Former::actions( Former::btn_primary_submit(trans('GlobalTranslations::common.save')), Former::default_reset(trans('GlobalTranslations::common.reset_changes'))->onclick('location.reload();')); ?>


        <?php echo Former::close(); ?>

        
    <?php echo HTML::widgetBox(false); ?>

<?php $__env->stopSection(); ?>
<?php echo $__env->make('Backend::layout', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>