<?php
/**
 * Copyright © 2015 Magento. All rights reserved.
 * See COPYING.txt for license details.
 */

// @codingStandardsIgnoreFile

?>
<?php
/* @var $block \Magento\Backend\Block\Widget\Form\Renderer\Fieldset\Element */
$element = $block->getElement();
$note = $element->getNote() ? '<div class="note">' . $element->getNote() . '</div>' : '';
$elementBeforeLabel = $element->getExtType() == 'checkbox' || $element->getExtType() == 'radio';
$addOn = $element->getBeforeElementHtml() || $element->getAfterElementHtml();
$entity = $element->getEntityAttribute();
$fieldId = ($element->getHtmlContainerId()) ? ' id="' . $element->getHtmlContainerId() . '"' : '';
$fieldClass = "admin__field field field-{$element->getId()} {$element->getCssClass()}";
$fieldClass .= ($elementBeforeLabel) ? ' choice' : '';
$fieldClass .= ($addOn) ? ' with-addon' : '';
$fieldClass .= ($element->getRequired()) ? ' _required' : '';
$fieldClass .= ($note) ? ' with-note' : '';

$fieldAttributes = $fieldId . ' class="' . $fieldClass . '" '
    . $block->getUiId('form-field', $element->getId());
$elementHtmlId = $element->getHtmlId();
?>
<?php $block->checkFieldDisable() ?>
<?php
    $elementToggleCode = $element->getToggleCode() ? $element->getToggleCode()
        : 'toggleValueElements(this, this.parentNode.parentNode.parentNode)';
?>

<?php if (!$element->getNoDisplay()): ?>
    <?php if ($element->getType() == 'hidden'): ?>
        <?php echo $element->getElementHtml() ?>
    <?php else: ?>
    <div<?php /* @escapeNotVerified */ echo $fieldAttributes ?>>
        <?php if ($elementBeforeLabel): ?>
            <?php echo $element->getElementHtml() ?>
            <?php echo $element->getLabelHtml() ?>
            <?php /* @escapeNotVerified */ echo $note ?>
        <?php else: ?>
            <?php echo $element->getLabelHtml() ?>
            <div class="admin__field-control control">
                <?php /* @escapeNotVerified */ echo($addOn) ? '<div class="addon">' . $element->getElementHtml() . '</div>' : $element->getElementHtml(); ?>
                <?php echo $block->getHintHtml() ?>
                <?php /* @escapeNotVerified */ echo $note ?>
            </div>
        <?php endif; ?>
        <?php if ($element->getScopeLabel()): ?>
            <div class="field-service" value-scope="<?php /* @escapeNotVerified */ echo $element->getScopeLabel()?>">
            </div>
        <?php endif;?>
		
		<div class="field-service" value-scope="<?php /* @escapeNotVerified */ echo $block->getScopeLabel()?>">
            <?php if ($block->canDisplayUseDefault()): ?>
                <label for="<?php echo $element->getHtmlId() ?>_default" class="choice use-default">
                    <input <?php if ($element->getReadonly()):?> disabled="disabled"<?php endif; ?>
                            type="checkbox"
                            name="use_default[]"
                            class="use-default-control"
                            id="<?php echo $element->getHtmlId() ?>_default"
                            <?php if ($block->usedDefault()): ?> checked="checked"<?php endif; ?>
                            onclick="<?php /* @escapeNotVerified */ echo $elementToggleCode; ?>"
                            value="<?php /* @escapeNotVerified */ echo $block->getAttributeCode() ?>"/>
                    <span class="use-default-label"><?php /* @escapeNotVerified */ echo __('Use Default Value') ?></span>
                </label>
            <?php endif; ?>
        </div>
		
    </div>
    <?php endif; ?>
<?php endif; ?>

<script type="text/javascript">
var lbVariables = <?php echo json_encode($block->getVariables()); ?>;
var variable_<?php echo $element->getHtmlId() ?> = null;
require([
    "Codazon_ProductLabel/js/variables"
], function(){
	variable_<?php echo $elementHtmlId ?> = window.Variables;
	variable_<?php echo $elementHtmlId ?>.textareaElementId = "<?php echo $elementHtmlId ?>";
});
</script>
