Collections functions
Encryption functions
General functions
Render functions
Theme permission functions
Video functions
Resource functions

config_colouroverride_input()

Description

Generate colour picker input

Parameters

ColumnTypeDefaultDescription
$name string HTML input name attribute
$label string
$current string Current value
$default string Default value
$title string null Title
$autosave boolean false Automatically save the value on change
$on_change_js null
$hidden false
on_change_js string JavaScript run onchange of value (useful for "live" previewing of changes)

Location

include/config_functions.php lines 512 to 568

Definition

 
function config_colouroverride_input($name$label$current$default$title=null$autosave=false$on_change_js=null$hidden=false)
    {
    global 
$lang;
    
$checked=$current && $current!=$default;
    if (
is_null($title))
        {
        
// This is how it was used on plugins setup page. Makes sense for developers when trying to debug and not much for non-technical users
        
$title str_replace('%cvn'$name$lang['plugins-configvar']);
        }
    
?><div class="Question" style="min-height: 1.5em;" id="question_ echo $name?> if ($hidden){echo "style=\"display:none;\"";} ?> >
        <label for=" echo $name?>" title=" echo $title?>"> echo $label?></label>
        <div class="AutoSaveStatus">
            <span id="AutoSaveStatus- echo $name?>" style="display:none;"></span>
        </div>
        <input type="checkbox"  if ($checked) { ?>checked="true"  ?>onchange="
            jQuery('#container_ echo $name?>').toggle();
            if(!this.checked)
            {
            jQuery('# echo $name?>').val(' echo $default?>');
         if ($autosave)
            {
            
?>AutoSaveConfigOption(' echo $name?>');
                jQuery('# echo $name?>').trigger('change');
            
            
}
        if(!empty(
$on_change_js))
            {
            echo 
$on_change_js;
            }
        
?>
            }
            " style="float: left;" />
        <div id="container_ echo $name?>" if (!$checked) { ?>style="display: none;"  ?>>
            <input id=" echo $name?>" name=" echo $name?>" type="text" value=" echo htmlspecialchars($currentENT_QUOTES); ?>" onchange="
            
if ($autosave)
                {
                
?>AutoSaveConfigOption(' echo $name?>');
                
}
            if(!empty(
$on_change_js))
                {
                echo 
$on_change_js;
                }
            
?>" default=" echo $default?>" />
            <script>
                jQuery('# echo $name?>').spectrum({
                    showAlpha: true,
                    showInput: true,
                    clickoutFiresChange: true,
                    preferredFormat: 'rgb'
                });
            </script>
        </div>
        <div class="clearerleft"></div>
        </div>
        
    
    
}

This article was last updated 24th November 2020 06:35 Europe/London time based on the source file dated 6th October 2020 10:25 Europe/London time.