Coding standards
Security in ResourceSpace
Developer reference
Database
Action functions
Admin functions
Ajax functions
Annotation functions
API functions
Collections functions
Comment functions
Config functions
CSV export functions
Dash functions
Debug functions
Encryption functions
Facial recognition functions
File functions
General functions
Language functions
Log functions
Login functions
Message functions
Migration functions
Node functions
PDF functions
Plugin functions
Render functions
Reporting functions
Request functions
Research functions
Slideshow functions
Theme permission functions
User functions
Video functions
Database functions
Metadata functions
Resource functions
Search functions
Map functions
Job functions
Tab functions
Test 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 673 to 733

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 escape($name); ?> if ($hidden){echo "style=\"display:none;\"";} ?> >
        <label for=" echo escape($name); ?>" title=" echo escape($title); ?>"> echo escape($label); ?></label>
        <div class="AutoSaveStatus">
            <span id="AutoSaveStatus- echo escape($name); ?>" style="display:none;"></span>
        </div>
        <input type="checkbox"  if ($checked) { ?>checked="true"  ?>onchange="
            jQuery('#container_ echo escape($name); ?>').toggle();
            if(!this.checked)
            {
            // Unchecked, set the default. Must first change the type as a color picker can't hold the empty string.
            jQuery('# echo escape($name); ?>').attr('type','text');
            jQuery('# echo escape($name); ?>').val(' echo escape($default); ?>');
            
            
if(!empty($on_change_js))
                {
                echo 
$on_change_js;
                }
            if (
$autosave)
            {
            
?>AutoSaveConfigOption(' echo escape($name); ?>');
                jQuery('# echo escape($name); ?>').trigger('change');
            
            
}
        if(!empty(
$on_change_js))
            {
            echo 
$on_change_js;
            }
        
?>
            }
        else
            {
            jQuery('# echo escape($name); ?>').attr('type','color');
            }
            " style="float: left;" />
        <div id="container_ echo escape($name); ?>" if (!$checked) { ?>style="display: none;"  ?>>
            &nbsp;
            <input id=" echo escape($name); ?>" name=" echo escape($name); ?>" type=" echo ($checked?"color":"text"?>" value=" echo escape($current); ?>" onchange="
            
if ($autosave)
                {
                
?>AutoSaveConfigOption(' echo escape($name); ?>');
                
}
            if(!empty(
$on_change_js))
                {
                echo 
$on_change_js;
                }
            
?>" default=" echo escape($default); ?>" />
        </div>
        <div class="clearerleft"></div>
        </div>
        
    
    
}

This article was last updated 11th February 2025 19:05 Europe/London time based on the source file dated 10th February 2025 11:45 Europe/London time.