<?php
$textAttributes = [
    'id' => $id . '_label',
    'class' => 'form-control field-link-label ' . (isset($language) && $language == $defaultLang ? ' default-lang' : ''),
    'maxlength' => $maxLength,
    'data-toggle' => (isset($errors) && $errors->has($errorKey . '.label') ? 'tooltip': null),
    'title' => (isset($errors) && $errors->has($errorKey . '.label') ? $errors->first($errorKey . '.label'): null),
    'placeholder' => trans('backend.insert_link_label')
];
$searchAttributes = [
    'id' => $id . '_search',
    'class' => 'form-control multiple-picker-search-field',
    'maxlength' => '150',
    'placeholder' => ucfirst(Illuminate\Support\Facades\Lang::get('backend.search')),
];
$urlAttributes = [
    'id' => $id . '_url',
    'class' => 'form-control field-link-url' . (isset($language) && $language == $defaultLang ? ' default-lang' : ''),
    'data-toggle' => (isset($errors) && $errors->has($errorKey . '.url') ? 'tooltip': null),
    'title' => (isset($errors) && $errors->has($errorKey . '.url') ? $errors->first($errorKey . '.url'): null),
    'placeholder' => trans('backend.insert_link_url')
];
$isExternalAttributes = [
    'id' => $id . '_isExternal',
    'class' => 'is-external-checkbox',
];
$isNewtabAttributes = [
    'id' => $id . '_isNewtab',
    'class' => 'is-newtab-checkbox',
];
if (!$enabled) {
    $textAttributes['disabled'] = true;
    $isExternalAttributes['disabled'] = true;
    $isNewtabAttributes['disabled'] = true;
    $urlAttributes['disabled'] = true;
    $searchAttributes['disabled'] = true;
}
?>
<?php if(isset($language)): ?>
<div id="link-field-<?php echo e($id); ?>" class="form-field-link is-versionable form-group form-language-group <?php echo e($blocksMode ? "blocks-mode--$blocksMode" : 'blocks-mode--hide'); ?> form-language-<?php echo e($language); ?><?php echo e($language == $defaultLang ? ' default-lang' : ''); ?><?php echo e((isset($hasErrors) && $hasErrors ? ' has-group-error' : '')); ?><?php echo e($parentHidden ? ' parent-hidden' : ''); ?>" style="<?php echo e(!empty($hide) ? 'display:none' : ''); ?>">
<?php else: ?>
<div id="link-field-<?php echo e($id); ?>" class="form-group is-versionable <?php echo e($blocksMode ? "blocks-mode--$blocksMode" : 'blocks-mode--hide'); ?> <?php echo e($hasErrors ? ' has-group-error' : ''); ?><?php echo e($parentHidden ? ' parent-hidden' : ''); ?>" style="<?php echo e(!empty($hide) ? 'display:none' : ''); ?>">
<?php endif; ?>
    <?php echo html()->label(ucfirst($label))->for($id)->attributes(['class' => 'control-label']); ?>

    <?php if(isset($language)): ?>
        <div class="form-group-translation-tools pull-right">
            <?php echo $__env->make('admin.generic.components.forms.copy-translation', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?>
        </div>
    <?php endif; ?>
    <div class="well">
        <div class="row">
            <div class="col-sm-8">
                <div class="form-group <?php $__errorArgs = [$errorKey . '.label'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?> has-error <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>">
                    <?php echo e(html()->text($name . '[label]', $linkLabel)->attributes($textAttributes)); ?>

                </div>
            </div>
            <div class="col-sm-4">
                <div class="form-group">
                    <label class="checkbox-inline">
                        <?php echo e(html()->checkbox($name . '[isExternal]', $isExternal, 'true')->attributes($isExternalAttributes)); ?>

                        <b><?php echo app('translator')->get('backend.external_link'); ?></b>
                    </label>
                </div>
                <div class="form-group">
                    <label class="checkbox-inline">
                        <?php echo e(html()->checkbox($name . '[isNewtab]', $isNewtab, 'true')->attributes($isNewtabAttributes)); ?>

                        <b><?php echo app('translator')->get('backend.external_newtab'); ?></b>
                    </label>
                </div>
            </div>
        </div>
        <div class="internal-link-chooser">
            <?php echo e(html()->hidden($name . '[selectedObjectId]', $selectedObjectId)->attributes([
                'id' => $id . '_selectedObjectId',
                'class' => 'selected-object-id'
            ])); ?>

            <div class="row select-object" <?php echo e((isset($errors) && $errors->has($errorKey . '.selectedObjectId') ? 'data-toggle="tooltip" title="' . $errors->first($errorKey . '.selectedObjectId') . '"': null)); ?> >
                <div class="col-sm-8 object-placeholder">
                </div>
                <div class="col-sm-4">
                    <button type="button" class="btn btn-default command-choose-object">
                        <span><?php echo app('translator')->get('backend.select_object'); ?></span>
                    </button>
                </div>
            </div>
            <div class="row object-list-picker" <?php echo e($isExternal ? 'style="display: none;"' : ''); ?>>
                <div class="col-sm-8 multiple-picker-wrapper">
                    <select name="<?php echo e($name . '[_search-type]'); ?>" class="form-control search-type-select <?php echo e(sizeof($objectTypes) <=1 ? 'hidden' : ''); ?>">
                        <option value="">All Types</option>
                        <?php $__currentLoopData = $objectTypes; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $objectTypes): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                            <option value="<?php echo e($objectTypes); ?>"><?php echo e($objectTypes); ?></option>
                        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
                    </select>
                    <?php echo e(html()->text($name . '[_search]', null)->attributes($searchAttributes)); ?>

                </div>
                <div class="col-sm-4">
                    <button type="button" class="btn btn-default command-cancel-select">
                        <span><?php echo app('translator')->get('backend.cancel'); ?></span>
                    </button>
                </div>
            </div>
        </div>
        <div class="row external-link-chooser" <?php echo e(!$isExternal ? 'style="display: none;"' : ''); ?>>
            <div class="col-sm-8">
                <div class="form-group <?php $__errorArgs = [$errorKey . '.url'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?> has-error <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>">
                    <?php echo e(html()->text($name . '[url]', $linkUrl)->attributes($urlAttributes)); ?>

                </div>
            </div>
        </div>
    </div>
    <?php if(!empty($info)): ?>
        <span id="helpBlock" class="help-block"><?php echo e($info); ?></span>
    <?php endif; ?>
</div>

<script>
    $(function(){
        new Eae.View.BackendLinkField({
            el: $("#generic_form_<?php echo e(getRequestContext('generic_form_timestamp')); ?> #link-field-<?php echo e($id); ?>"),
            fieldName: <?php echo json_encode($fieldName, 15, 512) ?>,
            isExternal: <?php echo json_encode($isExternal, 15, 512) ?>,
            disabled: <?php echo $enabled ? 'false': 'true'; ?>,
            parent:  <?php echo empty($parent) ? 'false': json_encode($parent); ?>,
            searchUrl: <?php echo json_encode($searchUrl, 15, 512) ?>,
            selectedObject: <?php echo json_encode($selectedObject, 15, 512) ?>,
            <?php if(isset($language)): ?>
                language: <?php echo json_encode($language, 15, 512) ?>
            <?php endif; ?>
        });
    });
</script>
<?php /**PATH /var/www/html/resources/views/admin/generic/components/forms/link.blade.php ENDPATH**/ ?>