cleanup and update of jquery-colorpicker dependency
This commit is contained in:
@ -1,13 +0,0 @@
|
||||
{
|
||||
"folders":
|
||||
[
|
||||
{
|
||||
"follow_symlinks": true,
|
||||
"path": ".",
|
||||
"folder_exclude_patterns": [
|
||||
"min",
|
||||
"trans"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
@ -1,18 +1,21 @@
|
||||
<?php
|
||||
require_once ('global.php');
|
||||
require_once (CRAYON_RESOURCE_PHP);
|
||||
require_once('global.php');
|
||||
require_once(CRAYON_RESOURCE_PHP);
|
||||
|
||||
/* Manages fonts once they are loaded. */
|
||||
class CrayonFonts extends CrayonUserResourceCollection {
|
||||
// Properties and Constants ===============================================
|
||||
|
||||
const DEFAULT_FONT = 'monaco';
|
||||
const DEFAULT_FONT_NAME = 'Monaco';
|
||||
class CrayonFonts extends CrayonUserResourceCollection
|
||||
{
|
||||
// Properties and Constants ===============================================
|
||||
|
||||
// Methods ================================================================
|
||||
const DEFAULT_FONT = 'monaco';
|
||||
const DEFAULT_FONT_NAME = 'Monaco';
|
||||
|
||||
function __construct() {
|
||||
$this->set_default(self::DEFAULT_FONT, self::DEFAULT_FONT_NAME);
|
||||
// Methods ================================================================
|
||||
|
||||
function __construct()
|
||||
{
|
||||
$this->set_default(self::DEFAULT_FONT, self::DEFAULT_FONT_NAME);
|
||||
$this->directory(CRAYON_FONT_PATH);
|
||||
$this->relative_directory(CRAYON_FONT_DIR);
|
||||
$this->extension('css');
|
||||
@ -30,7 +33,6 @@ class CrayonFonts extends CrayonUserResourceCollection {
|
||||
}
|
||||
CrayonLog::debug($this->directory());
|
||||
CrayonLog::debug($this->user_directory());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
@ -629,5 +629,3 @@ class CrayonFormatter {
|
||||
return ' ' . $dim_mode . ': ' . $hl->setting_val($name) . $dim_unit . ';';
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
@ -1,423 +1,449 @@
|
||||
<?php
|
||||
// Class includes
|
||||
require_once ('global.php');
|
||||
require_once (CRAYON_PARSER_PHP);
|
||||
require_once (CRAYON_FORMATTER_PHP);
|
||||
require_once (CRAYON_SETTINGS_PHP);
|
||||
require_once (CRAYON_LANGS_PHP);
|
||||
require_once('global.php');
|
||||
require_once(CRAYON_PARSER_PHP);
|
||||
require_once(CRAYON_FORMATTER_PHP);
|
||||
require_once(CRAYON_SETTINGS_PHP);
|
||||
require_once(CRAYON_LANGS_PHP);
|
||||
|
||||
/* The main class for managing the syntax highlighter */
|
||||
class CrayonHighlighter {
|
||||
// Properties and Constants ===============================================
|
||||
private $id = '';
|
||||
// URL is initially NULL, meaning none provided
|
||||
private $url = NULL;
|
||||
private $code = '';
|
||||
private $formatted_code = '';
|
||||
private $title = '';
|
||||
private $line_count = 0;
|
||||
private $marked_lines = array();
|
||||
private $range = NULL;
|
||||
private $error = '';
|
||||
// Determine whether the code needs to be loaded, parsed or formatted
|
||||
private $needs_load = FALSE;
|
||||
private $needs_format = FALSE;
|
||||
// Record the script run times
|
||||
private $runtime = array();
|
||||
// Whether the code is mixed
|
||||
private $is_mixed = FALSE;
|
||||
// Inline code on a single floating line
|
||||
private $is_inline = FALSE;
|
||||
private $is_highlighted = TRUE;
|
||||
|
||||
// Objects
|
||||
// Stores the CrayonLang being used
|
||||
private $language = NULL;
|
||||
// A copy of the current global settings which can be overridden
|
||||
private $settings = NULL;
|
||||
|
||||
// Methods ================================================================
|
||||
function __construct($url = NULL, $language = NULL, $id = NULL) {
|
||||
if ($url !== NULL) {
|
||||
$this->url($url);
|
||||
}
|
||||
|
||||
if ($language !== NULL) {
|
||||
$this->language($language);
|
||||
}
|
||||
// Default ID
|
||||
$id = $id !== NULL ? $id : uniqid();
|
||||
$this->id($id);
|
||||
}
|
||||
|
||||
/* Tries to load the code locally, then attempts to load it remotely */
|
||||
private function load() {
|
||||
if (empty($this->url)) {
|
||||
$this->error('The specified URL is empty, please provide a valid URL.');
|
||||
return;
|
||||
}
|
||||
// Try to replace the URL with an absolute path if it is local, used to prevent scripts
|
||||
// from executing when they are loaded.
|
||||
$url = $this->url;
|
||||
if ($this->setting_val(CrayonSettings::DECODE_ATTRIBUTES)) {
|
||||
$url = CrayonUtil::html_entity_decode($url);
|
||||
}
|
||||
$url = CrayonUtil::pathf($url);
|
||||
$site_http = CrayonGlobalSettings::site_url();
|
||||
$scheme = parse_url($url, PHP_URL_SCHEME);
|
||||
// Try to replace the site URL with a path to force local loading
|
||||
if (empty($scheme)) {
|
||||
// No url scheme is given - path may be given as relative
|
||||
$url = CrayonUtil::path_slash($site_http) . CrayonUtil::path_slash($this->setting_val(CrayonSettings::LOCAL_PATH)) . $url;
|
||||
}
|
||||
$http_code = 0;
|
||||
// If available, use the built in wp remote http get function.
|
||||
if (function_exists('wp_remote_get')) {
|
||||
$url_uid = 'crayon_' . CrayonUtil::str_uid($url);
|
||||
$cached = get_transient($url_uid, 'crayon-syntax');
|
||||
CrayonSettingsWP::load_cache();
|
||||
if ($cached !== FALSE) {
|
||||
$content = $cached;
|
||||
$http_code = 200;
|
||||
} else {
|
||||
$response = @wp_remote_get($url, array('sslverify' => false, 'timeout' => 20));
|
||||
$content = wp_remote_retrieve_body($response);
|
||||
$http_code = wp_remote_retrieve_response_code($response);
|
||||
$cache = $this->setting_val(CrayonSettings::CACHE);
|
||||
$cache_sec = CrayonSettings::get_cache_sec($cache);
|
||||
if ($cache_sec > 1 && $http_code >= 200 && $http_code < 400) {
|
||||
set_transient($url_uid, $content, $cache_sec);
|
||||
CrayonSettingsWP::add_cache($url_uid);
|
||||
}
|
||||
}
|
||||
} else if (in_array(parse_url($url, PHP_URL_SCHEME), array('ssl', 'http', 'https'))) {
|
||||
// Fallback to cURL. At this point, the URL scheme must be valid.
|
||||
$ch = curl_init($url);
|
||||
curl_setopt($ch, CURLOPT_HEADER, FALSE);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
|
||||
// For https connections, we do not require SSL verification
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
|
||||
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 20);
|
||||
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
|
||||
curl_setopt($ch, CURLOPT_FRESH_CONNECT, FALSE);
|
||||
curl_setopt($ch, CURLOPT_MAXREDIRS, 5);
|
||||
if (isset($_SERVER['HTTP_USER_AGENT'])) {
|
||||
curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
|
||||
}
|
||||
$content = curl_exec($ch);
|
||||
$error = curl_error($ch);
|
||||
$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
||||
curl_close($ch);
|
||||
}
|
||||
if ($http_code >= 200 && $http_code < 400) {
|
||||
$this->code($content);
|
||||
} else {
|
||||
if (empty($this->code)) {
|
||||
// If code is also given, just use that
|
||||
$this->error("The provided URL ('$this->url'), parsed remotely as ('$url'), could not be accessed.");
|
||||
}
|
||||
}
|
||||
$this->needs_load = FALSE;
|
||||
}
|
||||
|
||||
/* Central point of access for all other functions to update code. */
|
||||
public function process() {
|
||||
$tmr = new CrayonTimer();
|
||||
$this->runtime = NULL;
|
||||
if ($this->needs_load) {
|
||||
$tmr->start();
|
||||
$this->load();
|
||||
$this->runtime[CRAYON_LOAD_TIME] = $tmr->stop();
|
||||
}
|
||||
if (!empty($this->error) || empty($this->code)) {
|
||||
// Disable highlighting for errors and empty code
|
||||
return;
|
||||
}
|
||||
|
||||
if ($this->language === NULL) {
|
||||
$this->language_detect();
|
||||
}
|
||||
if ($this->needs_format) {
|
||||
$tmr->start();
|
||||
try {
|
||||
// Parse before hand to read modes
|
||||
$code = $this->code;
|
||||
// If inline, then combine lines into one
|
||||
if ($this->is_inline) {
|
||||
$code = preg_replace('#[\r\n]+#ms', '', $code);
|
||||
if ($this->setting_val(CrayonSettings::TRIM_WHITESPACE)) {
|
||||
$code = trim($code);
|
||||
}
|
||||
}
|
||||
// Decode html entities (e.g. if using visual editor or manually encoding)
|
||||
if ($this->setting_val(CrayonSettings::DECODE)) {
|
||||
$code = CrayonUtil::html_entity_decode($code);
|
||||
}
|
||||
// Save code so output is plain output is the same
|
||||
$this->code = $code;
|
||||
|
||||
// Allow mixed if langauge supports it and setting is set
|
||||
CrayonParser::parse($this->language->id());
|
||||
if (!$this->setting_val(CrayonSettings::MIXED) || !$this->language->mode(CrayonParser::ALLOW_MIXED)) {
|
||||
// Format the code with the generated regex and elements
|
||||
$this->formatted_code = CrayonFormatter::format_code($code, $this->language, $this);
|
||||
} else {
|
||||
// Format the code with Mixed Highlighting
|
||||
$this->formatted_code = CrayonFormatter::format_mixed_code($code, $this->language, $this);
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
$this->error($e->message());
|
||||
return;
|
||||
}
|
||||
$this->needs_format = FALSE;
|
||||
$this->runtime[CRAYON_FORMAT_TIME] = $tmr->stop();
|
||||
}
|
||||
}
|
||||
|
||||
/* Used to format the glue in between code when finding mixed languages */
|
||||
private function format_glue($glue, $highlight = TRUE) {
|
||||
// TODO $highlight
|
||||
return CrayonFormatter::format_code($glue, $this->language, $this, $highlight);
|
||||
}
|
||||
class CrayonHighlighter
|
||||
{
|
||||
// Properties and Constants ===============================================
|
||||
private $id = '';
|
||||
// URL is initially NULL, meaning none provided
|
||||
private $url = NULL;
|
||||
private $code = '';
|
||||
private $formatted_code = '';
|
||||
private $title = '';
|
||||
private $line_count = 0;
|
||||
private $marked_lines = array();
|
||||
private $range = NULL;
|
||||
private $error = '';
|
||||
// Determine whether the code needs to be loaded, parsed or formatted
|
||||
private $needs_load = FALSE;
|
||||
private $needs_format = FALSE;
|
||||
// Record the script run times
|
||||
private $runtime = array();
|
||||
// Whether the code is mixed
|
||||
private $is_mixed = FALSE;
|
||||
// Inline code on a single floating line
|
||||
private $is_inline = FALSE;
|
||||
private $is_highlighted = TRUE;
|
||||
|
||||
/* Sends the code to the formatter for printing. Apart from the getters and setters, this is
|
||||
the only other function accessible outside this class. $show_lines can also be a string. */
|
||||
function output($show_lines = TRUE, $print = TRUE) {
|
||||
$this->process();
|
||||
if (empty($this->error)) {
|
||||
// If no errors have occured, print the formatted code
|
||||
$ret = CrayonFormatter::print_code($this, $this->formatted_code, $show_lines, $print);
|
||||
} else {
|
||||
$ret = CrayonFormatter::print_error($this, $this->error, '', $print);
|
||||
}
|
||||
// Reset the error message at the end of the print session
|
||||
$this->error = '';
|
||||
// If $print = FALSE, $ret will contain the output
|
||||
return $ret;
|
||||
}
|
||||
// Objects
|
||||
// Stores the CrayonLang being used
|
||||
private $language = NULL;
|
||||
// A copy of the current global settings which can be overridden
|
||||
private $settings = NULL;
|
||||
|
||||
// Getters and Setters ====================================================
|
||||
function code($code = NULL) {
|
||||
if ($code === NULL) {
|
||||
return $this->code;
|
||||
} else {
|
||||
// Trim whitespace
|
||||
if ($this->setting_val(CrayonSettings::TRIM_WHITESPACE)) {
|
||||
$code = preg_replace("#(?:^\\s*\\r?\\n)|(?:\\r?\\n\\s*$)#", '', $code);
|
||||
}
|
||||
// Methods ================================================================
|
||||
function __construct($url = NULL, $language = NULL, $id = NULL)
|
||||
{
|
||||
if ($url !== NULL) {
|
||||
$this->url($url);
|
||||
}
|
||||
|
||||
if ($language !== NULL) {
|
||||
$this->language($language);
|
||||
}
|
||||
// Default ID
|
||||
$id = $id !== NULL ? $id : uniqid();
|
||||
$this->id($id);
|
||||
}
|
||||
|
||||
/* Tries to load the code locally, then attempts to load it remotely */
|
||||
private function load()
|
||||
{
|
||||
if (empty($this->url)) {
|
||||
$this->error('The specified URL is empty, please provide a valid URL.');
|
||||
return;
|
||||
}
|
||||
// Try to replace the URL with an absolute path if it is local, used to prevent scripts
|
||||
// from executing when they are loaded.
|
||||
$url = $this->url;
|
||||
if ($this->setting_val(CrayonSettings::DECODE_ATTRIBUTES)) {
|
||||
$url = CrayonUtil::html_entity_decode($url);
|
||||
}
|
||||
$url = CrayonUtil::pathf($url);
|
||||
$site_http = CrayonGlobalSettings::site_url();
|
||||
$scheme = parse_url($url, PHP_URL_SCHEME);
|
||||
// Try to replace the site URL with a path to force local loading
|
||||
if (empty($scheme)) {
|
||||
// No url scheme is given - path may be given as relative
|
||||
$url = CrayonUtil::path_slash($site_http) . CrayonUtil::path_slash($this->setting_val(CrayonSettings::LOCAL_PATH)) . $url;
|
||||
}
|
||||
$http_code = 0;
|
||||
// If available, use the built in wp remote http get function.
|
||||
if (function_exists('wp_remote_get')) {
|
||||
$url_uid = 'crayon_' . CrayonUtil::str_uid($url);
|
||||
$cached = get_transient($url_uid, 'crayon-syntax');
|
||||
CrayonSettingsWP::load_cache();
|
||||
if ($cached !== FALSE) {
|
||||
$content = $cached;
|
||||
$http_code = 200;
|
||||
} else {
|
||||
$response = @wp_remote_get($url, array('sslverify' => false, 'timeout' => 20));
|
||||
$content = wp_remote_retrieve_body($response);
|
||||
$http_code = wp_remote_retrieve_response_code($response);
|
||||
$cache = $this->setting_val(CrayonSettings::CACHE);
|
||||
$cache_sec = CrayonSettings::get_cache_sec($cache);
|
||||
if ($cache_sec > 1 && $http_code >= 200 && $http_code < 400) {
|
||||
set_transient($url_uid, $content, $cache_sec);
|
||||
CrayonSettingsWP::add_cache($url_uid);
|
||||
}
|
||||
}
|
||||
} else if (in_array(parse_url($url, PHP_URL_SCHEME), array('ssl', 'http', 'https'))) {
|
||||
// Fallback to cURL. At this point, the URL scheme must be valid.
|
||||
$ch = curl_init($url);
|
||||
curl_setopt($ch, CURLOPT_HEADER, FALSE);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
|
||||
// For https connections, we do not require SSL verification
|
||||
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
|
||||
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 20);
|
||||
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
|
||||
curl_setopt($ch, CURLOPT_FRESH_CONNECT, FALSE);
|
||||
curl_setopt($ch, CURLOPT_MAXREDIRS, 5);
|
||||
if (isset($_SERVER['HTTP_USER_AGENT'])) {
|
||||
curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']);
|
||||
}
|
||||
$content = curl_exec($ch);
|
||||
$error = curl_error($ch);
|
||||
$http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
||||
curl_close($ch);
|
||||
}
|
||||
if ($http_code >= 200 && $http_code < 400) {
|
||||
$this->code($content);
|
||||
} else {
|
||||
if (empty($this->code)) {
|
||||
// If code is also given, just use that
|
||||
$this->error("The provided URL ('$this->url'), parsed remotely as ('$url'), could not be accessed.");
|
||||
}
|
||||
}
|
||||
$this->needs_load = FALSE;
|
||||
}
|
||||
|
||||
/* Central point of access for all other functions to update code. */
|
||||
public function process()
|
||||
{
|
||||
$tmr = new CrayonTimer();
|
||||
$this->runtime = NULL;
|
||||
if ($this->needs_load) {
|
||||
$tmr->start();
|
||||
$this->load();
|
||||
$this->runtime[CRAYON_LOAD_TIME] = $tmr->stop();
|
||||
}
|
||||
if (!empty($this->error) || empty($this->code)) {
|
||||
// Disable highlighting for errors and empty code
|
||||
return;
|
||||
}
|
||||
|
||||
if ($this->language === NULL) {
|
||||
$this->language_detect();
|
||||
}
|
||||
if ($this->needs_format) {
|
||||
$tmr->start();
|
||||
try {
|
||||
// Parse before hand to read modes
|
||||
$code = $this->code;
|
||||
// If inline, then combine lines into one
|
||||
if ($this->is_inline) {
|
||||
$code = preg_replace('#[\r\n]+#ms', '', $code);
|
||||
if ($this->setting_val(CrayonSettings::TRIM_WHITESPACE)) {
|
||||
$code = trim($code);
|
||||
}
|
||||
}
|
||||
// Decode html entities (e.g. if using visual editor or manually encoding)
|
||||
if ($this->setting_val(CrayonSettings::DECODE)) {
|
||||
$code = CrayonUtil::html_entity_decode($code);
|
||||
}
|
||||
// Save code so output is plain output is the same
|
||||
$this->code = $code;
|
||||
|
||||
// Allow mixed if langauge supports it and setting is set
|
||||
CrayonParser::parse($this->language->id());
|
||||
if (!$this->setting_val(CrayonSettings::MIXED) || !$this->language->mode(CrayonParser::ALLOW_MIXED)) {
|
||||
// Format the code with the generated regex and elements
|
||||
$this->formatted_code = CrayonFormatter::format_code($code, $this->language, $this);
|
||||
} else {
|
||||
// Format the code with Mixed Highlighting
|
||||
$this->formatted_code = CrayonFormatter::format_mixed_code($code, $this->language, $this);
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
$this->error($e->message());
|
||||
return;
|
||||
}
|
||||
$this->needs_format = FALSE;
|
||||
$this->runtime[CRAYON_FORMAT_TIME] = $tmr->stop();
|
||||
}
|
||||
}
|
||||
|
||||
/* Used to format the glue in between code when finding mixed languages */
|
||||
private function format_glue($glue, $highlight = TRUE)
|
||||
{
|
||||
// TODO $highlight
|
||||
return CrayonFormatter::format_code($glue, $this->language, $this, $highlight);
|
||||
}
|
||||
|
||||
/* Sends the code to the formatter for printing. Apart from the getters and setters, this is
|
||||
the only other function accessible outside this class. $show_lines can also be a string. */
|
||||
function output($show_lines = TRUE, $print = TRUE)
|
||||
{
|
||||
$this->process();
|
||||
if (empty($this->error)) {
|
||||
// If no errors have occured, print the formatted code
|
||||
$ret = CrayonFormatter::print_code($this, $this->formatted_code, $show_lines, $print);
|
||||
} else {
|
||||
$ret = CrayonFormatter::print_error($this, $this->error, '', $print);
|
||||
}
|
||||
// Reset the error message at the end of the print session
|
||||
$this->error = '';
|
||||
// If $print = FALSE, $ret will contain the output
|
||||
return $ret;
|
||||
}
|
||||
|
||||
// Getters and Setters ====================================================
|
||||
function code($code = NULL)
|
||||
{
|
||||
if ($code === NULL) {
|
||||
return $this->code;
|
||||
} else {
|
||||
// Trim whitespace
|
||||
if ($this->setting_val(CrayonSettings::TRIM_WHITESPACE)) {
|
||||
$code = preg_replace("#(?:^\\s*\\r?\\n)|(?:\\r?\\n\\s*$)#", '', $code);
|
||||
}
|
||||
|
||||
if ($this->setting_val(CrayonSettings::TRIM_CODE_TAG)) {
|
||||
$code = preg_replace('#^\s*<\s*code[^>]*>#msi', '', $code);
|
||||
$code = preg_replace('#</\s*code[^>]*>\s*$#msi', '', $code);
|
||||
}
|
||||
|
||||
$before = $this->setting_val(CrayonSettings::WHITESPACE_BEFORE);
|
||||
if ($before > 0) {
|
||||
$code = str_repeat("\n", $before) . $code;
|
||||
}
|
||||
$after = $this->setting_val(CrayonSettings::WHITESPACE_AFTER);
|
||||
if ($after > 0) {
|
||||
$code = $code . str_repeat("\n", $after);
|
||||
}
|
||||
|
||||
if (!empty($code)) {
|
||||
$this->code = $code;
|
||||
$this->needs_format = TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
$before = $this->setting_val(CrayonSettings::WHITESPACE_BEFORE);
|
||||
if ($before > 0) {
|
||||
$code = str_repeat("\n", $before) . $code;
|
||||
}
|
||||
$after = $this->setting_val(CrayonSettings::WHITESPACE_AFTER);
|
||||
if ($after > 0) {
|
||||
$code = $code . str_repeat("\n", $after);
|
||||
}
|
||||
|
||||
function language($id = NULL) {
|
||||
if ($id === NULL || !is_string($id)) {
|
||||
return $this->language;
|
||||
}
|
||||
|
||||
if ( ($lang = CrayonResources::langs()->get($id)) != FALSE || ($lang = CrayonResources::langs()->alias($id)) != FALSE ) {
|
||||
// Set the language if it exists or look for an alias
|
||||
$this->language = $lang;
|
||||
} else {
|
||||
$this->language_detect();
|
||||
}
|
||||
|
||||
// Prepare the language for use, even if we have no code, we need the name
|
||||
CrayonParser::parse($this->language->id());
|
||||
}
|
||||
|
||||
function language_detect() {
|
||||
// Attempt to detect the language
|
||||
if (!empty($id)) {
|
||||
$this->log("The language '$id' could not be loaded.");
|
||||
}
|
||||
$this->language = CrayonResources::langs()->detect($this->url, $this->setting_val(CrayonSettings::FALLBACK_LANG));
|
||||
}
|
||||
if (!empty($code)) {
|
||||
$this->code = $code;
|
||||
$this->needs_format = TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function url($url = NULL) {
|
||||
if ($url === NULL) {
|
||||
return $this->url;
|
||||
} else {
|
||||
$this->url = $url;
|
||||
$this->needs_load = TRUE;
|
||||
}
|
||||
}
|
||||
function language($id = NULL)
|
||||
{
|
||||
if ($id === NULL || !is_string($id)) {
|
||||
return $this->language;
|
||||
}
|
||||
|
||||
function title($title = NULL) {
|
||||
if (!CrayonUtil::str($this->title, $title)) {
|
||||
return $this->title;
|
||||
}
|
||||
}
|
||||
if (($lang = CrayonResources::langs()->get($id)) != FALSE || ($lang = CrayonResources::langs()->alias($id)) != FALSE) {
|
||||
// Set the language if it exists or look for an alias
|
||||
$this->language = $lang;
|
||||
} else {
|
||||
$this->language_detect();
|
||||
}
|
||||
|
||||
function line_count($line_count = NULL) {
|
||||
if (!CrayonUtil::num($this->line_count, $line_count)) {
|
||||
return $this->line_count;
|
||||
}
|
||||
}
|
||||
// Prepare the language for use, even if we have no code, we need the name
|
||||
CrayonParser::parse($this->language->id());
|
||||
}
|
||||
|
||||
function marked($str = NULL) {
|
||||
if ($str === NULL) {
|
||||
return $this->marked_lines;
|
||||
}
|
||||
// If only an int is given
|
||||
if (is_int($str)) {
|
||||
$array = array($str);
|
||||
return CrayonUtil::arr($this->marked_lines, $array);
|
||||
}
|
||||
// A string with ints separated by commas, can also contain ranges
|
||||
$array = CrayonUtil::trim_e($str);
|
||||
$array = array_unique($array);
|
||||
$lines = array();
|
||||
foreach ($array as $line) {
|
||||
// Check for ranges
|
||||
if (strpos($line, '-') !== FALSE) {
|
||||
$ranges = CrayonUtil::range_str($line);
|
||||
$lines = array_merge($lines, $ranges);
|
||||
} else {
|
||||
// Otherwise check the string for a number
|
||||
$line = intval($line);
|
||||
if ($line !== 0) {
|
||||
$lines[] = $line;
|
||||
}
|
||||
}
|
||||
}
|
||||
return CrayonUtil::arr($this->marked_lines, $lines);
|
||||
}
|
||||
|
||||
function range($str = NULL) {
|
||||
if ($str === NULL) {
|
||||
return $this->range;
|
||||
} else {
|
||||
$range = CrayonUtil::range_str_single($str);
|
||||
if ($range) {
|
||||
$this->range = $range;
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
function language_detect()
|
||||
{
|
||||
// Attempt to detect the language
|
||||
if (!empty($id)) {
|
||||
$this->log("The language '$id' could not be loaded.");
|
||||
}
|
||||
$this->language = CrayonResources::langs()->detect($this->url, $this->setting_val(CrayonSettings::FALLBACK_LANG));
|
||||
}
|
||||
|
||||
function log($var) {
|
||||
if ($this->setting_val(CrayonSettings::ERROR_LOG)) {
|
||||
CrayonLog::log($var);
|
||||
}
|
||||
}
|
||||
function url($url = NULL)
|
||||
{
|
||||
if ($url === NULL) {
|
||||
return $this->url;
|
||||
} else {
|
||||
$this->url = $url;
|
||||
$this->needs_load = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
function id($id = NULL) {
|
||||
if ($id == NULL) {
|
||||
return $this->id;
|
||||
} else {
|
||||
$this->id = strval($id);
|
||||
}
|
||||
}
|
||||
|
||||
function error($string = NULL) {
|
||||
if (!$string) {
|
||||
return $this->error;
|
||||
}
|
||||
$this->error .= $string;
|
||||
$this->log($string);
|
||||
// Add the error string and ensure no further processing occurs
|
||||
$this->needs_load = FALSE;
|
||||
$this->needs_format = FALSE;
|
||||
}
|
||||
function title($title = NULL)
|
||||
{
|
||||
if (!CrayonUtil::str($this->title, $title)) {
|
||||
return $this->title;
|
||||
}
|
||||
}
|
||||
|
||||
// Set and retreive settings
|
||||
// TODO fix this, it's too limiting
|
||||
function settings($mixed = NULL) {
|
||||
if ($this->settings == NULL) {
|
||||
$this->settings = CrayonGlobalSettings::get_obj();
|
||||
}
|
||||
|
||||
if ($mixed === NULL) {
|
||||
return $this->settings;
|
||||
} else if (is_string($mixed)) {
|
||||
return $this->settings->get($mixed);
|
||||
} else if (is_array($mixed)) {
|
||||
$this->settings->set($mixed);
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
function line_count($line_count = NULL)
|
||||
{
|
||||
if (!CrayonUtil::num($this->line_count, $line_count)) {
|
||||
return $this->line_count;
|
||||
}
|
||||
}
|
||||
|
||||
/* Retrieve a single setting's value for use in the formatter. By default, on failure it will
|
||||
* return TRUE to ensure FALSE is only sent when a setting is found. This prevents a fake
|
||||
* FALSE when the formatter checks for a positive setting (Show/Enable) and fails. When a
|
||||
* negative setting is needed (Hide/Disable), $default_return should be set to FALSE. */
|
||||
// TODO fix this (see above)
|
||||
function setting_val($name = NULL, $default_return = TRUE) {
|
||||
if (is_string($name) && $setting = $this->settings($name)) {
|
||||
return $setting->value();
|
||||
} else {
|
||||
// Name not valid
|
||||
return (is_bool($default_return) ? $default_return : TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
// Set a setting value
|
||||
// TODO fix this (see above)
|
||||
function setting_set($name = NULL, $value = TRUE) {
|
||||
$this->settings->set($name, $value);
|
||||
}
|
||||
function marked($str = NULL)
|
||||
{
|
||||
if ($str === NULL) {
|
||||
return $this->marked_lines;
|
||||
}
|
||||
// If only an int is given
|
||||
if (is_int($str)) {
|
||||
$array = array($str);
|
||||
return CrayonUtil::arr($this->marked_lines, $array);
|
||||
}
|
||||
// A string with ints separated by commas, can also contain ranges
|
||||
$array = CrayonUtil::trim_e($str);
|
||||
$array = array_unique($array);
|
||||
$lines = array();
|
||||
foreach ($array as $line) {
|
||||
// Check for ranges
|
||||
if (strpos($line, '-') !== FALSE) {
|
||||
$ranges = CrayonUtil::range_str($line);
|
||||
$lines = array_merge($lines, $ranges);
|
||||
} else {
|
||||
// Otherwise check the string for a number
|
||||
$line = intval($line);
|
||||
if ($line !== 0) {
|
||||
$lines[] = $line;
|
||||
}
|
||||
}
|
||||
}
|
||||
return CrayonUtil::arr($this->marked_lines, $lines);
|
||||
}
|
||||
|
||||
// Used to find current index in dropdown setting
|
||||
function setting_index($name = NULL) {
|
||||
$setting = $this->settings($name);
|
||||
if (is_string($name) && $setting->is_array()) {
|
||||
return $setting->index();
|
||||
} else {
|
||||
// Returns -1 to avoid accidentally selecting an item in a dropdown
|
||||
return CrayonSettings::INVALID;
|
||||
}
|
||||
}
|
||||
function range($str = NULL)
|
||||
{
|
||||
if ($str === NULL) {
|
||||
return $this->range;
|
||||
} else {
|
||||
$range = CrayonUtil::range_str_single($str);
|
||||
if ($range) {
|
||||
$this->range = $range;
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
function formatted_code() {
|
||||
return $this->formatted_code;
|
||||
}
|
||||
function log($var)
|
||||
{
|
||||
if ($this->setting_val(CrayonSettings::ERROR_LOG)) {
|
||||
CrayonLog::log($var);
|
||||
}
|
||||
}
|
||||
|
||||
function runtime() {
|
||||
return $this->runtime;
|
||||
}
|
||||
|
||||
function is_highlighted($highlighted = NULL) {
|
||||
if ($highlighted === NULL) {
|
||||
return $this->is_highlighted;
|
||||
} else {
|
||||
$this->is_highlighted = $highlighted;
|
||||
}
|
||||
}
|
||||
|
||||
function is_mixed($mixed = NULL) {
|
||||
if ($mixed === NULL) {
|
||||
return $this->is_mixed;
|
||||
} else {
|
||||
$this->is_mixed = $mixed;
|
||||
}
|
||||
}
|
||||
|
||||
function is_inline($inline = NULL) {
|
||||
if ($inline === NULL) {
|
||||
return $this->is_inline;
|
||||
} else {
|
||||
$inline = CrayonUtil::str_to_bool($inline, FALSE);
|
||||
$this->is_inline = $inline;
|
||||
}
|
||||
}
|
||||
function id($id = NULL)
|
||||
{
|
||||
if ($id == NULL) {
|
||||
return $this->id;
|
||||
} else {
|
||||
$this->id = strval($id);
|
||||
}
|
||||
}
|
||||
|
||||
function error($string = NULL)
|
||||
{
|
||||
if (!$string) {
|
||||
return $this->error;
|
||||
}
|
||||
$this->error .= $string;
|
||||
$this->log($string);
|
||||
// Add the error string and ensure no further processing occurs
|
||||
$this->needs_load = FALSE;
|
||||
$this->needs_format = FALSE;
|
||||
}
|
||||
|
||||
// Set and retreive settings
|
||||
// TODO fix this, it's too limiting
|
||||
function settings($mixed = NULL)
|
||||
{
|
||||
if ($this->settings == NULL) {
|
||||
$this->settings = CrayonGlobalSettings::get_obj();
|
||||
}
|
||||
|
||||
if ($mixed === NULL) {
|
||||
return $this->settings;
|
||||
} else if (is_string($mixed)) {
|
||||
return $this->settings->get($mixed);
|
||||
} else if (is_array($mixed)) {
|
||||
$this->settings->set($mixed);
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* Retrieve a single setting's value for use in the formatter. By default, on failure it will
|
||||
* return TRUE to ensure FALSE is only sent when a setting is found. This prevents a fake
|
||||
* FALSE when the formatter checks for a positive setting (Show/Enable) and fails. When a
|
||||
* negative setting is needed (Hide/Disable), $default_return should be set to FALSE. */
|
||||
// TODO fix this (see above)
|
||||
function setting_val($name = NULL, $default_return = TRUE)
|
||||
{
|
||||
if (is_string($name) && $setting = $this->settings($name)) {
|
||||
return $setting->value();
|
||||
} else {
|
||||
// Name not valid
|
||||
return (is_bool($default_return) ? $default_return : TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
// Set a setting value
|
||||
// TODO fix this (see above)
|
||||
function setting_set($name = NULL, $value = TRUE)
|
||||
{
|
||||
$this->settings->set($name, $value);
|
||||
}
|
||||
|
||||
// Used to find current index in dropdown setting
|
||||
function setting_index($name = NULL)
|
||||
{
|
||||
$setting = $this->settings($name);
|
||||
if (is_string($name) && $setting->is_array()) {
|
||||
return $setting->index();
|
||||
} else {
|
||||
// Returns -1 to avoid accidentally selecting an item in a dropdown
|
||||
return CrayonSettings::INVALID;
|
||||
}
|
||||
}
|
||||
|
||||
function formatted_code()
|
||||
{
|
||||
return $this->formatted_code;
|
||||
}
|
||||
|
||||
function runtime()
|
||||
{
|
||||
return $this->runtime;
|
||||
}
|
||||
|
||||
function is_highlighted($highlighted = NULL)
|
||||
{
|
||||
if ($highlighted === NULL) {
|
||||
return $this->is_highlighted;
|
||||
} else {
|
||||
$this->is_highlighted = $highlighted;
|
||||
}
|
||||
}
|
||||
|
||||
function is_mixed($mixed = NULL)
|
||||
{
|
||||
if ($mixed === NULL) {
|
||||
return $this->is_mixed;
|
||||
} else {
|
||||
$this->is_mixed = $mixed;
|
||||
}
|
||||
}
|
||||
|
||||
function is_inline($inline = NULL)
|
||||
{
|
||||
if ($inline === NULL) {
|
||||
return $this->is_inline;
|
||||
} else {
|
||||
$inline = CrayonUtil::str_to_bool($inline, FALSE);
|
||||
$this->is_inline = $inline;
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
File diff suppressed because it is too large
Load Diff
@ -1,265 +1,275 @@
|
||||
<?php
|
||||
require_once ('global.php');
|
||||
require_once (CRAYON_LANGS_PHP);
|
||||
require_once('global.php');
|
||||
require_once(CRAYON_LANGS_PHP);
|
||||
|
||||
/* Manages parsing the syntax for any given language, constructing the regex, and validating the
|
||||
elements. */
|
||||
class CrayonParser {
|
||||
// Properties and Constants ===============================================
|
||||
const CASE_INSENSITIVE = 'CASE_INSENSITIVE';
|
||||
const MULTI_LINE = 'MULTI_LINE';
|
||||
const SINGLE_LINE = 'SINGLE_LINE';
|
||||
const ALLOW_MIXED = 'ALLOW_MIXED';
|
||||
//const NO_END_TAG = '(?![^<]*>)'; // No longer used
|
||||
const HTML_CHAR = 'HTML_CHAR';
|
||||
const HTML_CHAR_REGEX = '<|>|(&([\w-]+);?)|[ \t]+';
|
||||
const CRAYON_ELEMENT = 'CRAYON_ELEMENT';
|
||||
const CRAYON_ELEMENT_REGEX = '\{\{crayon-internal:[^\}]*\}\}';
|
||||
const CRAYON_ELEMENT_REGEX_CAPTURE = '\{\{crayon-internal:([^\}]*)\}\}';
|
||||
|
||||
private static $modes = array(self::CASE_INSENSITIVE => TRUE, self::MULTI_LINE => TRUE, self::SINGLE_LINE => TRUE, self::ALLOW_MIXED => TRUE);
|
||||
class CrayonParser
|
||||
{
|
||||
// Properties and Constants ===============================================
|
||||
const CASE_INSENSITIVE = 'CASE_INSENSITIVE';
|
||||
const MULTI_LINE = 'MULTI_LINE';
|
||||
const SINGLE_LINE = 'SINGLE_LINE';
|
||||
const ALLOW_MIXED = 'ALLOW_MIXED';
|
||||
//const NO_END_TAG = '(?![^<]*>)'; // No longer used
|
||||
const HTML_CHAR = 'HTML_CHAR';
|
||||
const HTML_CHAR_REGEX = '<|>|(&([\w-]+);?)|[ \t]+';
|
||||
const CRAYON_ELEMENT = 'CRAYON_ELEMENT';
|
||||
const CRAYON_ELEMENT_REGEX = '\{\{crayon-internal:[^\}]*\}\}';
|
||||
const CRAYON_ELEMENT_REGEX_CAPTURE = '\{\{crayon-internal:([^\}]*)\}\}';
|
||||
|
||||
// Methods ================================================================
|
||||
private function __construct() {}
|
||||
private static $modes = array(self::CASE_INSENSITIVE => TRUE, self::MULTI_LINE => TRUE, self::SINGLE_LINE => TRUE, self::ALLOW_MIXED => TRUE);
|
||||
|
||||
/**
|
||||
* Parse all languages stored in CrayonLangs.
|
||||
* Avoid using this unless you must list the details in language files for all languages.
|
||||
* @return array Array of all loaded CrayonLangs.
|
||||
*/
|
||||
public static function parse_all() {
|
||||
$langs = CrayonResources::langs()->get();
|
||||
if (empty($langs)) {
|
||||
return FALSE;
|
||||
}
|
||||
foreach ($langs as $lang) {
|
||||
self::parse($lang->id());
|
||||
}
|
||||
return $langs;
|
||||
}
|
||||
// Methods ================================================================
|
||||
private function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
/* Read a syntax file and parse the regex rules within it, this may require several other
|
||||
files containing lists of keywords and such to be read. Updates the parsed elements and
|
||||
regex in the CrayonLang with the given $id. */
|
||||
public static function parse($id) {
|
||||
// Verify the language is loaded and has not been parsed before
|
||||
if ( !($lang = CrayonResources::langs()->get($id)) ) {
|
||||
CrayonLog::syslog("The language with id '$id' was not loaded and could not be parsed.");
|
||||
return FALSE;
|
||||
} else if ($lang->is_parsed()) {
|
||||
return;
|
||||
}
|
||||
// Read language file
|
||||
$path = CrayonResources::langs()->path($id);
|
||||
/**
|
||||
* Parse all languages stored in CrayonLangs.
|
||||
* Avoid using this unless you must list the details in language files for all languages.
|
||||
* @return array Array of all loaded CrayonLangs.
|
||||
*/
|
||||
public static function parse_all()
|
||||
{
|
||||
$langs = CrayonResources::langs()->get();
|
||||
if (empty($langs)) {
|
||||
return FALSE;
|
||||
}
|
||||
foreach ($langs as $lang) {
|
||||
self::parse($lang->id());
|
||||
}
|
||||
return $langs;
|
||||
}
|
||||
|
||||
/* Read a syntax file and parse the regex rules within it, this may require several other
|
||||
files containing lists of keywords and such to be read. Updates the parsed elements and
|
||||
regex in the CrayonLang with the given $id. */
|
||||
public static function parse($id)
|
||||
{
|
||||
// Verify the language is loaded and has not been parsed before
|
||||
if (!($lang = CrayonResources::langs()->get($id))) {
|
||||
CrayonLog::syslog("The language with id '$id' was not loaded and could not be parsed.");
|
||||
return FALSE;
|
||||
} else if ($lang->is_parsed()) {
|
||||
return;
|
||||
}
|
||||
// Read language file
|
||||
$path = CrayonResources::langs()->path($id);
|
||||
CrayonLog::debug('Parsing language ' . $path);
|
||||
if ( ($file = CrayonUtil::lines($path, 'wcs')) === FALSE ) {
|
||||
if (($file = CrayonUtil::lines($path, 'wcs')) === FALSE) {
|
||||
CrayonLog::debug('Parsing failed ' . $path);
|
||||
return FALSE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// Extract the language name
|
||||
$name_pattern = '#^[ \t]*name[ \t]+([^\r\n]+)[ \t]*#mi';
|
||||
preg_match($name_pattern, $file, $name);
|
||||
if (count($name) > 1) {
|
||||
$name = $name[1];
|
||||
$lang->name($name);
|
||||
$file = preg_replace($name_pattern, '', $file);
|
||||
} else {
|
||||
$name = $lang->id();
|
||||
}
|
||||
// Extract the language name
|
||||
$name_pattern = '#^[ \t]*name[ \t]+([^\r\n]+)[ \t]*#mi';
|
||||
preg_match($name_pattern, $file, $name);
|
||||
if (count($name) > 1) {
|
||||
$name = $name[1];
|
||||
$lang->name($name);
|
||||
$file = preg_replace($name_pattern, '', $file);
|
||||
} else {
|
||||
$name = $lang->id();
|
||||
}
|
||||
|
||||
// Extract the language version
|
||||
$version_pattern = '#^[ \t]*version[ \t]+([^\r\n]+)[ \t]*#mi';
|
||||
preg_match($version_pattern, $file, $version);
|
||||
if (count($version) > 1) {
|
||||
$version = $version[1];
|
||||
$lang->version($version);
|
||||
$file = preg_replace($version_pattern, '', $file);
|
||||
}
|
||||
// Extract the language version
|
||||
$version_pattern = '#^[ \t]*version[ \t]+([^\r\n]+)[ \t]*#mi';
|
||||
preg_match($version_pattern, $file, $version);
|
||||
if (count($version) > 1) {
|
||||
$version = $version[1];
|
||||
$lang->version($version);
|
||||
$file = preg_replace($version_pattern, '', $file);
|
||||
}
|
||||
|
||||
// Extract the modes
|
||||
$mode_pattern = '#^[ \t]*(' . implode('|', array_keys(self::$modes)) . ')[ \t]+(?:=[ \t]*)?([^\r\n]+)[ \t]*#mi';
|
||||
preg_match_all($mode_pattern, $file, $mode_matches);
|
||||
if (count($mode_matches) == 3) {
|
||||
for ($i = 0; $i < count($mode_matches[0]); $i++) {
|
||||
$lang->mode($mode_matches[1][$i], $mode_matches[2][$i]);
|
||||
}
|
||||
$file = preg_replace($mode_pattern, '', $file);
|
||||
}
|
||||
// Extract the modes
|
||||
$mode_pattern = '#^[ \t]*(' . implode('|', array_keys(self::$modes)) . ')[ \t]+(?:=[ \t]*)?([^\r\n]+)[ \t]*#mi';
|
||||
preg_match_all($mode_pattern, $file, $mode_matches);
|
||||
if (count($mode_matches) == 3) {
|
||||
for ($i = 0; $i < count($mode_matches[0]); $i++) {
|
||||
$lang->mode($mode_matches[1][$i], $mode_matches[2][$i]);
|
||||
}
|
||||
$file = preg_replace($mode_pattern, '', $file);
|
||||
}
|
||||
|
||||
/* Add reserved Crayon element. This is used by Crayon internally. */
|
||||
$crayon_element = new CrayonElement(self::CRAYON_ELEMENT, $path, self::CRAYON_ELEMENT_REGEX);
|
||||
$lang->element(self::CRAYON_ELEMENT, $crayon_element);
|
||||
/* Add reserved Crayon element. This is used by Crayon internally. */
|
||||
$crayon_element = new CrayonElement(self::CRAYON_ELEMENT, $path, self::CRAYON_ELEMENT_REGEX);
|
||||
$lang->element(self::CRAYON_ELEMENT, $crayon_element);
|
||||
|
||||
// Extract elements, classes and regex
|
||||
$pattern = '#^[ \t]*([\w:]+)[ \t]+(?:\[([\w\t ]*)\][ \t]+)?([^\r\n]+)[ \t]*#m';
|
||||
preg_match_all($pattern, $file, $matches);
|
||||
// Extract elements, classes and regex
|
||||
$pattern = '#^[ \t]*([\w:]+)[ \t]+(?:\[([\w\t ]*)\][ \t]+)?([^\r\n]+)[ \t]*#m';
|
||||
preg_match_all($pattern, $file, $matches);
|
||||
|
||||
if (!empty($matches[0])) {
|
||||
$elements = $matches[1];
|
||||
$classes = $matches[2];
|
||||
$regexes = $matches[3];
|
||||
} else {
|
||||
CrayonLog::syslog("No regex patterns and/or elements were parsed from language file at '$path'.");
|
||||
}
|
||||
if (!empty($matches[0])) {
|
||||
$elements = $matches[1];
|
||||
$classes = $matches[2];
|
||||
$regexes = $matches[3];
|
||||
} else {
|
||||
CrayonLog::syslog("No regex patterns and/or elements were parsed from language file at '$path'.");
|
||||
}
|
||||
|
||||
// Remember state in case we encounter catchable exceptions
|
||||
$error = FALSE;
|
||||
for ($i = 0; $i < count($matches[0]); $i++) {
|
||||
// References
|
||||
$name = &$elements[$i];
|
||||
$class = &$classes[$i];
|
||||
$regex = &$regexes[$i];
|
||||
$name = trim(strtoupper($name));
|
||||
// Ensure both the element and regex are valid
|
||||
if (empty($name) || empty($regex)) {
|
||||
CrayonLog::syslog("Element(s) and/or regex(es) are missing in '$path'.");
|
||||
$error = TRUE;
|
||||
continue;
|
||||
}
|
||||
// Look for fallback element
|
||||
$pieces = explode(':', $name);
|
||||
if (count($pieces) == 2) {
|
||||
$name = $pieces[0];
|
||||
$fallback = $pieces[1];
|
||||
} else if (count($pieces) == 1) {
|
||||
$name = $pieces[0];
|
||||
$fallback = '';
|
||||
} else {
|
||||
CrayonLog::syslog("Too many colons found in element name '$name' in '$path'");
|
||||
$error = TRUE;
|
||||
continue;
|
||||
}
|
||||
// Create a new CrayonElement
|
||||
$element = new CrayonElement($name, $path);
|
||||
$element->fallback($fallback);
|
||||
if (!empty($class)) {
|
||||
// Avoid setting known css to blank
|
||||
$element->css($class);
|
||||
}
|
||||
if ($element->regex($regex) === FALSE) {
|
||||
$error = TRUE;
|
||||
continue;
|
||||
}
|
||||
// Add the regex to the element
|
||||
$lang->element($name, $element);
|
||||
$state = $error ? CrayonLang::PARSED_ERRORS : CrayonLang::PARSED_SUCCESS;
|
||||
$lang->state($state);
|
||||
}
|
||||
// Remember state in case we encounter catchable exceptions
|
||||
$error = FALSE;
|
||||
for ($i = 0; $i < count($matches[0]); $i++) {
|
||||
// References
|
||||
$name = &$elements[$i];
|
||||
$class = &$classes[$i];
|
||||
$regex = &$regexes[$i];
|
||||
$name = trim(strtoupper($name));
|
||||
// Ensure both the element and regex are valid
|
||||
if (empty($name) || empty($regex)) {
|
||||
CrayonLog::syslog("Element(s) and/or regex(es) are missing in '$path'.");
|
||||
$error = TRUE;
|
||||
continue;
|
||||
}
|
||||
// Look for fallback element
|
||||
$pieces = explode(':', $name);
|
||||
if (count($pieces) == 2) {
|
||||
$name = $pieces[0];
|
||||
$fallback = $pieces[1];
|
||||
} else if (count($pieces) == 1) {
|
||||
$name = $pieces[0];
|
||||
$fallback = '';
|
||||
} else {
|
||||
CrayonLog::syslog("Too many colons found in element name '$name' in '$path'");
|
||||
$error = TRUE;
|
||||
continue;
|
||||
}
|
||||
// Create a new CrayonElement
|
||||
$element = new CrayonElement($name, $path);
|
||||
$element->fallback($fallback);
|
||||
if (!empty($class)) {
|
||||
// Avoid setting known css to blank
|
||||
$element->css($class);
|
||||
}
|
||||
if ($element->regex($regex) === FALSE) {
|
||||
$error = TRUE;
|
||||
continue;
|
||||
}
|
||||
// Add the regex to the element
|
||||
$lang->element($name, $element);
|
||||
$state = $error ? CrayonLang::PARSED_ERRORS : CrayonLang::PARSED_SUCCESS;
|
||||
$lang->state($state);
|
||||
}
|
||||
|
||||
/* Prevents < > and other html entities from being printed as is, which could lead to actual html tags
|
||||
* from the printed code appearing on the page - not good. This can also act to color any HTML entities
|
||||
* that are not picked up by previously defined elements.
|
||||
*/
|
||||
$html = new CrayonElement(self::HTML_CHAR, $path, self::HTML_CHAR_REGEX);
|
||||
$lang->element(self::HTML_CHAR, $html);
|
||||
}
|
||||
/* Prevents < > and other html entities from being printed as is, which could lead to actual html tags
|
||||
* from the printed code appearing on the page - not good. This can also act to color any HTML entities
|
||||
* that are not picked up by previously defined elements.
|
||||
*/
|
||||
$html = new CrayonElement(self::HTML_CHAR, $path, self::HTML_CHAR_REGEX);
|
||||
$lang->element(self::HTML_CHAR, $html);
|
||||
}
|
||||
|
||||
// Validates regex and accesses data stored in a CrayonElement
|
||||
public static function validate_regex($regex, $element) {
|
||||
if (is_string($regex) && @get_class($element) == CRAYON_ELEMENT_CLASS) {
|
||||
// If the (?alt) tag has been used, insert the file into the regex
|
||||
$file = self::regex_match('#\(\?alt:(.+?)\)#', $regex);
|
||||
if ( count($file) == 2 ) {
|
||||
// Element 0 has full match, 1 has captured groups
|
||||
for ($i = 0; $i < count($file[1]); $i++) {
|
||||
$file_lines = CrayonUtil::lines(dirname($element->path()) . crayon_s() . $file[1][$i], 'rcwh');
|
||||
if ($file_lines !== FALSE) {
|
||||
$file_lines = implode('|', $file_lines);
|
||||
// If any spaces exist, treat them as whitespace
|
||||
$file_lines = preg_replace('#[ \t]+#msi', '\s+', $file_lines);
|
||||
$regex = str_replace($file[0][$i], "(?:$file_lines)", $regex);
|
||||
} else {
|
||||
CrayonLog::syslog("Parsing of '{$element->path()}' failed, an (?alt) tag failed for the element '{$element->name()}'" );
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Validates regex and accesses data stored in a CrayonElement
|
||||
public static function validate_regex($regex, $element)
|
||||
{
|
||||
if (is_string($regex) && @get_class($element) == CRAYON_ELEMENT_CLASS) {
|
||||
// If the (?alt) tag has been used, insert the file into the regex
|
||||
$file = self::regex_match('#\(\?alt:(.+?)\)#', $regex);
|
||||
if (count($file) == 2) {
|
||||
// Element 0 has full match, 1 has captured groups
|
||||
for ($i = 0; $i < count($file[1]); $i++) {
|
||||
$file_lines = CrayonUtil::lines(dirname($element->path()) . crayon_s() . $file[1][$i], 'rcwh');
|
||||
if ($file_lines !== FALSE) {
|
||||
$file_lines = implode('|', $file_lines);
|
||||
// If any spaces exist, treat them as whitespace
|
||||
$file_lines = preg_replace('#[ \t]+#msi', '\s+', $file_lines);
|
||||
$regex = str_replace($file[0][$i], "(?:$file_lines)", $regex);
|
||||
} else {
|
||||
CrayonLog::syslog("Parsing of '{$element->path()}' failed, an (?alt) tag failed for the element '{$element->name()}'");
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// If the (?default:element) function is used, replace the regex with the default, if exists
|
||||
$def = self::regex_match('#\(\?default(?:\:(\w+))?\)#', $regex);
|
||||
if ( count($def) == 2 ) {
|
||||
// Load default language
|
||||
$default = CrayonResources::langs()->get(CrayonLangs::DEFAULT_LANG);
|
||||
// If default has not been loaded, we can't use it, skip the element
|
||||
if (!$default) {
|
||||
CrayonLog::syslog(
|
||||
"Could not use default regex in the element '{$element->name()}' in '{$element->path()}'");
|
||||
return FALSE;
|
||||
}
|
||||
for ($i = 0; $i < count($def[1]); $i++) {
|
||||
// If an element has been provided
|
||||
$element_name = ( !empty($def[1][$i]) ) ? $def[1][$i] : $element->name();
|
||||
if (($default_element = $default->element($element_name)) != FALSE) {
|
||||
$regex = str_replace($def[0][$i], '(?:' . $default_element->regex() .')', $regex);
|
||||
} else {
|
||||
CrayonLog::syslog("The language at '{$element->path()}' referred to the Default Language regex for element '{$element->name()}', which did not exist.");
|
||||
// If the (?default:element) function is used, replace the regex with the default, if exists
|
||||
$def = self::regex_match('#\(\?default(?:\:(\w+))?\)#', $regex);
|
||||
if (count($def) == 2) {
|
||||
// Load default language
|
||||
$default = CrayonResources::langs()->get(CrayonLangs::DEFAULT_LANG);
|
||||
// If default has not been loaded, we can't use it, skip the element
|
||||
if (!$default) {
|
||||
CrayonLog::syslog(
|
||||
"Could not use default regex in the element '{$element->name()}' in '{$element->path()}'");
|
||||
return FALSE;
|
||||
}
|
||||
for ($i = 0; $i < count($def[1]); $i++) {
|
||||
// If an element has been provided
|
||||
$element_name = (!empty($def[1][$i])) ? $def[1][$i] : $element->name();
|
||||
if (($default_element = $default->element($element_name)) != FALSE) {
|
||||
$regex = str_replace($def[0][$i], '(?:' . $default_element->regex() . ')', $regex);
|
||||
} else {
|
||||
CrayonLog::syslog("The language at '{$element->path()}' referred to the Default Language regex for element '{$element->name()}', which did not exist.");
|
||||
if (CRAYON_DEBUG) {
|
||||
CrayonLog::syslog("Default language URL: " . CrayonResources::langs()->url(CrayonLangs::DEFAULT_LANG));
|
||||
CrayonLog::syslog("Default language Path: " . CrayonResources::langs()->path(CrayonLangs::DEFAULT_LANG));
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// If the (?html) tag is used, escape characters in html (<, > and &)
|
||||
$html = self::regex_match('#\(\?html:(.+?)\)#', $regex);
|
||||
if ( count($html) == 2 ) {
|
||||
for ($i = 0; $i < count($html[1]); $i++) {
|
||||
$regex = str_replace($html[0][$i], htmlentities($html[1][$i]), $regex);
|
||||
}
|
||||
}
|
||||
// If the (?html) tag is used, escape characters in html (<, > and &)
|
||||
$html = self::regex_match('#\(\?html:(.+?)\)#', $regex);
|
||||
if (count($html) == 2) {
|
||||
for ($i = 0; $i < count($html[1]); $i++) {
|
||||
$regex = str_replace($html[0][$i], htmlentities($html[1][$i]), $regex);
|
||||
}
|
||||
}
|
||||
|
||||
// Ensure all parenthesis are atomic to avoid conflicting with element matches
|
||||
$regex = CrayonUtil::esc_atomic($regex);
|
||||
// Ensure all parenthesis are atomic to avoid conflicting with element matches
|
||||
$regex = CrayonUtil::esc_atomic($regex);
|
||||
|
||||
// Escape #, this is our delimiter
|
||||
$regex = CrayonUtil::esc_hash($regex);
|
||||
// Escape #, this is our delimiter
|
||||
$regex = CrayonUtil::esc_hash($regex);
|
||||
|
||||
// Test if regex is valid
|
||||
if (@preg_match("#$regex#", '') === FALSE) {
|
||||
CrayonLog::syslog("The regex for the element '{$element->name()}' in '{$element->path()}' is not valid.");
|
||||
return FALSE;
|
||||
}
|
||||
// Test if regex is valid
|
||||
if (@preg_match("#$regex#", '') === FALSE) {
|
||||
CrayonLog::syslog("The regex for the element '{$element->name()}' in '{$element->path()}' is not valid.");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return $regex;
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
return $regex;
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
public static function validate_css($css) {
|
||||
if (is_string($css)) {
|
||||
// Remove dots in CSS class and convert to lowercase
|
||||
$css = str_replace('.', '', $css);
|
||||
$css = strtolower($css);
|
||||
$css = explode(' ', $css);
|
||||
$css_str = '';
|
||||
foreach ($css as $c) {
|
||||
if (!empty($c)) {
|
||||
$css_str .= $c . ' ';
|
||||
}
|
||||
}
|
||||
return trim($css_str);
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
public static function validate_css($css)
|
||||
{
|
||||
if (is_string($css)) {
|
||||
// Remove dots in CSS class and convert to lowercase
|
||||
$css = str_replace('.', '', $css);
|
||||
$css = strtolower($css);
|
||||
$css = explode(' ', $css);
|
||||
$css_str = '';
|
||||
foreach ($css as $c) {
|
||||
if (!empty($c)) {
|
||||
$css_str .= $c . ' ';
|
||||
}
|
||||
}
|
||||
return trim($css_str);
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
public static function regex_match($pattern, $subject) {
|
||||
if (preg_match_all($pattern, $subject, $matches)) {
|
||||
return $matches;
|
||||
}
|
||||
return array();
|
||||
}
|
||||
public static function regex_match($pattern, $subject)
|
||||
{
|
||||
if (preg_match_all($pattern, $subject, $matches)) {
|
||||
return $matches;
|
||||
}
|
||||
return array();
|
||||
}
|
||||
|
||||
public static function modes() {
|
||||
return self::$modes;
|
||||
}
|
||||
public static function modes()
|
||||
{
|
||||
return self::$modes;
|
||||
}
|
||||
|
||||
public static function is_mode($name) {
|
||||
return is_string($name) && array_key_exists($name, self::$modes);
|
||||
}
|
||||
public static function is_mode($name)
|
||||
{
|
||||
return is_string($name) && array_key_exists($name, self::$modes);
|
||||
}
|
||||
}
|
||||
?>
|
@ -1,296 +1,333 @@
|
||||
<?php
|
||||
require_once ('global.php');
|
||||
require_once (CRAYON_LANGS_PHP);
|
||||
require_once (CRAYON_THEMES_PHP);
|
||||
require_once (CRAYON_FONTS_PHP);
|
||||
require_once('global.php');
|
||||
require_once(CRAYON_LANGS_PHP);
|
||||
require_once(CRAYON_THEMES_PHP);
|
||||
require_once(CRAYON_FONTS_PHP);
|
||||
|
||||
class CrayonResources {
|
||||
private static $langs = NULL;
|
||||
private static $themes = NULL;
|
||||
private static $fonts = NULL;
|
||||
class CrayonResources
|
||||
{
|
||||
private static $langs = NULL;
|
||||
private static $themes = NULL;
|
||||
private static $fonts = NULL;
|
||||
|
||||
private function __construct() {}
|
||||
private function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
public static function langs() {
|
||||
public static function langs()
|
||||
{
|
||||
if (self::$langs == NULL) {
|
||||
self::$langs = new CrayonLangs();
|
||||
}
|
||||
return self::$langs;
|
||||
}
|
||||
return self::$langs;
|
||||
}
|
||||
|
||||
public static function themes() {
|
||||
public static function themes()
|
||||
{
|
||||
if (self::$themes == NULL) {
|
||||
self::$themes = new CrayonThemes();
|
||||
}
|
||||
return self::$themes;
|
||||
}
|
||||
return self::$themes;
|
||||
}
|
||||
|
||||
public static function fonts() {
|
||||
public static function fonts()
|
||||
{
|
||||
if (self::$fonts == NULL) {
|
||||
self::$fonts = new CrayonFonts();
|
||||
}
|
||||
return self::$fonts;
|
||||
}
|
||||
return self::$fonts;
|
||||
}
|
||||
}
|
||||
|
||||
class CrayonResourceCollection {
|
||||
// Properties and Constants ===============================================
|
||||
class CrayonResourceCollection
|
||||
{
|
||||
// Properties and Constants ===============================================
|
||||
|
||||
// Loaded resources
|
||||
// Loaded resources
|
||||
|
||||
private $collection = array();
|
||||
// Loading state
|
||||
private $collection = array();
|
||||
// Loading state
|
||||
|
||||
private $state = self::UNLOADED;
|
||||
// Directory containing resources
|
||||
private $state = self::UNLOADED;
|
||||
// Directory containing resources
|
||||
|
||||
private $dir = '';
|
||||
private $default_id = '';
|
||||
private $default_name = '';
|
||||
const UNLOADED = -1;
|
||||
const LOADING = 0;
|
||||
const LOADED = 1;
|
||||
private $dir = '';
|
||||
private $default_id = '';
|
||||
private $default_name = '';
|
||||
const UNLOADED = -1;
|
||||
const LOADING = 0;
|
||||
const LOADED = 1;
|
||||
|
||||
// Methods ================================================================
|
||||
// Methods ================================================================
|
||||
|
||||
/* Override in subclasses. Returns the absolute path for a given resource. Does not check for its existence. */
|
||||
public function path($id) {
|
||||
return '';
|
||||
}
|
||||
/* Override in subclasses. Returns the absolute path for a given resource. Does not check for its existence. */
|
||||
public function path($id)
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
/* Verifies a resource exists. */
|
||||
public function exists($id) {
|
||||
return file_exists($this->path($id));
|
||||
}
|
||||
/* Verifies a resource exists. */
|
||||
public function exists($id)
|
||||
{
|
||||
return file_exists($this->path($id));
|
||||
}
|
||||
|
||||
/* Load all the available languages. Doesn't parse them for their names and regex. */
|
||||
public function load() {
|
||||
// Load only once
|
||||
/* Load all the available languages. Doesn't parse them for their names and regex. */
|
||||
public function load()
|
||||
{
|
||||
// Load only once
|
||||
|
||||
if (!$this->is_state_unloaded()) {
|
||||
return;
|
||||
}
|
||||
$this->state = self::LOADING;
|
||||
$this->load_process();
|
||||
$this->state = self::LOADED;
|
||||
}
|
||||
if (!$this->is_state_unloaded()) {
|
||||
return;
|
||||
}
|
||||
$this->state = self::LOADING;
|
||||
$this->load_process();
|
||||
$this->state = self::LOADED;
|
||||
}
|
||||
|
||||
public function load_resources($dir = NULL) {
|
||||
public function load_resources($dir = NULL)
|
||||
{
|
||||
if ($dir === NULL) {
|
||||
$dir = $this->dir;
|
||||
}
|
||||
|
||||
if (!$this->is_state_loading()) {
|
||||
if (!$this->is_state_loading()) {
|
||||
// Load only once
|
||||
return;
|
||||
}
|
||||
try {
|
||||
// Look in directory for resources
|
||||
return;
|
||||
}
|
||||
try {
|
||||
// Look in directory for resources
|
||||
|
||||
if (!is_dir($dir)) {
|
||||
CrayonLog::syslog('The resource directory is missing, should be at \'' . $dir . '\'.');
|
||||
} else if (($handle = @opendir($dir)) != FALSE) {
|
||||
// Loop over directory contents
|
||||
while (($file = readdir($handle)) !== FALSE) {
|
||||
if ($file != "." && $file != "..") {
|
||||
// Check if $file is directory, remove extension when checking for existence.
|
||||
if (!is_dir($dir)) {
|
||||
CrayonLog::syslog('The resource directory is missing, should be at \'' . $dir . '\'.');
|
||||
} else if (($handle = @opendir($dir)) != FALSE) {
|
||||
// Loop over directory contents
|
||||
while (($file = readdir($handle)) !== FALSE) {
|
||||
if ($file != "." && $file != "..") {
|
||||
// Check if $file is directory, remove extension when checking for existence.
|
||||
|
||||
if (!is_dir($dir . $file)) {
|
||||
$file = CrayonUtil::path_rem_ext($file);
|
||||
}
|
||||
if ($this->exists($file)) {
|
||||
$this->add_resource($this->resource_instance($file));
|
||||
}
|
||||
}
|
||||
}
|
||||
closedir($handle);
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
CrayonLog::syslog('An error occured when trying to load resources: ' . $e->getFile() . $e->getLine());
|
||||
}
|
||||
}
|
||||
if (!is_dir($dir . $file)) {
|
||||
$file = CrayonUtil::path_rem_ext($file);
|
||||
}
|
||||
if ($this->exists($file)) {
|
||||
$this->add_resource($this->resource_instance($file));
|
||||
}
|
||||
}
|
||||
}
|
||||
closedir($handle);
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
CrayonLog::syslog('An error occured when trying to load resources: ' . $e->getFile() . $e->getLine());
|
||||
}
|
||||
}
|
||||
|
||||
/* Override in subclasses. */
|
||||
public function load_process() {
|
||||
if (!$this->is_state_loading()) {
|
||||
return;
|
||||
}
|
||||
$this->load_resources();
|
||||
$this->add_default();
|
||||
}
|
||||
/* Override in subclasses. */
|
||||
public function load_process()
|
||||
{
|
||||
if (!$this->is_state_loading()) {
|
||||
return;
|
||||
}
|
||||
$this->load_resources();
|
||||
$this->add_default();
|
||||
}
|
||||
|
||||
/* Override in subclasses */
|
||||
public function add_default() {
|
||||
if (!$this->is_state_loading()) {
|
||||
return FALSE;
|
||||
} else if (!$this->is_loaded($this->default_id)) {
|
||||
CrayonLog::syslog('The default resource could not be loaded from \'' . $this->dir . '\'.');
|
||||
// Add the default, but it will not be functionable
|
||||
/* Override in subclasses */
|
||||
public function add_default()
|
||||
{
|
||||
if (!$this->is_state_loading()) {
|
||||
return FALSE;
|
||||
} else if (!$this->is_loaded($this->default_id)) {
|
||||
CrayonLog::syslog('The default resource could not be loaded from \'' . $this->dir . '\'.');
|
||||
// Add the default, but it will not be functionable
|
||||
|
||||
$default = $this->resource_instance($this->default_id, $this->default_name);
|
||||
$this->add($this->default_id, $default);
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
$default = $this->resource_instance($this->default_id, $this->default_name);
|
||||
$this->add($this->default_id, $default);
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* Returns the default resource */
|
||||
public function set_default($id, $name) {
|
||||
$this->default_id = $id;
|
||||
$this->default_name = $name;
|
||||
}
|
||||
/* Returns the default resource */
|
||||
public function set_default($id, $name)
|
||||
{
|
||||
$this->default_id = $id;
|
||||
$this->default_name = $name;
|
||||
}
|
||||
|
||||
/* Returns the default resource */
|
||||
public function get_default() {
|
||||
return $this->get($this->default_id);
|
||||
}
|
||||
/* Returns the default resource */
|
||||
public function get_default()
|
||||
{
|
||||
return $this->get($this->default_id);
|
||||
}
|
||||
|
||||
/* Override in subclasses to create subclass object if needed */
|
||||
public function resource_instance($id, $name = NULL) {
|
||||
return new CrayonResource($id, $name);
|
||||
}
|
||||
/* Override in subclasses to create subclass object if needed */
|
||||
public function resource_instance($id, $name = NULL)
|
||||
{
|
||||
return new CrayonResource($id, $name);
|
||||
}
|
||||
|
||||
public function add($id, $resource) {
|
||||
if (is_string($id) && !empty($id)) {
|
||||
$this->collection[$id] = $resource;
|
||||
asort($this->collection);
|
||||
public function add($id, $resource)
|
||||
{
|
||||
if (is_string($id) && !empty($id)) {
|
||||
$this->collection[$id] = $resource;
|
||||
asort($this->collection);
|
||||
CrayonLog::debug('Added resource: ' . $this->path($id));
|
||||
} else {
|
||||
} else {
|
||||
CrayonLog::syslog('Could not add resource: ', $id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function add_resource($resource) {
|
||||
$this->add($resource->id(), $resource);
|
||||
}
|
||||
public function add_resource($resource)
|
||||
{
|
||||
$this->add($resource->id(), $resource);
|
||||
}
|
||||
|
||||
public function remove($name) {
|
||||
if (is_string($name) && !empty($name) && array_key_exists($name, $this->collection)) {
|
||||
unset($this->collection[$name]);
|
||||
}
|
||||
}
|
||||
public function remove($name)
|
||||
{
|
||||
if (is_string($name) && !empty($name) && array_key_exists($name, $this->collection)) {
|
||||
unset($this->collection[$name]);
|
||||
}
|
||||
}
|
||||
|
||||
public function remove_all() {
|
||||
$this->collection = array();
|
||||
}
|
||||
public function remove_all()
|
||||
{
|
||||
$this->collection = array();
|
||||
}
|
||||
|
||||
/* Returns the resource for the given id or NULL if it can't be found */
|
||||
public function get($id = NULL) {
|
||||
$this->load();
|
||||
if ($id === NULL) {
|
||||
return $this->collection;
|
||||
} else if (is_string($id) && $this->is_loaded($id)) {
|
||||
return $this->collection[$id];
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
/* Returns the resource for the given id or NULL if it can't be found */
|
||||
public function get($id = NULL)
|
||||
{
|
||||
$this->load();
|
||||
if ($id === NULL) {
|
||||
return $this->collection;
|
||||
} else if (is_string($id) && $this->is_loaded($id)) {
|
||||
return $this->collection[$id];
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
public function get_array() {
|
||||
$array = array();
|
||||
foreach ($this->get() as $resource) {
|
||||
$array[$resource->id()] = $resource->name();
|
||||
}
|
||||
return $array;
|
||||
}
|
||||
public function get_array()
|
||||
{
|
||||
$array = array();
|
||||
foreach ($this->get() as $resource) {
|
||||
$array[$resource->id()] = $resource->name();
|
||||
}
|
||||
return $array;
|
||||
}
|
||||
|
||||
public function is_loaded($id) {
|
||||
if (is_string($id)) {
|
||||
return array_key_exists($id, $this->collection);
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
public function is_loaded($id)
|
||||
{
|
||||
if (is_string($id)) {
|
||||
return array_key_exists($id, $this->collection);
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
public function get_state() {
|
||||
return $this->state;
|
||||
}
|
||||
public function get_state()
|
||||
{
|
||||
return $this->state;
|
||||
}
|
||||
|
||||
public function is_state_loaded() {
|
||||
return $this->state == self::LOADED;
|
||||
}
|
||||
public function is_state_loaded()
|
||||
{
|
||||
return $this->state == self::LOADED;
|
||||
}
|
||||
|
||||
public function is_state_loading() {
|
||||
return $this->state == self::LOADING;
|
||||
}
|
||||
public function is_state_loading()
|
||||
{
|
||||
return $this->state == self::LOADING;
|
||||
}
|
||||
|
||||
public function is_state_unloaded() {
|
||||
return $this->state == self::UNLOADED;
|
||||
}
|
||||
public function is_state_unloaded()
|
||||
{
|
||||
return $this->state == self::UNLOADED;
|
||||
}
|
||||
|
||||
public function directory($dir = NULL) {
|
||||
public function directory($dir = NULL)
|
||||
{
|
||||
if ($dir === NULL) {
|
||||
return $this->dir;
|
||||
} else {
|
||||
$this->dir = CrayonUtil::path_slash($dir);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function url($id) {
|
||||
return '';
|
||||
}
|
||||
public function url($id)
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
public function get_css($id, $ver = NULL) {
|
||||
$resource = $this->get($id);
|
||||
return '<link rel="stylesheet" type="text/css" href="' . $this->url($resource->id()) . ($ver ? "?ver=$ver" : '') . '" />' . CRAYON_NL;
|
||||
}
|
||||
public function get_css($id, $ver = NULL)
|
||||
{
|
||||
$resource = $this->get($id);
|
||||
return '<link rel="stylesheet" type="text/css" href="' . $this->url($resource->id()) . ($ver ? "?ver=$ver" : '') . '" />' . CRAYON_NL;
|
||||
}
|
||||
}
|
||||
|
||||
class CrayonUsedResourceCollection extends CrayonResourceCollection {
|
||||
class CrayonUsedResourceCollection extends CrayonResourceCollection
|
||||
{
|
||||
|
||||
// Checks if any resoruces are being used
|
||||
public function is_used($id = NULL) {
|
||||
if ($id === NULL) {
|
||||
foreach ($this->get() as $resource) {
|
||||
if ($resource->used()) {
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
} else {
|
||||
$resource = $this->get($id);
|
||||
if (!$resource) {
|
||||
return FALSE;
|
||||
} else {
|
||||
return $resource->used();
|
||||
}
|
||||
}
|
||||
}
|
||||
// Checks if any resoruces are being used
|
||||
public function is_used($id = NULL)
|
||||
{
|
||||
if ($id === NULL) {
|
||||
foreach ($this->get() as $resource) {
|
||||
if ($resource->used()) {
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
return FALSE;
|
||||
} else {
|
||||
$resource = $this->get($id);
|
||||
if (!$resource) {
|
||||
return FALSE;
|
||||
} else {
|
||||
return $resource->used();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function set_used($id, $value = TRUE) {
|
||||
$resource = $this->get($id);
|
||||
if ($resource !== NULL && !$resource->used()) {
|
||||
$resource->used($value == TRUE);
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
public function set_used($id, $value = TRUE)
|
||||
{
|
||||
$resource = $this->get($id);
|
||||
if ($resource !== NULL && !$resource->used()) {
|
||||
$resource->used($value == TRUE);
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
public function get_used() {
|
||||
$used = array();
|
||||
foreach ($this->get() as $resource) {
|
||||
if ($resource->used()) {
|
||||
$used[] = $resource;
|
||||
}
|
||||
}
|
||||
return $used;
|
||||
}
|
||||
public function get_used()
|
||||
{
|
||||
$used = array();
|
||||
foreach ($this->get() as $resource) {
|
||||
if ($resource->used()) {
|
||||
$used[] = $resource;
|
||||
}
|
||||
}
|
||||
return $used;
|
||||
}
|
||||
|
||||
// XXX Override
|
||||
public function resource_instance($id, $name = NULL) {
|
||||
return new CrayonUsedResource($id, $name);
|
||||
}
|
||||
// XXX Override
|
||||
public function resource_instance($id, $name = NULL)
|
||||
{
|
||||
return new CrayonUsedResource($id, $name);
|
||||
}
|
||||
|
||||
public function get_used_css() {
|
||||
$used = $this->get_used();
|
||||
$css = array();
|
||||
foreach ($used as $resource) {
|
||||
$url = $this->url($resource->id());
|
||||
$css[$resource->id()] = $url;
|
||||
}
|
||||
return $css;
|
||||
}
|
||||
public function get_used_css()
|
||||
{
|
||||
$used = $this->get_used();
|
||||
$css = array();
|
||||
foreach ($used as $resource) {
|
||||
$url = $this->url($resource->id());
|
||||
$css[$resource->id()] = $url;
|
||||
}
|
||||
return $css;
|
||||
}
|
||||
}
|
||||
|
||||
class CrayonUserResourceCollection extends CrayonUsedResourceCollection {
|
||||
class CrayonUserResourceCollection extends CrayonUsedResourceCollection
|
||||
{
|
||||
private $user_dir = '';
|
||||
private $curr_dir = NULL;
|
||||
// TODO better to use a base dir and relative
|
||||
@ -299,17 +336,20 @@ class CrayonUserResourceCollection extends CrayonUsedResourceCollection {
|
||||
private $extension = '';
|
||||
|
||||
// XXX Override
|
||||
public function resource_instance($id, $name = NULL) {
|
||||
public function resource_instance($id, $name = NULL)
|
||||
{
|
||||
$resource = $this->create_user_resource_instance($id, $name);
|
||||
$resource->user($this->curr_dir == $this->user_directory());
|
||||
return $resource;
|
||||
}
|
||||
|
||||
public function create_user_resource_instance($id, $name = NULL) {
|
||||
public function create_user_resource_instance($id, $name = NULL)
|
||||
{
|
||||
return new CrayonUserResource($id, $name);
|
||||
}
|
||||
|
||||
public function user_directory($dir = NULL) {
|
||||
public function user_directory($dir = NULL)
|
||||
{
|
||||
if ($dir === NULL) {
|
||||
return $this->user_dir;
|
||||
} else {
|
||||
@ -317,21 +357,24 @@ class CrayonUserResourceCollection extends CrayonUsedResourceCollection {
|
||||
}
|
||||
}
|
||||
|
||||
public function relative_directory($relative_directory = NULL) {
|
||||
public function relative_directory($relative_directory = NULL)
|
||||
{
|
||||
if ($relative_directory == NULL) {
|
||||
return $this->relative_directory;
|
||||
}
|
||||
$this->relative_directory = $relative_directory;
|
||||
}
|
||||
|
||||
public function extension($extension = NULL) {
|
||||
public function extension($extension = NULL)
|
||||
{
|
||||
if ($extension == NULL) {
|
||||
return $this->extension;
|
||||
}
|
||||
$this->extension = $extension;
|
||||
}
|
||||
|
||||
public function load_resources($dir = NULL) {
|
||||
public function load_resources($dir = NULL)
|
||||
{
|
||||
$this->curr_dir = $this->directory();
|
||||
parent::load_resources($this->curr_dir);
|
||||
$this->curr_dir = $this->user_directory();
|
||||
@ -339,11 +382,13 @@ class CrayonUserResourceCollection extends CrayonUsedResourceCollection {
|
||||
$this->curr_dir = NULL;
|
||||
}
|
||||
|
||||
public function current_directory() {
|
||||
public function current_directory()
|
||||
{
|
||||
return $this->curr_dir;
|
||||
}
|
||||
|
||||
public function dir_is_user($id, $user = NULL) {
|
||||
public function dir_is_user($id, $user = NULL)
|
||||
{
|
||||
if ($user === NULL) {
|
||||
if ($this->is_state_loading()) {
|
||||
// We seem to be loading resources - use current directory
|
||||
@ -360,95 +405,112 @@ class CrayonUserResourceCollection extends CrayonUsedResourceCollection {
|
||||
return $user;
|
||||
}
|
||||
|
||||
public function dirpath($user = NULL) {
|
||||
public function dirpath($user = NULL)
|
||||
{
|
||||
$path = $user ? $this->user_directory() : $this->directory();
|
||||
return CrayonUtil::path_slash($path);
|
||||
}
|
||||
|
||||
public function dirpath_for_id($id, $user = NULL) {
|
||||
public function dirpath_for_id($id, $user = NULL)
|
||||
{
|
||||
$user = $this->dir_is_user($id, $user);
|
||||
return $this->dirpath($user) . $id;
|
||||
}
|
||||
|
||||
public function dirurl($user = NULL) {
|
||||
public function dirurl($user = NULL)
|
||||
{
|
||||
$path = $user ? CrayonGlobalSettings::upload_url() : CrayonGlobalSettings::plugin_path();
|
||||
return CrayonUtil::path_slash($path . $this->relative_directory());
|
||||
}
|
||||
|
||||
// XXX Override
|
||||
public function path($id, $user = NULL) {
|
||||
public function path($id, $user = NULL)
|
||||
{
|
||||
$user = $this->dir_is_user($id, $user);
|
||||
return $this->dirpath($user) . $this->filename($id, $user);
|
||||
}
|
||||
|
||||
// XXX Override
|
||||
public function url($id, $user = NULL) {
|
||||
public function url($id, $user = NULL)
|
||||
{
|
||||
$user = $this->dir_is_user($id, $user);
|
||||
return $this->dirurl($user) . $this->filename($id, $user);
|
||||
}
|
||||
|
||||
public function filename($id, $user = NULL) {
|
||||
public function filename($id, $user = NULL)
|
||||
{
|
||||
return "$id.$this->extension";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class CrayonResource {
|
||||
private $id = '';
|
||||
private $name = '';
|
||||
class CrayonResource
|
||||
{
|
||||
private $id = '';
|
||||
private $name = '';
|
||||
|
||||
function __construct($id, $name = NULL) {
|
||||
$id = $this->clean_id($id);
|
||||
CrayonUtil::str($this->id, $id);
|
||||
( empty($name) ) ? $this->name( self::clean_name($this->id) ) : $this->name($name);
|
||||
}
|
||||
function __construct($id, $name = NULL)
|
||||
{
|
||||
$id = $this->clean_id($id);
|
||||
CrayonUtil::str($this->id, $id);
|
||||
(empty($name)) ? $this->name(self::clean_name($this->id)) : $this->name($name);
|
||||
}
|
||||
|
||||
function __tostring() {
|
||||
return $this->name;
|
||||
}
|
||||
function __tostring()
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
function id() {
|
||||
return $this->id;
|
||||
}
|
||||
function id()
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
function name($name = NULL) {
|
||||
if ($name === NULL) {
|
||||
return $this->name;
|
||||
} else {
|
||||
$this->name = $name;
|
||||
}
|
||||
}
|
||||
function name($name = NULL)
|
||||
{
|
||||
if ($name === NULL) {
|
||||
return $this->name;
|
||||
} else {
|
||||
$this->name = $name;
|
||||
}
|
||||
}
|
||||
|
||||
function clean_id($id) {
|
||||
$id = CrayonUtil::space_to_hyphen( strtolower(trim($id)) );
|
||||
function clean_id($id)
|
||||
{
|
||||
$id = CrayonUtil::space_to_hyphen(strtolower(trim($id)));
|
||||
return preg_replace('#[^\w-]#msi', '', $id);
|
||||
}
|
||||
}
|
||||
|
||||
public static function clean_name($id) {
|
||||
$id = CrayonUtil::hyphen_to_space( strtolower(trim($id)) );
|
||||
return CrayonUtil::ucwords($id);
|
||||
}
|
||||
public static function clean_name($id)
|
||||
{
|
||||
$id = CrayonUtil::hyphen_to_space(strtolower(trim($id)));
|
||||
return CrayonUtil::ucwords($id);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class CrayonUsedResource extends CrayonResource {
|
||||
class CrayonUsedResource extends CrayonResource
|
||||
{
|
||||
// Keeps track of usage
|
||||
private $used = FALSE;
|
||||
private $used = FALSE;
|
||||
|
||||
function used($used = NULL) {
|
||||
if ($used === NULL) {
|
||||
return $this->used;
|
||||
} else {
|
||||
$this->used = ($used ? TRUE : FALSE);
|
||||
}
|
||||
}
|
||||
function used($used = NULL)
|
||||
{
|
||||
if ($used === NULL) {
|
||||
return $this->used;
|
||||
} else {
|
||||
$this->used = ($used ? TRUE : FALSE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class CrayonUserResource extends CrayonUsedResource {
|
||||
class CrayonUserResource extends CrayonUsedResource
|
||||
{
|
||||
// Keeps track of user modifications
|
||||
private $user = FALSE;
|
||||
|
||||
function user($user = NULL) {
|
||||
function user($user = NULL)
|
||||
{
|
||||
if ($user === NULL) {
|
||||
return $this->user;
|
||||
} else {
|
||||
@ -457,22 +519,23 @@ class CrayonUserResource extends CrayonUsedResource {
|
||||
}
|
||||
}
|
||||
|
||||
class CrayonVersionResource extends CrayonUserResource {
|
||||
class CrayonVersionResource extends CrayonUserResource
|
||||
{
|
||||
// Adds version
|
||||
private $version = '';
|
||||
private $version = '';
|
||||
|
||||
function __construct($id, $name = NULL, $version = NULL) {
|
||||
parent::__construct($id, $name);
|
||||
$this->version($version);
|
||||
}
|
||||
function __construct($id, $name = NULL, $version = NULL)
|
||||
{
|
||||
parent::__construct($id, $name);
|
||||
$this->version($version);
|
||||
}
|
||||
|
||||
function version($version = NULL) {
|
||||
if ($version === NULL) {
|
||||
return $this->version;
|
||||
} else if (is_string($version)) {
|
||||
$this->version = $version;
|
||||
}
|
||||
}
|
||||
function version($version = NULL)
|
||||
{
|
||||
if ($version === NULL) {
|
||||
return $this->version;
|
||||
} else if (is_string($version)) {
|
||||
$this->version = $version;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
@ -7,7 +7,8 @@ require_once(CRAYON_THEMES_PHP);
|
||||
* Stores CrayonSetting objects.
|
||||
* Each Crayon instance stores an instance of this class containing its specific settings.
|
||||
*/
|
||||
class CrayonSettings {
|
||||
class CrayonSettings
|
||||
{
|
||||
// Properties and Constants ===============================================
|
||||
const INVALID = -1; // Used for invalid dropdown index
|
||||
// Plugin data
|
||||
@ -121,7 +122,8 @@ class CrayonSettings {
|
||||
|
||||
private static $cache_array;
|
||||
|
||||
public static function get_cache_sec($cache) {
|
||||
public static function get_cache_sec($cache)
|
||||
{
|
||||
$values = array_values(self::$cache_array);
|
||||
if (array_key_exists($cache, $values)) {
|
||||
return $values[$cache];
|
||||
@ -136,11 +138,13 @@ class CrayonSettings {
|
||||
// The settings with default values
|
||||
private static $default = NULL;
|
||||
|
||||
function __construct() {
|
||||
function __construct()
|
||||
{
|
||||
$this->init();
|
||||
}
|
||||
|
||||
function copy() {
|
||||
function copy()
|
||||
{
|
||||
$settings = new CrayonSettings();
|
||||
foreach ($this->settings as $setting) {
|
||||
$settings->set($setting); // Overuse of set?
|
||||
@ -150,7 +154,8 @@ class CrayonSettings {
|
||||
|
||||
// Methods ================================================================
|
||||
|
||||
private function init() {
|
||||
private function init()
|
||||
{
|
||||
global $CRAYON_VERSION;
|
||||
|
||||
crayon_load_plugin_textdomain();
|
||||
@ -271,7 +276,8 @@ class CrayonSettings {
|
||||
// Getter and Setter ======================================================
|
||||
|
||||
// TODO this needs simplification
|
||||
function set($name, $value = NULL, $replace = FALSE) {
|
||||
function set($name, $value = NULL, $replace = FALSE)
|
||||
{
|
||||
// Set associative array of settings
|
||||
if (is_array($name)) {
|
||||
$keys = array_keys($name);
|
||||
@ -309,7 +315,8 @@ class CrayonSettings {
|
||||
}
|
||||
}
|
||||
|
||||
function get($name = NULL) {
|
||||
function get($name = NULL)
|
||||
{
|
||||
if ($name === NULL) {
|
||||
$copy = array();
|
||||
foreach ($this->settings as $name => $setting) {
|
||||
@ -324,7 +331,8 @@ class CrayonSettings {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
function val($name = NULL) {
|
||||
function val($name = NULL)
|
||||
{
|
||||
if (($setting = self::get($name)) != FALSE) {
|
||||
return $setting->value();
|
||||
} else {
|
||||
@ -332,7 +340,8 @@ class CrayonSettings {
|
||||
}
|
||||
}
|
||||
|
||||
function val_str($name) {
|
||||
function val_str($name)
|
||||
{
|
||||
if (($setting = self::get($name)) != FALSE) {
|
||||
$def = $setting->def();
|
||||
$index = $setting->value();
|
||||
@ -344,7 +353,8 @@ class CrayonSettings {
|
||||
}
|
||||
}
|
||||
|
||||
function get_array() {
|
||||
function get_array()
|
||||
{
|
||||
$array = array();
|
||||
foreach ($this->settings as $setting) {
|
||||
$array[$setting->name()] = $setting->value();
|
||||
@ -352,13 +362,15 @@ class CrayonSettings {
|
||||
return $array;
|
||||
}
|
||||
|
||||
function is_setting($name) {
|
||||
function is_setting($name)
|
||||
{
|
||||
return (is_string($name) && array_key_exists($name, $this->settings));
|
||||
}
|
||||
|
||||
/* Gets default settings, either as associative array of name=>value or CrayonSetting
|
||||
objects */
|
||||
public static function get_defaults($name = NULL, $objects = TRUE) {
|
||||
public static function get_defaults($name = NULL, $objects = TRUE)
|
||||
{
|
||||
if (self::$default === NULL) {
|
||||
self::$default = new CrayonSettings();
|
||||
}
|
||||
@ -386,7 +398,8 @@ class CrayonSettings {
|
||||
}
|
||||
}
|
||||
|
||||
public static function get_defaults_array() {
|
||||
public static function get_defaults_array()
|
||||
{
|
||||
return self::get_defaults(NULL, FALSE);
|
||||
}
|
||||
|
||||
@ -399,7 +412,8 @@ class CrayonSettings {
|
||||
* @param string $name
|
||||
* @param mixed $value
|
||||
*/
|
||||
public static function validate($name, $value) {
|
||||
public static function validate($name, $value)
|
||||
{
|
||||
if (!is_string($name)) {
|
||||
return '';
|
||||
}
|
||||
@ -470,7 +484,8 @@ class CrayonSettings {
|
||||
// Takes an associative array of "smart settings" and regular settings. Smart settings can be used
|
||||
// to configure regular settings quickly.
|
||||
// E.g. 'max_height="20px"' will set 'height="20"', 'height_mode="0", height_unit="0"'
|
||||
public static function smart_settings($settings) {
|
||||
public static function smart_settings($settings)
|
||||
{
|
||||
if (!is_array($settings)) {
|
||||
return FALSE;
|
||||
}
|
||||
@ -524,7 +539,8 @@ class CrayonSettings {
|
||||
}
|
||||
|
||||
// Used for height and width smart settings, I couldn't bear to copy paste code twice...
|
||||
private static function smart_hw($name, $set, $mode, $unit, &$settings) {
|
||||
private static function smart_hw($name, $set, $mode, $unit, &$settings)
|
||||
{
|
||||
if (!is_string($name) || !is_string($set) || !is_string($mode) || !is_string($unit) || !is_array($settings)) {
|
||||
return;
|
||||
}
|
||||
@ -557,7 +573,8 @@ class CrayonSettings {
|
||||
* These settings can be overriden by individual Crayons.
|
||||
* Also manages global site settings and paths.
|
||||
*/
|
||||
class CrayonGlobalSettings {
|
||||
class CrayonGlobalSettings
|
||||
{
|
||||
// The global settings stored as a CrayonSettings object.
|
||||
private static $global = NULL;
|
||||
/* These are used to load local files reliably and prevent scripts like PHP from executing
|
||||
@ -572,50 +589,60 @@ class CrayonGlobalSettings {
|
||||
private static $upload_url = '';
|
||||
private static $mkdir = NULL;
|
||||
|
||||
private function __construct() {
|
||||
private function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
private static function init() {
|
||||
private static function init()
|
||||
{
|
||||
if (self::$global === NULL) {
|
||||
self::$global = new CrayonSettings();
|
||||
}
|
||||
}
|
||||
|
||||
public static function get($name = NULL) {
|
||||
public static function get($name = NULL)
|
||||
{
|
||||
self::init();
|
||||
return self::$global->get($name);
|
||||
}
|
||||
|
||||
public static function get_array() {
|
||||
public static function get_array()
|
||||
{
|
||||
self::init();
|
||||
return self::$global->get_array();
|
||||
}
|
||||
|
||||
public static function get_obj() {
|
||||
public static function get_obj()
|
||||
{
|
||||
self::init();
|
||||
return self::$global->copy();
|
||||
}
|
||||
|
||||
public static function val($name = NULL) {
|
||||
public static function val($name = NULL)
|
||||
{
|
||||
self::init();
|
||||
return self::$global->val($name);
|
||||
}
|
||||
|
||||
public static function val_str($name = NULL) {
|
||||
public static function val_str($name = NULL)
|
||||
{
|
||||
self::init();
|
||||
return self::$global->val_str($name);
|
||||
}
|
||||
|
||||
public static function has_changed($input, $setting, $value) {
|
||||
public static function has_changed($input, $setting, $value)
|
||||
{
|
||||
return $input == $setting && $value != CrayonGlobalSettings::val($setting);
|
||||
}
|
||||
|
||||
public static function set($name, $value = NULL, $replace = FALSE) {
|
||||
public static function set($name, $value = NULL, $replace = FALSE)
|
||||
{
|
||||
self::init();
|
||||
self::$global->set($name, $value, $replace);
|
||||
}
|
||||
|
||||
public static function site_url($site_http = NULL) {
|
||||
public static function site_url($site_http = NULL)
|
||||
{
|
||||
if ($site_http === NULL) {
|
||||
return self::$site_http;
|
||||
} else {
|
||||
@ -623,7 +650,8 @@ class CrayonGlobalSettings {
|
||||
}
|
||||
}
|
||||
|
||||
public static function site_path($site_path = NULL) {
|
||||
public static function site_path($site_path = NULL)
|
||||
{
|
||||
if ($site_path === NULL) {
|
||||
return self::$site_path;
|
||||
} else {
|
||||
@ -631,7 +659,8 @@ class CrayonGlobalSettings {
|
||||
}
|
||||
}
|
||||
|
||||
public static function plugin_path($plugin_path = NULL) {
|
||||
public static function plugin_path($plugin_path = NULL)
|
||||
{
|
||||
if ($plugin_path === NULL) {
|
||||
return self::$plugin_path;
|
||||
} else {
|
||||
@ -639,7 +668,8 @@ class CrayonGlobalSettings {
|
||||
}
|
||||
}
|
||||
|
||||
public static function upload_path($upload_path = NULL) {
|
||||
public static function upload_path($upload_path = NULL)
|
||||
{
|
||||
if ($upload_path === NULL) {
|
||||
return self::$upload_path;
|
||||
} else {
|
||||
@ -647,7 +677,8 @@ class CrayonGlobalSettings {
|
||||
}
|
||||
}
|
||||
|
||||
public static function upload_url($upload_url = NULL) {
|
||||
public static function upload_url($upload_url = NULL)
|
||||
{
|
||||
if ($upload_url === NULL) {
|
||||
return self::$upload_url;
|
||||
} else {
|
||||
@ -655,7 +686,8 @@ class CrayonGlobalSettings {
|
||||
}
|
||||
}
|
||||
|
||||
public static function set_mkdir($mkdir = NULL) {
|
||||
public static function set_mkdir($mkdir = NULL)
|
||||
{
|
||||
if ($mkdir === NULL) {
|
||||
return self::$mkdir;
|
||||
} else {
|
||||
@ -663,7 +695,8 @@ class CrayonGlobalSettings {
|
||||
}
|
||||
}
|
||||
|
||||
public static function mkdir($dir = NULL) {
|
||||
public static function mkdir($dir = NULL)
|
||||
{
|
||||
if (self::$mkdir) {
|
||||
call_user_func(self::$mkdir, $dir);
|
||||
} else {
|
||||
@ -678,14 +711,17 @@ $INT = new CrayonValidator('#\d+#');
|
||||
/**
|
||||
* Validation class.
|
||||
*/
|
||||
class CrayonValidator {
|
||||
class CrayonValidator
|
||||
{
|
||||
private $pattern = '#*#msi';
|
||||
|
||||
public function __construct($pattern) {
|
||||
public function __construct($pattern)
|
||||
{
|
||||
$this->pattern($pattern);
|
||||
}
|
||||
|
||||
public function pattern($pattern) {
|
||||
public function pattern($pattern)
|
||||
{
|
||||
if ($pattern === NULL) {
|
||||
return $pattern;
|
||||
} else {
|
||||
@ -693,11 +729,13 @@ class CrayonValidator {
|
||||
}
|
||||
}
|
||||
|
||||
public function validate($str) {
|
||||
public function validate($str)
|
||||
{
|
||||
return preg_match($this->pattern, $str) !== FALSE;
|
||||
}
|
||||
|
||||
public function sanitize($str) {
|
||||
public function sanitize($str)
|
||||
{
|
||||
preg_match_all($this->pattern, $str, $matches);
|
||||
$result = '';
|
||||
foreach ($matches as $match) {
|
||||
@ -707,14 +745,18 @@ class CrayonValidator {
|
||||
}
|
||||
}
|
||||
|
||||
class CrayonNonNegIntValidator extends CrayonValidator {
|
||||
public function __construct() {
|
||||
class CrayonNonNegIntValidator extends CrayonValidator
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct('#\d+#');
|
||||
}
|
||||
}
|
||||
|
||||
class CrayonIntValidator extends CrayonValidator {
|
||||
public function __construct() {
|
||||
class CrayonIntValidator extends CrayonValidator
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct('#-?\d+#');
|
||||
}
|
||||
}
|
||||
@ -723,7 +765,8 @@ class CrayonIntValidator extends CrayonValidator {
|
||||
* Individual setting.
|
||||
* Can store boolean, string, dropdown (with array of strings), etc.
|
||||
*/
|
||||
class CrayonSetting {
|
||||
class CrayonSetting
|
||||
{
|
||||
private $name = '';
|
||||
/* The type of variables that can be set as the value.
|
||||
* For dropdown settings, value is int, even though value() will return a string. */
|
||||
@ -738,7 +781,8 @@ class CrayonSetting {
|
||||
private $validator = NULL;
|
||||
|
||||
|
||||
public function __construct($name, $default = '', $value = NULL, $locked = NULL) {
|
||||
public function __construct($name, $default = '', $value = NULL, $locked = NULL)
|
||||
{
|
||||
$this->name($name);
|
||||
if ($default !== NULL) {
|
||||
$this->def($default); // Perform first to set type
|
||||
@ -751,29 +795,35 @@ class CrayonSetting {
|
||||
}
|
||||
}
|
||||
|
||||
function __tostring() {
|
||||
function __tostring()
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
function copy() {
|
||||
function copy()
|
||||
{
|
||||
return new CrayonSetting($this->name, $this->default, $this->value, $this->locked);
|
||||
}
|
||||
|
||||
function name($name = NULL) {
|
||||
function name($name = NULL)
|
||||
{
|
||||
if (!CrayonUtil::str($this->name, $name)) {
|
||||
return $this->name;
|
||||
}
|
||||
}
|
||||
|
||||
function type() {
|
||||
function type()
|
||||
{
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
function is_array() {
|
||||
function is_array()
|
||||
{
|
||||
return $this->is_array;
|
||||
}
|
||||
|
||||
function locked($locked = NULL) {
|
||||
function locked($locked = NULL)
|
||||
{
|
||||
if ($locked === NULL) {
|
||||
return $this->locked;
|
||||
} else {
|
||||
@ -788,7 +838,8 @@ class CrayonSetting {
|
||||
* value() returns string value at current index for dropdown settings.
|
||||
* @param $value
|
||||
*/
|
||||
function value($value = NULL) {
|
||||
function value($value = NULL)
|
||||
{
|
||||
if ($value === NULL) {
|
||||
/*if ($this->is_array) {
|
||||
return $this->default[$this->value]; // value at index
|
||||
@ -812,7 +863,8 @@ class CrayonSetting {
|
||||
}
|
||||
}
|
||||
|
||||
function array_value() {
|
||||
function array_value()
|
||||
{
|
||||
if ($this->is_array) {
|
||||
return NULL;
|
||||
}
|
||||
@ -824,7 +876,8 @@ class CrayonSetting {
|
||||
* For dropdown settings, default value is array of all possible value strings.
|
||||
* @param $default
|
||||
*/
|
||||
function def($default = NULL) {
|
||||
function def($default = NULL)
|
||||
{
|
||||
// Only allow default to be set once
|
||||
|
||||
if ($this->type === NULL && $default !== NULL) {
|
||||
@ -864,7 +917,8 @@ class CrayonSetting {
|
||||
* @param int|string $index
|
||||
* @return FALSE if not dropdown setting
|
||||
*/
|
||||
function index($index = NULL) {
|
||||
function index($index = NULL)
|
||||
{
|
||||
if (!$this->is_array) {
|
||||
return FALSE;
|
||||
} else if ($index === NULL) {
|
||||
@ -885,7 +939,8 @@ class CrayonSetting {
|
||||
/**
|
||||
* Finds the index of a string in an array setting
|
||||
*/
|
||||
function find_index($str) {
|
||||
function find_index($str)
|
||||
{
|
||||
if (!$this->is_array || is_string($str)) {
|
||||
return FALSE;
|
||||
}
|
||||
@ -897,7 +952,8 @@ class CrayonSetting {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
function validator($validator) {
|
||||
function validator($validator)
|
||||
{
|
||||
if ($validator === NULL) {
|
||||
return $this->validator;
|
||||
} else {
|
||||
@ -905,7 +961,8 @@ class CrayonSetting {
|
||||
}
|
||||
}
|
||||
|
||||
function sanitize($str) {
|
||||
function sanitize($str)
|
||||
{
|
||||
if ($this->validator != NULL) {
|
||||
return $this->validator->sanitize($str);
|
||||
} else {
|
||||
@ -914,5 +971,3 @@ class CrayonSetting {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
@ -9,7 +9,8 @@ require_once(CRAYON_SETTINGS_PHP);
|
||||
CrayonHighlighter and any non-WP classes will only use CrayonSettings to separate
|
||||
the implementation of global settings and ensure any system can use them. */
|
||||
|
||||
class CrayonSettingsWP {
|
||||
class CrayonSettingsWP
|
||||
{
|
||||
// Properties and Constants ===============================================
|
||||
|
||||
// A copy of the current options in db
|
||||
@ -45,12 +46,14 @@ class CrayonSettingsWP {
|
||||
const SAMPLE_CODE = 'sample-code';
|
||||
const CACHE_CLEAR = 'crayon-cache-clear';
|
||||
|
||||
private function __construct() {
|
||||
private function __construct()
|
||||
{
|
||||
}
|
||||
|
||||
// Methods ================================================================
|
||||
|
||||
public static function admin_load() {
|
||||
public static function admin_load()
|
||||
{
|
||||
self::$admin_page = $admin_page = add_options_page('Crayon Syntax Highlighter ' . crayon__('Settings'), 'Crayon', 'manage_options', 'crayon_settings', 'CrayonSettingsWP::settings');
|
||||
add_action("admin_print_scripts-$admin_page", 'CrayonSettingsWP::admin_scripts');
|
||||
add_action("admin_print_styles-$admin_page", 'CrayonSettingsWP::admin_styles');
|
||||
@ -73,7 +76,8 @@ class CrayonSettingsWP {
|
||||
}
|
||||
}
|
||||
|
||||
public static function admin_styles() {
|
||||
public static function admin_styles()
|
||||
{
|
||||
global $CRAYON_VERSION;
|
||||
if (CRAYON_MINIFY) {
|
||||
wp_enqueue_style('crayon', plugins_url(CRAYON_STYLE_MIN, __FILE__), array('editor-buttons'), $CRAYON_VERSION);
|
||||
@ -84,7 +88,8 @@ class CrayonSettingsWP {
|
||||
}
|
||||
}
|
||||
|
||||
public static function admin_scripts() {
|
||||
public static function admin_scripts()
|
||||
{
|
||||
global $CRAYON_VERSION;
|
||||
|
||||
if (CRAYON_MINIFY) {
|
||||
@ -102,7 +107,8 @@ class CrayonSettingsWP {
|
||||
}
|
||||
}
|
||||
|
||||
public static function other_scripts() {
|
||||
public static function other_scripts()
|
||||
{
|
||||
global $CRAYON_VERSION;
|
||||
self::load_settings(TRUE);
|
||||
$deps = array('jquery', 'crayon_util_js');
|
||||
@ -114,7 +120,8 @@ class CrayonSettingsWP {
|
||||
wp_enqueue_script('crayon_js', plugins_url(CRAYON_JS, __FILE__), $deps, $CRAYON_VERSION);
|
||||
}
|
||||
|
||||
public static function init_js_settings() {
|
||||
public static function init_js_settings()
|
||||
{
|
||||
// This stores JS variables used in AJAX calls and in the JS files
|
||||
global $CRAYON_VERSION;
|
||||
self::load_settings(TRUE);
|
||||
@ -147,7 +154,8 @@ class CrayonSettingsWP {
|
||||
}
|
||||
}
|
||||
|
||||
public static function init_admin_js_settings() {
|
||||
public static function init_admin_js_settings()
|
||||
{
|
||||
if (!self::$admin_js_settings) {
|
||||
// We need to load themes at this stage
|
||||
CrayonSettingsWP::load_settings();
|
||||
@ -189,7 +197,8 @@ class CrayonSettingsWP {
|
||||
}
|
||||
}
|
||||
|
||||
public static function settings() {
|
||||
public static function settings()
|
||||
{
|
||||
if (!current_user_can('manage_options')) {
|
||||
wp_die(crayon__('You do not have sufficient permissions to access this page.'));
|
||||
}
|
||||
@ -238,11 +247,12 @@ class CrayonSettingsWP {
|
||||
|
||||
<div id="crayon-theme-editor-wrap" class="wrap"></div>
|
||||
|
||||
<?php
|
||||
<?php
|
||||
}
|
||||
|
||||
// Load the global settings and update them from the db
|
||||
public static function load_settings($just_load_settings = FALSE) {
|
||||
public static function load_settings($just_load_settings = FALSE)
|
||||
{
|
||||
if (self::$options === NULL) {
|
||||
// Load settings from db
|
||||
if (!(self::$options = get_option(self::OPTIONS))) {
|
||||
@ -291,12 +301,14 @@ class CrayonSettingsWP {
|
||||
}
|
||||
}
|
||||
|
||||
public static function get_settings() {
|
||||
public static function get_settings()
|
||||
{
|
||||
return get_option(self::OPTIONS);
|
||||
}
|
||||
|
||||
// Saves settings from CrayonGlobalSettings, or provided array, to the db
|
||||
public static function save_settings($settings = NULL) {
|
||||
public static function save_settings($settings = NULL)
|
||||
{
|
||||
if ($settings === NULL) {
|
||||
$settings = CrayonGlobalSettings::get_array();
|
||||
}
|
||||
@ -308,7 +320,8 @@ class CrayonSettingsWP {
|
||||
/**
|
||||
* This loads the posts marked as containing Crayons
|
||||
*/
|
||||
public static function load_posts() {
|
||||
public static function load_posts()
|
||||
{
|
||||
if (self::$crayon_posts === NULL) {
|
||||
// Load from db
|
||||
if (!(self::$crayon_posts = get_option(self::POSTS))) {
|
||||
@ -330,7 +343,8 @@ class CrayonSettingsWP {
|
||||
/**
|
||||
* Saves the marked posts to the db
|
||||
*/
|
||||
public static function save_posts($posts = NULL) {
|
||||
public static function save_posts($posts = NULL)
|
||||
{
|
||||
if ($posts === NULL) {
|
||||
$posts = self::$crayon_posts;
|
||||
}
|
||||
@ -341,7 +355,8 @@ class CrayonSettingsWP {
|
||||
/**
|
||||
* Adds a post as containing a Crayon
|
||||
*/
|
||||
public static function add_post($id, $save = TRUE) {
|
||||
public static function add_post($id, $save = TRUE)
|
||||
{
|
||||
self::load_posts();
|
||||
if (!in_array($id, self::$crayon_posts)) {
|
||||
self::$crayon_posts[] = $id;
|
||||
@ -354,7 +369,8 @@ class CrayonSettingsWP {
|
||||
/**
|
||||
* Removes a post as not containing a Crayon
|
||||
*/
|
||||
public static function remove_post($id, $save = TRUE) {
|
||||
public static function remove_post($id, $save = TRUE)
|
||||
{
|
||||
self::load_posts();
|
||||
$key = array_search($id, self::$crayon_posts);
|
||||
if ($key === false) {
|
||||
@ -366,7 +382,8 @@ class CrayonSettingsWP {
|
||||
}
|
||||
}
|
||||
|
||||
public static function remove_posts() {
|
||||
public static function remove_posts()
|
||||
{
|
||||
self::$crayon_posts = array();
|
||||
self::save_posts();
|
||||
}
|
||||
@ -376,7 +393,8 @@ class CrayonSettingsWP {
|
||||
/**
|
||||
* This loads the posts marked as containing Crayons
|
||||
*/
|
||||
public static function load_legacy_posts($force = FALSE) {
|
||||
public static function load_legacy_posts($force = FALSE)
|
||||
{
|
||||
if (self::$crayon_legacy_posts === NULL || $force) {
|
||||
// Load from db
|
||||
if (!(self::$crayon_legacy_posts = get_option(self::LEGACY_POSTS))) {
|
||||
@ -398,7 +416,8 @@ class CrayonSettingsWP {
|
||||
/**
|
||||
* Saves the marked posts to the db
|
||||
*/
|
||||
public static function save_legacy_posts($posts = NULL) {
|
||||
public static function save_legacy_posts($posts = NULL)
|
||||
{
|
||||
if ($posts === NULL) {
|
||||
$posts = self::$crayon_legacy_posts;
|
||||
}
|
||||
@ -409,7 +428,8 @@ class CrayonSettingsWP {
|
||||
/**
|
||||
* Adds a post as containing a Crayon
|
||||
*/
|
||||
public static function add_legacy_post($id, $save = TRUE) {
|
||||
public static function add_legacy_post($id, $save = TRUE)
|
||||
{
|
||||
self::load_legacy_posts();
|
||||
if (!in_array($id, self::$crayon_legacy_posts)) {
|
||||
self::$crayon_legacy_posts[] = $id;
|
||||
@ -422,7 +442,8 @@ class CrayonSettingsWP {
|
||||
/**
|
||||
* Removes a post as not containing a Crayon
|
||||
*/
|
||||
public static function remove_legacy_post($id, $save = TRUE) {
|
||||
public static function remove_legacy_post($id, $save = TRUE)
|
||||
{
|
||||
self::load_legacy_posts();
|
||||
$key = array_search($id, self::$crayon_legacy_posts);
|
||||
if ($key === false) {
|
||||
@ -434,14 +455,16 @@ class CrayonSettingsWP {
|
||||
}
|
||||
}
|
||||
|
||||
public static function remove_legacy_posts() {
|
||||
public static function remove_legacy_posts()
|
||||
{
|
||||
self::$crayon_legacy_posts = array();
|
||||
self::save_legacy_posts();
|
||||
}
|
||||
|
||||
// Cache
|
||||
|
||||
public static function add_cache($name) {
|
||||
public static function add_cache($name)
|
||||
{
|
||||
self::load_cache();
|
||||
if (!in_array($name, self::$cache)) {
|
||||
self::$cache[] = $name;
|
||||
@ -449,7 +472,8 @@ class CrayonSettingsWP {
|
||||
self::save_cache();
|
||||
}
|
||||
|
||||
public static function remove_cache($name) {
|
||||
public static function remove_cache($name)
|
||||
{
|
||||
self::load_cache();
|
||||
$key = array_search($name, self::$cache);
|
||||
if ($key === false) {
|
||||
@ -459,7 +483,8 @@ class CrayonSettingsWP {
|
||||
self::save_cache();
|
||||
}
|
||||
|
||||
public static function clear_cache() {
|
||||
public static function clear_cache()
|
||||
{
|
||||
self::load_cache();
|
||||
foreach (self::$cache as $name) {
|
||||
delete_transient($name);
|
||||
@ -468,7 +493,8 @@ class CrayonSettingsWP {
|
||||
self::save_cache();
|
||||
}
|
||||
|
||||
public static function load_cache() {
|
||||
public static function load_cache()
|
||||
{
|
||||
// Load cache from db
|
||||
if (!(self::$cache = get_option(self::CACHE))) {
|
||||
self::$cache = array();
|
||||
@ -476,14 +502,16 @@ class CrayonSettingsWP {
|
||||
}
|
||||
}
|
||||
|
||||
public static function save_cache() {
|
||||
public static function save_cache()
|
||||
{
|
||||
update_option(self::CACHE, self::$cache);
|
||||
self::load_cache();
|
||||
}
|
||||
|
||||
// Paths
|
||||
|
||||
public static function admin_init() {
|
||||
public static function admin_init()
|
||||
{
|
||||
// Load default settings if they don't exist
|
||||
self::load_settings();
|
||||
|
||||
@ -518,19 +546,22 @@ class CrayonSettingsWP {
|
||||
|
||||
// Wrapper functions
|
||||
|
||||
private static function add_section($name, $title, $callback = NULL) {
|
||||
private static function add_section($name, $title, $callback = NULL)
|
||||
{
|
||||
$callback = (empty($callback) ? 'blank' : $callback);
|
||||
add_settings_section($name, $title, 'CrayonSettingsWP::' . $callback, self::SETTINGS);
|
||||
}
|
||||
|
||||
private static function add_field($section, $title, $callback, $args = array()) {
|
||||
private static function add_field($section, $title, $callback, $args = array())
|
||||
{
|
||||
$unique = preg_replace('#\\s#', '_', strtolower($title));
|
||||
add_settings_field($unique, $title, 'CrayonSettingsWP::' . $callback, self::SETTINGS, $section, $args);
|
||||
}
|
||||
|
||||
// Validates all the settings passed from the form in $inputs
|
||||
|
||||
public static function settings_validate($inputs) {
|
||||
public static function settings_validate($inputs)
|
||||
{
|
||||
|
||||
// Load current settings from db
|
||||
self::load_settings(TRUE);
|
||||
@ -630,12 +661,14 @@ class CrayonSettingsWP {
|
||||
|
||||
// Section callback functions
|
||||
|
||||
public static function blank() {
|
||||
public static function blank()
|
||||
{
|
||||
} // Used for required callbacks with blank content
|
||||
|
||||
// Input Drawing ==========================================================
|
||||
|
||||
private static function input($args) {
|
||||
private static function input($args)
|
||||
{
|
||||
$id = '';
|
||||
$size = 40;
|
||||
$margin = FALSE;
|
||||
@ -648,7 +681,8 @@ class CrayonSettingsWP {
|
||||
self::$options[$id], '" style="margin-left: ', ($margin ? '20px' : '0px'), ';" crayon-preview="', ($preview ? 1 : 0), '" />', ($break ? CRAYON_BR : '');
|
||||
}
|
||||
|
||||
private static function checkbox($args, $line_break = TRUE, $preview = TRUE) {
|
||||
private static function checkbox($args, $line_break = TRUE, $preview = TRUE)
|
||||
{
|
||||
if (empty($args) || !is_array($args) || count($args) != 2) {
|
||||
return;
|
||||
}
|
||||
@ -661,7 +695,8 @@ class CrayonSettingsWP {
|
||||
}
|
||||
|
||||
// Draws a dropdown by loading the default value (an array) from a setting
|
||||
private static function dropdown($id, $line_break = TRUE, $preview = TRUE, $echo = TRUE, $resources = NULL, $selected = NULL) {
|
||||
private static function dropdown($id, $line_break = TRUE, $preview = TRUE, $echo = TRUE, $resources = NULL, $selected = NULL)
|
||||
{
|
||||
if (!array_key_exists($id, self::$options)) {
|
||||
return;
|
||||
}
|
||||
@ -686,7 +721,8 @@ class CrayonSettingsWP {
|
||||
}
|
||||
}
|
||||
|
||||
private static function button($args = array()) {
|
||||
private static function button($args = array())
|
||||
{
|
||||
extract($args);
|
||||
CrayonUtil::set_var($id, '');
|
||||
CrayonUtil::set_var($class, '');
|
||||
@ -695,26 +731,27 @@ class CrayonSettingsWP {
|
||||
return '<a id="' . $id . '" class="button-primary ' . $class . '" onclick="' . $onclick . '">' . $title . '</a>';
|
||||
}
|
||||
|
||||
private static function info_span($name, $text) {
|
||||
private static function info_span($name, $text)
|
||||
{
|
||||
echo '<span id="', $name, '-info">', $text, '</span>';
|
||||
}
|
||||
|
||||
private static function span($text) {
|
||||
private static function span($text)
|
||||
{
|
||||
echo '<span>', $text, '</span>';
|
||||
}
|
||||
|
||||
// General Fields =========================================================
|
||||
public static function help() {
|
||||
public static function help()
|
||||
{
|
||||
global $CRAYON_WEBSITE, $CRAYON_TWITTER, $CRAYON_GIT, $CRAYON_PLUGIN_WP, $CRAYON_DONATE;
|
||||
if (CrayonGlobalSettings::val(CrayonSettings::HIDE_HELP)) {
|
||||
return;
|
||||
}
|
||||
echo '<div id="crayon-help" class="updated settings-error crayon-help">
|
||||
<p><strong>Howdy, coder!</strong> Thanks for using Crayon. <strong>Useful Links:</strong> <a href="' . $CRAYON_WEBSITE . '" target="_blank">Documentation</a>, <a href="' . $CRAYON_GIT . '" target="_blank">GitHub</a>, <a href="' . $CRAYON_PLUGIN_WP . '" target="_blank">Plugin Page</a>, <a href="' . $CRAYON_TWITTER . '" target="_blank">Twitter</a>. Crayon has always been free. If you value my work please consider a <a href="' . $CRAYON_DONATE . '">small donation</a> to show your appreciation. Thanks! <a class="crayon-help-close">X</a></p></div>
|
||||
';
|
||||
}
|
||||
|
||||
public static function help_screen() {
|
||||
public static function help_screen()
|
||||
{
|
||||
$screen = get_current_screen();
|
||||
|
||||
if ($screen->id != self::$admin_page) {
|
||||
@ -722,7 +759,8 @@ class CrayonSettingsWP {
|
||||
}
|
||||
}
|
||||
|
||||
public static function metrics() {
|
||||
public static function metrics()
|
||||
{
|
||||
echo '<div id="crayon-section-metrics" class="crayon-hide-inline">';
|
||||
self::checkbox(array(CrayonSettings::HEIGHT_SET, '<span class="crayon-span-50">' . crayon__('Height') . ' </span>'), FALSE);
|
||||
self::dropdown(CrayonSettings::HEIGHT_MODE, FALSE);
|
||||
@ -760,7 +798,8 @@ class CrayonSettingsWP {
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
public static function toolbar() {
|
||||
public static function toolbar()
|
||||
{
|
||||
echo '<div id="crayon-section-toolbar" class="crayon-hide-inline">';
|
||||
self::span(crayon__('Display the Toolbar') . ' ');
|
||||
self::dropdown(CrayonSettings::TOOLBAR);
|
||||
@ -775,7 +814,8 @@ class CrayonSettingsWP {
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
public static function lines() {
|
||||
public static function lines()
|
||||
{
|
||||
echo '<div id="crayon-section-lines" class="crayon-hide-inline">';
|
||||
self::checkbox(array(CrayonSettings::STRIPED, crayon__('Display striped code lines')));
|
||||
self::checkbox(array(CrayonSettings::MARKING, crayon__('Enable line marking for important lines')));
|
||||
@ -789,7 +829,8 @@ class CrayonSettingsWP {
|
||||
echo '</div>';
|
||||
}
|
||||
|
||||
public static function langs() {
|
||||
public static function langs()
|
||||
{
|
||||
echo '<a name="langs"></a>';
|
||||
// Specialised dropdown for languages
|
||||
if (array_key_exists(CrayonSettings::FALLBACK_LANG, self::$options)) {
|
||||
@ -818,7 +859,8 @@ class CrayonSettingsWP {
|
||||
}
|
||||
}
|
||||
|
||||
public static function show_langs() {
|
||||
public static function show_langs()
|
||||
{
|
||||
CrayonSettingsWP::load_settings();
|
||||
require_once(CRAYON_PARSER_PHP);
|
||||
if (($langs = CrayonParser::parse_all()) != FALSE) {
|
||||
@ -846,7 +888,8 @@ class CrayonSettingsWP {
|
||||
exit();
|
||||
}
|
||||
|
||||
public static function posts() {
|
||||
public static function posts()
|
||||
{
|
||||
echo '<a name="posts"></a>';
|
||||
echo self::button(array('id' => 'show-posts', 'title' => crayon__('Show Crayon Posts')));
|
||||
echo ' <input type="submit" name="', self::OPTIONS, '[refresh_tags]" id="refresh_tags" class="button-primary" value="', crayon__('Refresh'), '" />';
|
||||
@ -854,7 +897,8 @@ class CrayonSettingsWP {
|
||||
echo '<div id="crayon-subsection-posts-info"></div>';
|
||||
}
|
||||
|
||||
public static function post_cmp($a, $b) {
|
||||
public static function post_cmp($a, $b)
|
||||
{
|
||||
$a = $a->post_modified;
|
||||
$b = $b->post_modified;
|
||||
if ($a == $b) {
|
||||
@ -864,7 +908,8 @@ class CrayonSettingsWP {
|
||||
}
|
||||
}
|
||||
|
||||
public static function show_posts() {
|
||||
public static function show_posts()
|
||||
{
|
||||
CrayonSettingsWP::load_settings();
|
||||
$postIDs = self::load_posts();
|
||||
$legacy_posts = self::load_legacy_posts();
|
||||
@ -903,7 +948,8 @@ class CrayonSettingsWP {
|
||||
exit();
|
||||
}
|
||||
|
||||
public static function show_preview() {
|
||||
public static function show_preview()
|
||||
{
|
||||
echo '<div id="content">';
|
||||
|
||||
self::load_settings(); // Run first to ensure global settings loaded
|
||||
@ -970,7 +1016,8 @@ class Human {
|
||||
exit();
|
||||
}
|
||||
|
||||
public static function theme($editor = FALSE) {
|
||||
public static function theme($editor = FALSE)
|
||||
{
|
||||
$db_theme = self::$options[CrayonSettings::THEME]; // Theme name from db
|
||||
if (!array_key_exists(CrayonSettings::THEME, self::$options)) {
|
||||
$db_theme = '';
|
||||
@ -1022,7 +1069,8 @@ class Human {
|
||||
}
|
||||
}
|
||||
|
||||
public static function font($editor = FALSE) {
|
||||
public static function font($editor = FALSE)
|
||||
{
|
||||
$db_font = self::$options[CrayonSettings::FONT]; // Theme name from db
|
||||
if (!array_key_exists(CrayonSettings::FONT, self::$options)) {
|
||||
$db_font = '';
|
||||
@ -1049,7 +1097,8 @@ class Human {
|
||||
self::checkbox(array(CrayonSettings::ENQUEUE_FONTS, crayon__('Enqueue fonts in the header (more efficient).') . self::help_button('http://aramk.com/blog/2012/01/07/enqueuing-themes-and-fonts-in-crayon/')));
|
||||
}
|
||||
|
||||
public static function code($editor = FALSE) {
|
||||
public static function code($editor = FALSE)
|
||||
{
|
||||
echo '<div id="crayon-section-code-interaction" class="crayon-hide-inline-only">';
|
||||
self::checkbox(array(CrayonSettings::PLAIN, crayon__('Enable plain code view and display') . ' '), FALSE);
|
||||
self::dropdown(CrayonSettings::SHOW_PLAIN);
|
||||
@ -1085,7 +1134,8 @@ class Human {
|
||||
self::input(array('id' => CrayonSettings::WHITESPACE_AFTER, 'size' => 2, 'break' => TRUE));
|
||||
}
|
||||
|
||||
public static function tags() {
|
||||
public static function tags()
|
||||
{
|
||||
self::checkbox(array(CrayonSettings::INLINE_TAG, crayon__('Capture Inline Tags') . self::help_button('http://aramk.com/blog/2012/03/07/inline-crayons/')));
|
||||
self::checkbox(array(CrayonSettings::INLINE_WRAP, crayon__('Wrap Inline Tags') . self::help_button('http://aramk.com/blog/2012/03/07/inline-crayons/')));
|
||||
self::checkbox(array(CrayonSettings::CODE_TAG_CAPTURE, crayon__('Capture <code> as')), FALSE);
|
||||
@ -1101,7 +1151,8 @@ class Human {
|
||||
self::checkbox(array(CrayonSettings::PLAIN_TAG, crayon__('Enable [plain][/plain] tag.') . self::help_button('http://aramk.com/blog/2011/12/27/mini-tags-in-crayon/')));
|
||||
}
|
||||
|
||||
public static function files() {
|
||||
public static function files()
|
||||
{
|
||||
echo '<a name="files"></a>';
|
||||
echo crayon__('When loading local files and a relative path is given for the URL, use the absolute path'), ': ',
|
||||
'<div style="margin-left: 20px">', home_url(), '/';
|
||||
@ -1109,7 +1160,8 @@ class Human {
|
||||
echo '</div>', crayon__('Followed by your relative URL.');
|
||||
}
|
||||
|
||||
public static function tag_editor() {
|
||||
public static function tag_editor()
|
||||
{
|
||||
$can_convert = self::load_legacy_posts();
|
||||
if ($can_convert) {
|
||||
$disabled = '';
|
||||
@ -1135,7 +1187,8 @@ class Human {
|
||||
self::input(array('id' => CrayonSettings::TAG_EDITOR_QUICKTAG_BUTTON_TEXT, 'break' => TRUE));
|
||||
}
|
||||
|
||||
public static function misc() {
|
||||
public static function misc()
|
||||
{
|
||||
echo crayon__('Clear the cache used to store remote code requests'), ': ';
|
||||
self::dropdown(CrayonSettings::CACHE, false);
|
||||
echo '<input type="submit" id="', self::CACHE_CLEAR, '" name="', self::CACHE_CLEAR, '" class="button-secondary" value="', crayon__('Clear Now'), '" /><br/>';
|
||||
@ -1155,14 +1208,16 @@ class Human {
|
||||
|
||||
// Debug Fields ===========================================================
|
||||
|
||||
public static function errors() {
|
||||
public static function errors()
|
||||
{
|
||||
self::checkbox(array(CrayonSettings::ERROR_LOG, crayon__('Log errors for individual Crayons')));
|
||||
self::checkbox(array(CrayonSettings::ERROR_LOG_SYS, crayon__('Log system-wide errors')));
|
||||
self::checkbox(array(CrayonSettings::ERROR_MSG_SHOW, crayon__('Display custom message for errors')));
|
||||
self::input(array('id' => CrayonSettings::ERROR_MSG, 'size' => 60, 'margin' => TRUE));
|
||||
}
|
||||
|
||||
public static function log() {
|
||||
public static function log()
|
||||
{
|
||||
$log = CrayonLog::log();
|
||||
touch(CRAYON_LOG_FILE);
|
||||
$exists = file_exists(CRAYON_LOG_FILE);
|
||||
@ -1188,7 +1243,8 @@ class Human {
|
||||
|
||||
// About Fields ===========================================================
|
||||
|
||||
public static function info() {
|
||||
public static function info()
|
||||
{
|
||||
global $CRAYON_VERSION, $CRAYON_DATE, $CRAYON_AUTHOR, $CRAYON_WEBSITE, $CRAYON_TWITTER, $CRAYON_GIT, $CRAYON_PLUGIN_WP, $CRAYON_AUTHOR_SITE, $CRAYON_EMAIL, $CRAYON_DONATE;
|
||||
echo '<a name="info"></a>';
|
||||
$version = '<strong>' . crayon__('Version') . ':</strong> ' . $CRAYON_VERSION;
|
||||
@ -1224,10 +1280,7 @@ class Human {
|
||||
<a id="git-icon" class="small-icon" title="GitHub" href="' . $CRAYON_GIT . '" target="_blank"></a>
|
||||
<a id="wp-icon" class="small-icon" title="Plugin Page" href="' . $CRAYON_PLUGIN_WP . '" target="_blank"></a>
|
||||
<a id="twitter-icon" class="small-icon" title="Twitter" href="' . $CRAYON_TWITTER . '" target="_blank"></a>
|
||||
<a id="gmail-icon" class="small-icon" title="Email" href="mailto:' . $CRAYON_EMAIL . '" target="_blank"></a>
|
||||
<div id="crayon-donate"><a href="' . $CRAYON_DONATE . '" title="Donate" target="_blank">
|
||||
<img src="' . plugins_url(CRAYON_DONATE_BUTTON, __FILE__) . '"></a>
|
||||
</div>';
|
||||
<a id="gmail-icon" class="small-icon" title="Email" href="mailto:' . $CRAYON_EMAIL . '" target="_blank"></a>';
|
||||
|
||||
echo '
|
||||
<table id="crayon-info" border="0">
|
||||
@ -1244,14 +1297,15 @@ class Human {
|
||||
<td colspan="2">' . $links . '</td>
|
||||
</tr>
|
||||
</table>';
|
||||
|
||||
}
|
||||
|
||||
public static function help_button($link) {
|
||||
public static function help_button($link)
|
||||
{
|
||||
return ' <a href="' . $link . '" target="_blank" class="crayon-question">' . crayon__('?') . '</a>';
|
||||
}
|
||||
|
||||
public static function plugin_row_meta($meta, $file) {
|
||||
public static function plugin_row_meta($meta, $file)
|
||||
{
|
||||
global $CRAYON_DONATE;
|
||||
if ($file == CrayonWP::basename()) {
|
||||
$meta[] = '<a href="options-general.php?page=crayon_settings">' . crayon__('Settings') . '</a>';
|
||||
@ -1269,5 +1323,3 @@ if (defined('ABSPATH') && is_admin()) {
|
||||
add_action('admin_menu', 'CrayonSettingsWP::admin_load');
|
||||
add_filter('plugin_row_meta', 'CrayonSettingsWP::plugin_row_meta', 10, 2);
|
||||
}
|
||||
|
||||
?>
|
||||
|
@ -41,5 +41,3 @@ class CrayonThemes extends CrayonUserResourceCollection {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
@ -3,7 +3,7 @@
|
||||
Plugin Name: Crayon Syntax Highlighter
|
||||
Plugin URI: https://github.com/aramk/crayon-syntax-highlighter
|
||||
Description: Supports multiple languages, themes, highlighting from a URL, local file or post text.
|
||||
Version: 2.8.4
|
||||
Version: 2.8.6
|
||||
Author: Aram Kocharyan
|
||||
Author URI: http://aramk.com/
|
||||
Text Domain: crayon-syntax-highlighter
|
||||
@ -1336,5 +1336,3 @@ if (defined('ABSPATH')) {
|
||||
}
|
||||
add_filter('init', 'CrayonWP::init_ajax');
|
||||
}
|
||||
|
||||
?>
|
||||
|
199
global.php
199
global.php
@ -1,35 +1,35 @@
|
||||
<?php
|
||||
|
||||
// Switches
|
||||
define('CRAYON_DEBUG', FALSE);
|
||||
const CRAYON_DEBUG = FALSE;
|
||||
|
||||
define('CRAYON_TAG_EDITOR', TRUE);
|
||||
define('CRAYON_THEME_EDITOR', TRUE);
|
||||
const CRAYON_TAG_EDITOR = TRUE;
|
||||
const CRAYON_THEME_EDITOR = TRUE;
|
||||
|
||||
define('CRAYON_MINIFY', TRUE);
|
||||
const CRAYON_MINIFY = TRUE;
|
||||
|
||||
// Constants
|
||||
|
||||
// General definitions
|
||||
define('CRAYON_DOMAIN', 'crayon-syntax-highlighter');
|
||||
const CRAYON_DOMAIN = 'crayon-syntax-highlighter';
|
||||
|
||||
// These are overridden by functions since v1.1.1
|
||||
$CRAYON_VERSION = '1.1.1';
|
||||
$CRAYON_DATE = '27th September, 2011';
|
||||
$CRAYON_VERSION = '2.8.6';
|
||||
$CRAYON_DATE = '29th November, 2021';
|
||||
$CRAYON_AUTHOR = 'Aram Kocharyan';
|
||||
$CRAYON_AUTHOR_SITE = 'http://aramk.com';
|
||||
$CRAYON_DONATE = 'http://bit.ly/crayondonate';
|
||||
$CRAYON_AUTHOR_SITE = 'https://aramk.com';
|
||||
$CRAYON_DONATE = 'https://bit.ly/crayondonate';
|
||||
$CRAYON_WEBSITE = 'https://github.com/aramk/crayon-syntax-highlighter';
|
||||
$CRAYON_EMAIL = 'crayon.syntax@gmail.com';
|
||||
$CRAYON_TWITTER = 'http://twitter.com/crayonsyntax';
|
||||
$CRAYON_GIT = 'http://github.com/aramk/crayon-syntax-highlighter';
|
||||
$CRAYON_TWITTER = 'https://twitter.com/crayonsyntax';
|
||||
$CRAYON_GIT = 'https://git.icod.de/dalu/crayon-syntax-highlighter';
|
||||
$CRAYON_PLUGIN_WP = 'https://wordpress.org/plugins/crayon-syntax-highlighter/';
|
||||
|
||||
// XXX Used to name the class
|
||||
|
||||
define('CRAYON_HIGHLIGHTER', 'CrayonHighlighter');
|
||||
define('CRAYON_ELEMENT_CLASS', 'CrayonElement');
|
||||
define('CRAYON_SETTING_CLASS', 'CrayonSetting');
|
||||
const CRAYON_HIGHLIGHTER = 'CrayonHighlighter';
|
||||
const CRAYON_ELEMENT_CLASS = 'CrayonElement';
|
||||
const CRAYON_SETTING_CLASS = 'CrayonSetting';
|
||||
|
||||
// Directories
|
||||
|
||||
@ -50,97 +50,98 @@ define('CRAYON_TAG_EDITOR_DIR', crayon_s('tag-editor'));
|
||||
|
||||
// Paths
|
||||
|
||||
define('CRAYON_ROOT_PATH', crayon_pf(dirname(__FILE__)));
|
||||
define('CRAYON_LANG_PATH', CRAYON_ROOT_PATH . CRAYON_LANG_DIR);
|
||||
define('CRAYON_THEME_PATH', CRAYON_ROOT_PATH . CRAYON_THEME_DIR);
|
||||
define('CRAYON_FONT_PATH', CRAYON_ROOT_PATH . CRAYON_FONT_DIR);
|
||||
define('CRAYON_UTIL_PATH', CRAYON_ROOT_PATH . CRAYON_UTIL_DIR);
|
||||
define('CRAYON_TAG_EDITOR_PATH', CRAYON_ROOT_PATH . CRAYON_UTIL_DIR . CRAYON_TAG_EDITOR_DIR);
|
||||
define('CRAYON_THEME_EDITOR_PATH', CRAYON_ROOT_PATH . CRAYON_UTIL_DIR . CRAYON_THEME_EDITOR_DIR);
|
||||
define("CRAYON_ROOT_PATH", crayon_pf(dirname(__FILE__)));
|
||||
const CRAYON_LANG_PATH = CRAYON_ROOT_PATH . CRAYON_LANG_DIR;
|
||||
const CRAYON_THEME_PATH = CRAYON_ROOT_PATH . CRAYON_THEME_DIR;
|
||||
const CRAYON_FONT_PATH = CRAYON_ROOT_PATH . CRAYON_FONT_DIR;
|
||||
const CRAYON_UTIL_PATH = CRAYON_ROOT_PATH . CRAYON_UTIL_DIR;
|
||||
const CRAYON_TAG_EDITOR_PATH = CRAYON_ROOT_PATH . CRAYON_UTIL_DIR . CRAYON_TAG_EDITOR_DIR;
|
||||
const CRAYON_THEME_EDITOR_PATH = CRAYON_ROOT_PATH . CRAYON_UTIL_DIR . CRAYON_THEME_EDITOR_DIR;
|
||||
|
||||
// Files
|
||||
|
||||
define('CRAYON_LOG_FILE', CRAYON_ROOT_PATH . 'log.txt');
|
||||
define('CRAYON_TOUCH_FILE', CRAYON_UTIL_PATH . 'touch.txt');
|
||||
define('CRAYON_LOG_MAX_SIZE', 50000); // Bytes
|
||||
const CRAYON_LOG_FILE = CRAYON_ROOT_PATH . 'log.txt';
|
||||
const CRAYON_TOUCH_FILE = CRAYON_UTIL_PATH . 'touch.txt';
|
||||
const CRAYON_LOG_MAX_SIZE = 50000; // Bytes
|
||||
|
||||
define('CRAYON_README_FILE', CRAYON_ROOT_PATH . 'readme.txt');
|
||||
define('CRAYON_LANG_EXT', CRAYON_LANG_PATH . 'extensions.txt');
|
||||
define('CRAYON_LANG_ALIAS', CRAYON_LANG_PATH . 'aliases.txt');
|
||||
define('CRAYON_LANG_DELIM', CRAYON_LANG_PATH . 'delimiters.txt');
|
||||
define('CRAYON_HELP_FILE', CRAYON_UTIL_PATH . 'help.htm');
|
||||
const CRAYON_README_FILE = CRAYON_ROOT_PATH . 'readme.txt';
|
||||
const CRAYON_LANG_EXT = CRAYON_LANG_PATH . 'extensions.txt';
|
||||
const CRAYON_LANG_ALIAS = CRAYON_LANG_PATH . 'aliases.txt';
|
||||
const CRAYON_LANG_DELIM = CRAYON_LANG_PATH . 'delimiters.txt';
|
||||
const CRAYON_HELP_FILE = CRAYON_UTIL_PATH . 'help.htm';
|
||||
|
||||
// Minified
|
||||
define('CRAYON_JS_MIN', CRAYON_JS_MIN_DIR . 'crayon.min.js');
|
||||
define('CRAYON_JS_TE_MIN', CRAYON_JS_MIN_DIR . 'crayon.te.min.js');
|
||||
const CRAYON_JS_MIN = CRAYON_JS_MIN_DIR . 'crayon.min.js';
|
||||
const CRAYON_JS_TE_MIN = CRAYON_JS_MIN_DIR . 'crayon.te.min.js';
|
||||
|
||||
// Source
|
||||
define('CRAYON_JQUERY_POPUP', CRAYON_JS_SRC_DIR . 'jquery.popup.js');
|
||||
define('CRAYON_JS', CRAYON_JS_SRC_DIR . 'crayon.js');
|
||||
define('CRAYON_JS_ADMIN', CRAYON_JS_SRC_DIR . 'crayon_admin.js');
|
||||
define('CRAYON_JS_UTIL', CRAYON_JS_SRC_DIR . 'util.js');
|
||||
define('CRAYON_CSSJSON_JS', CRAYON_JS_SRC_DIR . 'cssjson.js');
|
||||
const CRAYON_JQUERY_POPUP = CRAYON_JS_SRC_DIR . 'jquery.popup.js';
|
||||
const CRAYON_JS = CRAYON_JS_SRC_DIR . 'crayon.js';
|
||||
const CRAYON_JS_ADMIN = CRAYON_JS_SRC_DIR . 'crayon_admin.js';
|
||||
const CRAYON_JS_UTIL = CRAYON_JS_SRC_DIR . 'util.js';
|
||||
const CRAYON_CSSJSON_JS = CRAYON_JS_SRC_DIR . 'cssjson.js';
|
||||
|
||||
define('CRAYON_CSS_JQUERY_COLORPICKER', CRAYON_JS_DIR . 'jquery-colorpicker/jquery.colorpicker.css');
|
||||
define('CRAYON_JS_JQUERY_COLORPICKER', CRAYON_JS_DIR . 'jquery-colorpicker/jquery.colorpicker.js');
|
||||
define('CRAYON_JS_TINYCOLOR', CRAYON_JS_DIR . 'tinycolor-min.js');
|
||||
define('CRAYON_TAG_EDITOR_JS', 'crayon_tag_editor.js');
|
||||
define('CRAYON_COLORBOX_JS', 'colorbox/jquery.colorbox-min.js');
|
||||
define('CRAYON_COLORBOX_CSS', 'colorbox/colorbox.css');
|
||||
define('CRAYON_TAG_EDITOR_PHP', CRAYON_TAG_EDITOR_PATH . 'crayon_tag_editor_wp.class.php');
|
||||
define('CRAYON_TINYMCE_JS', 'crayon_tinymce.js');
|
||||
define('CRAYON_QUICKTAGS_JS', 'crayon_qt.js');
|
||||
define('CRAYON_STYLE', CRAYON_CSS_SRC_DIR . 'crayon_style.css');
|
||||
define('CRAYON_STYLE_ADMIN', CRAYON_CSS_SRC_DIR . 'admin_style.css');
|
||||
define('CRAYON_STYLE_GLOBAL', CRAYON_CSS_SRC_DIR . 'global_style.css');
|
||||
define('CRAYON_STYLE_MIN', CRAYON_CSS_MIN_DIR . 'crayon.min.css');
|
||||
define('CRAYON_LOGO', CRAYON_CSS_DIR . 'images/crayon_logo.png');
|
||||
define('CRAYON_DONATE_BUTTON', CRAYON_CSS_DIR . 'images/donate.png');
|
||||
define('CRAYON_THEME_EDITOR_PHP', CRAYON_THEME_EDITOR_PATH . 'theme_editor.php');
|
||||
define('CRAYON_THEME_EDITOR_JS', CRAYON_UTIL_DIR . CRAYON_THEME_EDITOR_DIR . 'theme_editor.js');
|
||||
define('CRAYON_THEME_EDITOR_STYLE', CRAYON_UTIL_DIR . CRAYON_THEME_EDITOR_DIR . 'theme_editor.css');
|
||||
define('CRAYON_THEME_EDITOR_BUTTON', CRAYON_CSS_DIR . 'images/theme_editor.png');
|
||||
const CRAYON_CSS_JQUERY_COLORPICKER = CRAYON_JS_DIR . 'jquery-colorpicker/jquery.colorpicker.css';
|
||||
const CRAYON_JS_JQUERY_COLORPICKER = CRAYON_JS_DIR . 'jquery-colorpicker/jquery.colorpicker.js';
|
||||
const CRAYON_JS_TINYCOLOR = CRAYON_JS_DIR . 'tinycolor-min.js';
|
||||
const CRAYON_TAG_EDITOR_JS = 'crayon_tag_editor.js';
|
||||
const CRAYON_COLORBOX_JS = 'colorbox/jquery.colorbox-min.js';
|
||||
const CRAYON_COLORBOX_CSS = 'colorbox/colorbox.css';
|
||||
const CRAYON_TAG_EDITOR_PHP = CRAYON_TAG_EDITOR_PATH . 'crayon_tag_editor_wp.class.php';
|
||||
const CRAYON_TINYMCE_JS = 'crayon_tinymce.js';
|
||||
const CRAYON_QUICKTAGS_JS = 'crayon_qt.js';
|
||||
const CRAYON_STYLE = CRAYON_CSS_SRC_DIR . 'crayon_style.css';
|
||||
const CRAYON_STYLE_ADMIN = CRAYON_CSS_SRC_DIR . 'admin_style.css';
|
||||
const CRAYON_STYLE_GLOBAL = CRAYON_CSS_SRC_DIR . 'global_style.css';
|
||||
const CRAYON_STYLE_MIN = CRAYON_CSS_MIN_DIR . 'crayon.min.css';
|
||||
const CRAYON_LOGO = CRAYON_CSS_DIR . 'images/crayon_logo.png';
|
||||
const CRAYON_DONATE_BUTTON = CRAYON_CSS_DIR . 'images/donate.png';
|
||||
const CRAYON_THEME_EDITOR_PHP = CRAYON_THEME_EDITOR_PATH . 'theme_editor.php';
|
||||
const CRAYON_THEME_EDITOR_JS = CRAYON_UTIL_DIR . CRAYON_THEME_EDITOR_DIR . 'theme_editor.js';
|
||||
const CRAYON_THEME_EDITOR_STYLE = CRAYON_UTIL_DIR . CRAYON_THEME_EDITOR_DIR . 'theme_editor.css';
|
||||
const CRAYON_THEME_EDITOR_BUTTON = CRAYON_CSS_DIR . 'images/theme_editor.png';
|
||||
|
||||
// PHP Files
|
||||
define('CRAYON_FORMATTER_PHP', CRAYON_ROOT_PATH . 'crayon_formatter.class.php');
|
||||
define('CRAYON_HIGHLIGHTER_PHP', CRAYON_ROOT_PATH . 'crayon_highlighter.class.php');
|
||||
define('CRAYON_LANGS_PHP', CRAYON_ROOT_PATH . 'crayon_langs.class.php');
|
||||
define('CRAYON_PARSER_PHP', CRAYON_ROOT_PATH . 'crayon_parser.class.php');
|
||||
define('CRAYON_SETTINGS_PHP', CRAYON_ROOT_PATH . 'crayon_settings.class.php');
|
||||
define('CRAYON_THEMES_PHP', CRAYON_ROOT_PATH . 'crayon_themes.class.php');
|
||||
define('CRAYON_FONTS_PHP', CRAYON_ROOT_PATH . 'crayon_fonts.class.php');
|
||||
define('CRAYON_RESOURCE_PHP', CRAYON_ROOT_PATH . 'crayon_resource.class.php');
|
||||
define('CRAYON_UTIL_PHP', CRAYON_UTIL_DIR . 'crayon_util.class.php');
|
||||
define('CRAYON_TIMER_PHP', CRAYON_UTIL_DIR . 'crayon_timer.class.php');
|
||||
define('CRAYON_LOG_PHP', CRAYON_UTIL_DIR . 'crayon_log.class.php');
|
||||
const CRAYON_FORMATTER_PHP = CRAYON_ROOT_PATH . 'crayon_formatter.class.php';
|
||||
const CRAYON_HIGHLIGHTER_PHP = CRAYON_ROOT_PATH . 'crayon_highlighter.class.php';
|
||||
const CRAYON_LANGS_PHP = CRAYON_ROOT_PATH . 'crayon_langs.class.php';
|
||||
const CRAYON_PARSER_PHP = CRAYON_ROOT_PATH . 'crayon_parser.class.php';
|
||||
const CRAYON_SETTINGS_PHP = CRAYON_ROOT_PATH . 'crayon_settings.class.php';
|
||||
const CRAYON_THEMES_PHP = CRAYON_ROOT_PATH . 'crayon_themes.class.php';
|
||||
const CRAYON_FONTS_PHP = CRAYON_ROOT_PATH . 'crayon_fonts.class.php';
|
||||
const CRAYON_RESOURCE_PHP = CRAYON_ROOT_PATH . 'crayon_resource.class.php';
|
||||
const CRAYON_UTIL_PHP = CRAYON_UTIL_DIR . 'crayon_util.class.php';
|
||||
const CRAYON_TIMER_PHP = CRAYON_UTIL_DIR . 'crayon_timer.class.php';
|
||||
const CRAYON_LOG_PHP = CRAYON_UTIL_DIR . 'crayon_log.class.php';
|
||||
|
||||
// Script time
|
||||
|
||||
define('CRAYON_LOAD_TIME', 'Load Time');
|
||||
const CRAYON_LOAD_TIME = 'Load Time';
|
||||
//define('CRAYON_PARSE_TIME', 'Parse Time');
|
||||
define('CRAYON_FORMAT_TIME', 'Format Time');
|
||||
const CRAYON_FORMAT_TIME = 'Format Time';
|
||||
|
||||
// Printing
|
||||
|
||||
define('CRAYON_BR', "<br />");
|
||||
define('CRAYON_NL', "\r\n");
|
||||
define('CRAYON_BL', CRAYON_BR . CRAYON_NL);
|
||||
define('CRAYON_DASH', "==============================================================================");
|
||||
define('CRAYON_LINE', "------------------------------------------------------------------------------");
|
||||
const CRAYON_BR = "<br />";
|
||||
const CRAYON_NL = "\r\n";
|
||||
const CRAYON_BL = CRAYON_BR . CRAYON_NL;
|
||||
const CRAYON_DASH = "==============================================================================";
|
||||
const CRAYON_LINE = "------------------------------------------------------------------------------";
|
||||
|
||||
// Load utilities
|
||||
|
||||
require_once (CRAYON_UTIL_PHP);
|
||||
require_once (CRAYON_TIMER_PHP);
|
||||
require_once (CRAYON_LOG_PHP);
|
||||
require_once(CRAYON_UTIL_PHP);
|
||||
require_once(CRAYON_TIMER_PHP);
|
||||
require_once(CRAYON_LOG_PHP);
|
||||
|
||||
// Turn on the error & exception handlers
|
||||
//crayon_handler_on();
|
||||
|
||||
// GLOBAL FUNCTIONS
|
||||
|
||||
// Check for forwardslash/backslash in folder path to structure paths
|
||||
function crayon_s($url = '') {
|
||||
// Check for forward slash/backslash in folder path to structure paths
|
||||
function crayon_s($url = '')
|
||||
{
|
||||
$url = strval($url);
|
||||
if (!empty($url) && !preg_match('#(\\\\|/)$#', $url)) {
|
||||
return $url . '/';
|
||||
@ -152,7 +153,8 @@ function crayon_s($url = '') {
|
||||
}
|
||||
|
||||
// Returns path using forward slashes, slash added at the end
|
||||
function crayon_pf($url, $slash = TRUE) {
|
||||
function crayon_pf($url, $slash = TRUE)
|
||||
{
|
||||
$url = trim(strval($url));
|
||||
if ($slash) {
|
||||
$url = crayon_s($url);
|
||||
@ -161,12 +163,14 @@ function crayon_pf($url, $slash = TRUE) {
|
||||
}
|
||||
|
||||
// Returns path using back slashes
|
||||
function crayon_pb($url) {
|
||||
function crayon_pb($url)
|
||||
{
|
||||
return str_replace('/', '\\', crayon_s(trim(strval($url))));
|
||||
}
|
||||
|
||||
// Get/Set plugin information
|
||||
function crayon_set_info($info_array) {
|
||||
function crayon_set_info($info_array)
|
||||
{
|
||||
global $CRAYON_VERSION, $CRAYON_DATE, $CRAYON_AUTHOR, $CRAYON_WEBSITE;
|
||||
if (!is_array($info_array)) {
|
||||
return;
|
||||
@ -177,45 +181,53 @@ function crayon_set_info($info_array) {
|
||||
crayon_set_info_key('PluginURI', $info_array, $CRAYON_WEBSITE);
|
||||
}
|
||||
|
||||
function crayon_set_info_key($key, $array, &$info) {
|
||||
function crayon_set_info_key($key, $array, &$info)
|
||||
{
|
||||
if (array_key_exists($key, $array)) {
|
||||
$info = $array[$key];
|
||||
return true;
|
||||
} else {
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
function crayon_vargs(&$var, $default) {
|
||||
function crayon_vargs(&$var, $default)
|
||||
{
|
||||
$var = isset($var) ? $var : $default;
|
||||
}
|
||||
|
||||
// Checks if the input is a valid PHP file and matches the $valid filename
|
||||
function crayon_is_php_file($filepath, $valid) {
|
||||
function crayon_is_php_file($filepath, $valid)
|
||||
{
|
||||
$path = pathinfo(crayon_pf($filepath));
|
||||
return is_file($filepath) && $path['extension'] === 'php' && $path['filename'] === $valid;
|
||||
}
|
||||
|
||||
// Stops the script if crayon_is_php_file() returns false or a remote path is given
|
||||
function crayon_die_if_not_php($filepath, $valid) {
|
||||
function crayon_die_if_not_php($filepath, $valid)
|
||||
{
|
||||
if (!crayon_is_php_file($filepath, $valid) || crayon_is_path_url($filepath)) {
|
||||
die("[ERROR] '$filepath' is not a valid PHP file for '$valid'");
|
||||
}
|
||||
}
|
||||
|
||||
function crayon_is_path_url($path) {
|
||||
function crayon_is_path_url($path)
|
||||
{
|
||||
$parts = parse_url($path);
|
||||
return isset($parts['scheme']) && strlen($parts['scheme']) > 1;
|
||||
}
|
||||
|
||||
// LANGUAGE TRANSLATION FUNCTIONS
|
||||
|
||||
function crayon_load_plugin_textdomain() {
|
||||
function crayon_load_plugin_textdomain()
|
||||
{
|
||||
if (function_exists('load_plugin_textdomain')) {
|
||||
load_plugin_textdomain(CRAYON_DOMAIN, false, CRAYON_DIR . CRAYON_TRANS_DIR);
|
||||
}
|
||||
}
|
||||
|
||||
function crayon__($text) {
|
||||
function crayon__($text)
|
||||
{
|
||||
if (function_exists('__')) {
|
||||
return __($text, CRAYON_DOMAIN);
|
||||
} else {
|
||||
@ -223,7 +235,8 @@ function crayon__($text) {
|
||||
}
|
||||
}
|
||||
|
||||
function crayon_e($text) {
|
||||
function crayon_e($text)
|
||||
{
|
||||
if (function_exists('_e')) {
|
||||
_e($text, CRAYON_DOMAIN);
|
||||
} else {
|
||||
@ -231,7 +244,8 @@ function crayon_e($text) {
|
||||
}
|
||||
}
|
||||
|
||||
function crayon_n($singular, $plural, $count) {
|
||||
function crayon_n($singular, $plural, $count)
|
||||
{
|
||||
if (function_exists('_n')) {
|
||||
return _n($singular, $plural, $count, CRAYON_DOMAIN);
|
||||
} else {
|
||||
@ -239,12 +253,11 @@ function crayon_n($singular, $plural, $count) {
|
||||
}
|
||||
}
|
||||
|
||||
function crayon_x($text, $context) {
|
||||
function crayon_x($text, $context)
|
||||
{
|
||||
if (function_exists('_x')) {
|
||||
return _x($text, $context, CRAYON_DOMAIN);
|
||||
} else {
|
||||
return $text;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
13
js/jquery-colorpicker/.editorconfig
Normal file
13
js/jquery-colorpicker/.editorconfig
Normal file
@ -0,0 +1,13 @@
|
||||
# https://editorconfig.org
|
||||
|
||||
root = true
|
||||
|
||||
[*]
|
||||
charset = utf-8
|
||||
indent_style = space
|
||||
end_of_line = lf
|
||||
insert_final_newline = true
|
||||
trim_trailing_whitespace = true
|
||||
|
||||
[*.js,*.json,*.html,*.css]
|
||||
indent_size = 2
|
34
js/jquery-colorpicker/.eslintrc.json
Normal file
34
js/jquery-colorpicker/.eslintrc.json
Normal file
@ -0,0 +1,34 @@
|
||||
{
|
||||
"env": {
|
||||
"browser": true,
|
||||
"es6": true
|
||||
},
|
||||
"extends": "eslint:recommended",
|
||||
"globals": {
|
||||
"Atomics": "readonly",
|
||||
"SharedArrayBuffer": "readonly"
|
||||
},
|
||||
"parserOptions": {
|
||||
"ecmaVersion": 2018
|
||||
},
|
||||
"rules": {
|
||||
"indent": [
|
||||
"error",
|
||||
2
|
||||
],
|
||||
"no-trailing-whitespace": true,
|
||||
"no-multi-space": true,
|
||||
"linebreak-style": [
|
||||
"error",
|
||||
"unix"
|
||||
],
|
||||
"quotes": [
|
||||
"error",
|
||||
"single"
|
||||
],
|
||||
"semi": [
|
||||
"error",
|
||||
"always"
|
||||
]
|
||||
}
|
||||
}
|
7
js/jquery-colorpicker/.gitignore
vendored
7
js/jquery-colorpicker/.gitignore
vendored
@ -1 +1,8 @@
|
||||
/nbproject/private/
|
||||
/nbproject/
|
||||
.svn
|
||||
.idea/*
|
||||
/debug/
|
||||
/node_modules/
|
||||
/bower_components/
|
||||
/npm-debug.log
|
7
js/jquery-colorpicker/.stylelintrc
Normal file
7
js/jquery-colorpicker/.stylelintrc
Normal file
@ -0,0 +1,7 @@
|
||||
{
|
||||
"rules": {
|
||||
"indentation": 2,
|
||||
"no-descending-specificity": null
|
||||
},
|
||||
"extends": "stylelint-config-recommended"
|
||||
}
|
81
js/jquery-colorpicker/CHANGELOG.md
Normal file
81
js/jquery-colorpicker/CHANGELOG.md
Normal file
@ -0,0 +1,81 @@
|
||||
# Change Log
|
||||
All notable changes to this project will be documented in this file.
|
||||
|
||||
The format is based on [Keep a Changelog](http://keepachangelog.com/)
|
||||
and this project adheres to [Semantic Versioning](http://semver.org/).
|
||||
|
||||
## 1.2.20 - 2019-09-01
|
||||
### Fixed
|
||||
- Merged security patches for third party components.
|
||||
|
||||
## 1.2.19 - 2019-07-11
|
||||
### Fixed
|
||||
- Merged security patches for third party components.
|
||||
|
||||
## 1.2.18 - 2019-05-13
|
||||
### Added
|
||||
- Merged PR #159 by @NicolasCARPi; Added `cancelOnExit` option in response to #158.
|
||||
|
||||
## 1.2.17 - 2018-07-15
|
||||
### Fixed
|
||||
- Merged PR #148 by @teambuktu; Input event for ui-colorpicker-number.
|
||||
|
||||
## 1.2.16 - 2018-02-19
|
||||
### Fixed
|
||||
- Merged PR #145 by @gentoo90; accept numpad keys on hex inputs.
|
||||
|
||||
## 1.2.15 - 2018-02-12
|
||||
### Fixed
|
||||
- Fix #144 by @Backslider23; memory part doesn't enable OK button correctly.
|
||||
- Fixed black initialization issue in rgbslider part.
|
||||
|
||||
## 1.2.14 - 2017-12-10
|
||||
### Added
|
||||
- PR #143 by @zaeder; `ready` event at end of widget creation.
|
||||
|
||||
## 1.2.13 - 2017-05-02
|
||||
### Fixed
|
||||
- Fix #137 by @larsinsd; Typing in hex input does not enable OK button.
|
||||
- Fix #139 by @s1738berger; Colorpicker cannot get disabled with option
|
||||
'buttonImageOnly'
|
||||
- Fix #130 by @actionpark; Return `css` and `hex` color in all events.
|
||||
|
||||
## 1.2.12 - 2017-03-29
|
||||
### Fixed
|
||||
- Fixed #136 by @mateuszf; Cannot disable animation.
|
||||
|
||||
## 1.2.11 - 2017-03-29
|
||||
### Fixed
|
||||
- Fixed #134 by @larsinsd and @justzuhri; `Ctrl+V` not working on Mac OS-X.
|
||||
|
||||
## 1.2.10 - 2017-03-29
|
||||
### Added
|
||||
- Added Copic color swatches.
|
||||
- Added Prismacolor color swatches.
|
||||
- Added DIN 6164 color swatches.
|
||||
- Added ISCC-NBS color swatches.
|
||||
|
||||
## 1.2.9 - 2017-01-21
|
||||
### Fixed
|
||||
- Implemented fix #135 by @cosmicnet; replaced `.attr()` calls with `.prop()`.
|
||||
|
||||
## 1.2.8 - 2017-01-05
|
||||
### Added
|
||||
- Polish (`pl`) translation added from PR #133 by @kniziol.
|
||||
### Changed
|
||||
- Replaced deprecated `.bind()`, `.unbind()`, `.delegate()` and `.undelegate()`
|
||||
functions by `.on()` and `.off()` for jQuery 3.0.0 compatibility.
|
||||
- Documented jQueryUI 1.12.0+ requirement for jQuery 3.0.0+.
|
||||
|
||||
## 1.2.7 - 2016-12-24
|
||||
### Added
|
||||
- Ukranian (`uk`) translation added from PR #131 by @ashep.
|
||||
|
||||
## 1.2.6 - 2016-10-28
|
||||
### Fixed
|
||||
- Allow focussing and keyboard support on the "map" and "bar" parts.
|
||||
|
||||
## 1.2.5 - 2016-10-28
|
||||
### Fixed
|
||||
- The "None" and "Transparent" radiobuttons didn't always refresh in certain
|
||||
color states.
|
21
js/jquery-colorpicker/LICENSE
Normal file
21
js/jquery-colorpicker/LICENSE
Normal file
@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2011 Martijn van der Lee
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
@ -1,231 +0,0 @@
|
||||
jQuery.colorpicker v0.9.3
|
||||
|
||||
Copyright (c) 2011-2012 Martijn W. van der Lee
|
||||
Licensed under the MIT.
|
||||
|
||||
Full-featured colorpicker for jQueryUI with full theming support.
|
||||
Most images from jPicker by Christopher T. Tillman.
|
||||
Sourcecode created from scratch by Martijn W. van der Lee.
|
||||
|
||||
IE support; make sure you have a doctype defined, or the colorpicker will not
|
||||
display correctly.
|
||||
|
||||
Options:
|
||||
alpha: false
|
||||
Whether or not to show the inputs for alpha.
|
||||
|
||||
altAlpha: true
|
||||
Change the opacity of the altField element(s) according to the alpha
|
||||
setting.
|
||||
|
||||
altField: ''
|
||||
Change the background color of the elements specified in this element.
|
||||
|
||||
altOnChange: true
|
||||
If true, the altField element(s) are updated on every change, otherwise
|
||||
only upon closing.
|
||||
|
||||
altProperties: 'background-color'
|
||||
Comma-separated list of CSS properties to set color of in the altField.
|
||||
The following properties are allowed, all others are ignored.
|
||||
background-color
|
||||
color
|
||||
border-color
|
||||
outline-color
|
||||
|
||||
autoOpen: false
|
||||
If true, the dialog opens automatically upon page load.
|
||||
|
||||
buttonColorize: false
|
||||
If a buttonimage is specified, change the background color of the
|
||||
image when the color is changed.
|
||||
|
||||
buttonImage: 'images/ui-colorpicker.png'
|
||||
Same as jQueryUI DatePicker.
|
||||
|
||||
buttonImageOnly: false
|
||||
Same as jQueryUI DatePicker.
|
||||
|
||||
buttonText: null
|
||||
Same as jQueryUI DatePicker. If null, use language default.
|
||||
|
||||
closeOnEscape: true
|
||||
Close the window when pressing the Escape key on the keyboard.
|
||||
|
||||
closeOnOutside: true
|
||||
Close the window when clicking outside the colorpicker display.
|
||||
|
||||
color: '#00FF00'
|
||||
Initial color. Formats recognized are:
|
||||
#rrggbb
|
||||
rrggbb (same as previous, but without the #)
|
||||
rgb(rrr,ggg,bbb)
|
||||
rgba(rrr,ggg,bbb,a.a)
|
||||
rgb(rrr%,ggg%,bbb%)
|
||||
rgba(rrr%,ggg%,bbb%,aaa%)
|
||||
w3c-defined color name
|
||||
|
||||
colorFormat: 'HEX'
|
||||
Specifies the format of the color string returned in callbacks.
|
||||
You can either specify one of the predefined formats:
|
||||
#HEX #112233
|
||||
#HEX3 #123 if possible, otherwise false.
|
||||
HEX 112233
|
||||
HEX3 123 if possible, otherwise false.
|
||||
RGB rgb(123,45,67) if opaque, otherwise false.
|
||||
RGBA rgba(123,45,67,0.123%)
|
||||
RGB% rgb(12%,34%,56%) if opaque, otherwise false.
|
||||
RGBA% rgba(12%,34%,56%,0.123%)
|
||||
HSL hsl(123,45,67) if opaque, otherwise false.
|
||||
HSLA hsla(123,45,67,0.123%)
|
||||
HSL% hsl(12%,34%,56%) if opaque, otherwise false.
|
||||
HSLA% hsla(12%,34%,56%,0.123%)
|
||||
NAME Closest color name
|
||||
EXACT Exact name if possible, otherwise false.
|
||||
or specify your own format...
|
||||
Each color channel is specified as a pair of two characters.
|
||||
The first character determines the color channel:
|
||||
a Alpha
|
||||
r, g, b RGB color space; red, green and blue
|
||||
h, s, v HSV color space; hue, saturation and value
|
||||
c, m, y, k CMYK color space; cyan, magenta, yellow and black
|
||||
L, A, B LAB color space; Luminosity, *A and *B.
|
||||
The second character specifies the data type:
|
||||
x Two-digit hexadecimal notation.
|
||||
d Decimal (0-255) notation.
|
||||
f Floating point (0-1) notation, not rounded.
|
||||
p Percentage (0-100) notation, not rounded.
|
||||
If you prefix a valid pair with a backslash, it won't be replaced.
|
||||
All patterns are case sensitive.
|
||||
For example, to create the common hex color format, use "#rxgxbx".
|
||||
For an rgba() format, use "rgba(rd,gd,bd,af)"
|
||||
|
||||
You can also specify an array of formats where the first non-FALSE one
|
||||
is returned. Note that the only formats able to return FALSE are the
|
||||
predefined formats HEX3 and EXACT. For example, this array will output
|
||||
HEX3 format if possible or HEX format otherwise:
|
||||
['HEX3', 'HEX']
|
||||
|
||||
dragggable: true
|
||||
Make the dialog draggable if the header is visible and the dialog is
|
||||
not inline.
|
||||
|
||||
duration: 'fast'
|
||||
Same as jQueryUI DatePicker.
|
||||
|
||||
hsv: true
|
||||
Whether or not to show the inputs for HSV.
|
||||
|
||||
layout: { ... }
|
||||
Set the position of elements in a table layout.
|
||||
You could create any layout possible with HTML tables by specifying
|
||||
cell position and size of each part.
|
||||
@todo document how this works.
|
||||
|
||||
limit: ''
|
||||
Limit the selectable colors to any of the predefined limits:
|
||||
'' No limitations, allow 8bpp color for a palette of
|
||||
all 16 million colors.
|
||||
'websafe' Set of 216 colors composed of 00, 33, 66, 99, cc
|
||||
and ff color channel values in #rrggbb.
|
||||
'nibble' 4 bits per color, can be easily converted to #rgb
|
||||
format.
|
||||
The palette is limited to 4096 colors.
|
||||
'binary' Allow only #00 or #ff as color channel values for
|
||||
primary colors only; only 8 colors are available
|
||||
with this limit.
|
||||
'name' Limit to closest color name.
|
||||
|
||||
modal:
|
||||
Ensures no other controls on screen can be used while the dialog is
|
||||
opened.
|
||||
Also look at showCancelButton and closeOnEscape to use in combination
|
||||
with the modal option. closeOnOutside is redundant when used with modal.
|
||||
|
||||
mode: 'h'
|
||||
Determines the functionality of the map and bar components. Allowed
|
||||
values are; 'h', 's', 'l', 'r', 'g', 'b' or 'a', for hue, saturation,
|
||||
luminosity, red, green, blue and alpha respectively.
|
||||
|
||||
parts: ''
|
||||
Determine which parts to display.
|
||||
Use any of the preset names ('full', 'popup' or 'inline') or specify
|
||||
an array of part names (i.e. ['header', 'map', 'bar', 'hex', 'hsv',
|
||||
'rgb', 'alpha', 'lab', 'cmyk', 'preview', 'swatches', 'footer']).
|
||||
If an empty string is given, the parts will be automatically chosen as
|
||||
preset 'popup' or 'inline' depending on the context in which the
|
||||
colorpicker is used.
|
||||
|
||||
rgb: true, // Show RGB controls and modes
|
||||
Whether or not to show the inputs for RGB.
|
||||
|
||||
regional: '',
|
||||
Sets the language to use. Note that you must load the appropriate
|
||||
language file from the i18n directory. '' is included by default.
|
||||
|
||||
showAnim: 'fadeIn'
|
||||
Same as jQueryUI DatePicker.
|
||||
|
||||
showCancelButton: true
|
||||
Show the Cancel button if buttonpane is visible.
|
||||
|
||||
showCloseButton: true
|
||||
Show the Close button if the header is visible.
|
||||
If the dialog is inline, the close button is never shown.
|
||||
|
||||
showNoneButton: false
|
||||
Show the None/Revert button if buttonpane is visible.
|
||||
|
||||
showOn: 'focus'
|
||||
Same as jQueryUI DatePicker.
|
||||
|
||||
showOptions: {}
|
||||
Same as jQueryUI DatePicker.
|
||||
|
||||
swatches: null
|
||||
'null' to show swatches of HTML colors or provide your own object
|
||||
with colornames and {r:1, g:1, b:1} array.
|
||||
For example { 'red': {r:1, g:0, b:0}, 'blue': {r:0, g:0, b:1} }
|
||||
|
||||
title: null
|
||||
Title to display in the header. If null, use language default.
|
||||
|
||||
Events:
|
||||
init: null
|
||||
Triggered on initially setting the color. Called only once.
|
||||
Callbacks recieve same data as select event.
|
||||
|
||||
close: null
|
||||
Triggered when the popup is closed.
|
||||
Callbacks recieve same data as select event and an additional number
|
||||
of fields containing the current color in all supported color spaces.
|
||||
These are rgb{}, hsv{}, cmyk{}, lab{}, hsl{} and a.
|
||||
Most values are floating point numbers in range [0,1] for accuracy.
|
||||
The a and b values in the lab color space have range [-1,1].
|
||||
|
||||
select: null
|
||||
Triggered on each change, confirmation (click on OK button) and
|
||||
cancellation (click on Cancel, outside window or window close button)
|
||||
respectively.
|
||||
|
||||
The event recieves a jQuery event object and a data object containing
|
||||
the elements 'formatted' (with the color formatted according to
|
||||
formatColor).
|
||||
|
||||
Note that select may be triggered in rapid succession when dragging
|
||||
the mouse accross the map or bar and may be triggered without a change
|
||||
in color upon specific user interactions.
|
||||
|
||||
Methods:
|
||||
open
|
||||
Open the dialog
|
||||
|
||||
close
|
||||
Close the dialog
|
||||
|
||||
destroy
|
||||
Destroy the widget
|
||||
|
||||
setColor
|
||||
Set the current color to the specified color. Accepts any
|
||||
CSS-confirmant color specification.
|
539
js/jquery-colorpicker/README.md
Normal file
539
js/jquery-colorpicker/README.md
Normal file
@ -0,0 +1,539 @@
|
||||
<p align="center"><img src="images/logotype-a.png"></p>
|
||||
|
||||
<p align="center">A full-featured colorpicker for jQueryUI with full theming support.</p>
|
||||
|
||||
[](https://badge.fury.io/js/vanderlee-colorpicker)
|
||||
[](https://choosealicense.com/licenses/mit/)
|
||||
|
||||
Copyright © 2011-2019 Martijn W. van der Lee.
|
||||
|
||||
Most images from jPicker by Christopher T. Tillman.
|
||||
Sourcecode created from scratch by Martijn W. van der Lee.
|
||||
|
||||
Features
|
||||
--------
|
||||
- jQueryUI (themeroller-based) look & feel
|
||||
- Familiar interface layout
|
||||
- Highly configurable
|
||||
- Control parts
|
||||
- Layout
|
||||
- Input/output formats
|
||||
- Swatches
|
||||
- Many more
|
||||
- Accurate color model
|
||||
- Supports localization
|
||||
- English, Dutch, French, etc.
|
||||
- Easily translatable (https://www.transifex.com/projects/p/jquery-colorpicker/)
|
||||
- Smart window alignment
|
||||
- Complete API with events and methods
|
||||
- Easily extendable with plugins
|
||||
- Many examples included: RGB-Sliders with CSS gradients, Per-user cookie
|
||||
memory for colors.
|
||||
- Documented
|
||||
- Limited Unit tests (QUnit-based)
|
||||
- Disable/enable
|
||||
- Keyboard support
|
||||
|
||||
Requirements
|
||||
------------
|
||||
jQuery 1.7.1 or higher required (will not work with v1.6 or before).
|
||||
|
||||
jQueryUI 1.8.0 or higher required.
|
||||
|
||||
For jQuery 3.0.0 or higher, you must use jQueryUI 1.12.0 or higher.
|
||||
|
||||
IE support; make sure you have a doctype defined, or the colorpicker will not
|
||||
display correctly.
|
||||
|
||||
Installation
|
||||
------------
|
||||
|
||||
With **npm**: `npm install vanderlee-colorpicker`
|
||||
|
||||
With **yarn**: `yarn add vanderlee-colorpicker`
|
||||
|
||||
With **bower** (deprecated): `bower install colorpicker`
|
||||
|
||||
Zip archive: https://github.com/vanderlee/colorpicker/archive/master.zip
|
||||
|
||||
jQueryUI custom build
|
||||
---------------------
|
||||
If you download a custom build of jQueryUI, you need these components:
|
||||
|
||||
* Dialog (includes Core, Widget, Mouse, Position, Draggable and Resizable)
|
||||
* Fade Effect (only if you use the `showAnim` option, includes Effects Core)
|
||||
|
||||
To use the `parts/jquery.ui.colorpicker-rgbslider.js` plugin, you must add:
|
||||
|
||||
* Slider (includes Core, Widget and Mouse)
|
||||
|
||||
To use the demo page included in the documentation, you must add:
|
||||
|
||||
* Tabs (includes Core and Widget)
|
||||
|
||||
Browser support
|
||||
---------------
|
||||
Tested various versions of this plugin with the following browsers:
|
||||
|
||||
- Chrome 31-54
|
||||
- FireFox 25-48
|
||||
- Opera 17-39
|
||||
- Internet Explorer 10-11
|
||||
- Edge 20-25
|
||||
|
||||
Keyboard support
|
||||
----------------
|
||||
You can use the arrow keys to move the cursors on the map and bar controls.
|
||||
Steps are measures in on-screen pixels.
|
||||
|
||||
Holding the `shift` key while using the arrow keys takes steps 10x larger.
|
||||
Pressing the `page down` and `page up` keys does the same for vertical movement.
|
||||
|
||||
Holding the `ctrl` key while using the arrow keys takes you to the edges.
|
||||
Pressing the `home` and `end` keys does the same for vertical movement.
|
||||
|
||||
Documentation
|
||||
=============
|
||||
`.colorpicker(options)`
|
||||
--------------------
|
||||
Turns an element into a colorpicker.
|
||||
|
||||
Options
|
||||
-------
|
||||
### alpha (false)
|
||||
Whether or not to show the inputs for alpha.
|
||||
|
||||
### altAlpha (true)
|
||||
Change the opacity of the altField element(s) according to the alpha setting.
|
||||
|
||||
### altField ('')
|
||||
Change the background color of the elements specified in this element.
|
||||
|
||||
### altOnChange (true)
|
||||
If true, the altField element(s) are updated on every change, otherwise
|
||||
only upon closing.
|
||||
|
||||
### altProperties (background-color)
|
||||
Comma-separated list of CSS properties to set color of in the altField.
|
||||
The following properties are allowed, all others are ignored.
|
||||
|
||||
* ``background-color``
|
||||
* ``border-color``
|
||||
* ``color``
|
||||
* ``fill``
|
||||
* ``outline-color``
|
||||
* ``stroke``
|
||||
|
||||
### autoOpen (false)
|
||||
If true, the dialog opens automatically upon page load.
|
||||
|
||||
### buttonClass (null)
|
||||
If this option is set to a string, the button will be assigned the
|
||||
class specified.
|
||||
|
||||
### buttonColorize (false)
|
||||
If a `buttonImage` is specified, change the background color of the
|
||||
image when the color is changed.
|
||||
|
||||
### buttonImage ('images/ui-colorpicker.png')
|
||||
Same as jQueryUI DatePicker.
|
||||
|
||||
### buttonImageOnly (false)
|
||||
Same as jQueryUI DatePicker.
|
||||
|
||||
### buttonText (null)
|
||||
Same as jQueryUI DatePicker. If null, use language default.
|
||||
|
||||
### cancelOnExit (false)
|
||||
If true, the value is reverted to the original one on exit.
|
||||
|
||||
### closeOnEscape (true)
|
||||
Close the window when pressing the Escape key on the keyboard.
|
||||
|
||||
### closeOnOutside (true)
|
||||
Close the window when clicking outside the colorpicker display.
|
||||
|
||||
### color ('#00FF00')
|
||||
Initial color. Formats recognized are:
|
||||
|
||||
* #rrggbb
|
||||
* rrggbb (same as previous, but without the #)
|
||||
* rgb(rrr,ggg,bbb)
|
||||
* rgba(rrr,ggg,bbb,a.a)
|
||||
* rgb(rrr%,ggg%,bbb%)
|
||||
* rgba(rrr%,ggg%,bbb%,aaa%)
|
||||
* w3c-defined color name
|
||||
|
||||
### colorFormat ('HEX')
|
||||
Specifies the format of the color string returned in callbacks.
|
||||
You can either specify one of the predefined formats:
|
||||
|
||||
* ``#HEX`` #112233 (#RRGGBB)
|
||||
* ``#HEX3`` #123 (#RGB) if possible, otherwise false.
|
||||
* ``HEX`` 112233 (RRGGBB)
|
||||
* ``HEX3`` 123 (RGB) if possible, otherwise false.
|
||||
* ``#HEXA`` #11223344 (#RRGGBBAA)
|
||||
* ``#HEXA4`` #1234 (#RGBA) if possible, otherwise false.
|
||||
* ``HEXA`` 11223344 (RRGGBBAA)
|
||||
* ``HEXA4 `` 1234 (RGBA) if possible, otherwise false.
|
||||
* ``RGB`` rgb(123,45,67) if opaque, otherwise false.
|
||||
* ``RGBA`` rgba(123,45,67,0.123%)
|
||||
* ``RGB%`` rgb(12%,34%,56%) if opaque, otherwise false.
|
||||
* ``RGBA%`` rgba(12%,34%,56%,0.123%)
|
||||
* ``HSL`` hsl(123,45,67) if opaque, otherwise false.
|
||||
* ``HSLA`` hsla(123,45,67,0.123%)
|
||||
* ``HSL%`` hsl(12%,34%,56%) if opaque, otherwise false.
|
||||
* ``HSLA%`` hsla(12%,34%,56%,0.123%)
|
||||
* ``NAME`` Closest color name
|
||||
* ``EXACT`` Exact name if possible, otherwise false.
|
||||
|
||||
or specify your own format...
|
||||
Each color channel is specified as a pair of two characters.
|
||||
The first character determines the color channel:
|
||||
|
||||
* ``a`` Alpha
|
||||
* ``r, g, b`` RGB color space; red, green and blue
|
||||
* ``h, s, v`` HSV color space; hue, saturation and value
|
||||
* ``c, m, y, k`` CMYK color space; cyan, magenta, yellow and black
|
||||
* ``L, A, B`` LAB color space; Luminosity, *A and *B.
|
||||
|
||||
The second character specifies the data type:
|
||||
|
||||
* ``x`` Two-digit hexadecimal notation.
|
||||
* ``d`` Decimal (0-255) notation.
|
||||
* ``f`` Floating point (0-1) notation, not rounded.
|
||||
* ``p`` Percentage (0-100) notation, not rounded.
|
||||
|
||||
If you prefix a valid pair with a backslash, it won't be replaced.
|
||||
All patterns are case sensitive.
|
||||
For example, to create the common hex color format, use "#rxgxbx".
|
||||
For an rgba() format, use "rgba(rd,gd,bd,af)"
|
||||
|
||||
You can also specify an array of formats where the first non-FALSE one
|
||||
is returned. Note that the only formats able to return FALSE are the
|
||||
predefined formats HEX3 and EXACT. For example, this array will output
|
||||
HEX3 format if possible or HEX format otherwise:
|
||||
|
||||
* ``['HEX3', 'HEX']``
|
||||
|
||||
### disabled (false)
|
||||
Disable or enable the colorpicker and all it's controls by setting this option.
|
||||
|
||||
If you disable the `input` using the `disabled` HTML attribute before attaching
|
||||
a colorpicker, it will automatically be disabled.
|
||||
|
||||
You can change this option using the `option` method call.
|
||||
|
||||
### draggable (true)
|
||||
Make the dialog draggable if the header is visible and the dialog is
|
||||
not inline.
|
||||
|
||||
### containment (null)
|
||||
If the dialog is draggable, constrains dragging to within the bounds of the
|
||||
specified element or region. Same as jQueryUI Draggable.
|
||||
|
||||
### duration ('fast')
|
||||
Same as jQueryUI DatePicker.
|
||||
|
||||
### hideOn ('button')
|
||||
Specifies what user events will hide the colorpicker if not inline.
|
||||
Specify multiple events by separating with space.
|
||||
|
||||
* ``focus`` When the element goes out of focus (either tab or click)
|
||||
* ``click`` When the element is clicked (for non-inputs)
|
||||
* ``alt`` When clicking on an element specified with as altField
|
||||
* ``button`` When clicking on the button created if this event is specified.
|
||||
* ``all`` selects all possible triggers
|
||||
* ``both`` same as ``all`` (deprecated, kept backwards compatibility)
|
||||
|
||||
### hsv (true)
|
||||
Whether or not to show the inputs for HSV.
|
||||
|
||||
### inline (true)
|
||||
If set to false, attaching to a non-input will still make the dialog
|
||||
a popup instead of inline. Make sure you handle events to catch the
|
||||
color change, otherwise you can't use the color.
|
||||
|
||||
### inlineFrame (true)
|
||||
If enabled, shows a border and background when inline. Disabling may
|
||||
allow closer integration.
|
||||
|
||||
### layout ({ ... })
|
||||
Set the position of elements in a table layout.
|
||||
You could create any layout possible with HTML tables by specifying
|
||||
cell position and size of each part.
|
||||
|
||||
The layout option takes a map (object) with each property name matching one of
|
||||
the available parts (including any possible custom or plugin parts). The value
|
||||
is a an array with four coordinates on order `[`left`, `top`, `width`,
|
||||
`height`]`.
|
||||
|
||||
The coordinates correspond to cells in a table, so if you want to have a part
|
||||
at top-left and spanning two rows and three columns, the value would be
|
||||
`[0, 0, 3, 2]`.
|
||||
|
||||
Care should be taken to ensure no parts overlap (best to just draw out a grid
|
||||
on paper first). Behavior is undefined if parts overlap. You need not cover
|
||||
the entire rectangular area; any empty cells will be simply remain empty.
|
||||
|
||||
The default layout is as follows:
|
||||
|
||||
{
|
||||
map: [0, 0, 1, 5],
|
||||
bar: [1, 0, 1, 5],
|
||||
preview: [2, 0, 1, 1],
|
||||
hsv: [2, 1, 1, 1],
|
||||
rgb: [2, 2, 1, 1],
|
||||
alpha: [2, 3, 1, 1],
|
||||
hex: [2, 4, 1, 1],
|
||||
lab: [3, 1, 1, 1],
|
||||
cmyk: [3, 2, 1, 2],
|
||||
swatches: [4, 0, 1, 5]
|
||||
}
|
||||
|
||||
### limit ('')
|
||||
Limit the selectable colors to any of the predefined limits:
|
||||
|
||||
* ``''`` No limitations, allow 8bpp color for a palette of all 16 million
|
||||
colors.
|
||||
* ``websafe`` Set of 216 colors composed of 00, 33, 66, 99, cc and ff color
|
||||
channel values in #rrggbb.
|
||||
* ``nibble`` 4 bits per color, can be easily converted to #rgb format. The
|
||||
palette is limited to 4096 colors.
|
||||
* ``binary`` Allow only #00 or #ff as color channel values for primary colors
|
||||
only; only 8 colors are available with this limit.
|
||||
* ``name`` Limit to closest color name.
|
||||
|
||||
### modal (false)
|
||||
Ensures no other controls on screen can be used while the dialog is
|
||||
opened.
|
||||
Also look at showCancelButton and closeOnEscape to use in combination
|
||||
with the modal option. closeOnOutside is redundant when used with modal.
|
||||
|
||||
### mode ('h')
|
||||
Determines the functionality of the map and bar components. Allowed
|
||||
values are; 'h', 's', 'l', 'r', 'g', 'b' or 'a', for hue, saturation,
|
||||
luminosity, red, green, blue and alpha respectively.
|
||||
|
||||
### okOnEnter (false)
|
||||
Close the window when pressing the Enter key on the keyboard, keeping the
|
||||
selected color.
|
||||
|
||||
### part
|
||||
Use the part option to specify options specific to parts (including plugin
|
||||
parts). By default, the following part options are available:
|
||||
|
||||
### parts ('')
|
||||
Determine which parts to display.
|
||||
Use any of the preset names ('full', 'popup' or 'inline') or specify an array
|
||||
of part names (i.e. ['header', 'map', 'bar', 'hex', 'hsv',
|
||||
'rgb', 'alpha', 'lab', 'cmyk', 'preview', 'swatches', 'footer']).
|
||||
If an empty string is given, the parts will be automatically chosen as
|
||||
preset 'popup' or 'inline' depending on the context in which the
|
||||
colorpicker is used.
|
||||
|
||||
### position (null)
|
||||
Specify the position of the dialog as a jQueryUI position object.
|
||||
See [jQueryUI .position() API documentation](http://api.jqueryui.com/position/)
|
||||
for information on how to use.
|
||||
ColorPicker adds an additional option to the `of` option; the value `'element'`
|
||||
will refer to the element to which the ColorPicker is attached, including if it
|
||||
is invisible).
|
||||
By default, the dialog will attached to the bottom-left of the element, flipping
|
||||
on collision.
|
||||
|
||||
### regional ('')
|
||||
Sets the language to use. Note that you must load the appropriate language file
|
||||
from the i18n directory. '' is included by default.
|
||||
|
||||
### revert (false)
|
||||
If enabled, closing the dialog through any means but the OK button will revert
|
||||
the color back to the previous state, as if pressing the Cancel button.
|
||||
The revert option changes the behavior of the [X] button in the header, the
|
||||
Escape keyboard button and clicking outside the dialog, when any of these
|
||||
features are enabled.
|
||||
|
||||
### rgb (true)
|
||||
Whether or not to show the inputs for RGB.
|
||||
|
||||
### showAnim ('fadeIn')
|
||||
Same as jQueryUI DatePicker.
|
||||
|
||||
### showCancelButton (true)
|
||||
Show the Cancel button if buttonpane is visible.
|
||||
|
||||
### showCloseButton (true)
|
||||
Show the Close button if the header is visible.
|
||||
If the dialog is inline, the close button is never shown.
|
||||
|
||||
### showNoneButton (false)
|
||||
Show the None/Revert button if buttonpane is visible.
|
||||
|
||||
### showOn ('focus click alt')
|
||||
Specifies what user events will show the colorpicker if not inline.
|
||||
Specify multiple events by separating with space.
|
||||
|
||||
* ``focus`` When the element comes into focus (either tab or click)
|
||||
* ``click`` When the element is clicked (for non-inputs)
|
||||
* ``alt`` When clicking on an element specified with as altField
|
||||
* ``button`` When clicking on the button created if this event is specified.
|
||||
* ``all`` selects all possible triggers
|
||||
* ``both`` same as ``all`` (deprecated, kept backwards compatibility)
|
||||
|
||||
### showOptions ({})
|
||||
Same as jQueryUI DatePicker.
|
||||
|
||||
### swatches (null)
|
||||
'null' to show swatches of HTML colors or provide your own object
|
||||
with colornames and {r:1, g:1, b:1} array.
|
||||
For example { 'red': {r:1, g:0, b:0}, 'blue': {r:0, g:0, b:1} }
|
||||
Alternatively, load a predefined set of swatches and specify the name.
|
||||
For example, for the pantone set, specify 'pantone'.
|
||||
|
||||
### swatchesWidth (84)
|
||||
Width of the swatches display in pixels.
|
||||
|
||||
### title (null)
|
||||
Title to display in the header. If null, use language default.
|
||||
|
||||
Events
|
||||
------
|
||||
Each event receives a jQuery `event` object and an object containing the
|
||||
elements 'formatted' (with the color formatted according to `formatColor`),
|
||||
the Colorpicker element that triggered the event and the color represented in a
|
||||
number of format:
|
||||
|
||||
* `hex: rrggbb`
|
||||
* `css: #rrggbb`
|
||||
* `a: ...`
|
||||
* `rgb: {r: ..., g: ..., b: ...}`
|
||||
* `hsv: {h: ..., s: ..., v: ...}`
|
||||
* `cmyk: {c: ..., m: ..., y: ..., k: ...}`
|
||||
* `hsl: {h: ..., s: ..., l: ...}`
|
||||
* `lab: {l: ..., a: ..., b: ...}`
|
||||
|
||||
Note that select may be triggered in rapid succession when dragging
|
||||
the mouse across the map or bar and may be triggered without a change
|
||||
in color upon specific user interactions.
|
||||
|
||||
### cancel (event, {formatted: ..., colorPicker: ...})
|
||||
Triggered when the dialog is closed through the cancel button.
|
||||
|
||||
### close (event, {formatted: ..., colorPicker: ...})
|
||||
Triggered when the popup is closed.
|
||||
|
||||
### init (event, {formatted: ..., colorPicker: ...})
|
||||
Triggered on initially setting the color. Called only once.
|
||||
Callbacks receive same data as select event.
|
||||
|
||||
### ok (event, {formatted: ..., colorPicker: ...})
|
||||
Triggered when the dialog is closed through the cancel button.
|
||||
|
||||
### open (event, {formatted: ..., colorPicker: ...})
|
||||
Triggered whenever the dialog is opened.
|
||||
|
||||
### ready (event, {formatted: ..., colorPicker: ...})
|
||||
Triggered after creating the widget/dialog.
|
||||
|
||||
### select (event, {formatted: ..., colorPicker: ...})
|
||||
Triggered on each change, confirmation (click on OK button) and
|
||||
cancellation (click on Cancel, outside window or window close button)
|
||||
respectively.
|
||||
|
||||
### stop(event, {formatted: ..., colorPicker: ...})
|
||||
Triggered when the user stops changing a control. This only affects the map
|
||||
and bar parts. Where the `select` event will trigger on each mouse move, the
|
||||
`stop` event will only trigger when the mouse button is released. For other
|
||||
controls, `stop` and `select` are both triggered.
|
||||
|
||||
The callback is otherwise identical to `select`. When both are triggered,
|
||||
`select` is triggered before `stop`.
|
||||
|
||||
Methods
|
||||
-------
|
||||
### open
|
||||
Open the dialog
|
||||
|
||||
### close
|
||||
Close the dialog
|
||||
|
||||
### destroy
|
||||
Destroy the widget
|
||||
|
||||
### setColor
|
||||
Set the current color to the specified color. Accepts any CSS-confirming color
|
||||
specification.
|
||||
|
||||
Plugins
|
||||
-------
|
||||
Colorpicker is extensible with several types of plugins. A number of plugins
|
||||
is provided for use. The plugins are constructed such that you only need to
|
||||
load the javascript file after the Colorpicker plugin itself is loaded.
|
||||
|
||||
### limits
|
||||
Limits let you limit the possible colors, as used by the 'limit' option.
|
||||
|
||||
No plugins included.
|
||||
|
||||
### parsers
|
||||
Parser take a textual representation of a color and return a Color object.
|
||||
If no match is found, nothing is returned and the next parser is tried.
|
||||
Parsers are tried in order of appearance.
|
||||
|
||||
Included plugins:
|
||||
* ``cmyk-parser`` Parses a ``cmyk(c, y, m, k)`` format, similar
|
||||
to rgba.
|
||||
* ``cmyk-percentage-parser`` Parses a ``cmyk(c%, y%, m%, k%)`` format with
|
||||
percentages.
|
||||
|
||||
### parts
|
||||
You can add additional visual parts, usually controls, that interact
|
||||
with the rest of Colorpicker framework.
|
||||
|
||||
Included plugins:
|
||||
* ``memory`` Cookie-based memory nodes.
|
||||
* ``rgbsliders`` Set of three red/green/blue sliders with dynamically
|
||||
adjusted gradients.
|
||||
* ``swatchesswitcher`` Switch through all available sets of swatches.
|
||||
|
||||
### partslists
|
||||
Partslists are a convenient way to select multiple parts at once without having
|
||||
to specify each one individually.
|
||||
|
||||
No plugins included.
|
||||
|
||||
### regional
|
||||
Regional (in the i18n directory) plugins contain localized texts
|
||||
(a.k.a. translations). A number of languages is provided.
|
||||
|
||||
Included regionals:
|
||||
* ``de`` German (Deutsch).
|
||||
* ``el`` Greece.
|
||||
* ``en`` English (default).
|
||||
* ``fr`` French.
|
||||
* ``nl`` Dutch.
|
||||
* ``pt-br`` Brazilian Portuguese.
|
||||
* ``ru`` Russian.
|
||||
|
||||
### swatches
|
||||
Swatches are collections of predefined and named colors. By default the
|
||||
standard ``html`` colors are loaded.
|
||||
Setting `swatches` using the `option` method will switch the displayed swatches.
|
||||
|
||||
Included plugins:
|
||||
* ``crayola`` Crayola pencil color names
|
||||
* ``pantone`` Pantone color codes
|
||||
* ``ral-classic`` Classic RAL paint numbers
|
||||
* ``x11`` X11 color palette (using "gray", not "grey").
|
||||
|
||||
### writers
|
||||
Writers take a Color object and output a textual representation of the color.
|
||||
Writers are used for the colorFormat option.
|
||||
|
||||
No plugins included.
|
||||
|
||||
Objects
|
||||
-------
|
||||
Colorpicker uses a Color object internally to represent a color and convert
|
||||
between the supported color models.
|
||||
You can create a new Color object through $.colorpicker.Color.
|
@ -1,20 +1,28 @@
|
||||
Fix the weird one-pixel vertical shift bug.
|
||||
Caused by ui-widget class.
|
||||
Only happens in Chrome and only on some, not all.
|
||||
Disappears and re-appears at different zoom levels.
|
||||
In hex input, accept (and strip) '#' symbol on copy/past.
|
||||
Completely destroy object when closed.
|
||||
Enabled/disabled
|
||||
isRTL? What to RTL, besides button?
|
||||
Disable selection in MSIE: this.dialog.on('selectstart', function(event) { return false; })
|
||||
Special rendering mode for color_none? Use [X] images?
|
||||
Fix parsing from input with websafe colors
|
||||
Recognize "transparent" color name.
|
||||
Limit number of events triggered.
|
||||
Small size variant (128x128)
|
||||
isRTL? What to RTL, besides button?
|
||||
Undo/redo memory?
|
||||
ARIA support.
|
||||
Allow only set (dec/hex) characters in inputs
|
||||
Most-recently-used swatches
|
||||
HSL/HSV distance calculations should take into account cyclic hue.
|
||||
$.undelegate and remove keydown methods for opening upon close()
|
||||
Separate into a pure dialog and a "caller" plugin.
|
||||
Implement a getColor method.
|
||||
Use preconfigured/default output color.
|
||||
Allow optional manual specification of color.
|
||||
Fix the weird one-pixel vertical shift bug.
|
||||
Caused by ui-widget class.
|
||||
Only happens in Chrome and only on some, not all.
|
||||
Disappears and re-appears at different zoom levels.
|
||||
In hex input, accept (and strip) '#' symbol on copy/past.
|
||||
Completely destroy object when closed.
|
||||
Enabled/disabled
|
||||
isRTL? What to RTL, besides button?
|
||||
Disable selection in MSIE: this.dialog.on('selectstart', function(event) { return false; })
|
||||
Special rendering mode for color_none? Use [X] images?
|
||||
Fix parsing from input with websafe colors
|
||||
Recognize "transparent" color name.
|
||||
Limit number of events triggered.
|
||||
Small size variant (128x128)
|
||||
isRTL? What to RTL, besides button?
|
||||
Undo/redo memory?
|
||||
ARIA support.
|
||||
Allow only set (dec/hex) characters in inputs
|
||||
Most-recently-used swatches
|
||||
HSL/HSV distance calculations should take into account cyclic hue.
|
||||
Support CSS4 color format draft proposals: http://dev.w3.org/csswg/css-color/
|
||||
Add more swatches; i.e. http://en.wikipedia.org/wiki/List_of_8-bit_computer_hardware_palettes
|
||||
Allow Cancel button to be enabled even when no change. Extra value for `showCancelButton`?
|
||||
|
26
js/jquery-colorpicker/bower.json
Normal file
26
js/jquery-colorpicker/bower.json
Normal file
@ -0,0 +1,26 @@
|
||||
{
|
||||
"name": "colorpicker",
|
||||
"version": "1.2.20",
|
||||
"homepage": "https://github.com/vanderlee/colorpicker",
|
||||
"authors": [
|
||||
"Martijn van der Lee <martijn@vanderlee.com>"
|
||||
],
|
||||
"description": "JQuery colorpicker: themeroller styling, RGB, HSL, CMYK and L*A*B support. Standard look & feel, configurable. Works as a popup or inline.",
|
||||
"main": "jquery.colorpicker.js",
|
||||
"keywords": [
|
||||
"jquery",
|
||||
"colorpicker"
|
||||
],
|
||||
"license": "MIT",
|
||||
"ignore": [
|
||||
"**/.*",
|
||||
"node_modules",
|
||||
"bower_components",
|
||||
"test",
|
||||
"tests"
|
||||
],
|
||||
"dependencies": {
|
||||
"jquery": ">=1.7.1",
|
||||
"jquery-ui": ">=1.8.0"
|
||||
}
|
||||
}
|
641
js/jquery-colorpicker/demo.html
Normal file
641
js/jquery-colorpicker/demo.html
Normal file
@ -0,0 +1,641 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>jQuery Colorpicker</title>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
|
||||
<!-- jQuery/jQueryUI (hosted) -->
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.js"></script>
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/jquery-ui.js"></script>
|
||||
<link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/themes/ui-lightness/jquery-ui.css" rel="stylesheet" type="text/css"/>
|
||||
<style>
|
||||
body {
|
||||
font-family: 'Segoe UI', Verdana, Arial, Helvetica, sans-serif;
|
||||
font-size: 62.5%;
|
||||
}
|
||||
</style>
|
||||
<script src="jquery.colorpicker.js"></script>
|
||||
<link href="jquery.colorpicker.css" rel="stylesheet" type="text/css"/>
|
||||
<script src="i18n/jquery.ui.colorpicker-nl.js"></script>
|
||||
<script src="swatches/jquery.ui.colorpicker-pantone.js"></script>
|
||||
<script src="swatches/jquery.ui.colorpicker-crayola.js"></script>
|
||||
<script src="swatches/jquery.ui.colorpicker-ral-classic.js"></script>
|
||||
<script src="swatches/jquery.ui.colorpicker-x11.js"></script>
|
||||
<script src="swatches/jquery.ui.colorpicker-copic.js"></script>
|
||||
<script src="swatches/jquery.ui.colorpicker-prismacolor.js"></script>
|
||||
<script src="swatches/jquery.ui.colorpicker-isccnbs.js"></script>
|
||||
<script src="swatches/jquery.ui.colorpicker-din6164.js"></script>
|
||||
<script src="parts/jquery.ui.colorpicker-rgbslider.js"></script>
|
||||
<script src="parts/jquery.ui.colorpicker-memory.js"></script>
|
||||
<script src="parts/jquery.ui.colorpicker-swatchesswitcher.js"></script>
|
||||
<script src="parsers/jquery.ui.colorpicker-cmyk-parser.js"></script>
|
||||
<script src="parsers/jquery.ui.colorpicker-cmyk-percentage-parser.js"></script>
|
||||
|
||||
<script>
|
||||
$(function() {
|
||||
$('#tabs').tabs();
|
||||
});
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>jQuery ColorPicker - Demo page</h1>
|
||||
|
||||
<div id="tabs">
|
||||
<ul>
|
||||
<li><a href="#tab-input">Basic <input></a></li>
|
||||
<li><a href="#tab-element">Basic element</a></li>
|
||||
<li><a href="#tab-full">All features</a></li>
|
||||
<li><a href="#tab-i18n">Localization</a></li>
|
||||
<li><a href="#tab-websafe">Websafe colors</a></li>
|
||||
<li><a href="#tab-alt">Alternative display field</a></li>
|
||||
<li><a href="#tab-events">Events</a></li>
|
||||
<li><a href="#tab-input-format">Input formatting</a></li>
|
||||
<li><a href="#tab-format">Output formatting</a></li>
|
||||
<li><a href="#tab-format-list">Output format list</a></li>
|
||||
<li><a href="#tab-dialog">In a dialog</a></li>
|
||||
<li><a href="#tab-modal">Modal</a></li>
|
||||
<li><a href="#tab-no-inline">Any element to popup</a></li>
|
||||
<li><a href="#tab-layout">Custom layout</a></li>
|
||||
<li><a href="#tab-pantone">Custom swatches</a></li>
|
||||
<li><a href="#tab-swatches-array">Custom swatches - array</a></li>
|
||||
<li><a href="#tab-hidden-input">Hidden input</a></li>
|
||||
<li><a href="#tab-plugins">Plugins</a></li>
|
||||
<li><a href="#tab-buttonImageOnly">buttonImageOnly</a></li>
|
||||
<li><a href="#tab-revert">Revert</a></li>
|
||||
<li><a href="#tab-okonenter">Close on enter</a></li>
|
||||
<li><a href="#tab-128">128-pixel map and bar</a></li>
|
||||
<li><a href="#tab-customcolor">Custom color format</a></li>
|
||||
<li><a href="#tab-position">Centered in window</a></li>
|
||||
<li><a href="#tab-disable">Disable/enable</a></li>
|
||||
<li><a href="#tab-noanim">No show animation</a></li>
|
||||
</ul>
|
||||
|
||||
<div id="tab-input">
|
||||
<h2>Basic <input> example, without any options</h2>
|
||||
<input type="text" class="cp-basic" value="fe9810"/>
|
||||
|
||||
<script>
|
||||
$(function() {
|
||||
});
|
||||
</script>
|
||||
</div>
|
||||
|
||||
<div id="tab-element">
|
||||
<h2>Basic element (<span>> example, without any options</h2>
|
||||
<span class="cp-basic" style="display: inline-block; vertical-align: top;"></span>
|
||||
|
||||
<script>
|
||||
$(function() {
|
||||
$('.cp-basic').colorpicker();
|
||||
});
|
||||
</script>
|
||||
</div>
|
||||
|
||||
<div id="tab-full">
|
||||
<h2>Fully-featured example</h2>
|
||||
<input type="text" class="cp-full" value="186aa7"/>
|
||||
|
||||
<script>
|
||||
$(function() {
|
||||
$('.cp-full').colorpicker({
|
||||
parts: 'full',
|
||||
showOn: 'both',
|
||||
buttonColorize: true,
|
||||
showNoneButton: true,
|
||||
alpha: true,
|
||||
colorFormat: 'RGBA'
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</div>
|
||||
|
||||
<div id="tab-i18n">
|
||||
<h2>Localized to Dutch (nl)</h2>
|
||||
<input type="text" class="cp-i18n" value="ccea73"/>
|
||||
|
||||
<script>
|
||||
$(function() {
|
||||
$('.cp-i18n').colorpicker({
|
||||
regional: 'nl',
|
||||
showNoneButton: true,
|
||||
alpha: true
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</div>
|
||||
|
||||
<div id="tab-websafe">
|
||||
<h2>Limit to websafe colors</h2>
|
||||
<input type="text" class="cp-websafe" value="0fa7c2"/>
|
||||
|
||||
<script>
|
||||
$(function() {
|
||||
$('.cp-websafe').colorpicker({
|
||||
limit: 'websafe'
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</div>
|
||||
|
||||
<div id="tab-alt">
|
||||
<h2>Alternative field class</h2>
|
||||
<input type="text" class="cp-alt" value="b762ae"/>
|
||||
<span class="cp-alt-target" style="display: inline-block; border: thin solid black; padding: .5em 4em;">
|
||||
<div style=" background-color: white; border: thin solid black; padding: .25em 2em; font-size: 1.25em; font-weight: bold;">Background-color on outside, text color here</div>
|
||||
</span>
|
||||
|
||||
<script>
|
||||
$(function() {
|
||||
$('.cp-alt').colorpicker({
|
||||
altField: '.cp-alt-target',
|
||||
altProperties: 'background-color,color',
|
||||
altAlpha: true,
|
||||
alpha: true
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</div>
|
||||
|
||||
<div id="tab-events">
|
||||
<h2>Events</h2>
|
||||
<input type="text" class="cp-events" value="92b64a"/>
|
||||
<div class="cp-events-log" style="vertical-align: top; display: inline-block; border: thin solid black; height: 10em; overflow-y: scroll; width: 50em;"></div>
|
||||
|
||||
<script>
|
||||
$(function() {
|
||||
var count = 0;
|
||||
|
||||
function addToEventLog(label, message) {
|
||||
var line = '<div>#'+(++count)+' '+label+': '+message+'</div>',
|
||||
log = $('.cp-events-log');
|
||||
log.append(line).scrollTop(log[0].scrollHeight);
|
||||
}
|
||||
|
||||
$('.cp-events').colorpicker({
|
||||
init: function(event, color) {
|
||||
addToEventLog('Init', color.formatted, color.colorPicker.color.toCSS());
|
||||
},
|
||||
select: function(event, color) {
|
||||
addToEventLog('Select', color.formatted);
|
||||
},
|
||||
stop: function(event, color) {
|
||||
addToEventLog('Stop', color.formatted);
|
||||
},
|
||||
close: function(event, color) {
|
||||
addToEventLog('Close', color.formatted + ' r:' + color.rgb.r + ' g:' + color.rgb.g + ' b:' + color.rgb.b + ' a:' + color.a);
|
||||
},
|
||||
ok: function(event, color) {
|
||||
addToEventLog('Ok', color.formatted + ' r:' + color.rgb.r + ' g:' + color.rgb.g + ' b:' + color.rgb.b + ' a:' + color.a);
|
||||
},
|
||||
open: function(event, color) {
|
||||
addToEventLog('Open', color.formatted + ' r:' + color.rgb.r + ' g:' + color.rgb.g + ' b:' + color.rgb.b + ' a:' + color.a);
|
||||
},
|
||||
cancel: function(event, color) {
|
||||
addToEventLog('Cancel', color.formatted + ' r:' + color.rgb.r + ' g:' + color.rgb.g + ' b:' + color.rgb.b + ' a:' + color.a);
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</div>
|
||||
|
||||
<div id="tab-format">
|
||||
<h2>Output formatting HSLA</h2>
|
||||
<input type="text" class="cp-format" value="918237"/>
|
||||
<span class="cp-format-output"></span>
|
||||
|
||||
<script>
|
||||
$(function() {
|
||||
$('.cp-format').colorpicker({
|
||||
colorFormat: 'HSLA',
|
||||
alpha: true,
|
||||
init: function(event, color) {
|
||||
$('.cp-format-output').text(color.formatted);
|
||||
},
|
||||
select: function(event, color) {
|
||||
$('.cp-format-output').text(color.formatted);
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</div>
|
||||
|
||||
<div id="tab-format-list">
|
||||
<h2>Output format list</h2>
|
||||
You can specify a list of output formats, the first perfect match for the color is output.<br/>
|
||||
<input type="text" class="cp-name" value="a92fb4"/>
|
||||
<span class="cp-name-output"></span>
|
||||
|
||||
<script>
|
||||
$(function() {
|
||||
$('.cp-name').colorpicker({
|
||||
parts: 'full',
|
||||
colorFormat: ['EXACT', '#HEX3', 'RGB', 'RGBA'],
|
||||
init: function(event, color) {
|
||||
$('.cp-name-output').text(color.formatted);
|
||||
},
|
||||
select: function(event, color) {
|
||||
$('.cp-name-output').text(color.formatted);
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</div>
|
||||
|
||||
<div id="tab-dialog">
|
||||
<h2>Dialog with Colorpicker popup (demonstrates z-index)</h2>
|
||||
<button id="cp-dialog-open">Open dialog</button>
|
||||
<div id="cp-dialog-modal" title="Basic modal dialog">
|
||||
Basic <input> example, without any options: <input type="text" class="cp-onclick" value="fe9810"/>
|
||||
<br/>
|
||||
Basic element example, without any options: <span class="cp-onclick" style="display: inline-block; vertical-align: top;"></span>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
$(function() {
|
||||
var dialogModal = $('#cp-dialog-modal').dialog({
|
||||
autoOpen: false,
|
||||
minWidth: 500,
|
||||
modal: true,
|
||||
buttons: { 'Close': function() {
|
||||
$(this).dialog('close');
|
||||
}
|
||||
}
|
||||
});
|
||||
$('.cp-onclick').colorpicker({
|
||||
showOn: 'click',
|
||||
inlineFrame: false
|
||||
});
|
||||
$('#cp-dialog-open').click(function() {
|
||||
dialogModal.dialog('open');
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</div>
|
||||
|
||||
<div id="tab-modal">
|
||||
<h2>Modal (and showCancelButton, closeOnEscape, showCloseButton)</h2>
|
||||
<input type="text" class="cp-modal" value="9ba73f"/>
|
||||
|
||||
<script>
|
||||
$(function() {
|
||||
$('.cp-modal').colorpicker({
|
||||
parts: 'draggable',
|
||||
showCloseButton: false,
|
||||
modal: true,
|
||||
showCancelButton: false,
|
||||
closeOnEscape: false
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</div>
|
||||
|
||||
<div id="tab-input-format">
|
||||
<h2>Input formatting</h2>
|
||||
Demonstrates the ability to parse common color formats as input.<br/>
|
||||
<input type="text" class="cp-input" value="rgb(123,42,87)"/>
|
||||
|
||||
<script>
|
||||
$(function() {
|
||||
$('.cp-input').colorpicker({
|
||||
colorFormat: ['RGBA']
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</div>
|
||||
|
||||
<div id="tab-no-inline">
|
||||
<h2>Popup from any element (<em>)</h2>
|
||||
Just click on this <em>Emphasized</em> word to show the colorpicker.
|
||||
|
||||
<script>
|
||||
$(function() {
|
||||
$('em').colorpicker({
|
||||
inline: false
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</div>
|
||||
|
||||
<div id="tab-layout">
|
||||
<h2>Custom layout</h2>
|
||||
It's easy to arrange a new layout for the dialog. Especially handy when used in a sidebar.<br/>
|
||||
<input type="text" class="cp-layout" value="92b7a5"/>
|
||||
|
||||
<script>
|
||||
$(function() {
|
||||
$('.cp-layout').colorpicker({
|
||||
parts: ['header', 'map', 'bar', 'hex', 'hsv', 'rgb', 'alpha', 'preview', 'swatches', 'footer'],
|
||||
alpha: true,
|
||||
layout: {
|
||||
hex: [0, 0, 2, 1],
|
||||
preview: [2, 0, 1, 1],
|
||||
map: [0, 1, 3, 1], // Left, Top, Width, Height (in table cells).
|
||||
bar: [0, 2, 1, 4],
|
||||
swatches: [2, 2, 1, 4],
|
||||
rgb: [1, 2, 1, 1],
|
||||
hsv: [1, 3, 1, 1],
|
||||
alpha: [1, 4, 1, 1],
|
||||
lab: [0, 5, 1, 1],
|
||||
cmyk: [1, 5, 1, 2]
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</div>
|
||||
|
||||
<div id="tab-pantone">
|
||||
<h2>Custom swatches</h2>
|
||||
Use the Pantone PMS colors as swatches<br/>
|
||||
<input type="text" class="cp-pantone" value="242"/>
|
||||
<span class="cp-pantone-output"></span>
|
||||
|
||||
<script>
|
||||
$(function() {
|
||||
$('.cp-pantone').colorpicker({
|
||||
parts: 'full',
|
||||
swatches: 'pantone',
|
||||
colorFormat: 'NAME',
|
||||
swatchesWidth: 173,
|
||||
limit: 'name',
|
||||
init: function(event, color) {
|
||||
$('.cp-pantone-output').text(color.formatted);
|
||||
},
|
||||
select: function(event, color) {
|
||||
$('.cp-pantone-output').text(color.formatted);
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</div>
|
||||
|
||||
<div id="tab-swatches-array">
|
||||
<h2>Custom swatches - array</h2>
|
||||
Use an array of swatches<br/>
|
||||
<input type="text" class="cp-custom-array" value="666666"/>
|
||||
<span class="cp-custom-array-output"></span>
|
||||
|
||||
<script>
|
||||
$(function() {
|
||||
/** Correctly handles the order of swatches.
|
||||
*/
|
||||
jQuery.colorpicker.swatches.custom_array = [
|
||||
{name: '000000', r: 0, g: 0, b: 0},
|
||||
{name: '444444', r: 0.266666666666667, g: 0.266666666666667, b:
|
||||
0.266666666666667},
|
||||
{name: '666666', r: 0.4, g: 0.4, b: 0.4},
|
||||
{name: '999999', r: 0.6, g: 0.6, b: 0.6}
|
||||
];
|
||||
/** This is supported, but does not respect the order in chrome.
|
||||
Black appears at the end of the list of swatches. */
|
||||
jQuery.colorpicker.swatches.custom = {
|
||||
'000000': {r: 0, g: 0, b: 0},
|
||||
'444444': {r: 0.266666666666667, g: 0.266666666666667, b:
|
||||
0.266666666666667},
|
||||
'666666': {r: 0.4, g: 0.4, b: 0.4},
|
||||
'999999': {r: 0.6, g: 0.6, b: 0.6}
|
||||
};
|
||||
|
||||
$('.cp-custom-array').colorpicker({
|
||||
parts: 'full',
|
||||
swatches: 'custom_array',
|
||||
colorFormat: 'NAME',
|
||||
swatchesWidth: 173,
|
||||
limit: 'name',
|
||||
init: function(event, color) {
|
||||
$('.cp-custom-array-output').text(color.formatted);
|
||||
},
|
||||
select: function(event, color) {
|
||||
$('.cp-custom-array-output').text(color.formatted);
|
||||
},
|
||||
containment: 'body'
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</div>
|
||||
|
||||
<div id="tab-hidden-input">
|
||||
<h2>Hidden input</h2>
|
||||
Uses a hidden input and buttons to pop open the colorpicker<br/>
|
||||
<input type="hidden" class="cp-hidden-input" value="#abc123"/>
|
||||
<button id="cp-hidden-input-open">Open</button>
|
||||
|
||||
<script>
|
||||
$(function() {
|
||||
var dialogHidden = $('.cp-hidden-input').colorpicker();
|
||||
$('#cp-hidden-input-open').click(function(e) {
|
||||
e.stopPropagation();
|
||||
dialogHidden.colorpicker('open');
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</div>
|
||||
|
||||
<div id="tab-plugins">
|
||||
<h2>Plugins</h2>
|
||||
Demonstrates how to extend the set of parts with plugins.<br/>
|
||||
<ol>
|
||||
<li>RGB Slider - Individual RGB sliders</li>
|
||||
<li>Memory - Store and retrieve colors with cookies</li>
|
||||
<li>Swatches Switcher - Switch between different sets of swatches</li>
|
||||
</ol>
|
||||
<input type="text" class="cp-plugins" value="#18b7af"/>
|
||||
|
||||
<script>
|
||||
$(function() {
|
||||
$('.cp-plugins').colorpicker({
|
||||
parts: ['header', 'preview', 'hex', 'rgbslider', 'memory', 'swatches', 'swatchesswitcher', 'footer'],
|
||||
layout: {
|
||||
preview: [0, 0, 1, 1],
|
||||
hex: [1, 0, 1, 1],
|
||||
rgbslider: [0, 1, 2, 1],
|
||||
memory: [0, 2, 2, 1],
|
||||
|
||||
swatchesswitcher: [2, 0, 1, 1],
|
||||
swatches: [2, 1, 1, 2]
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</div>
|
||||
|
||||
<div id="tab-buttonImageOnly">
|
||||
<h2>Only a button image</h2>
|
||||
<input type="text" class="cp-buttonImageOnly" value="#18b7af"/>
|
||||
<br/>
|
||||
<label for="toggle-cp-buttonImageOnly-disable">Enabled: <input type="checkbox" id="toggle-cp-buttonImageOnly-disable" checked="checked"/></label>
|
||||
|
||||
<script>
|
||||
$(function() {
|
||||
$('.cp-buttonImageOnly').colorpicker({
|
||||
showOn: 'both',
|
||||
buttonImageOnly: true
|
||||
});
|
||||
|
||||
$('#toggle-cp-buttonImageOnly-disable').click(function() {
|
||||
$('.cp-buttonImageOnly').colorpicker($(this).is(':checked') ? 'enable' : 'disable');
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</div>
|
||||
|
||||
<div id="tab-revert">
|
||||
<h2>Revert color on non-button exit.</h2>
|
||||
<p>Reverts the color on escape, clickOnOutside or close window
|
||||
using the [X] button.</p>
|
||||
<p>Open the Colorpicker, change color and click outside window,
|
||||
press ESC key or click the [X] button in the header. The dialog
|
||||
should now close and the previous color restored in the
|
||||
input.</p>
|
||||
<input type="text" class="cp-revert" value=""/>
|
||||
|
||||
<script>
|
||||
$(function() {
|
||||
$('.cp-revert').colorpicker({
|
||||
revert: true,
|
||||
parts: 'full',
|
||||
showNoneButton: true
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</div>
|
||||
|
||||
<div id="tab-okonenter">
|
||||
<h2>Close OK on enter</h2>
|
||||
Close the popup by pressing the enter key, keeping the selected color.
|
||||
<input type="text" class="cp-okonenter" value="a83b19"/>
|
||||
|
||||
<script>
|
||||
$(function() {
|
||||
$('.cp-okonenter').colorpicker({
|
||||
okOnEnter: true
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</div>
|
||||
|
||||
<div id="tab-128">
|
||||
<h2>128-pixel map and bar</h2>
|
||||
<span class="cp-128" style="display: inline-block; vertical-align: top;"></span>
|
||||
|
||||
<script>
|
||||
$(function() {
|
||||
$('.cp-128').colorpicker({
|
||||
parts: ['map', 'bar'],
|
||||
layout: {
|
||||
map: [0, 0, 1, 1], // Left, Top, Width, Height (in table cells).
|
||||
bar: [1, 0, 1, 1]
|
||||
},
|
||||
part: {
|
||||
map: { size: 128 },
|
||||
bar: { size: 128 }
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</div>
|
||||
|
||||
<div id="tab-customcolor">
|
||||
<h2>Custom color format</h2>
|
||||
<input type="text" size="80" class="cp-customcolor" value="0;83.782958984375;83.782958984375;4.736328125" style="display: inline-block; vertical-align: top;"/>
|
||||
|
||||
<script>
|
||||
$(function() {
|
||||
$.colorpicker.parsers['csv-cmyk'] = function (color) {
|
||||
var m = /^(\d+(?:\.\d+)?)\s*[,;]\s*(\d+(?:\.\d+)?)\s*[,;]\s*(\d+(?:\.\d+)?)\s*[,;]\s*(\d+(?:\.\d+)?)/.exec(color);
|
||||
if (m) {
|
||||
return (new $.colorpicker.Color()).setCMYK(
|
||||
m[1] / 100,
|
||||
m[2] / 100,
|
||||
m[3] / 100,
|
||||
m[4] / 100
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
$('.cp-customcolor').colorpicker({
|
||||
showOn: 'both',
|
||||
colorFormat: ['cp,mp,yp,kp'],
|
||||
buttonImageOnly: true,
|
||||
buttonColorize: true,
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</div>
|
||||
|
||||
<div id="tab-position">
|
||||
<h2>Centered using position option</h2>
|
||||
<input type="text" class="cp-position"/>
|
||||
|
||||
<script>
|
||||
$(function() {
|
||||
$('.cp-position').colorpicker({
|
||||
position: {
|
||||
my: 'center',
|
||||
at: 'center',
|
||||
of: window
|
||||
},
|
||||
modal: true
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</div>
|
||||
|
||||
<div id="tab-disable">
|
||||
<h2>Disable/enable</h2>
|
||||
<label for="toggle-cp-disable">Enabled: <input type="checkbox" id="toggle-cp-disable"/></label>
|
||||
<br/>
|
||||
Disabled by default:
|
||||
<input type="text" class="cp-disable" value="186aa7" disabled="disabled"/>
|
||||
<br/>
|
||||
Disabled using option:
|
||||
<input type="text" class="cp-disable-option" value="186aa7"/>
|
||||
<br/>
|
||||
<span class="cp-disable-option" style="display: inline-block; vertical-align: top;"></span>
|
||||
|
||||
<script>
|
||||
$(function() {
|
||||
$('.cp-disable').colorpicker({
|
||||
showOn: 'both',
|
||||
buttonColorize: true
|
||||
});
|
||||
|
||||
$('.cp-disable-option').colorpicker({
|
||||
parts: 'full',
|
||||
// parts: ['header', 'preview', 'hex', 'rgbslider', 'memory', 'swatches', 'swatchesswitcher', 'footer'],
|
||||
// layout: {
|
||||
// preview: [0, 0, 1, 1],
|
||||
// hex: [1, 0, 1, 1],
|
||||
// rgbslider: [0, 1, 2, 1],
|
||||
// memory: [0, 2, 2, 1],
|
||||
// swatchesswitcher: [2, 0, 1, 1],
|
||||
// swatches: [2, 1, 1, 2]
|
||||
// },
|
||||
showOn: 'both',
|
||||
disabled: true,
|
||||
buttonColorize: true,
|
||||
alpha: true
|
||||
|
||||
});
|
||||
|
||||
$('#toggle-cp-disable').click(function() {
|
||||
$('.cp-disable, .cp-disable-option').colorpicker($(this).is(':checked') ? 'enable' : 'disable');
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</div>
|
||||
|
||||
<div id="tab-noanim">
|
||||
<h2>No show animation</h2>
|
||||
<input type="text" class="cp-noanim" value="8e44ad"/>
|
||||
|
||||
<script>
|
||||
$(function() {
|
||||
$('.cp-noanim').colorpicker({
|
||||
showAnim: ''
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
27
js/jquery-colorpicker/i18n/jquery.ui.colorpicker-de.js
vendored
Normal file
27
js/jquery-colorpicker/i18n/jquery.ui.colorpicker-de.js
vendored
Normal file
@ -0,0 +1,27 @@
|
||||
;jQuery(function($) {
|
||||
$.colorpicker.regional['de'] = {
|
||||
ok: 'OK',
|
||||
cancel: 'Abbrechen',
|
||||
none: 'Keine',
|
||||
button: 'Farbe',
|
||||
title: 'Wähle eine Farbe',
|
||||
transparent: 'Transparent',
|
||||
hsvH: 'H',
|
||||
hsvS: 'S',
|
||||
hsvV: 'V',
|
||||
rgbR: 'R',
|
||||
rgbG: 'G',
|
||||
rgbB: 'B',
|
||||
labL: 'L',
|
||||
labA: 'a',
|
||||
labB: 'b',
|
||||
hslH: 'H',
|
||||
hslS: 'S',
|
||||
hslL: 'L',
|
||||
cmykC: 'C',
|
||||
cmykM: 'M',
|
||||
cmykY: 'Y',
|
||||
cmykK: 'K',
|
||||
alphaA: 'A'
|
||||
};
|
||||
});
|
28
js/jquery-colorpicker/i18n/jquery.ui.colorpicker-el.js
vendored
Normal file
28
js/jquery-colorpicker/i18n/jquery.ui.colorpicker-el.js
vendored
Normal file
@ -0,0 +1,28 @@
|
||||
;
|
||||
jQuery(function ($) {
|
||||
$.colorpicker.regional['el'] = {
|
||||
"alphaA": "A",
|
||||
"button": "Χρώμα",
|
||||
"cancel": "Άκυρο",
|
||||
"cmykC": "C",
|
||||
"cmykK": "K",
|
||||
"cmykM": "M",
|
||||
"cmykY": "Y",
|
||||
"hslH": "H",
|
||||
"hslL": "L",
|
||||
"hslS": "S",
|
||||
"hsvH": "H",
|
||||
"hsvS": "S",
|
||||
"hsvV": "V",
|
||||
"labA": "a",
|
||||
"labB": "b",
|
||||
"labL": "L",
|
||||
"none": "Κανένα",
|
||||
"ok": "Επιβεβαίωση",
|
||||
"rgbB": "B",
|
||||
"rgbG": "G",
|
||||
"rgbR": "Κ",
|
||||
"title": "Επιλέξτε χρώμα",
|
||||
"transparent": "Διαφάνεια"
|
||||
};
|
||||
});
|
27
js/jquery-colorpicker/i18n/jquery.ui.colorpicker-en-GB.js
vendored
Normal file
27
js/jquery-colorpicker/i18n/jquery.ui.colorpicker-en-GB.js
vendored
Normal file
@ -0,0 +1,27 @@
|
||||
;jQuery(function($) {
|
||||
$.colorpicker.regional['en-GB'] = {
|
||||
ok: 'OK',
|
||||
cancel: 'Cancel',
|
||||
none: 'None',
|
||||
button: 'Colour',
|
||||
title: 'Pick a colour',
|
||||
transparent: 'Transparent',
|
||||
hsvH: 'H',
|
||||
hsvS: 'S',
|
||||
hsvV: 'V',
|
||||
rgbR: 'R',
|
||||
rgbG: 'G',
|
||||
rgbB: 'B',
|
||||
labL: 'L',
|
||||
labA: 'a',
|
||||
labB: 'b',
|
||||
hslH: 'H',
|
||||
hslS: 'S',
|
||||
hslL: 'L',
|
||||
cmykC: 'C',
|
||||
cmykM: 'M',
|
||||
cmykY: 'Y',
|
||||
cmykK: 'K',
|
||||
alphaA: 'A'
|
||||
};
|
||||
});
|
27
js/jquery-colorpicker/i18n/jquery.ui.colorpicker-en-US.js
vendored
Normal file
27
js/jquery-colorpicker/i18n/jquery.ui.colorpicker-en-US.js
vendored
Normal file
@ -0,0 +1,27 @@
|
||||
;jQuery(function($) {
|
||||
$.colorpicker.regional['en-US'] = {
|
||||
ok: 'OK',
|
||||
cancel: 'Cancel',
|
||||
none: 'None',
|
||||
button: 'Color',
|
||||
title: 'Pick a color',
|
||||
transparent: 'Transparent',
|
||||
hsvH: 'H',
|
||||
hsvS: 'S',
|
||||
hsvV: 'V',
|
||||
rgbR: 'R',
|
||||
rgbG: 'G',
|
||||
rgbB: 'B',
|
||||
labL: 'L',
|
||||
labA: 'a',
|
||||
labB: 'b',
|
||||
hslH: 'H',
|
||||
hslS: 'S',
|
||||
hslL: 'L',
|
||||
cmykC: 'C',
|
||||
cmykM: 'M',
|
||||
cmykY: 'Y',
|
||||
cmykK: 'K',
|
||||
alphaA: 'A'
|
||||
};
|
||||
});
|
@ -1,4 +1,4 @@
|
||||
jQuery(function($) {
|
||||
;jQuery(function($) {
|
||||
$.colorpicker.regional['en'] = {
|
||||
ok: 'OK',
|
||||
cancel: 'Cancel',
|
||||
|
27
js/jquery-colorpicker/i18n/jquery.ui.colorpicker-es.js
vendored
Normal file
27
js/jquery-colorpicker/i18n/jquery.ui.colorpicker-es.js
vendored
Normal file
@ -0,0 +1,27 @@
|
||||
;jQuery(function($) {
|
||||
$.colorpicker.regional['es'] = {
|
||||
ok: 'OK',
|
||||
cancel: 'Cancelar',
|
||||
none: 'Ninguno',
|
||||
button: 'Color',
|
||||
title: 'Selecciona un color',
|
||||
transparent: 'Transparente',
|
||||
hsvH: 'H',
|
||||
hsvS: 'S',
|
||||
hsvV: 'V',
|
||||
rgbR: 'R',
|
||||
rgbG: 'G',
|
||||
rgbB: 'B',
|
||||
labL: 'L',
|
||||
labA: 'a',
|
||||
labB: 'b',
|
||||
hslH: 'H',
|
||||
hslS: 'S',
|
||||
hslL: 'L',
|
||||
cmykC: 'C',
|
||||
cmykM: 'M',
|
||||
cmykY: 'Y',
|
||||
cmykK: 'K',
|
||||
alphaA: 'A'
|
||||
};
|
||||
});
|
@ -1,4 +1,4 @@
|
||||
jQuery(function($) {
|
||||
;jQuery(function($) {
|
||||
$.colorpicker.regional['fr'] = {
|
||||
ok: 'OK',
|
||||
cancel: 'Annuler',
|
||||
|
@ -1,4 +1,4 @@
|
||||
jQuery(function($) {
|
||||
;jQuery(function($) {
|
||||
$.colorpicker.regional['nl'] = {
|
||||
ok: 'OK',
|
||||
cancel: 'Annuleren',
|
||||
|
27
js/jquery-colorpicker/i18n/jquery.ui.colorpicker-pl.js
vendored
Normal file
27
js/jquery-colorpicker/i18n/jquery.ui.colorpicker-pl.js
vendored
Normal file
@ -0,0 +1,27 @@
|
||||
;jQuery(function($) {
|
||||
$.colorpicker.regional['pl'] = {
|
||||
ok: 'OK',
|
||||
cancel: 'Anuluj',
|
||||
none: 'Wyczyść',
|
||||
button: 'Kolor',
|
||||
title: 'Wskaż kolor',
|
||||
transparent: 'Przezroczysty',
|
||||
hsvH: 'H',
|
||||
hsvS: 'S',
|
||||
hsvV: 'V',
|
||||
rgbR: 'R',
|
||||
rgbG: 'G',
|
||||
rgbB: 'B',
|
||||
labL: 'L',
|
||||
labA: 'a',
|
||||
labB: 'b',
|
||||
hslH: 'H',
|
||||
hslS: 'S',
|
||||
hslL: 'L',
|
||||
cmykC: 'C',
|
||||
cmykM: 'M',
|
||||
cmykY: 'Y',
|
||||
cmykK: 'K',
|
||||
alphaA: 'A'
|
||||
};
|
||||
});
|
27
js/jquery-colorpicker/i18n/jquery.ui.colorpicker-pt-BR.js
vendored
Normal file
27
js/jquery-colorpicker/i18n/jquery.ui.colorpicker-pt-BR.js
vendored
Normal file
@ -0,0 +1,27 @@
|
||||
;jQuery(function($) {
|
||||
$.colorpicker.regional['pt-br'] = {
|
||||
ok: 'OK',
|
||||
cancel: 'Cancelar',
|
||||
none: 'Nenhum',
|
||||
button: 'Cor',
|
||||
title: 'Escolha uma cor',
|
||||
transparent: 'Transparente',
|
||||
hsvH: 'H',
|
||||
hsvS: 'S',
|
||||
hsvV: 'V',
|
||||
rgbR: 'R',
|
||||
rgbG: 'G',
|
||||
rgbB: 'B',
|
||||
labL: 'L',
|
||||
labA: 'a',
|
||||
labB: 'b',
|
||||
hslH: 'H',
|
||||
hslS: 'S',
|
||||
hslL: 'L',
|
||||
cmykC: 'C',
|
||||
cmykM: 'M',
|
||||
cmykY: 'Y',
|
||||
cmykK: 'K',
|
||||
alphaA: 'A'
|
||||
};
|
||||
});
|
27
js/jquery-colorpicker/i18n/jquery.ui.colorpicker-ru.js
vendored
Normal file
27
js/jquery-colorpicker/i18n/jquery.ui.colorpicker-ru.js
vendored
Normal file
@ -0,0 +1,27 @@
|
||||
;jQuery(function($) {
|
||||
$.colorpicker.regional['ru'] = {
|
||||
ok: 'OK',
|
||||
cancel: 'Отменить',
|
||||
none: 'Никакой',
|
||||
button: 'Цвет',
|
||||
title: 'Выбрать цвет',
|
||||
transparent: 'Прозрачный',
|
||||
hsvH: 'H',
|
||||
hsvS: 'S',
|
||||
hsvV: 'V',
|
||||
rgbR: 'R',
|
||||
rgbG: 'G',
|
||||
rgbB: 'B',
|
||||
labL: 'L',
|
||||
labA: 'a',
|
||||
labB: 'b',
|
||||
hslH: 'H',
|
||||
hslS: 'S',
|
||||
hslL: 'L',
|
||||
cmykC: 'C',
|
||||
cmykM: 'M',
|
||||
cmykY: 'Y',
|
||||
cmykK: 'K',
|
||||
alphaA: 'A'
|
||||
};
|
||||
});
|
27
js/jquery-colorpicker/i18n/jquery.ui.colorpicker-sr.js
vendored
Normal file
27
js/jquery-colorpicker/i18n/jquery.ui.colorpicker-sr.js
vendored
Normal file
@ -0,0 +1,27 @@
|
||||
;jQuery(function($) {
|
||||
$.colorpicker.regional['sr'] = {
|
||||
ok: 'OK',
|
||||
cancel: 'Odustani',
|
||||
none: 'Nijedno',
|
||||
button: 'Boja',
|
||||
title: 'Izaberi boju',
|
||||
transparent: 'Providno',
|
||||
hsvH: 'H',
|
||||
hsvS: 'S',
|
||||
hsvV: 'V',
|
||||
rgbR: 'R',
|
||||
rgbG: 'G',
|
||||
rgbB: 'B',
|
||||
labL: 'L',
|
||||
labA: 'a',
|
||||
labB: 'b',
|
||||
hslH: 'H',
|
||||
hslS: 'S',
|
||||
hslL: 'L',
|
||||
cmykC: 'C',
|
||||
cmykM: 'M',
|
||||
cmykY: 'Y',
|
||||
cmykK: 'K',
|
||||
alphaA: 'A'
|
||||
};
|
||||
});
|
27
js/jquery-colorpicker/i18n/jquery.ui.colorpicker-uk.js
vendored
Normal file
27
js/jquery-colorpicker/i18n/jquery.ui.colorpicker-uk.js
vendored
Normal file
@ -0,0 +1,27 @@
|
||||
;jQuery(function ($) {
|
||||
$.colorpicker.regional['uk'] = {
|
||||
ok: 'ОК',
|
||||
cancel: 'Скасувати',
|
||||
none: 'Ніякий',
|
||||
button: 'Колір',
|
||||
title: 'Обрати колір',
|
||||
transparent: 'Прозорий',
|
||||
hsvH: 'H',
|
||||
hsvS: 'S',
|
||||
hsvV: 'V',
|
||||
rgbR: 'R',
|
||||
rgbG: 'G',
|
||||
rgbB: 'B',
|
||||
labL: 'L',
|
||||
labA: 'a',
|
||||
labB: 'b',
|
||||
hslH: 'H',
|
||||
hslS: 'S',
|
||||
hslL: 'L',
|
||||
cmykC: 'C',
|
||||
cmykM: 'M',
|
||||
cmykY: 'Y',
|
||||
cmykK: 'K',
|
||||
alphaA: 'A'
|
||||
};
|
||||
});
|
BIN
js/jquery-colorpicker/images/128/bar-alpha.png
Normal file
BIN
js/jquery-colorpicker/images/128/bar-alpha.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.5 KiB |
BIN
js/jquery-colorpicker/images/128/bar.png
Normal file
BIN
js/jquery-colorpicker/images/128/bar.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.1 KiB |
BIN
js/jquery-colorpicker/images/128/map.png
Normal file
BIN
js/jquery-colorpicker/images/128/map.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 36 KiB |
BIN
js/jquery-colorpicker/images/favicon.png
Normal file
BIN
js/jquery-colorpicker/images/favicon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 6.2 KiB |
BIN
js/jquery-colorpicker/images/logotype-a.png
Normal file
BIN
js/jquery-colorpicker/images/logotype-a.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 12 KiB |
BIN
js/jquery-colorpicker/images/logotype-b.png
Normal file
BIN
js/jquery-colorpicker/images/logotype-b.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 17 KiB |
@ -1,210 +1,332 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>jQuery Colorpicker</title>
|
||||
<!-- jQuery/jQueryUI (hosted) -->
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.js"></script>
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/jquery-ui.js"></script>
|
||||
<link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/themes/ui-lightness/jquery-ui.css" rel="stylesheet" type="text/css"/>
|
||||
<style>
|
||||
body {
|
||||
font-family: 'Segoe UI', Verdana, Arial, Helvetica, sans-serif;
|
||||
font-size: 62.5%;
|
||||
}
|
||||
</style>
|
||||
<script src="jquery.colorpicker.js"></script>
|
||||
<link href="jquery.colorpicker.css" rel="stylesheet" type="text/css"/>
|
||||
<script src="i18n/jquery.ui.colorpicker-nl.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<h1>jQuery ColorPicker</h1>
|
||||
|
||||
<hr/>
|
||||
|
||||
Basic <input> example, without any options: <input type="text" class="cp-basic" value="fe9810"/>
|
||||
|
||||
<hr/>
|
||||
|
||||
Basic <div> example, without any options: <span class="cp-basic" style="display: inline-block; vertical-align: top;"></span>
|
||||
<script>
|
||||
$( function() {
|
||||
$('.cp-basic').colorpicker();
|
||||
});
|
||||
</script>
|
||||
|
||||
<hr/>
|
||||
|
||||
Fully-featured example: <input type="text" class="cp-full" value="186aa7"/>
|
||||
<script>
|
||||
$( function() {
|
||||
$('.cp-full').colorpicker({
|
||||
parts: 'full',
|
||||
showOn: 'both',
|
||||
buttonColorize: true,
|
||||
showNoneButton: true,
|
||||
alpha: true
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
<hr/>
|
||||
|
||||
Localized to Dutch (nl): <input type="text" class="cp-nl" value="ccea73"/>
|
||||
<script>
|
||||
$( function() {
|
||||
$('.cp-nl').colorpicker({
|
||||
regional: 'nl',
|
||||
showNoneButton: true,
|
||||
alpha: true
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
<hr/>
|
||||
|
||||
Limit to websafe colors: <input type="text" class="cp-websafe" value="0fa7c2"/>
|
||||
<script>
|
||||
$( function() {
|
||||
$('.cp-websafe').colorpicker({
|
||||
limit: 'websafe'
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
<hr/>
|
||||
|
||||
Alternative field class: <input type="text" class="cp-alt" value="b762ae"/>
|
||||
<span class="cp-alt-target" style="display: inline-block; border: thin solid black; padding: .5em 4em;">
|
||||
<div style=" background-color: white; border: thin solid black; padding: .25em 2em; font-size: 1.25em; font-weight: bold;">Background-color on outside, text color here</div>
|
||||
</span>
|
||||
<script>
|
||||
$( function() {
|
||||
$('.cp-alt').colorpicker({
|
||||
altField: '.cp-alt-target',
|
||||
altProperties: 'background-color,color',
|
||||
altAlpha: true,
|
||||
alpha: true
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
<hr/>
|
||||
|
||||
Events: <input type="text" class="cp-events" value="92b64a"/>
|
||||
<div class="cp-events-log" style="vertical-align: top; display: inline-block; border: thin solid black; height: 10em; overflow-y: scroll; width: 50em;"></div>
|
||||
<script>
|
||||
$( function() {
|
||||
var count = 0;
|
||||
|
||||
function addToEventLog(label, message) {
|
||||
var line = '<div>#'+(++count)+' '+label+': '+message+'</div>';
|
||||
var log = $('.cp-events-log');
|
||||
log.append(line).scrollTop(log[0].scrollHeight);
|
||||
}
|
||||
|
||||
$('.cp-events').colorpicker({
|
||||
init: function(event, color) {
|
||||
addToEventLog('Init', color.formatted);
|
||||
},
|
||||
select: function(event, color) {
|
||||
addToEventLog('Select', color.formatted);
|
||||
},
|
||||
close: function(event, color) {
|
||||
addToEventLog('Close', color.formatted + ' r:' + color.rgb.r + ' g:' + color.rgb.g + ' b:' + color.rgb.b + ' a:' + color.a);
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
<hr/>
|
||||
|
||||
Output formatting HSLA: <input type="text" class="cp-format" value="918237"/>
|
||||
<span class="cp-format-output"></span>
|
||||
<script>
|
||||
$( function() {
|
||||
$('.cp-format').colorpicker({
|
||||
colorFormat: 'HSLA',
|
||||
alpha: true,
|
||||
init: function(event, color) {
|
||||
$('.cp-format-output').text(color.formatted);
|
||||
},
|
||||
select: function(event, color) {
|
||||
$('.cp-format-output').text(color.formatted);
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
<hr/>
|
||||
|
||||
Output format list: <input type="text" class="cp-name" value="a92fb4"/>
|
||||
<span class="cp-name-output"></span>
|
||||
<script>
|
||||
$( function() {
|
||||
$('.cp-name').colorpicker({
|
||||
parts: 'full',
|
||||
colorFormat: ['NAME', 'EXACT', '#HEX3', 'RGB', 'RGBA'],
|
||||
init: function(event, color) {
|
||||
$('.cp-name-output').text(color.formatted);
|
||||
},
|
||||
select: function(event, color) {
|
||||
$('.cp-name-output').text(color.formatted);
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
<hr/>
|
||||
|
||||
Dialog with Colorpicker popup (demonstrates z-index):
|
||||
<button id="cp-dialog-open">Open dialog</button>
|
||||
<div id="cp-dialog-modal" title="Basic modal dialog">
|
||||
Basic <input> example, without any options: <input type="text" class="cp-basic" value="fe9810"/>
|
||||
<br/>
|
||||
Basic <div> example, without any options: <span class="cp-basic" style="display: inline-block; vertical-align: top;"></span>
|
||||
</div>
|
||||
<script>
|
||||
$(function() {
|
||||
var dialog = $('#cp-dialog-modal').dialog({
|
||||
autoOpen: false,
|
||||
minWidth: 500,
|
||||
modal: true,
|
||||
buttons: { 'Close': function() {
|
||||
$(this).dialog('close');
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
$('#cp-dialog-open').click(function() {
|
||||
dialog.dialog('open');
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
<hr/>
|
||||
|
||||
Modal (and showCancelButton, closeOnEscape, showCloseButton): <input type="text" class="cp-modal" value="9ba73f"/>
|
||||
<script>
|
||||
$( function() {
|
||||
$('.cp-modal').colorpicker({
|
||||
parts: 'draggable',
|
||||
showCloseButton: false,
|
||||
modal: true,
|
||||
showCancelButton: false,
|
||||
closeOnEscape: false
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
<hr/>
|
||||
|
||||
Input formatting: <input type="text" class="cp-input" value="rgb(123,42,87)"/>
|
||||
<script>
|
||||
$( function() {
|
||||
$('.cp-input').colorpicker({
|
||||
colorFormat: ['RGBA']
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<title>jQuery.Colorpicker</title>
|
||||
|
||||
<!-- jQuery/jQueryUI (hosted) -->
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.js"></script>
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.24/jquery-ui.js"></script>
|
||||
<link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.24/themes/ui-lightness/jquery-ui.css" rel="stylesheet" type="text/css"/>
|
||||
|
||||
<!-- Markdown parser -->
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/pagedown/1.0/Markdown.Converter.min.js"></script>
|
||||
|
||||
<!-- Prettyprint -->
|
||||
<link href="https://cdnjs.cloudflare.com/ajax/libs/prettify/r298/prettify.min.css" rel="stylesheet" type="text/css"/>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/prettify/r298/prettify.min.js"></script>
|
||||
|
||||
<!-- Index -->
|
||||
<style>
|
||||
body {
|
||||
font-family: "Segoe UI", Verdana, Helvetica, Arial, sans-serif;
|
||||
font-size: 11px;
|
||||
padding: 3em 8em 1em 4em;
|
||||
}
|
||||
|
||||
#logo {
|
||||
background: url('images/logotype-a.png') no-repeat center center;
|
||||
background-size: contain;
|
||||
height: 20em;
|
||||
}
|
||||
|
||||
#preview {
|
||||
text-align: center;
|
||||
}
|
||||
#preview > * {
|
||||
box-shadow: 0 0 2em silver;
|
||||
padding: 2em;
|
||||
}
|
||||
|
||||
.chapter {
|
||||
-webkit-columns: 460px;
|
||||
-moz-columns: 460px;
|
||||
columns: 460px;
|
||||
|
||||
-webkit-column-gap: 4em;
|
||||
-moz-column-gap: 4em;
|
||||
column-gap: 4em;
|
||||
|
||||
-webkit-column-rule: thin solid silver;
|
||||
-moz-column-rule: thin solid silver;
|
||||
column-rule: thin solid silver;
|
||||
|
||||
text-align: justify;
|
||||
}
|
||||
|
||||
h1,
|
||||
h2 {
|
||||
background: black;
|
||||
color: white;
|
||||
padding: .2em .4em;
|
||||
}
|
||||
h1 {
|
||||
margin-top: 1em;
|
||||
}
|
||||
h2 {
|
||||
background: gray;
|
||||
}
|
||||
|
||||
hr {
|
||||
border-top: double;
|
||||
margin: 2em 25%;
|
||||
}
|
||||
|
||||
#footer {
|
||||
margin-top: 4em;
|
||||
text-align: center;
|
||||
color: silver;
|
||||
border-top: thin solid silver;
|
||||
padding-top: 1em;
|
||||
}
|
||||
|
||||
.output {
|
||||
font-family: monospace;
|
||||
border: solid thin silver;
|
||||
padding: .2em .4em;
|
||||
background-color: #cf3;
|
||||
}
|
||||
|
||||
.clickable {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
pre {
|
||||
tab-size: 4;
|
||||
overflow-x: auto;
|
||||
background-color: #eee;
|
||||
-webkit-column-break-inside: avoid;
|
||||
}
|
||||
</style>
|
||||
<script>
|
||||
$(function() {
|
||||
function tabsToSpaces(line, tabsize) {
|
||||
var out = '',
|
||||
tabsize = tabsize || 4,
|
||||
c;
|
||||
for (c in line) {
|
||||
var ch = line.charAt(c);
|
||||
if (ch === '\t') {
|
||||
do {
|
||||
out += ' ';
|
||||
} while (out.length % tabsize);
|
||||
} else {
|
||||
out += ch;
|
||||
}
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
function visualizeElement(element, type) {
|
||||
var code = $(element).html().split('\n'),
|
||||
tabsize = 4,
|
||||
minlength = 2E53,
|
||||
l;
|
||||
|
||||
// Convert tabs to spaces
|
||||
for (l in code) {
|
||||
code[l] = tabsToSpaces(code[l], tabsize);
|
||||
}
|
||||
|
||||
|
||||
// determine minimum length
|
||||
var minlength = 2E53;
|
||||
var first = 2E53;
|
||||
var last = 0;
|
||||
for (l in code) {
|
||||
if (/\S/.test(code[l])) {
|
||||
minlength = Math.min(minlength, /^\s*/.exec(code[l])[0].length);
|
||||
first = Math.min(first, l);
|
||||
last = Math.max(last, l);
|
||||
}
|
||||
}
|
||||
|
||||
code = code.slice(first, last + 1);
|
||||
|
||||
// strip tabs at start
|
||||
for (l in code) {
|
||||
code[l] = code[l].slice(minlength);
|
||||
}
|
||||
|
||||
// recombine
|
||||
code = code.join('\n');
|
||||
|
||||
var fragment = $('<pre class="prettyprint"><code/></pre>').text(code).insertAfter(element);
|
||||
$('<h3 class="clickable">'+type+'…</h3>').insertBefore(fragment).click(function() {
|
||||
fragment.slideToggle();
|
||||
});
|
||||
}
|
||||
|
||||
// extract html fragments
|
||||
$('div.prettyprint, span.prettyprint').each(function() {
|
||||
visualizeElement(this, 'HTML');
|
||||
});
|
||||
|
||||
// extract scripts
|
||||
$('script.prettyprint').each(function() {
|
||||
visualizeElement(this, 'Javascript');
|
||||
});
|
||||
|
||||
// Include the readme
|
||||
var markdown = new Markdown.Converter();
|
||||
$.get('README.md', function(readme) {
|
||||
$('#readme').html(markdown.makeHtml(readme));
|
||||
$('#readme h1').each(function() {
|
||||
$(this).nextUntil('h1').wrapAll('<div class="chapter"/>');
|
||||
});
|
||||
$('#readme pre').addClass('prettyprint');
|
||||
prettyPrint();
|
||||
|
||||
// build menu
|
||||
var menuitems = [];
|
||||
$('h1').each(function() {
|
||||
var text = $(this).text(),
|
||||
id = $(this).attr('id') || 'chapter '+text;
|
||||
$(this).attr('id', id);
|
||||
menuitems.push('<a href="#'+id+'">'+text+'</a>');
|
||||
});
|
||||
$(menu).html(menuitems.join(' — '));
|
||||
}, 'html');
|
||||
});
|
||||
</script>
|
||||
|
||||
<!-- Plugin -->
|
||||
<script src="jquery.colorpicker.js"></script>
|
||||
<link href="jquery.colorpicker.css" rel="stylesheet" type="text/css"/>
|
||||
|
||||
<!-- Plugin extensions -->
|
||||
<script src="i18n/jquery.ui.colorpicker-nl.js"></script>
|
||||
<script src="parts/jquery.ui.colorpicker-rgbslider.js"></script>
|
||||
<script src="parts/jquery.ui.colorpicker-memory.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<a href="https://github.com/vanderlee/colorpicker"><img style="position: absolute; top: 0; right: 0; border: 0;" src="https://s3.amazonaws.com/github/ribbons/forkme_right_darkblue_121621.png" alt="Fork me on GitHub"></a>
|
||||
|
||||
<div id="menu"></div>
|
||||
|
||||
<div id="logo"></div>
|
||||
|
||||
<div id="preview">
|
||||
<span id="colorpicker-preview" style="display: inline-block; vertical-align: top;"></span>
|
||||
<script>
|
||||
$(function() {
|
||||
$('#colorpicker-preview').colorpicker({
|
||||
parts: 'full',
|
||||
alpha: true
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</div>
|
||||
|
||||
<div id="book">
|
||||
<div id="readme"></div>
|
||||
|
||||
<h1>Examples</h1>
|
||||
<div id="examples" class="chapter">
|
||||
Try it yourself…
|
||||
|
||||
<h2>Simple popup</h2>
|
||||
<div class="prettyprint">
|
||||
<input type="text" id="colorpicker-popup" value="fe9810"/>
|
||||
</div>
|
||||
<script class="prettyprint">
|
||||
$(function() {
|
||||
$('#colorpicker-popup').colorpicker();
|
||||
});
|
||||
</script>
|
||||
|
||||
<h2>Fully featured popup</h2>
|
||||
<div class="prettyprint">
|
||||
<input type="text" id="colorpicker-full" value="fe9810"/>
|
||||
</div>
|
||||
<script class="prettyprint">
|
||||
$(function() {
|
||||
$('#colorpicker-full').colorpicker({
|
||||
parts: 'full',
|
||||
alpha: true,
|
||||
showOn: 'both',
|
||||
buttonColorize: true,
|
||||
showNoneButton: true
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
<h2>Custom layout</h2>
|
||||
<div class="prettyprint">
|
||||
<input type="text" id="colorpicker-layout" value="fe9810"/>
|
||||
</div>
|
||||
<script class="prettyprint">
|
||||
$(function() {
|
||||
$('#colorpicker-layout').colorpicker({
|
||||
parts: [ 'header', 'map', 'bar', 'hex',
|
||||
'hsv', 'rgb', 'alpha', 'preview',
|
||||
'swatches', 'footer'
|
||||
],
|
||||
alpha: true,
|
||||
layout: {
|
||||
hex: [0, 0, 2, 1],
|
||||
preview: [2, 0, 1, 1],
|
||||
map: [0, 1, 3, 1],
|
||||
bar: [0, 2, 1, 4],
|
||||
swatches: [2, 2, 1, 4],
|
||||
rgb: [1, 2, 1, 1],
|
||||
hsv: [1, 3, 1, 1],
|
||||
alpha: [1, 4, 1, 1],
|
||||
lab: [0, 5, 1, 1],
|
||||
cmyk: [1, 5, 1, 2]
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
<h2>Plugins</h2>
|
||||
<div class="prettyprint">
|
||||
<input type="text" id="colorpicker-plugins" value="fe9810"/>
|
||||
</div>
|
||||
<script class="prettyprint">
|
||||
$(function() {
|
||||
$('#colorpicker-plugins').colorpicker({
|
||||
parts: [ 'header', 'preview', 'hex',
|
||||
'rgbslider', 'memory', 'footer'
|
||||
],
|
||||
layout: {
|
||||
preview: [0, 0, 1, 1],
|
||||
hex: [1, 0, 1, 1],
|
||||
rgbslider: [0, 1, 2, 1],
|
||||
memory: [0, 2, 2, 1]
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
<h2>Localization</h2>
|
||||
<div class="prettyprint">
|
||||
<input type="text" id="colorpicker-l10n" value="fe9810"/>
|
||||
</div>
|
||||
<script class="prettyprint">
|
||||
$(function() {
|
||||
$('#colorpicker-l10n').colorpicker({
|
||||
parts: 'draggable',
|
||||
regional: 'nl',
|
||||
showNoneButton: true,
|
||||
alpha: true
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
<h2>More examples…</h2>
|
||||
Click here view a lot more demo's <a href="demo.html" target="_blank">Demos</a>
|
||||
</div>
|
||||
|
||||
<h1>Unittest</h1>
|
||||
<div id="unittest" class="chapter">
|
||||
jQuery.colorpicker comes with a small set of QUnit-based unittests.<br/>
|
||||
Click here to run the tests in a new window: <a href="test/index.html" target="_blank">Unittests</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="footer">
|
||||
Copyright © 2011-2017 Martijn van der Lee. MIT Open Source license applies.
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
@ -1,199 +1,238 @@
|
||||
.ui-colorpicker,
|
||||
.ui-dialog.ui-colorpicker {
|
||||
width: auto;
|
||||
white-space: nowrap;
|
||||
|
||||
-webkit-touch-callout: none;
|
||||
-webkit-user-select: none;
|
||||
-khtml-user-select: none;
|
||||
-moz-user-select: none;
|
||||
-ms-user-select: none;
|
||||
user-select: none;
|
||||
}
|
||||
|
||||
.ui-colorpicker-inline {
|
||||
position: static;
|
||||
}
|
||||
|
||||
.ui-colorpicker-buttonset {
|
||||
float: left;
|
||||
margin-left: .4em;
|
||||
}
|
||||
|
||||
.ui-colorpicker-buttonset .ui-button {
|
||||
margin: .5em 0 .5em 0;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.ui-colorpicker-buttonpane {
|
||||
background-image: none;
|
||||
margin: .7em 0 0 0;
|
||||
padding: 0 .2em;
|
||||
border-left: 0;
|
||||
border-right: 0;
|
||||
border-bottom: 0;
|
||||
}
|
||||
|
||||
.ui-colorpicker-buttonpane button {
|
||||
float: right;
|
||||
margin: .5em .2em .4em;
|
||||
cursor: pointer;
|
||||
padding: .2em .6em .3em .6em;
|
||||
width: auto;
|
||||
overflow: visible;
|
||||
}
|
||||
|
||||
.ui-colorpicker-buttonpane button.ui-colorpicker-current {
|
||||
float: left;
|
||||
}
|
||||
|
||||
.ui-colorpicker table {
|
||||
font-size: 100%; /* Reset browser table font-size */
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.ui-colorpicker table td {
|
||||
vertical-align: top;
|
||||
}
|
||||
|
||||
.ui-colorpicker-padding-left {
|
||||
padding-left: 10px;
|
||||
}
|
||||
.ui-colorpicker-padding-top {
|
||||
padding-top: 10px;
|
||||
}
|
||||
|
||||
.ui-colorpicker-border {
|
||||
border: 1px inset;
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
/* Bar & map */
|
||||
.ui-colorpicker-map > *,
|
||||
.ui-colorpicker-bar > * {
|
||||
position: absolute;
|
||||
cursor: crosshair;
|
||||
}
|
||||
|
||||
.ui-colorpicker-map-pointer,
|
||||
.ui-colorpicker-bar-pointer {
|
||||
position: absolute;
|
||||
}
|
||||
/* Map */
|
||||
.ui-colorpicker-map,
|
||||
.ui-colorpicker-map > * {
|
||||
display: block;
|
||||
width: 256px;
|
||||
height: 256px;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.ui-colorpicker-map-layer-1,
|
||||
.ui-colorpicker-map-layer-2 {
|
||||
background: url(images/map.png) no-repeat;
|
||||
}
|
||||
|
||||
.ui-colorpicker-map-layer-alpha {
|
||||
background: url(images/map-opacity.png);
|
||||
}
|
||||
|
||||
.ui-colorpicker-map-pointer {
|
||||
display: inline-block;
|
||||
width: 15px;
|
||||
height: 15px;
|
||||
background: url(images/map-pointer.png) no-repeat;
|
||||
}
|
||||
|
||||
/* Bar */
|
||||
.ui-colorpicker-bar,
|
||||
.ui-colorpicker-bar > * {
|
||||
display: block;
|
||||
width: 20px;
|
||||
height: 256px;
|
||||
overflow: hidden;
|
||||
background-repeat: repeat-x;
|
||||
}
|
||||
|
||||
.ui-colorpicker-bar-layer-1,
|
||||
.ui-colorpicker-bar-layer-2,
|
||||
.ui-colorpicker-bar-layer-3,
|
||||
.ui-colorpicker-bar-layer-4 {
|
||||
background: url(images/bar.png) repeat-x;
|
||||
}
|
||||
|
||||
.ui-colorpicker-bar-layer-alpha {
|
||||
background: url(images/bar-opacity.png);
|
||||
}
|
||||
|
||||
.ui-colorpicker-bar-layer-alphabar {
|
||||
background: url(images/bar-alpha.png);
|
||||
}
|
||||
|
||||
.ui-colorpicker-bar-pointer {
|
||||
display: inline-block;
|
||||
width: 20px;
|
||||
height: 7px;
|
||||
background: url(images/bar-pointer.png) no-repeat;
|
||||
}
|
||||
|
||||
/* Preview */
|
||||
.ui-colorpicker-preview {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.ui-colorpicker-preview-initial {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.ui-colorpicker-preview-initial,
|
||||
.ui-colorpicker-preview-current {
|
||||
width: 50px;
|
||||
height: 20px;
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
.ui-colorpicker-preview-initial-alpha,
|
||||
.ui-colorpicker-preview-current-alpha {
|
||||
width: 50px;
|
||||
height: 20px;
|
||||
display: inline-block;
|
||||
background: url(images/preview-opacity.png) repeat;
|
||||
}
|
||||
|
||||
/* Inputs */
|
||||
.ui-colorpicker-rgb label,
|
||||
.ui-colorpicker-hsv label,
|
||||
.ui-colorpicker-hsl label,
|
||||
.ui-colorpicker-lab label,
|
||||
.ui-colorpicker-cmyk label,
|
||||
.ui-colorpicker-alpha label {
|
||||
width: 1.5em;
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
.ui-colorpicker-number {
|
||||
margin: .1em;
|
||||
width: 4em;
|
||||
}
|
||||
|
||||
/* Hex */
|
||||
.ui-colorpicker-hex {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
/* Swatches */
|
||||
.ui-colorpicker-swatches {
|
||||
width: 84px;
|
||||
height: 256px;
|
||||
overflow: auto;
|
||||
background-color: #f8f8f8;
|
||||
}
|
||||
|
||||
.ui-colorpicker-swatch {
|
||||
cursor: pointer;
|
||||
float: left;
|
||||
width: 11px;
|
||||
height: 11px;
|
||||
border-right: 1px solid black;
|
||||
border-bottom: 1px solid black;
|
||||
}
|
||||
.ui-colorpicker,
|
||||
.ui-dialog.ui-colorpicker {
|
||||
width: auto;
|
||||
white-space: nowrap;
|
||||
-webkit-touch-callout: none;
|
||||
-webkit-user-select: none;
|
||||
-khtml-user-select: none;
|
||||
-ms-user-select: none;
|
||||
user-select: none;
|
||||
}
|
||||
|
||||
.ui-colorpicker-inline {
|
||||
position: static;
|
||||
}
|
||||
|
||||
.ui-colorpicker-buttonset {
|
||||
float: left;
|
||||
margin-left: .4em;
|
||||
}
|
||||
|
||||
.ui-colorpicker-buttonset .ui-button {
|
||||
margin: .5em 0 .5em 0;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.ui-colorpicker-buttonpane {
|
||||
background-image: none;
|
||||
margin: .7em 0 0 0;
|
||||
padding: 0 .2em;
|
||||
border-left: 0;
|
||||
border-right: 0;
|
||||
border-bottom: 0;
|
||||
}
|
||||
|
||||
.ui-colorpicker-buttonpane button {
|
||||
float: right;
|
||||
margin: .5em .2em .4em;
|
||||
cursor: pointer;
|
||||
padding: .2em .6em .3em .6em;
|
||||
width: auto;
|
||||
overflow: visible;
|
||||
}
|
||||
|
||||
.ui-colorpicker-buttonpane button.ui-colorpicker-current {
|
||||
float: left;
|
||||
}
|
||||
|
||||
.ui-colorpicker table {
|
||||
width: 100%;
|
||||
font-size: 100%; /* Reset browser table font-size */
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.ui-colorpicker table td {
|
||||
vertical-align: top;
|
||||
}
|
||||
|
||||
.ui-colorpicker-padding-left {
|
||||
padding-left: 10px;
|
||||
}
|
||||
.ui-colorpicker-padding-top {
|
||||
padding-top: 10px;
|
||||
}
|
||||
|
||||
.ui-colorpicker-border {
|
||||
border: 1px inset;
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
/* Bar & map */
|
||||
.ui-colorpicker-map > *,
|
||||
.ui-colorpicker-bar > * {
|
||||
position: absolute;
|
||||
cursor: crosshair;
|
||||
}
|
||||
|
||||
.ui-colorpicker-map-pointer,
|
||||
.ui-colorpicker-bar-pointer {
|
||||
position: absolute;
|
||||
left: 0;
|
||||
}
|
||||
|
||||
/* Map */
|
||||
.ui-colorpicker-map,
|
||||
.ui-colorpicker-map > * {
|
||||
display: block;
|
||||
width: 256px;
|
||||
height: 256px;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.ui-colorpicker-map-layer-1,
|
||||
.ui-colorpicker-map-layer-2 {
|
||||
background: url(images/map.png) no-repeat;
|
||||
}
|
||||
|
||||
.ui-colorpicker-map-128,
|
||||
.ui-colorpicker-map-128 > * {
|
||||
width: 128px;
|
||||
height: 128px;
|
||||
}
|
||||
|
||||
.ui-colorpicker-map-128 .ui-colorpicker-map-layer-1,
|
||||
.ui-colorpicker-map-128 .ui-colorpicker-map-layer-2 {
|
||||
background: url(images/128/map.png) no-repeat;
|
||||
}
|
||||
|
||||
.ui-colorpicker-map-layer-alpha {
|
||||
background: url(images/map-opacity.png);
|
||||
}
|
||||
|
||||
.ui-colorpicker-map-pointer {
|
||||
display: inline-block;
|
||||
width: 15px;
|
||||
height: 15px;
|
||||
background: url(images/map-pointer.png) no-repeat;
|
||||
}
|
||||
|
||||
/* Bar */
|
||||
.ui-colorpicker-bar,
|
||||
.ui-colorpicker-bar > * {
|
||||
display: block;
|
||||
width: 20px;
|
||||
height: 256px;
|
||||
overflow: hidden;
|
||||
background-repeat: repeat-x;
|
||||
}
|
||||
|
||||
.ui-colorpicker-bar-128,
|
||||
.ui-colorpicker-bar-128 > * {
|
||||
height: 128px;
|
||||
}
|
||||
|
||||
.ui-colorpicker-bar-layer-1,
|
||||
.ui-colorpicker-bar-layer-2,
|
||||
.ui-colorpicker-bar-layer-3,
|
||||
.ui-colorpicker-bar-layer-4 {
|
||||
background: url(images/bar.png) repeat-x;
|
||||
}
|
||||
|
||||
.ui-colorpicker-bar-128 .ui-colorpicker-bar-layer-1,
|
||||
.ui-colorpicker-bar-128 .ui-colorpicker-bar-layer-2,
|
||||
.ui-colorpicker-bar-128 .ui-colorpicker-bar-layer-3,
|
||||
.ui-colorpicker-bar-128 .ui-colorpicker-bar-layer-4 {
|
||||
background: url(images/128/bar.png) repeat-x;
|
||||
}
|
||||
|
||||
.ui-colorpicker-bar-layer-alpha {
|
||||
background: url(images/bar-opacity.png);
|
||||
}
|
||||
|
||||
.ui-colorpicker-bar-layer-alphabar {
|
||||
background: url(images/bar-alpha.png);
|
||||
}
|
||||
|
||||
.ui-colorpicker-bar-128 .ui-colorpicker-bar-layer-alphabar {
|
||||
background: url(images/128/bar-alpha.png);
|
||||
}
|
||||
|
||||
.ui-colorpicker-bar-pointer {
|
||||
display: inline-block;
|
||||
width: 20px;
|
||||
height: 7px;
|
||||
background: url(images/bar-pointer.png) no-repeat;
|
||||
}
|
||||
|
||||
/* Preview */
|
||||
.ui-colorpicker-preview {
|
||||
text-align: center;
|
||||
height: 20px;
|
||||
}
|
||||
|
||||
.ui-colorpicker-preview-initial {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.ui-colorpicker-preview-initial,
|
||||
.ui-colorpicker-preview-current {
|
||||
width: 50px;
|
||||
height: 20px;
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
.ui-colorpicker-preview-initial-alpha,
|
||||
.ui-colorpicker-preview-current-alpha {
|
||||
width: 50px;
|
||||
height: 20px;
|
||||
display: inline-block;
|
||||
background: url(images/preview-opacity.png) repeat;
|
||||
}
|
||||
|
||||
/* Inputs */
|
||||
.ui-colorpicker-rgb label,
|
||||
.ui-colorpicker-hsv label,
|
||||
.ui-colorpicker-hsl label,
|
||||
.ui-colorpicker-lab label,
|
||||
.ui-colorpicker-cmyk label,
|
||||
.ui-colorpicker-alpha label {
|
||||
width: 1.5em;
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
.ui-colorpicker-number {
|
||||
margin: .1em;
|
||||
width: 4em;
|
||||
}
|
||||
|
||||
/* Hex */
|
||||
.ui-colorpicker-hex {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
/* Swatches */
|
||||
.ui-colorpicker-swatches {
|
||||
height: 256px;
|
||||
overflow: auto;
|
||||
background-color: #f8f8f8;
|
||||
}
|
||||
|
||||
.ui-colorpicker-swatch {
|
||||
cursor: pointer;
|
||||
float: left;
|
||||
width: 11px;
|
||||
height: 11px;
|
||||
border-right: 1px solid black;
|
||||
border-bottom: 1px solid black;
|
||||
}
|
||||
|
||||
.ui-colorpicker-disabled {
|
||||
opacity: .5;
|
||||
-ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=50)";
|
||||
filter: alpha(opacity=50);
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.ui-colorpicker-disabled * {
|
||||
cursor: default !important;
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
32
js/jquery-colorpicker/package.json
Normal file
32
js/jquery-colorpicker/package.json
Normal file
@ -0,0 +1,32 @@
|
||||
{
|
||||
"name": "vanderlee-colorpicker",
|
||||
"version": "1.2.20",
|
||||
"homepage": "https://github.com/vanderlee/colorpicker",
|
||||
"author": "Martijn van der Lee <martijn@vanderlee.com>",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/vanderlee/colorpicker"
|
||||
},
|
||||
"description": "JQuery colorpicker: themeroller styling, RGB, HSL, CMYK and L*A*B support. Standard look & feel, configurable. Works as a popup or inline.",
|
||||
"main": "jquery.colorpicker.js",
|
||||
"keywords": [
|
||||
"jquery",
|
||||
"colorpicker"
|
||||
],
|
||||
"license": "MIT",
|
||||
"ignore": [
|
||||
"**/.*",
|
||||
"node_modules",
|
||||
"bower_components",
|
||||
"test"
|
||||
],
|
||||
"dependencies": {
|
||||
"jquery": ">=1.7.1",
|
||||
"jquery-ui": ">=1.8.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"eslint": "^5.15.1",
|
||||
"stylelint": "^9.10.1",
|
||||
"stylelint-config-recommended": "^2.1.0"
|
||||
}
|
||||
}
|
13
js/jquery-colorpicker/parsers/jquery.ui.colorpicker-cmyk-parser.js
vendored
Normal file
13
js/jquery-colorpicker/parsers/jquery.ui.colorpicker-cmyk-parser.js
vendored
Normal file
@ -0,0 +1,13 @@
|
||||
jQuery(function($) {
|
||||
$.colorpicker.parsers['CMYK'] = function (color) {
|
||||
var m = /^cmyk\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*\)$/.exec(color);
|
||||
if (m) {
|
||||
return (new $.colorpicker.Color()).setCMYK(
|
||||
m[1] / 255,
|
||||
m[2] / 255,
|
||||
m[3] / 255,
|
||||
m[4] / 255
|
||||
);
|
||||
}
|
||||
};
|
||||
});
|
13
js/jquery-colorpicker/parsers/jquery.ui.colorpicker-cmyk-percentage-parser.js
vendored
Normal file
13
js/jquery-colorpicker/parsers/jquery.ui.colorpicker-cmyk-percentage-parser.js
vendored
Normal file
@ -0,0 +1,13 @@
|
||||
jQuery(function($) {
|
||||
$.colorpicker.parsers['CMYK%'] = function (color) {
|
||||
var m = /^cmyk\(\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*\)$/.exec(color);
|
||||
if (m) {
|
||||
return (new $.colorpicker.Color()).setCMYK(
|
||||
m[1] / 100,
|
||||
m[2] / 100,
|
||||
m[3] / 100,
|
||||
m[4] / 100
|
||||
);
|
||||
}
|
||||
};
|
||||
});
|
80
js/jquery-colorpicker/parts/jquery.ui.colorpicker-memory.js
vendored
Normal file
80
js/jquery-colorpicker/parts/jquery.ui.colorpicker-memory.js
vendored
Normal file
@ -0,0 +1,80 @@
|
||||
jQuery(function($) {
|
||||
$.colorpicker.parts.memory = function (inst) {
|
||||
var that = this,
|
||||
container,
|
||||
selectNode = function(node) {
|
||||
inst.color = inst._parseColor($(node).css('backgroundColor'));
|
||||
inst._change();
|
||||
},
|
||||
deleteNode = function(node) {
|
||||
node.remove();
|
||||
},
|
||||
addNode = function(color) {
|
||||
var $node = $('<div/>').addClass('ui-colorpicker-swatch').css('backgroundColor', color);
|
||||
$node.mousedown(function(e) {
|
||||
e.stopPropagation();
|
||||
|
||||
if (!inst.options.disabled) {
|
||||
switch (e.which) {
|
||||
case 1:
|
||||
selectNode(this);
|
||||
break;
|
||||
case 3:
|
||||
deleteNode($node);
|
||||
setMemory();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}).on('contextmenu', function(e) {
|
||||
e.preventDefault();
|
||||
});
|
||||
|
||||
container.append($node);
|
||||
},
|
||||
getMemory = function() {
|
||||
if (window.localStorage) {
|
||||
var memory = localStorage.getItem('colorpicker-memory');
|
||||
if (memory) {
|
||||
return JSON.parse(memory);
|
||||
}
|
||||
}
|
||||
return $.map((document.cookie.match(/\bcolorpicker-memory=([^;]*)/) || [0, ''])[1].split(','),unescape);
|
||||
};
|
||||
setMemory = function() {
|
||||
var colors = [];
|
||||
$('> *', container).each(function() {
|
||||
colors.push($(this).css('backgroundColor'));
|
||||
});
|
||||
if (window.localStorage) {
|
||||
localStorage.setItem('colorpicker-memory',JSON.stringify(colors));
|
||||
}
|
||||
else {
|
||||
var expdate=new Date();
|
||||
expdate.setDate(expdate.getDate() + (365 * 10));
|
||||
document.cookie = 'colorpicker-memory='+$.map(colors,escape).join()+';expires='+expdate.toUTCString();
|
||||
}
|
||||
};
|
||||
|
||||
this.init = function () {
|
||||
container = $('<div/>')
|
||||
.addClass('ui-colorpicker-memory ui-colorpicker-border ui-colorpicker-swatches')
|
||||
.css({
|
||||
width: 84,
|
||||
height: 84,
|
||||
cursor: 'crosshair'
|
||||
})
|
||||
.appendTo($('.ui-colorpicker-memory-container', inst.dialog));
|
||||
|
||||
$.each(getMemory(), function() {
|
||||
addNode(this);
|
||||
});
|
||||
|
||||
container.mousedown(function(e) {
|
||||
if (!inst.options.disabled) {
|
||||
addNode(inst.color.toCSS());
|
||||
setMemory();
|
||||
}
|
||||
});
|
||||
};
|
||||
};
|
||||
});
|
80
js/jquery-colorpicker/parts/jquery.ui.colorpicker-rgbslider.js
vendored
Normal file
80
js/jquery-colorpicker/parts/jquery.ui.colorpicker-rgbslider.js
vendored
Normal file
@ -0,0 +1,80 @@
|
||||
jQuery(function($) {
|
||||
/**
|
||||
* Set a horizontal gradient background image on an element.
|
||||
* Uses the now-deprecated $.browser
|
||||
* @param $ element
|
||||
* @param $.colorpicker.Color startColor
|
||||
* @param $.colorpicker.Color endColor
|
||||
* @returns {undefined}
|
||||
*/
|
||||
function setGradient(element, startColor, endColor) {
|
||||
var start = startColor.toCSS(),
|
||||
end = endColor.toCSS(),
|
||||
styles = window.getComputedStyle(document.documentElement, ''),
|
||||
prefix = (Array.prototype.slice.call(styles).join('').match(/-(moz|webkit|ms)-/) || (styles.OLink === '' && ['', 'o']))[1];
|
||||
|
||||
element.css('background-image', '-'+prefix+'-linear-gradient(left, '+start+' 0%, '+end+' 100%)');
|
||||
}
|
||||
|
||||
$.colorpicker.parts.rgbslider = function (inst) {
|
||||
var that = this,
|
||||
sliders = { r: $('<div class="ui-colorpicker-slider"/>'),
|
||||
g: $('<div class="ui-colorpicker-slider"/>'),
|
||||
b: $('<div class="ui-colorpicker-slider"/>')
|
||||
};
|
||||
|
||||
this.updateGradients = function () {
|
||||
var color = inst.color.getRGB();
|
||||
|
||||
setGradient(sliders.r, new $.colorpicker.Color(0, color.g, color.b), new $.colorpicker.Color(1, color.g, color.b));
|
||||
setGradient(sliders.g, new $.colorpicker.Color(color.r, 0, color.b), new $.colorpicker.Color(color.r, 1, color.b));
|
||||
setGradient(sliders.b, new $.colorpicker.Color(color.r, color.g, 0), new $.colorpicker.Color(color.r, color.g, 1));
|
||||
};
|
||||
|
||||
this.init = function () {
|
||||
$('<div class="ui-colorpicker-rgbslider"/>').append(sliders.r, sliders.g, sliders.b)
|
||||
.appendTo($('.ui-colorpicker-rgbslider-container', inst.dialog));
|
||||
|
||||
function refresh() {
|
||||
var r = sliders.r.slider('value') / 255,
|
||||
g = sliders.g.slider('value') / 255,
|
||||
b = sliders.b.slider('value') / 255;
|
||||
|
||||
inst.color.setRGB(r, g, b);
|
||||
inst._change();
|
||||
|
||||
that.updateGradients();
|
||||
}
|
||||
|
||||
$(sliders.r).add(sliders.g).add(sliders.b).slider({
|
||||
min: 0,
|
||||
max: 255,
|
||||
step: 1,
|
||||
slide: refresh,
|
||||
change: refresh
|
||||
});
|
||||
|
||||
this.updateGradients();
|
||||
};
|
||||
|
||||
this.repaint = function () {
|
||||
$.each(inst.color.getRGB(), function (index, value) {
|
||||
var input = sliders[index];
|
||||
value = Math.round(value * 255);
|
||||
if (input.slider('value') !== value) {
|
||||
input.slider('value', value);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
this.update = function () {
|
||||
this.repaint();
|
||||
};
|
||||
|
||||
this.disable = function (disabled) {
|
||||
sliders.r.slider(disabled ? 'disable' : 'enable');
|
||||
sliders.g.slider(disabled ? 'disable' : 'enable');
|
||||
sliders.b.slider(disabled ? 'disable' : 'enable');
|
||||
};
|
||||
};
|
||||
});
|
35
js/jquery-colorpicker/parts/jquery.ui.colorpicker-swatchesswitcher.js
vendored
Normal file
35
js/jquery-colorpicker/parts/jquery.ui.colorpicker-swatchesswitcher.js
vendored
Normal file
@ -0,0 +1,35 @@
|
||||
jQuery(function($) {
|
||||
$.colorpicker.parts.swatchesswitcher = function (inst) {
|
||||
var that = this,
|
||||
part = null;
|
||||
|
||||
this.init = function () {
|
||||
var names = $.map($.colorpicker.swatches, function(v, name) { return name; }).sort(),
|
||||
current = inst.options.swatches || 'html',
|
||||
select = $('<select>').width(inst.options.swatchesWidth + 2);
|
||||
|
||||
part = $('<div/>')
|
||||
.addClass('ui-colorpicker-swatchesswitcher')
|
||||
.css('text-align', 'center')
|
||||
.appendTo($('.ui-colorpicker-swatchesswitcher-container', inst.dialog));
|
||||
select.appendTo(part);
|
||||
|
||||
$.each(names, function(x, name) {
|
||||
var label = $.colorpicker.swatchesNames[name]
|
||||
|| name.replace(/[-_]/, ' ').replace(/^([a-z\u00E0-\u00FC])|\s+([a-z\u00E0-\u00FC])/g, function($1) {
|
||||
return $1.toUpperCase();
|
||||
});
|
||||
$('<option>').val(name).text(label).appendTo(select);
|
||||
});
|
||||
select.val(current);
|
||||
|
||||
select.change(function() {
|
||||
inst.option('swatches', $(this).val());
|
||||
});
|
||||
};
|
||||
|
||||
this.disable = function (disabled) {
|
||||
$('select', part).prop('disabled', disabled);
|
||||
};
|
||||
};
|
||||
});
|
363
js/jquery-colorpicker/swatches/jquery.ui.colorpicker-copic.js
vendored
Normal file
363
js/jquery-colorpicker/swatches/jquery.ui.colorpicker-copic.js
vendored
Normal file
@ -0,0 +1,363 @@
|
||||
jQuery(function($) {
|
||||
$.colorpicker.swatchesNames['copic'] = 'Copic';
|
||||
$.colorpicker.swatches['copic'] = [
|
||||
{name: 'Colorless Blender', r: 1, g: 1, b: 1},
|
||||
{name: 'Black', r: 0.1921568627451, g: 0.16862745098039, b: 0.16862745098039},
|
||||
{name: 'Special Black', r: 0.011764705882353, g: 0.027450980392157, b: 0.031372549019608},
|
||||
{name: 'Frost Blue', r: 0.86666666666667, g: 0.94117647058824, b: 0.95686274509804},
|
||||
{name: 'Pale Porcelain Blue', r: 0.90196078431373, g: 0.95686274509804, b: 0.96078431372549},
|
||||
{name: 'Pale Celestine', r: 0.94117647058824, g: 0.97647058823529, b: 0.99607843137255},
|
||||
{name: 'Mint Blue', r: 0.83921568627451, g: 0.93333333333333, b: 0.94901960784314},
|
||||
{name: 'Robin\'s Egg Blue', r: 0.70196078431373, g: 0.89019607843137, b: 0.94509803921569},
|
||||
{name: 'Tahitian Blue', r: 0.45098039215686, g: 0.81176470588235, b: 0.90196078431373},
|
||||
{name: 'Process Blue', r: 0.25098039215686, g: 0.77254901960784, b: 0.90196078431373},
|
||||
{name: 'Peacock Blue', r: 0, g: 0.70196078431373, b: 0.90196078431373},
|
||||
{name: 'Ice Blue', r: 0.7843137254902, g: 0.90196078431373, b: 0.94117647058824},
|
||||
{name: 'Light Blue', r: 0.44313725490196, g: 0.81176470588235, b: 0.92156862745098},
|
||||
{name: 'Cyanine Blue', r: 0, g: 0.73725490196078, b: 0.91764705882353},
|
||||
{name: 'Lapis Lazuli', r: 0.11372549019608, g: 0.54117647058824, b: 0.79607843137255},
|
||||
{name: 'Baby Blue', r: 0.85882352941176, g: 0.92941176470588, b: 0.97647058823529},
|
||||
{name: 'Phthalo Blue', r: 0.57254901960784, g: 0.76078431372549, b: 0.90980392156863},
|
||||
{name: 'Sky', r: 0.54117647058824, g: 0.8078431372549, b: 0.95294117647059},
|
||||
{name: 'Cobalt Blue', r: 0.39607843137255, g: 0.70196078431373, b: 0.89019607843137},
|
||||
{name: 'Royal Blue', r: 0.098039215686275, g: 0.42745098039216, b: 0.71372549019608},
|
||||
{name: 'Ultramarine', r: 0.003921568627451, g: 0.46666666666667, b: 0.75686274509804},
|
||||
{name: 'Pale Blue', r: 0.88627450980392, g: 0.93725490196078, b: 0.96862745098039},
|
||||
{name: 'Manganese Blue', r: 0.50980392156863, g: 0.76470588235294, b: 0.92941176470588},
|
||||
{name: 'Antwerp Blue', r: 0.082352941176471, g: 0.43529411764706, b: 0.64313725490196},
|
||||
{name: 'Prussian Blue', r: 0.16862745098039, g: 0.3921568627451, b: 0.66274509803922},
|
||||
{name: 'Powder Blue', r: 0.88627450980392, g: 0.94117647058824, b: 0.9843137254902},
|
||||
{name: 'Smoky Blue', r: 0.45882352941176, g: 0.75294117647059, b: 0.91764705882353},
|
||||
{name: 'Soft Greenish Blue', r: 0.67843137254902, g: 0.80392156862745, b: 0.86274509803922},
|
||||
{name: 'Pale Blue Gray', r: 0.85490196078431, g: 0.88235294117647, b: 0.95294117647059},
|
||||
{name: 'Light Hydrangea', r: 0.65490196078431, g: 0.73333333333333, b: 0.87843137254902},
|
||||
{name: 'Clematis', r: 0.4078431372549, g: 0.53333333333333, b: 0.77254901960784},
|
||||
{name: 'Stratospheric Blue', r: 0.12941176470588, g: 0.39607843137255, b: 0.68235294117647},
|
||||
{name: 'Iris', r: 0.23137254901961, g: 0.27843137254902, b: 0.6156862745098},
|
||||
{name: 'Pale Grayish Blue', r: 0.83529411764706, g: 0.88627450980392, b: 0.92156862745098},
|
||||
{name: 'Light Crockery Blue', r: 0.5843137254902, g: 0.75686274509804, b: 0.85490196078431},
|
||||
{name: 'Light Grayish Cobalt', r: 0.37647058823529, g: 0.77254901960784, b: 0.81176470588235},
|
||||
{name: 'Night Blue', r: 0.27058823529412, g: 0.47843137254902, b: 0.60392156862745},
|
||||
{name: 'Agate', r: 0.058823529411765, g: 0.32941176470588, b: 0.49411764705882},
|
||||
{name: 'Pale Aqua', r: 0.89803921568627, g: 0.95686274509804, b: 0.92941176470588},
|
||||
{name: 'Snow Green', r: 0.93725490196078, g: 0.97254901960784, b: 0.95294117647059},
|
||||
{name: 'Aqua Blue', r: 0.78039215686275, g: 0.90196078431373, b: 0.98039215686275},
|
||||
{name: 'New Blue', r: 0.77647058823529, g: 0.90980392156863, b: 0.91764705882353},
|
||||
{name: 'Holiday Blue', r: 0.11372549019608, g: 0.72156862745098, b: 0.8078431372549},
|
||||
{name: 'Petroleum Blue', r: 0.11372549019608, g: 0.72156862745098, b: 0.8078431372549},
|
||||
{name: 'Blue Green', r: 0.86274509803922, g: 0.94117647058824, b: 0.93725490196078},
|
||||
{name: 'Cool Shadow', r: 0.86274509803922, g: 0.94117647058824, b: 0.93725490196078},
|
||||
{name: 'Moon White', r: 0.8078431372549, g: 0.92156862745098, b: 0.94509803921569},
|
||||
{name: 'Mint Green', r: 0.76862745098039, g: 0.90588235294118, b: 0.91372549019608},
|
||||
{name: 'Aqua', r: 0.62745098039216, g: 0.85098039215686, b: 0.82352941176471},
|
||||
{name: 'Teal Blue', r: 0.2156862745098, g: 0.75294117647059, b: 0.69019607843137},
|
||||
{name: 'Coral Sea', r: 0.74117647058824, g: 0.89803921568627, b: 0.86666666666667},
|
||||
{name: 'Aqua Mint', r: 0.73725490196078, g: 0.88627450980392, b: 0.84313725490196},
|
||||
{name: 'Horizon Green', r: 0.63921568627451, g: 0.85490196078431, b: 0.84313725490196},
|
||||
{name: 'Nile Blue', r: 0.68627450980392, g: 0.87450980392157, b: 0.87450980392157},
|
||||
{name: 'Duck Blue', r: 0, g: 0.71372549019608, b: 0.72549019607843},
|
||||
{name: 'Ice Mint', r: 0.67450980392157, g: 0.81176470588235, b: 0.81960784313725},
|
||||
{name: 'Jasper', r: 0.3921568627451, g: 0.74509803921569, b: 0.74509803921569},
|
||||
{name: 'Ocean Mist', r: 0.85490196078431, g: 0.92549019607843, b: 0.93333333333333},
|
||||
{name: 'Ice Ocean', r: 0.45490196078431, g: 0.72156862745098, b: 0.73333333333333},
|
||||
{name: 'Abyss Green', r: 0.34901960784314, g: 0.56862745098039, b: 0.55686274509804},
|
||||
{name: 'Bronze', r: 0.28627450980392, g: 0.43921568627451, b: 0.41960784313725},
|
||||
{name: 'Gray Sky', r: 0.72941176470588, g: 0.75686274509804, b: 0.72549019607843},
|
||||
{name: 'Green Gray', r: 0.72941176470588, g: 0.75686274509804, b: 0.72549019607843},
|
||||
{name: 'Bush', r: 0.50588235294118, g: 0.63529411764706, b: 0.56862745098039},
|
||||
{name: 'Flagstone Blue', r: 0.43137254901961, g: 0.6078431372549, b: 0.52941176470588},
|
||||
{name: 'Mauve Shadow', r: 0.87843137254902, g: 0.86274509803922, b: 0.92941176470588},
|
||||
{name: 'Iridescent Mauve', r: 0.91764705882353, g: 0.90588235294118, b: 0.94901960784314},
|
||||
{name: 'Pale Thistle', r: 0.91764705882353, g: 0.90588235294118, b: 0.94901960784314},
|
||||
{name: 'Viola', r: 0.76862745098039, g: 0.78823529411765, b: 0.90196078431373},
|
||||
{name: 'Prune', r: 0.66666666666667, g: 0.72156862745098, b: 0.85882352941176},
|
||||
{name: 'Blue Berry', r: 0.48627450980392, g: 0.5921568627451, b: 0.8078431372549},
|
||||
{name: 'Blue Violet', r: 0.91764705882353, g: 0.90588235294118, b: 0.94901960784314},
|
||||
{name: 'Soft Violet', r: 0.83137254901961, g: 0.82352941176471, b: 0.90980392156863},
|
||||
{name: 'Hydrangea Blue', r: 0.51764705882353, g: 0.56862745098039, b: 0.7843137254902},
|
||||
{name: 'Deep Reddish Blue', r: 0.43137254901961, g: 0.51764705882353, b: 0.74117647058824},
|
||||
{name: 'Dull Lavender', r: 0.81176470588235, g: 0.85882352941176, b: 0.94509803921569},
|
||||
{name: 'Grayish Lavender', r: 0.69411764705882, g: 0.75294117647059, b: 0.86666666666667},
|
||||
{name: 'Grayish Violet', r: 0.50588235294118, g: 0.51764705882353, b: 0.65490196078431},
|
||||
{name: 'Slate', r: 0.21960784313725, g: 0.27058823529412, b: 0.34509803921569},
|
||||
{name: 'Pale Lavender', r: 0.91764705882353, g: 0.90588235294118, b: 0.94901960784314},
|
||||
{name: 'Bluebell', r: 0.62352941176471, g: 0.65490196078431, b: 0.73725490196078},
|
||||
{name: 'Cool Gray No.0', r: 0.87843137254902, g: 0.90588235294118, b: 0.92941176470588},
|
||||
{name: 'Cool Gray No.00', r: 0.87843137254902, g: 0.90588235294118, b: 0.92941176470588},
|
||||
{name: 'Cool Gray No.1', r: 0.85490196078431, g: 0.89019607843137, b: 0.90980392156863},
|
||||
{name: 'Cool Gray No.10', r: 0.12549019607843, g: 0.16862745098039, b: 0.1921568627451},
|
||||
{name: 'Cool Gray No.2', r: 0.8, g: 0.84313725490196, b: 0.86666666666667},
|
||||
{name: 'Cool Gray No.3', r: 0.75686274509804, g: 0.8, b: 0.82352941176471},
|
||||
{name: 'Cool Gray No.4', r: 0.57254901960784, g: 0.62745098039216, b: 0.67058823529412},
|
||||
{name: 'Cool Gray No.5', r: 0.57254901960784, g: 0.62745098039216, b: 0.67058823529412},
|
||||
{name: 'Cool Gray No.6', r: 0.38823529411765, g: 0.43921568627451, b: 0.47450980392157},
|
||||
{name: 'Cool Gray No.7', r: 0.38823529411765, g: 0.43921568627451, b: 0.47450980392157},
|
||||
{name: 'Cool Gray No.8', r: 0.32549019607843, g: 0.36470588235294, b: 0.4},
|
||||
{name: 'Cool Gray No.9', r: 0.23529411764706, g: 0.27843137254902, b: 0.30196078431373},
|
||||
{name: 'Skin White', r: 0.9921568627451, g: 0.95294117647059, b: 0.91764705882353},
|
||||
{name: 'Pale Fruit Pink', r: 0.99607843137255, g: 0.96078431372549, b: 0.93333333333333},
|
||||
{name: 'Floral White', r: 1, g: 0.98039215686275, b: 0.95686274509804},
|
||||
{name: 'Pink Flamingo', r: 1, g: 0.93333333333333, b: 0.89411764705882},
|
||||
{name: 'Fruit Pink', r: 0.99607843137255, g: 0.92549019607843, b: 0.87843137254902},
|
||||
{name: 'Lipstick Natural', r: 0.89411764705882, g: 0.73725490196078, b: 0.76862745098039},
|
||||
{name: 'Light Mahogany', r: 0.8, g: 0.50588235294118, b: 0.4156862745098},
|
||||
{name: 'Brown', r: 0.7921568627451, g: 0.39607843137255, b: 0.32549019607843},
|
||||
{name: 'Burnt Sienna', r: 0.85098039215686, g: 0.4156862745098, b: 0.30980392156863},
|
||||
{name: 'Bareley Beige', r: 0.99607843137255, g: 0.91372549019608, b: 0.83921568627451},
|
||||
{name: 'Light Suntan', r: 0.91372549019608, g: 0.77254901960784, b: 0.68627450980392},
|
||||
{name: 'Dark Suntan', r: 0.9843137254902, g: 0.73333333333333, b: 0.55294117647059},
|
||||
{name: 'Reddish Brass', r: 0.72156862745098, g: 0.37254901960784, b: 0.34117647058824},
|
||||
{name: 'Copper', r: 0.53333333333333, g: 0.32549019607843, b: 0.30196078431373},
|
||||
{name: 'Redwood', r: 0.76862745098039, g: 0.32156862745098, b: 0.21960784313725},
|
||||
{name: 'Baby Skin Pink', r: 0.9921568627451, g: 0.88627450980392, b: 0.78039215686275},
|
||||
{name: 'Hazelnut', r: 0.92549019607843, g: 0.7921568627451, b: 0.69411764705882},
|
||||
{name: 'Caribe Cocoa', r: 0.82352941176471, g: 0.64313725490196, b: 0.50980392156863},
|
||||
{name: 'Africano', r: 0.6, g: 0.46274509803922, b: 0.38823529411765},
|
||||
{name: 'Burnt Umber', r: 0.53333333333333, g: 0.27450980392157, b: 0.21176470588235},
|
||||
{name: 'Bisque', r: 0.96862745098039, g: 0.94117647058824, b: 0.83921568627451},
|
||||
{name: 'Brick Beige', r: 0.94901960784314, g: 0.90196078431373, b: 0.8078431372549},
|
||||
{name: 'Sand', r: 0.95294117647059, g: 0.82352941176471, b: 0.69411764705882},
|
||||
{name: 'Orientale', r: 0.94117647058824, g: 0.7921568627451, b: 0.65098039215686},
|
||||
{name: 'Chamois', r: 0.90196078431373, g: 0.76470588235294, b: 0.63921568627451},
|
||||
{name: 'Sepia', r: 0.8, g: 0.56862745098039, b: 0.34901960784314},
|
||||
{name: 'Leather', r: 0.77254901960784, g: 0.45490196078431, b: 0.24705882352941},
|
||||
{name: 'Brick White', r: 0.94901960784314, g: 0.90980392156863, b: 0.86274509803922},
|
||||
{name: 'Pearl White', r: 0.99607843137255, g: 0.94509803921569, b: 0.88235294117647},
|
||||
{name: 'Sand White', r: 0.95294117647059, g: 0.91764705882353, b: 0.85098039215686},
|
||||
{name: 'Dull Ivory', r: 0.90980392156863, g: 0.85490196078431, b: 0.74117647058824},
|
||||
{name: 'Clay', r: 0.54117647058824, g: 0.43137254901961, b: 0.34901960784314},
|
||||
{name: 'Dark Brown', r: 0.54117647058824, g: 0.43137254901961, b: 0.34901960784314},
|
||||
{name: 'Dark Bark', r: 0.38823529411765, g: 0.29803921568627, b: 0.23529411764706},
|
||||
{name: 'Egg Shell', r: 0.95686274509804, g: 0.92156862745098, b: 0.94117647058824},
|
||||
{name: 'Milky White', r: 0.99607843137255, g: 0.92549019607843, b: 0.83921568627451},
|
||||
{name: 'Raw Silk', r: 0.94509803921569, g: 0.87450980392157, b: 0.72549019607843},
|
||||
{name: 'Light Camel', r: 0.94509803921569, g: 0.87450980392157, b: 0.72549019607843},
|
||||
{name: 'Light Walnut', r: 0.69411764705882, g: 0.52156862745098, b: 0.34509803921569},
|
||||
{name: 'Walnut', r: 0.60392156862745, g: 0.49803921568627, b: 0.42352941176471},
|
||||
{name: 'Ash Rose', r: 0.93725490196078, g: 0.91764705882353, b: 0.90196078431373},
|
||||
{name: 'Champagne', r: 0.63137254901961, g: 0.51764705882353, b: 0.48627450980392},
|
||||
{name: 'Cocoa Brown', r: 0.63137254901961, g: 0.51764705882353, b: 0.48627450980392},
|
||||
{name: 'Maroon', r: 0.49803921568627, g: 0.37647058823529, b: 0.30588235294118},
|
||||
{name: 'Cashew', r: 0.29019607843137, g: 0.17254901960784, b: 0.13333333333333},
|
||||
{name: 'Ivory', r: 0.94117647058824, g: 0.90196078431373, b: 0.76078431372549},
|
||||
{name: 'Khaki', r: 0.68235294117647, g: 0.62352941176471, b: 0.50196078431373},
|
||||
{name: 'Fig', r: 0.43529411764706, g: 0.37647058823529, b: 0.30196078431373},
|
||||
{name: 'Pecan', r: 0.35294117647059, g: 0.28627450980392, b: 0.22352941176471},
|
||||
{name: 'Tea Rose', r: 0.99607843137255, g: 0.82352941176471, b: 0.72549019607843},
|
||||
{name: 'Flesh Pink', r: 0.98823529411765, g: 0.73725490196078, b: 0.49411764705882},
|
||||
{name: 'Deep Orange', r: 0.70588235294118, g: 0.37647058823529, b: 0.20392156862745},
|
||||
{name: 'Baked Clay', r: 0.70588235294118, g: 0.37647058823529, b: 0.20392156862745},
|
||||
{name: 'Fluorescent Dull Blue', r: 0.019607843137255, g: 0.56078431372549, b: 0.8156862745098},
|
||||
{name: 'Fluorescent Dull Blue Green', r: 0.3843137254902, g: 0.79607843137255, b: 0.90980392156863},
|
||||
{name: 'Fluorescent Pink', r: 0.96078431372549, g: 0.63921568627451, b: 0.78039215686275},
|
||||
{name: 'Fluorescent Dull Violet', r: 0.49803921568627, g: 0.45490196078431, b: 0.71372549019608},
|
||||
{name: 'Fluorescent Yellow Orange', r: 1, g: 0.96470588235294, b: 0.5921568627451},
|
||||
{name: 'Fluorescent Yellow', r: 0.61960784313725, g: 0.80392156862745, b: 0.26274509803922},
|
||||
{name: 'Fluorescent Dull Yellow Green', r: 0.61960784313725, g: 0.80392156862745, b: 0.26274509803922},
|
||||
{name: 'Fluorescent Orange', r: 0.99607843137255, g: 0.8, b: 0.6},
|
||||
{name: 'Jade Green', r: 0.89019607843137, g: 0.94901960784314, b: 0.92941176470588},
|
||||
{name: 'Pale Green', r: 0.91764705882353, g: 0.96078431372549, b: 0.92941176470588},
|
||||
{name: 'Crystal Opal', r: 0.94509803921569, g: 0.96862745098039, b: 0.95294117647059},
|
||||
{name: 'Spectrum Green', r: 0.81176470588235, g: 0.90980392156863, b: 0.82745098039216},
|
||||
{name: 'Meadow Green', r: 0.71372549019608, g: 0.85490196078431, b: 0.61176470588235},
|
||||
{name: 'Emerald Green', r: 0.41176470588235, g: 0.75294117647059, b: 0.48235294117647},
|
||||
{name: 'Nile Green', r: 0.48235294117647, g: 0.77254901960784, b: 0.46274509803922},
|
||||
{name: 'Veronese Green', r: 0.47843137254902, g: 0.76862745098039, b: 0.39607843137255},
|
||||
{name: 'Sea Green', r: 0.82352941176471, g: 0.90980392156863, b: 0.76862745098039},
|
||||
{name: 'Apple Green', r: 0.5921568627451, g: 0.81176470588235, b: 0.56470588235294},
|
||||
{name: 'Malachite', r: 0.37647058823529, g: 0.75686274509804, b: 0.59607843137255},
|
||||
{name: 'Forest Green', r: 0.07843137254902, g: 0.70196078431373, b: 0.49019607843137},
|
||||
{name: 'Bright Parrot Green', r: 0.17647058823529, g: 0.72549019607843, b: 0.54117647058824},
|
||||
{name: 'Wax White', r: 0.92941176470588, g: 0.96470588235294, b: 0.85882352941176},
|
||||
{name: 'Lime Green', r: 0.76862745098039, g: 0.89411764705882, b: 0.80392156862745},
|
||||
{name: 'Willow', r: 0.76470588235294, g: 0.87843137254902, b: 0.70588235294118},
|
||||
{name: 'Ocean Green', r: 0.066666666666667, g: 0.58039215686275, b: 0.3843137254902},
|
||||
{name: 'Pine Tree Green', r: 0.098039215686275, g: 0.48627450980392, b: 0.36470588235294},
|
||||
{name: 'Dim Green', r: 0.89411764705882, g: 0.94509803921569, b: 0.87450980392157},
|
||||
{name: 'Pistachio', r: 0.84313725490196, g: 0.90588235294118, b: 0.65882352941176},
|
||||
{name: 'Mistletoe', r: 0.34117647058824, g: 0.61960784313725, b: 0.47058823529412},
|
||||
{name: 'Spring Dim Green', r: 0.8, g: 0.85490196078431, b: 0.72549019607843},
|
||||
{name: 'Verdigris', r: 0.6156862745098, g: 0.76470588235294, b: 0.66666666666667},
|
||||
{name: 'Grayish Olive', r: 0.59607843137255, g: 0.65490196078431, b: 0.52549019607843},
|
||||
{name: 'Olive', r: 0.37254901960784, g: 0.49411764705882, b: 0.22745098039216},
|
||||
{name: 'Neutral Gray No.0', r: 0.92549019607843, g: 0.93333333333333, b: 0.92941176470588},
|
||||
{name: 'Neutral Gray No.1', r: 0.88627450980392, g: 0.89019607843137, b: 0.89803921568627},
|
||||
{name: 'Neutral Gray No.10', r: 0.1921568627451, g: 0.1843137254902, b: 0.18823529411765},
|
||||
{name: 'Neutral Gray No.2', r: 0.85490196078431, g: 0.85882352941176, b: 0.86666666666667},
|
||||
{name: 'Neutral Gray No.3', r: 0.81960784313725, g: 0.82352941176471, b: 0.83137254901961},
|
||||
{name: 'Neutral Gray No.4', r: 0.73725490196078, g: 0.74117647058824, b: 0.75686274509804},
|
||||
{name: 'Neutral Gray No.5', r: 0.65882352941176, g: 0.66274509803922, b: 0.67843137254902},
|
||||
{name: 'Neutral Gray No.6', r: 0.58039215686275, g: 0.5843137254902, b: 0.6},
|
||||
{name: 'Neutral Gray No.7', r: 0.46666666666667, g: 0.47058823529412, b: 0.48627450980392},
|
||||
{name: 'Neutral Gray No.8', r: 0.38823529411765, g: 0.3921568627451, b: 0.4},
|
||||
{name: 'Neutral Gray No.9', r: 0.29803921568627, g: 0.30196078431373, b: 0.30980392156863},
|
||||
{name: 'Pinkish White', r: 0.99607843137255, g: 0.91764705882353, b: 0.88235294117647},
|
||||
{name: 'Cherry White', r: 0.99607843137255, g: 0.94117647058824, b: 0.90588235294118},
|
||||
{name: 'Pink Beryl', r: 0.99607843137255, g: 0.95294117647059, b: 0.93725490196078},
|
||||
{name: 'Pinkish Vanilla', r: 0.9921568627451, g: 0.87843137254902, b: 0.84705882352941},
|
||||
{name: 'Flesh', r: 0.9921568627451, g: 0.82745098039216, b: 0.78039215686275},
|
||||
{name: 'Salmon Red', r: 0.96470588235294, g: 0.56862745098039, b: 0.48235294117647},
|
||||
{name: 'Vermilion', r: 0.94901960784314, g: 0.40392156862745, b: 0.32941176470588},
|
||||
{name: 'Pale Cherry Pink', r: 0.9921568627451, g: 0.88235294117647, b: 0.83529411764706},
|
||||
{name: 'Light Tea Rose', r: 0.98823529411765, g: 0.82745098039216, b: 0.75686274509804},
|
||||
{name: 'Light Rouse', r: 0.96078431372549, g: 0.6078431372549, b: 0.57254901960784},
|
||||
{name: 'Lipstick Orange', r: 0.95686274509804, g: 0.51764705882353, b: 0.42352941176471},
|
||||
{name: 'Blush', r: 0.98823529411765, g: 0.84313725490196, b: 0.81176470588235},
|
||||
{name: 'Sardonyx', r: 0.98039215686275, g: 0.75686274509804, b: 0.71372549019608},
|
||||
{name: 'Light Prawn', r: 0.97254901960784, g: 0.71764705882353, b: 0.69411764705882},
|
||||
{name: 'Prawn', r: 0.94901960784314, g: 0.45882352941176, b: 0.47450980392157},
|
||||
{name: 'Cadmium Red', r: 0.94509803921569, g: 0.31372549019608, b: 0.3843137254902},
|
||||
{name: 'Lipstick Red', r: 0.92941176470588, g: 0.090196078431373, b: 0.29411764705882},
|
||||
{name: 'Pale Yellowish Pink', r: 0.98823529411765, g: 0.89019607843137, b: 0.87450980392157},
|
||||
{name: 'Peach', r: 0.98039215686275, g: 0.75686274509804, b: 0.72941176470588},
|
||||
{name: 'Coral', r: 0.94901960784314, g: 0.44313725490196, b: 0.52156862745098},
|
||||
{name: 'Carmine', r: 0.90980392156863, g: 0.42352941176471, b: 0.45490196078431},
|
||||
{name: 'Garnet', r: 0.79607843137255, g: 0.28235294117647, b: 0.47843137254902},
|
||||
{name: 'Bougainvillaea', r: 0.93333333333333, g: 0.51764705882353, b: 0.55686274509804},
|
||||
{name: 'Strong Red', r: 0.87843137254902, g: 0.30196078431373, b: 0.41176470588235},
|
||||
{name: 'Currant', r: 0.82352941176471, g: 0.48627450980392, b: 0.5843137254902},
|
||||
{name: 'Cardinal', r: 0.71764705882353, g: 0.30980392156863, b: 0.43921568627451},
|
||||
{name: 'Rose Pink', r: 0.94509803921569, g: 0.7843137254902, b: 0.83921568627451},
|
||||
{name: 'Rose Mist', r: 0.94509803921569, g: 0.61176470588235, b: 0.72549019607843},
|
||||
{name: 'Rose Red', r: 0.82745098039216, g: 0.4156862745098, b: 0.57647058823529},
|
||||
{name: 'Dark Red', r: 0.49019607843137, g: 0.16862745098039, b: 0.25882352941176},
|
||||
{name: 'Water Lily', r: 0.94509803921569, g: 0.85490196078431, b: 0.91764705882353},
|
||||
{name: 'Pale Purple', r: 0.95686274509804, g: 0.88627450980392, b: 0.93333333333333},
|
||||
{name: 'Evening Primrose', r: 0.94901960784314, g: 0.91764705882353, b: 0.96078431372549},
|
||||
{name: 'Sugared Almond Pink', r: 0.98039215686275, g: 0.83529411764706, b: 0.90196078431373},
|
||||
{name: 'Shock Pink', r: 0.96470588235294, g: 0.63921568627451, b: 0.74901960784314},
|
||||
{name: 'Cerise', r: 0.95294117647059, g: 0.52549019607843, b: 0.68627450980392},
|
||||
{name: 'Fuchsia', r: 0.88235294117647, g: 0.44313725490196, b: 0.67450980392157},
|
||||
{name: 'Pale Pink', r: 0.9921568627451, g: 0.92549019607843, b: 0.95686274509804},
|
||||
{name: 'Pink', r: 0.9843137254902, g: 0.83921568627451, b: 0.86666666666667},
|
||||
{name: 'Tender Pink', r: 0.97647058823529, g: 0.78823529411765, b: 0.84313725490196},
|
||||
{name: 'Begonia Pink', r: 0.95686274509804, g: 0.5843137254902, b: 0.71764705882353},
|
||||
{name: 'Deep Magenta', r: 0.85882352941176, g: 0.49411764705882, b: 0.70196078431373},
|
||||
{name: 'Red Violet', r: 0.82352941176471, g: 0.4078431372549, b: 0.66666666666667},
|
||||
{name: 'Light Pink', r: 0.9921568627451, g: 0.90980392156863, b: 0.90588235294118},
|
||||
{name: 'Pure Pink', r: 0.97254901960784, g: 0.72941176470588, b: 0.78823529411765},
|
||||
{name: 'Dog Rose Flower', r: 0.95686274509804, g: 0.57647058823529, b: 0.74509803921569},
|
||||
{name: 'Crimson', r: 0.93725490196078, g: 0.28235294117647, b: 0.50196078431373},
|
||||
{name: 'Shadow Pink', r: 0.98039215686275, g: 0.82745098039216, b: 0.8078431372549},
|
||||
{name: 'Dark Pink', r: 0.97647058823529, g: 0.68627450980392, b: 0.68235294117647},
|
||||
{name: 'Salmon Pink', r: 0.97254901960784, g: 0.73333333333333, b: 0.71372549019608},
|
||||
{name: 'Cotton Candy', r: 0.97647058823529, g: 0.7921568627451, b: 0.87058823529412},
|
||||
{name: 'Hollyhock', r: 0.91372549019608, g: 0.64705882352941, b: 0.7921568627451},
|
||||
{name: 'Begonia', r: 0.8156862745098, g: 0.6156862745098, b: 0.68235294117647},
|
||||
{name: 'Raspberry', r: 0.72156862745098, g: 0.4156862745098, b: 0.51764705882353},
|
||||
{name: 'Peony', r: 0.54509803921569, g: 0.34117647058824, b: 0.43137254901961},
|
||||
{name: 'Garyish Cherry', r: 0.90196078431373, g: 0.83137254901961, b: 0.88627450980392},
|
||||
{name: 'Smokey Purple', r: 0.90588235294118, g: 0.71372549019608, b: 0.8},
|
||||
{name: 'Baby Blossoms', r: 0.71372549019608, g: 0.51764705882353, b: 0.63137254901961},
|
||||
{name: 'Argyle Purple', r: 0.35294117647059, g: 0.28235294117647, b: 0.34509803921569},
|
||||
{name: 'Toner Gray No.0', r: 0.92549019607843, g: 0.93333333333333, b: 0.92941176470588},
|
||||
{name: 'Toner Gray No.1', r: 0.91764705882353, g: 0.91764705882353, b: 0.90980392156863},
|
||||
{name: 'Toner Gray No.10', r: 0.19607843137255, g: 0.18039215686275, b: 0.17647058823529},
|
||||
{name: 'Toner Gray No.2', r: 0.87843137254902, g: 0.87843137254902, b: 0.87058823529412},
|
||||
{name: 'Toner Gray No.3', r: 0.81960784313725, g: 0.82352941176471, b: 0.8},
|
||||
{name: 'Toner Gray No.4', r: 0.73725490196078, g: 0.73333333333333, b: 0.72549019607843},
|
||||
{name: 'Toner Gray No.5', r: 0.65882352941176, g: 0.65490196078431, b: 0.63921568627451},
|
||||
{name: 'Toner Gray No.6', r: 0.58039215686275, g: 0.5843137254902, b: 0.56470588235294},
|
||||
{name: 'Toner Gray No.7', r: 0.46666666666667, g: 0.46274509803922, b: 0.45490196078431},
|
||||
{name: 'Toner Gray No.8', r: 0.38823529411765, g: 0.3921568627451, b: 0.37254901960784},
|
||||
{name: 'Toner Gray No.9', r: 0.29803921568627, g: 0.29411764705882, b: 0.28627450980392},
|
||||
{name: 'Pale Heath', r: 0.91372549019608, g: 0.89803921568627, b: 0.95294117647059},
|
||||
{name: 'Rose Quartz', r: 0.94117647058824, g: 0.92941176470588, b: 0.96470588235294},
|
||||
{name: 'Heath', r: 0.89411764705882, g: 0.75686274509804, b: 0.85098039215686},
|
||||
{name: 'Lilac', r: 0.90196078431373, g: 0.66666666666667, b: 0.8078431372549},
|
||||
{name: 'Marigold', r: 0.88627450980392, g: 0.65098039215686, b: 0.7921568627451},
|
||||
{name: 'Lavender', r: 0.8078431372549, g: 0.5843137254902, b: 0.76078431372549},
|
||||
{name: 'Violet', r: 0.52941176470588, g: 0.32941176470588, b: 0.63137254901961},
|
||||
{name: 'Pale Lilac', r: 0.93333333333333, g: 0.84313725490196, b: 0.91372549019608},
|
||||
{name: 'Mallow', r: 0.82745098039216, g: 0.65098039215686, b: 0.80392156862745},
|
||||
{name: 'Amethyst', r: 0.62745098039216, g: 0.57254901960784, b: 0.78039215686275},
|
||||
{name: 'Wisteria', r: 0.88627450980392, g: 0.87843137254902, b: 0.92941176470588},
|
||||
{name: 'Ash Lavender', r: 0.69803921568627, g: 0.69411764705882, b: 0.8156862745098},
|
||||
{name: 'Pale Blackberry', r: 0.52156862745098, g: 0.49803921568627, b: 0.67843137254902},
|
||||
{name: 'Eggplant', r: 0.41960784313725, g: 0.4, b: 0.55686274509804},
|
||||
{name: 'Pale Grape', r: 0.90980392156863, g: 0.76862745098039, b: 0.8156862745098},
|
||||
{name: 'Early Grape', r: 0.89803921568627, g: 0.75686274509804, b: 0.85882352941176},
|
||||
{name: 'Light Grape', r: 0.71764705882353, g: 0.48627450980392, b: 0.65882352941176},
|
||||
{name: 'Aubergine', r: 0.32156862745098, g: 0.26274509803922, b: 0.34509803921569},
|
||||
{name: 'Warm Gray No.0', r: 0.92549019607843, g: 0.92549019607843, b: 0.89411764705882},
|
||||
{name: 'Warm Gray No.00', r: 0.95294117647059, g: 0.95294117647059, b: 0.92156862745098},
|
||||
{name: 'Warm Gray No.1', r: 0.90588235294118, g: 0.90588235294118, b: 0.87450980392157},
|
||||
{name: 'Warm Gray No.10', r: 0.18823529411765, g: 0.1843137254902, b: 0.16862745098039},
|
||||
{name: 'Warm Gray No.2', r: 0.86666666666667, g: 0.86666666666667, b: 0.83529411764706},
|
||||
{name: 'Warm Gray No.3', r: 0.82352941176471, g: 0.82352941176471, b: 0.7921568627451},
|
||||
{name: 'Warm Gray No.4', r: 0.73725490196078, g: 0.74117647058824, b: 0.71764705882353},
|
||||
{name: 'Warm Gray No.5', r: 0.65882352941176, g: 0.66274509803922, b: 0.64313725490196},
|
||||
{name: 'Warm Gray No.6', r: 0.58039215686275, g: 0.5843137254902, b: 0.56078431372549},
|
||||
{name: 'Warm Gray No.7', r: 0.46666666666667, g: 0.47058823529412, b: 0.45098039215686},
|
||||
{name: 'Warm Gray No.8', r: 0.38823529411765, g: 0.3921568627451, b: 0.37254901960784},
|
||||
{name: 'Warm Gray No.9', r: 0.29803921568627, g: 0.30196078431373, b: 0.28235294117647},
|
||||
{name: 'Barium Yellow', r: 0.99607843137255, g: 0.9921568627451, b: 0.87450980392157},
|
||||
{name: 'Pale Lemon', r: 1, g: 0.98823529411765, b: 0.91372549019608},
|
||||
{name: 'Yellow Fluorite', r: 0.99607843137255, g: 0.99607843137255, b: 0.95686274509804},
|
||||
{name: 'Canary Yellow', r: |