<?php
/* Smarty version 4.3.2, created on 2024-07-23 17:09:04
  from '/var/www/html/public/legacy/include/SuiteEditor/tpls/SuiteEditorDirectHTML.tpl' */

/* @var Smarty_Internal_Template $_smarty_tpl */
if ($_smarty_tpl->_decodeProperties($_smarty_tpl, array (
  'version' => '4.3.2',
  'unifunc' => 'content_669fe3b090cf83_87493290',
  'has_nocache_code' => false,
  'file_dependency' => 
  array (
    'ff297245a9cde8cdd60e99bb3ef6510bd87f3312' => 
    array (
      0 => '/var/www/html/public/legacy/include/SuiteEditor/tpls/SuiteEditorDirectHTML.tpl',
      1 => 1709743133,
      2 => 'file',
    ),
  ),
  'includes' => 
  array (
  ),
),false)) {
function content_669fe3b090cf83_87493290 (Smarty_Internal_Template $_smarty_tpl) {
?>
<!-- [Direct HTML Editor implementation] -->

<?php echo '<script'; ?>
>

    /**
     * Direct HTML Editor value getter function
     *
     * @returns string - Direct HTML Editor value
     */
    SuiteEditor.getValue = function() {
        return $('#<?php echo $_smarty_tpl->tpl_vars['elementId']->value;?>
').val();
    };

    /**
     * Direct HTML Editor value setter function
     *
     * @param htmlCode
     */
    SuiteEditor.apply = function(htmlCode) {
        if(typeof htmlCode === 'undefined') {
            htmlCode = '';
            }

        $('#<?php echo $_smarty_tpl->tpl_vars['elementId']->value;?>
').val(htmlCode);
    };

    /**
     * Direct HTML Editor value insert function
     *
     * @param text
     * @param elemId
     */
    SuiteEditor.insert = function(text, elemId) {
        if(typeof elemId === 'undefined') {
            elemId = '<?php echo $_smarty_tpl->tpl_vars['elementId']->value;?>
';
        }
        if(elemId != '<?php echo $_smarty_tpl->tpl_vars['elementId']->value;?>
') {
            throw 'incorrect editor element id (textarea id: '+elemId+')';
        }

        function insertAtCursor(myField, myValue) {
            //IE support
            if (document.selection) {
                myField.focus();
                sel = document.selection.createRange();
                sel.text = myValue;
            }
            //MOZILLA and others
            else if (myField.selectionStart || myField.selectionStart == '0') {
                var startPos = myField.selectionStart;
                var endPos = myField.selectionEnd;
                myField.value = myField.value.substring(0, startPos)
                        + myValue
                        + myField.value.substring(endPos, myField.value.length);
            } else {
                myField.value += myValue;
            }
        }

        insertAtCursor(document.getElementById(elemId), text);

     };

    $(function(){

        <?php if ($_smarty_tpl->tpl_vars['clickHandler']->value) {?>
            $('#<?php echo $_smarty_tpl->tpl_vars['elementId']->value;?>
').click(<?php echo $_smarty_tpl->tpl_vars['clickHandler']->value;?>
);
        <?php }?>

        $(window).mouseup(function() {
            $('#<?php echo $_smarty_tpl->tpl_vars['textareaId']->value;?>
').val(SuiteEditor.getValue());
        });
    });
<?php echo '</script'; ?>
>

<textarea id="<?php echo $_smarty_tpl->tpl_vars['elementId']->value;?>
" name="<?php echo $_smarty_tpl->tpl_vars['elementId']->value;?>
" cols="100" rows="25" style="width:100%"  title=""><?php echo $_smarty_tpl->tpl_vars['contents']->value;?>
</textarea><?php }
}
