Crayon Syntax Highlighter - Version 2.0.0

Version Description

  • ADDED:
    • Theme Editor allowing users to create and modify Crayon Themes!
    • Polish translation (thanks to Bartosz Romanowski)
    • Vim language
    • Solarized themes (thanks to Greduan)
    • Converting legacy tags now has an "encode" option. If selected, any legacy tag where the "decode" attribute is missing (neither true or false) has its code encoded and decode="true" specified.
  • FIXED:
    • Removed fancybox_init.js and integrated into util.js, other minor improvements in loading Tag Editor
    • Improved expanding with shirt
    • Issues with expanding a single line, other minor issues.
    • Merged JS and PHP debugging toggle
    • Moved everything towards camelCase from underscores
    • Minor improvements to Objective-C
    • Numerous bug fixes and improvements!
Download this release

Release Info

Developer akarmenia
Plugin Icon wp plugin Crayon Syntax Highlighter
Version 2.0.0
Comparing to
See all releases

Code changes from version 1.17 to 2.0.0

Files changed (76) hide show
  1. crayon_highlighter.class.php +8 -8
  2. crayon_resource.class.php +79 -44
  3. crayon_settings.class.php +21 -3
  4. crayon_settings_wp.class.php +1087 -1055
  5. crayon_themes.class.php +51 -8
  6. crayon_wp.class.php +39 -14
  7. css/admin_style.css +37 -2
  8. global.php +7 -9
  9. js/crayon.js +263 -239
  10. js/crayon_admin.js +231 -85
  11. js/cssjson.js +130 -103
  12. js/jquery-colorpicker/README +231 -0
  13. js/jquery-colorpicker/TODO +20 -0
  14. js/jquery-colorpicker/i18n/jquery.ui.colorpicker-en.js +27 -0
  15. js/jquery-colorpicker/i18n/jquery.ui.colorpicker-fr.js +27 -0
  16. js/jquery-colorpicker/i18n/jquery.ui.colorpicker-nl.js +27 -0
  17. js/jquery-colorpicker/images/bar-alpha.png +0 -0
  18. js/jquery-colorpicker/images/bar-opacity.png +0 -0
  19. js/jquery-colorpicker/images/bar-pointer.png +0 -0
  20. js/jquery-colorpicker/images/bar.png +0 -0
  21. js/jquery-colorpicker/images/map-opacity.png +0 -0
  22. js/jquery-colorpicker/images/map-pointer.png +0 -0
  23. js/jquery-colorpicker/images/map.png +0 -0
  24. js/jquery-colorpicker/images/preview-opacity.png +0 -0
  25. js/jquery-colorpicker/images/ui-colorpicker.png +0 -0
  26. js/jquery-colorpicker/index.html +210 -0
  27. js/jquery-colorpicker/jquery.colorpicker.css +199 -0
  28. js/jquery-colorpicker/jquery.colorpicker.js +2550 -0
  29. js/jquery-ui/jquery-ui.css +8 -8
  30. js/test.html +14 -0
  31. js/tinycolor-min.js +21 -0
  32. js/util.js +263 -156
  33. langs/applescript/.DS_Store +0 -0
  34. langs/default/default.txt +7 -7
  35. langs/delphi/.DS_Store +0 -0
  36. langs/objc/objc.txt +9 -7
  37. langs/php/php.txt +1 -1
  38. langs/readme.txt +4 -0
  39. langs/vim/statement.txt +180 -0
  40. langs/vim/vim.txt +20 -0
  41. readme.txt +23 -1
  42. screenshot-5.png +0 -0
  43. themes/ado/ado.css +197 -172
  44. themes/classic/classic.css +171 -176
  45. themes/epicgeeks/epicgeeks.css +185 -239
  46. themes/neon/neon.css +200 -186
  47. themes/solarized-dark/solarized-dark.css +111 -96
  48. themes/solarized-light/solarized-light.css +197 -0
  49. themes/son-of-obsidian/son-of-obsidian.css +188 -0
  50. themes/twilight/twilight.css +195 -184
  51. trans/crayon-syntax-highlighter-pl_PL.mo +0 -0
  52. trans/crayon-syntax-highlighter-pl_PL.po +1014 -0
  53. util/ajax.php +0 -20
  54. util/crayon_util.class.php +793 -538
  55. util/{exceptions.php → depreciated/exceptions.php} +0 -0
  56. util/external_use.php +4 -4
  57. util/list_langs.php +0 -28
  58. util/list_posts.php +0 -27
  59. util/preview.php +0 -68
  60. util/sample/vim.txt +12 -0
  61. util/scraper/readme.txt +1 -0
  62. util/tag-editor/crayon_tag_editor_wp.class.php +8 -3
  63. util/tag-editor/crayon_te.js +14 -14
  64. util/theme-editor/images/button-pressed.png +0 -0
  65. util/theme-editor/images/button.png +0 -0
  66. util/theme-editor/images/frame.png +0 -0
  67. util/theme-editor/images/highlighting.png +0 -0
  68. util/theme-editor/images/information.png +0 -0
  69. util/theme-editor/images/lines.png +0 -0
  70. util/theme-editor/images/numbers.png +0 -0
  71. util/theme-editor/images/title.png +0 -0
  72. util/theme-editor/images/toolbar.png +0 -0
  73. util/theme-editor/theme_editor.css +279 -4
  74. util/theme-editor/theme_editor.js +623 -11
  75. util/theme-editor/theme_editor.php +862 -17
  76. util/theme-editor/theme_editor_content.php +0 -109
crayon_highlighter.class.php CHANGED
@@ -64,7 +64,7 @@ class CrayonHighlighter {
64
  }
65
  $url = CrayonUtil::pathf($url);
66
  $local = FALSE; // Whether to read locally
67
- $site_http = CrayonGlobalSettings::site_http();
68
  $site_path = CrayonGlobalSettings::site_path();
69
  $scheme = parse_url($url, PHP_URL_SCHEME);
70
 
@@ -227,13 +227,13 @@ class CrayonHighlighter {
227
  $code = preg_replace("#(?:^\\s*\\r?\\n)|(?:\\r?\\n\\s*$)#", '', $code);
228
  }
229
 
230
- $before = $this->setting_val(CrayonSettings::WHITESPACE_BEFORE);
231
- if ($before > 0) {
232
- $code = str_repeat("\n", $before) . $code;
233
- }
234
- $after = $this->setting_val(CrayonSettings::WHITESPACE_AFTER);
235
- if ($after > 0) {
236
- $code = $code . str_repeat("\n", $after);
237
  }
238
 
239
  if (!empty($code)) {
64
  }
65
  $url = CrayonUtil::pathf($url);
66
  $local = FALSE; // Whether to read locally
67
+ $site_http = CrayonGlobalSettings::site_url();
68
  $site_path = CrayonGlobalSettings::site_path();
69
  $scheme = parse_url($url, PHP_URL_SCHEME);
70
 
227
  $code = preg_replace("#(?:^\\s*\\r?\\n)|(?:\\r?\\n\\s*$)#", '', $code);
228
  }
229
 
230
+ $before = $this->setting_val(CrayonSettings::WHITESPACE_BEFORE);
231
+ if ($before > 0) {
232
+ $code = str_repeat("\n", $before) . $code;
233
+ }
234
+ $after = $this->setting_val(CrayonSettings::WHITESPACE_AFTER);
235
+ if ($after > 0) {
236
+ $code = $code . str_repeat("\n", $after);
237
  }
238
 
239
  if (!empty($code)) {
crayon_resource.class.php CHANGED
@@ -11,30 +11,24 @@ class CrayonResources {
11
 
12
  private function __construct() {}
13
 
14
- private static function init() {
15
- if (self::$langs == NULL) {
16
- self::$langs = new CrayonLangs();
17
- }
18
- if (self::$themes == NULL) {
19
- self::$themes = new CrayonThemes();
20
- }
21
- if (self::$fonts == NULL) {
22
- self::$fonts = new CrayonFonts();
23
- }
24
- }
25
-
26
  public static function langs() {
27
- self::init();
 
 
28
  return self::$langs;
29
  }
30
 
31
  public static function themes() {
32
- self::init();
 
 
33
  return self::$themes;
34
  }
35
 
36
  public static function fonts() {
37
- self::init();
 
 
38
  return self::$fonts;
39
  }
40
  }
@@ -64,7 +58,7 @@ class CrayonResourceCollection {
64
  return '';
65
  }
66
 
67
- /* Verifies a language exists. */
68
  public function exists($id) {
69
  return file_exists($this->path($id));
70
  }
@@ -81,25 +75,27 @@ class CrayonResourceCollection {
81
  $this->state = self::LOADED;
82
  }
83
 
84
- public function load_resources() {
85
- // Load only once
 
 
86
 
87
  if (!$this->is_state_loading()) {
 
88
  return;
89
  }
90
  try {
91
  // Look in directory for resources
92
 
93
- if (!file_exists($this->dir)) {
94
- CrayonLog::syslog('The resource directory is missing, should be at \'' . $this->dir . '\'.');
95
- } else if (($handle = @opendir($this->dir)) != FALSE) {
96
  // Loop over directory contents
97
-
98
  while (($file = readdir($handle)) !== FALSE) {
99
  if ($file != "." && $file != "..") {
100
  // Check if $file is directory, remove extension when checking for existence.
101
 
102
- if (!is_dir($this->dir . $file)) {
103
  $file = CrayonUtil::path_rem_ext($file);
104
  }
105
  if ($this->exists($file)) {
@@ -153,11 +149,6 @@ class CrayonResourceCollection {
153
  public function resource_instance($id, $name = NULL) {
154
  return new CrayonResource($id, $name);
155
  }
156
-
157
- // /* Override in subclasses to clean differently */
158
- // public function clean_id($id) {
159
- // return CrayonUtil::space_to_hyphen( strtolower(trim($id)) );
160
- // }
161
 
162
  public function add($id, $resource) {
163
  if (is_string($id) && !empty($id)) {
@@ -223,19 +214,20 @@ class CrayonResourceCollection {
223
  }
224
 
225
  public function directory($dir = NULL) {
226
- $dir = CrayonUtil::path_slash($dir);
227
- if (!CrayonUtil::str($this->dir, $dir, FALSE)) {
228
- return $this->dir;
229
- }
 
230
  }
231
 
232
  public function get_url($id) {
233
  return '';
234
  }
235
 
236
- public function get_css($id) {
237
  $resource = $this->get($id);
238
- return '<link rel="stylesheet" type="text/css" href="' . $this->get_url($resource->id()) . '" />' . CRAYON_NL;
239
  }
240
  }
241
 
@@ -295,12 +287,45 @@ class CrayonUsedResourceCollection extends CrayonResourceCollection {
295
  }
296
  }
297
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
298
  class CrayonResource {
299
  private $id = '';
300
  private $name = '';
301
 
302
  function __construct($id, $name = NULL) {
303
- $id = $this->clean_id($id);
304
  CrayonUtil::str($this->id, $id);
305
  ( empty($name) ) ? $this->name( $this->clean_name($this->id) ) : $this->name($name);
306
  }
@@ -322,26 +347,23 @@ class CrayonResource {
322
  }
323
 
324
  // Override
325
- function clean_id($id) {
326
- return CrayonUtil::space_to_hyphen( strtolower(trim($id)) );
 
327
  }
328
 
329
  // Override
330
- function clean_name($id) {
331
  $id = CrayonUtil::hyphen_to_space( strtolower(trim($id)) );
332
  return CrayonUtil::ucwords($id);
333
  }
334
 
335
  }
336
 
337
- /* Keeps track of usage */
338
  class CrayonUsedResource extends CrayonResource {
 
339
  private $used = FALSE;
340
 
341
- function __construct($id, $name = NULL) {
342
- parent::__construct($id, $name);
343
- }
344
-
345
  function used($used = NULL) {
346
  if ($used === NULL) {
347
  return $this->used;
@@ -351,8 +373,21 @@ class CrayonUsedResource extends CrayonResource {
351
  }
352
  }
353
 
354
- /* Adds version */
 
 
 
 
 
 
 
 
 
 
 
 
355
  class CrayonVersionResource extends CrayonResource {
 
356
  private $version = '';
357
 
358
  function __construct($id, $name = NULL, $version = NULL) {
11
 
12
  private function __construct() {}
13
 
 
 
 
 
 
 
 
 
 
 
 
 
14
  public static function langs() {
15
+ if (self::$langs == NULL) {
16
+ self::$langs = new CrayonLangs();
17
+ }
18
  return self::$langs;
19
  }
20
 
21
  public static function themes() {
22
+ if (self::$themes == NULL) {
23
+ self::$themes = new CrayonThemes();
24
+ }
25
  return self::$themes;
26
  }
27
 
28
  public static function fonts() {
29
+ if (self::$fonts == NULL) {
30
+ self::$fonts = new CrayonFonts();
31
+ }
32
  return self::$fonts;
33
  }
34
  }
58
  return '';
59
  }
60
 
61
+ /* Verifies a resource exists. */
62
  public function exists($id) {
63
  return file_exists($this->path($id));
64
  }
75
  $this->state = self::LOADED;
76
  }
77
 
78
+ public function load_resources($dir = NULL) {
79
+ if ($dir === NULL) {
80
+ $dir = $this->dir;
81
+ }
82
 
83
  if (!$this->is_state_loading()) {
84
+ // Load only once
85
  return;
86
  }
87
  try {
88
  // Look in directory for resources
89
 
90
+ if (!is_dir($dir)) {
91
+ CrayonLog::syslog('The resource directory is missing, should be at \'' . $dir . '\'.');
92
+ } else if (($handle = @opendir($dir)) != FALSE) {
93
  // Loop over directory contents
 
94
  while (($file = readdir($handle)) !== FALSE) {
95
  if ($file != "." && $file != "..") {
96
  // Check if $file is directory, remove extension when checking for existence.
97
 
98
+ if (!is_dir($dir . $file)) {
99
  $file = CrayonUtil::path_rem_ext($file);
100
  }
101
  if ($this->exists($file)) {
149
  public function resource_instance($id, $name = NULL) {
150
  return new CrayonResource($id, $name);
151
  }
 
 
 
 
 
152
 
153
  public function add($id, $resource) {
154
  if (is_string($id) && !empty($id)) {
214
  }
215
 
216
  public function directory($dir = NULL) {
217
+ if ($dir === NULL) {
218
+ return $this->dir;
219
+ } else {
220
+ $this->dir = CrayonUtil::path_slash($dir);
221
+ }
222
  }
223
 
224
  public function get_url($id) {
225
  return '';
226
  }
227
 
228
+ public function get_css($id, $ver = NULL) {
229
  $resource = $this->get($id);
230
+ return '<link rel="stylesheet" type="text/css" href="' . $this->get_url($resource->id()) . ($ver ? "?ver=$ver" : '') . '" />' . CRAYON_NL;
231
  }
232
  }
233
 
287
  }
288
  }
289
 
290
+ class CrayonUserResourceCollection extends CrayonUsedResourceCollection {
291
+ private $user_dir = '';
292
+ private $curr_dir = NULL;
293
+
294
+ // XXX Override
295
+ public function resource_instance($id, $name = NULL) {
296
+ $resource = new CrayonUserResource($id, $name);
297
+ $resource->user($this->curr_dir == $this->user_directory());
298
+ return $resource;
299
+ }
300
+
301
+ public function user_directory($dir = NULL) {
302
+ if ($dir === NULL) {
303
+ return $this->user_dir;
304
+ } else {
305
+ $this->user_dir = CrayonUtil::path_slash($dir);
306
+ }
307
+ }
308
+
309
+ public function load_resources($dir = NULL) {
310
+ $this->curr_dir = $this->directory();
311
+ parent::load_resources($this->curr_dir);
312
+ $this->curr_dir = $this->user_directory();
313
+ parent::load_resources($this->curr_dir);
314
+ $this->curr_dir = NULL;
315
+ }
316
+
317
+ public function current_directory() {
318
+ return $this->curr_dir;
319
+ }
320
+
321
+ }
322
+
323
  class CrayonResource {
324
  private $id = '';
325
  private $name = '';
326
 
327
  function __construct($id, $name = NULL) {
328
+ $id = self::clean_id($id);
329
  CrayonUtil::str($this->id, $id);
330
  ( empty($name) ) ? $this->name( $this->clean_name($this->id) ) : $this->name($name);
331
  }
347
  }
348
 
349
  // Override
350
+ static function clean_id($id) {
351
+ $id = CrayonUtil::space_to_hyphen( strtolower(trim($id)) );
352
+ return preg_replace('#[^\w-]#msi', '', $id);
353
  }
354
 
355
  // Override
356
+ static function clean_name($id) {
357
  $id = CrayonUtil::hyphen_to_space( strtolower(trim($id)) );
358
  return CrayonUtil::ucwords($id);
359
  }
360
 
361
  }
362
 
 
363
  class CrayonUsedResource extends CrayonResource {
364
+ // Keeps track of usage
365
  private $used = FALSE;
366
 
 
 
 
 
367
  function used($used = NULL) {
368
  if ($used === NULL) {
369
  return $this->used;
373
  }
374
  }
375
 
376
+ class CrayonUserResource extends CrayonUsedResource {
377
+ // Keeps track of user modifications
378
+ private $user = FALSE;
379
+
380
+ function user($user = NULL) {
381
+ if ($user === NULL) {
382
+ return $this->user;
383
+ } else {
384
+ $this->user = ($user ? TRUE : FALSE);
385
+ }
386
+ }
387
+ }
388
+
389
  class CrayonVersionResource extends CrayonResource {
390
+ // Adds version
391
  private $version = '';
392
 
393
  function __construct($id, $name = NULL, $version = NULL) {
crayon_settings.class.php CHANGED
@@ -207,7 +207,7 @@ class CrayonSettings {
207
  new CrayonSetting(self::CACHE, array_keys(self::$cache_array), 1),
208
  new CrayonSetting(self::EFFICIENT_ENQUEUE, FALSE),
209
  new CrayonSetting(self::CAPTURE_PRE, TRUE),
210
- new CrayonSetting(self::CAPTURE_MINI_TAG, TRUE),
211
  new CrayonSetting(self::MIXED, TRUE),
212
  new CrayonSetting(self::SHOW_MIXED, TRUE),
213
  new CrayonSetting(self::PLAIN_TAG, TRUE),
@@ -215,7 +215,7 @@ class CrayonSettings {
215
  new CrayonSetting(self::ENQUEUE_FONTS, TRUE),
216
  new CrayonSetting(self::MAIN_QUERY, FALSE),
217
  new CrayonSetting(self::SAFE_ENQUEUE, TRUE),
218
- new CrayonSetting(self::INLINE_TAG, TRUE),
219
  new CrayonSetting(self::INLINE_MARGIN, 5),
220
  new CrayonSetting(self::INLINE_WRAP, TRUE),
221
  new CrayonSetting(self::BACKQUOTE, TRUE),
@@ -537,6 +537,8 @@ class CrayonGlobalSettings {
537
  private static $site_path = '';
538
  // The absolute root directory of the plugins (eg. /User/example/plugins)
539
  private static $plugin_path = '';
 
 
540
  private function __construct() {}
541
 
542
  private static function init() {
@@ -575,7 +577,7 @@ class CrayonGlobalSettings {
575
  self::$global->set($name, $value, $replace);
576
  }
577
 
578
- public static function site_http($site_http = NULL) {
579
  if ($site_http === NULL) {
580
  return self::$site_http;
581
  } else {
@@ -598,6 +600,22 @@ class CrayonGlobalSettings {
598
  self::$plugin_path = CrayonUtil::path_slash($plugin_path);
599
  }
600
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
601
  }
602
 
603
  /**
207
  new CrayonSetting(self::CACHE, array_keys(self::$cache_array), 1),
208
  new CrayonSetting(self::EFFICIENT_ENQUEUE, FALSE),
209
  new CrayonSetting(self::CAPTURE_PRE, TRUE),
210
+ new CrayonSetting(self::CAPTURE_MINI_TAG, FALSE),
211
  new CrayonSetting(self::MIXED, TRUE),
212
  new CrayonSetting(self::SHOW_MIXED, TRUE),
213
  new CrayonSetting(self::PLAIN_TAG, TRUE),
215
  new CrayonSetting(self::ENQUEUE_FONTS, TRUE),
216
  new CrayonSetting(self::MAIN_QUERY, FALSE),
217
  new CrayonSetting(self::SAFE_ENQUEUE, TRUE),
218
+ new CrayonSetting(self::INLINE_TAG, FALSE),
219
  new CrayonSetting(self::INLINE_MARGIN, 5),
220
  new CrayonSetting(self::INLINE_WRAP, TRUE),
221
  new CrayonSetting(self::BACKQUOTE, TRUE),
537
  private static $site_path = '';
538
  // The absolute root directory of the plugins (eg. /User/example/plugins)
539
  private static $plugin_path = '';
540
+ private static $upload_path = '';
541
+ private static $upload_url = '';
542
  private function __construct() {}
543
 
544
  private static function init() {
577
  self::$global->set($name, $value, $replace);
578
  }
579
 
580
+ public static function site_url($site_http = NULL) {
581
  if ($site_http === NULL) {
582
  return self::$site_http;
583
  } else {
600
  self::$plugin_path = CrayonUtil::path_slash($plugin_path);
601
  }
602
  }
603
+
604
+ public static function upload_path($upload_path = NULL) {
605
+ if ($upload_path === NULL) {
606
+ return self::$upload_path;
607
+ } else {
608
+ self::$upload_path = CrayonUtil::path_slash($upload_path);
609
+ }
610
+ }
611
+
612
+ public static function upload_url($upload_url = NULL) {
613
+ if ($upload_url === NULL) {
614
+ return self::$upload_url;
615
+ } else {
616
+ self::$upload_url = CrayonUtil::url_slash($upload_url);
617
+ }
618
+ }
619
  }
620
 
621
  /**
crayon_settings_wp.class.php CHANGED
@@ -9,615 +9,637 @@ require_once (CRAYON_SETTINGS_PHP);
9
  CrayonHighlighter and any non-WP classes will only use CrayonSettings to separate
10
  the implementation of global settings and ensure any system can use them. */
11
  class CrayonSettingsWP {
12
- // Properties and Constants ===============================================
13
-
14
- // A copy of the current options in db
15
- private static $options = NULL;
16
- // Posts containing crayons in db
17
- private static $crayon_posts = NULL;
18
- // Posts containing legacy tags in db
19
- private static $crayon_legacy_posts = NULL;
20
- // An array of cache names for use with Transients API
21
- private static $cache = NULL;
22
- // Array of settings to pass to js
23
- private static $js_settings = NULL;
24
- private static $admin_js_settings = NULL;
25
- private static $admin_page = '';
26
- private static $is_fully_loaded = FALSE;
27
-
28
- const SETTINGS = 'crayon_fields';
29
- const FIELDS = 'crayon_settings';
30
- const OPTIONS = 'crayon_options';
31
- const POSTS = 'crayon_posts';
32
- const LEGACY_POSTS = 'crayon_legacy_posts';
33
- const CACHE = 'crayon_cache';
34
- const GENERAL = 'crayon_general';
35
- const DEBUG = 'crayon_debug';
36
- const ABOUT = 'crayon_about';
37
-
38
- // Used on submit
39
- const LOG_CLEAR = 'log_clear';
40
- const LOG_EMAIL_ADMIN = 'log_email_admin';
41
- const LOG_EMAIL_DEV = 'log_email_dev';
42
-
43
- private function __construct() {
44
- }
45
-
46
- // Methods ================================================================
47
-
48
- public static function admin_load() {
49
- self::$admin_page = $admin_page = add_options_page('Crayon Syntax Highlighter '.crayon__('Settings'), 'Crayon', 'manage_options', 'crayon_settings', 'CrayonSettingsWP::settings');
50
- add_action("admin_print_scripts-$admin_page", 'CrayonSettingsWP::admin_scripts');
51
- add_action("admin_print_styles-$admin_page", 'CrayonSettingsWP::admin_styles');
52
- // Register settings, second argument is option name stored in db
53
- register_setting(self::FIELDS, self::OPTIONS, 'CrayonSettingsWP::settings_validate');
54
- add_action("admin_head-$admin_page", 'CrayonSettingsWP::admin_init');
55
- // Register settings for post page
56
- add_action("admin_print_styles-post-new.php", 'CrayonSettingsWP::admin_scripts');
57
- add_action("admin_print_styles-post.php", 'CrayonSettingsWP::admin_scripts');
58
- add_action("admin_print_styles-post-new.php", 'CrayonSettingsWP::admin_styles');
59
- add_action("admin_print_styles-post.php", 'CrayonSettingsWP::admin_styles');
60
-
61
- // TODO depreciated since WP 3.3, remove eventually
62
- global $wp_version;
63
- if ($wp_version >= '3.3') {
64
- add_action("load-$admin_page", 'CrayonSettingsWP::help_screen');
65
- } else {
66
- add_filter('contextual_help', 'CrayonSettingsWP::cont_help', 10, 3);
67
- }
68
- }
69
-
70
- public static function admin_styles() {
71
- global $CRAYON_VERSION;
72
- wp_enqueue_style('crayon', plugins_url(CRAYON_STYLE, __FILE__), array(), $CRAYON_VERSION);
73
- wp_enqueue_style('crayon_global', plugins_url(CRAYON_STYLE_GLOBAL, __FILE__), array(), $CRAYON_VERSION);
74
- wp_enqueue_style('crayon_admin', plugins_url(CRAYON_STYLE_ADMIN, __FILE__), array(), $CRAYON_VERSION);
75
- wp_enqueue_style('crayon_theme_editor', plugins_url(CRAYON_THEME_EDITOR_STYLE, __FILE__), array(), $CRAYON_VERSION);
76
- }
77
-
78
- public static function admin_scripts() {
79
- global $CRAYON_VERSION;
80
- wp_enqueue_script('crayon_util_js', plugins_url(CRAYON_JS_UTIL, __FILE__), array('jquery'), $CRAYON_VERSION);
81
- self::init_js_settings();
82
- if (is_admin()) {
83
- wp_enqueue_script('crayon_admin_js', plugins_url(CRAYON_JS_ADMIN, __FILE__), array('jquery', 'crayon_util_js'), $CRAYON_VERSION);
84
- self::init_admin_js_settings();
85
- }
86
- self::other_scripts();
87
- }
88
-
89
- public static function other_scripts() {
90
- global $CRAYON_VERSION;
91
- self::load_settings(TRUE);
92
- $deps = array('jquery', 'crayon_util_js');
93
- if (CrayonGlobalSettings::val(CrayonSettings::POPUP) || is_admin()) {
94
- wp_enqueue_script('crayon_jquery_popup', plugins_url(CRAYON_JQUERY_POPUP, __FILE__), array('jquery'), $CRAYON_VERSION);
95
- $deps[] = 'crayon_jquery_popup';
96
- }
97
- wp_enqueue_script('crayon_js', plugins_url(CRAYON_JS, __FILE__), $deps, $CRAYON_VERSION);
98
- }
99
-
100
- public static function init_js_settings() {
101
- // This stores JS variables used in AJAX calls and in the JS files
102
- self::load_settings(TRUE);
103
- if (!self::$js_settings) {
104
- self::$js_settings = array(
105
- 'is_admin' => intval(is_admin()),
106
- 'ajaxurl' => admin_url('admin-ajax.php'),
107
- 'prefix' => CrayonSettings::PREFIX,
108
- 'setting' => CrayonSettings::SETTING,
109
- 'selected' => CrayonSettings::SETTING_SELECTED,
110
- 'changed' => CrayonSettings::SETTING_CHANGED,
111
- 'special' => CrayonSettings::SETTING_SPECIAL,
112
- 'orig_value' => CrayonSettings::SETTING_ORIG_VALUE
113
- );
114
- wp_localize_script('crayon_util_js', 'CrayonSyntaxSettings', self::$js_settings);
115
- }
116
- }
117
-
118
- public static function init_admin_js_settings() {
119
- if (!self::$admin_js_settings) {
120
- $themes_ = CrayonResources::themes()->get();
121
- $themes = array();
122
- foreach ($themes_ as $theme) {
123
- $themes[$theme->id()] = $theme->name();
124
- }
125
- self::$admin_js_settings = array(
126
- 'themes' => $themes,
127
- 'themes_url' => plugins_url(CRAYON_THEME_DIR, __FILE__)
128
- );
129
- wp_localize_script('crayon_admin_js', 'CrayonAdminSettings', self::$admin_js_settings);
130
- }
131
- }
132
-
133
- public static function settings() {
134
- if (!current_user_can('manage_options')) {
135
- wp_die(crayon__('You do not have sufficient permissions to access this page.'));
136
- }
137
- // Go through and find all Crayons in posts on each reload
138
- //self::scan_and_save_posts();
139
-
140
- ?>
141
-
142
- <script type="text/javascript">
143
- jQuery(document).ready(function() {
144
- CrayonSyntaxAdmin.init();
145
- });
146
- </script>
147
-
148
-
149
- <div id="crayon-main-wrap" class="wrap">
150
-
151
- <div id="icon-options-general" class="icon32">
152
- <br>
153
- </div>
154
- <h2>
155
- Crayon Syntax Highlighter
156
- <?php crayon_e('Settings'); ?>
157
- </h2>
158
- <?php self::help(); ?>
159
- <form id="crayon-settings-form" action="options.php" method="post">
160
- <?php
161
- settings_fields(self::FIELDS);
162
- ?>
163
-
164
- <?php
165
- do_settings_sections(self::SETTINGS);
166
- ?>
167
-
168
- <p class="submit">
169
- <input type="submit" name="submit" id="submit" class="button-primary"
170
- value="<?php
171
- crayon_e('Save Changes');
172
- ?>"> <input type="submit"
173
- name="<?php
174
- echo self::OPTIONS;
175
- ?>[reset]" id="reset"
176
- class="button-primary"
177
- value="<?php
178
- crayon_e('Reset Settings');
179
- ?>">
180
- </p>
181
- </form>
182
- </div>
183
-
184
- <div
185
- id="crayon-theme-editor-wrap" class="wrap"
186
- url="<?php echo plugins_url(CRAYON_THEME_EDITOR_CONTENT_PHP, __FILE__); ?>"></div>
187
-
188
- <?php
189
- }
190
-
191
- // Load the global settings and update them from the db
192
- public static function load_settings($just_load_settings = FALSE) {
193
- if (self::$options === NULL) {
194
- // Load settings from db
195
- if (!(self::$options = get_option(self::OPTIONS))) {
196
- self::$options = CrayonSettings::get_defaults_array();
197
- update_option(self::OPTIONS, self::$options);
198
- }
199
- // Initialise default global settings and update them from db
200
- CrayonGlobalSettings::set(self::$options);
201
- }
202
-
203
- if (!self::$is_fully_loaded && !$just_load_settings) {
204
- // Load everything else as well
205
- // Load all available languages and themes
206
- CrayonResources::langs()->load();
207
- CrayonResources::themes()->load();
208
-
209
- // For local file loading
210
- // This is used to decouple WP functions from internal Crayon classes
211
- CrayonGlobalSettings::site_http(home_url());
212
- CrayonGlobalSettings::site_path(ABSPATH);
213
- CrayonGlobalSettings::plugin_path(plugins_url('', __FILE__));
214
-
215
- // Ensure all missing settings in db are replaced by default values
216
- $changed = FALSE;
217
- foreach (CrayonSettings::get_defaults_array() as $name => $value) {
218
- // Add missing settings
219
- if (!array_key_exists($name, self::$options)) {
220
- self::$options[$name] = $value;
221
- $changed = TRUE;
222
- }
223
- }
224
- // A setting was missing, update options
225
- if ($changed) {
226
- update_option(self::OPTIONS, self::$options);
227
- }
228
-
229
- self::$is_fully_loaded = TRUE;
230
- }
231
- }
232
-
233
- public static function get_settings() {
234
- return get_option(self::OPTIONS);
235
- }
236
-
237
- // Saves settings from CrayonGlobalSettings, or provided array, to the db
238
- public static function save_settings($settings = NULL) {
239
- if ($settings === NULL) {
240
- $settings = CrayonGlobalSettings::get_array();
241
- }
242
- update_option(self::OPTIONS, $settings);
243
- }
244
-
245
- // Crayon posts
246
-
247
- /**
248
- * This loads the posts marked as containing Crayons
249
- */
250
- public static function load_posts() {
251
- if (self::$crayon_posts === NULL) {
252
- // Load from db
253
- if (!(self::$crayon_posts = get_option(self::POSTS))) {
254
- // Posts don't exist! Scan for them. This will fill self::$crayon_posts
255
- self::$crayon_posts = CrayonWP::scan_posts();
256
- update_option(self::POSTS, self::$crayon_posts);
257
- }
258
- }
259
- return self::$crayon_posts;
260
- }
261
-
262
- /**
263
- * This looks through all posts and marks those which contain Crayons
264
- */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
265
  // public static function scan_and_save_posts() {
266
  // self::save_posts(CrayonWP::scan_posts(TRUE, TRUE));
267
  // }
268
 
269
- /**
270
- * Saves the marked posts to the db
271
- */
272
- public static function save_posts($posts = NULL) {
273
- if ($posts === NULL) {
274
- $posts = self::$crayon_posts;
275
- }
276
- update_option(self::POSTS, $posts);
277
- self::load_posts();
278
- }
279
-
280
- /**
281
- * Adds a post as containing a Crayon
282
- */
283
- public static function add_post($id) {
284
- self::load_posts();
285
- if (!in_array($id, self::$crayon_posts)) {
286
- self::$crayon_posts[] = $id;
287
- }
288
- self::save_posts();
289
- }
290
-
291
- /**
292
- * Removes a post as not containing a Crayon
293
- */
294
- public static function remove_post($id) {
295
- self::load_posts();
296
- $key = array_search($id, self::$crayon_posts);
297
- if ($key === false) {
298
- return;
299
- }
300
- unset(self::$crayon_posts[$key]);
301
- self::save_posts();
302
- }
303
-
304
- public static function remove_posts() {
305
- self::$crayon_posts = array();
306
- self::save_posts();
307
- }
308
-
309
- // Crayon legacy posts
310
-
311
- /**
312
- * This loads the posts marked as containing Crayons
313
- */
314
- public static function load_legacy_posts() {
315
- if (self::$crayon_legacy_posts === NULL) {
316
- // Load from db
317
- if (!(self::$crayon_legacy_posts = get_option(self::LEGACY_POSTS))) {
318
- // Posts don't exist! Scan for them. This will fill self::$crayon_legacy_posts
319
- self::$crayon_legacy_posts = CrayonWP::scan_legacy_posts();
320
- update_option(self::LEGACY_POSTS, self::$crayon_legacy_posts);
321
- }
322
- }
323
- return self::$crayon_legacy_posts;
324
- }
325
-
326
- /**
327
- * This looks through all posts and marks those which contain Crayons
328
- */
329
  // public static function scan_and_save_posts() {
330
  // self::save_posts(CrayonWP::scan_posts(TRUE, TRUE));
331
  // }
332
-
333
- /**
334
- * Saves the marked posts to the db
335
- */
336
- public static function save_legacy_posts($posts = NULL) {
337
- if ($posts === NULL) {
338
- $posts = self::$crayon_legacy_posts;
339
- }
340
- update_option(self::LEGACY_POSTS, $posts);
341
- self::load_legacy_posts();
342
- }
343
-
344
- /**
345
- * Adds a post as containing a Crayon
346
- */
347
- public static function add_legacy_post($id) {
348
- self::load_legacy_posts();
349
- if (!in_array($id, self::$crayon_legacy_posts)) {
350
- self::$crayon_legacy_posts[] = $id;
351
- }
352
- self::save_legacy_posts();
353
- }
354
-
355
- /**
356
- * Removes a post as not containing a Crayon
357
- */
358
- public static function remove_legacy_post($id) {
359
- self::load_legacy_posts();
360
- $key = array_search($id, self::$crayon_legacy_posts);
361
- if ($key === false) {
362
- return;
363
- }
364
- unset(self::$crayon_legacy_posts[$key]);
365
- self::save_legacy_posts();
366
- }
367
-
368
- public static function remove_legacy_posts() {
369
- self::$crayon_legacy_posts = array();
370
- self::save_legacy_posts();
371
- }
372
-
373
- // Cache
374
-
375
- public static function add_cache($name) {
376
- self::load_cache();
377
- if (!in_array($name, self::$cache)) {
378
- self::$cache[] = $name;
379
- }
380
- self::save_cache();
381
- }
382
-
383
- public static function remove_cache($name) {
384
- self::load_cache();
385
- $key = array_search($name, self::$cache);
386
- if ($key === false) {
387
- return;
388
- }
389
- unset(self::$cache[$key]);
390
- self::save_cache();
391
- }
392
-
393
- public static function clear_cache() {
394
- self::load_cache();
395
- foreach (self::$cache as $name) {
396
- delete_transient($name);
397
- }
398
- self::$cache = array();
399
- self::save_cache();
400
- }
401
-
402
- public static function load_cache() {
403
- // Load cache from db
404
- if (!(self::$cache = get_option(self::CACHE))) {
405
- self::$cache = array();
406
- update_option(self::CACHE, self::$cache);
407
- }
408
- }
409
-
410
- public static function save_cache() {
411
- update_option(self::CACHE, self::$cache);
412
- self::load_cache();
413
- }
414
 
415
- // Paths
416
-
417
- public static function admin_init() {
418
- // Load default settings if they don't exist
419
- self::load_settings();
420
-
421
- // General
422
- // Some of these will the $editor arguments, if TRUE it will alter for use in the Tag Editor
423
- self::add_section(self::GENERAL, crayon__('General'));
424
- self::add_field(self::GENERAL, crayon__('Theme'), 'theme');
425
- self::add_field(self::GENERAL, crayon__('Font'), 'font');
426
- self::add_field(self::GENERAL, crayon__('Metrics'), 'metrics');
427
- self::add_field(self::GENERAL, crayon__('Toolbar'), 'toolbar');
428
- self::add_field(self::GENERAL, crayon__('Lines'), 'lines');
429
- self::add_field(self::GENERAL, crayon__('Code'), 'code');
430
- self::add_field(self::GENERAL, crayon__('Tags'), 'tags');
431
- self::add_field(self::GENERAL, crayon__('Languages'), 'langs');
432
- self::add_field(self::GENERAL, crayon__('Files'), 'files');
433
- self::add_field(self::GENERAL, crayon__('Posts'), 'posts');
434
- self::add_field(self::GENERAL, crayon__('Tag Editor'), 'tag_editor');
435
- self::add_field(self::GENERAL, crayon__('Misc'), 'misc');
436
-
437
- // Debug
438
- self::add_section(self::DEBUG, crayon__('Debug'));
439
- self::add_field(self::DEBUG, crayon__('Errors'), 'errors');
440
- self::add_field(self::DEBUG, crayon__('Log'), 'log');
441
- // ABOUT
442
-
443
- self::add_section(self::ABOUT, crayon__('About'));
444
- $image = '<div id="crayon-logo">
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
445
 
446
  <img src="' . plugins_url(CRAYON_LOGO, __FILE__) . '" /><br/></div>';
447
- self::add_field(self::ABOUT, $image, 'info');
448
- }
449
-
450
- // Wrapper functions
451
-
452
- private static function add_section($name, $title, $callback = NULL) {
453
- $callback = (empty($callback) ? 'blank' : $callback);
454
- add_settings_section($name, $title, 'CrayonSettingsWP::' . $callback, self::SETTINGS);
455
- }
456
-
457
- private static function add_field($section, $title, $callback, $args = array()) {
458
- $unique = preg_replace('#\\s#', '_', strtolower($title));
459
- add_settings_field($unique, $title, 'CrayonSettingsWP::' . $callback, self::SETTINGS, $section, $args);
460
- }
461
-
462
- // Validates all the settings passed from the form in $inputs
463
-
464
- public static function settings_validate($inputs) {
465
- // Load current settings from db
466
- self::load_settings(TRUE);
467
-
468
- global $CRAYON_EMAIL;
469
- // When reset button is pressed, remove settings so default loads next time
470
- if (array_key_exists('reset', $inputs)) {
471
- self::clear_cache();
472
- return array();
473
- }
474
- // Convert old tags
475
- if (array_key_exists('convert', $inputs)) {
476
- CrayonWP::convert_tags();
477
- }
478
- // Refresh internal tag management
479
- if (array_key_exists('refresh_tags', $inputs)) {
480
- CrayonWP::refresh_posts();
481
- }
482
- // Clear the log if needed
483
- if (array_key_exists(self::LOG_CLEAR, $_POST)) {
484
- CrayonLog::clear();
485
- }
486
- // Send to admin
487
- if (array_key_exists(self::LOG_EMAIL_ADMIN, $_POST)) {
488
- CrayonLog::email(get_bloginfo('admin_email'));
489
- }
490
- // Send to developer
491
- if (array_key_exists(self::LOG_EMAIL_DEV, $_POST)) {
492
- CrayonLog::email($CRAYON_EMAIL, get_bloginfo('admin_email'));
493
- }
494
-
495
- // Clear the cache
496
- if (array_key_exists('crayon-cache-clear', $_POST)) {
497
- self::clear_cache();
498
- }
499
-
500
- // Validate inputs
501
- foreach ($inputs as $input => $value) {
502
- // Convert all array setting values to ints
503
- $inputs[$input] = CrayonSettings::validate($input, $value);
504
- // Clear cache when changed
505
- if ($input == CrayonSettings::CACHE && $value != CrayonGlobalSettings::val(CrayonSettings::CACHE)) {
506
- self::clear_cache();
507
- }
508
- }
509
-
510
- // If settings don't exist in input, set them to default
511
- $global_settings = CrayonSettings::get_defaults();
512
-
513
- $ignored = array(CrayonSettings::HIDE_HELP);
514
-
515
- foreach ($global_settings as $setting) {
516
- // XXX Ignore some settings
517
- if ( in_array($setting->name(), $ignored) ) {
518
- $inputs[$setting->name()] = CrayonGlobalSettings::val($setting->name());
519
- continue;
520
- }
521
-
522
- // If boolean setting is not in input, then it is set to FALSE in the form
523
- if (!array_key_exists($setting->name(), $inputs)) {
524
- // For booleans, set to FALSE (unchecked boxes are not sent as POST)
525
- if (is_bool($setting->def())) {
526
- $inputs[$setting->name()] = FALSE;
527
- } else {
528
- /* For array settings, set the input as the value, which by default is the
529
- default index */
530
- if (is_array($setting->def())) {
531
- $inputs[$setting->name()] = $setting->value();
532
- } else {
533
- $inputs[$setting->name()] = $setting->def();
534
- }
535
- }
536
- }
537
- }
538
-
539
- return $inputs;
540
- }
541
-
542
- // Section callback functions
543
-
544
- public static function blank() {
545
- } // Used for required callbacks with blank content
546
-
547
- // Input Drawing ==========================================================
548
-
549
- private static function textbox($args) {
550
- $id = '';
551
- $size = 40;
552
- $margin = FALSE;
553
- $preview = 1;
554
- $break = FALSE;
555
- extract($args);
556
-
557
- echo '<input id="', CrayonSettings::PREFIX, $id, '" name="', self::OPTIONS, '[', $id, ']" class="'.CrayonSettings::SETTING.'" size="', $size, '" type="text" value="',
558
- self::$options[$id], '" style="margin-left: ', ($margin ? '20px' : '0px'), ';" crayon-preview="', ($preview ? 1 : 0), '" />', ($break ? CRAYON_BR : '');
559
- }
560
-
561
- private static function checkbox($args, $line_break = TRUE, $preview = TRUE) {
562
- if (empty($args) || !is_array($args) || count($args) != 2) {
563
- return;
564
- }
565
- $id = $args[0];
566
- $text = $args[1];
567
- $checked = (!array_key_exists($id, self::$options)) ? FALSE : self::$options[$id] == TRUE;
568
- $checked_str = $checked ? ' checked="checked"' : '';
569
- echo '<input id="', CrayonSettings::PREFIX, $id, '" name="', self::OPTIONS, '[', $id, ']" type="checkbox" class="'.CrayonSettings::SETTING.'" value="1"', $checked_str,
570
- ' crayon-preview="', ($preview ? 1 : 0), '" /> ', '<label for="', CrayonSettings::PREFIX, $id, '">', $text, '</label>', ($line_break ? CRAYON_BR : '');
571
- }
572
-
573
- // Draws a dropdown by loading the default value (an array) from a setting
574
- private static function dropdown($id, $line_break = TRUE, $preview = TRUE, $echo = TRUE, $resources = NULL) {
575
- if (!array_key_exists($id, self::$options)) {
576
- return;
577
- }
578
- $resources = $resources != NULL ? $resources : CrayonGlobalSettings::get($id)->def();
579
-
580
- $return = '<select id="'.CrayonSettings::PREFIX.$id.'" name="'.self::OPTIONS.'['.$id.']" class="'.CrayonSettings::SETTING.'" crayon-preview="'.($preview ? 1 : 0).'">';
581
- foreach ($resources as $k=>$v) {
582
- $return .='<option value="'.$k.'" '.selected(self::$options[$id], $k, FALSE).'>'.$v.'</option>';
583
- }
584
- $return .= '</select>'.($line_break ? CRAYON_BR : '');
585
- if ($echo) {
586
- echo $return;
587
- } else {
588
- return $return;
589
- }
590
- }
591
-
592
- private static function button($args = array()) {
593
- extract($args);
594
- CrayonUtil::set_var($id, '');
595
- CrayonUtil::set_var($class, '');
596
- CrayonUtil::set_var($onclick, '');
597
- CrayonUtil::set_var($title, '');
598
- return '<a id="'.$id.'" class="button-primary '.$class.'" onclick="'.$onclick.'">'.$title.'</a>';
599
- }
600
-
601
- private static function info_span($name, $text) {
602
- echo '<span id="', $name, '-info">', $text,'</span>';
603
- }
604
-
605
- private static function span($text) {
606
- echo '<span>', $text,'</span>';
607
- }
608
-
609
- // General Fields =========================================================
610
- public static function help() {
611
- global $CRAYON_WEBSITE, $CRAYON_TWITTER, $CRAYON_GIT, $CRAYON_PLUGIN_WP;
612
- if (CrayonGlobalSettings::val(CrayonSettings::HIDE_HELP)) {
613
- return;
614
- }
615
- echo '
 
 
 
 
 
 
 
 
616
  <div id="crayon-help" class="updated settings-error crayon-help">
617
- <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>. <a class="crayon-help-close">X</a></p>
618
- </div>
619
  ';
620
- }
621
 
622
  // public static function get_crayon_help_file() {
623
  // // Load help
@@ -629,22 +651,22 @@ class CrayonSettingsWP {
629
  // return $help;
630
  // }
631
 
632
- public static function help_screen() {
633
- $screen = get_current_screen();
634
 
635
- if ($screen->id != self::$admin_page) {
636
- return;
637
- }
638
-
639
- // Add my_help_tab if current screen is My Admin Page
640
  // $screen->add_help_tab( array(
641
  // 'id' => 'crayon_help_tab',
642
  // 'title' => crayon__('Crayon Help'),
643
  // 'content' => self::get_crayon_help_file() // TODO consider adding tranlations for help
644
  // ) );
645
- }
646
 
647
- // XXX Depreciated since WP 3.3
648
  // public static function cont_help($contextual_help, $screen_id, $screen) {
649
  // if ($screen_id == self::$admin_page) {
650
  // return self::get_crayon_help_file();
@@ -652,228 +674,228 @@ class CrayonSettingsWP {
652
  // return $contextual_help;
653
  // }
654
 
655
- public static function metrics() {
656
- echo '<div id="crayon-section-metrics" class="crayon-hide-inline">';
657
- self::checkbox(array(CrayonSettings::HEIGHT_SET, '<span class="crayon-span-50">'.crayon__('Height').' </span>'), FALSE);
658
- self::dropdown(CrayonSettings::HEIGHT_MODE, FALSE);
659
- echo ' ';
660
- self::textbox(array('id' => CrayonSettings::HEIGHT, 'size' => 8));
661
- echo ' ';
662
- self::dropdown(CrayonSettings::HEIGHT_UNIT);
663
- self::checkbox(array(CrayonSettings::WIDTH_SET, '<span class="crayon-span-50">'.crayon__('Width').' </span>'), FALSE);
664
- self::dropdown(CrayonSettings::WIDTH_MODE, FALSE);
665
- echo ' ';
666
- self::textbox(array('id' => CrayonSettings::WIDTH, 'size' => 8));
667
- echo ' ';
668
- self::dropdown(CrayonSettings::WIDTH_UNIT);
669
- $text = array(crayon__('Top Margin') => array(CrayonSettings::TOP_SET, CrayonSettings::TOP_MARGIN),
670
- crayon__('Bottom Margin') => array(CrayonSettings::BOTTOM_SET, CrayonSettings::BOTTOM_MARGIN),
671
- crayon__('Left Margin') => array(CrayonSettings::LEFT_SET, CrayonSettings::LEFT_MARGIN),
672
- crayon__('Right Margin') => array(CrayonSettings::RIGHT_SET, CrayonSettings::RIGHT_MARGIN));
673
- foreach ($text as $p => $s) {
674
- $set = $s[0];
675
- $margin = $s[1];
676
- $preview = ($p == crayon__('Left Margin') || $p == crayon__('Right Margin'));
677
- self::checkbox(array($set, '<span class="crayon-span-110">' . $p . '</span>'), FALSE, $preview);
678
- echo ' ';
679
- self::textbox(array('id' => $margin, 'size' => 8, 'preview' => FALSE));
680
- echo '<span class="crayon-span-margin">', crayon__('Pixels'), '</span>', CRAYON_BR;
681
- }
682
- echo '<span class="crayon-span" style="min-width: 135px;">'.crayon__('Horizontal Alignment').' </span>';
683
- self::dropdown(CrayonSettings::H_ALIGN);
684
- echo '<div id="crayon-subsection-float">';
685
- self::checkbox(array(CrayonSettings::FLOAT_ENABLE, crayon__('Allow floating elements to surround Crayon')), FALSE, FALSE);
686
- echo '</div>';
687
- echo '<span class="crayon-span-100">' . crayon__('Inline Margin') . ' </span>';
688
- self::textbox(array('id' => CrayonSettings::INLINE_MARGIN, 'size' => 2));
689
- echo '<span class="crayon-span-margin">', crayon__('Pixels'), '</span>';
690
- echo '</div>';
691
- }
692
-
693
- public static function toolbar() {
694
- echo '<div id="crayon-section-toolbar" class="crayon-hide-inline">';
695
- self::span(crayon__('Display the Toolbar').' ');
696
- self::dropdown(CrayonSettings::TOOLBAR);
697
- echo '<div id="crayon-subsection-toolbar">';
698
- self::checkbox(array(CrayonSettings::TOOLBAR_OVERLAY, crayon__('Overlay the toolbar on code rather than push it down when possible')));
699
- self::checkbox(array(CrayonSettings::TOOLBAR_HIDE, crayon__('Toggle the toolbar on single click when it is overlayed')));
700
- self::checkbox(array(CrayonSettings::TOOLBAR_DELAY, crayon__('Delay hiding the toolbar on MouseOut')));
701
- echo '</div>';
702
- self::checkbox(array(CrayonSettings::SHOW_TITLE, crayon__('Display the title when provided')));
703
- self::span(crayon__('Display the language').' ');
704
- self::dropdown(CrayonSettings::SHOW_LANG);
705
- echo '</div>';
706
- }
707
-
708
- public static function lines() {
709
- echo '<div id="crayon-section-lines" class="crayon-hide-inline">';
710
- self::checkbox(array(CrayonSettings::STRIPED, crayon__('Display striped code lines')));
711
- self::checkbox(array(CrayonSettings::MARKING, crayon__('Enable line marking for important lines')));
712
- self::checkbox(array(CrayonSettings::RANGES, crayon__('Enable line ranges for showing only parts of code')));
713
- self::checkbox(array(CrayonSettings::NUMS, crayon__('Display line numbers by default')));
714
- self::checkbox(array(CrayonSettings::NUMS_TOGGLE, crayon__('Enable line number toggling')));
715
- self::checkbox(array(CrayonSettings::WRAP, crayon__('Wrap lines by default')));
716
- self::checkbox(array(CrayonSettings::WRAP_TOGGLE, crayon__('Enable line wrap toggling')));
717
- self::span(crayon__('Start line numbers from').' ');
718
- self::textbox(array('id' => CrayonSettings::START_LINE, 'size' => 2, 'break' => TRUE));
719
- echo '</div>';
720
- }
721
-
722
- public static function langs() {
723
- echo '<a name="langs"></a>';
724
- // Specialised dropdown for languages
725
- if (array_key_exists(CrayonSettings::FALLBACK_LANG, self::$options)) {
726
- if (($langs = CrayonParser::parse_all()) != FALSE) {
727
- $langs = CrayonLangs::sort_by_name($langs);
728
- self::span(crayon__('When no language is provided, use the fallback').': ');
729
- self::dropdown(CrayonSettings::FALLBACK_LANG,FALSE,TRUE,TRUE,$langs);
730
- // Information about parsing
731
- $parsed = CrayonResources::langs()->is_parsed();
732
- $count = count($langs);
733
- echo '</select>', CRAYON_BR, ($parsed ? '' : '<span class="crayon-error">'),
734
- sprintf(crayon_n('%d language has been detected.', '%d languages have been detected.', $count), $count), ' ',
735
- $parsed ? crayon__('Parsing was successful') : crayon__('Parsing was unsuccessful'),
736
- ($parsed ? '. ' : '</span>');
737
- // Check if fallback from db is loaded
738
- $db_fallback = self::$options[CrayonSettings::FALLBACK_LANG]; // Fallback name from db
739
-
740
- if (!CrayonResources::langs()->is_loaded($db_fallback) || !CrayonResources::langs()->exists($db_fallback)) {
741
- echo '<br/><span class="crayon-error">', sprintf(crayon__('The selected language with id %s could not be loaded'), '<strong>'.$db_fallback.'</strong>'), '. </span>';
742
- }
743
- // Language parsing info
744
- echo CRAYON_BR, '<div id="crayon-subsection-langs-info"><div>'.self::button(array('id'=>'show-langs', 'title'=>crayon__('Show Languages'))).'</div></div>';
745
- } else {
746
- echo 'No languages could be parsed.';
747
- }
748
- }
749
- }
750
-
751
- public static function show_langs() {
752
- require_once (CRAYON_PARSER_PHP);
753
- if (($langs = CrayonParser::parse_all()) != FALSE) {
754
- $langs = CrayonLangs::sort_by_name($langs);
755
- echo '<table class="crayon-table" cellspacing="0" cellpadding="0"><tr class="crayon-table-header">',
756
- '<td>ID</td><td>Name</td><td>Version</td><td>File Extensions</td><td>Aliases</td><td>State</td></tr>';
757
- $keys = array_values($langs);
758
- for ($i = 0; $i < count($langs); $i++) {
759
- $lang = $keys[$i];
760
- $tr = ($i == count($langs) - 1) ? 'crayon-table-last' : '';
761
- echo '<tr class="', $tr, '">',
762
- '<td>', $lang->id(), '</td>',
763
- '<td>', $lang->name(), '</td>',
764
- '<td>', $lang->version(), '</td>',
765
- '<td>', implode(', ', $lang->ext()), '</td>',
766
- '<td>', implode(', ', $lang->alias()), '</td>',
767
- '<td class="', strtolower(CrayonUtil::space_to_hyphen($lang->state_info())), '">',
768
- $lang->state_info(), '</td>',
769
- '</tr>';
770
- }
771
- echo '</table><br/>Languages that have the same extension as their name don\'t need to explicitly map extensions.';
772
- } else {
773
- echo 'No languages could be found.';
774
- }
775
- exit();
776
- }
777
-
778
- public static function posts() {
779
- echo '<a name="posts"></a>';
780
- echo self::button(array('id'=>'show-posts', 'title'=>crayon__('Show Crayon Posts')));
781
- echo ' <input type="submit" name="', self::OPTIONS, '[refresh_tags]" id="refresh_tags" class="button-primary" value="', crayon__('Refresh') ,'" />';
782
- echo self::help_button('http://bit.ly/NQfZN5');
783
- echo '<div id="crayon-subsection-posts-info"></div>';
784
- }
785
-
786
- public static function post_cmp($a, $b) {
787
- $a = $a->post_modified;
788
- $b = $b->post_modified;
789
- if ($a == $b) {
790
- return 0;
791
- } else {
792
- return $a < $b ? 1 : -1;
793
- }
794
- }
795
-
796
- public static function show_posts() {
797
- $postIDs = self::load_posts();
798
- $legacy_posts = self::load_legacy_posts();
799
- // Avoids O(n^2) by using a hash map, tradeoff in using strval
800
- $legacy_map = array();
801
- foreach ($legacy_posts as $legacyID) {
802
- $legacy_map[strval($legacyID)] = TRUE;
803
- }
804
-
805
- echo '<table class="crayon-table" cellspacing="0" cellpadding="0"><tr class="crayon-table-header">',
806
- '<td>', crayon__('ID'), '</td><td>', crayon__('Title'), '</td><td>', crayon__('Posted'), '</td><td>', crayon__('Modifed'), '</td><td>', crayon__('Contains Legacy Tags?'), '</td></tr>';
807
-
808
- $posts = array();
809
- for ($i = 0; $i < count($postIDs); $i++) {
810
- $posts[$i] = get_post($postIDs[$i]);
811
- }
812
-
813
- usort($posts, 'CrayonSettingsWP::post_cmp');
814
-
815
- for ($i = 0; $i < count($posts); $i++) {
816
- $post = $posts[$i];
817
- $postID = $post->ID;
818
- $title = $post->post_title;
819
- $title = !empty($title) ? $title : 'N/A';
820
- $tr = ($i == count($posts) - 1) ? 'crayon-table-last' : '';
821
- echo '<tr class="', $tr, '">',
822
- '<td>', $postID, '</td>',
823
- '<td><a href="', $post->guid ,'" target="_blank">', $title, '</a></td>',
824
- '<td>', $post->post_date, '</td>',
825
- '<td>', $post->post_modified, '</td>',
826
- '<td>', isset($legacy_map[strval($postID)]) ? '<span style="color: red;">'.crayon__('Yes').'</a>' : crayon__('No'), '</td>',
827
- '</tr>';
828
- }
829
-
830
- echo '</table>';
831
- exit();
832
- }
833
-
834
- public static function show_preview() {
835
- echo '<div id="content">';
836
-
837
- self::load_settings(); // Run first to ensure global settings loaded
838
-
839
- $crayon = CrayonWP::instance();
840
-
841
- // Settings to prevent from validating
842
- $preview_settings = array();
843
-
844
- // Load settings from GET and validate
845
- foreach ($_GET as $key => $value) {
846
- // echo $key, ' ', $value , '<br/>';
847
- if (!in_array($key, $preview_settings)) {
848
- $_GET[$key] = CrayonSettings::validate($key, $value);
849
- }
850
- }
851
- $crayon->settings($_GET);
852
- if (!isset($crayon_preview_dont_override_get) || !$crayon_preview_dont_override_get) {
853
- $settings = array(CrayonSettings::TOP_SET => TRUE, CrayonSettings::TOP_MARGIN => 10,
854
- CrayonSettings::BOTTOM_SET => FALSE, CrayonSettings::BOTTOM_MARGIN => 0);
855
- $crayon->settings($settings);
856
- }
857
-
858
- // Print the theme CSS
859
- $theme_id = $crayon->setting_val(CrayonSettings::THEME);
860
- if ($theme_id != NULL) {
861
- echo CrayonResources::themes()->get_css($theme_id);
862
- }
863
-
864
- $font_id = $crayon->setting_val(CrayonSettings::FONT);
865
- if ($font_id != NULL /*&& $font_id != CrayonFonts::DEFAULT_FONT*/) {
866
- echo CrayonResources::fonts()->get_css($font_id);
867
- }
868
-
869
- // Load custom code based on language
870
- $lang = $crayon->setting_val(CrayonSettings::FALLBACK_LANG);
871
- $path = crayon_pf( CRAYON_UTIL_PATH . '/sample/' . $lang . '.txt', FALSE );
872
-
873
- if ($lang && @file_exists($path)) {
874
- $crayon->url($path);
875
- } else {
876
- $code = "
877
  // A sample class
878
  class Human {
879
  private int age = 0;
@@ -883,270 +905,280 @@ class Human {
883
  }
884
  }
885
  ";
886
- $crayon->code($code);
887
- }
888
- $crayon->title('Sample Code');
889
- $crayon->marked('5-7');
890
- $crayon->output($highlight = true, $nums = true, $print = true);
891
- echo '</div>';
892
- crayon_load_plugin_textdomain();
893
- exit();
894
- }
895
-
896
- public static function theme($editor = FALSE) {
897
- $db_theme = self::$options[CrayonSettings::THEME]; // Theme name from db
898
- if (!array_key_exists(CrayonSettings::THEME, self::$options)) {
899
- $db_theme = '';
900
- }
901
- $themes_array = CrayonResources::themes()->get_array();
902
- self::dropdown(CrayonSettings::THEME,FALSE,FALSE,TRUE,$themes_array);
903
- if ($editor) {
904
- return;
905
- }
906
- // Theme editor
907
- if (CRAYON_THEME_EDITOR) {
908
- // echo '<a id="crayon-theme-editor-button" class="button-primary crayon-admin-button" loading="'. crayon__('Loading...') .'" loaded="'. crayon__('Theme Editor') .'" >'. crayon__('Theme Editor') .'</a></br>';
909
- echo '<div id="crayon-theme-editor-admin-buttons">';
910
- $buttons = array('edit' => crayon__('Edit'), 'duplicate' => crayon__('Duplicate'), 'create' => crayon__('Create'), 'delete' => crayon__('Delete'));
911
- foreach ($buttons as $k=>$v) {
912
- echo '<a id="crayon-theme-editor-', $k, '-button" class="button-primary crayon-admin-button" loading="', crayon__('Loading...'), '" loaded="', $v, '" >', $v, '</a>';
913
- }
914
- echo '</br></div>';
915
- }
916
- // Preview Box
917
- ?>
918
- <div id="crayon-theme-panel">
919
- <div id="crayon-theme-info">
920
- <div class="desc"></div>
921
- <div class="version field">Version:</div><div class="value"></div>
922
- <div class="author field">Author:</div><div class="value"></div>
923
- </div>
924
-
925
- <div id="crayon-live-preview"></div>
926
- <div id="crayon-preview-info">
927
- <?php printf(crayon__('Change the %1$sfallback language%2$s to change the sample code. Lines 5-7 are marked.'), '<a href="#langs">', '</a>'); ?>
928
- </div>
929
- </div>
930
- <?php
931
- // Preview checkbox
932
- self::checkbox(array(CrayonSettings::PREVIEW, crayon__('Enable Live Preview')), FALSE, FALSE);
933
- echo '</select><span class="crayon-span-10"></span>';
934
- self::checkbox(array(CrayonSettings::ENQUEUE_THEMES, crayon__('Enqueue themes in the header (more efficient).') . self::help_button('http://bit.ly/zTUAQV')));
935
- // Check if theme from db is loaded
936
- if (!CrayonResources::themes()->is_loaded($db_theme) || !CrayonResources::themes()->exists($db_theme)) {
937
- echo '<span class="crayon-error">', sprintf(crayon__('The selected theme with id %s could not be loaded'), '<strong>'.$db_theme.'</strong>'), '. </span>';
938
- }
939
- }
940
-
941
- public static function font($editor = FALSE) {
942
- $db_font = self::$options[CrayonSettings::FONT]; // Theme name from db
943
- if (!array_key_exists(CrayonSettings::FONT, self::$options)) {
944
- $db_font = '';
945
- }
946
- $fonts_array = CrayonResources::fonts()->get_array();
947
- self::dropdown(CrayonSettings::FONT,FALSE,TRUE,TRUE,$fonts_array);
948
- echo '<span class="crayon-span-10"></span>';
949
- self::checkbox(array(CrayonSettings::FONT_SIZE_ENABLE, crayon__('Custom Font Size').' '), FALSE);
950
- self::textbox(array('id' => CrayonSettings::FONT_SIZE, 'size' => 2));
951
- echo '<span class="crayon-span-margin">', crayon__('Pixels'), '</span></br>';
952
- if ((!CrayonResources::fonts()->is_loaded($db_font) || !CrayonResources::fonts()->exists($db_font))) {
953
- // Default font doesn't actually exist as a file, it means do not override default theme font
954
- echo '<span class="crayon-error">', sprintf(crayon__('The selected font with id %s could not be loaded'), '<strong>'.$db_font.'</strong>'), '. </span><br/>';
955
- }
956
- if ($editor) {
957
- return;
958
- }
959
- echo '<div style="height:10px;"></div>';
960
- self::checkbox(array(CrayonSettings::ENQUEUE_FONTS, crayon__('Enqueue fonts in the header (more efficient).') . self::help_button('http://bit.ly/zTUAQV')));
961
- }
962
-
963
- public static function code($editor = FALSE) {
964
- echo '<div id="crayon-section-code-interaction" class="crayon-hide-inline-only">';
965
- self::checkbox(array(CrayonSettings::PLAIN, crayon__('Enable plain code view and display').' '), FALSE);
966
- self::dropdown(CrayonSettings::SHOW_PLAIN);
967
- echo '<span id="crayon-subsection-copy-check">';
968
- self::checkbox(array(CrayonSettings::PLAIN_TOGGLE, crayon__('Enable plain code toggling')));
969
- self::checkbox(array(CrayonSettings::SHOW_PLAIN_DEFAULT, crayon__('Show the plain code by default')));
970
- self::checkbox(array(CrayonSettings::COPY, crayon__('Enable code copy/paste')));
971
- echo '</span>';
972
- self::checkbox(array(CrayonSettings::POPUP, crayon__('Enable opening code in a window')));
973
- self::checkbox(array(CrayonSettings::SCROLL, crayon__('Always display scrollbars')));
974
- self::checkbox(array(CrayonSettings::EXPAND, crayon__('Expand code beyond page borders on mouseover')));
975
- self::checkbox(array(CrayonSettings::EXPAND_TOGGLE, crayon__('Enable code expanding toggling when possible')));
976
- echo '</div>';
977
- if (!$editor) {
978
- self::checkbox(array(CrayonSettings::DECODE, crayon__('Decode HTML entities in code')));
979
- }
980
- self::checkbox(array(CrayonSettings::DECODE_ATTRIBUTES, crayon__('Decode HTML entities in attributes')));
981
- echo '<div class="crayon-hide-inline-only">';
982
- self::checkbox(array(CrayonSettings::TRIM_WHITESPACE, crayon__('Remove whitespace surrounding the shortcode content')));
983
- echo '</div>';
984
- self::checkbox(array(CrayonSettings::MIXED, crayon__('Allow Mixed Language Highlighting with delimiters and tags.') . self::help_button('http://bit.ly/ukwts2')));
985
- echo '<div class="crayon-hide-inline-only">';
986
- self::checkbox(array(CrayonSettings::SHOW_MIXED, crayon__('Show Mixed Language Icon (+)')));
987
- echo '</div>';
988
- self::span(crayon__('Tab size in spaces').': ');
989
- self::textbox(array('id' => CrayonSettings::TAB_SIZE, 'size' => 2, 'break' => TRUE));
990
- self::span(crayon__('Blank lines before code:') . ' ');
991
- self::textbox(array('id' => CrayonSettings::WHITESPACE_BEFORE, 'size' => 2, 'break' => TRUE));
992
- self::span(crayon__('Blank lines after code:') . ' ');
993
- self::textbox(array('id' => CrayonSettings::WHITESPACE_AFTER, 'size' => 2, 'break' => TRUE));
994
- }
995
-
996
- public static function tags() {
997
- self::checkbox(array(CrayonSettings::CAPTURE_MINI_TAG, crayon__('Capture Mini Tags like [php][/php] as Crayons.') . self::help_button('http://bit.ly/rRZuzk')));
998
- self::checkbox(array(CrayonSettings::INLINE_TAG, crayon__('Capture Inline Tags like {php}{/php} inside sentences.') . self::help_button('http://bit.ly/yFafFL')));
999
- self::checkbox(array(CrayonSettings::INLINE_WRAP, crayon__('Wrap Inline Tags') . self::help_button('http://bit.ly/yFafFL')));
1000
- self::checkbox(array(CrayonSettings::BACKQUOTE, crayon__('Capture `backquotes` as &lt;code&gt;') . self::help_button('http://bit.ly/yFafFL')));
1001
- self::checkbox(array(CrayonSettings::CAPTURE_PRE, crayon__('Capture &lt;pre&gt; tags as Crayons') . self::help_button('http://bit.ly/rRZuzk')));
1002
- self::checkbox(array(CrayonSettings::PLAIN_TAG, crayon__('Enable [plain][/plain] tag.') . self::help_button('http://bit.ly/rRZuzk')));
1003
- }
1004
-
1005
- public static function files() {
1006
- echo '<a name="files"></a>';
1007
- echo crayon__('When loading local files and a relative path is given for the URL, use the absolute path'),': ',
1008
- '<div style="margin-left: 20px">', home_url(), '/';
1009
- self::textbox(array('id' => CrayonSettings::LOCAL_PATH));
1010
- echo '</div>', crayon__('Followed by your relative URL.');
1011
- }
1012
-
1013
- public static function tag_editor() {
1014
- $can_convert = self::load_legacy_posts();
1015
- if ($can_convert) {
1016
- $disabled = '';
1017
- $convert_text = crayon__('Convert Legacy Tags');
1018
- } else {
1019
- $disabled = 'disabled="disabled"';
1020
- $convert_text = crayon__('No Legacy Tags Found');
1021
- }
1022
-
1023
- echo '<input type="submit" name="', self::OPTIONS, '[convert]" id="convert" class="button-primary" value="', $convert_text, '"', $disabled, ' /> ';
1024
- echo self::help_button('http://bit.ly/ReRr0i') , CRAYON_BR, CRAYON_BR;
1025
- $sep = sprintf(crayon__('Use %s to separate setting names from values in the &lt;pre&gt; class attribute'),
1026
- self::dropdown(CrayonSettings::ATTR_SEP, FALSE, FALSE, FALSE));
1027
- echo '<span>', $sep, self::help_button('http://bit.ly/H3xW3D'), '</span><br/>';
1028
- self::checkbox(array(CrayonSettings::TAG_EDITOR_FRONT, crayon__("Display the Tag Editor in any TinyMCE instances on the frontend (e.g. bbPress)") . self::help_button('http://bit.ly/TyYyll')));
1029
- self::checkbox(array(CrayonSettings::TAG_EDITOR_SETTINGS, crayon__("Display Tag Editor settings on the frontend")));
1030
- }
1031
-
1032
- public static function misc() {
1033
- echo crayon__('Clear the cache used to store remote code requests'),': ';
1034
- self::dropdown(CrayonSettings::CACHE, false);
1035
- echo '<input type="submit" id="crayon-cache-clear" name="crayon-cache-clear" class="button-secondary" value="', crayon__('Clear Now'), '" /><br/>';
1036
- self::checkbox(array(CrayonSettings::EFFICIENT_ENQUEUE, crayon__('Attempt to load Crayon\'s CSS and JavaScript only when needed'). self::help_button('http://ak.net84.net/?p=660')));
1037
- self::checkbox(array(CrayonSettings::SAFE_ENQUEUE, crayon__('Disable enqueuing for page templates that may contain The Loop.') . self::help_button('http://bit.ly/AcWRNY')));
1038
- self::checkbox(array(CrayonSettings::COMMENTS, crayon__('Allow Crayons inside comments')));
1039
- self::checkbox(array(CrayonSettings::EXCERPT_STRIP, crayon__('Remove Crayons from excerpts')));
1040
- self::checkbox(array(CrayonSettings::MAIN_QUERY, crayon__('Load Crayons only from the main Wordpress query')));
1041
- self::checkbox(array(CrayonSettings::TOUCHSCREEN, crayon__('Disable mouse gestures for touchscreen devices (eg. MouseOver)')));
1042
- self::checkbox(array(CrayonSettings::DISABLE_ANIM, crayon__('Disable animations')));
1043
- self::checkbox(array(CrayonSettings::DISABLE_RUNTIME, crayon__('Disable runtime stats')));
1044
- }
1045
-
1046
- // Debug Fields ===========================================================
1047
-
1048
- public static function errors() {
1049
- self::checkbox(array(CrayonSettings::ERROR_LOG, crayon__('Log errors for individual Crayons')));
1050
- self::checkbox(array(CrayonSettings::ERROR_LOG_SYS, crayon__('Log system-wide errors')));
1051
- self::checkbox(array(CrayonSettings::ERROR_MSG_SHOW, crayon__('Display custom message for errors')));
1052
- self::textbox(array('id' => CrayonSettings::ERROR_MSG, 'size' => 60, 'margin' => TRUE));
1053
- }
1054
-
1055
- public static function log() {
1056
- $log = CrayonLog::log();
1057
- touch(CRAYON_LOG_FILE);
1058
- $exists = file_exists(CRAYON_LOG_FILE);
1059
- $writable = is_writable(CRAYON_LOG_FILE);
1060
- if (!empty($log)) {
1061
- echo '<div id="crayon-log-wrapper">', '<div id="crayon-log"><div id="crayon-log-text">', $log,
1062
- '</div></div>', '<div id="crayon-log-controls">',
1063
- '<input type="button" id="crayon-log-toggle" show_txt="',crayon__('Show Log'),'" hide_txt="',crayon__('Hide Log'),'" class="button-secondary" value="', crayon__('Show Log'), '"> ',
1064
- '<input type="submit" id="crayon-log-clear" name="', self::LOG_CLEAR ,
1065
- '" class="button-secondary" value="', crayon__('Clear Log'), '"> ', '<input type="submit" id="crayon-log-email" name="',
1066
- self::LOG_EMAIL_ADMIN . '" class="button-secondary" value="', crayon__('Email Admin'), '"> ',
1067
- '<input type="submit" id="crayon-log-email" name="', self::LOG_EMAIL_DEV,
1068
- '" class="button-secondary" value="', crayon__('Email Developer'), '"> ', '</div>', '</div>';
1069
- }
1070
- echo '<span', (!empty($log)) ? ' class="crayon-span"' : '', '>', (empty($log)) ? crayon__('The log is currently empty.').' ' : '';
1071
- if ($exists) {
1072
- $writable ? crayon_e('The log file exists and is writable.') : crayon_e('The log file exists and is not writable.');
1073
- } else {
1074
- crayon_e('The log file does not exist and is not writable.');
1075
- }
1076
- echo '</span>';
1077
- }
1078
-
1079
- // About Fields ===========================================================
1080
-
1081
- public static function info() {
1082
- global $CRAYON_VERSION, $CRAYON_DATE, $CRAYON_AUTHOR, $CRAYON_WEBSITE, $CRAYON_TWITTER, $CRAYON_GIT, $CRAYON_PLUGIN_WP, $CRAYON_AUTHOR_SITE, $CRAYON_EMAIL, $CRAYON_DONATE;
1083
- echo '<a name="info"></a>';
1084
- $version = '<strong>'.crayon__('Version').':</strong> ' . $CRAYON_VERSION;
1085
- $date = $CRAYON_DATE;
1086
- $developer = '<strong>'.crayon__('Developer').':</strong> ' . '<a href="'.$CRAYON_AUTHOR_SITE.'" target="_blank">' . $CRAYON_AUTHOR . '</a>';
1087
- $translators = '<strong>'.crayon__('Translators').':</strong> ' .
1088
- 'Chinese (<a href="http://smerpup.com/" target="_blank">Dezhi Liu</a>, <a href="http://neverno.me/" target="_blank">Jash Yin</a>),
 
 
 
 
 
 
 
1089
  Dutch (<a href="https://twitter.com/#!/chilionsnoek" target="_blank">Chilion Snoek</a>),
1090
  French (<a href="http://tech.dupeu.pl" target="_blank">Victor Felder</a>),
1091
  German (<a href="http://www.technologyblog.de/" target="_blank">Stephan Knau&#223;</a>),
1092
  Italian (<a href="http://www.federicobellucci.net/" target="_blank">Federico Bellucci</a>),
1093
  Japanese (<a href="https://twitter.com/#!/west_323" target="_blank">@west_323</a>),
1094
  Lithuanian (<a href="http://www.host1free.com" target="_blank">Vincent G</a>),
 
1095
  Portuguese (<a href="http://www.adonai.eti.br" target="_blank">Adonai S. Canez</a>),
1096
  Russian (<a href="http://simplelib.com/" target="_blank">Minimus</a>, <a href="http://atlocal.net/" target="_blank">Di_Skyer</a>),
1097
  Spanish (<a href="http://www.hbravo.com/" target="_blank">Hermann Bravo</a>),
1098
  Turkish (<a href="http://hakanertr.wordpress.com" target="_blank">Hakan</a>)';
1099
 
1100
- $links = '
1101
  <a id="docs-icon" class="small-icon" title="Documentation" href="' . $CRAYON_WEBSITE . '" target="_blank"></a>
1102
  <a id="git-icon" class="small-icon" title="GitHub" href="' . $CRAYON_GIT . '" target="_blank"></a>
1103
  <a id="wp-icon" class="small-icon" title="Plugin Page" href="' . $CRAYON_PLUGIN_WP . '" target="_blank"></a>
1104
  <a id="twitter-icon" class="small-icon" title="Twitter" href="' . $CRAYON_TWITTER . '" target="_blank"></a>
1105
  <a id="gmail-icon" class="small-icon" title="Email" href="mailto:' . $CRAYON_EMAIL . '" target="_blank"></a>
1106
  <div id="crayon-donate"><a href="' . $CRAYON_DONATE . '" title="Donate" target="_blank">
1107
- <img src="'.plugins_url(CRAYON_DONATE_BUTTON, __FILE__).'"></a>
1108
  </div>';
1109
 
1110
- echo '
1111
  <table id="crayon-info" border="0">
1112
  <tr>
1113
- <td>'.$version.' - '.$date.'</td>
1114
  </tr>
1115
  <tr>
1116
- <td>'.$developer.'</td>
1117
  </tr>
1118
  <tr>
1119
- <td>'.$translators.'</td>
1120
  </tr>
1121
  <tr>
1122
  <td colspan="2">', crayon__("The result of innumerable hours of hard work over many months. It's an ongoing project, keep me motivated!"), '</td>
1123
  </tr>
1124
  <tr>
1125
- <td colspan="2">'.$links.'</td>
1126
  </tr>
1127
  </table>';
1128
 
1129
- }
1130
-
1131
- public static function help_button($link) {
1132
- return ' <a href="' . $link . '" target="_blank" class="crayon-question">' . crayon__('?') . '</a>';
1133
- }
1134
-
1135
- public static function plugin_row_meta($meta, $file) {
1136
- global $CRAYON_DONATE;
1137
- if ($file == CrayonWP::basename()) {
1138
- $meta[] = '<a href="options-general.php?page=crayon_settings">' . crayon__('Settings') . '</a>';
1139
- $meta[] = '<a href="'.$CRAYON_DONATE.'" target="_blank">' . crayon__('Donate') . '</a>';
1140
- }
1141
- return $meta;
1142
- }
 
1143
  }
 
1144
  // Add the settings menus
1145
 
1146
  if (defined('ABSPATH') && is_admin()) {
1147
- // For the admin section
1148
- add_action('admin_menu', 'CrayonSettingsWP::admin_load');
1149
- add_filter('plugin_row_meta', 'CrayonSettingsWP::plugin_row_meta', 10, 2);
1150
  }
1151
 
1152
  ?>
9
  CrayonHighlighter and any non-WP classes will only use CrayonSettings to separate
10
  the implementation of global settings and ensure any system can use them. */
11
  class CrayonSettingsWP {
12
+ // Properties and Constants ===============================================
13
+
14
+ // A copy of the current options in db
15
+ private static $options = NULL;
16
+ // Posts containing crayons in db
17
+ private static $crayon_posts = NULL;
18
+ // Posts containing legacy tags in db
19
+ private static $crayon_legacy_posts = NULL;
20
+ // An array of cache names for use with Transients API
21
+ private static $cache = NULL;
22
+ // Array of settings to pass to js
23
+ private static $js_settings = NULL;
24
+ private static $admin_js_settings = NULL;
25
+ private static $admin_page = '';
26
+ private static $is_fully_loaded = FALSE;
27
+
28
+ const SETTINGS = 'crayon_fields';
29
+ const FIELDS = 'crayon_settings';
30
+ const OPTIONS = 'crayon_options';
31
+ const POSTS = 'crayon_posts';
32
+ const LEGACY_POSTS = 'crayon_legacy_posts';
33
+ const CACHE = 'crayon_cache';
34
+ const GENERAL = 'crayon_general';
35
+ const DEBUG = 'crayon_debug';
36
+ const ABOUT = 'crayon_about';
37
+
38
+ // Used on submit
39
+ const LOG_CLEAR = 'log_clear';
40
+ const LOG_EMAIL_ADMIN = 'log_email_admin';
41
+ const LOG_EMAIL_DEV = 'log_email_dev';
42
+
43
+ private function __construct() {
44
+ }
45
+
46
+ // Methods ================================================================
47
+
48
+ public static function admin_load() {
49
+ self::$admin_page = $admin_page = add_options_page('Crayon Syntax Highlighter ' . crayon__('Settings'), 'Crayon', 'manage_options', 'crayon_settings', 'CrayonSettingsWP::settings');
50
+ add_action("admin_print_scripts-$admin_page", 'CrayonSettingsWP::admin_scripts');
51
+ add_action("admin_print_styles-$admin_page", 'CrayonSettingsWP::admin_styles');
52
+ // Register settings, second argument is option name stored in db
53
+ register_setting(self::FIELDS, self::OPTIONS, 'CrayonSettingsWP::settings_validate');
54
+ add_action("admin_head-$admin_page", 'CrayonSettingsWP::admin_init');
55
+ // Register settings for post page
56
+ add_action("admin_print_styles-post-new.php", 'CrayonSettingsWP::admin_scripts');
57
+ add_action("admin_print_styles-post.php", 'CrayonSettingsWP::admin_scripts');
58
+ add_action("admin_print_styles-post-new.php", 'CrayonSettingsWP::admin_styles');
59
+ add_action("admin_print_styles-post.php", 'CrayonSettingsWP::admin_styles');
60
+
61
+ // TODO depreciated since WP 3.3, remove eventually
62
+ global $wp_version;
63
+ if ($wp_version >= '3.3') {
64
+ add_action("load-$admin_page", 'CrayonSettingsWP::help_screen');
65
+ } else {
66
+ add_filter('contextual_help', 'CrayonSettingsWP::cont_help', 10, 3);
67
+ }
68
+ }
69
+
70
+ public static function admin_styles() {
71
+ global $CRAYON_VERSION;
72
+ wp_enqueue_style('crayon', plugins_url(CRAYON_STYLE, __FILE__), array(), $CRAYON_VERSION);
73
+ wp_enqueue_style('crayon_global', plugins_url(CRAYON_STYLE_GLOBAL, __FILE__), array(), $CRAYON_VERSION);
74
+ wp_enqueue_style('crayon_admin', plugins_url(CRAYON_STYLE_ADMIN, __FILE__), array(), $CRAYON_VERSION);
75
+ wp_enqueue_style('crayon_theme_editor', plugins_url(CRAYON_THEME_EDITOR_STYLE, __FILE__), array(), $CRAYON_VERSION);
76
+ }
77
+
78
+ public static function admin_scripts() {
79
+ global $CRAYON_VERSION;
80
+ wp_enqueue_script('crayon_util_js', plugins_url(CRAYON_JS_UTIL, __FILE__), array('jquery'), $CRAYON_VERSION);
81
+ self::init_js_settings();
82
+ if (is_admin()) {
83
+ wp_enqueue_script('crayon_admin_js', plugins_url(CRAYON_JS_ADMIN, __FILE__), array('jquery', 'crayon_util_js'), $CRAYON_VERSION);
84
+ self::init_admin_js_settings();
85
+ }
86
+ self::other_scripts();
87
+ }
88
+
89
+ public static function other_scripts() {
90
+ global $CRAYON_VERSION;
91
+ self::load_settings(TRUE);
92
+ $deps = array('jquery', 'crayon_util_js');
93
+ if (CrayonGlobalSettings::val(CrayonSettings::POPUP) || is_admin()) {
94
+ wp_enqueue_script('crayon_jquery_popup', plugins_url(CRAYON_JQUERY_POPUP, __FILE__), array('jquery'), $CRAYON_VERSION);
95
+ $deps[] = 'crayon_jquery_popup';
96
+ }
97
+ wp_enqueue_script('crayon_js', plugins_url(CRAYON_JS, __FILE__), $deps, $CRAYON_VERSION);
98
+ }
99
+
100
+ public static function init_js_settings() {
101
+ // This stores JS variables used in AJAX calls and in the JS files
102
+ global $CRAYON_VERSION;
103
+ self::load_settings(TRUE);
104
+ if (!self::$js_settings) {
105
+ self::$js_settings = array(
106
+ 'version' => $CRAYON_VERSION,
107
+ 'is_admin' => intval(is_admin()),
108
+ 'ajaxurl' => admin_url('admin-ajax.php'),
109
+ 'prefix' => CrayonSettings::PREFIX,
110
+ 'setting' => CrayonSettings::SETTING,
111
+ 'selected' => CrayonSettings::SETTING_SELECTED,
112
+ 'changed' => CrayonSettings::SETTING_CHANGED,
113
+ 'special' => CrayonSettings::SETTING_SPECIAL,
114
+ 'orig_value' => CrayonSettings::SETTING_ORIG_VALUE,
115
+ 'debug' => CRAYON_DEBUG
116
+ );
117
+ wp_localize_script('crayon_util_js', 'CrayonSyntaxSettings', self::$js_settings);
118
+ }
119
+ }
120
+
121
+ public static function init_admin_js_settings() {
122
+ if (!self::$admin_js_settings) {
123
+ // We need to load themes at this stage
124
+ CrayonSettingsWP::load_settings();
125
+ $themes_ = CrayonResources::themes()->get();
126
+ $stockThemes = array();
127
+ $userThemes = array();
128
+ foreach ($themes_ as $theme) {
129
+ $id = $theme->id();
130
+ $name = $theme->name();
131
+ if ($theme->user()) {
132
+ $userThemes[$id] = $name;
133
+ } else {
134
+ $stockThemes[$id] = $name;
135
+ }
136
+ }
137
+ self::$admin_js_settings = array(
138
+ 'themes' => array_merge($stockThemes, $userThemes),
139
+ 'stockThemes' => $stockThemes,
140
+ 'userThemes' => $userThemes,
141
+ 'defaultTheme' => CrayonThemes::DEFAULT_THEME,
142
+ 'themesURL' => CrayonThemes::dir_url(),
143
+ 'userThemesURL' => CrayonThemes::dir_url(true)
144
+ );
145
+ wp_localize_script('crayon_admin_js', 'CrayonAdminSettings', self::$admin_js_settings);
146
+ }
147
+ }
148
+
149
+ public static function settings() {
150
+ if (!current_user_can('manage_options')) {
151
+ wp_die(crayon__('You do not have sufficient permissions to access this page.'));
152
+ }
153
+ ?>
154
+
155
+ <script type="text/javascript">
156
+ jQuery(document).ready(function () {
157
+ CrayonSyntaxAdmin.init();
158
+ });
159
+ </script>
160
+
161
+
162
+ <div id="crayon-main-wrap" class="wrap">
163
+
164
+ <div id="icon-options-general" class="icon32">
165
+ <br>
166
+ </div>
167
+ <h2>
168
+ Crayon Syntax Highlighter
169
+ <?php crayon_e('Settings'); ?>
170
+ </h2>
171
+ <?php self::help(); ?>
172
+ <form id="crayon-settings-form" action="options.php" method="post">
173
+ <?php
174
+ settings_fields(self::FIELDS);
175
+ ?>
176
+
177
+ <?php
178
+ do_settings_sections(self::SETTINGS);
179
+ ?>
180
+
181
+ <p class="submit">
182
+ <input type="submit" name="submit" id="submit" class="button-primary"
183
+ value="<?php
184
+ crayon_e('Save Changes');
185
+ ?>"> <input type="submit"
186
+ name="<?php
187
+ echo self::OPTIONS;
188
+ ?>[reset]" id="reset"
189
+ class="button-primary"
190
+ value="<?php
191
+ crayon_e('Reset Settings');
192
+ ?>">
193
+ </p>
194
+ </form>
195
+ </div>
196
+
197
+ <div id="crayon-theme-editor-wrap" class="wrap"></div>
198
+
199
+ <?php
200
+ }
201
+
202
+ // Load the global settings and update them from the db
203
+ public static function load_settings($just_load_settings = FALSE) {
204
+ if (self::$options === NULL) {
205
+ // Load settings from db
206
+ if (!(self::$options = get_option(self::OPTIONS))) {
207
+ self::$options = CrayonSettings::get_defaults_array();
208
+ update_option(self::OPTIONS, self::$options);
209
+ }
210
+ // Initialise default global settings and update them from db
211
+ CrayonGlobalSettings::set(self::$options);
212
+ }
213
+
214
+ if (!self::$is_fully_loaded && !$just_load_settings) {
215
+ // Load everything else as well
216
+
217
+ // For local file loading
218
+ // This is used to decouple WP functions from internal Crayon classes
219
+ CrayonGlobalSettings::site_url(home_url());
220
+ CrayonGlobalSettings::site_path(ABSPATH);
221
+ CrayonGlobalSettings::plugin_path(plugins_url('', __FILE__));
222
+ $upload = wp_upload_dir();
223
+ CrayonGlobalSettings::upload_path(CrayonUtil::path_slash($upload['basedir']) . CRAYON_DIR);
224
+ CrayonGlobalSettings::upload_url($upload['baseurl'] . '/' . CRAYON_DIR);
225
+
226
+ // Load all available languages and themes
227
+ CrayonResources::langs()->load();
228
+ CrayonResources::themes()->load();
229
+
230
+ // Ensure all missing settings in db are replaced by default values
231
+ $changed = FALSE;
232
+ foreach (CrayonSettings::get_defaults_array() as $name => $value) {
233
+ // Add missing settings
234
+ if (!array_key_exists($name, self::$options)) {
235
+ self::$options[$name] = $value;
236
+ $changed = TRUE;
237
+ }
238
+ }
239
+ // A setting was missing, update options
240
+ if ($changed) {
241
+ update_option(self::OPTIONS, self::$options);
242
+ }
243
+
244
+ self::$is_fully_loaded = TRUE;
245
+ }
246
+ }
247
+
248
+ public static function get_settings() {
249
+ return get_option(self::OPTIONS);
250
+ }
251
+
252
+ // Saves settings from CrayonGlobalSettings, or provided array, to the db
253
+ public static function save_settings($settings = NULL) {
254
+ if ($settings === NULL) {
255
+ $settings = CrayonGlobalSettings::get_array();
256
+ }
257
+ update_option(self::OPTIONS, $settings);
258
+ }
259
+
260
+ // Crayon posts
261
+
262
+ /**
263
+ * This loads the posts marked as containing Crayons
264
+ */
265
+ public static function load_posts() {
266
+ if (self::$crayon_posts === NULL) {
267
+ // Load from db
268
+ if (!(self::$crayon_posts = get_option(self::POSTS))) {
269
+ // Posts don't exist! Scan for them. This will fill self::$crayon_posts
270
+ self::$crayon_posts = CrayonWP::scan_posts();
271
+ update_option(self::POSTS, self::$crayon_posts);
272
+ }
273
+ }
274
+ return self::$crayon_posts;
275
+ }
276
+
277
+ /**
278
+ * This looks through all posts and marks those which contain Crayons
279
+ */
280
  // public static function scan_and_save_posts() {
281
  // self::save_posts(CrayonWP::scan_posts(TRUE, TRUE));
282
  // }
283
 
284
+ /**
285
+ * Saves the marked posts to the db
286
+ */
287
+ public static function save_posts($posts = NULL) {
288
+ if ($posts === NULL) {
289
+ $posts = self::$crayon_posts;
290
+ }
291
+ update_option(self::POSTS, $posts);
292
+ self::load_posts();
293
+ }
294
+
295
+ /**
296
+ * Adds a post as containing a Crayon
297
+ */
298
+ public static function add_post($id) {
299
+ self::load_posts();
300
+ if (!in_array($id, self::$crayon_posts)) {
301
+ self::$crayon_posts[] = $id;
302
+ }
303
+ self::save_posts();
304
+ }
305
+
306
+ /**
307
+ * Removes a post as not containing a Crayon
308
+ */
309
+ public static function remove_post($id) {
310
+ self::load_posts();
311
+ $key = array_search($id, self::$crayon_posts);
312
+ if ($key === false) {
313
+ return;
314
+ }
315
+ unset(self::$crayon_posts[$key]);
316
+ self::save_posts();
317
+ }
318
+
319
+ public static function remove_posts() {
320
+ self::$crayon_posts = array();
321
+ self::save_posts();
322
+ }
323
+
324
+ // Crayon legacy posts
325
+
326
+ /**
327
+ * This loads the posts marked as containing Crayons
328
+ */
329
+ public static function load_legacy_posts() {
330
+ if (self::$crayon_legacy_posts === NULL) {
331
+ // Load from db
332
+ if (!(self::$crayon_legacy_posts = get_option(self::LEGACY_POSTS))) {
333
+ // Posts don't exist! Scan for them. This will fill self::$crayon_legacy_posts
334
+ self::$crayon_legacy_posts = CrayonWP::scan_legacy_posts();
335
+ update_option(self::LEGACY_POSTS, self::$crayon_legacy_posts);
336
+ }
337
+ }
338
+ return self::$crayon_legacy_posts;
339
+ }
340
+
341
+ /**
342
+ * This looks through all posts and marks those which contain Crayons
343
+ */
344
  // public static function scan_and_save_posts() {
345
  // self::save_posts(CrayonWP::scan_posts(TRUE, TRUE));
346
  // }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
347
 
348
+ /**
349
+ * Saves the marked posts to the db
350
+ */
351
+ public static function save_legacy_posts($posts = NULL) {
352
+ if ($posts === NULL) {
353
+ $posts = self::$crayon_legacy_posts;
354
+ }
355
+ update_option(self::LEGACY_POSTS, $posts);
356
+ self::load_legacy_posts();
357
+ }
358
+
359
+ /**
360
+ * Adds a post as containing a Crayon
361
+ */
362
+ public static function add_legacy_post($id) {
363
+ self::load_legacy_posts();
364
+ if (!in_array($id, self::$crayon_legacy_posts)) {
365
+ self::$crayon_legacy_posts[] = $id;
366
+ }
367
+ self::save_legacy_posts();
368
+ }
369
+
370
+ /**
371
+ * Removes a post as not containing a Crayon
372
+ */
373
+ public static function remove_legacy_post($id) {
374
+ self::load_legacy_posts();
375
+ $key = array_search($id, self::$crayon_legacy_posts);
376
+ if ($key === false) {
377
+ return;
378
+ }
379
+ unset(self::$crayon_legacy_posts[$key]);
380
+ self::save_legacy_posts();
381
+ }
382
+
383
+ public static function remove_legacy_posts() {
384
+ self::$crayon_legacy_posts = array();
385
+ self::save_legacy_posts();
386
+ }
387
+
388
+ // Cache
389
+
390
+ public static function add_cache($name) {
391
+ self::load_cache();
392
+ if (!in_array($name, self::$cache)) {
393
+ self::$cache[] = $name;
394
+ }
395
+ self::save_cache();
396
+ }
397
+
398
+ public static function remove_cache($name) {
399
+ self::load_cache();
400
+ $key = array_search($name, self::$cache);
401
+ if ($key === false) {
402
+ return;
403
+ }
404
+ unset(self::$cache[$key]);
405
+ self::save_cache();
406
+ }
407
+
408
+ public static function clear_cache() {
409
+ self::load_cache();
410
+ foreach (self::$cache as $name) {
411
+ delete_transient($name);
412
+ }
413
+ self::$cache = array();
414
+ self::save_cache();
415
+ }
416
+
417
+ public static function load_cache() {
418
+ // Load cache from db
419
+ if (!(self::$cache = get_option(self::CACHE))) {
420
+ self::$cache = array();
421
+ update_option(self::CACHE, self::$cache);
422
+ }
423
+ }
424
+
425
+ public static function save_cache() {
426
+ update_option(self::CACHE, self::$cache);
427
+ self::load_cache();
428
+ }
429
+
430
+ // Paths
431
+
432
+ public static function admin_init() {
433
+ // Load default settings if they don't exist
434
+ self::load_settings();
435
+
436
+ // General
437
+ // Some of these will the $editor arguments, if TRUE it will alter for use in the Tag Editor
438
+ self::add_section(self::GENERAL, crayon__('General'));
439
+ self::add_field(self::GENERAL, crayon__('Theme'), 'theme');
440
+ self::add_field(self::GENERAL, crayon__('Font'), 'font');
441
+ self::add_field(self::GENERAL, crayon__('Metrics'), 'metrics');
442
+ self::add_field(self::GENERAL, crayon__('Toolbar'), 'toolbar');
443
+ self::add_field(self::GENERAL, crayon__('Lines'), 'lines');
444
+ self::add_field(self::GENERAL, crayon__('Code'), 'code');
445
+ self::add_field(self::GENERAL, crayon__('Tags'), 'tags');
446
+ self::add_field(self::GENERAL, crayon__('Languages'), 'langs');
447
+ self::add_field(self::GENERAL, crayon__('Files'), 'files');
448
+ self::add_field(self::GENERAL, crayon__('Posts'), 'posts');
449
+ self::add_field(self::GENERAL, crayon__('Tag Editor'), 'tag_editor');
450
+ self::add_field(self::GENERAL, crayon__('Misc'), 'misc');
451
+
452
+ // Debug
453
+ self::add_section(self::DEBUG, crayon__('Debug'));
454
+ self::add_field(self::DEBUG, crayon__('Errors'), 'errors');
455
+ self::add_field(self::DEBUG, crayon__('Log'), 'log');
456
+ // ABOUT
457
+
458
+ self::add_section(self::ABOUT, crayon__('About'));
459
+ $image = '<div id="crayon-logo">
460
 
461
  <img src="' . plugins_url(CRAYON_LOGO, __FILE__) . '" /><br/></div>';
462
+ self::add_field(self::ABOUT, $image, 'info');
463
+ }
464
+
465
+ // Wrapper functions
466
+
467
+ private static function add_section($name, $title, $callback = NULL) {
468
+ $callback = (empty($callback) ? 'blank' : $callback);
469
+ add_settings_section($name, $title, 'CrayonSettingsWP::' . $callback, self::SETTINGS);
470
+ }
471
+
472
+ private static function add_field($section, $title, $callback, $args = array()) {
473
+ $unique = preg_replace('#\\s#', '_', strtolower($title));
474
+ add_settings_field($unique, $title, 'CrayonSettingsWP::' . $callback, self::SETTINGS, $section, $args);
475
+ }
476
+
477
+ // Validates all the settings passed from the form in $inputs
478
+
479
+ public static function settings_validate($inputs) {
480
+ // Load current settings from db
481
+ self::load_settings(TRUE);
482
+
483
+ global $CRAYON_EMAIL;
484
+ // When reset button is pressed, remove settings so default loads next time
485
+ if (array_key_exists('reset', $inputs)) {
486
+ self::clear_cache();
487
+ return array();
488
+ }
489
+ // Convert old tags
490
+ if (array_key_exists('convert', $inputs)) {
491
+ $encode = array_key_exists('convert_encode', $inputs);
492
+ CrayonWP::convert_tags($encode);
493
+ }
494
+ // Refresh internal tag management
495
+ if (array_key_exists('refresh_tags', $inputs)) {
496
+ CrayonWP::refresh_posts();
497
+ }
498
+ // Clear the log if needed
499
+ if (array_key_exists(self::LOG_CLEAR, $_POST)) {
500
+ CrayonLog::clear();
501
+ }
502
+ // Send to admin
503
+ if (array_key_exists(self::LOG_EMAIL_ADMIN, $_POST)) {
504
+ CrayonLog::email(get_bloginfo('admin_email'));
505
+ }
506
+ // Send to developer
507
+ if (array_key_exists(self::LOG_EMAIL_DEV, $_POST)) {
508
+ CrayonLog::email($CRAYON_EMAIL, get_bloginfo('admin_email'));
509
+ }
510
+
511
+ // Clear the cache
512
+ if (array_key_exists('crayon-cache-clear', $_POST)) {
513
+ self::clear_cache();
514
+ }
515
+
516
+ // Validate inputs
517
+ foreach ($inputs as $input => $value) {
518
+ // Convert all array setting values to ints
519
+ $inputs[$input] = CrayonSettings::validate($input, $value);
520
+ // Clear cache when changed
521
+ if ($input == CrayonSettings::CACHE && $value != CrayonGlobalSettings::val(CrayonSettings::CACHE)) {
522
+ self::clear_cache();
523
+ }
524
+ }
525
+
526
+ // If settings don't exist in input, set them to default
527
+ $global_settings = CrayonSettings::get_defaults();
528
+
529
+ $ignored = array(CrayonSettings::HIDE_HELP);
530
+
531
+ foreach ($global_settings as $setting) {
532
+ // XXX Ignore some settings
533
+ if (in_array($setting->name(), $ignored)) {
534
+ $inputs[$setting->name()] = CrayonGlobalSettings::val($setting->name());
535
+ continue;
536
+ }
537
+
538
+ // If boolean setting is not in input, then it is set to FALSE in the form
539
+ if (!array_key_exists($setting->name(), $inputs)) {
540
+ // For booleans, set to FALSE (unchecked boxes are not sent as POST)
541
+ if (is_bool($setting->def())) {
542
+ $inputs[$setting->name()] = FALSE;
543
+ } else {
544
+ /* For array settings, set the input as the value, which by default is the
545
+ default index */
546
+ if (is_array($setting->def())) {
547
+ $inputs[$setting->name()] = $setting->value();
548
+ } else {
549
+ $inputs[$setting->name()] = $setting->def();
550
+ }
551
+ }
552
+ }
553
+ }
554
+
555
+ return $inputs;
556
+ }
557
+
558
+ // Section callback functions
559
+
560
+ public static function blank() {
561
+ } // Used for required callbacks with blank content
562
+
563
+ // Input Drawing ==========================================================
564
+
565
+ private static function textbox($args) {
566
+ $id = '';
567
+ $size = 40;
568
+ $margin = FALSE;
569
+ $preview = 1;
570
+ $break = FALSE;
571
+ extract($args);
572
+
573
+ echo '<input id="', CrayonSettings::PREFIX, $id, '" name="', self::OPTIONS, '[', $id, ']" class="' . CrayonSettings::SETTING . '" size="', $size, '" type="text" value="',
574
+ self::$options[$id], '" style="margin-left: ', ($margin ? '20px' : '0px'), ';" crayon-preview="', ($preview ? 1 : 0), '" />', ($break ? CRAYON_BR : '');
575
+ }
576
+
577
+ private static function checkbox($args, $line_break = TRUE, $preview = TRUE) {
578
+ if (empty($args) || !is_array($args) || count($args) != 2) {
579
+ return;
580
+ }
581
+ $id = $args[0];
582
+ $text = $args[1];
583
+ $checked = (!array_key_exists($id, self::$options)) ? FALSE : self::$options[$id] == TRUE;
584
+ $checked_str = $checked ? ' checked="checked"' : '';
585
+ echo '<input id="', CrayonSettings::PREFIX, $id, '" name="', self::OPTIONS, '[', $id, ']" type="checkbox" class="' . CrayonSettings::SETTING . '" value="1"', $checked_str,
586
+ ' crayon-preview="', ($preview ? 1 : 0), '" /> ', '<label for="', CrayonSettings::PREFIX, $id, '">', $text, '</label>', ($line_break ? CRAYON_BR : '');
587
+ }
588
+
589
+ // Draws a dropdown by loading the default value (an array) from a setting
590
+ private static function dropdown($id, $line_break = TRUE, $preview = TRUE, $echo = TRUE, $resources = NULL, $selected = NULL) {
591
+ if (!array_key_exists($id, self::$options)) {
592
+ return;
593
+ }
594
+ $resources = $resources != NULL ? $resources : CrayonGlobalSettings::get($id)->def();
595
+
596
+ $return = '<select id="' . CrayonSettings::PREFIX . $id . '" name="' . self::OPTIONS . '[' . $id . ']" class="' . CrayonSettings::SETTING . '" crayon-preview="' . ($preview ? 1 : 0) . '">';
597
+ foreach ($resources as $k => $v) {
598
+ if (is_array($v) && count($v)) {
599
+ $data = $v[0];
600
+ $text = $v[1];
601
+ } else {
602
+ $text = $v;
603
+ }
604
+ $is_selected = $selected !== NULL && $selected == $k ? 'selected' : selected(self::$options[$id], $k, FALSE);
605
+ $return .= '<option ' . (isset($data) ? 'data-value="' . $data . '"' : '') . ' value="' . $k . '" ' . $is_selected . '>' . $text . '</option>';
606
+ }
607
+ $return .= '</select>' . ($line_break ? CRAYON_BR : '');
608
+ if ($echo) {
609
+ echo $return;
610
+ } else {
611
+ return $return;
612
+ }
613
+ }
614
+
615
+ private static function button($args = array()) {
616
+ extract($args);
617
+ CrayonUtil::set_var($id, '');
618
+ CrayonUtil::set_var($class, '');
619
+ CrayonUtil::set_var($onclick, '');
620
+ CrayonUtil::set_var($title, '');
621
+ return '<a id="' . $id . '" class="button-primary ' . $class . '" onclick="' . $onclick . '">' . $title . '</a>';
622
+ }
623
+
624
+ private static function info_span($name, $text) {
625
+ echo '<span id="', $name, '-info">', $text, '</span>';
626
+ }
627
+
628
+ private static function span($text) {
629
+ echo '<span>', $text, '</span>';
630
+ }
631
+
632
+ // General Fields =========================================================
633
+ public static function help() {
634
+ global $CRAYON_WEBSITE, $CRAYON_TWITTER, $CRAYON_GIT, $CRAYON_PLUGIN_WP, $CRAYON_DONATE;
635
+ if (CrayonGlobalSettings::val(CrayonSettings::HIDE_HELP)) {
636
+ return;
637
+ }
638
+ echo '
639
  <div id="crayon-help" class="updated settings-error crayon-help">
640
+ <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>
 
641
  ';
642
+ }
643
 
644
  // public static function get_crayon_help_file() {
645
  // // Load help
651
  // return $help;
652
  // }
653
 
654
+ public static function help_screen() {
655
+ $screen = get_current_screen();
656
 
657
+ if ($screen->id != self::$admin_page) {
658
+ return;
659
+ }
660
+
661
+ // Add my_help_tab if current screen is My Admin Page
662
  // $screen->add_help_tab( array(
663
  // 'id' => 'crayon_help_tab',
664
  // 'title' => crayon__('Crayon Help'),
665
  // 'content' => self::get_crayon_help_file() // TODO consider adding tranlations for help
666
  // ) );
667
+ }
668
 
669
+ // XXX Depreciated since WP 3.3
670
  // public static function cont_help($contextual_help, $screen_id, $screen) {
671
  // if ($screen_id == self::$admin_page) {
672
  // return self::get_crayon_help_file();
674
  // return $contextual_help;
675
  // }
676
 
677
+ public static function metrics() {
678
+ echo '<div id="crayon-section-metrics" class="crayon-hide-inline">';
679
+ self::checkbox(array(CrayonSettings::HEIGHT_SET, '<span class="crayon-span-50">' . crayon__('Height') . ' </span>'), FALSE);
680
+ self::dropdown(CrayonSettings::HEIGHT_MODE, FALSE);
681
+ echo ' ';
682
+ self::textbox(array('id' => CrayonSettings::HEIGHT, 'size' => 8));
683
+ echo ' ';
684
+ self::dropdown(CrayonSettings::HEIGHT_UNIT);
685
+ self::checkbox(array(CrayonSettings::WIDTH_SET, '<span class="crayon-span-50">' . crayon__('Width') . ' </span>'), FALSE);
686
+ self::dropdown(CrayonSettings::WIDTH_MODE, FALSE);
687
+ echo ' ';
688
+ self::textbox(array('id' => CrayonSettings::WIDTH, 'size' => 8));
689
+ echo ' ';
690
+ self::dropdown(CrayonSettings::WIDTH_UNIT);
691
+ $text = array(crayon__('Top Margin') => array(CrayonSettings::TOP_SET, CrayonSettings::TOP_MARGIN),
692
+ crayon__('Bottom Margin') => array(CrayonSettings::BOTTOM_SET, CrayonSettings::BOTTOM_MARGIN),
693
+ crayon__('Left Margin') => array(CrayonSettings::LEFT_SET, CrayonSettings::LEFT_MARGIN),
694
+ crayon__('Right Margin') => array(CrayonSettings::RIGHT_SET, CrayonSettings::RIGHT_MARGIN));
695
+ foreach ($text as $p => $s) {
696
+ $set = $s[0];
697
+ $margin = $s[1];
698
+ $preview = ($p == crayon__('Left Margin') || $p == crayon__('Right Margin'));
699
+ self::checkbox(array($set, '<span class="crayon-span-110">' . $p . '</span>'), FALSE, $preview);
700
+ echo ' ';
701
+ self::textbox(array('id' => $margin, 'size' => 8, 'preview' => FALSE));
702
+ echo '<span class="crayon-span-margin">', crayon__('Pixels'), '</span>', CRAYON_BR;
703
+ }
704
+ echo '<span class="crayon-span" style="min-width: 135px;">' . crayon__('Horizontal Alignment') . ' </span>';
705
+ self::dropdown(CrayonSettings::H_ALIGN);
706
+ echo '<div id="crayon-subsection-float">';
707
+ self::checkbox(array(CrayonSettings::FLOAT_ENABLE, crayon__('Allow floating elements to surround Crayon')), FALSE, FALSE);
708
+ echo '</div>';
709
+ echo '<span class="crayon-span-100">' . crayon__('Inline Margin') . ' </span>';
710
+ self::textbox(array('id' => CrayonSettings::INLINE_MARGIN, 'size' => 2));
711
+ echo '<span class="crayon-span-margin">', crayon__('Pixels'), '</span>';
712
+ echo '</div>';
713
+ }
714
+
715
+ public static function toolbar() {
716
+ echo '<div id="crayon-section-toolbar" class="crayon-hide-inline">';
717
+ self::span(crayon__('Display the Toolbar') . ' ');
718
+ self::dropdown(CrayonSettings::TOOLBAR);
719
+ echo '<div id="crayon-subsection-toolbar">';
720
+ self::checkbox(array(CrayonSettings::TOOLBAR_OVERLAY, crayon__('Overlay the toolbar on code rather than push it down when possible')));
721
+ self::checkbox(array(CrayonSettings::TOOLBAR_HIDE, crayon__('Toggle the toolbar on single click when it is overlayed')));
722
+ self::checkbox(array(CrayonSettings::TOOLBAR_DELAY, crayon__('Delay hiding the toolbar on MouseOut')));
723
+ echo '</div>';
724
+ self::checkbox(array(CrayonSettings::SHOW_TITLE, crayon__('Display the title when provided')));
725
+ self::span(crayon__('Display the language') . ' ');
726
+ self::dropdown(CrayonSettings::SHOW_LANG);
727
+ echo '</div>';
728
+ }
729
+
730
+ public static function lines() {
731
+ echo '<div id="crayon-section-lines" class="crayon-hide-inline">';
732
+ self::checkbox(array(CrayonSettings::STRIPED, crayon__('Display striped code lines')));
733
+ self::checkbox(array(CrayonSettings::MARKING, crayon__('Enable line marking for important lines')));
734
+ self::checkbox(array(CrayonSettings::RANGES, crayon__('Enable line ranges for showing only parts of code')));
735
+ self::checkbox(array(CrayonSettings::NUMS, crayon__('Display line numbers by default')));
736
+ self::checkbox(array(CrayonSettings::NUMS_TOGGLE, crayon__('Enable line number toggling')));
737
+ self::checkbox(array(CrayonSettings::WRAP, crayon__('Wrap lines by default')));
738
+ self::checkbox(array(CrayonSettings::WRAP_TOGGLE, crayon__('Enable line wrap toggling')));
739
+ self::span(crayon__('Start line numbers from') . ' ');
740
+ self::textbox(array('id' => CrayonSettings::START_LINE, 'size' => 2, 'break' => TRUE));
741
+ echo '</div>';
742
+ }
743
+
744
+ public static function langs() {
745
+ echo '<a name="langs"></a>';
746
+ // Specialised dropdown for languages
747
+ if (array_key_exists(CrayonSettings::FALLBACK_LANG, self::$options)) {
748
+ if (($langs = CrayonParser::parse_all()) != FALSE) {
749
+ $langs = CrayonLangs::sort_by_name($langs);
750
+ self::span(crayon__('When no language is provided, use the fallback') . ': ');
751
+ self::dropdown(CrayonSettings::FALLBACK_LANG, FALSE, TRUE, TRUE, $langs);
752
+ // Information about parsing
753
+ $parsed = CrayonResources::langs()->is_parsed();
754
+ $count = count($langs);
755
+ echo '</select>', CRAYON_BR, ($parsed ? '' : '<span class="crayon-error">'),
756
+ sprintf(crayon_n('%d language has been detected.', '%d languages have been detected.', $count), $count), ' ',
757
+ $parsed ? crayon__('Parsing was successful') : crayon__('Parsing was unsuccessful'),
758
+ ($parsed ? '. ' : '</span>');
759
+ // Check if fallback from db is loaded
760
+ $db_fallback = self::$options[CrayonSettings::FALLBACK_LANG]; // Fallback name from db
761
+
762
+ if (!CrayonResources::langs()->is_loaded($db_fallback) || !CrayonResources::langs()->exists($db_fallback)) {
763
+ echo '<br/><span class="crayon-error">', sprintf(crayon__('The selected language with id %s could not be loaded'), '<strong>' . $db_fallback . '</strong>'), '. </span>';
764
+ }
765
+ // Language parsing info
766
+ echo CRAYON_BR, '<div id="crayon-subsection-langs-info"><div>' . self::button(array('id' => 'show-langs', 'title' => crayon__('Show Languages'))) . '</div></div>';
767
+ } else {
768
+ echo 'No languages could be parsed.';
769
+ }
770
+ }
771
+ }
772
+
773
+ public static function show_langs() {
774
+ require_once (CRAYON_PARSER_PHP);
775
+ if (($langs = CrayonParser::parse_all()) != FALSE) {
776
+ $langs = CrayonLangs::sort_by_name($langs);
777
+ echo '<table class="crayon-table" cellspacing="0" cellpadding="0"><tr class="crayon-table-header">',
778
+ '<td>ID</td><td>Name</td><td>Version</td><td>File Extensions</td><td>Aliases</td><td>State</td></tr>';
779
+ $keys = array_values($langs);
780
+ for ($i = 0; $i < count($langs); $i++) {
781
+ $lang = $keys[$i];
782
+ $tr = ($i == count($langs) - 1) ? 'crayon-table-last' : '';
783
+ echo '<tr class="', $tr, '">',
784
+ '<td>', $lang->id(), '</td>',
785
+ '<td>', $lang->name(), '</td>',
786
+ '<td>', $lang->version(), '</td>',
787
+ '<td>', implode(', ', $lang->ext()), '</td>',
788
+ '<td>', implode(', ', $lang->alias()), '</td>',
789
+ '<td class="', strtolower(CrayonUtil::space_to_hyphen($lang->state_info())), '">',
790
+ $lang->state_info(), '</td>',
791
+ '</tr>';
792
+ }
793
+ echo '</table><br/>Languages that have the same extension as their name don\'t need to explicitly map extensions.';
794
+ } else {
795
+ echo 'No languages could be found.';
796
+ }
797
+ exit();
798
+ }
799
+
800
+ public static function posts() {
801
+ echo '<a name="posts"></a>';
802
+ echo self::button(array('id' => 'show-posts', 'title' => crayon__('Show Crayon Posts')));
803
+ echo ' <input type="submit" name="', self::OPTIONS, '[refresh_tags]" id="refresh_tags" class="button-primary" value="', crayon__('Refresh'), '" />';
804
+ echo self::help_button('http://bit.ly/NQfZN5');
805
+ echo '<div id="crayon-subsection-posts-info"></div>';
806
+ }
807
+
808
+ public static function post_cmp($a, $b) {
809
+ $a = $a->post_modified;
810
+ $b = $b->post_modified;
811
+ if ($a == $b) {
812
+ return 0;
813
+ } else {
814
+ return $a < $b ? 1 : -1;
815
+ }
816
+ }
817
+
818
+ public static function show_posts() {
819
+ $postIDs = self::load_posts();
820
+ $legacy_posts = self::load_legacy_posts();
821
+ // Avoids O(n^2) by using a hash map, tradeoff in using strval
822
+ $legacy_map = array();
823
+ foreach ($legacy_posts as $legacyID) {
824
+ $legacy_map[strval($legacyID)] = TRUE;
825
+ }
826
+
827
+ echo '<table class="crayon-table" cellspacing="0" cellpadding="0"><tr class="crayon-table-header">',
828
+ '<td>', crayon__('ID'), '</td><td>', crayon__('Title'), '</td><td>', crayon__('Posted'), '</td><td>', crayon__('Modifed'), '</td><td>', crayon__('Contains Legacy Tags?'), '</td></tr>';
829
+
830
+ $posts = array();
831
+ for ($i = 0; $i < count($postIDs); $i++) {
832
+ $posts[$i] = get_post($postIDs[$i]);
833
+ }
834
+
835
+ usort($posts, 'CrayonSettingsWP::post_cmp');
836
+
837
+ for ($i = 0; $i < count($posts); $i++) {
838
+ $post = $posts[$i];
839
+ $postID = $post->ID;
840
+ $title = $post->post_title;
841
+ $title = !empty($title) ? $title : 'N/A';
842
+ $tr = ($i == count($posts) - 1) ? 'crayon-table-last' : '';
843
+ echo '<tr class="', $tr, '">',
844
+ '<td>', $postID, '</td>',
845
+ '<td><a href="', $post->guid, '" target="_blank">', $title, '</a></td>',
846
+ '<td>', $post->post_date, '</td>',
847
+ '<td>', $post->post_modified, '</td>',
848
+ '<td>', isset($legacy_map[strval($postID)]) ? '<span style="color: red;">' . crayon__('Yes') . '</a>' : crayon__('No'), '</td>',
849
+ '</tr>';
850
+ }
851
+
852
+ echo '</table>';
853
+ exit();
854
+ }
855
+
856
+ public static function show_preview() {
857
+ echo '<div id="content">';
858
+
859
+ self::load_settings(); // Run first to ensure global settings loaded
860
+
861
+ $crayon = CrayonWP::instance();
862
+
863
+ // Settings to prevent from validating
864
+ $preview_settings = array();
865
+
866
+ // Load settings from GET and validate
867
+ foreach ($_POST as $key => $value) {
868
+ // echo $key, ' ', $value , '<br/>';
869
+ if (!in_array($key, $preview_settings)) {
870
+ $_POST[$key] = CrayonSettings::validate($key, $value);
871
+ }
872
+ }
873
+ $crayon->settings($_POST);
874
+ if (!isset($crayon_preview_dont_override_get) || !$crayon_preview_dont_override_get) {
875
+ $settings = array(CrayonSettings::TOP_SET => TRUE, CrayonSettings::TOP_MARGIN => 10,
876
+ CrayonSettings::BOTTOM_SET => FALSE, CrayonSettings::BOTTOM_MARGIN => 0);
877
+ $crayon->settings($settings);
878
+ }
879
+
880
+ // Print the theme CSS
881
+ $theme_id = $crayon->setting_val(CrayonSettings::THEME);
882
+ if ($theme_id != NULL) {
883
+ echo CrayonResources::themes()->get_css($theme_id, date('U'));
884
+ }
885
+
886
+ $font_id = $crayon->setting_val(CrayonSettings::FONT);
887
+ if ($font_id != NULL /*&& $font_id != CrayonFonts::DEFAULT_FONT*/) {
888
+ echo CrayonResources::fonts()->get_css($font_id);
889
+ }
890
+
891
+ // Load custom code based on language
892
+ $lang = $crayon->setting_val(CrayonSettings::FALLBACK_LANG);
893
+ $path = crayon_pf(CRAYON_UTIL_PATH . '/sample/' . $lang . '.txt', FALSE);
894
+
895
+ if ($lang && @file_exists($path)) {
896
+ $crayon->url($path);
897
+ } else {
898
+ $code = "
899
  // A sample class
900
  class Human {
901
  private int age = 0;
905
  }
906
  }
907
  ";
908
+ $crayon->code($code);
909
+ }
910
+ $crayon->title('Sample Code');
911
+ $crayon->marked('5-7');
912
+ $crayon->output($highlight = true, $nums = true, $print = true);
913
+ echo '</div>';
914
+ crayon_load_plugin_textdomain();
915
+ exit();
916
+ }
917
+
918
+ public static function theme($editor = FALSE) {
919
+ $db_theme = self::$options[CrayonSettings::THEME]; // Theme name from db
920
+ if (!array_key_exists(CrayonSettings::THEME, self::$options)) {
921
+ $db_theme = '';
922
+ }
923
+ $themes_array = CrayonResources::themes()->get_array();
924
+ // Mark user themes
925
+ foreach ($themes_array as $id => $name) {
926
+ $mark = CrayonResources::themes()->get($id)->user() ? ' *' : '';
927
+ $themes_array[$id] = array($name, $name . $mark);
928
+ }
929
+ $missing_theme = !CrayonResources::themes()->is_loaded($db_theme) || !CrayonResources::themes()->exists($db_theme);
930
+ self::dropdown(CrayonSettings::THEME, FALSE, FALSE, TRUE, $themes_array, $missing_theme ? CrayonThemes::DEFAULT_THEME : NULL);
931
+ if ($editor) {
932
+ return;
933
+ }
934
+ // Theme editor
935
+ if (CRAYON_THEME_EDITOR) {
936
+ // echo '<a id="crayon-theme-editor-button" class="button-primary crayon-admin-button" loading="'. crayon__('Loading...') .'" loaded="'. crayon__('Theme Editor') .'" >'. crayon__('Theme Editor') .'</a></br>';
937
+ echo '<div id="crayon-theme-editor-admin-buttons">';
938
+ $buttons = array('edit' => crayon__('Edit'), 'duplicate' => crayon__('Duplicate'), 'submit' => crayon__('Submit'),
939
+ 'delete' => crayon__('Delete'));
940
+ foreach ($buttons as $k => $v) {
941
+ echo '<a id="crayon-theme-editor-', $k, '-button" class="button-secondary crayon-admin-button" loading="', crayon__('Loading...'), '" loaded="', $v, '" >', $v, '</a>';
942
+ }
943
+ echo '<span class="crayon-span-5"></span>', self::help_button('http://bit.ly/crayon-themes'), '<span class="crayon-span-5"></span>', crayon__("Duplicate a Stock Theme into a User Theme to allow editing.");
944
+ echo '</br></div>';
945
+ }
946
+ // Preview Box
947
+ ?>
948
+ <div id="crayon-theme-panel">
949
+ <div id="crayon-theme-info"></div>
950
+ <div id="crayon-live-preview-wrapper">
951
+ <div id="crayon-live-preview"></div>
952
+ </div>
953
+ <div id="crayon-preview-info">
954
+ <?php printf(crayon__('Change the %1$sfallback language%2$s to change the sample code. Lines 5-7 are marked.'), '<a href="#langs">', '</a>'); ?>
955
+ </div>
956
+ </div>
957
+ <?php
958
+ // Preview checkbox
959
+ self::checkbox(array(CrayonSettings::PREVIEW, crayon__('Enable Live Preview')), FALSE, FALSE);
960
+ echo '</select><span class="crayon-span-10"></span>';
961
+ self::checkbox(array(CrayonSettings::ENQUEUE_THEMES, crayon__('Enqueue themes in the header (more efficient).') . self::help_button('http://bit.ly/zTUAQV')));
962
+ // Check if theme from db is loaded
963
+ if ($missing_theme) {
964
+ echo '<span class="crayon-error">', sprintf(crayon__('The selected theme with id %s could not be loaded'), '<strong>' . $db_theme . '</strong>'), '. </span>';
965
+ }
966
+ }
967
+
968
+ public static function font($editor = FALSE) {
969
+ $db_font = self::$options[CrayonSettings::FONT]; // Theme name from db
970
+ if (!array_key_exists(CrayonSettings::FONT, self::$options)) {
971
+ $db_font = '';
972
+ }
973
+ $fonts_array = CrayonResources::fonts()->get_array();
974
+ self::dropdown(CrayonSettings::FONT, FALSE, TRUE, TRUE, $fonts_array);
975
+ echo '<span class="crayon-span-10"></span>';
976
+ self::checkbox(array(CrayonSettings::FONT_SIZE_ENABLE, crayon__('Custom Font Size') . ' '), FALSE);
977
+ self::textbox(array('id' => CrayonSettings::FONT_SIZE, 'size' => 2));
978
+ echo '<span class="crayon-span-margin">', crayon__('Pixels'), '</span></br>';
979
+ if ((!CrayonResources::fonts()->is_loaded($db_font) || !CrayonResources::fonts()->exists($db_font))) {
980
+ // Default font doesn't actually exist as a file, it means do not override default theme font
981
+ echo '<span class="crayon-error">', sprintf(crayon__('The selected font with id %s could not be loaded'), '<strong>' . $db_font . '</strong>'), '. </span><br/>';
982
+ }
983
+ if ($editor) {
984
+ return;
985
+ }
986
+ echo '<div style="height:10px;"></div>';
987
+ self::checkbox(array(CrayonSettings::ENQUEUE_FONTS, crayon__('Enqueue fonts in the header (more efficient).') . self::help_button('http://bit.ly/zTUAQV')));
988
+ }
989
+
990
+ public static function code($editor = FALSE) {
991
+ echo '<div id="crayon-section-code-interaction" class="crayon-hide-inline-only">';
992
+ self::checkbox(array(CrayonSettings::PLAIN, crayon__('Enable plain code view and display') . ' '), FALSE);
993
+ self::dropdown(CrayonSettings::SHOW_PLAIN);
994
+ echo '<span id="crayon-subsection-copy-check">';
995
+ self::checkbox(array(CrayonSettings::PLAIN_TOGGLE, crayon__('Enable plain code toggling')));
996
+ self::checkbox(array(CrayonSettings::SHOW_PLAIN_DEFAULT, crayon__('Show the plain code by default')));
997
+ self::checkbox(array(CrayonSettings::COPY, crayon__('Enable code copy/paste')));
998
+ echo '</span>';
999
+ self::checkbox(array(CrayonSettings::POPUP, crayon__('Enable opening code in a window')));
1000
+ self::checkbox(array(CrayonSettings::SCROLL, crayon__('Always display scrollbars')));
1001
+ self::checkbox(array(CrayonSettings::EXPAND, crayon__('Expand code beyond page borders on mouseover')));
1002
+ self::checkbox(array(CrayonSettings::EXPAND_TOGGLE, crayon__('Enable code expanding toggling when possible')));
1003
+ echo '</div>';
1004
+ if (!$editor) {
1005
+ self::checkbox(array(CrayonSettings::DECODE, crayon__('Decode HTML entities in code')));
1006
+ }
1007
+ self::checkbox(array(CrayonSettings::DECODE_ATTRIBUTES, crayon__('Decode HTML entities in attributes')));
1008
+ echo '<div class="crayon-hide-inline-only">';
1009
+ self::checkbox(array(CrayonSettings::TRIM_WHITESPACE, crayon__('Remove whitespace surrounding the shortcode content')));
1010
+ echo '</div>';
1011
+ self::checkbox(array(CrayonSettings::MIXED, crayon__('Allow Mixed Language Highlighting with delimiters and tags.') . self::help_button('http://bit.ly/ukwts2')));
1012
+ echo '<div class="crayon-hide-inline-only">';
1013
+ self::checkbox(array(CrayonSettings::SHOW_MIXED, crayon__('Show Mixed Language Icon (+)')));
1014
+ echo '</div>';
1015
+ self::span(crayon__('Tab size in spaces') . ': ');
1016
+ self::textbox(array('id' => CrayonSettings::TAB_SIZE, 'size' => 2, 'break' => TRUE));
1017
+ self::span(crayon__('Blank lines before code:') . ' ');
1018
+ self::textbox(array('id' => CrayonSettings::WHITESPACE_BEFORE, 'size' => 2, 'break' => TRUE));
1019
+ self::span(crayon__('Blank lines after code:') . ' ');
1020
+ self::textbox(array('id' => CrayonSettings::WHITESPACE_AFTER, 'size' => 2, 'break' => TRUE));
1021
+ }
1022
+
1023
+ public static function tags() {
1024
+ echo '<div class="note" style="width: 350px;">', sprintf(crayon__("Using this markup for Mini Tags and Inline tags is now %sdepreciated%s! Use the %sTag Editor%s instead and convert legacy tags."), '<a href="#" target="_blank">', '</a>', '<a href="#" target="_blank">', '</a>'), '</div>';
1025
+ self::checkbox(array(CrayonSettings::CAPTURE_MINI_TAG, crayon__('Capture Mini Tags like [php][/php] as Crayons.') . self::help_button('http://bit.ly/rRZuzk')));
1026
+ self::checkbox(array(CrayonSettings::INLINE_TAG, crayon__('Capture Inline Tags like {php}{/php} inside sentences.') . self::help_button('http://bit.ly/yFafFL')));
1027
+ self::checkbox(array(CrayonSettings::INLINE_WRAP, crayon__('Wrap Inline Tags') . self::help_button('http://bit.ly/yFafFL')));
1028
+ self::checkbox(array(CrayonSettings::BACKQUOTE, crayon__('Capture `backquotes` as &lt;code&gt;') . self::help_button('http://bit.ly/yFafFL')));
1029
+ self::checkbox(array(CrayonSettings::CAPTURE_PRE, crayon__('Capture &lt;pre&gt; tags as Crayons') . self::help_button('http://bit.ly/rRZuzk')));
1030
+ self::checkbox(array(CrayonSettings::PLAIN_TAG, crayon__('Enable [plain][/plain] tag.') . self::help_button('http://bit.ly/rRZuzk')));
1031
+ }
1032
+
1033
+ public static function files() {
1034
+ echo '<a name="files"></a>';
1035
+ echo crayon__('When loading local files and a relative path is given for the URL, use the absolute path'), ': ',
1036
+ '<div style="margin-left: 20px">', home_url(), '/';
1037
+ self::textbox(array('id' => CrayonSettings::LOCAL_PATH));
1038
+ echo '</div>', crayon__('Followed by your relative URL.');
1039
+ }
1040
+
1041
+ public static function tag_editor() {
1042
+ $can_convert = self::load_legacy_posts();
1043
+ if ($can_convert) {
1044
+ $disabled = '';
1045
+ $convert_text = crayon__('Convert Legacy Tags');
1046
+ } else {
1047
+ $disabled = 'disabled="disabled"';
1048
+ $convert_text = crayon__('No Legacy Tags Found');
1049
+ }
1050
+
1051
+ echo '<input type="submit" name="', self::OPTIONS, '[convert]" id="convert" class="button-primary" value="', $convert_text, '"', $disabled, ' />&nbsp; ';
1052
+ self::checkbox(array('convert_encode', crayon__("Encode")), FALSE);
1053
+ echo self::help_button('http://bit.ly/ReRr0i'), CRAYON_BR, CRAYON_BR;
1054
+ $sep = sprintf(crayon__('Use %s to separate setting names from values in the &lt;pre&gt; class attribute'),
1055
+ self::dropdown(CrayonSettings::ATTR_SEP, FALSE, FALSE, FALSE));
1056
+ echo '<span>', $sep, self::help_button('http://bit.ly/H3xW3D'), '</span><br/>';
1057
+ self::checkbox(array(CrayonSettings::TAG_EDITOR_FRONT, crayon__("Display the Tag Editor in any TinyMCE instances on the frontend (e.g. bbPress)") . self::help_button('http://bit.ly/TyYyll')));
1058
+ self::checkbox(array(CrayonSettings::TAG_EDITOR_SETTINGS, crayon__("Display Tag Editor settings on the frontend")));
1059
+ }
1060
+
1061
+ public static function misc() {
1062
+ echo crayon__('Clear the cache used to store remote code requests'), ': ';
1063
+ self::dropdown(CrayonSettings::CACHE, false);
1064
+ echo '<input type="submit" id="crayon-cache-clear" name="crayon-cache-clear" class="button-secondary" value="', crayon__('Clear Now'), '" /><br/>';
1065
+ self::checkbox(array(CrayonSettings::EFFICIENT_ENQUEUE, crayon__('Attempt to load Crayon\'s CSS and JavaScript only when needed') . self::help_button('http://ak.net84.net/?p=660')));
1066
+ self::checkbox(array(CrayonSettings::SAFE_ENQUEUE, crayon__('Disable enqueuing for page templates that may contain The Loop.') . self::help_button('http://bit.ly/AcWRNY')));
1067
+ self::checkbox(array(CrayonSettings::COMMENTS, crayon__('Allow Crayons inside comments')));
1068
+ self::checkbox(array(CrayonSettings::EXCERPT_STRIP, crayon__('Remove Crayons from excerpts')));
1069
+ self::checkbox(array(CrayonSettings::MAIN_QUERY, crayon__('Load Crayons only from the main Wordpress query')));
1070
+ self::checkbox(array(CrayonSettings::TOUCHSCREEN, crayon__('Disable mouse gestures for touchscreen devices (eg. MouseOver)')));
1071
+ self::checkbox(array(CrayonSettings::DISABLE_ANIM, crayon__('Disable animations')));
1072
+ self::checkbox(array(CrayonSettings::DISABLE_RUNTIME, crayon__('Disable runtime stats')));
1073
+ }
1074
+
1075
+ // Debug Fields ===========================================================
1076
+
1077
+ public static function errors() {
1078
+ self::checkbox(array(CrayonSettings::ERROR_LOG, crayon__('Log errors for individual Crayons')));
1079
+ self::checkbox(array(CrayonSettings::ERROR_LOG_SYS, crayon__('Log system-wide errors')));
1080
+ self::checkbox(array(CrayonSettings::ERROR_MSG_SHOW, crayon__('Display custom message for errors')));
1081
+ self::textbox(array('id' => CrayonSettings::ERROR_MSG, 'size' => 60, 'margin' => TRUE));
1082
+ }
1083
+
1084
+ public static function log() {
1085
+ $log = CrayonLog::log();
1086
+ touch(CRAYON_LOG_FILE);
1087
+ $exists = file_exists(CRAYON_LOG_FILE);
1088
+ $writable = is_writable(CRAYON_LOG_FILE);
1089
+ if (!empty($log)) {
1090
+ echo '<div id="crayon-log-wrapper">', '<div id="crayon-log"><div id="crayon-log-text">', $log,
1091
+ '</div></div>', '<div id="crayon-log-controls">',
1092
+ '<input type="button" id="crayon-log-toggle" show_txt="', crayon__('Show Log'), '" hide_txt="', crayon__('Hide Log'), '" class="button-secondary" value="', crayon__('Show Log'), '"> ',
1093
+ '<input type="submit" id="crayon-log-clear" name="', self::LOG_CLEAR,
1094
+ '" class="button-secondary" value="', crayon__('Clear Log'), '"> ', '<input type="submit" id="crayon-log-email" name="',
1095
+ self::LOG_EMAIL_ADMIN . '" class="button-secondary" value="', crayon__('Email Admin'), '"> ',
1096
+ '<input type="submit" id="crayon-log-email" name="', self::LOG_EMAIL_DEV,
1097
+ '" class="button-secondary" value="', crayon__('Email Developer'), '"> ', '</div>', '</div>';
1098
+ }
1099
+ echo '<span', (!empty($log)) ? ' class="crayon-span"' : '', '>', (empty($log)) ? crayon__('The log is currently empty.') . ' ' : '';
1100
+ if ($exists) {
1101
+ $writable ? crayon_e('The log file exists and is writable.') : crayon_e('The log file exists and is not writable.');
1102
+ } else {
1103
+ crayon_e('The log file does not exist and is not writable.');
1104
+ }
1105
+ echo '</span>';
1106
+ }
1107
+
1108
+ // About Fields ===========================================================
1109
+
1110
+ public static function info() {
1111
+ global $CRAYON_VERSION, $CRAYON_DATE, $CRAYON_AUTHOR, $CRAYON_WEBSITE, $CRAYON_TWITTER, $CRAYON_GIT, $CRAYON_PLUGIN_WP, $CRAYON_AUTHOR_SITE, $CRAYON_EMAIL, $CRAYON_DONATE;
1112
+ echo '<a name="info"></a>';
1113
+ $version = '<strong>' . crayon__('Version') . ':</strong> ' . $CRAYON_VERSION;
1114
+ $date = $CRAYON_DATE;
1115
+ $developer = '<strong>' . crayon__('Developer') . ':</strong> ' . '<a href="' . $CRAYON_AUTHOR_SITE . '" target="_blank">' . $CRAYON_AUTHOR . '</a>';
1116
+ $translators = '<strong>' . crayon__('Translators') . ':</strong> ' .
1117
+ 'Chinese (<a href="http://smerpup.com/" target="_blank">Dezhi Liu</a>, <a href="http://neverno.me/" target="_blank">Jash Yin</a>),
1118
  Dutch (<a href="https://twitter.com/#!/chilionsnoek" target="_blank">Chilion Snoek</a>),
1119
  French (<a href="http://tech.dupeu.pl" target="_blank">Victor Felder</a>),
1120
  German (<a href="http://www.technologyblog.de/" target="_blank">Stephan Knau&#223;</a>),
1121
  Italian (<a href="http://www.federicobellucci.net/" target="_blank">Federico Bellucci</a>),
1122
  Japanese (<a href="https://twitter.com/#!/west_323" target="_blank">@west_323</a>),
1123
  Lithuanian (<a href="http://www.host1free.com" target="_blank">Vincent G</a>),
1124
+ Polish (<a href="https://github.com/toszcze" target="_blank">Bartosz Romanowski</a>),
1125
  Portuguese (<a href="http://www.adonai.eti.br" target="_blank">Adonai S. Canez</a>),
1126
  Russian (<a href="http://simplelib.com/" target="_blank">Minimus</a>, <a href="http://atlocal.net/" target="_blank">Di_Skyer</a>),
1127
  Spanish (<a href="http://www.hbravo.com/" target="_blank">Hermann Bravo</a>),
1128
  Turkish (<a href="http://hakanertr.wordpress.com" target="_blank">Hakan</a>)';
1129
 
1130
+ $links = '
1131
  <a id="docs-icon" class="small-icon" title="Documentation" href="' . $CRAYON_WEBSITE . '" target="_blank"></a>
1132
  <a id="git-icon" class="small-icon" title="GitHub" href="' . $CRAYON_GIT . '" target="_blank"></a>
1133
  <a id="wp-icon" class="small-icon" title="Plugin Page" href="' . $CRAYON_PLUGIN_WP . '" target="_blank"></a>
1134
  <a id="twitter-icon" class="small-icon" title="Twitter" href="' . $CRAYON_TWITTER . '" target="_blank"></a>
1135
  <a id="gmail-icon" class="small-icon" title="Email" href="mailto:' . $CRAYON_EMAIL . '" target="_blank"></a>
1136
  <div id="crayon-donate"><a href="' . $CRAYON_DONATE . '" title="Donate" target="_blank">
1137
+ <img src="' . plugins_url(CRAYON_DONATE_BUTTON, __FILE__) . '"></a>
1138
  </div>';
1139
 
1140
+ echo '
1141
  <table id="crayon-info" border="0">
1142
  <tr>
1143
+ <td>' . $version . ' - ' . $date . '</td>
1144
  </tr>
1145
  <tr>
1146
+ <td>' . $developer . '</td>
1147
  </tr>
1148
  <tr>
1149
+ <td>' . $translators . '</td>
1150
  </tr>
1151
  <tr>
1152
  <td colspan="2">', crayon__("The result of innumerable hours of hard work over many months. It's an ongoing project, keep me motivated!"), '</td>
1153
  </tr>
1154
  <tr>
1155
+ <td colspan="2">' . $links . '</td>
1156
  </tr>
1157
  </table>';
1158
 
1159
+ }
1160
+
1161
+ public static function help_button($link) {
1162
+ return ' <a href="' . $link . '" target="_blank" class="crayon-question">' . crayon__('?') . '</a>';
1163
+ }
1164
+
1165
+ public static function plugin_row_meta($meta, $file) {
1166
+ global $CRAYON_DONATE;
1167
+ if ($file == CrayonWP::basename()) {
1168
+ $meta[] = '<a href="options-general.php?page=crayon_settings">' . crayon__('Settings') . '</a>';
1169
+ $meta[] = '<a href="options-general.php?page=crayon_settings&theme-editor=1">' . crayon__('Theme Editor') . '</a>';
1170
+ $meta[] = '<a href="' . $CRAYON_DONATE . '" target="_blank">' . crayon__('Donate') . '</a>';
1171
+ }
1172
+ return $meta;
1173
+ }
1174
  }
1175
+
1176
  // Add the settings menus
1177
 
1178
  if (defined('ABSPATH') && is_admin()) {
1179
+ // For the admin section
1180
+ add_action('admin_menu', 'CrayonSettingsWP::admin_load');
1181
+ add_filter('plugin_row_meta', 'CrayonSettingsWP::plugin_row_meta', 10, 2);
1182
  }
1183
 
1184
  ?>
crayon_themes.class.php CHANGED
@@ -3,30 +3,73 @@ require_once ('global.php');
3
  require_once (CRAYON_RESOURCE_PHP);
4
 
5
  /* Manages themes once they are loaded. */
6
- class CrayonThemes extends CrayonUsedResourceCollection {
7
  // Properties and Constants ===============================================
8
 
9
  const DEFAULT_THEME = 'classic';
10
  const DEFAULT_THEME_NAME = 'Classic';
 
11
 
12
  private $printed_themes = array();
13
-
14
  // Methods ================================================================
15
 
16
  function __construct() {
17
  $this->directory ( CRAYON_THEME_PATH );
 
 
 
 
18
  $this->set_default ( self::DEFAULT_THEME, self::DEFAULT_THEME_NAME );
19
  }
20
 
21
  // XXX Override
22
- public function path($id) {
23
- return CRAYON_THEME_PATH . $id . "/$id.css";
24
  }
25
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
26
  // XXX Override
27
- public function get_url($id) {
28
- return CrayonGlobalSettings::plugin_path() . CrayonUtil::pathf(CRAYON_THEME_DIR) . $id . '/' . $id . '.css';
 
 
 
 
 
 
 
 
 
 
 
 
 
29
  }
30
-
 
 
 
 
 
31
  }
 
32
  ?>
3
  require_once (CRAYON_RESOURCE_PHP);
4
 
5
  /* Manages themes once they are loaded. */
6
+ class CrayonThemes extends CrayonUserResourceCollection {
7
  // Properties and Constants ===============================================
8
 
9
  const DEFAULT_THEME = 'classic';
10
  const DEFAULT_THEME_NAME = 'Classic';
11
+ const CSS_PREFIX = '.crayon-theme-';
12
 
13
  private $printed_themes = array();
14
+
15
  // Methods ================================================================
16
 
17
  function __construct() {
18
  $this->directory ( CRAYON_THEME_PATH );
19
+ $this->user_directory(CrayonGlobalSettings::upload_path() . CRAYON_THEME_DIR);
20
+ if (!is_dir($this->user_directory())) {
21
+ mkdir($this->user_directory(), 0777, TRUE);
22
+ }
23
  $this->set_default ( self::DEFAULT_THEME, self::DEFAULT_THEME_NAME );
24
  }
25
 
26
  // XXX Override
27
+ public function path($id, $user = NULL) {
28
+ return $this->dirpath($id, $user) . "$id.css";
29
  }
30
+
31
+ public function dirpath($id, $user = NULL) {
32
+ $path = NULL;
33
+ if ($user === NULL) {
34
+ if ($this->is_state_loading()) {
35
+ // We seem to be loading resources - use current directory
36
+ $user = $this->current_directory() == $this->user_directory();
37
+ } else {
38
+ $theme = $this->get($id);
39
+ if ($theme) {
40
+ $user = $theme->user();
41
+ } else {
42
+ $user = FALSE;
43
+ }
44
+ }
45
+ }
46
+ $path = $user ? $this->user_directory() : $this->directory();
47
+ return CrayonUtil::path_slash($path . $id);
48
+ }
49
+
50
  // XXX Override
51
+ public function get_url($id, $user = NULL) {
52
+ if ($user === NULL) {
53
+ if ($this->is_state_loading()) {
54
+ // We seem to be loading resources - use current directory
55
+ $user = $this->current_directory() == $this->user_directory();
56
+ } else {
57
+ $theme = $this->get($id);
58
+ if ($theme) {
59
+ $user = $theme->user();
60
+ } else {
61
+ $user = FALSE;
62
+ }
63
+ }
64
+ }
65
+ return self::dir_url($user) . $id . '/' . $id . '.css';
66
  }
67
+
68
+ public static function dir_url($user = FALSE) {
69
+ $path = $user ? CrayonGlobalSettings::upload_url() : CrayonGlobalSettings::plugin_path();
70
+ return $path . CrayonUtil::pathf(CRAYON_THEME_DIR);
71
+ }
72
+
73
  }
74
+
75
  ?>
crayon_wp.class.php CHANGED
@@ -1,9 +1,9 @@
1
  <?php
2
  /*
3
- Plugin Name: Crayon Syntax Highlighter
4
  Plugin URI: http://ak.net84.net/projects/crayon-syntax-highlighter
5
  Description: Supports multiple languages, themes, highlighting from a URL, local file or post text.
6
- Version: 1.17
7
  Author: Aram Kocharyan
8
  Author URI: http://ak.net84.net/
9
  Text Domain: crayon-syntax-highlighter
@@ -226,6 +226,7 @@ class CrayonWP {
226
  public static function capture_crayons($wp_id, $wp_content, $extra_settings = array(), $args = array()) {
227
  extract($args);
228
  CrayonUtil::set_var($callback, NULL);
 
229
  CrayonUtil::set_var($ignore, TRUE);
230
  CrayonUtil::set_var($preserve_atts, FALSE);
231
  CrayonUtil::set_var($flags, NULL);
@@ -369,7 +370,7 @@ class CrayonWP {
369
  if ($callback === NULL) {
370
  $wp_content = str_replace($full_matches[$i], '[crayon-' . $id . $is_inline . '/]', $wp_content);
371
  } else {
372
- $wp_content = call_user_func($callback, $c, $full_matches[$i], $id, $is_inline, $wp_content);
373
  }
374
  }
375
 
@@ -397,7 +398,7 @@ class CrayonWP {
397
 
398
  // Whether to enqueue syles/scripts
399
  $enqueue = FALSE;
400
- CrayonSettingsWP::load_settings(TRUE); // Load just the settings from db, for now
401
 
402
  self::init_tags_regex();
403
  $crayon_posts = CrayonSettingsWP::load_posts(); // Loads posts containing crayons
@@ -764,8 +765,12 @@ class CrayonWP {
764
  return self::class_tag($matches);
765
  }
766
 
767
- // Check if the $ notation has been used to ignore [crayon] tags within posts and remove all matches
768
- // Can also remove if used without $ as a regular crayon
 
 
 
 
769
  public static function crayon_remove_ignore($the_content, $ignore_flag = '$') {
770
  if ($ignore_flag == FALSE) {
771
  $ignore_flag = '';
@@ -778,7 +783,8 @@ class CrayonWP {
778
  if (CrayonGlobalSettings::val(CrayonSettings::CAPTURE_PRE)) {
779
  $the_content = str_ireplace(array($ignore_flag . '<pre', 'pre>' . $ignore_flag), array('<pre', 'pre>'), $the_content);
780
  // Remove any <code> tags wrapping around the whole code, since we won't needed them
781
- $the_content = preg_replace('#(^\s*<\s*code[^>]*>)|(<\s*/\s*code[^>]*>\s*$)#msi', '', $the_content);
 
782
  }
783
  if (CrayonGlobalSettings::val(CrayonSettings::PLAIN_TAG)) {
784
  $the_content = str_ireplace(array($ignore_flag . '[plain', 'plain]' . $ignore_flag), array('[plain', 'plain]'), $the_content);
@@ -893,6 +899,11 @@ class CrayonWP {
893
  public static function init_ajax() {
894
  add_action('wp_ajax_crayon-ajax', 'CrayonWP::ajax');
895
  add_action('wp_ajax_crayon-tag-editor', 'CrayonTagEditorWP::content');
 
 
 
 
 
896
  add_action('wp_ajax_crayon-show-posts', 'CrayonSettingsWP::show_posts');
897
  add_action('wp_ajax_crayon-show-langs', 'CrayonSettingsWP::show_langs');
898
  add_action('wp_ajax_crayon-show-preview', 'CrayonSettingsWP::show_preview');
@@ -1024,7 +1035,11 @@ class CrayonWP {
1024
 
1025
  if (CrayonUtil::version_compare($version, '1.14') < 0) {
1026
  CrayonLog::syslog("Updated to v1.14: Font size enabled");
1027
- $settings[CrayonSettings::FONT_SIZE_ENABLE] = true;
 
 
 
 
1028
  }
1029
 
1030
  // Save new version
@@ -1073,9 +1088,10 @@ class CrayonWP {
1073
  /**
1074
  * Converts Crayon tags found in WP to <pre> form.
1075
  * XXX: This will alter blog content, so backup before calling.
1076
- * XXX: Do NOT call this while updating posts or comments, it may cause an infinite loop or fail
 
1077
  */
1078
- public static function convert_tags($just_check = FALSE) {
1079
  $crayon_posts = CrayonSettingsWP::load_legacy_posts();
1080
  if ($crayon_posts === NULL) {
1081
  return;
@@ -1084,6 +1100,7 @@ class CrayonWP {
1084
  self::init_legacy_tag_bits();
1085
  $args = array(
1086
  'callback' => 'CrayonWP::capture_replace_pre',
 
1087
  'ignore' => FALSE,
1088
  'preserve_atts' => TRUE,
1089
  'flags' => self::$legacy_flags
@@ -1119,10 +1136,18 @@ class CrayonWP {
1119
  }
1120
 
1121
  // Used as capture_crayons callback
1122
- public static function capture_replace_pre($capture, $original, $id, $is_inline, $wp_content) {
1123
- $atts = array();
1124
- $atts['class'] = CrayonUtil::html_attributes($capture['atts'], CrayonGlobalSettings::val_str(CrayonSettings::ATTR_SEP), '');
1125
- return str_replace($original, CrayonUtil::html_element('pre', $capture['code'], $atts), $wp_content);
 
 
 
 
 
 
 
 
1126
  }
1127
 
1128
  }
1
  <?php
2
  /*
3
+ Plugin Name: Crayon Syntax Highlighter
4
  Plugin URI: http://ak.net84.net/projects/crayon-syntax-highlighter
5
  Description: Supports multiple languages, themes, highlighting from a URL, local file or post text.
6
+ Version: 2.0.0
7
  Author: Aram Kocharyan
8
  Author URI: http://ak.net84.net/
9
  Text Domain: crayon-syntax-highlighter
226
  public static function capture_crayons($wp_id, $wp_content, $extra_settings = array(), $args = array()) {
227
  extract($args);
228
  CrayonUtil::set_var($callback, NULL);
229
+ CrayonUtil::set_var($callback_extra_args, NULL);
230
  CrayonUtil::set_var($ignore, TRUE);
231
  CrayonUtil::set_var($preserve_atts, FALSE);
232
  CrayonUtil::set_var($flags, NULL);
370
  if ($callback === NULL) {
371
  $wp_content = str_replace($full_matches[$i], '[crayon-' . $id . $is_inline . '/]', $wp_content);
372
  } else {
373
+ $wp_content = call_user_func($callback, $c, $full_matches[$i], $id, $is_inline, $wp_content, $callback_extra_args);
374
  }
375
  }
376
 
398
 
399
  // Whether to enqueue syles/scripts
400
  $enqueue = FALSE;
401
+ CrayonSettingsWP::load_settings(TRUE); // We will eventually need more than the settings
402
 
403
  self::init_tags_regex();
404
  $crayon_posts = CrayonSettingsWP::load_posts(); // Loads posts containing crayons
765
  return self::class_tag($matches);
766
  }
767
 
768
+ /**
769
+ * Check if the $ notation has been used to ignore [crayon] tags within posts and remove all matches
770
+ * Can also remove if used without $ as a regular crayon
771
+ *
772
+ * @depreciated
773
+ */
774
  public static function crayon_remove_ignore($the_content, $ignore_flag = '$') {
775
  if ($ignore_flag == FALSE) {
776
  $ignore_flag = '';
783
  if (CrayonGlobalSettings::val(CrayonSettings::CAPTURE_PRE)) {
784
  $the_content = str_ireplace(array($ignore_flag . '<pre', 'pre>' . $ignore_flag), array('<pre', 'pre>'), $the_content);
785
  // Remove any <code> tags wrapping around the whole code, since we won't needed them
786
+ // XXX This causes <code> tags to be stripped in the post content! Disabled now.
787
+ // $the_content = preg_replace('#(^\s*<\s*code[^>]*>)|(<\s*/\s*code[^>]*>\s*$)#msi', '', $the_content);
788
  }
789
  if (CrayonGlobalSettings::val(CrayonSettings::PLAIN_TAG)) {
790
  $the_content = str_ireplace(array($ignore_flag . '[plain', 'plain]' . $ignore_flag), array('[plain', 'plain]'), $the_content);
899
  public static function init_ajax() {
900
  add_action('wp_ajax_crayon-ajax', 'CrayonWP::ajax');
901
  add_action('wp_ajax_crayon-tag-editor', 'CrayonTagEditorWP::content');
902
+ add_action('wp_ajax_crayon-theme-editor', 'CrayonThemeEditorWP::content');
903
+ add_action('wp_ajax_crayon-theme-editor-save', 'CrayonThemeEditorWP::save');
904
+ add_action('wp_ajax_crayon-theme-editor-delete', 'CrayonThemeEditorWP::delete');
905
+ add_action('wp_ajax_crayon-theme-editor-duplicate', 'CrayonThemeEditorWP::duplicate');
906
+ add_action('wp_ajax_crayon-theme-editor-submit', 'CrayonThemeEditorWP::submit');
907
  add_action('wp_ajax_crayon-show-posts', 'CrayonSettingsWP::show_posts');
908
  add_action('wp_ajax_crayon-show-langs', 'CrayonSettingsWP::show_langs');
909
  add_action('wp_ajax_crayon-show-preview', 'CrayonSettingsWP::show_preview');
1035
 
1036
  if (CrayonUtil::version_compare($version, '1.14') < 0) {
1037
  CrayonLog::syslog("Updated to v1.14: Font size enabled");
1038
+ $settings[CrayonSettings::FONT_SIZE_ENABLE] = TRUE;
1039
+ }
1040
+
1041
+ if (CrayonUtil::version_compare($version, '1.17') < 0) {
1042
+ $settings[CrayonSettings::HIDE_HELP] = FALSE;
1043
  }
1044
 
1045
  // Save new version
1088
  /**
1089
  * Converts Crayon tags found in WP to <pre> form.
1090
  * XXX: This will alter blog content, so backup before calling.
1091
+ * XXX: Do NOT call this while updating posts or comments, it may cause an infinite loop or fail.
1092
+ * @param $encode Whether to detect missing "decode" attribute and encode html entities in the code.
1093
  */
1094
+ public static function convert_tags($encode = FALSE) {
1095
  $crayon_posts = CrayonSettingsWP::load_legacy_posts();
1096
  if ($crayon_posts === NULL) {
1097
  return;
1100
  self::init_legacy_tag_bits();
1101
  $args = array(
1102
  'callback' => 'CrayonWP::capture_replace_pre',
1103
+ 'callback_extra_args' => array('encode' => $encode),
1104
  'ignore' => FALSE,
1105
  'preserve_atts' => TRUE,
1106
  'flags' => self::$legacy_flags
1136
  }
1137
 
1138
  // Used as capture_crayons callback
1139
+ public static function capture_replace_pre($capture, $original, $id, $is_inline, $wp_content, $args = array()) {
1140
+ $code = $capture['code'];
1141
+ $oldAtts = $capture['atts'];
1142
+ $newAtts = array();
1143
+ $encode = isset($args['encode']) ? $args['encode'] : FALSE;
1144
+ if (!isset($oldAtts[CrayonSettings::DECODE]) && $encode) {
1145
+ // Encode the content, since no decode information exists.
1146
+ $code = CrayonUtil::htmlentities($code);
1147
+ $oldAtts[CrayonSettings::DECODE] = TRUE;
1148
+ }
1149
+ $newAtts['class'] = CrayonUtil::html_attributes($oldAtts, CrayonGlobalSettings::val_str(CrayonSettings::ATTR_SEP), '');
1150
+ return str_replace($original, CrayonUtil::html_element('pre', $code, $newAtts), $wp_content);
1151
  }
1152
 
1153
  }
css/admin_style.css CHANGED
@@ -192,9 +192,16 @@
192
  }
193
 
194
  #crayon-theme-info {
195
- float: left;
 
 
 
 
 
 
 
196
  }
197
- #crayon-theme-info * {
198
  float: left;
199
  }
200
  #crayon-theme-info .field {
@@ -204,6 +211,23 @@
204
  #crayon-theme-info .value {
205
  margin-left: 5px;
206
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
207
 
208
  #crayon-editor-table td {
209
  vertical-align: top;
@@ -243,3 +267,14 @@
243
  display: inline;
244
  padding: 0;
245
  }
 
 
 
 
 
 
 
 
 
 
 
192
  }
193
 
194
  #crayon-theme-info {
195
+ display: table;
196
+ padding: 0;
197
+ margin: 0;
198
+ margin-top: 5px;
199
+ }
200
+ #crayon-theme-info > div {
201
+ display: table-cell;
202
+ vertical-align: middle;
203
  }
204
+ #crayon-theme-info .content * {
205
  float: left;
206
  }
207
  #crayon-theme-info .field {
211
  #crayon-theme-info .value {
212
  margin-left: 5px;
213
  }
214
+ #crayon-theme-info .description.value {
215
+ font-style: italic;
216
+ color: #999;
217
+ }
218
+ #crayon-theme-info .type {
219
+ text-align: center;
220
+ min-width: 120px;
221
+ font-weight: bold;
222
+ border-right: 1px solid #ccc;
223
+ padding-right: 5px;
224
+ }
225
+ #crayon-theme-info .type.stock {
226
+ color: #666;
227
+ }
228
+ #crayon-theme-info .type.user {
229
+ color: #5b9a00;
230
+ }
231
 
232
  #crayon-editor-table td {
233
  vertical-align: top;
267
  display: inline;
268
  padding: 0;
269
  }
270
+
271
+ #crayon-theme-editor-info a {
272
+ text-decoration: none !important;
273
+ font-style: italic !important;
274
+ color: #666 !important;
275
+ }
276
+
277
+ .note {
278
+ font-style: italic;
279
+ color: #999;
280
+ }
global.php CHANGED
@@ -6,17 +6,15 @@ define('CRAYON_DEBUG', FALSE);
6
 
7
  // TODO remove once done
8
  define('CRAYON_TAG_EDITOR', TRUE);
9
- define('CRAYON_THEME_EDITOR', FALSE);
10
 
11
  // Constants
12
 
13
- $uid = CRAYON_DEBUG ? uniqid() : ''; // Prevent caching in debug mode
14
-
15
  // General definitions
16
  define('CRAYON_DOMAIN', 'crayon-syntax-highlighter');
17
 
18
  // These are overriden by functions since v1.1.1
19
- $CRAYON_VERSION = '1.1.1' . $uid;
20
  $CRAYON_DATE = '27th September, 2011';
21
  $CRAYON_AUTHOR = 'Aram Kocharyan';
22
  $CRAYON_AUTHOR_SITE = 'http://ak.net84.net/';
@@ -77,6 +75,9 @@ define('CRAYON_JS_FANCYBOX', CRAYON_JS_DIR . 'fancybox/jquery.fancybox.init.pack
77
  define('CRAYON_CSS_FANCYBOX', CRAYON_JS_DIR . 'fancybox/jquery.fancybox.css');
78
  define('CRAYON_CSS_JQUERY_UI', CRAYON_JS_DIR . 'jquery-ui/jquery-ui.css');
79
  define('CRAYON_JS_JQUERY_UI', CRAYON_JS_DIR . 'jquery-ui/jquery-ui.js');
 
 
 
80
  // TODO rename TE
81
  define('CRAYON_TE_JS', 'crayon_te.js');
82
  define('CRAYON_TE_PHP', CRAYON_TAG_EDITOR_PATH . 'crayon_tag_editor_wp.class.php');
@@ -89,7 +90,6 @@ define('CRAYON_STYLE_GLOBAL', CRAYON_CSS_DIR . 'global_style.css');
89
  define('CRAYON_LOGO', CRAYON_CSS_DIR . 'images/crayon_logo.png');
90
  define('CRAYON_DONATE_BUTTON', CRAYON_CSS_DIR . 'images/donate.png');
91
  define('CRAYON_THEME_EDITOR_PHP', CRAYON_THEME_EDITOR_PATH . 'theme_editor.php');
92
- define('CRAYON_THEME_EDITOR_CONTENT_PHP', CRAYON_UTIL_DIR . CRAYON_THEME_EDITOR_DIR . 'theme_editor_content.php');
93
  define('CRAYON_THEME_EDITOR_JS', CRAYON_UTIL_DIR . CRAYON_THEME_EDITOR_DIR . 'theme_editor.js');
94
  define('CRAYON_THEME_EDITOR_STYLE', CRAYON_UTIL_DIR . CRAYON_THEME_EDITOR_DIR . 'theme_editor.css');
95
  define('CRAYON_THEME_EDITOR_BUTTON', CRAYON_CSS_DIR . 'images/theme_editor.png');
@@ -125,7 +125,6 @@ define('CRAYON_LINE', "---------------------------------------------------------
125
  // Load utilities
126
 
127
  require_once (CRAYON_UTIL_PHP);
128
- //require_once (CRAYON_EXCEPTIONS_PHP);
129
  require_once (CRAYON_TIMER_PHP);
130
  require_once (CRAYON_LOG_PHP);
131
 
@@ -162,12 +161,11 @@ function crayon_pb($url) {
162
 
163
  // Get/Set plugin information
164
  function crayon_set_info($info_array) {
165
- global $CRAYON_VERSION, $CRAYON_DATE, $CRAYON_AUTHOR, $CRAYON_WEBSITE, $uid;
166
  if (!is_array($info_array)) {
167
  return;
168
  }
169
  crayon_set_info_key('Version', $info_array, $CRAYON_VERSION);
170
- $CRAYON_VERSION .= $uid;
171
  if (($date = @filemtime(CRAYON_README_FILE)) !== FALSE) {
172
  $CRAYON_DATE = date("jS F, Y", $date);
173
  }
@@ -217,7 +215,7 @@ function crayon__($text) {
217
  if (function_exists('__')) {
218
  return __($text, CRAYON_DOMAIN);
219
  } else {
220
- return $text . CRAYON_DOMAIN;
221
  }
222
  }
223
 
6
 
7
  // TODO remove once done
8
  define('CRAYON_TAG_EDITOR', TRUE);
9
+ define('CRAYON_THEME_EDITOR', TRUE);
10
 
11
  // Constants
12
 
 
 
13
  // General definitions
14
  define('CRAYON_DOMAIN', 'crayon-syntax-highlighter');
15
 
16
  // These are overriden by functions since v1.1.1
17
+ $CRAYON_VERSION = '1.1.1';
18
  $CRAYON_DATE = '27th September, 2011';
19
  $CRAYON_AUTHOR = 'Aram Kocharyan';
20
  $CRAYON_AUTHOR_SITE = 'http://ak.net84.net/';
75
  define('CRAYON_CSS_FANCYBOX', CRAYON_JS_DIR . 'fancybox/jquery.fancybox.css');
76
  define('CRAYON_CSS_JQUERY_UI', CRAYON_JS_DIR . 'jquery-ui/jquery-ui.css');
77
  define('CRAYON_JS_JQUERY_UI', CRAYON_JS_DIR . 'jquery-ui/jquery-ui.js');
78
+ define('CRAYON_CSS_JQUERY_COLORPICKER', CRAYON_JS_DIR . 'jquery-colorpicker/jquery.colorpicker.css');
79
+ define('CRAYON_JS_JQUERY_COLORPICKER', CRAYON_JS_DIR . 'jquery-colorpicker/jquery.colorpicker.js');
80
+ define('CRAYON_JS_TINYCOLOR', CRAYON_JS_DIR . 'tinycolor-min.js');
81
  // TODO rename TE
82
  define('CRAYON_TE_JS', 'crayon_te.js');
83
  define('CRAYON_TE_PHP', CRAYON_TAG_EDITOR_PATH . 'crayon_tag_editor_wp.class.php');
90
  define('CRAYON_LOGO', CRAYON_CSS_DIR . 'images/crayon_logo.png');
91
  define('CRAYON_DONATE_BUTTON', CRAYON_CSS_DIR . 'images/donate.png');
92
  define('CRAYON_THEME_EDITOR_PHP', CRAYON_THEME_EDITOR_PATH . 'theme_editor.php');
 
93
  define('CRAYON_THEME_EDITOR_JS', CRAYON_UTIL_DIR . CRAYON_THEME_EDITOR_DIR . 'theme_editor.js');
94
  define('CRAYON_THEME_EDITOR_STYLE', CRAYON_UTIL_DIR . CRAYON_THEME_EDITOR_DIR . 'theme_editor.css');
95
  define('CRAYON_THEME_EDITOR_BUTTON', CRAYON_CSS_DIR . 'images/theme_editor.png');
125
  // Load utilities
126
 
127
  require_once (CRAYON_UTIL_PHP);
 
128
  require_once (CRAYON_TIMER_PHP);
129
  require_once (CRAYON_LOG_PHP);
130
 
161
 
162
  // Get/Set plugin information
163
  function crayon_set_info($info_array) {
164
+ global $CRAYON_VERSION, $CRAYON_DATE, $CRAYON_AUTHOR, $CRAYON_WEBSITE;
165
  if (!is_array($info_array)) {
166
  return;
167
  }
168
  crayon_set_info_key('Version', $info_array, $CRAYON_VERSION);
 
169
  if (($date = @filemtime(CRAYON_README_FILE)) !== FALSE) {
170
  $CRAYON_DATE = date("jS F, Y", $date);
171
  }
215
  if (function_exists('__')) {
216
  return __($text, CRAYON_DOMAIN);
217
  } else {
218
+ return $text;
219
  }
220
  }
221
 
js/crayon.js CHANGED
@@ -21,15 +21,19 @@
21
  if (typeof styleName != 'undefined') {
22
  if (typeof value != 'undefined') {
23
  // Set style property
24
- var priority = typeof priority != 'undefined' ? priority : '';
25
  if (typeof style.setProperty != 'undefined') {
26
  style.setProperty(styleName, value, priority);
27
  } else {
28
- style.styleName = value + ' ' + priority;
 
 
 
 
29
  }
30
  } else {
31
  // Get style property
32
- return style.styleName;
33
  }
34
  } else {
35
  // Get CSSStyleDeclaration
@@ -89,13 +93,13 @@
89
  uid += getUID();
90
  }
91
  c.attr('id', uid);
92
- console_log(uid);
93
 
94
  if (typeof replace == 'undefined') {
95
  replace = false;
96
  }
97
 
98
- if (!replace && !make_uid(uid)) {
99
  // Already a Crayon
100
  return;
101
  }
@@ -107,13 +111,13 @@
107
  var table = c.find(CRAYON_TABLE);
108
  var code = c.find(CRAYON_CODE);
109
  var nums = c.find(CRAYON_NUMS);
110
- var nums_content = c.find(CRAYON_NUMS_CONTENT);
111
- var nums_button = c.find(CRAYON_NUMS_BUTTON);
112
- var wrap_button = c.find(CRAYON_WRAP_BUTTON);
113
- var expand_button = c.find(CRAYON_EXPAND_BUTTON);
114
- var popup_button = c.find(CRAYON_POPUP_BUTTON);
115
- var copy_button = c.find(CRAYON_COPY_BUTTON);
116
- var plain_button = c.find(CRAYON_PLAIN_BUTTON);
117
 
118
  crayon[uid] = c;
119
  crayon[uid].toolbar = toolbar;
@@ -123,16 +127,16 @@
123
  crayon[uid].table = table;
124
  crayon[uid].code = code;
125
  crayon[uid].nums = nums;
126
- crayon[uid].nums_content = nums_content;
127
- crayon[uid].nums_button = nums_button;
128
- crayon[uid].wrap_button = wrap_button;
129
- crayon[uid].expand_button = expand_button;
130
- crayon[uid].popup_button = popup_button;
131
- crayon[uid].copy_button = copy_button;
132
- crayon[uid].plain_button = plain_button;
133
- crayon[uid].nums_visible = true;
134
  crayon[uid].wrapped = false;
135
- crayon[uid].plain_visible = false;
136
 
137
  crayon[uid].toolbar_delay = 0;
138
  crayon[uid].time = 1;
@@ -141,62 +145,58 @@
141
  $(CRAYON_PLAIN).css('z-index', 0);
142
 
143
  // XXX Remember CSS dimensions
144
- var main_style = main.style();
145
  crayon[uid].main_style = {
146
- 'height': main_style && main_style.height || '',
147
- 'max-height': main_style && main_style.maxHeight || '',
148
- 'min-height': main_style && main_style.minHeight || '',
149
- 'width': main_style && main_style.width || '',
150
- 'max-width': main_style && main_style.maxWidth || '',
151
- 'min-width': main_style && main_style.minWidth || ''
152
  };
153
 
154
  var load_timer;
155
  var i = 0;
156
  crayon[uid].loading = true;
157
- crayon[uid].scroll_block_fix = false;
158
 
159
  // Register click events
160
- nums_button.click(function () {
161
- CrayonSyntax.toggle_nums(uid);
162
  });
163
- wrap_button.click(function () {
164
- CrayonSyntax.toggle_wrap(uid);
165
  });
166
- expand_button.click(function () {
167
- CrayonSyntax.toggle_expand(uid);
168
  });
169
- plain_button.click(function () {
170
- CrayonSyntax.toggle_plain(uid);
171
  });
172
- copy_button.click(function () {
173
- CrayonSyntax.copy_plain(uid);
174
  });
175
 
176
  // Enable retina if supported
177
  retina(uid);
178
 
179
  var load_func = function () {
180
- if (main.height() < 30) {
181
- crayon[uid].scroll_block_fix = true;
182
- }
183
-
184
  // If nums hidden by default
185
  if (nums.filter('[data-settings~="hide"]').length != 0) {
186
- nums_content.ready(function () {
187
- console_log('function' + uid);
188
- CrayonSyntax.toggle_nums(uid, true, true);
189
  });
190
  } else {
191
- update_nums_button(uid);
192
  }
193
 
194
  if (typeof crayon[uid].expanded == 'undefined') {
195
  // Determine if we should enable code expanding toggling
196
  if (Math.abs(crayon[uid].main.width() - crayon[uid].table.width()) < 10) {
197
- crayon[uid].expand_button.hide();
198
  } else {
199
- crayon[uid].expand_button.show();
200
  }
201
  }
202
 
@@ -209,12 +209,12 @@
209
  i++;
210
  };
211
  load_timer = setInterval(load_func, 300);
212
- fix_scroll_blank(uid);
213
 
214
  // Add ref to num for each line
215
  $(CRAYON_NUM, crayon[uid]).each(function () {
216
- var line_id = $(this).attr('data-line');
217
- var line = $('#' + line_id);
218
  var height = line.style('height');
219
  if (height) {
220
  line.attr('data-height', height);
@@ -231,19 +231,19 @@
231
  // Used to hide info
232
  if (!touchscreen) {
233
  main.click(function () {
234
- crayon_info(uid, '', false);
235
  });
236
  plain.click(function () {
237
- crayon_info(uid, '', false);
238
  });
239
  info.click(function () {
240
- crayon_info(uid, '', false);
241
  });
242
  }
243
 
244
  // Used for code popup
245
  if (c.filter('[data-settings~="no-popup"]').length == 0) {
246
- crayon[uid].popup_settings = popupWindow(popup_button, {
247
  height: screen.height - 200,
248
  width: screen.width - 100,
249
  top: 75,
@@ -252,16 +252,20 @@
252
  windowURL: '',
253
  data: '' // Data overrides URL
254
  }, function () {
255
- code_popup(uid);
256
  }, function () {
257
- //console_log('after');
258
  });
259
  }
260
 
261
  plain.css('opacity', 0);
 
 
 
262
  // If a toolbar with mouseover was found
263
  if (toolbar.filter('[data-settings~="mouseover"]').length != 0 && !touchscreen) {
264
- crayon[uid].toolbar_mouseover = true;
 
265
 
266
  toolbar.css('margin-top', '-' + toolbar.height() + 'px');
267
  toolbar.hide();
@@ -274,10 +278,10 @@
274
  // Hide on single click when overlayed
275
  if (toolbar.filter('[data-settings~="hide"]').length != 0) {
276
  main.click(function () {
277
- toolbar_toggle(uid, undefined, undefined, 0);
278
  });
279
  plain.click(function () {
280
- toolbar_toggle(uid, false, undefined, 0);
281
  });
282
  }
283
  } else {
@@ -289,10 +293,10 @@
289
  }
290
  // Use .hover() for chrome, but in firefox mouseover/mouseout worked best
291
  c.mouseenter(function () {
292
- toolbar_toggle(uid, true);
293
  })
294
  .mouseleave(function () {
295
- toolbar_toggle(uid, false);
296
  });
297
  } else if (touchscreen) {
298
  toolbar.show();
@@ -302,24 +306,24 @@
302
  if (plain.length != 0 && !touchscreen) {
303
  if (plain.filter('[data-settings~="dblclick"]').length != 0) {
304
  main.dblclick(function () {
305
- CrayonSyntax.toggle_plain(uid);
306
  });
307
  } else if (plain.filter('[data-settings~="click"]').length != 0) {
308
  main.click(function () {
309
- CrayonSyntax.toggle_plain(uid);
310
  });
311
  } else if (plain.filter('[data-settings~="mouseover"]').length != 0) {
312
  c.mouseenter(function () {
313
- CrayonSyntax.toggle_plain(uid, true);
314
  })
315
  .mouseleave(function () {
316
- CrayonSyntax.toggle_plain(uid, false);
317
  });
318
- nums_button.hide();
319
  }
320
  if (plain.filter('[data-settings~="show-plain-default"]').length != 0) {
321
  // XXX
322
- CrayonSyntax.toggle_plain(uid, true);
323
  }
324
  }
325
 
@@ -342,10 +346,10 @@
342
 
343
  if (expand) {
344
  c.mouseenter(function () {
345
- toggle_expand(uid, true);
346
  })
347
  .mouseleave(function () {
348
- toggle_expand(uid, false);
349
  });
350
  }
351
 
@@ -363,20 +367,20 @@
363
  crayon[uid].mac = c.hasClass('crayon-os-mac');
364
 
365
  // Update clickable buttons
366
- update_nums_button(uid);
367
- update_plain_button(uid);
368
- update_wrap(uid);
369
  };
370
 
371
- var make_uid = function (uid) {
372
- console_log(crayon);
373
  if (typeof crayon[uid] == 'undefined') {
374
  crayon[uid] = $('#' + uid);
375
- console_log('make ' + uid);
376
  return true;
377
  }
378
 
379
- console_log('no make ' + uid);
380
  return false;
381
  };
382
 
@@ -384,9 +388,9 @@
384
  return currUID++;
385
  };
386
 
387
- var code_popup = function (uid) {
388
  if (typeof crayon[uid] == 'undefined') {
389
- return make_uid(uid);
390
  }
391
  var settings = crayon[uid].popup_settings;
392
  if (settings.data) {
@@ -413,21 +417,21 @@
413
  clone.find(CRAYON_MAIN).css('height', '');
414
 
415
  var code = '';
416
- if (crayon[uid].plain_visible) {
417
  code = clone.find(CRAYON_PLAIN);
418
  } else {
419
  code = clone.find(CRAYON_MAIN);
420
  }
421
 
422
- settings.data = base.get_all_css() + '<body class="crayon-popup-window" style="padding:0; margin:0;"><div class="' + clone.attr('class') +
423
- ' crayon-popup">' + remove_css_inline(get_jquery_str(code)) + '</div></body>';
424
  };
425
 
426
- var get_jquery_str = function (object) {
427
  return $('<div>').append(object.clone()).remove().html();
428
  };
429
 
430
- var remove_css_inline = function (string) {
431
  var reStyle = /style\s*=\s*"([^"]+)"/gmi;
432
  var match = null;
433
  while ((match = reStyle.exec(string)) != null) {
@@ -439,7 +443,7 @@
439
  };
440
 
441
  // Get all CSS on the page as a string
442
- base.get_all_css = function () {
443
  var css_str = '';
444
  var css = $('link[rel="stylesheet"]');
445
  var filtered = [];
@@ -451,33 +455,33 @@
451
  filtered = css.filter('[href*="crayon-syntax-highlighter"]');
452
  }
453
  filtered.each(function () {
454
- var string = get_jquery_str($(this));
455
  css_str += string;
456
  });
457
  return css_str;
458
  };
459
 
460
- base.copy_plain = function (uid, hover) {
461
  if (typeof crayon[uid] == 'undefined') {
462
- return make_uid(uid);
463
  }
464
 
465
  var plain = crayon[uid].plain;
466
 
467
- base.toggle_plain(uid, true, true);
468
- toolbar_toggle(uid, true);
469
 
470
  key = crayon[uid].mac ? '\u2318' : 'CTRL';
471
  var text = crayon[uid].copy_button.attr('data-text');
472
  text = text.replace(/%s/, key + '+C');
473
  text = text.replace(/%s/, key + '+V');
474
- crayon_info(uid, text);
475
  return false;
476
  };
477
 
478
- var crayon_info = function (uid, text, show) {
479
  if (typeof crayon[uid] == 'undefined') {
480
- return make_uid(uid);
481
  }
482
 
483
  var info = crayon[uid].info;
@@ -489,18 +493,18 @@
489
  show = true;
490
  }
491
 
492
- if (crayon_is_slide_hidden(info) && show) {
493
  info.html('<div>' + text + '</div>');
494
  info.css('margin-top', -info.height());
495
  info.show();
496
- crayon_slide(uid, info, true);
497
  setTimeout(function () {
498
- crayon_slide(uid, info, false);
499
  }, 5000);
500
  }
501
 
502
  if (!show) {
503
- crayon_slide(uid, info, false);
504
  }
505
 
506
  };
@@ -517,7 +521,7 @@
517
  }
518
  };
519
 
520
- var crayon_is_slide_hidden = function (object) {
521
  var object_neg_height = '-' + object.height() + 'px';
522
  if (object.css('margin-top') == object_neg_height || object.css('display') == 'none') {
523
  return true;
@@ -526,48 +530,54 @@
526
  }
527
  };
528
 
529
- var crayon_slide = function (uid, object, show, anim_time, hide_delay) {
530
- var object_neg_height = '-' + object.height() + 'px';
 
 
 
 
 
531
 
532
  if (typeof show == 'undefined') {
533
- if (crayon_is_slide_hidden(object)) {
534
  show = true;
535
  } else {
536
  show = false;
537
  }
538
  }
539
  // Instant means no time delay for showing/hiding
540
- if (typeof anim_time == 'undefined') {
541
- anim_time = 100;
542
  }
543
- if (anim_time == false) {
544
- anim_time = false;
545
  }
546
- if (typeof hide_delay == 'undefined') {
547
- hide_delay = 0;
548
  }
549
  object.stop(true);
550
  if (show == true) {
551
  object.show();
552
  object.animate({
553
  marginTop: 0
554
- }, animt(anim_time, uid));
555
  } else if (show == false) {
556
  // Delay if fully visible
557
- if (/*instant == false && */object.css('margin-top') == '0px' && hide_delay) {
558
- object.delay(hide_delay);
559
  }
560
  object.animate({
561
- marginTop: object_neg_height
562
- }, animt(anim_time, uid), function () {
563
  object.hide();
 
564
  });
565
  }
566
  };
567
 
568
- base.toggle_plain = function (uid, hover, select) {
569
  if (typeof crayon[uid] == 'undefined') {
570
- return make_uid(uid);
571
  }
572
 
573
  var main = crayon[uid].main;
@@ -577,7 +587,7 @@
577
  return;
578
  }
579
 
580
- reconsile_dimensions(uid);
581
 
582
  var visible, hidden;
583
  if (typeof hover != 'undefined') {
@@ -598,7 +608,7 @@
598
  }
599
  }
600
 
601
- crayon[uid].plain_visible = (hidden == plain);
602
 
603
  // Remember scroll positions of visible
604
  crayon[uid].top = visible.scrollTop();
@@ -607,13 +617,13 @@
607
  /* Used to detect a change in overflow when the mouse moves out
608
  * of the Crayon. If it does, then overflow has already been changed,
609
  * no need to revert it after toggling plain. */
610
- crayon[uid].scroll_changed = false;
611
 
612
  // Hide scrollbars during toggle to avoid Chrome weird draw error
613
  // visible.css('overflow', 'hidden');
614
  // hidden.css('overflow', 'hidden');
615
 
616
- fix_scroll_blank(uid);
617
 
618
  // Show hidden, hide visible
619
  visible.stop(true);
@@ -646,64 +656,64 @@
646
  hidden.scrollTop(crayon[uid].top);
647
  hidden.scrollLeft(crayon[uid].left);
648
 
649
- update_plain_button(uid);
650
 
651
  // Hide toolbar if possible
652
- toolbar_toggle(uid, false);
653
  return false;
654
  };
655
 
656
- base.toggle_nums = function (uid, hide, instant) {
657
  if (typeof crayon[uid] == 'undefined') {
658
- make_uid(uid);
659
  return false;
660
  }
661
 
662
  if (crayon[uid].table.is(':animated')) {
663
  return false;
664
  }
665
- var nums_width = Math.round(crayon[uid].nums_content.width() + 1);
666
- var neg_width = '-' + nums_width + 'px';
667
 
668
  // Force hiding
669
- var num_hidden;
670
  if (typeof hide != 'undefined') {
671
- num_hidden = false;
672
  } else {
673
  // Check hiding
674
- num_hidden = (crayon[uid].table.css('margin-left') == neg_width);
675
  }
676
 
677
- var num_margin;
678
- if (num_hidden) {
679
  // Show
680
- num_margin = '0px';
681
- crayon[uid].nums_visible = true;
682
  } else {
683
  // Hide
684
  crayon[uid].table.css('margin-left', '0px');
685
- crayon[uid].nums_visible = false;
686
- num_margin = neg_width;
687
  }
688
 
689
  if (typeof instant != 'undefined') {
690
- crayon[uid].table.css('margin-left', num_margin);
691
- update_nums_button(uid);
692
  return false;
693
  }
694
 
695
  // Stop jerking animation from scrollbar appearing for a split second due to
696
  // change in width. Prevents scrollbar disappearing if already visible.
697
- h_scroll_visible = (crayon[uid].table.width() + px_to_int(crayon[uid].table.css('margin-left')) > crayon[uid].main.width());
698
  v_scroll_visible = (crayon[uid].table.height() > crayon[uid].main.height());
699
  if (!h_scroll_visible && !v_scroll_visible) {
700
  crayon[uid].main.css('overflow', 'hidden');
701
  }
702
  crayon[uid].table.animate({
703
- marginLeft: num_margin
704
  }, animt(200, uid), function () {
705
  if (typeof crayon[uid] != 'undefined') {
706
- update_nums_button(uid);
707
  if (!h_scroll_visible && !v_scroll_visible) {
708
  crayon[uid].main.css('overflow', 'auto');
709
  }
@@ -712,45 +722,47 @@
712
  return false;
713
  };
714
 
715
- base.toggle_wrap = function (uid) {
716
  crayon[uid].wrapped = !crayon[uid].wrapped;
717
- update_wrap(uid);
718
  };
719
 
720
- base.toggle_expand = function (uid) {
721
  var expand = !CrayonUtil.setDefault(crayon[uid].expanded, false);
722
- toggle_expand(uid, expand);
723
  };
724
 
725
- var update_wrap = function (uid) {
 
726
  if (crayon[uid].wrapped) {
727
  crayon[uid].addClass(CRAYON_WRAPPED);
728
  } else {
729
  crayon[uid].removeClass(CRAYON_WRAPPED);
730
  }
731
- update_wrap_button(uid);
732
- if (!crayon[uid].expanded) {
733
- restore_dimensions(uid);
734
- }
735
- crayon[uid].wrap_times = 0;
736
- crayon[uid].wrap_timer = setInterval(function () {
737
- reconsile_lines(uid);
738
- crayon[uid].wrap_times++;
739
- if (crayon[uid].wrap_times == 5) {
740
- clearInterval(crayon[uid].wrap_timer);
 
741
  }
742
  }, 200);
743
  };
744
 
745
- var fix_table_width = function (uid) {
746
  if (typeof crayon[uid] == 'undefined') {
747
- make_uid(uid);
748
  return false;
749
  }
750
  };
751
 
752
  // Convert '-10px' to -10
753
- var px_to_int = function (pixels) {
754
  if (typeof pixels != 'string') {
755
  return 0;
756
  }
@@ -762,87 +774,95 @@
762
  }
763
  };
764
 
765
- var update_nums_button = function (uid) {
766
- if (typeof crayon[uid] == 'undefined' || typeof crayon[uid].nums_visible == 'undefined') {
767
  return;
768
  }
769
- if (crayon[uid].nums_visible) {
770
- crayon[uid].nums_button.removeClass(UNPRESSED);
771
- crayon[uid].nums_button.addClass(PRESSED);
772
  } else {
773
  // TODO doesn't work on iPhone
774
- crayon[uid].nums_button.removeClass(PRESSED);
775
- crayon[uid].nums_button.addClass(UNPRESSED);
776
  }
777
  };
778
 
779
- var update_wrap_button = function (uid) {
780
  if (typeof crayon[uid] == 'undefined' || typeof crayon[uid].wrapped == 'undefined') {
781
  return;
782
  }
783
  if (crayon[uid].wrapped) {
784
- crayon[uid].wrap_button.removeClass(UNPRESSED);
785
- crayon[uid].wrap_button.addClass(PRESSED);
786
  } else {
787
  // TODO doesn't work on iPhone
788
- crayon[uid].wrap_button.removeClass(PRESSED);
789
- crayon[uid].wrap_button.addClass(UNPRESSED);
790
  }
791
  };
792
 
793
- var update_expand_button = function (uid) {
794
  if (typeof crayon[uid] == 'undefined' || typeof crayon[uid].expanded == 'undefined') {
795
  return;
796
  }
797
 
798
  if (crayon[uid].expanded) {
799
- crayon[uid].expand_button.removeClass(UNPRESSED);
800
- crayon[uid].expand_button.addClass(PRESSED);
801
  } else {
802
  // TODO doesn't work on iPhone
803
- crayon[uid].expand_button.removeClass(PRESSED);
804
- crayon[uid].expand_button.addClass(UNPRESSED);
805
  }
806
  };
807
 
808
- var update_plain_button = function (uid) {
809
- if (typeof crayon[uid] == 'undefined' || typeof crayon[uid].plain_visible == 'undefined') {
810
  return;
811
  }
812
 
813
- if (crayon[uid].plain_visible) {
814
- crayon[uid].plain_button.removeClass(UNPRESSED);
815
- crayon[uid].plain_button.addClass(PRESSED);
816
  } else {
817
  // TODO doesn't work on iPhone
818
- crayon[uid].plain_button.removeClass(PRESSED);
819
- crayon[uid].plain_button.addClass(UNPRESSED);
820
  }
821
  };
822
 
823
- var toolbar_toggle = function (uid, show, anim_time, hide_delay) {
824
  if (typeof crayon[uid] == 'undefined') {
825
- return make_uid(uid);
826
- } else if (!crayon[uid].toolbar_mouseover) {
827
  return;
828
  }
829
  var toolbar = crayon[uid].toolbar;
830
 
831
- if (typeof hide_delay == 'undefined') {
832
- hide_delay = crayon[uid].toolbar_delay;
833
  }
834
 
835
- crayon_slide(uid, toolbar, show, anim_time, hide_delay);
 
 
836
  };
837
 
838
  var initSize = function (uid) {
839
- // Shared for scrollbars and expanding
840
- crayon[uid].initialSize = {width: crayon[uid].width(), height: crayon[uid].height()};
 
 
 
 
 
 
841
  };
842
 
843
- var toggle_expand = function (uid, expand) {
844
  if (typeof crayon[uid] == 'undefined') {
845
- return make_uid(uid);
846
  }
847
  if (typeof expand == 'undefined') {
848
  return;
@@ -855,6 +875,10 @@
855
  if (typeof crayon[uid].expanded == 'undefined') {
856
  initSize(uid);
857
  crayon[uid].finalSize = {width: crayon[uid].table.width(), height: crayon[uid].table.height()};
 
 
 
 
858
  // Ensure we don't shrink
859
  crayon[uid].finalSize.width = CrayonUtil.setMin(crayon[uid].finalSize.width, crayon[uid].initialSize.width);
860
  crayon[uid].finalSize.height = CrayonUtil.setMin(crayon[uid].finalSize.height, crayon[uid].initialSize.height);
@@ -880,21 +904,27 @@
880
  'min-width': 'none',
881
  'max-width': 'none'
882
  };
883
- crayon[uid].height(crayon[uid].height());
884
  crayon[uid].width(crayon[uid].width());
885
  crayon[uid].css({
886
  'min-width': 'none',
887
  'max-width': 'none'
888
  });
 
 
 
 
 
 
 
 
889
  main.css(expandHeight);
890
  main.css(expandWidth);
891
  crayon[uid].stop(true);
892
- crayon[uid].animate({
893
- width: finalSize.width,
894
- height: finalSize.height
895
- }, animt(crayon[uid].expandTime, uid), function () {
896
  crayon[uid].expanded = true;
897
- update_expand_button(uid);
898
  });
899
  } else {
900
  var initialSize = crayon[uid].initialSize;
@@ -904,37 +934,40 @@
904
  if (!crayon[uid].expanded) {
905
  crayon[uid].delay(delay);
906
  }
907
- crayon[uid].animate({
908
- width: initialSize.width,
909
- height: initialSize.height
910
- }, animt(crayon[uid].expandTime, uid), function () {
911
- expand_finish(uid);
 
 
 
912
  });
913
  } else {
914
  setTimeout(function () {
915
- expand_finish(uid);
916
  }, delay);
917
  }
918
  }
919
 
920
- reconsile_dimensions(uid);
921
  if (expand) {
922
- update_wrap(uid);
923
  }
924
  };
925
 
926
- var expand_finish = function(uid) {
927
  crayon[uid].expanded = false;
928
- restore_dimensions(uid);
929
- update_expand_button(uid);
930
  if (crayon[uid].wrapped) {
931
- update_wrap(uid);
932
  }
933
  };
934
 
935
  var toggle_scroll = function (uid, show, expand) {
936
  if (typeof crayon[uid] == 'undefined') {
937
- return make_uid(uid);
938
  }
939
  if (typeof show == 'undefined') {
940
  return;
@@ -943,13 +976,11 @@
943
  var main = crayon[uid].main;
944
  var plain = crayon[uid].plain;
945
 
946
- if (typeof crayon[uid].initialSize == 'undefined') {
947
- initSize(uid);
948
- }
949
 
950
  if (show) {
951
- main.height(main.height());
952
- plain.height(plain.height());
953
  // Show scrollbars
954
  main.css('overflow', 'auto');
955
  plain.css('overflow', 'auto');
@@ -968,22 +999,18 @@
968
  crayon[uid].left = visible.scrollLeft();
969
  main.css('overflow', 'hidden');
970
  plain.css('overflow', 'hidden');
971
- // main.height(crayon[uid].initialSize.height);
972
- // plain.height(crayon[uid].initialSize.height);
973
-
974
  if (!crayon[uid].expanded) {
975
- restore_dimensions(uid);
976
  }
977
-
978
- //restore_dimensions(uid);
979
  }
980
  // Register that overflow has changed
981
- crayon[uid].scroll_changed = true;
982
- fix_scroll_blank(uid);
983
  };
984
 
985
  /* Fix weird draw error, causes blank area to appear where scrollbar once was. */
986
- var fix_scroll_blank = function (uid) {
987
  // Scrollbar draw error in Chrome
988
  crayon[uid].table.style('width', '100%', 'important');
989
  var redraw = setTimeout(function () {
@@ -992,27 +1019,27 @@
992
  }, 10);
993
  };
994
 
995
- var restore_dimensions = function (uid) {
996
  // Restore dimensions
997
  var main = crayon[uid].main;
998
- var main_style = crayon[uid].main_style;
999
- main.css(main_style);
1000
  // Width styles also apply to crayon
1001
  crayon[uid].css('height', 'auto');
1002
- crayon[uid].css('width', main_style['width']);
1003
- crayon[uid].css('max-width', main_style['max-width']);
1004
- crayon[uid].css('min-width', main_style['min-width']);
1005
  };
1006
 
1007
- var reconsile_dimensions = function (uid) {
1008
  // Reconsile dimensions
1009
  crayon[uid].plain.height(crayon[uid].main.height());
1010
  };
1011
 
1012
- var reconsile_lines = function (uid) {
1013
  $(CRAYON_NUM, crayon[uid]).each(function () {
1014
- var line_id = $(this).attr('data-line');
1015
- var line = $('#' + line_id);
1016
  if (crayon[uid].wrapped) {
1017
  line.css('height', '');
1018
  $(this).css('height', line.height());
@@ -1020,12 +1047,9 @@
1020
  } else {
1021
  var height = line.attr('data-height');
1022
  height = height ? height : '';
1023
- if (typeof height != 'undefined') {
1024
- line.css('height', height);
1025
- $(this).css('height', height);
1026
- }
1027
  //line.css('height', line.css('line-height'));
1028
- //console.log(line.css('line-height'));
1029
  }
1030
  });
1031
  };
21
  if (typeof styleName != 'undefined') {
22
  if (typeof value != 'undefined') {
23
  // Set style property
24
+ priority = typeof priority != 'undefined' ? priority : '';
25
  if (typeof style.setProperty != 'undefined') {
26
  style.setProperty(styleName, value, priority);
27
  } else {
28
+ // XXX Using priority breaks on IE 7 & 8
29
+ // if (priority) {
30
+ // value = value + ' !' + priority;
31
+ // }
32
+ style[styleName] = value;
33
  }
34
  } else {
35
  // Get style property
36
+ return style[styleName];
37
  }
38
  } else {
39
  // Get CSSStyleDeclaration
93
  uid += getUID();
94
  }
95
  c.attr('id', uid);
96
+ CrayonUtil.log(uid);
97
 
98
  if (typeof replace == 'undefined') {
99
  replace = false;
100
  }
101
 
102
+ if (!replace && !makeUID(uid)) {
103
  // Already a Crayon
104
  return;
105
  }
111
  var table = c.find(CRAYON_TABLE);
112
  var code = c.find(CRAYON_CODE);
113
  var nums = c.find(CRAYON_NUMS);
114
+ var numsContent = c.find(CRAYON_NUMS_CONTENT);
115
+ var numsButton = c.find(CRAYON_NUMS_BUTTON);
116
+ var wrapButton = c.find(CRAYON_WRAP_BUTTON);
117
+ var expandButton = c.find(CRAYON_EXPAND_BUTTON);
118
+ var popupButton = c.find(CRAYON_POPUP_BUTTON);
119
+ var copyButton = c.find(CRAYON_COPY_BUTTON);
120
+ var plainButton = c.find(CRAYON_PLAIN_BUTTON);
121
 
122
  crayon[uid] = c;
123
  crayon[uid].toolbar = toolbar;
127
  crayon[uid].table = table;
128
  crayon[uid].code = code;
129
  crayon[uid].nums = nums;
130
+ crayon[uid].nums_content = numsContent;
131
+ crayon[uid].numsButton = numsButton;
132
+ crayon[uid].wrapButton = wrapButton;
133
+ crayon[uid].expandButton = expandButton;
134
+ crayon[uid].popup_button = popupButton;
135
+ crayon[uid].copy_button = copyButton;
136
+ crayon[uid].plainButton = plainButton;
137
+ crayon[uid].numsVisible = true;
138
  crayon[uid].wrapped = false;
139
+ crayon[uid].plainVisible = false;
140
 
141
  crayon[uid].toolbar_delay = 0;
142
  crayon[uid].time = 1;
145
  $(CRAYON_PLAIN).css('z-index', 0);
146
 
147
  // XXX Remember CSS dimensions
148
+ var mainStyle = main.style();
149
  crayon[uid].main_style = {
150
+ 'height': mainStyle && mainStyle.height || '',
151
+ 'max-height': mainStyle && mainStyle.maxHeight || '',
152
+ 'min-height': mainStyle && mainStyle.minHeight || '',
153
+ 'width': mainStyle && mainStyle.width || '',
154
+ 'max-width': mainStyle && mainStyle.maxWidth || '',
155
+ 'min-width': mainStyle && mainStyle.minWidth || ''
156
  };
157
 
158
  var load_timer;
159
  var i = 0;
160
  crayon[uid].loading = true;
161
+ crayon[uid].scrollBlockFix = false;
162
 
163
  // Register click events
164
+ numsButton.click(function () {
165
+ CrayonSyntax.toggleNums(uid);
166
  });
167
+ wrapButton.click(function () {
168
+ CrayonSyntax.toggleWrap(uid);
169
  });
170
+ expandButton.click(function () {
171
+ CrayonSyntax.toggleExpand(uid);
172
  });
173
+ plainButton.click(function () {
174
+ CrayonSyntax.togglePlain(uid);
175
  });
176
+ copyButton.click(function () {
177
+ CrayonSyntax.copyPlain(uid);
178
  });
179
 
180
  // Enable retina if supported
181
  retina(uid);
182
 
183
  var load_func = function () {
 
 
 
 
184
  // If nums hidden by default
185
  if (nums.filter('[data-settings~="hide"]').length != 0) {
186
+ numsContent.ready(function () {
187
+ CrayonUtil.log('function' + uid);
188
+ CrayonSyntax.toggleNums(uid, true, true);
189
  });
190
  } else {
191
+ updateNumsButton(uid);
192
  }
193
 
194
  if (typeof crayon[uid].expanded == 'undefined') {
195
  // Determine if we should enable code expanding toggling
196
  if (Math.abs(crayon[uid].main.width() - crayon[uid].table.width()) < 10) {
197
+ crayon[uid].expandButton.hide();
198
  } else {
199
+ crayon[uid].expandButton.show();
200
  }
201
  }
202
 
209
  i++;
210
  };
211
  load_timer = setInterval(load_func, 300);
212
+ fixScrollBlank(uid);
213
 
214
  // Add ref to num for each line
215
  $(CRAYON_NUM, crayon[uid]).each(function () {
216
+ var lineID = $(this).attr('data-line');
217
+ var line = $('#' + lineID);
218
  var height = line.style('height');
219
  if (height) {
220
  line.attr('data-height', height);
231
  // Used to hide info
232
  if (!touchscreen) {
233
  main.click(function () {
234
+ crayonInfo(uid, '', false);
235
  });
236
  plain.click(function () {
237
+ crayonInfo(uid, '', false);
238
  });
239
  info.click(function () {
240
+ crayonInfo(uid, '', false);
241
  });
242
  }
243
 
244
  // Used for code popup
245
  if (c.filter('[data-settings~="no-popup"]').length == 0) {
246
+ crayon[uid].popup_settings = popupWindow(popupButton, {
247
  height: screen.height - 200,
248
  width: screen.width - 100,
249
  top: 75,
252
  windowURL: '',
253
  data: '' // Data overrides URL
254
  }, function () {
255
+ codePopup(uid);
256
  }, function () {
257
+ //CrayonUtil.log('after');
258
  });
259
  }
260
 
261
  plain.css('opacity', 0);
262
+
263
+ crayon[uid].toolbar_visible = true;
264
+ crayon[uid].toolbarMouseover = false;
265
  // If a toolbar with mouseover was found
266
  if (toolbar.filter('[data-settings~="mouseover"]').length != 0 && !touchscreen) {
267
+ crayon[uid].toolbarMouseover = true;
268
+ crayon[uid].toolbar_visible = false;
269
 
270
  toolbar.css('margin-top', '-' + toolbar.height() + 'px');
271
  toolbar.hide();
278
  // Hide on single click when overlayed
279
  if (toolbar.filter('[data-settings~="hide"]').length != 0) {
280
  main.click(function () {
281
+ toggleToolbar(uid, undefined, undefined, 0);
282
  });
283
  plain.click(function () {
284
+ toggleToolbar(uid, false, undefined, 0);
285
  });
286
  }
287
  } else {
293
  }
294
  // Use .hover() for chrome, but in firefox mouseover/mouseout worked best
295
  c.mouseenter(function () {
296
+ toggleToolbar(uid, true);
297
  })
298
  .mouseleave(function () {
299
+ toggleToolbar(uid, false);
300
  });
301
  } else if (touchscreen) {
302
  toolbar.show();
306
  if (plain.length != 0 && !touchscreen) {
307
  if (plain.filter('[data-settings~="dblclick"]').length != 0) {
308
  main.dblclick(function () {
309
+ CrayonSyntax.togglePlain(uid);
310
  });
311
  } else if (plain.filter('[data-settings~="click"]').length != 0) {
312
  main.click(function () {
313
+ CrayonSyntax.togglePlain(uid);
314
  });
315
  } else if (plain.filter('[data-settings~="mouseover"]').length != 0) {
316
  c.mouseenter(function () {
317
+ CrayonSyntax.togglePlain(uid, true);
318
  })
319
  .mouseleave(function () {
320
+ CrayonSyntax.togglePlain(uid, false);
321
  });
322
+ numsButton.hide();
323
  }
324
  if (plain.filter('[data-settings~="show-plain-default"]').length != 0) {
325
  // XXX
326
+ CrayonSyntax.togglePlain(uid, true);
327
  }
328
  }
329
 
346
 
347
  if (expand) {
348
  c.mouseenter(function () {
349
+ toggleExpand(uid, true);
350
  })
351
  .mouseleave(function () {
352
+ toggleExpand(uid, false);
353
  });
354
  }
355
 
367
  crayon[uid].mac = c.hasClass('crayon-os-mac');
368
 
369
  // Update clickable buttons
370
+ updateNumsButton(uid);
371
+ updatePlainButton(uid);
372
+ updateWrap(uid);
373
  };
374
 
375
+ var makeUID = function (uid) {
376
+ CrayonUtil.log(crayon);
377
  if (typeof crayon[uid] == 'undefined') {
378
  crayon[uid] = $('#' + uid);
379
+ CrayonUtil.log('make ' + uid);
380
  return true;
381
  }
382
 
383
+ CrayonUtil.log('no make ' + uid);
384
  return false;
385
  };
386
 
388
  return currUID++;
389
  };
390
 
391
+ var codePopup = function (uid) {
392
  if (typeof crayon[uid] == 'undefined') {
393
+ return makeUID(uid);
394
  }
395
  var settings = crayon[uid].popup_settings;
396
  if (settings.data) {
417
  clone.find(CRAYON_MAIN).css('height', '');
418
 
419
  var code = '';
420
+ if (crayon[uid].plainVisible) {
421
  code = clone.find(CRAYON_PLAIN);
422
  } else {
423
  code = clone.find(CRAYON_MAIN);
424
  }
425
 
426
+ settings.data = base.getAllCSS() + '<body class="crayon-popup-window" style="padding:0; margin:0;"><div class="' + clone.attr('class') +
427
+ ' crayon-popup">' + removeCssInline(getHtmlString(code)) + '</div></body>';
428
  };
429
 
430
+ var getHtmlString = function (object) {
431
  return $('<div>').append(object.clone()).remove().html();
432
  };
433
 
434
+ var removeCssInline = function (string) {
435
  var reStyle = /style\s*=\s*"([^"]+)"/gmi;
436
  var match = null;
437
  while ((match = reStyle.exec(string)) != null) {
443
  };
444
 
445
  // Get all CSS on the page as a string
446
+ base.getAllCSS = function () {
447
  var css_str = '';
448
  var css = $('link[rel="stylesheet"]');
449
  var filtered = [];
455
  filtered = css.filter('[href*="crayon-syntax-highlighter"]');
456
  }
457
  filtered.each(function () {
458
+ var string = getHtmlString($(this));
459
  css_str += string;
460
  });
461
  return css_str;
462
  };
463
 
464
+ base.copyPlain = function (uid, hover) {
465
  if (typeof crayon[uid] == 'undefined') {
466
+ return makeUID(uid);
467
  }
468
 
469
  var plain = crayon[uid].plain;
470
 
471
+ base.togglePlain(uid, true, true);
472
+ toggleToolbar(uid, true);
473
 
474
  key = crayon[uid].mac ? '\u2318' : 'CTRL';
475
  var text = crayon[uid].copy_button.attr('data-text');
476
  text = text.replace(/%s/, key + '+C');
477
  text = text.replace(/%s/, key + '+V');
478
+ crayonInfo(uid, text);
479
  return false;
480
  };
481
 
482
+ var crayonInfo = function (uid, text, show) {
483
  if (typeof crayon[uid] == 'undefined') {
484
+ return makeUID(uid);
485
  }
486
 
487
  var info = crayon[uid].info;
493
  show = true;
494
  }
495
 
496
+ if (isSlideHidden(info) && show) {
497
  info.html('<div>' + text + '</div>');
498
  info.css('margin-top', -info.height());
499
  info.show();
500
+ crayonSlide(uid, info, true);
501
  setTimeout(function () {
502
+ crayonSlide(uid, info, false);
503
  }, 5000);
504
  }
505
 
506
  if (!show) {
507
+ crayonSlide(uid, info, false);
508
  }
509
 
510
  };
521
  }
522
  };
523
 
524
+ var isSlideHidden = function (object) {
525
  var object_neg_height = '-' + object.height() + 'px';
526
  if (object.css('margin-top') == object_neg_height || object.css('display') == 'none') {
527
  return true;
530
  }
531
  };
532
 
533
+ var crayonSlide = function (uid, object, show, animTime, hideDelay, callback) {
534
+ var complete = function () {
535
+ if (callback) {
536
+ callback(uid, object);
537
+ }
538
+ }
539
+ var objectNegHeight = '-' + object.height() + 'px';
540
 
541
  if (typeof show == 'undefined') {
542
+ if (isSlideHidden(object)) {
543
  show = true;
544
  } else {
545
  show = false;
546
  }
547
  }
548
  // Instant means no time delay for showing/hiding
549
+ if (typeof animTime == 'undefined') {
550
+ animTime = 100;
551
  }
552
+ if (animTime == false) {
553
+ animTime = false;
554
  }
555
+ if (typeof hideDelay == 'undefined') {
556
+ hideDelay = 0;
557
  }
558
  object.stop(true);
559
  if (show == true) {
560
  object.show();
561
  object.animate({
562
  marginTop: 0
563
+ }, animt(animTime, uid), complete);
564
  } else if (show == false) {
565
  // Delay if fully visible
566
+ if (/*instant == false && */object.css('margin-top') == '0px' && hideDelay) {
567
+ object.delay(hideDelay);
568
  }
569
  object.animate({
570
+ marginTop: objectNegHeight
571
+ }, animt(animTime, uid), function () {
572
  object.hide();
573
+ complete();
574
  });
575
  }
576
  };
577
 
578
+ base.togglePlain = function (uid, hover, select) {
579
  if (typeof crayon[uid] == 'undefined') {
580
+ return makeUID(uid);
581
  }
582
 
583
  var main = crayon[uid].main;
587
  return;
588
  }
589
 
590
+ reconsileDimensions(uid);
591
 
592
  var visible, hidden;
593
  if (typeof hover != 'undefined') {
608
  }
609
  }
610
 
611
+ crayon[uid].plainVisible = (hidden == plain);
612
 
613
  // Remember scroll positions of visible
614
  crayon[uid].top = visible.scrollTop();
617
  /* Used to detect a change in overflow when the mouse moves out
618
  * of the Crayon. If it does, then overflow has already been changed,
619
  * no need to revert it after toggling plain. */
620
+ crayon[uid].scrollChanged = false;
621
 
622
  // Hide scrollbars during toggle to avoid Chrome weird draw error
623
  // visible.css('overflow', 'hidden');
624
  // hidden.css('overflow', 'hidden');
625
 
626
+ fixScrollBlank(uid);
627
 
628
  // Show hidden, hide visible
629
  visible.stop(true);
656
  hidden.scrollTop(crayon[uid].top);
657
  hidden.scrollLeft(crayon[uid].left);
658
 
659
+ updatePlainButton(uid);
660
 
661
  // Hide toolbar if possible
662
+ toggleToolbar(uid, false);
663
  return false;
664
  };
665
 
666
+ base.toggleNums = function (uid, hide, instant) {
667
  if (typeof crayon[uid] == 'undefined') {
668
+ makeUID(uid);
669
  return false;
670
  }
671
 
672
  if (crayon[uid].table.is(':animated')) {
673
  return false;
674
  }
675
+ var numsWidth = Math.round(crayon[uid].nums_content.width() + 1);
676
+ var negWidth = '-' + numsWidth + 'px';
677
 
678
  // Force hiding
679
+ var numHidden;
680
  if (typeof hide != 'undefined') {
681
+ numHidden = false;
682
  } else {
683
  // Check hiding
684
+ numHidden = (crayon[uid].table.css('margin-left') == negWidth);
685
  }
686
 
687
+ var numMargin;
688
+ if (numHidden) {
689
  // Show
690
+ numMargin = '0px';
691
+ crayon[uid].numsVisible = true;
692
  } else {
693
  // Hide
694
  crayon[uid].table.css('margin-left', '0px');
695
+ crayon[uid].numsVisible = false;
696
+ numMargin = negWidth;
697
  }
698
 
699
  if (typeof instant != 'undefined') {
700
+ crayon[uid].table.css('margin-left', numMargin);
701
+ updateNumsButton(uid);
702
  return false;
703
  }
704
 
705
  // Stop jerking animation from scrollbar appearing for a split second due to
706
  // change in width. Prevents scrollbar disappearing if already visible.
707
+ h_scroll_visible = (crayon[uid].table.width() + pxToInt(crayon[uid].table.css('margin-left')) > crayon[uid].main.width());
708
  v_scroll_visible = (crayon[uid].table.height() > crayon[uid].main.height());
709
  if (!h_scroll_visible && !v_scroll_visible) {
710
  crayon[uid].main.css('overflow', 'hidden');
711
  }
712
  crayon[uid].table.animate({
713
+ marginLeft: numMargin
714
  }, animt(200, uid), function () {
715
  if (typeof crayon[uid] != 'undefined') {
716
+ updateNumsButton(uid);
717
  if (!h_scroll_visible && !v_scroll_visible) {
718
  crayon[uid].main.css('overflow', 'auto');
719
  }
722
  return false;
723
  };
724
 
725
+ base.toggleWrap = function (uid) {
726
  crayon[uid].wrapped = !crayon[uid].wrapped;
727
+ updateWrap(uid);
728
  };
729
 
730
+ base.toggleExpand = function (uid) {
731
  var expand = !CrayonUtil.setDefault(crayon[uid].expanded, false);
732
+ toggleExpand(uid, expand);
733
  };
734
 
735
+ var updateWrap = function (uid, restore) {
736
+ restore = CrayonUtil.setDefault(restore, true);
737
  if (crayon[uid].wrapped) {
738
  crayon[uid].addClass(CRAYON_WRAPPED);
739
  } else {
740
  crayon[uid].removeClass(CRAYON_WRAPPED);
741
  }
742
+ updateWrapButton(uid);
743
+ if (!crayon[uid].expanded && restore) {
744
+ restoreDimensions(uid);
745
+ }
746
+ crayon[uid].wrapTimes = 0;
747
+ clearInterval(crayon[uid].wrapTimer);
748
+ crayon[uid].wrapTimer = setInterval(function () {
749
+ reconsileLines(uid);
750
+ crayon[uid].wrapTimes++;
751
+ if (crayon[uid].wrapTimes == 5) {
752
+ clearInterval(crayon[uid].wrapTimer);
753
  }
754
  }, 200);
755
  };
756
 
757
+ var fixTableWidth = function (uid) {
758
  if (typeof crayon[uid] == 'undefined') {
759
+ makeUID(uid);
760
  return false;
761
  }
762
  };
763
 
764
  // Convert '-10px' to -10
765
+ var pxToInt = function (pixels) {
766
  if (typeof pixels != 'string') {
767
  return 0;
768
  }
774
  }
775
  };
776
 
777
+ var updateNumsButton = function (uid) {
778
+ if (typeof crayon[uid] == 'undefined' || typeof crayon[uid].numsVisible == 'undefined') {
779
  return;
780
  }
781
+ if (crayon[uid].numsVisible) {
782
+ crayon[uid].numsButton.removeClass(UNPRESSED);
783
+ crayon[uid].numsButton.addClass(PRESSED);
784
  } else {
785
  // TODO doesn't work on iPhone
786
+ crayon[uid].numsButton.removeClass(PRESSED);
787
+ crayon[uid].numsButton.addClass(UNPRESSED);
788
  }
789
  };
790
 
791
+ var updateWrapButton = function (uid) {
792
  if (typeof crayon[uid] == 'undefined' || typeof crayon[uid].wrapped == 'undefined') {
793
  return;
794
  }
795
  if (crayon[uid].wrapped) {
796
+ crayon[uid].wrapButton.removeClass(UNPRESSED);
797
+ crayon[uid].wrapButton.addClass(PRESSED);
798
  } else {
799
  // TODO doesn't work on iPhone
800
+ crayon[uid].wrapButton.removeClass(PRESSED);
801
+ crayon[uid].wrapButton.addClass(UNPRESSED);
802
  }
803
  };
804
 
805
+ var updateExpandButton = function (uid) {
806
  if (typeof crayon[uid] == 'undefined' || typeof crayon[uid].expanded == 'undefined') {
807
  return;
808
  }
809
 
810
  if (crayon[uid].expanded) {
811
+ crayon[uid].expandButton.removeClass(UNPRESSED);
812
+ crayon[uid].expandButton.addClass(PRESSED);
813
  } else {
814
  // TODO doesn't work on iPhone
815
+ crayon[uid].expandButton.removeClass(PRESSED);
816
+ crayon[uid].expandButton.addClass(UNPRESSED);
817
  }
818
  };
819
 
820
+ var updatePlainButton = function (uid) {
821
+ if (typeof crayon[uid] == 'undefined' || typeof crayon[uid].plainVisible == 'undefined') {
822
  return;
823
  }
824
 
825
+ if (crayon[uid].plainVisible) {
826
+ crayon[uid].plainButton.removeClass(UNPRESSED);
827
+ crayon[uid].plainButton.addClass(PRESSED);
828
  } else {
829
  // TODO doesn't work on iPhone
830
+ crayon[uid].plainButton.removeClass(PRESSED);
831
+ crayon[uid].plainButton.addClass(UNPRESSED);
832
  }
833
  };
834
 
835
+ var toggleToolbar = function (uid, show, animTime, hideDelay) {
836
  if (typeof crayon[uid] == 'undefined') {
837
+ return makeUID(uid);
838
+ } else if (!crayon[uid].toolbarMouseover) {
839
  return;
840
  }
841
  var toolbar = crayon[uid].toolbar;
842
 
843
+ if (typeof hideDelay == 'undefined') {
844
+ hideDelay = crayon[uid].toolbar_delay;
845
  }
846
 
847
+ crayonSlide(uid, toolbar, show, animTime, hideDelay, function () {
848
+ crayon[uid].toolbar_visible = show;
849
+ });
850
  };
851
 
852
  var initSize = function (uid) {
853
+ if (typeof crayon[uid].initialSize == 'undefined') {
854
+ // Shared for scrollbars and expanding
855
+ crayon[uid].initialSize = {width: crayon[uid].main.width(), height: crayon[uid].main.height()};
856
+ // If toolbar is always showing, make room for it
857
+ if (crayon[uid].toolbarMouseover == false) {
858
+ crayon[uid].initialSize.height += crayon[uid].toolbar.height();
859
+ }
860
+ }
861
  };
862
 
863
+ var toggleExpand = function (uid, expand) {
864
  if (typeof crayon[uid] == 'undefined') {
865
+ return makeUID(uid);
866
  }
867
  if (typeof expand == 'undefined') {
868
  return;
875
  if (typeof crayon[uid].expanded == 'undefined') {
876
  initSize(uid);
877
  crayon[uid].finalSize = {width: crayon[uid].table.width(), height: crayon[uid].table.height()};
878
+ // If toolbar is always showing, make room for it
879
+ if (crayon[uid].toolbarMouseover == false) {
880
+ crayon[uid].finalSize.height += crayon[uid].toolbar.height();
881
+ }
882
  // Ensure we don't shrink
883
  crayon[uid].finalSize.width = CrayonUtil.setMin(crayon[uid].finalSize.width, crayon[uid].initialSize.width);
884
  crayon[uid].finalSize.height = CrayonUtil.setMin(crayon[uid].finalSize.height, crayon[uid].initialSize.height);
904
  'min-width': 'none',
905
  'max-width': 'none'
906
  };
907
+
908
  crayon[uid].width(crayon[uid].width());
909
  crayon[uid].css({
910
  'min-width': 'none',
911
  'max-width': 'none'
912
  });
913
+ var newSize = {
914
+ width: finalSize.width
915
+ };
916
+ if (finalSize.height > crayon[uid].toolbar.height() * 2) {
917
+ newSize.height = finalSize.height;
918
+ crayon[uid].height(crayon[uid].height());
919
+ }
920
+
921
  main.css(expandHeight);
922
  main.css(expandWidth);
923
  crayon[uid].stop(true);
924
+
925
+ crayon[uid].animate(newSize, animt(crayon[uid].expandTime, uid), function () {
 
 
926
  crayon[uid].expanded = true;
927
+ updateExpandButton(uid);
928
  });
929
  } else {
930
  var initialSize = crayon[uid].initialSize;
934
  if (!crayon[uid].expanded) {
935
  crayon[uid].delay(delay);
936
  }
937
+ var newSize = {
938
+ width: initialSize.width
939
+ };
940
+ if (crayon[uid].style('height') != 'auto') {
941
+ newSize.height = initialSize.height;
942
+ }
943
+ crayon[uid].animate(newSize, animt(crayon[uid].expandTime, uid), function () {
944
+ expandFinish(uid);
945
  });
946
  } else {
947
  setTimeout(function () {
948
+ expandFinish(uid);
949
  }, delay);
950
  }
951
  }
952
 
953
+ reconsileDimensions(uid);
954
  if (expand) {
955
+ updateWrap(uid, false);
956
  }
957
  };
958
 
959
+ var expandFinish = function(uid) {
960
  crayon[uid].expanded = false;
961
+ restoreDimensions(uid);
962
+ updateExpandButton(uid);
963
  if (crayon[uid].wrapped) {
964
+ updateWrap(uid);
965
  }
966
  };
967
 
968
  var toggle_scroll = function (uid, show, expand) {
969
  if (typeof crayon[uid] == 'undefined') {
970
+ return makeUID(uid);
971
  }
972
  if (typeof show == 'undefined') {
973
  return;
976
  var main = crayon[uid].main;
977
  var plain = crayon[uid].plain;
978
 
979
+ initSize(uid);
 
 
980
 
981
  if (show) {
982
+ // main.height(main.height());
983
+ // plain.height(plain.height());
984
  // Show scrollbars
985
  main.css('overflow', 'auto');
986
  plain.css('overflow', 'auto');
999
  crayon[uid].left = visible.scrollLeft();
1000
  main.css('overflow', 'hidden');
1001
  plain.css('overflow', 'hidden');
1002
+
 
 
1003
  if (!crayon[uid].expanded) {
1004
+ restoreDimensions(uid);
1005
  }
 
 
1006
  }
1007
  // Register that overflow has changed
1008
+ crayon[uid].scrollChanged = true;
1009
+ fixScrollBlank(uid);
1010
  };
1011
 
1012
  /* Fix weird draw error, causes blank area to appear where scrollbar once was. */
1013
+ var fixScrollBlank = function (uid) {
1014
  // Scrollbar draw error in Chrome
1015
  crayon[uid].table.style('width', '100%', 'important');
1016
  var redraw = setTimeout(function () {
1019
  }, 10);
1020
  };
1021
 
1022
+ var restoreDimensions = function (uid) {
1023
  // Restore dimensions
1024
  var main = crayon[uid].main;
1025
+ var mainStyle = crayon[uid].main_style;
1026
+ main.css(mainStyle);
1027
  // Width styles also apply to crayon
1028
  crayon[uid].css('height', 'auto');
1029
+ crayon[uid].css('width', mainStyle['width']);
1030
+ crayon[uid].css('max-width', mainStyle['max-width']);
1031
+ crayon[uid].css('min-width', mainStyle['min-width']);
1032
  };
1033
 
1034
+ var reconsileDimensions = function (uid) {
1035
  // Reconsile dimensions
1036
  crayon[uid].plain.height(crayon[uid].main.height());
1037
  };
1038
 
1039
+ var reconsileLines = function (uid) {
1040
  $(CRAYON_NUM, crayon[uid]).each(function () {
1041
+ var lineID = $(this).attr('data-line');
1042
+ var line = $('#' + lineID);
1043
  if (crayon[uid].wrapped) {
1044
  line.css('height', '');
1045
  $(this).css('height', line.height());
1047
  } else {
1048
  var height = line.attr('data-height');
1049
  height = height ? height : '';
1050
+ line.css('height', height);
1051
+ $(this).css('height', height);
 
 
1052
  //line.css('height', line.css('line-height'));
 
1053
  }
1054
  });
1055
  };
js/crayon_admin.js CHANGED
@@ -6,30 +6,30 @@
6
  var base = this;
7
 
8
  // Preview
9
- var preview, preview_info, preview_cbox, preview_delay_timer, preview_get = null;
10
  // The DOM object ids that trigger a preview update
11
  var preview_obj_names = [];
12
  // The jQuery objects for these objects
13
  var preview_objs = [];
14
  var preview_last_values = [];
15
  // Alignment
16
- var align_drop = float = null;
17
  // Toolbar
18
- var overlay = toolbar = null;
19
  // Error
20
- var msg_cbox = msg = null;
21
  // Log
22
- var log_button = log_text = null;
23
 
24
- var main_wrap, theme_editor_wrap, editor_url, theme_editor_edit_button, theme_editor_create_button = null;
25
- var theme_select, theme_info, theme_ver, theme_author, theme_desc = null;
26
 
27
  var settings = null;
28
  var adminSettings = null;
29
  var util = null;
30
 
31
  base.init = function () {
32
- console_log('admin init');
33
  settings = CrayonSyntaxSettings;
34
  adminSettings = CrayonAdminSettings;
35
  util = CrayonUtil;
@@ -37,17 +37,6 @@
37
  // Wraps
38
  main_wrap = $('#crayon-main-wrap');
39
  theme_editor_wrap = $('#crayon-theme-editor-wrap');
40
- editor_url = theme_editor_wrap.attr('url');
41
- theme_editor_edit_button = $('#crayon-theme-editor-edit-button');
42
- theme_editor_create_button = $('#crayon-theme-editor-create-button');
43
- theme_editor_edit_button.click(function () {
44
- CrayonSyntaxAdmin.show_theme_editor(theme_editor_edit_button,
45
- true);
46
- });
47
- theme_editor_create_button.click(function () {
48
- CrayonSyntaxAdmin.show_theme_editor(theme_editor_create_button,
49
- false);
50
- });
51
 
52
  // Themes
53
  theme_select = $('#crayon-theme');
@@ -61,15 +50,45 @@
61
  base.preview_update();
62
  });
63
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
64
  // Help
65
  help = $('.crayon-help-close');
66
  help.click(function () {
67
  $('.crayon-help').hide();
68
- $.get(settings.ajaxurl, {action : 'crayon-ajax', 'hide-help' : 1});
 
 
 
69
  });
70
 
71
  // Preview
72
  preview = $('#crayon-live-preview');
 
73
  preview_info = $('#crayon-preview-info');
74
  preview_cbox = util.cssElem('#preview');
75
  if (preview.length != 0) {
@@ -84,30 +103,39 @@
84
  }
85
 
86
  $('#show-posts').click(function () {
87
- $.get(settings.ajaxurl, {action : 'crayon-show-posts'}, function (data) {
 
 
88
  $('#crayon-subsection-posts-info').html(data);
89
  });
90
  });
91
 
92
  $('#show-langs').click(function () {
93
- $.get(settings.ajaxurl, {action : 'crayon-show-langs'}, function (data) {
 
 
94
  $('#lang-info').hide();
95
  $('#crayon-subsection-langs-info').html(data);
96
  });
97
  });
98
 
99
  // Convert
100
- $('#crayon-settings-form input').live('focusin focusout mouseup', function () {
101
- $('#crayon-settings-form').data('lastSelected', $(this));
102
- });
103
- $('#crayon-settings-form').submit(function () {
104
- var last = $(this).data('lastSelected').get(0);
105
- var target = $('#convert').get(0);
106
- if (last == target) {
107
- var r = confirm("Please BACKUP your database first! Converting will update your post content. Do you wish to continue?");
108
- return r;
109
- }
110
- });
 
 
 
 
 
111
 
112
  // Alignment
113
  align_drop = util.cssElem('#h-align');
@@ -164,7 +192,6 @@
164
  : show_log);
165
  log_button.val(text);
166
  });
167
-
168
  };
169
 
170
  /* Whenever a control changes preview */
@@ -172,8 +199,8 @@
172
  var val = 0;
173
  var obj;
174
  var getVars = {
175
- action : 'crayon-show-preview',
176
- theme : adminSettings.curr_theme
177
  };
178
  for (var i = 0; i < preview_obj_names.length; i++) {
179
  obj = preview_objs[i];
@@ -182,19 +209,30 @@
182
  } else {
183
  val = obj.val();
184
  }
185
- getVars[preview_obj_names[i]] = crayon_escape(val);
186
  }
187
 
188
  // Load Preview
189
- $.get(settings.ajaxurl, getVars, function (data) {
190
  preview.html(data);
191
  // Important! Calls the crayon.js init
192
  CrayonSyntax.init();
 
193
  });
194
  };
195
 
 
 
 
 
 
 
 
 
 
 
196
  var preview_toggle = function () {
197
- // console_log('preview_toggle');
198
  if (preview_cbox.is(':checked')) {
199
  preview.show();
200
  preview_info.show();
@@ -230,13 +268,13 @@
230
  // Checks if the text input is changed, if so, runs the callback
231
  // with given event
232
  preview_txt_change = function (callback, event) {
233
- // console_log('checking if changed');
234
  var obj = event.target;
235
  var last = preview_last_values[obj.id];
236
- // console_log('last' + preview_last_values[obj.id]);
237
 
238
  if (obj.value != last) {
239
- // console_log('changed');
240
  // Update last value to current
241
  preview_last_values[obj.id] = obj.value;
242
  // Run callback with event
@@ -246,7 +284,7 @@
246
 
247
  // Only updates when text is changed
248
  preview_txt_callback = function (event) {
249
- // console_log('txt callback');
250
  preview_txt_change(base.preview_update, event);
251
  };
252
 
@@ -255,7 +293,7 @@
255
  preview_txt_change(function () {
256
  clearInterval(preview_delay_timer);
257
  preview_delay_timer = setInterval(function () {
258
- // console_log('delayed update');
259
  base.preview_update();
260
  clearInterval(preview_delay_timer);
261
  }, 500);
@@ -313,66 +351,174 @@
313
  return false;
314
  };
315
 
316
- base.show_theme_editor_now = function (button) {
317
- main_wrap.hide();
318
- theme_editor_wrap.show();
319
- theme_editor_loading = false;
320
- button.html(button.attr('loaded'));
321
- };
322
 
323
- base.show_theme_info = function (callback) {
324
- adminSettings.curr_theme = $('#crayon-theme').val();
325
- adminSettings.curr_theme_url = adminSettings.themes_url + adminSettings.curr_theme + '/' + adminSettings.curr_theme + '.css';
 
 
 
 
 
 
326
  $.ajax({
327
- url : adminSettings.curr_theme_url,
328
- success : function (data) {
329
- adminSettings.curr_theme_str = data;
330
- var fields = {
331
- 'Version' : theme_ver,
332
- 'Author' : theme_author,
333
- 'Author URI' : null,
334
- 'Description' : theme_desc
335
- };
336
- for (field in fields) {
337
- var re = new RegExp('(?:^|[\\r\\n]\\s*)\\b' + field + '\\s*:\\s*([^\\r\\n]+)', 'gmi');
338
- var match = re.exec(data);
339
- var val = fields[field];
340
- if (match) {
341
- if (val != null) {
342
- val.html(match[1].escape().linkify('_blank'));
343
- } else if (field == 'Author URI') {
344
- theme_author.html('<a href="' + match[1] + '" target="_blank">' + theme_author.text() + '</a>');
345
- }
346
- } else if (val != null) {
347
- val.text('N/A');
348
- }
349
- }
 
 
 
350
  if (callback) {
351
  callback();
352
  }
353
  },
354
- cache : false
355
  });
 
 
356
  };
357
 
358
- base.show_theme_editor = function (button, editing) {
359
- button.html(button.attr('loading'));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
360
 
361
- adminSettings.editing = editing;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
362
 
 
 
 
 
 
 
 
 
363
  // Load theme editor
364
- $.get(editor_url + '?curr_theme='
365
- + adminSettings.curr_theme + '&editing='
366
- + editing, function (data) {
 
 
367
  theme_editor_wrap.html(data);
368
  // Load preview into editor
369
- CrayonSyntaxThemeEditor.init(function () {
 
 
 
370
  base.show_theme_editor_now(button);
371
- }, preview.clone());
372
  });
373
  return false;
374
  };
375
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
376
  };
377
 
378
  })(jQueryCrayon);
6
  var base = this;
7
 
8
  // Preview
9
+ var preview, previewWrapper, preview_info, preview_cbox, preview_delay_timer, preview_get, preview_loaded;
10
  // The DOM object ids that trigger a preview update
11
  var preview_obj_names = [];
12
  // The jQuery objects for these objects
13
  var preview_objs = [];
14
  var preview_last_values = [];
15
  // Alignment
16
+ var align_drop, float;
17
  // Toolbar
18
+ var overlay, toolbar;
19
  // Error
20
+ var msg_cbox, msg;
21
  // Log
22
+ var log_button, log_text;
23
 
24
+ var main_wrap, theme_editor_wrap, theme_editor_loading, theme_editor_edit_button, theme_editor_create_button, theme_editor_duplicate_button, theme_editor_delete_button, theme_editor_submit_button;
25
+ var theme_select, theme_info, theme_ver, theme_author, theme_desc;
26
 
27
  var settings = null;
28
  var adminSettings = null;
29
  var util = null;
30
 
31
  base.init = function () {
32
+ CrayonUtil.log('admin init');
33
  settings = CrayonSyntaxSettings;
34
  adminSettings = CrayonAdminSettings;
35
  util = CrayonUtil;
37
  // Wraps
38
  main_wrap = $('#crayon-main-wrap');
39
  theme_editor_wrap = $('#crayon-theme-editor-wrap');
 
 
 
 
 
 
 
 
 
 
 
40
 
41
  // Themes
42
  theme_select = $('#crayon-theme');
50
  base.preview_update();
51
  });
52
 
53
+ theme_editor_edit_button = $('#crayon-theme-editor-edit-button');
54
+ theme_editor_create_button = $('#crayon-theme-editor-create-button');
55
+ theme_editor_duplicate_button = $('#crayon-theme-editor-duplicate-button');
56
+ theme_editor_delete_button = $('#crayon-theme-editor-delete-button');
57
+ theme_editor_submit_button = $('#crayon-theme-editor-submit-button');
58
+ theme_editor_edit_button.click(function () {
59
+ base.show_theme_editor(theme_editor_edit_button,
60
+ true);
61
+ });
62
+ theme_editor_create_button.click(function () {
63
+ base.show_theme_editor(theme_editor_create_button,
64
+ false);
65
+ });
66
+ theme_editor_duplicate_button.click(function () {
67
+ CrayonSyntaxThemeEditor.duplicate(adminSettings.currTheme, adminSettings.currThemeName);
68
+ });
69
+ theme_editor_delete_button.click(function () {
70
+ if (!theme_editor_edit_button.attr('disabled')) {
71
+ CrayonSyntaxThemeEditor.del(adminSettings.currTheme, adminSettings.currThemeName);
72
+ }
73
+ return false;
74
+ });
75
+ theme_editor_submit_button.click(function () {
76
+ CrayonSyntaxThemeEditor.submit(adminSettings.currTheme, adminSettings.currThemeName);
77
+ });
78
+
79
  // Help
80
  help = $('.crayon-help-close');
81
  help.click(function () {
82
  $('.crayon-help').hide();
83
+ CrayonUtil.getAJAX({
84
+ action: 'crayon-ajax',
85
+ 'hide-help': 1
86
+ });
87
  });
88
 
89
  // Preview
90
  preview = $('#crayon-live-preview');
91
+ previewWrapper = $('#crayon-live-preview-wrapper');
92
  preview_info = $('#crayon-preview-info');
93
  preview_cbox = util.cssElem('#preview');
94
  if (preview.length != 0) {
103
  }
104
 
105
  $('#show-posts').click(function () {
106
+ CrayonUtil.getAJAX({
107
+ action: 'crayon-show-posts'
108
+ }, function (data) {
109
  $('#crayon-subsection-posts-info').html(data);
110
  });
111
  });
112
 
113
  $('#show-langs').click(function () {
114
+ CrayonUtil.getAJAX({
115
+ action: 'crayon-show-langs'
116
+ }, function (data) {
117
  $('#lang-info').hide();
118
  $('#crayon-subsection-langs-info').html(data);
119
  });
120
  });
121
 
122
  // Convert
123
+ $('#crayon-settings-form input').live(
124
+ 'focusin focusout mouseup',
125
+ function () {
126
+ $('#crayon-settings-form')
127
+ .data('lastSelected', $(this));
128
+ });
129
+ $('#crayon-settings-form')
130
+ .submit(
131
+ function () {
132
+ var last = $(this).data('lastSelected').get(0);
133
+ var target = $('#convert').get(0);
134
+ if (last == target) {
135
+ var r = confirm("Please BACKUP your database first! Converting will update your post content. Do you wish to continue?");
136
+ return r;
137
+ }
138
+ });
139
 
140
  // Alignment
141
  align_drop = util.cssElem('#h-align');
192
  : show_log);
193
  log_button.val(text);
194
  });
 
195
  };
196
 
197
  /* Whenever a control changes preview */
199
  var val = 0;
200
  var obj;
201
  var getVars = {
202
+ action: 'crayon-show-preview',
203
+ theme: adminSettings.currTheme
204
  };
205
  for (var i = 0; i < preview_obj_names.length; i++) {
206
  obj = preview_objs[i];
209
  } else {
210
  val = obj.val();
211
  }
212
+ getVars[preview_obj_names[i]] = CrayonUtil.escape(val);
213
  }
214
 
215
  // Load Preview
216
+ CrayonUtil.postAJAX(getVars, function (data) {
217
  preview.html(data);
218
  // Important! Calls the crayon.js init
219
  CrayonSyntax.init();
220
+ base.preview_ready();
221
  });
222
  };
223
 
224
+ base.preview_ready = function () {
225
+ if (!preview_loaded) {
226
+ preview_loaded = true;
227
+ if (window.GET['theme-editor']) {
228
+ CrayonSyntaxAdmin.show_theme_editor(
229
+ theme_editor_edit_button, true);
230
+ }
231
+ }
232
+ };
233
+
234
  var preview_toggle = function () {
235
+ // CrayonUtil.log('preview_toggle');
236
  if (preview_cbox.is(':checked')) {
237
  preview.show();
238
  preview_info.show();
268
  // Checks if the text input is changed, if so, runs the callback
269
  // with given event
270
  preview_txt_change = function (callback, event) {
271
+ // CrayonUtil.log('checking if changed');
272
  var obj = event.target;
273
  var last = preview_last_values[obj.id];
274
+ // CrayonUtil.log('last' + preview_last_values[obj.id]);
275
 
276
  if (obj.value != last) {
277
+ // CrayonUtil.log('changed');
278
  // Update last value to current
279
  preview_last_values[obj.id] = obj.value;
280
  // Run callback with event
284
 
285
  // Only updates when text is changed
286
  preview_txt_callback = function (event) {
287
+ // CrayonUtil.log('txt callback');
288
  preview_txt_change(base.preview_update, event);
289
  };
290
 
293
  preview_txt_change(function () {
294
  clearInterval(preview_delay_timer);
295
  preview_delay_timer = setInterval(function () {
296
+ // CrayonUtil.log('delayed update');
297
  base.preview_update();
298
  clearInterval(preview_delay_timer);
299
  }, 500);
351
  return false;
352
  };
353
 
 
 
 
 
 
 
354
 
355
+
356
+ base.refresh_theme_info = function (callback) {
357
+ adminSettings.currTheme = theme_select.val();
358
+ adminSettings.currThemeName = theme_select.find('option:selected').attr('data-value');
359
+ adminSettings.currThemeIsUser = adminSettings.currTheme in adminSettings.userThemes;
360
+ var url = adminSettings.currThemeIsUser ? adminSettings.userThemesURL : adminSettings.themesURL;
361
+ adminSettings.currThemeURL = base.get_theme_url(adminSettings.currTheme);
362
+ // Load the theme file
363
+
364
  $.ajax({
365
+ url: adminSettings.currThemeURL,
366
+ success: function (data) {
367
+ adminSettings.currThemeCSS = data;
368
+ // var fields = {
369
+ // 'Version': theme_ver,
370
+ // 'Author': theme_author,
371
+ // 'URL': null,
372
+ // 'Description': theme_desc
373
+ // };
374
+ // for (field in fields) {
375
+ // var re = new RegExp('(?:^|[\\r\\n]\\s*)\\b' + field
376
+ // + '\\s*:\\s*([^\\r\\n]+)', 'gmi');
377
+ // var match = re.exec(data);
378
+ // var val = fields[field];
379
+ // if (match) {
380
+ // if (val != null) {
381
+ // val.html(match[1].escape().linkify('_blank'));
382
+ // } else if (field == 'Author URI') {
383
+ // theme_author.html('<a href="' + match[1]
384
+ // + '" target="_blank">'
385
+ // + theme_author.text() + '</a>');
386
+ // }
387
+ // } else if (val != null) {
388
+ // val.text('N/A');
389
+ // }
390
+ // }
391
  if (callback) {
392
  callback();
393
  }
394
  },
395
+ cache: false
396
  });
397
+
398
+ adminSettings.currThemeCSS = '';
399
  };
400
 
401
+ base.get_theme_url = function ($id) {
402
+ var url = $id in adminSettings.userThemes ? adminSettings.userThemesURL : adminSettings.themesURL;
403
+ return url + $id + '/' + $id + '.css';
404
+ };
405
+
406
+ base.show_theme_info = function (callback) {
407
+ base.refresh_theme_info(function () {
408
+ var info = CrayonSyntaxThemeEditor.readCSSInfo(adminSettings.currThemeCSS);
409
+ var infoHTML = '';
410
+ for (id in info) {
411
+ if (id != 'name') {
412
+ infoHTML += '<div class="fieldset">';
413
+ if (id != 'description') {
414
+ infoHTML += '<div class="' + id + ' field">' + CrayonSyntaxThemeEditor.getFieldName(id) + ':</div>';
415
+ }
416
+ infoHTML += '<div class="' + id + ' value">' + info[id].linkify('_blank') + '</div></div>';
417
+ }
418
+ }
419
+ var type, typeName;
420
+ if (adminSettings.currThemeIsUser) {
421
+ type = 'user';
422
+ typeName = CrayonThemeEditorStrings.userTheme;
423
+ } else {
424
+ type = 'stock';
425
+ typeName = CrayonThemeEditorStrings.stockTheme;
426
+ }
427
+ infoHTML = '<div class="type ' + type + '">' + typeName + '</div><div class="content">' + infoHTML + '</div>';
428
+ theme_info.html(infoHTML);
429
+ // Disable for stock themes
430
+ var disabled = !adminSettings.currThemeIsUser && !settings.debug;
431
+ theme_editor_edit_button.attr('disabled', disabled);
432
+ theme_editor_delete_button.attr('disabled', disabled);
433
+ theme_editor_submit_button.attr('disabled', disabled);
434
+ if (callback) {
435
+ callback();
436
+ }
437
+ });
438
 
439
+ // CrayonSyntaxThemeEditor.
440
+ //
441
+ // $.ajax({
442
+ // url: adminSettings.currThemeURL,
443
+ // success: function (data) {
444
+ // adminSettings.curr_theme_str = data;
445
+ // var fields = {
446
+ // 'Version': theme_ver,
447
+ // 'Author': theme_author,
448
+ // 'URL': null,
449
+ // 'Description': theme_desc
450
+ // };
451
+ // for (field in fields) {
452
+ // var re = new RegExp('(?:^|[\\r\\n]\\s*)\\b' + field
453
+ // + '\\s*:\\s*([^\\r\\n]+)', 'gmi');
454
+ // var match = re.exec(data);
455
+ // var val = fields[field];
456
+ // if (match) {
457
+ // if (val != null) {
458
+ // val.html(match[1].escape().linkify('_blank'));
459
+ // } else if (field == 'Author URI') {
460
+ // theme_author.html('<a href="' + match[1]
461
+ // + '" target="_blank">'
462
+ // + theme_author.text() + '</a>');
463
+ // }
464
+ // } else if (val != null) {
465
+ // val.text('N/A');
466
+ // }
467
+ // }
468
+ // if (callback) {
469
+ // callback();
470
+ // }
471
+ // },
472
+ // cache: false
473
+ // });
474
+ };
475
 
476
+ base.show_theme_editor = function (button, editing) {
477
+ if (theme_editor_edit_button.attr('disabled')) {
478
+ return false;
479
+ }
480
+ base.refresh_theme_info();
481
+ button.html(button.attr('loading'));
482
+ adminSettings.editing_theme = editing;
483
+ theme_editor_loading = true;
484
  // Load theme editor
485
+ CrayonUtil.getAJAX({
486
+ action: 'crayon-theme-editor',
487
+ currTheme: adminSettings.currTheme,
488
+ editing: editing
489
+ }, function (data) {
490
  theme_editor_wrap.html(data);
491
  // Load preview into editor
492
+ if (theme_editor_loading) {
493
+ CrayonSyntaxThemeEditor.init();
494
+ }
495
+ CrayonSyntaxThemeEditor.show(function () {
496
  base.show_theme_editor_now(button);
497
+ }, preview);
498
  });
499
  return false;
500
  };
501
 
502
+ base.resetPreview = function() {
503
+ previewWrapper.append(preview);
504
+ CrayonSyntaxThemeEditor.removeStyle();
505
+ };
506
+
507
+ base.show_theme_editor_now = function (button) {
508
+ main_wrap.hide();
509
+ theme_editor_wrap.show();
510
+ theme_editor_loading = false;
511
+ button.html(button.attr('loaded'));
512
+ };
513
+
514
+ // base.delete_theme = function () {
515
+ // adminSettings.curr_theme
516
+ // };
517
+
518
+ // base.duplicate_theme = function () {
519
+ //
520
+ // };
521
+
522
  };
523
 
524
  })(jQueryCrayon);
js/cssjson.js CHANGED
@@ -1,81 +1,113 @@
1
- /*
 
 
 
2
 
3
- CSS-JSON Converter for JavaScript, v.1.0
4
- By Aram Kocharyan, http://ak.net84.net/
5
 
6
- Converts CSS to JSON and back.
7
 
8
- */
 
 
 
 
9
 
10
- // String functions
11
- var StringExtensions = new function() {
12
- // Added natively now
13
- this.trim = function() {
14
- return this.replace(/^\s+|\s+$/g, '');
15
  };
16
- String.prototype.trim = this.trim;
17
-
18
- this.repeat = function(n) {
19
- return new Array(1 + n).join(this);
20
- }
21
- String.prototype.repeat = this.repeat;
22
- }
23
 
24
- var CSSJSON = new function() {
25
-
26
- // These aren't used, just shown for convenience
27
  var selX = /([^\s\;\{\}][^\;\{\}]*)\{/g;
28
  var endX = /\}/g;
29
  var lineX = /([^\;\{\}]*)\;/g;
30
- var commentX = /\/\*.*?\*\//g;
31
  var lineAttrX = /([^\:]+):([^\;]*);/;
32
-
33
- // This is used, a concatenation of all above. We use alternation to capture.
34
- var altX = /(\/\*[\s\S]*?\*\/)|([^\s\;\{\}][^\;\{\}]*(?=\{))|(\})|([^\;\{\}]+\;)/gmi;
35
-
 
36
  // Capture groups
37
  var capComment = 1;
38
- var capSel = 2
39
  var capEnd = 3;
40
  var capAttr = 4;
41
-
42
- // The main JSON converter function. Set keepOrder to true to keep order of comments etc.
43
- this.toJSON = function(css, keepOrder) {
44
- return getCSSRuleNode(css, keepOrder);
45
- }
46
-
47
- var isEmpty = function(x) {
48
- return typeof x == 'undefined' || x.length == 0 || x == null;
49
- }
50
-
51
- // Input is css string and current pos, returns JSON object
52
- var getCSSRuleNode = function(cssString, keepOrder) {
53
- var node = {};
 
 
 
 
 
 
 
 
 
 
54
  var match = null;
55
  var count = 0;
56
-
57
- while ( (match = altX.exec(cssString)) != null ) {
58
- console.log(match);
59
- if (!isEmpty(match[capComment])) {
 
 
 
 
 
 
 
 
 
 
 
 
60
  // Comment
61
  var add = match[capComment].trim();
62
  node[count++] = add;
63
- } else if (!isEmpty(match[capSel])) {
64
- //} else if (typeof match[capSel] != 'undefined') {
65
  // New node, we recurse
66
- var name = match[capSel].trim();
67
- var newNode = getCSSRuleNode(cssString, keepOrder);
68
- if (keepOrder) {
 
69
  var obj = {};
70
  obj['name'] = name;
71
  obj['value'] = newNode;
72
- // Since we must use key as index to keep order and not name,
73
- // this will differentiate between a Rule Node and an Attribute,
74
- // since both contain a name and value pair.
75
  obj['type'] = 'rule';
76
  node[count++] = obj;
77
  } else {
78
- node[name] = newNode;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
79
  }
80
  } else if (!isEmpty(match[capEnd])) {
81
  // Node has finished
@@ -87,77 +119,72 @@ var CSSJSON = new function() {
87
  // Attribute
88
  var name = attr[1].trim();
89
  var value = attr[2].trim();
90
- if (keepOrder) {
91
  var obj = {};
92
  obj['name'] = name;
93
  obj['value'] = value;
94
  obj['type'] = 'attr';
95
  node[count++] = obj;
96
  } else {
97
- node[name] = value;
98
  }
99
  } else {
100
  // Semicolon terminated line
101
  node[count++] = line;
102
  }
103
- }
104
  }
105
-
106
  return node;
107
- }
108
-
109
- // The main CSS converter function.
110
- this.toCSS = function(json) {
111
- return strCSSRuleNode(json);
112
- }
113
-
114
- // Print a JSON node as CSS
115
- var strCSSRuleNode = function(node, level) {
 
 
 
116
  var cssString = '';
117
- if (typeof level == 'undefined') {
118
- level = 0;
119
  }
120
- for (i in node) {
121
- var subNode = node[i];
122
- if (typeof i == 'number' || parseInt(i) == i) {
123
- // Ordered
124
- if (typeof subNode == 'object') {
125
- if (subNode.type == 'rule') {
126
- // Selector
127
- cssString += strNode(subNode.name, subNode.value, level);
128
- } else {
129
- // Attribute
130
- cssString += strAttr(subNode.name, subNode.value, level);
131
- }
 
132
  } else {
133
- // Line/Comment
134
- cssString += '\t'.repeat(level) + subNode + '\n';
135
- }
136
- } else if (typeof i == 'string') {
137
- // Unordered
138
- if (typeof subNode == 'object') {
139
- // Selector
140
- cssString += strNode(i, subNode, level);
141
- } else {
142
- // Attribute
143
- cssString += strAttr(i, subNode, level);
144
  }
 
145
  }
146
  }
147
  return cssString;
148
- }
149
-
150
  // Helpers
151
-
152
- var strAttr = function(name, value, level) {
153
- return '\t'.repeat(level) + name + ': ' + value + ';\n';
154
- }
155
-
156
- var strNode = function(name, value, level) {
157
- var cssString = '\t'.repeat(level) + name + ' {\n';
158
- cssString += strCSSRuleNode(value, level+1);
159
- cssString += '\t'.repeat(level) + '}\n\n';
160
  return cssString;
161
- }
162
 
163
- }
1
+ /**
2
+ * CSS-JSON Converter for JavaScript, v.2.0 By Aram Kocharyan,
3
+ * http://ak.net84.net/ Converts CSS to JSON and back.
4
+ */
5
 
6
+ var CSSJSON = new function() {
 
7
 
8
+ var base = this;
9
 
10
+ base.init = function() {
11
+ // String functions
12
+ String.prototype.trim = function() {
13
+ return this.replace(/^\s+|\s+$/g, '');
14
+ };
15
 
16
+ String.prototype.repeat = function(n) {
17
+ return new Array(1 + n).join(this);
18
+ };
 
 
19
  };
20
+ base.init();
 
 
 
 
 
 
21
 
 
 
 
22
  var selX = /([^\s\;\{\}][^\;\{\}]*)\{/g;
23
  var endX = /\}/g;
24
  var lineX = /([^\;\{\}]*)\;/g;
25
+ var commentX = /\/\*[\s\S]*?\*\//g;
26
  var lineAttrX = /([^\:]+):([^\;]*);/;
27
+
28
+ // This is used, a concatenation of all above. We use alternation to
29
+ // capture.
30
+ var altX = /(\/\*[\s\S]*?\*\/)|([^\s\;\{\}][^\;\{\}]*(?=\{))|(\})|([^\;\{\}]+\;(?!\s*\*\/))/gmi;
31
+
32
  // Capture groups
33
  var capComment = 1;
34
+ var capSelector = 2;
35
  var capEnd = 3;
36
  var capAttr = 4;
37
+
38
+ var isEmpty = function(x) {
39
+ return typeof x == 'undefined' || x.length == 0 || x == null;
40
+ };
41
+
42
+ /**
43
+ * Input is css string and current pos, returns JSON object
44
+ *
45
+ * @param cssString
46
+ * The CSS string.
47
+ * @param args
48
+ * An optional argument object. ordered: Whether order of
49
+ * comments and other nodes should be kept in the output. This
50
+ * will return an object where all the keys are numbers and the
51
+ * values are objects containing "name" and "value" keys for each
52
+ * node. comments: Whether to capture comments. split: Whether to
53
+ * split each comma separated list of selectors.
54
+ */
55
+ base.toJSON = function(cssString, args) {
56
+ var node = {
57
+ children: {},
58
+ attributes: {}
59
+ };
60
  var match = null;
61
  var count = 0;
62
+
63
+ if (typeof args == 'undefined') {
64
+ var args = {
65
+ ordered : false,
66
+ comments : false,
67
+ stripComments : false,
68
+ split : false
69
+ };
70
+ }
71
+ if (args.stripComments) {
72
+ args.comments = false;
73
+ cssString = cssString.replace(commentX, '');
74
+ }
75
+
76
+ while ((match = altX.exec(cssString)) != null) {
77
+ if (!isEmpty(match[capComment]) && args.comments) {
78
  // Comment
79
  var add = match[capComment].trim();
80
  node[count++] = add;
81
+ } else if (!isEmpty(match[capSelector])) {
 
82
  // New node, we recurse
83
+ var name = match[capSelector].trim();
84
+ // This will return when we encounter a closing brace
85
+ var newNode = base.toJSON(cssString, args);
86
+ if (args.ordered) {
87
  var obj = {};
88
  obj['name'] = name;
89
  obj['value'] = newNode;
90
+ // Since we must use key as index to keep order and not
91
+ // name, this will differentiate between a Rule Node and an
92
+ // Attribute, since both contain a name and value pair.
93
  obj['type'] = 'rule';
94
  node[count++] = obj;
95
  } else {
96
+ if (args.split) {
97
+ var bits = name.split(',');
98
+ } else {
99
+ var bits = [name];
100
+ }
101
+ for (i in bits) {
102
+ var sel = bits[i].trim();
103
+ if (sel in node.children) {
104
+ for (var att in newNode.attributes) {
105
+ node.children[sel].attributes[att] = newNode.attributes[att];
106
+ }
107
+ } else {
108
+ node.children[sel] = newNode;
109
+ }
110
+ }
111
  }
112
  } else if (!isEmpty(match[capEnd])) {
113
  // Node has finished
119
  // Attribute
120
  var name = attr[1].trim();
121
  var value = attr[2].trim();
122
+ if (args.ordered) {
123
  var obj = {};
124
  obj['name'] = name;
125
  obj['value'] = value;
126
  obj['type'] = 'attr';
127
  node[count++] = obj;
128
  } else {
129
+ node.attributes[name] = value;
130
  }
131
  } else {
132
  // Semicolon terminated line
133
  node[count++] = line;
134
  }
135
+ }
136
  }
137
+
138
  return node;
139
+ };
140
+
141
+ /**
142
+ * @param node
143
+ * A JSON node.
144
+ * @param depth
145
+ * The depth of the current node; used for indentation and
146
+ * optional.
147
+ * @param breaks
148
+ * Whether to add line breaks in the output.
149
+ */
150
+ base.toCSS = function(node, depth, breaks) {
151
  var cssString = '';
152
+ if (typeof depth == 'undefined') {
153
+ depth = 0;
154
  }
155
+ if (typeof breaks == 'undefined') {
156
+ breaks = false;
157
+ }
158
+ if (node.attributes) {
159
+ for (i in node.attributes) {
160
+ cssString += strAttr(i, node.attributes[i], depth);
161
+ }
162
+ }
163
+ if (node.children) {
164
+ var first = true;
165
+ for (i in node.children) {
166
+ if (breaks && !first) {
167
+ cssString += '\n';
168
  } else {
169
+ first = false;
 
 
 
 
 
 
 
 
 
 
170
  }
171
+ cssString += strNode(i, node.children[i], depth);
172
  }
173
  }
174
  return cssString;
175
+ };
176
+
177
  // Helpers
178
+
179
+ var strAttr = function(name, value, depth) {
180
+ return '\t'.repeat(depth) + name + ': ' + value + ';\n';
181
+ };
182
+
183
+ var strNode = function(name, value, depth) {
184
+ var cssString = '\t'.repeat(depth) + name + ' {\n';
185
+ cssString += base.toCSS(value, depth + 1);
186
+ cssString += '\t'.repeat(depth) + '}\n';
187
  return cssString;
188
+ };
189
 
190
+ };
js/jquery-colorpicker/README ADDED
@@ -0,0 +1,231 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ jQuery.colorpicker v0.9.3
2
+
3
+ Copyright (c) 2011-2012 Martijn W. van der Lee
4
+ Licensed under the MIT.
5
+
6
+ Full-featured colorpicker for jQueryUI with full theming support.
7
+ Most images from jPicker by Christopher T. Tillman.
8
+ Sourcecode created from scratch by Martijn W. van der Lee.
9
+
10
+ IE support; make sure you have a doctype defined, or the colorpicker will not
11
+ display correctly.
12
+
13
+ Options:
14
+ alpha: false
15
+ Whether or not to show the inputs for alpha.
16
+
17
+ altAlpha: true
18
+ Change the opacity of the altField element(s) according to the alpha
19
+ setting.
20
+
21
+ altField: ''
22
+ Change the background color of the elements specified in this element.
23
+
24
+ altOnChange: true
25
+ If true, the altField element(s) are updated on every change, otherwise
26
+ only upon closing.
27
+
28
+ altProperties: 'background-color'
29
+ Comma-separated list of CSS properties to set color of in the altField.
30
+ The following properties are allowed, all others are ignored.
31
+ background-color
32
+ color
33
+ border-color
34
+ outline-color
35
+
36
+ autoOpen: false
37
+ If true, the dialog opens automatically upon page load.
38
+
39
+ buttonColorize: false
40
+ If a buttonimage is specified, change the background color of the
41
+ image when the color is changed.
42
+
43
+ buttonImage: 'images/ui-colorpicker.png'
44
+ Same as jQueryUI DatePicker.
45
+
46
+ buttonImageOnly: false
47
+ Same as jQueryUI DatePicker.
48
+
49
+ buttonText: null
50
+ Same as jQueryUI DatePicker. If null, use language default.
51
+
52
+ closeOnEscape: true
53
+ Close the window when pressing the Escape key on the keyboard.
54
+
55
+ closeOnOutside: true
56
+ Close the window when clicking outside the colorpicker display.
57
+
58
+ color: '#00FF00'
59
+ Initial color. Formats recognized are:
60
+ #rrggbb
61
+ rrggbb (same as previous, but without the #)
62
+ rgb(rrr,ggg,bbb)
63
+ rgba(rrr,ggg,bbb,a.a)
64
+ rgb(rrr%,ggg%,bbb%)
65
+ rgba(rrr%,ggg%,bbb%,aaa%)
66
+ w3c-defined color name
67
+
68
+ colorFormat: 'HEX'
69
+ Specifies the format of the color string returned in callbacks.
70
+ You can either specify one of the predefined formats:
71
+ #HEX #112233
72
+ #HEX3 #123 if possible, otherwise false.
73
+ HEX 112233
74
+ HEX3 123 if possible, otherwise false.
75
+ RGB rgb(123,45,67) if opaque, otherwise false.
76
+ RGBA rgba(123,45,67,0.123%)
77
+ RGB% rgb(12%,34%,56%) if opaque, otherwise false.
78
+ RGBA% rgba(12%,34%,56%,0.123%)
79
+ HSL hsl(123,45,67) if opaque, otherwise false.
80
+ HSLA hsla(123,45,67,0.123%)
81
+ HSL% hsl(12%,34%,56%) if opaque, otherwise false.
82
+ HSLA% hsla(12%,34%,56%,0.123%)
83
+ NAME Closest color name
84
+ EXACT Exact name if possible, otherwise false.
85
+ or specify your own format...
86
+ Each color channel is specified as a pair of two characters.
87
+ The first character determines the color channel:
88
+ a Alpha
89
+ r, g, b RGB color space; red, green and blue
90
+ h, s, v HSV color space; hue, saturation and value
91
+ c, m, y, k CMYK color space; cyan, magenta, yellow and black
92
+ L, A, B LAB color space; Luminosity, *A and *B.
93
+ The second character specifies the data type:
94
+ x Two-digit hexadecimal notation.
95
+ d Decimal (0-255) notation.
96
+ f Floating point (0-1) notation, not rounded.
97
+ p Percentage (0-100) notation, not rounded.
98
+ If you prefix a valid pair with a backslash, it won't be replaced.
99
+ All patterns are case sensitive.
100
+ For example, to create the common hex color format, use "#rxgxbx".
101
+ For an rgba() format, use "rgba(rd,gd,bd,af)"
102
+
103
+ You can also specify an array of formats where the first non-FALSE one
104
+ is returned. Note that the only formats able to return FALSE are the
105
+ predefined formats HEX3 and EXACT. For example, this array will output
106
+ HEX3 format if possible or HEX format otherwise:
107
+ ['HEX3', 'HEX']
108
+
109
+ dragggable: true
110
+ Make the dialog draggable if the header is visible and the dialog is
111
+ not inline.
112
+
113
+ duration: 'fast'
114
+ Same as jQueryUI DatePicker.
115
+
116
+ hsv: true
117
+ Whether or not to show the inputs for HSV.
118
+
119
+ layout: { ... }
120
+ Set the position of elements in a table layout.
121
+ You could create any layout possible with HTML tables by specifying
122
+ cell position and size of each part.
123
+ @todo document how this works.
124
+
125
+ limit: ''
126
+ Limit the selectable colors to any of the predefined limits:
127
+ '' No limitations, allow 8bpp color for a palette of
128
+ all 16 million colors.
129
+ 'websafe' Set of 216 colors composed of 00, 33, 66, 99, cc
130
+ and ff color channel values in #rrggbb.
131
+ 'nibble' 4 bits per color, can be easily converted to #rgb
132
+ format.
133
+ The palette is limited to 4096 colors.
134
+ 'binary' Allow only #00 or #ff as color channel values for
135
+ primary colors only; only 8 colors are available
136
+ with this limit.
137
+ 'name' Limit to closest color name.
138
+
139
+ modal:
140
+ Ensures no other controls on screen can be used while the dialog is
141
+ opened.
142
+ Also look at showCancelButton and closeOnEscape to use in combination
143
+ with the modal option. closeOnOutside is redundant when used with modal.
144
+
145
+ mode: 'h'
146
+ Determines the functionality of the map and bar components. Allowed
147
+ values are; 'h', 's', 'l', 'r', 'g', 'b' or 'a', for hue, saturation,
148
+ luminosity, red, green, blue and alpha respectively.
149
+
150
+ parts: ''
151
+ Determine which parts to display.
152
+ Use any of the preset names ('full', 'popup' or 'inline') or specify
153
+ an array of part names (i.e. ['header', 'map', 'bar', 'hex', 'hsv',
154
+ 'rgb', 'alpha', 'lab', 'cmyk', 'preview', 'swatches', 'footer']).
155
+ If an empty string is given, the parts will be automatically chosen as
156
+ preset 'popup' or 'inline' depending on the context in which the
157
+ colorpicker is used.
158
+
159
+ rgb: true, // Show RGB controls and modes
160
+ Whether or not to show the inputs for RGB.
161
+
162
+ regional: '',
163
+ Sets the language to use. Note that you must load the appropriate
164
+ language file from the i18n directory. '' is included by default.
165
+
166
+ showAnim: 'fadeIn'
167
+ Same as jQueryUI DatePicker.
168
+
169
+ showCancelButton: true
170
+ Show the Cancel button if buttonpane is visible.
171
+
172
+ showCloseButton: true
173
+ Show the Close button if the header is visible.
174
+ If the dialog is inline, the close button is never shown.
175
+
176
+ showNoneButton: false
177
+ Show the None/Revert button if buttonpane is visible.
178
+
179
+ showOn: 'focus'
180
+ Same as jQueryUI DatePicker.
181
+
182
+ showOptions: {}
183
+ Same as jQueryUI DatePicker.
184
+
185
+ swatches: null
186
+ 'null' to show swatches of HTML colors or provide your own object
187
+ with colornames and {r:1, g:1, b:1} array.
188
+ For example { 'red': {r:1, g:0, b:0}, 'blue': {r:0, g:0, b:1} }
189
+
190
+ title: null
191
+ Title to display in the header. If null, use language default.
192
+
193
+ Events:
194
+ init: null
195
+ Triggered on initially setting the color. Called only once.
196
+ Callbacks recieve same data as select event.
197
+
198
+ close: null
199
+ Triggered when the popup is closed.
200
+ Callbacks recieve same data as select event and an additional number
201
+ of fields containing the current color in all supported color spaces.
202
+ These are rgb{}, hsv{}, cmyk{}, lab{}, hsl{} and a.
203
+ Most values are floating point numbers in range [0,1] for accuracy.
204
+ The a and b values in the lab color space have range [-1,1].
205
+
206
+ select: null
207
+ Triggered on each change, confirmation (click on OK button) and
208
+ cancellation (click on Cancel, outside window or window close button)
209
+ respectively.
210
+
211
+ The event recieves a jQuery event object and a data object containing
212
+ the elements 'formatted' (with the color formatted according to
213
+ formatColor).
214
+
215
+ Note that select may be triggered in rapid succession when dragging
216
+ the mouse accross the map or bar and may be triggered without a change
217
+ in color upon specific user interactions.
218
+
219
+ Methods:
220
+ open
221
+ Open the dialog
222
+
223
+ close
224
+ Close the dialog
225
+
226
+ destroy
227
+ Destroy the widget
228
+
229
+ setColor
230
+ Set the current color to the specified color. Accepts any
231
+ CSS-confirmant color specification.
js/jquery-colorpicker/TODO ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Fix the weird one-pixel vertical shift bug.
2
+ Caused by ui-widget class.
3
+ Only happens in Chrome and only on some, not all.
4
+ Disappears and re-appears at different zoom levels.
5
+ In hex input, accept (and strip) '#' symbol on copy/past.
6
+ Completely destroy object when closed.
7
+ Enabled/disabled
8
+ isRTL? What to RTL, besides button?
9
+ Disable selection in MSIE: this.dialog.on('selectstart', function(event) { return false; })
10
+ Special rendering mode for color_none? Use [X] images?
11
+ Fix parsing from input with websafe colors
12
+ Recognize "transparent" color name.
13
+ Limit number of events triggered.
14
+ Small size variant (128x128)
15
+ isRTL? What to RTL, besides button?
16
+ Undo/redo memory?
17
+ ARIA support.
18
+ Allow only set (dec/hex) characters in inputs
19
+ Most-recently-used swatches
20
+ HSL/HSV distance calculations should take into account cyclic hue.
js/jquery-colorpicker/i18n/jquery.ui.colorpicker-en.js ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ jQuery(function($) {
2
+ $.colorpicker.regional['en'] = {
3
+ ok: 'OK',
4
+ cancel: 'Cancel',
5
+ none: 'None',
6
+ button: 'Color',
7
+ title: 'Pick a color',
8
+ transparent: 'Transparent',
9
+ hsvH: 'H',
10
+ hsvS: 'S',
11
+ hsvV: 'V',
12
+ rgbR: 'R',
13
+ rgbG: 'G',
14
+ rgbB: 'B',
15
+ labL: 'L',
16
+ labA: 'a',
17
+ labB: 'b',
18
+ hslH: 'H',
19
+ hslS: 'S',
20
+ hslL: 'L',
21
+ cmykC: 'C',
22
+ cmykM: 'M',
23
+ cmykY: 'Y',
24
+ cmykK: 'K',
25
+ alphaA: 'A'
26
+ };
27
+ });
js/jquery-colorpicker/i18n/jquery.ui.colorpicker-fr.js ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ jQuery(function($) {
2
+ $.colorpicker.regional['fr'] = {
3
+ ok: 'OK',
4
+ cancel: 'Annuler',
5
+ none: 'Aucune couleur',
6
+ button: 'Couleur',
7
+ title: 'Choisir une couleur',
8
+ transparent: 'Transparent',
9
+ hsvH: 'T',
10
+ hsvS: 'S',
11
+ hsvV: 'V',
12
+ rgbR: 'R',
13
+ rgbG: 'V',
14
+ rgbB: 'B',
15
+ labL: 'L',
16
+ labA: 'a',
17
+ labB: 'b',
18
+ hslH: 'T',
19
+ hslS: 'S',
20
+ hslL: 'L',
21
+ cmykC: 'C',
22
+ cmykM: 'M',
23
+ cmykY: 'J',
24
+ cmykK: 'N',
25
+ alphaA: 'A'
26
+ };
27
+ });
js/jquery-colorpicker/i18n/jquery.ui.colorpicker-nl.js ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ jQuery(function($) {
2
+ $.colorpicker.regional['nl'] = {
3
+ ok: 'OK',
4
+ cancel: 'Annuleren',
5
+ none: 'Geen',
6
+ button: 'Kleur',
7
+ title: 'Kies een kleur',
8
+ transparent: 'Transparant',
9
+ hsvH: 'H',
10
+ hsvS: 'S',
11
+ hsvV: 'V',
12
+ rgbR: 'R',
13
+ rgbG: 'G',
14
+ rgbB: 'B',
15
+ labL: 'L',
16
+ labA: 'a',
17
+ labB: 'b',
18
+ hslH: 'H',
19
+ hslS: 'S',
20
+ hslL: 'L',
21
+ cmykC: 'C',
22
+ cmykM: 'M',
23
+ cmykY: 'Y',
24
+ cmykK: 'K',
25
+ alphaA: 'A'
26
+ };
27
+ });
js/jquery-colorpicker/images/bar-alpha.png ADDED
Binary file
js/jquery-colorpicker/images/bar-opacity.png ADDED
Binary file
js/jquery-colorpicker/images/bar-pointer.png ADDED
Binary file
js/jquery-colorpicker/images/bar.png ADDED
Binary file
js/jquery-colorpicker/images/map-opacity.png ADDED
Binary file
js/jquery-colorpicker/images/map-pointer.png ADDED
Binary file
js/jquery-colorpicker/images/map.png ADDED
Binary file
js/jquery-colorpicker/images/preview-opacity.png ADDED
Binary file
js/jquery-colorpicker/images/ui-colorpicker.png ADDED
Binary file
js/jquery-colorpicker/index.html ADDED
@@ -0,0 +1,210 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2
+ <html>
3
+ <head>
4
+ <title>jQuery Colorpicker</title>
5
+ <!-- jQuery/jQueryUI (hosted) -->
6
+ <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.js"></script>
7
+ <script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/jquery-ui.js"></script>
8
+ <link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/themes/ui-lightness/jquery-ui.css" rel="stylesheet" type="text/css"/>
9
+ <style>
10
+ body {
11
+ font-family: 'Segoe UI', Verdana, Arial, Helvetica, sans-serif;
12
+ font-size: 62.5%;
13
+ }
14
+ </style>
15
+ <script src="jquery.colorpicker.js"></script>
16
+ <link href="jquery.colorpicker.css" rel="stylesheet" type="text/css"/>
17
+ <script src="i18n/jquery.ui.colorpicker-nl.js"></script>
18
+ </head>
19
+ <body>
20
+ <h1>jQuery ColorPicker</h1>
21
+
22
+ <hr/>
23
+
24
+ Basic &lt;input&gt; example, without any options: <input type="text" class="cp-basic" value="fe9810"/>
25
+
26
+ <hr/>
27
+
28
+ Basic &lt;div&gt; example, without any options: <span class="cp-basic" style="display: inline-block; vertical-align: top;"></span>
29
+ <script>
30
+ $( function() {
31
+ $('.cp-basic').colorpicker();
32
+ });
33
+ </script>
34
+
35
+ <hr/>
36
+
37
+ Fully-featured example: <input type="text" class="cp-full" value="186aa7"/>
38
+ <script>
39
+ $( function() {
40
+ $('.cp-full').colorpicker({
41
+ parts: 'full',
42
+ showOn: 'both',
43
+ buttonColorize: true,
44
+ showNoneButton: true,
45
+ alpha: true
46
+ });
47
+ });
48
+ </script>
49
+
50
+ <hr/>
51
+
52
+ Localized to Dutch (nl): <input type="text" class="cp-nl" value="ccea73"/>
53
+ <script>
54
+ $( function() {
55
+ $('.cp-nl').colorpicker({
56
+ regional: 'nl',
57
+ showNoneButton: true,
58
+ alpha: true
59
+ });
60
+ });
61
+ </script>
62
+
63
+ <hr/>
64
+
65
+ Limit to websafe colors: <input type="text" class="cp-websafe" value="0fa7c2"/>
66
+ <script>
67
+ $( function() {
68
+ $('.cp-websafe').colorpicker({
69
+ limit: 'websafe'
70
+ });
71
+ });
72
+ </script>
73
+
74
+ <hr/>
75
+
76
+ Alternative field class: <input type="text" class="cp-alt" value="b762ae"/>
77
+ <span class="cp-alt-target" style="display: inline-block; border: thin solid black; padding: .5em 4em;">
78
+ <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>
79
+ </span>
80
+ <script>
81
+ $( function() {
82
+ $('.cp-alt').colorpicker({
83
+ altField: '.cp-alt-target',
84
+ altProperties: 'background-color,color',
85
+ altAlpha: true,
86
+ alpha: true
87
+ });
88
+ });
89
+ </script>
90
+
91
+ <hr/>
92
+
93
+ Events: <input type="text" class="cp-events" value="92b64a"/>
94
+ <div class="cp-events-log" style="vertical-align: top; display: inline-block; border: thin solid black; height: 10em; overflow-y: scroll; width: 50em;"></div>
95
+ <script>
96
+ $( function() {
97
+ var count = 0;
98
+
99
+ function addToEventLog(label, message) {
100
+ var line = '<div>#'+(++count)+' '+label+': '+message+'</div>';
101
+ var log = $('.cp-events-log');
102
+ log.append(line).scrollTop(log[0].scrollHeight);
103
+ }
104
+
105
+ $('.cp-events').colorpicker({
106
+ init: function(event, color) {
107
+ addToEventLog('Init', color.formatted);
108
+ },
109
+ select: function(event, color) {
110
+ addToEventLog('Select', color.formatted);
111
+ },
112
+ close: function(event, color) {
113
+ addToEventLog('Close', color.formatted + ' r:' + color.rgb.r + ' g:' + color.rgb.g + ' b:' + color.rgb.b + ' a:' + color.a);
114
+ }
115
+ });
116
+ });
117
+ </script>
118
+
119
+ <hr/>
120
+
121
+ Output formatting HSLA: <input type="text" class="cp-format" value="918237"/>
122
+ <span class="cp-format-output"></span>
123
+ <script>
124
+ $( function() {
125
+ $('.cp-format').colorpicker({
126
+ colorFormat: 'HSLA',
127
+ alpha: true,
128
+ init: function(event, color) {
129
+ $('.cp-format-output').text(color.formatted);
130
+ },
131
+ select: function(event, color) {
132
+ $('.cp-format-output').text(color.formatted);
133
+ }
134
+ });
135
+ });
136
+ </script>
137
+
138
+ <hr/>
139
+
140
+ Output format list: <input type="text" class="cp-name" value="a92fb4"/>
141
+ <span class="cp-name-output"></span>
142
+ <script>
143
+ $( function() {
144
+ $('.cp-name').colorpicker({
145
+ parts: 'full',
146
+ colorFormat: ['NAME', 'EXACT', '#HEX3', 'RGB', 'RGBA'],
147
+ init: function(event, color) {
148
+ $('.cp-name-output').text(color.formatted);
149
+ },
150
+ select: function(event, color) {
151
+ $('.cp-name-output').text(color.formatted);
152
+ }
153
+ });
154
+ });
155
+ </script>
156
+
157
+ <hr/>
158
+
159
+ Dialog with Colorpicker popup (demonstrates z-index):
160
+ <button id="cp-dialog-open">Open dialog</button>
161
+ <div id="cp-dialog-modal" title="Basic modal dialog">
162
+ Basic &lt;input&gt; example, without any options: <input type="text" class="cp-basic" value="fe9810"/>
163
+ <br/>
164
+ Basic &lt;div&gt; example, without any options: <span class="cp-basic" style="display: inline-block; vertical-align: top;"></span>
165
+ </div>
166
+ <script>
167
+ $(function() {
168
+ var dialog = $('#cp-dialog-modal').dialog({
169
+ autoOpen: false,
170
+ minWidth: 500,
171
+ modal: true,
172
+ buttons: { 'Close': function() {
173
+ $(this).dialog('close');
174
+ }
175
+ }
176
+ });
177
+
178
+ $('#cp-dialog-open').click(function() {
179
+ dialog.dialog('open');
180
+ });
181
+ });
182
+ </script>
183
+
184
+ <hr/>
185
+
186
+ Modal (and showCancelButton, closeOnEscape, showCloseButton): <input type="text" class="cp-modal" value="9ba73f"/>
187
+ <script>
188
+ $( function() {
189
+ $('.cp-modal').colorpicker({
190
+ parts: 'draggable',
191
+ showCloseButton: false,
192
+ modal: true,
193
+ showCancelButton: false,
194
+ closeOnEscape: false
195
+ });
196
+ });
197
+ </script>
198
+
199
+ <hr/>
200
+
201
+ Input formatting: <input type="text" class="cp-input" value="rgb(123,42,87)"/>
202
+ <script>
203
+ $( function() {
204
+ $('.cp-input').colorpicker({
205
+ colorFormat: ['RGBA']
206
+ });
207
+ });
208
+ </script>
209
+ </body>
210
+ </html>
js/jquery-colorpicker/jquery.colorpicker.css ADDED
@@ -0,0 +1,199 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .ui-colorpicker,
2
+ .ui-dialog.ui-colorpicker {
3
+ width: auto;
4
+ white-space: nowrap;
5
+
6
+ -webkit-touch-callout: none;
7
+ -webkit-user-select: none;
8
+ -khtml-user-select: none;
9
+ -moz-user-select: none;
10
+ -ms-user-select: none;
11
+ user-select: none;
12
+ }
13
+
14
+ .ui-colorpicker-inline {
15
+ position: static;
16
+ }
17
+
18
+ .ui-colorpicker-buttonset {
19
+ float: left;
20
+ margin-left: .4em;
21
+ }
22
+
23
+ .ui-colorpicker-buttonset .ui-button {
24
+ margin: .5em 0 .5em 0;
25
+ cursor: pointer;
26
+ }
27
+
28
+ .ui-colorpicker-buttonpane {
29
+ background-image: none;
30
+ margin: .7em 0 0 0;
31
+ padding: 0 .2em;
32
+ border-left: 0;
33
+ border-right: 0;
34
+ border-bottom: 0;
35
+ }
36
+
37
+ .ui-colorpicker-buttonpane button {
38
+ float: right;
39
+ margin: .5em .2em .4em;
40
+ cursor: pointer;
41
+ padding: .2em .6em .3em .6em;
42
+ width: auto;
43
+ overflow: visible;
44
+ }
45
+
46
+ .ui-colorpicker-buttonpane button.ui-colorpicker-current {
47
+ float: left;
48
+ }
49
+
50
+ .ui-colorpicker table {
51
+ font-size: 100%; /* Reset browser table font-size */
52
+ margin: 0;
53
+ }
54
+
55
+ .ui-colorpicker table td {
56
+ vertical-align: top;
57
+ }
58
+
59
+ .ui-colorpicker-padding-left {
60
+ padding-left: 10px;
61
+ }
62
+ .ui-colorpicker-padding-top {
63
+ padding-top: 10px;
64
+ }
65
+
66
+ .ui-colorpicker-border {
67
+ border: 1px inset;
68
+ display: inline-block;
69
+ }
70
+
71
+ /* Bar & map */
72
+ .ui-colorpicker-map > *,
73
+ .ui-colorpicker-bar > * {
74
+ position: absolute;
75
+ cursor: crosshair;
76
+ }
77
+
78
+ .ui-colorpicker-map-pointer,
79
+ .ui-colorpicker-bar-pointer {
80
+ position: absolute;
81
+ }
82
+ /* Map */
83
+ .ui-colorpicker-map,
84
+ .ui-colorpicker-map > * {
85
+ display: block;
86
+ width: 256px;
87
+ height: 256px;
88
+ overflow: hidden;
89
+ }
90
+
91
+ .ui-colorpicker-map-layer-1,
92
+ .ui-colorpicker-map-layer-2 {
93
+ background: url(images/map.png) no-repeat;
94
+ }
95
+
96
+ .ui-colorpicker-map-layer-alpha {
97
+ background: url(images/map-opacity.png);
98
+ }
99
+
100
+ .ui-colorpicker-map-pointer {
101
+ display: inline-block;
102
+ width: 15px;
103
+ height: 15px;
104
+ background: url(images/map-pointer.png) no-repeat;
105
+ }
106
+
107
+ /* Bar */
108
+ .ui-colorpicker-bar,
109
+ .ui-colorpicker-bar > * {
110
+ display: block;
111
+ width: 20px;
112
+ height: 256px;
113
+ overflow: hidden;
114
+ background-repeat: repeat-x;
115
+ }
116
+
117
+ .ui-colorpicker-bar-layer-1,
118
+ .ui-colorpicker-bar-layer-2,
119
+ .ui-colorpicker-bar-layer-3,
120
+ .ui-colorpicker-bar-layer-4 {
121
+ background: url(images/bar.png) repeat-x;
122
+ }
123
+
124
+ .ui-colorpicker-bar-layer-alpha {
125
+ background: url(images/bar-opacity.png);
126
+ }
127
+
128
+ .ui-colorpicker-bar-layer-alphabar {
129
+ background: url(images/bar-alpha.png);
130
+ }
131
+
132
+ .ui-colorpicker-bar-pointer {
133
+ display: inline-block;
134
+ width: 20px;
135
+ height: 7px;
136
+ background: url(images/bar-pointer.png) no-repeat;
137
+ }
138
+
139
+ /* Preview */
140
+ .ui-colorpicker-preview {
141
+ text-align: center;
142
+ }
143
+
144
+ .ui-colorpicker-preview-initial {
145
+ cursor: pointer;
146
+ }
147
+
148
+ .ui-colorpicker-preview-initial,
149
+ .ui-colorpicker-preview-current {
150
+ width: 50px;
151
+ height: 20px;
152
+ display: inline-block;
153
+ }
154
+
155
+ .ui-colorpicker-preview-initial-alpha,
156
+ .ui-colorpicker-preview-current-alpha {
157
+ width: 50px;
158
+ height: 20px;
159
+ display: inline-block;
160
+ background: url(images/preview-opacity.png) repeat;
161
+ }
162
+
163
+ /* Inputs */
164
+ .ui-colorpicker-rgb label,
165
+ .ui-colorpicker-hsv label,
166
+ .ui-colorpicker-hsl label,
167
+ .ui-colorpicker-lab label,
168
+ .ui-colorpicker-cmyk label,
169
+ .ui-colorpicker-alpha label {
170
+ width: 1.5em;
171
+ display: inline-block;
172
+ }
173
+
174
+ .ui-colorpicker-number {
175
+ margin: .1em;
176
+ width: 4em;
177
+ }
178
+
179
+ /* Hex */
180
+ .ui-colorpicker-hex {
181
+ text-align: center;
182
+ }
183
+
184
+ /* Swatches */
185
+ .ui-colorpicker-swatches {
186
+ width: 84px;
187
+ height: 256px;
188
+ overflow: auto;
189
+ background-color: #f8f8f8;
190
+ }
191
+
192
+ .ui-colorpicker-swatch {
193
+ cursor: pointer;
194
+ float: left;
195
+ width: 11px;
196
+ height: 11px;
197
+ border-right: 1px solid black;
198
+ border-bottom: 1px solid black;
199
+ }
js/jquery-colorpicker/jquery.colorpicker.js ADDED
@@ -0,0 +1,2550 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*jslint devel: true, bitwise: true, regexp: true, browser: true, confusion: true, unparam: true, eqeq: true, white: true, nomen: true, plusplus: true, maxerr: 50, indent: 4 */
2
+ /*globals jQuery,Color */
3
+
4
+ /*
5
+ * ColorPicker
6
+ *
7
+ * Copyright (c) 2011-2012 Martijn W. van der Lee
8
+ * Licensed under the MIT.
9
+ *
10
+ * Full-featured colorpicker for jQueryUI with full theming support.
11
+ * Most images from jPicker by Christopher T. Tillman.
12
+ * Sourcecode created from scratch by Martijn W. van der Lee.
13
+ */
14
+
15
+ (function ($) {
16
+ "use strict";
17
+
18
+ $.colorpicker = new function() {
19
+ this.regional = [];
20
+ this.regional[''] = {
21
+ ok: 'OK',
22
+ cancel: 'Cancel',
23
+ none: 'None',
24
+ button: 'Color',
25
+ title: 'Pick a color',
26
+ transparent: 'Transparent',
27
+ hsvH: 'H',
28
+ hsvS: 'S',
29
+ hsvV: 'V',
30
+ rgbR: 'R',
31
+ rgbG: 'G',
32
+ rgbB: 'B',
33
+ labL: 'L',
34
+ labA: 'a',
35
+ labB: 'b',
36
+ hslH: 'H',
37
+ hslS: 'S',
38
+ hslL: 'L',
39
+ cmykC: 'C',
40
+ cmykM: 'M',
41
+ cmykY: 'Y',
42
+ cmykK: 'K',
43
+ alphaA: 'A'
44
+ };
45
+ };
46
+
47
+ var _colorpicker_index = 0,
48
+
49
+ _container_popup = '<div class="ui-colorpicker ui-colorpicker-dialog ui-dialog ui-widget ui-widget-content ui-corner-all" style="display: none;"></div>',
50
+
51
+ _container_inline = '<div class="ui-colorpicker ui-colorpicker-inline ui-dialog ui-widget ui-widget-content ui-corner-all"></div>',
52
+
53
+ _parts_lists = {
54
+ 'full': ['header', 'map', 'bar', 'hex', 'hsv', 'rgb', 'alpha', 'lab', 'cmyk', 'preview', 'swatches', 'footer'],
55
+ 'popup': ['map', 'bar', 'hex', 'hsv', 'rgb', 'alpha', 'preview', 'footer'],
56
+ 'draggable': ['header', 'map', 'bar', 'hex', 'hsv', 'rgb', 'alpha', 'preview', 'footer'],
57
+ 'inline': ['map', 'bar', 'hex', 'hsv', 'rgb', 'alpha', 'preview']
58
+ },
59
+
60
+ _intToHex = function (dec) {
61
+ var result = Math.round(dec).toString(16);
62
+ if (result.length === 1) {
63
+ result = ('0' + result);
64
+ }
65
+ return result.toLowerCase();
66
+ },
67
+
68
+ _formats = {
69
+ '#HEX': function(color) {
70
+ return _formatColor('#rxgxbx', color);
71
+ }
72
+ , '#HEX3': function(color) {
73
+ var hex3 = _formats.HEX3(color);
74
+ return hex3 === false? false : '#'+hex3;
75
+ }
76
+ , 'HEX': function(color) {
77
+ return _formatColor('rxgxbx', color);
78
+ }
79
+ , 'HEX3': function(color) {
80
+ var rgb = color.getRGB(),
81
+ r = Math.round(rgb.r * 255),
82
+ g = Math.round(rgb.g * 255),
83
+ b = Math.round(rgb.b * 255);
84
+
85
+ if (((r >>> 4) == (r &= 0xf))
86
+ && ((g >>> 4) == (g &= 0xf))
87
+ && ((b >>> 4) == (b &= 0xf))) {
88
+ return r.toString(16)+g.toString(16)+b.toString(16);
89
+ }
90
+ return false;
91
+ }
92
+ , 'RGB': function(color) {
93
+ return color.getAlpha() >= 1
94
+ ? _formatColor('rgb(rd,gd,bd)', color)
95
+ : false;
96
+ }
97
+ , 'RGBA': function(color) {
98
+ return _formatColor('rgba(rd,gd,bd,af)', color);
99
+ }
100
+ , 'RGB%': function(color) {
101
+ return color.getAlpha() >= 1
102
+ ? _formatColor('rgb(rp%,gp%,bp%)', color)
103
+ : false;
104
+ }
105
+ , 'RGBA%': function(color) {
106
+ return _formatColor('rgba(rp%,gp%,bp%,af)', color);
107
+ }
108
+ , 'HSL': function(color) {
109
+ return color.getAlpha() >= 1
110
+ ? _formatColor('hsl(hd,sd,vd)', color)
111
+ : false;
112
+ }
113
+ , 'HSLA': function(color) {
114
+ return _formatColor('hsla(hd,sd,vd,af)', color);
115
+ }
116
+ , 'HSL%': function(color) {
117
+ return color.getAlpha() >= 1
118
+ ? _formatColor('hsl(hp%,sp%,vp%)', color)
119
+ : false;
120
+ }
121
+ , 'HSLA%': function(color) {
122
+ return _formatColor('hsla(hp%,sp%,vp%,af)', color);
123
+ }
124
+ , 'NAME': function(color) {
125
+ return _closestName(color);
126
+ }
127
+ , 'EXACT': function(color) { //@todo experimental. Implement a good fallback list
128
+ return _exactName(color);
129
+ }
130
+ },
131
+
132
+ _formatColor = function (formats, color) {
133
+ var that = this,
134
+ text = null,
135
+ types = { 'x': function(v) {return _intToHex(v * 255);}
136
+ , 'd': function(v) {return Math.round(v * 255);}
137
+ , 'f': function(v) {return v;}
138
+ , 'p': function(v) {return v * 100;}
139
+ },
140
+ channels = color.getChannels();
141
+
142
+ if (!$.isArray(formats)) {
143
+ formats = [formats];
144
+ }
145
+
146
+ $.each(formats, function(index, format) {
147
+ if (_formats[format]) {
148
+ text = _formats[format](color);
149
+ return (text === false);
150
+ } else {
151
+ text = format.replace(/\\?[argbhsvcmykLAB][xdfp]/g, function(m) {
152
+ if (m.match(/^\\/)) {
153
+ return m.slice(1);
154
+ }
155
+ return types[m.charAt(1)](channels[m.charAt(0)]);
156
+ });
157
+ return false;
158
+ }
159
+ });
160
+
161
+ return text;
162
+ },
163
+
164
+ _colors = {
165
+ 'black': {r: 0, g: 0, b: 0},
166
+ 'dimgray': {r: 0.4117647058823529, g: 0.4117647058823529, b: 0.4117647058823529},
167
+ 'gray': {r: 0.5019607843137255, g: 0.5019607843137255, b: 0.5019607843137255},
168
+ 'darkgray': {r: 0.6627450980392157, g: 0.6627450980392157, b: 0.6627450980392157},
169
+ 'silver': {r: 0.7529411764705882, g: 0.7529411764705882, b: 0.7529411764705882},
170
+ 'lightgrey': {r: 0.8274509803921568, g: 0.8274509803921568, b: 0.8274509803921568},
171
+ 'gainsboro': {r: 0.8627450980392157, g: 0.8627450980392157, b: 0.8627450980392157},
172
+ 'whitesmoke': {r: 0.9607843137254902, g: 0.9607843137254902, b: 0.9607843137254902},
173
+ 'white': {r: 1, g: 1, b: 1},
174
+ 'rosybrown': {r: 0.7372549019607844, g: 0.5607843137254902, b: 0.5607843137254902},
175
+ 'indianred': {r: 0.803921568627451, g: 0.3607843137254902, b: 0.3607843137254902},
176
+ 'brown': {r: 0.6470588235294118, g: 0.16470588235294117, b: 0.16470588235294117},
177
+ 'firebrick': {r: 0.6980392156862745, g: 0.13333333333333333, b: 0.13333333333333333},
178
+ 'lightcoral': {r: 0.9411764705882353, g: 0.5019607843137255, b: 0.5019607843137255},
179
+ 'maroon': {r: 0.5019607843137255, g: 0, b: 0},
180
+ 'darkred': {r: 0.5450980392156862, g: 0, b: 0},
181
+ 'red': {r: 1, g: 0, b: 0},
182
+ 'snow': {r: 1, g: 0.9803921568627451, b: 0.9803921568627451},
183
+ 'salmon': {r: 0.9803921568627451, g: 0.5019607843137255, b: 0.4470588235294118},
184
+ 'mistyrose': {r: 1, g: 0.8941176470588236, b: 0.8823529411764706},
185
+ 'tomato': {r: 1, g: 0.38823529411764707, b: 0.2784313725490196},
186
+ 'darksalmon': {r: 0.9137254901960784, g: 0.5882352941176471, b: 0.47843137254901963},
187
+ 'orangered': {r: 1, g: 0.27058823529411763, b: 0},
188
+ 'coral': {r: 1, g: 0.4980392156862745, b: 0.3137254901960784},
189
+ 'lightsalmon': {r: 1, g: 0.6274509803921569, b: 0.47843137254901963},
190
+ 'sienna': {r: 0.6274509803921569, g: 0.3215686274509804, b: 0.17647058823529413},
191
+ 'seashell': {r: 1, g: 0.9607843137254902, b: 0.9333333333333333},
192
+ 'chocolate': {r: 0.8235294117647058, g: 0.4117647058823529, b: 0.11764705882352941},
193
+ 'saddlebrown': {r: 0.5450980392156862, g: 0.27058823529411763, b: 0.07450980392156863},
194
+ 'sandybrown': {r: 0.9568627450980393, g: 0.6431372549019608, b: 0.3764705882352941},
195
+ 'peachpuff': {r: 1, g: 0.8549019607843137, b: 0.7254901960784313},
196
+ 'peru': {r: 0.803921568627451, g: 0.5215686274509804, b: 0.24705882352941178},
197
+ 'linen': {r: 0.9803921568627451, g: 0.9411764705882353, b: 0.9019607843137255},
198
+ 'darkorange': {r: 1, g: 0.5490196078431373, b: 0},
199
+ 'bisque': {r: 1, g: 0.8941176470588236, b: 0.7686274509803922},
200
+ 'burlywood': {r: 0.8705882352941177, g: 0.7215686274509804, b: 0.5294117647058824},
201
+ 'tan': {r: 0.8235294117647058, g: 0.7058823529411765, b: 0.5490196078431373},
202
+ 'antiquewhite': {r: 0.9803921568627451, g: 0.9215686274509803, b: 0.8431372549019608},
203
+ 'navajowhite': {r: 1, g: 0.8705882352941177, b: 0.6784313725490196},
204
+ 'blanchedalmond': {r: 1, g: 0.9215686274509803, b: 0.803921568627451},
205
+ 'papayawhip': {r: 1, g: 0.9372549019607843, b: 0.8352941176470589},
206
+ 'orange': {r: 1, g: 0.6470588235294118, b: 0},
207
+ 'moccasin': {r: 1, g: 0.8941176470588236, b: 0.7098039215686275},
208
+ 'wheat': {r: 0.9607843137254902, g: 0.8705882352941177, b: 0.7019607843137254},
209
+ 'oldlace': {r: 0.9921568627450981, g: 0.9607843137254902, b: 0.9019607843137255},
210
+ 'floralwhite': {r: 1, g: 0.9803921568627451, b: 0.9411764705882353},
211
+ 'goldenrod': {r: 0.8549019607843137, g: 0.6470588235294118, b: 0.12549019607843137},
212
+ 'darkgoldenrod': {r: 0.7215686274509804, g: 0.5254901960784314, b: 0.043137254901960784},
213
+ 'cornsilk': {r: 1, g: 0.9725490196078431, b: 0.8627450980392157},
214
+ 'gold': {r: 1, g: 0.8431372549019608, b: 0},
215
+ 'palegoldenrod': {r: 0.9333333333333333, g: 0.9098039215686274, b: 0.6666666666666666},
216
+ 'khaki': {r: 0.9411764705882353, g: 0.9019607843137255, b: 0.5490196078431373},
217
+ 'lemonchiffon': {r: 1, g: 0.9803921568627451, b: 0.803921568627451},
218
+ 'darkkhaki': {r: 0.7411764705882353, g: 0.7176470588235294, b: 0.4196078431372549},
219
+ 'beige': {r: 0.9607843137254902, g: 0.9607843137254902, b: 0.8627450980392157},
220
+ 'lightgoldenrodyellow': {r: 0.9803921568627451, g: 0.9803921568627451, b: 0.8235294117647058},
221
+ 'olive': {r: 0.5019607843137255, g: 0.5019607843137255, b: 0},
222
+ 'yellow': {r: 1, g: 1, b: 0},
223
+ 'lightyellow': {r: 1, g: 1, b: 0.8784313725490196},
224
+ 'ivory': {r: 1, g: 1, b: 0.9411764705882353},
225
+ 'olivedrab': {r: 0.4196078431372549, g: 0.5568627450980392, b: 0.13725490196078433},
226
+ 'yellowgreen': {r: 0.6039215686274509, g: 0.803921568627451, b: 0.19607843137254902},
227
+ 'darkolivegreen': {r: 0.3333333333333333, g: 0.4196078431372549, b: 0.1843137254901961},
228
+ 'greenyellow': {r: 0.6784313725490196, g: 1, b: 0.1843137254901961},
229
+ 'lawngreen': {r: 0.48627450980392156, g: 0.9882352941176471, b: 0},
230
+ 'chartreuse': {r: 0.4980392156862745, g: 1, b: 0},
231
+ 'darkseagreen': {r: 0.5607843137254902, g: 0.7372549019607844, b: 0.5607843137254902},
232
+ 'forestgreen': {r: 0.13333333333333333, g: 0.5450980392156862, b: 0.13333333333333333},
233
+ 'limegreen': {r: 0.19607843137254902, g: 0.803921568627451, b: 0.19607843137254902},
234
+ 'lightgreen': {r: 0.5647058823529412, g: 0.9333333333333333, b: 0.5647058823529412},
235
+ 'palegreen': {r: 0.596078431372549, g: 0.984313725490196, b: 0.596078431372549},
236
+ 'darkgreen': {r: 0, g: 0.39215686274509803, b: 0},
237
+ 'green': {r: 0, g: 0.5019607843137255, b: 0},
238
+ 'lime': {r: 0, g: 1, b: 0},
239
+ 'honeydew': {r: 0.9411764705882353, g: 1, b: 0.9411764705882353},
240
+ 'mediumseagreen': {r: 0.23529411764705882, g: 0.7019607843137254, b: 0.44313725490196076},
241
+ 'seagreen': {r: 0.1803921568627451, g: 0.5450980392156862, b: 0.3411764705882353},
242
+ 'springgreen': {r: 0, g: 1, b: 0.4980392156862745},
243
+ 'mintcream': {r: 0.9607843137254902, g: 1, b: 0.9803921568627451},
244
+ 'mediumspringgreen': {r: 0, g: 0.9803921568627451, b: 0.6039215686274509},
245
+ 'mediumaquamarine': {r: 0.4, g: 0.803921568627451, b: 0.6666666666666666},
246
+ 'aquamarine': {r: 0.4980392156862745, g: 1, b: 0.8313725490196079},
247
+ 'turquoise': {r: 0.25098039215686274, g: 0.8784313725490196, b: 0.8156862745098039},
248
+ 'lightseagreen': {r: 0.12549019607843137, g: 0.6980392156862745, b: 0.6666666666666666},
249
+ 'mediumturquoise': {r: 0.2823529411764706, g: 0.8196078431372549, b: 0.8},
250
+ 'darkslategray': {r: 0.1843137254901961, g: 0.30980392156862746, b: 0.30980392156862746},
251
+ 'paleturquoise': {r: 0.6862745098039216, g: 0.9333333333333333, b: 0.9333333333333333},
252
+ 'teal': {r: 0, g: 0.5019607843137255, b: 0.5019607843137255},
253
+ 'darkcyan': {r: 0, g: 0.5450980392156862, b: 0.5450980392156862},
254
+ 'darkturquoise': {r: 0, g: 0.807843137254902, b: 0.8196078431372549},
255
+ 'aqua': {r: 0, g: 1, b: 1},
256
+ 'cyan': {r: 0, g: 1, b: 1},
257
+ 'lightcyan': {r: 0.8784313725490196, g: 1, b: 1},
258
+ 'azure': {r: 0.9411764705882353, g: 1, b: 1},
259
+ 'cadetblue': {r: 0.37254901960784315, g: 0.6196078431372549, b: 0.6274509803921569},
260
+ 'powderblue': {r: 0.6901960784313725, g: 0.8784313725490196, b: 0.9019607843137255},
261
+ 'lightblue': {r: 0.6784313725490196, g: 0.8470588235294118, b: 0.9019607843137255},
262
+ 'deepskyblue': {r: 0, g: 0.7490196078431373, b: 1},
263
+ 'skyblue': {r: 0.5294117647058824, g: 0.807843137254902, b: 0.9215686274509803},
264
+ 'lightskyblue': {r: 0.5294117647058824, g: 0.807843137254902, b: 0.9803921568627451},
265
+ 'steelblue': {r: 0.27450980392156865, g: 0.5098039215686274, b: 0.7058823529411765},
266
+ 'aliceblue': {r: 0.9411764705882353, g: 0.9725490196078431, b: 1},
267
+ 'dodgerblue': {r: 0.11764705882352941, g: 0.5647058823529412, b: 1},
268
+ 'slategray': {r: 0.4392156862745098, g: 0.5019607843137255, b: 0.5647058823529412},
269
+ 'lightslategray': {r: 0.4666666666666667, g: 0.5333333333333333, b: 0.6},
270
+ 'lightsteelblue': {r: 0.6901960784313725, g: 0.7686274509803922, b: 0.8705882352941177},
271
+ 'cornflowerblue': {r: 0.39215686274509803, g: 0.5843137254901961, b: 0.9294117647058824},
272
+ 'royalblue': {r: 0.2549019607843137, g: 0.4117647058823529, b: 0.8823529411764706},
273
+ 'midnightblue': {r: 0.09803921568627451, g: 0.09803921568627451, b: 0.4392156862745098},
274
+ 'lavender': {r: 0.9019607843137255, g: 0.9019607843137255, b: 0.9803921568627451},
275
+ 'navy': {r: 0, g: 0, b: 0.5019607843137255},
276
+ 'darkblue': {r: 0, g: 0, b: 0.5450980392156862},
277
+ 'mediumblue': {r: 0, g: 0, b: 0.803921568627451},
278
+ 'blue': {r: 0, g: 0, b: 1},
279
+ 'ghostwhite': {r: 0.9725490196078431, g: 0.9725490196078431, b: 1},
280
+ 'darkslateblue': {r: 0.2823529411764706, g: 0.23921568627450981, b: 0.5450980392156862},
281
+ 'slateblue': {r: 0.41568627450980394, g: 0.35294117647058826, b: 0.803921568627451},
282
+ 'mediumslateblue': {r: 0.4823529411764706, g: 0.40784313725490196, b: 0.9333333333333333},
283
+ 'mediumpurple': {r: 0.5764705882352941, g: 0.4392156862745098, b: 0.8588235294117647},
284
+ 'blueviolet': {r: 0.5411764705882353, g: 0.16862745098039217, b: 0.8862745098039215},
285
+ 'indigo': {r: 0.29411764705882354, g: 0, b: 0.5098039215686274},
286
+ 'darkorchid': {r: 0.6, g: 0.19607843137254902, b: 0.8},
287
+ 'darkviolet': {r: 0.5803921568627451, g: 0, b: 0.8274509803921568},
288
+ 'mediumorchid': {r: 0.7294117647058823, g: 0.3333333333333333, b: 0.8274509803921568},
289
+ 'thistle': {r: 0.8470588235294118, g: 0.7490196078431373, b: 0.8470588235294118},
290
+ 'plum': {r: 0.8666666666666667, g: 0.6274509803921569, b: 0.8666666666666667},
291
+ 'violet': {r: 0.9333333333333333, g: 0.5098039215686274, b: 0.9333333333333333},
292
+ 'purple': {r: 0.5019607843137255, g: 0, b: 0.5019607843137255},
293
+ 'darkmagenta': {r: 0.5450980392156862, g: 0, b: 0.5450980392156862},
294
+ 'magenta': {r: 1, g: 0, b: 1},
295
+ 'fuchsia': {r: 1, g: 0, b: 1},
296
+ 'orchid': {r: 0.8549019607843137, g: 0.4392156862745098, b: 0.8392156862745098},
297
+ 'mediumvioletred': {r: 0.7803921568627451, g: 0.08235294117647059, b: 0.5215686274509804},
298
+ 'deeppink': {r: 1, g: 0.0784313725490196, b: 0.5764705882352941},
299
+ 'hotpink': {r: 1, g: 0.4117647058823529, b: 0.7058823529411765},
300
+ 'palevioletred': {r: 0.8588235294117647, g: 0.4392156862745098, b: 0.5764705882352941},
301
+ 'lavenderblush': {r: 1, g: 0.9411764705882353, b: 0.9607843137254902},
302
+ 'crimson': {r: 0.8627450980392157, g: 0.0784313725490196, b: 0.23529411764705882},
303
+ 'pink': {r: 1, g: 0.7529411764705882, b: 0.796078431372549},
304
+ 'lightpink': {r: 1, g: 0.7137254901960784, b: 0.7568627450980392}
305
+ },
306
+
307
+ _exactName = function(color) {
308
+ var name = false;
309
+
310
+ $.each(_colors, function(n, color_b) {
311
+ if (color.equals(new Color(color_b.r, color_b.g, color_b.b))) {
312
+ name = n;
313
+ return false;
314
+ }
315
+ });
316
+
317
+ return name;
318
+ },
319
+
320
+ _closestName = function(color) {
321
+ var rgb = color.getRGB(),
322
+ distance = null,
323
+ name = false,
324
+ d;
325
+
326
+ $.each(_colors, function(n, color_b) {
327
+ d = color.distance(new Color(color_b.r, color_b.g, color_b.b));
328
+ if (d < distance || distance === null) {
329
+ name = n;
330
+ if (d == 0) {
331
+ return false; // can't get much closer than 0
332
+ }
333
+ distance = d;
334
+ }
335
+ });
336
+
337
+ return name;
338
+ },
339
+
340
+ _parseHex = function(color) {
341
+ var c,
342
+ m;
343
+
344
+ // {#}rrggbb
345
+ m = /^#?([a-fA-F0-9]{1,6})$/.exec(color);
346
+ if (m) {
347
+ c = parseInt(m[1], 16);
348
+ return new Color(
349
+ ((c >> 16) & 0xFF) / 255,
350
+ ((c >> 8) & 0xFF) / 255,
351
+ (c & 0xFF) / 255
352
+ );
353
+ }
354
+
355
+ return false;
356
+ },
357
+
358
+ _parseColor = function(color) {
359
+ var name = $.trim(color).toLowerCase(),
360
+ m;
361
+
362
+ if (color == '') {
363
+ return new Color();
364
+ }
365
+
366
+ if (_colors[name]) {
367
+ return new Color(_colors[name].r, _colors[name].g, _colors[name].b);
368
+ }
369
+
370
+ // rgba(r,g,b,a)
371
+ m = /^rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(?:,\s*(\d+(?:\.\d+)?)\s*)?\)$/.exec(color);
372
+ if (m) {
373
+ return new Color(
374
+ m[1] / 255,
375
+ m[2] / 255,
376
+ m[3] / 255,
377
+ parseFloat(m[4])
378
+ );
379
+ }
380
+
381
+ // hsla(r,g,b,a)
382
+ m = /^hsla?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(?:,\s*(\d+(?:\.\d+)?)\s*)?\)$/.exec(color);
383
+ if (m) {
384
+ return (new Color()).setHSL(
385
+ m[1] / 255,
386
+ m[2] / 255,
387
+ m[3] / 255).setAlpha(parseFloat(m[4]));
388
+ }
389
+
390
+ // rgba(r%,g%,b%,a%)
391
+ m = /^rgba?\(\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d+(?:\.\d+)?)\s*)?\)$/.exec(color);
392
+ if (m) {
393
+ return new Color(
394
+ m[1] / 100,
395
+ m[2] / 100,
396
+ m[3] / 100,
397
+ m[4] / 100
398
+ );
399
+ }
400
+
401
+ // hsla(r%,g%,b%,a%)
402
+ m = /^hsla?\(\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d+(?:\.\d+)?)\s*)?\)$/.exec(color);
403
+ if (m) {
404
+ return (new Color()).setHSL(
405
+ m[1] / 100,
406
+ m[2] / 100,
407
+ m[3] / 100).setAlpha(m[4] / 100);
408
+ }
409
+
410
+ // #rrggbb
411
+ m = /^#([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})$/.exec(color);
412
+ if (m) {
413
+ return new Color(
414
+ parseInt(m[1], 16) / 255,
415
+ parseInt(m[2], 16) / 255,
416
+ parseInt(m[3], 16) / 255
417
+ );
418
+ }
419
+
420
+ // #rgb
421
+ m = /^#([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])$/.exec(color);
422
+ if (m) {
423
+ return new Color(
424
+ parseInt(m[1] + m[1], 16) / 255,
425
+ parseInt(m[2] + m[2], 16) / 255,
426
+ parseInt(m[3] + m[3], 16) / 255
427
+ );
428
+ }
429
+
430
+ return _parseHex(color);
431
+ },
432
+
433
+ _layoutTable = function(layout, callback) {
434
+ var bitmap,
435
+ x,
436
+ y,
437
+ width, height,
438
+ columns, rows,
439
+ index,
440
+ cell,
441
+ html,
442
+ w,
443
+ h,
444
+ colspan,
445
+ walked;
446
+
447
+ layout.sort(function(a, b) {
448
+ if (a.pos[1] == b.pos[1]) {
449
+ return a.pos[0] - b.pos[0];
450
+ }
451
+ return a.pos[1] - b.pos[1];
452
+ });
453
+
454
+ // Determine dimensions of the table
455
+ width = 0;
456
+ height = 0;
457
+ $.each (layout, function(index, part) {
458
+ width = Math.max(width, part.pos[0] + part.pos[2]);
459
+ height = Math.max(height, part.pos[1] + part.pos[3]);
460
+ });
461
+
462
+ // Initialize bitmap
463
+ bitmap = [];
464
+ for (x = 0; x < width; ++x) {
465
+ bitmap.push([]);
466
+ }
467
+
468
+ // Mark rows and columns which have layout assigned
469
+ rows = [];
470
+ columns = [];
471
+ $.each(layout, function(index, part) {
472
+ // mark columns
473
+ for (x = 0; x < part.pos[2]; x += 1) {
474
+ columns[part.pos[0] + x] = true;
475
+ }
476
+ for (y = 0; y < part.pos[3]; y += 1) {
477
+ rows[part.pos[1] + y] = true;
478
+ }
479
+ });
480
+
481
+ // Generate the table
482
+ html = '';
483
+ cell = layout[index = 0];
484
+ for (y = 0; y < height; ++y) {
485
+ html += '<tr>';
486
+ for (x = 0; x < width; x) {
487
+ if (typeof cell !== 'undefined' && x == cell.pos[0] && y == cell.pos[1]) {
488
+ // Create a "real" cell
489
+ html += callback(cell, x, y);
490
+
491
+ for (h = 0; h < cell.pos[3]; h +=1) {
492
+ for (w = 0; w < cell.pos[2]; w +=1) {
493
+ bitmap[x + w][y + h] = true;
494
+ }
495
+ }
496
+
497
+ x += cell.pos[2];
498
+ cell = layout[++index];
499
+ } else {
500
+ // Fill in the gaps
501
+ colspan = 0;
502
+ walked = false;
503
+
504
+ while (x < width && bitmap[x][y] === undefined && (cell === undefined || y < cell.pos[1] || (y == cell.pos[1] && x < cell.pos[0]))) {
505
+ if (columns[x] === true) {
506
+ colspan += 1;
507
+ }
508
+ walked = true;
509
+ x += 1;
510
+ }
511
+
512
+ if (colspan > 0) {
513
+ html += '<td colspan="'+colspan+'"></td>';
514
+ } else if (!walked) {
515
+ x += 1;
516
+ }
517
+ }
518
+ }
519
+ html += '</tr>';
520
+ }
521
+
522
+ return '<table cellspacing="0" cellpadding="0" border="0"><tbody>' + html + '</tbody></table>';
523
+ },
524
+
525
+ _parts = {
526
+ header: function (inst) {
527
+ var that = this,
528
+ e = null,
529
+ _html =function() {
530
+ var title = inst.options.title || inst._getRegional('title'),
531
+ html = '<span class="ui-dialog-title">' + title + '</span>';
532
+
533
+ if (!inst.inline && inst.options.showCloseButton) {
534
+ html += '<a href="#" class="ui-dialog-titlebar-close ui-corner-all" role="button">'
535
+ + '<span class="ui-icon ui-icon-closethick">close</span></a>';
536
+ }
537
+
538
+ return '<div class="ui-dialog-titlebar ui-widget-header ui-corner-all ui-helper-clearfix">' + html + '</div>';
539
+ };
540
+
541
+ this.init = function() {
542
+ e = $(_html()).prependTo(inst.dialog);
543
+
544
+ var close = $('.ui-dialog-titlebar-close', e);
545
+ inst._hoverable(close);
546
+ inst._focusable(close);
547
+ close.click(function(event) {
548
+ event.preventDefault();
549
+ inst.close();
550
+ });
551
+
552
+ if (!inst.inline && inst.options.draggable) {
553
+ inst.dialog.draggable({
554
+ handle: e
555
+ });
556
+ }
557
+ };
558
+ },
559
+
560
+ map: function (inst) {
561
+ var that = this,
562
+ e = null,
563
+ mousemove_timeout = null,
564
+ _mousedown, _mouseup, _mousemove, _html;
565
+
566
+ _mousedown = function (event) {
567
+ if (!inst.opened) {
568
+ return;
569
+ }
570
+
571
+ var div = $('.ui-colorpicker-map-layer-pointer', e),
572
+ offset = div.offset(),
573
+ width = div.width(),
574
+ height = div.height(),
575
+ x = event.pageX - offset.left,
576
+ y = event.pageY - offset.top;
577
+
578
+ if (x >= 0 && x < width && y >= 0 && y < height) {
579
+ event.stopImmediatePropagation();
580
+ event.preventDefault();
581
+ e.unbind('mousedown', _mousedown);
582
+ $(document).bind('mouseup', _mouseup);
583
+ $(document).bind('mousemove', _mousemove);
584
+ _mousemove(event);
585
+ }
586
+ };
587
+
588
+ _mouseup = function (event) {
589
+ event.stopImmediatePropagation();
590
+ event.preventDefault();
591
+ $(document).unbind('mouseup', _mouseup);
592
+ $(document).unbind('mousemove', _mousemove);
593
+ e.bind('mousedown', _mousedown);
594
+ };
595
+
596
+ _mousemove = function (event) {
597
+ event.stopImmediatePropagation();
598
+ event.preventDefault();
599
+
600
+ if (event.pageX === that.x && event.pageY === that.y) {
601
+ return;
602
+ }
603
+ that.x = event.pageX;
604
+ that.y = event.pageY;
605
+
606
+ var div = $('.ui-colorpicker-map-layer-pointer', e),
607
+ offset = div.offset(),
608
+ width = div.width(),
609
+ height = div.height(),
610
+ x = event.pageX - offset.left,
611
+ y = event.pageY - offset.top;
612
+
613
+ x = Math.max(0, Math.min(x / width, 1));
614
+ y = Math.max(0, Math.min(y / height, 1));
615
+
616
+ // interpret values
617
+ switch (inst.mode) {
618
+ case 'h':
619
+ inst.color.setHSV(null, x, 1 - y);
620
+ break;
621
+
622
+ case 's':
623
+ case 'a':
624
+ inst.color.setHSV(x, null, 1 - y);
625
+ break;
626
+
627
+ case 'v':
628
+ inst.color.setHSV(x, 1 - y, null);
629
+ break;
630
+
631
+ case 'r':
632
+ inst.color.setRGB(null, 1 - y, x);
633
+ break;
634
+
635
+ case 'g':
636
+ inst.color.setRGB(1 - y, null, x);
637
+ break;
638
+
639
+ case 'b':
640
+ inst.color.setRGB(x, 1 - y, null);
641
+ break;
642
+ }
643
+
644
+ inst._change();
645
+ };
646
+
647
+ _html = function () {
648
+ var html = '<div class="ui-colorpicker-map ui-colorpicker-border">'
649
+ + '<span class="ui-colorpicker-map-layer-1">&nbsp;</span>'
650
+ + '<span class="ui-colorpicker-map-layer-2">&nbsp;</span>'
651
+ + (inst.options.alpha ? '<span class="ui-colorpicker-map-layer-alpha">&nbsp;</span>' : '')
652
+ + '<span class="ui-colorpicker-map-layer-pointer"><span class="ui-colorpicker-map-pointer"></span></span></div>';
653
+ return html;
654
+ };
655
+
656
+ this.update = function () {
657
+ switch (inst.mode) {
658
+ case 'h':
659
+ $('.ui-colorpicker-map-layer-1', e).css({'background-position': '0 0', 'opacity': ''}).show();
660
+ $('.ui-colorpicker-map-layer-2', e).hide();
661
+ break;
662
+
663
+ case 's':
664
+ case 'a':
665
+ $('.ui-colorpicker-map-layer-1', e).css({'background-position': '0 -260px', 'opacity': ''}).show();
666
+ $('.ui-colorpicker-map-layer-2', e).css({'background-position': '0 -520px', 'opacity': ''}).show();
667
+ break;
668
+
669
+ case 'v':
670
+ $(e).css('background-color', 'black');
671
+ $('.ui-colorpicker-map-layer-1', e).css({'background-position': '0 -780px', 'opacity': ''}).show();
672
+ $('.ui-colorpicker-map-layer-2', e).hide();
673
+ break;
674
+
675
+ case 'r':
676
+ $('.ui-colorpicker-map-layer-1', e).css({'background-position': '0 -1040px', 'opacity': ''}).show();
677
+ $('.ui-colorpicker-map-layer-2', e).css({'background-position': '0 -1300px', 'opacity': ''}).show();
678
+ break;
679
+
680
+ case 'g':
681
+ $('.ui-colorpicker-map-layer-1', e).css({'background-position': '0 -1560px', 'opacity': ''}).show();
682
+ $('.ui-colorpicker-map-layer-2', e).css({'background-position': '0 -1820px', 'opacity': ''}).show();
683
+ break;
684
+
685
+ case 'b':
686
+ $('.ui-colorpicker-map-layer-1', e).css({'background-position': '0 -2080px', 'opacity': ''}).show();
687
+ $('.ui-colorpicker-map-layer-2', e).css({'background-position': '0 -2340px', 'opacity': ''}).show();
688
+ break;
689
+ }
690
+ that.repaint();
691
+ };
692
+
693
+ this.repaint = function () {
694
+ var div = $('.ui-colorpicker-map-layer-pointer', e),
695
+ x = 0,
696
+ y = 0;
697
+
698
+ switch (inst.mode) {
699
+ case 'h':
700
+ x = inst.color.getHSV().s * div.width();
701
+ y = (1 - inst.color.getHSV().v) * div.width();
702
+ $(e).css('background-color', inst.color.copy().normalize().toCSS());
703
+ break;
704
+
705
+ case 's':
706
+ case 'a':
707
+ x = inst.color.getHSV().h * div.width();
708
+ y = (1 - inst.color.getHSV().v) * div.width();
709
+ $('.ui-colorpicker-map-layer-2', e).css('opacity', 1 - inst.color.getHSV().s);
710
+ break;
711
+
712
+ case 'v':
713
+ x = inst.color.getHSV().h * div.width();
714
+ y = (1 - inst.color.getHSV().s) * div.width();
715
+ $('.ui-colorpicker-map-layer-1', e).css('opacity', inst.color.getHSV().v);
716
+ break;
717
+
718
+ case 'r':
719
+ x = inst.color.getRGB().b * div.width();
720
+ y = (1 - inst.color.getRGB().g) * div.width();
721
+ $('.ui-colorpicker-map-layer-2', e).css('opacity', inst.color.getRGB().r);
722
+ break;
723
+
724
+ case 'g':
725
+ x = inst.color.getRGB().b * div.width();
726
+ y = (1 - inst.color.getRGB().r) * div.width();
727
+ $('.ui-colorpicker-map-layer-2', e).css('opacity', inst.color.getRGB().g);
728
+ break;
729
+
730
+ case 'b':
731
+ x = inst.color.getRGB().r * div.width();
732
+ y = (1 - inst.color.getRGB().g) * div.width();
733
+ $('.ui-colorpicker-map-layer-2', e).css('opacity', inst.color.getRGB().b);
734
+ break;
735
+ }
736
+
737
+ if (inst.options.alpha) {
738
+ $('.ui-colorpicker-map-layer-alpha', e).css('opacity', 1 - inst.color.getAlpha());
739
+ }
740
+
741
+ $('.ui-colorpicker-map-pointer', e).css({
742
+ 'left': x - 7,
743
+ 'top': y - 7
744
+ });
745
+ };
746
+
747
+ this.init = function () {
748
+ e = $(_html()).appendTo($('.ui-colorpicker-map-container', inst.dialog));
749
+
750
+ e.bind('mousedown', _mousedown);
751
+ };
752
+ },
753
+
754
+ bar: function (inst) {
755
+ var that = this,
756
+ e = null,
757
+ _mousedown, _mouseup, _mousemove, _html;
758
+
759
+ _mousedown = function (event) {
760
+ if (!inst.opened) {
761
+ return;
762
+ }
763
+
764
+ var div = $('.ui-colorpicker-bar-layer-pointer', e),
765
+ offset = div.offset(),
766
+ width = div.width(),
767
+ height = div.height(),
768
+ x = event.pageX - offset.left,
769
+ y = event.pageY - offset.top;
770
+
771
+ if (x >= 0 && x < width && y >= 0 && y < height) {
772
+ event.stopImmediatePropagation();
773
+ event.preventDefault();
774
+ e.unbind('mousedown', _mousedown);
775
+ $(document).bind('mouseup', _mouseup);
776
+ $(document).bind('mousemove', _mousemove);
777
+ _mousemove(event);
778
+ }
779
+ };
780
+
781
+ _mouseup = function (event) {
782
+ event.stopImmediatePropagation();
783
+ event.preventDefault();
784
+ $(document).unbind('mouseup', _mouseup);
785
+ $(document).unbind('mousemove', _mousemove);
786
+ e.bind('mousedown', _mousedown);
787
+ };
788
+
789
+ _mousemove = function (event) {
790
+ event.stopImmediatePropagation();
791
+ event.preventDefault();
792
+
793
+ if (event.pageY === that.y) {
794
+ return;
795
+ }
796
+ that.y = event.pageY;
797
+
798
+ var div = $('.ui-colorpicker-bar-layer-pointer', e),
799
+ offset = div.offset(),
800
+ height = div.height(),
801
+ y = event.pageY - offset.top;
802
+
803
+ y = Math.max(0, Math.min(y / height, 1));
804
+
805
+ // interpret values
806
+ switch (inst.mode) {
807
+ case 'h':
808
+ inst.color.setHSV(1 - y, null, null);
809
+ break;
810
+
811
+ case 's':
812
+ inst.color.setHSV(null, 1 - y, null);
813
+ break;
814
+
815
+ case 'v':
816
+ inst.color.setHSV(null, null, 1 - y);
817
+ break;
818
+
819
+ case 'r':
820
+ inst.color.setRGB(1 - y, null, null);
821
+ break;
822
+
823
+ case 'g':
824
+ inst.color.setRGB(null, 1 - y, null);
825
+ break;
826
+
827
+ case 'b':
828
+ inst.color.setRGB(null, null, 1 - y);
829
+ break;
830
+
831
+ case 'a':
832
+ inst.color.setAlpha(1 - y);
833
+ break;
834
+ }
835
+
836
+ inst._change();
837
+ };
838
+
839
+ _html = function () {
840
+ var html = '<div class="ui-colorpicker-bar ui-colorpicker-border">'
841
+ + '<span class="ui-colorpicker-bar-layer-1">&nbsp;</span>'
842
+ + '<span class="ui-colorpicker-bar-layer-2">&nbsp;</span>'
843
+ + '<span class="ui-colorpicker-bar-layer-3">&nbsp;</span>'
844
+ + '<span class="ui-colorpicker-bar-layer-4">&nbsp;</span>';
845
+
846
+ if (inst.options.alpha) {
847
+ html += '<span class="ui-colorpicker-bar-layer-alpha">&nbsp;</span>'
848
+ + '<span class="ui-colorpicker-bar-layer-alphabar">&nbsp;</span>';
849
+ }
850
+
851
+ html += '<span class="ui-colorpicker-bar-layer-pointer"><span class="ui-colorpicker-bar-pointer"></span></span></div>';
852
+
853
+ return html;
854
+ };
855
+
856
+ this.update = function () {
857
+ switch (inst.mode) {
858
+ case 'h':
859
+ case 's':
860
+ case 'v':
861
+ case 'r':
862
+ case 'g':
863
+ case 'b':
864
+ $('.ui-colorpicker-bar-layer-alpha', e).show();
865
+ $('.ui-colorpicker-bar-layer-alphabar', e).hide();
866
+ break;
867
+
868
+ case 'a':
869
+ $('.ui-colorpicker-bar-layer-alpha', e).hide();
870
+ $('.ui-colorpicker-bar-layer-alphabar', e).show();
871
+ break;
872
+ }
873
+
874
+ switch (inst.mode) {
875
+ case 'h':
876
+ $('.ui-colorpicker-bar-layer-1', e).css({'background-position': '0 0', 'opacity': ''}).show();
877
+ $('.ui-colorpicker-bar-layer-2', e).hide();
878
+ $('.ui-colorpicker-bar-layer-3', e).hide();
879
+ $('.ui-colorpicker-bar-layer-4', e).hide();
880
+ break;
881
+
882
+ case 's':
883
+ $('.ui-colorpicker-bar-layer-1', e).css({'background-position': '0 -260px', 'opacity': ''}).show();
884
+ $('.ui-colorpicker-bar-layer-2', e).css({'background-position': '0 -520px', 'opacity': ''}).show();
885
+ $('.ui-colorpicker-bar-layer-3', e).hide();
886
+ $('.ui-colorpicker-bar-layer-4', e).hide();
887
+ break;
888
+
889
+ case 'v':
890
+ $('.ui-colorpicker-bar-layer-1', e).css({'background-position': '0 -520px', 'opacity': ''}).show();
891
+ $('.ui-colorpicker-bar-layer-2', e).hide();
892
+ $('.ui-colorpicker-bar-layer-3', e).hide();
893
+ $('.ui-colorpicker-bar-layer-4', e).hide();
894
+ break;
895
+
896
+ case 'r':
897
+ $('.ui-colorpicker-bar-layer-1', e).css({'background-position': '0 -1560px', 'opacity': ''}).show();
898
+ $('.ui-colorpicker-bar-layer-2', e).css({'background-position': '0 -1300px', 'opacity': ''}).show();
899
+ $('.ui-colorpicker-bar-layer-3', e).css({'background-position': '0 -780px', 'opacity': ''}).show();
900
+ $('.ui-colorpicker-bar-layer-4', e).css({'background-position': '0 -1040px', 'opacity': ''}).show();
901
+ break;
902
+
903
+ case 'g':
904
+ $('.ui-colorpicker-bar-layer-1', e).css({'background-position': '0 -2600px', 'opacity': ''}).show();
905
+ $('.ui-colorpicker-bar-layer-2', e).css({'background-position': '0 -2340px', 'opacity': ''}).show();
906
+ $('.ui-colorpicker-bar-layer-3', e).css({'background-position': '0 -1820px', 'opacity': ''}).show();
907
+ $('.ui-colorpicker-bar-layer-4', e).css({'background-position': '0 -2080px', 'opacity': ''}).show();
908
+ break;
909
+
910
+ case 'b':
911
+ $('.ui-colorpicker-bar-layer-1', e).css({'background-position': '0 -3640px', 'opacity': ''}).show();
912
+ $('.ui-colorpicker-bar-layer-2', e).css({'background-position': '0 -3380px', 'opacity': ''}).show();
913
+ $('.ui-colorpicker-bar-layer-3', e).css({'background-position': '0 -2860px', 'opacity': ''}).show();
914
+ $('.ui-colorpicker-bar-layer-4', e).css({'background-position': '0 -3120px', 'opacity': ''}).show();
915
+ break;
916
+
917
+ case 'a':
918
+ $('.ui-colorpicker-bar-layer-1', e).hide();
919
+ $('.ui-colorpicker-bar-layer-2', e).hide();
920
+ $('.ui-colorpicker-bar-layer-3', e).hide();
921
+ $('.ui-colorpicker-bar-layer-4', e).hide();
922
+ break;
923
+ }
924
+ that.repaint();
925
+ };
926
+
927
+ this.repaint = function () {
928
+ var div = $('.ui-colorpicker-bar-layer-pointer', e),
929
+ y = 0;
930
+
931
+ switch (inst.mode) {
932
+ case 'h':
933
+ y = (1 - inst.color.getHSV().h) * div.height();
934
+ break;
935
+
936
+ case 's':
937
+ y = (1 - inst.color.getHSV().s) * div.height();
938
+ $('.ui-colorpicker-bar-layer-2', e).css('opacity', 1 - inst.color.getHSV().v);
939
+ $(e).css('background-color', inst.color.copy().normalize().toCSS());
940
+ break;
941
+
942
+ case 'v':
943
+ y = (1 - inst.color.getHSV().v) * div.height();
944
+ $(e).css('background-color', inst.color.copy().normalize().toCSS());
945
+ break;
946
+
947
+ case 'r':
948
+ y = (1 - inst.color.getRGB().r) * div.height();
949
+ $('.ui-colorpicker-bar-layer-2', e).css('opacity', Math.max(0, (inst.color.getRGB().b - inst.color.getRGB().g)));
950
+ $('.ui-colorpicker-bar-layer-3', e).css('opacity', Math.max(0, (inst.color.getRGB().g - inst.color.getRGB().b)));
951
+ $('.ui-colorpicker-bar-layer-4', e).css('opacity', Math.min(inst.color.getRGB().b, inst.color.getRGB().g));
952
+ break;
953
+
954
+ case 'g':
955
+ y = (1 - inst.color.getRGB().g) * div.height();
956
+ $('.ui-colorpicker-bar-layer-2', e).css('opacity', Math.max(0, (inst.color.getRGB().b - inst.color.getRGB().r)));
957
+ $('.ui-colorpicker-bar-layer-3', e).css('opacity', Math.max(0, (inst.color.getRGB().r - inst.color.getRGB().b)));
958
+ $('.ui-colorpicker-bar-layer-4', e).css('opacity', Math.min(inst.color.getRGB().r, inst.color.getRGB().b));
959
+ break;
960
+
961
+ case 'b':
962
+ y = (1 - inst.color.getRGB().b) * div.height();
963
+ $('.ui-colorpicker-bar-layer-2', e).css('opacity', Math.max(0, (inst.color.getRGB().r - inst.color.getRGB().g)));
964
+ $('.ui-colorpicker-bar-layer-3', e).css('opacity', Math.max(0, (inst.color.getRGB().g - inst.color.getRGB().r)));
965
+ $('.ui-colorpicker-bar-layer-4', e).css('opacity', Math.min(inst.color.getRGB().r, inst.color.getRGB().g));
966
+ break;
967
+
968
+ case 'a':
969
+ y = (1 - inst.color.getAlpha()) * div.height();
970
+ $(e).css('background-color', inst.color.copy().normalize().toCSS());
971
+ break;
972
+ }
973
+
974
+ if (inst.mode !== 'a') {
975
+ $('.ui-colorpicker-bar-layer-alpha', e).css('opacity', 1 - inst.color.getAlpha());
976
+ }
977
+
978
+ $('.ui-colorpicker-bar-pointer', e).css('top', y - 3);
979
+ };
980
+
981
+ this.init = function () {
982
+ e = $(_html()).appendTo($('.ui-colorpicker-bar-container', inst.dialog));
983
+
984
+ e.bind('mousedown', _mousedown);
985
+ };
986
+ },
987
+
988
+ preview: function (inst) {
989
+ var that = this,
990
+ e = null,
991
+ _html;
992
+
993
+ _html = function () {
994
+ return '<div class="ui-colorpicker-preview ui-colorpicker-border">'
995
+ + '<div class="ui-colorpicker-preview-initial"><div class="ui-colorpicker-preview-initial-alpha"></div></div>'
996
+ + '<div class="ui-colorpicker-preview-current"><div class="ui-colorpicker-preview-current-alpha"></div></div>'
997
+ + '</div>';
998
+ };
999
+
1000
+ this.init = function () {
1001
+ e = $(_html()).appendTo($('.ui-colorpicker-preview-container', inst.dialog));
1002
+
1003
+ $('.ui-colorpicker-preview-initial', e).click(function () {
1004
+ inst.color = inst.currentColor.copy();
1005
+ inst._change();
1006
+ });
1007
+
1008
+ };
1009
+
1010
+ this.update = function () {
1011
+ if (inst.options.alpha) {
1012
+ $('.ui-colorpicker-preview-initial-alpha, .ui-colorpicker-preview-current-alpha', e).show();
1013
+ } else {
1014
+ $('.ui-colorpicker-preview-initial-alpha, .ui-colorpicker-preview-current-alpha', e).hide();
1015
+ }
1016
+
1017
+ this.repaint();
1018
+ };
1019
+
1020
+ this.repaint = function () {
1021
+ $('.ui-colorpicker-preview-initial', e).css('background-color', inst.currentColor.toCSS()).attr('title', inst.currentColor.toHex());
1022
+ $('.ui-colorpicker-preview-initial-alpha', e).css('opacity', 1 - inst.currentColor.getAlpha());
1023
+ $('.ui-colorpicker-preview-current', e).css('background-color', inst.color.toCSS()).attr('title', inst.color.toHex());
1024
+ $('.ui-colorpicker-preview-current-alpha', e).css('opacity', 1 - inst.color.getAlpha());
1025
+ };
1026
+ },
1027
+
1028
+ hsv: function (inst) {
1029
+ var that = this,
1030
+ e = null,
1031
+ _html;
1032
+
1033
+ _html = function () {
1034
+ var html = '';
1035
+
1036
+ if (inst.options.hsv) {
1037
+ html += '<div class="ui-colorpicker-hsv-h"><input class="ui-colorpicker-mode" type="radio" value="h"/><label>' + inst._getRegional('hsvH') + '</label><input class="ui-colorpicker-number" type="number" min="0" max="360" size="10"/><span class="ui-colorpicker-unit">&deg;</span></div>'
1038
+ + '<div class="ui-colorpicker-hsv-s"><input class="ui-colorpicker-mode" type="radio" value="s"/><label>' + inst._getRegional('hsvS') + '</label><input class="ui-colorpicker-number" type="number" min="0" max="100" size="10"/><span class="ui-colorpicker-unit">%</span></div>'
1039
+ + '<div class="ui-colorpicker-hsv-v"><input class="ui-colorpicker-mode" type="radio" value="v"/><label>' + inst._getRegional('hsvV') + '</label><input class="ui-colorpicker-number" type="number" min="0" max="100" size="10"/><span class="ui-colorpicker-unit">%</span></div>';
1040
+ }
1041
+
1042
+ return '<div class="ui-colorpicker-hsv">' + html + '</div>';
1043
+ };
1044
+
1045
+ this.init = function () {
1046
+ e = $(_html()).appendTo($('.ui-colorpicker-hsv-container', inst.dialog));
1047
+
1048
+ $('.ui-colorpicker-mode', e).click(function () {
1049
+ inst.mode = $(this).val();
1050
+ inst._updateAllParts();
1051
+ });
1052
+
1053
+ $('.ui-colorpicker-number', e).bind('change keyup', function () {
1054
+ inst.color.setHSV(
1055
+ $('.ui-colorpicker-hsv-h .ui-colorpicker-number', e).val() / 360,
1056
+ $('.ui-colorpicker-hsv-s .ui-colorpicker-number', e).val() / 100,
1057
+ $('.ui-colorpicker-hsv-v .ui-colorpicker-number', e).val() / 100
1058
+ );
1059
+ inst._change();
1060
+ });
1061
+ };
1062
+
1063
+ this.repaint = function () {
1064
+ var hsv = inst.color.getHSV();
1065
+ hsv.h *= 360;
1066
+ hsv.s *= 100;
1067
+ hsv.v *= 100;
1068
+
1069
+ $.each(hsv, function (index, value) {
1070
+ var input = $('.ui-colorpicker-hsv-' + index + ' .ui-colorpicker-number', e);
1071
+ value = Math.round(value);
1072
+ if (input.val() !== value) {
1073
+ input.val(value);
1074
+ }
1075
+ });
1076
+ };
1077
+
1078
+ this.update = function () {
1079
+ $('.ui-colorpicker-mode', e).each(function () {
1080
+ $(this).attr('checked', $(this).val() === inst.mode);
1081
+ });
1082
+ this.repaint();
1083
+ };
1084
+ },
1085
+
1086
+ rgb: function (inst) {
1087
+ var that = this,
1088
+ e = null,
1089
+ _html;
1090
+
1091
+ _html = function () {
1092
+ var html = '';
1093
+
1094
+ if (inst.options.rgb) {
1095
+ html += '<div class="ui-colorpicker-rgb-r"><input class="ui-colorpicker-mode" type="radio" value="r"/><label>' + inst._getRegional('rgbR') + '</label><input class="ui-colorpicker-number" type="number" min="0" max="255"/></div>'
1096
+ + '<div class="ui-colorpicker-rgb-g"><input class="ui-colorpicker-mode" type="radio" value="g"/><label>' + inst._getRegional('rgbG') + '</label><input class="ui-colorpicker-number" type="number" min="0" max="255"/></div>'
1097
+ + '<div class="ui-colorpicker-rgb-b"><input class="ui-colorpicker-mode" type="radio" value="b"/><label>' + inst._getRegional('rgbB') + '</label><input class="ui-colorpicker-number" type="number" min="0" max="255"/></div>';
1098
+ }
1099
+
1100
+ return '<div class="ui-colorpicker-rgb">' + html + '</div>';
1101
+ };
1102
+
1103
+ this.init = function () {
1104
+ e = $(_html()).appendTo($('.ui-colorpicker-rgb-container', inst.dialog));
1105
+
1106
+ $('.ui-colorpicker-mode', e).click(function () {
1107
+ inst.mode = $(this).val();
1108
+ inst._updateAllParts();
1109
+ });
1110
+
1111
+ $('.ui-colorpicker-number', e).bind('change keyup', function () {
1112
+ inst.color.setRGB(
1113
+ $('.ui-colorpicker-rgb-r .ui-colorpicker-number', e).val() / 255,
1114
+ $('.ui-colorpicker-rgb-g .ui-colorpicker-number', e).val() / 255,
1115
+ $('.ui-colorpicker-rgb-b .ui-colorpicker-number', e).val() / 255
1116
+ );
1117
+
1118
+ inst._change();
1119
+ });
1120
+ };
1121
+
1122
+ this.repaint = function () {
1123
+ $.each(inst.color.getRGB(), function (index, value) {
1124
+ var input = $('.ui-colorpicker-rgb-' + index + ' .ui-colorpicker-number', e);
1125
+ value = Math.round(value * 255);
1126
+ if (input.val() !== value) {
1127
+ input.val(value);
1128
+ }
1129
+ });
1130
+ };
1131
+
1132
+ this.update = function () {
1133
+ $('.ui-colorpicker-mode', e).each(function () {
1134
+ $(this).attr('checked', $(this).val() === inst.mode);
1135
+ });
1136
+ this.repaint();
1137
+ };
1138
+ },
1139
+
1140
+ lab: function (inst) {
1141
+ var that = this,
1142
+ part = null,
1143
+ html = function () {
1144
+ var html = '';
1145
+
1146
+ if (inst.options.hsv) {
1147
+ html += '<div class="ui-colorpicker-lab-l"><label>' + inst._getRegional('labL') + '</label><input class="ui-colorpicker-number" type="number" min="0" max="100"/></div>'
1148
+ + '<div class="ui-colorpicker-lab-a"><label>' + inst._getRegional('labA') + '</label><input class="ui-colorpicker-number" type="number" min="-128" max="127"/></div>'
1149
+ + '<div class="ui-colorpicker-lab-b"><label>' + inst._getRegional('labB') + '</label><input class="ui-colorpicker-number" type="number" min="-128" max="127"/></div>';
1150
+ }
1151
+
1152
+ return '<div class="ui-colorpicker-lab">' + html + '</div>';
1153
+ };
1154
+
1155
+ this.init = function () {
1156
+ var data = 0;
1157
+
1158
+ part = $(html()).appendTo($('.ui-colorpicker-lab-container', inst.dialog));
1159
+
1160
+ $('.ui-colorpicker-number', part).on('change keyup', function (event) {
1161
+ inst.color.setLAB(
1162
+ parseInt($('.ui-colorpicker-lab-l .ui-colorpicker-number', part).val(), 10) / 100,
1163
+ (parseInt($('.ui-colorpicker-lab-a .ui-colorpicker-number', part).val(), 10) + 128) / 255,
1164
+ (parseInt($('.ui-colorpicker-lab-b .ui-colorpicker-number', part).val(), 10) + 128) / 255
1165
+ );
1166
+ inst._change();
1167
+ });
1168
+ };
1169
+
1170
+ this.repaint = function () {
1171
+ var lab = inst.color.getLAB();
1172
+ lab.l *= 100;
1173
+ lab.a = (lab.a * 255) - 128;
1174
+ lab.b = (lab.b * 255) - 128;
1175
+
1176
+ $.each(lab, function (index, value) {
1177
+ var input = $('.ui-colorpicker-lab-' + index + ' .ui-colorpicker-number', part);
1178
+ value = Math.round(value);
1179
+ if (input.val() !== value) {
1180
+ input.val(value);
1181
+ }
1182
+ });
1183
+ };
1184
+
1185
+ this.update = function () {
1186
+ this.repaint();
1187
+ };
1188
+
1189
+ },
1190
+
1191
+ cmyk: function (inst) {
1192
+ var that = this,
1193
+ part = null,
1194
+ html = function () {
1195
+ var html = '';
1196
+
1197
+ if (inst.options.hsv) {
1198
+ html += '<div class="ui-colorpicker-cmyk-c"><label>' + inst._getRegional('cmykC') + '</label><input class="ui-colorpicker-number" type="number" min="0" max="100"/><span class="ui-colorpicker-unit">%</span></div>'
1199
+ + '<div class="ui-colorpicker-cmyk-m"><label>' + inst._getRegional('cmykM') + '</label><input class="ui-colorpicker-number" type="number" min="0" max="100"/><span class="ui-colorpicker-unit">%</span></div>'
1200
+ + '<div class="ui-colorpicker-cmyk-y"><label>' + inst._getRegional('cmykY') + '</label><input class="ui-colorpicker-number" type="number" min="0" max="100"/><span class="ui-colorpicker-unit">%</span></div>'
1201
+ + '<div class="ui-colorpicker-cmyk-k"><label>' + inst._getRegional('cmykK') + '</label><input class="ui-colorpicker-number" type="number" min="0" max="100"/><span class="ui-colorpicker-unit">%</span></div>';
1202
+ }
1203
+
1204
+ return '<div class="ui-colorpicker-cmyk">' + html + '</div>';
1205
+ };
1206
+
1207
+ this.init = function () {
1208
+ part = $(html()).appendTo($('.ui-colorpicker-cmyk-container', inst.dialog));
1209
+
1210
+ $('.ui-colorpicker-number', part).on('change keyup', function (event) {
1211
+ inst.color.setCMYK(
1212
+ parseInt($('.ui-colorpicker-cmyk-c .ui-colorpicker-number', part).val(), 10) / 100,
1213
+ parseInt($('.ui-colorpicker-cmyk-m .ui-colorpicker-number', part).val(), 10) / 100,
1214
+ parseInt($('.ui-colorpicker-cmyk-y .ui-colorpicker-number', part).val(), 10) / 100,
1215
+ parseInt($('.ui-colorpicker-cmyk-k .ui-colorpicker-number', part).val(), 10) / 100
1216
+ );
1217
+ inst._change();
1218
+ });
1219
+ };
1220
+
1221
+ this.repaint = function () {
1222
+ $.each(inst.color.getCMYK(), function (index, value) {
1223
+ var input = $('.ui-colorpicker-cmyk-' + index + ' .ui-colorpicker-number', part);
1224
+ value = Math.round(value * 100);
1225
+ if (input.val() !== value) {
1226
+ input.val(value);
1227
+ }
1228
+ });
1229
+ };
1230
+
1231
+ this.update = function () {
1232
+ this.repaint();
1233
+ };
1234
+
1235
+ },
1236
+
1237
+ alpha: function (inst) {
1238
+ var that = this,
1239
+ e = null,
1240
+ _html;
1241
+
1242
+ _html = function () {
1243
+ var html = '';
1244
+
1245
+ if (inst.options.alpha) {
1246
+ html += '<div class="ui-colorpicker-a"><input class="ui-colorpicker-mode" name="mode" type="radio" value="a"/><label>' + inst._getRegional('alphaA') + '</label><input class="ui-colorpicker-number" type="number" min="0" max="100"/><span class="ui-colorpicker-unit">%</span></div>';
1247
+ }
1248
+
1249
+ return '<div class="ui-colorpicker-alpha">' + html + '</div>';
1250
+ };
1251
+
1252
+ this.init = function () {
1253
+ e = $(_html()).appendTo($('.ui-colorpicker-alpha-container', inst.dialog));
1254
+
1255
+ $('.ui-colorpicker-mode', e).click(function () {
1256
+ inst.mode = $(this).val();
1257
+ inst._updateAllParts();
1258
+ });
1259
+
1260
+ $('.ui-colorpicker-number', e).bind('change keyup', function () {
1261
+ inst.color.setAlpha($('.ui-colorpicker-a .ui-colorpicker-number', e).val() / 100);
1262
+ inst._change();
1263
+ });
1264
+ };
1265
+
1266
+ this.update = function () {
1267
+ $('.ui-colorpicker-mode', e).each(function () {
1268
+ $(this).attr('checked', $(this).val() === inst.mode);
1269
+ });
1270
+ this.repaint();
1271
+ };
1272
+
1273
+ this.repaint = function () {
1274
+ var input = $('.ui-colorpicker-a .ui-colorpicker-number', e),
1275
+ value = Math.round(inst.color.getAlpha() * 100);
1276
+ if (!input.is(':focus') && input.val() !== value) {
1277
+ input.val(value);
1278
+ }
1279
+ };
1280
+ },
1281
+
1282
+ hex: function (inst) {
1283
+ var that = this,
1284
+ e = null,
1285
+ _html;
1286
+
1287
+ _html = function () {
1288
+ var html = '';
1289
+
1290
+ if (inst.options.alpha) {
1291
+ html += '<input class="ui-colorpicker-hex-alpha" type="text" maxlength="2" size="2"/>';
1292
+ }
1293
+
1294
+ html += '<input class="ui-colorpicker-hex-input" type="text" maxlength="6" size="6"/>';
1295
+
1296
+ return '<div class="ui-colorpicker-hex"><label>#</label>' + html + '</div>';
1297
+ };
1298
+
1299
+ this.init = function () {
1300
+ e = $(_html()).appendTo($('.ui-colorpicker-hex-container', inst.dialog));
1301
+
1302
+ // repeat here makes the invalid input disappear faster
1303
+ $('.ui-colorpicker-hex-input', e).bind('change keydown keyup', function (a, b, c) {
1304
+ if (/[^a-fA-F0-9]/.test($(this).val())) {
1305
+ $(this).val($(this).val().replace(/[^a-fA-F0-9]/, ''));
1306
+ }
1307
+ });
1308
+
1309
+ $('.ui-colorpicker-hex-input', e).bind('change keyup', function () {
1310
+ // repeat here makes sure that the invalid input doesn't get parsed
1311
+ inst.color = _parseHex($(this).val()).setAlpha(inst.color.getAlpha());
1312
+ inst._change();
1313
+ });
1314
+
1315
+ $('.ui-colorpicker-hex-alpha', e).bind('change keydown keyup', function () {
1316
+ if (/[^a-fA-F0-9]/.test($(this).val())) {
1317
+ $(this).val($(this).val().replace(/[^a-fA-F0-9]/, ''));
1318
+ }
1319
+ });
1320
+
1321
+ $('.ui-colorpicker-hex-alpha', e).bind('change keyup', function () {
1322
+ inst.color.setAlpha(parseInt($('.ui-colorpicker-hex-alpha', e).val(), 16) / 255);
1323
+ inst._change();
1324
+ });
1325
+ };
1326
+
1327
+ this.update = function () {
1328
+ this.repaint();
1329
+ };
1330
+
1331
+ this.repaint = function () {
1332
+ if (!$('.ui-colorpicker-hex-input', e).is(':focus')) {
1333
+ $('.ui-colorpicker-hex-input', e).val(inst.color.toHex(true));
1334
+ }
1335
+
1336
+ if (!$('.ui-colorpicker-hex-alpha', e).is(':focus')) {
1337
+ $('.ui-colorpicker-hex-alpha', e).val(_intToHex(inst.color.getAlpha() * 255));
1338
+ }
1339
+ };
1340
+ },
1341
+
1342
+ swatches: function (inst) {
1343
+ var that = this,
1344
+ part = null,
1345
+ html = function () {
1346
+ var html = '';
1347
+
1348
+ $.each(inst.options.swatches, function (name, color) {
1349
+ var c = new Color(color.r, color.g, color.b),
1350
+ css = c.toCSS();
1351
+ html += '<div class="ui-colorpicker-swatch" style="background-color: ' + css + '" title="' + name + '"></div>';
1352
+ });
1353
+
1354
+ return '<div class="ui-colorpicker-swatches ui-colorpicker-border">' + html + '</div>';
1355
+ };
1356
+
1357
+ this.init = function () {
1358
+ part = $(html()).appendTo($('.ui-colorpicker-swatches-container', inst.dialog));
1359
+
1360
+ $('.ui-colorpicker-swatch', part).click(function () {
1361
+ inst.color = _parseColor($(this).css('background-color'));
1362
+ inst._change();
1363
+ });
1364
+ };
1365
+ },
1366
+
1367
+ footer: function (inst) {
1368
+ var that = this,
1369
+ part = null,
1370
+ id_transparent = 'ui-colorpicker-special-transparent-'+_colorpicker_index,
1371
+ id_none = 'ui-colorpicker-special-none-'+_colorpicker_index,
1372
+ html = function () {
1373
+ var html = '';
1374
+
1375
+ if (inst.options.alpha || (!inst.inline && inst.options.showNoneButton)) {
1376
+ html += '<div class="ui-colorpicker-buttonset">';
1377
+
1378
+ if (inst.options.alpha) {
1379
+ html += '<input type="radio" name="ui-colorpicker-special" id="'+id_transparent+'" class="ui-colorpicker-special-transparent"/><label for="'+id_transparent+'">' + inst._getRegional('transparent') + '</label>';
1380
+ }
1381
+ if (!inst.inline && inst.options.showNoneButton) {
1382
+ html += '<input type="radio" name="ui-colorpicker-special" id="'+id_none+'" class="ui-colorpicker-special-none"><label for="'+id_none+'">' + inst._getRegional('none') + '</label>';
1383
+ }
1384
+ html += '</div>';
1385
+ }
1386
+
1387
+ if (!inst.inline) {
1388
+ html += '<div class="ui-dialog-buttonset">';
1389
+ if (inst.options.showCancelButton) {
1390
+ html += '<button class="ui-colorpicker-cancel">' + inst._getRegional('cancel') + '</button>';
1391
+ }
1392
+ html += '<button class="ui-colorpicker-ok">' + inst._getRegional('ok') + '</button>';
1393
+ html += '</div>';
1394
+ }
1395
+
1396
+ return '<div class="ui-dialog-buttonpane ui-widget-content">' + html + '</div>';
1397
+ };
1398
+
1399
+ this.init = function () {
1400
+ part = $(html()).appendTo(inst.dialog);
1401
+
1402
+ $('.ui-colorpicker-ok', part).button().click(function () {
1403
+ inst.close();
1404
+ });
1405
+
1406
+ $('.ui-colorpicker-cancel', part).button().click(function () {
1407
+ inst.color = inst.currentColor.copy();
1408
+ inst._change(inst.color.set);
1409
+ inst.close();
1410
+ });
1411
+
1412
+ //inst._getRegional('transparent')
1413
+ $('.ui-colorpicker-buttonset', part).buttonset();
1414
+
1415
+ $('.ui-colorpicker-special-color', part).click(function () {
1416
+ inst._change();
1417
+ });
1418
+
1419
+ $('#'+id_none, part).click(function () {
1420
+ inst._change(false);
1421
+ });
1422
+
1423
+ $('#'+id_transparent, part).click(function () {
1424
+ inst.color.setAlpha(0);
1425
+ inst._change();
1426
+ });
1427
+ };
1428
+
1429
+ this.repaint = function () {
1430
+ if (!inst.color.set) {
1431
+ $('.ui-colorpicker-special-none', part).attr('checked', true).button( "refresh" );
1432
+ } else if (inst.color.getAlpha() == 0) {
1433
+ $('.ui-colorpicker-special-transparent', part).attr('checked', true).button( "refresh" );
1434
+ } else {
1435
+ $('input', part).attr('checked', false).button( "refresh" );
1436
+ }
1437
+
1438
+ $('.ui-colorpicker-cancel', part).button(inst.changed ? 'enable' : 'disable');
1439
+ };
1440
+
1441
+ this.update = function () {};
1442
+ }
1443
+ },
1444
+
1445
+ Color = function () {
1446
+ var spaces = { rgb: {r: 0, g: 0, b: 0},
1447
+ hsv: {h: 0, s: 0, v: 0},
1448
+ hsl: {h: 0, s: 0, l: 0},
1449
+ lab: {l: 0, a: 0, b: 0},
1450
+ cmyk: {c: 0, m: 0, y: 0, k: 1}
1451
+ },
1452
+ a = 1,
1453
+ arg,
1454
+ args = arguments,
1455
+ _clip = function(v) {
1456
+ if (isNaN(v) || v === null) {
1457
+ return 0;
1458
+ }
1459
+ if (typeof v == 'string') {
1460
+ v = parseInt(v, 10);
1461
+ }
1462
+ return Math.max(0, Math.min(v, 1));
1463
+ },
1464
+ _hexify = function (number) {
1465
+ var digits = '0123456789abcdef',
1466
+ lsd = number % 16,
1467
+ msd = (number - lsd) / 16,
1468
+ hexified = digits.charAt(msd) + digits.charAt(lsd);
1469
+ return hexified;
1470
+ },
1471
+ _rgb_to_xyz = function(rgb) {
1472
+ var r = (rgb.r > 0.04045) ? Math.pow((rgb.r + 0.055) / 1.055, 2.4) : rgb.r / 12.92,
1473
+ g = (rgb.g > 0.04045) ? Math.pow((rgb.g + 0.055) / 1.055, 2.4) : rgb.g / 12.92,
1474
+ b = (rgb.b > 0.04045) ? Math.pow((rgb.b + 0.055) / 1.055, 2.4) : rgb.b / 12.92;
1475
+
1476
+ return {
1477
+ x: r * 0.4124 + g * 0.3576 + b * 0.1805,
1478
+ y: r * 0.2126 + g * 0.7152 + b * 0.0722,
1479
+ z: r * 0.0193 + g * 0.1192 + b * 0.9505
1480
+ };
1481
+ },
1482
+ _xyz_to_rgb = function(xyz) {
1483
+ var rgb = {
1484
+ r: xyz.x * 3.2406 + xyz.y * -1.5372 + xyz.z * -0.4986,
1485
+ g: xyz.x * -0.9689 + xyz.y * 1.8758 + xyz.z * 0.0415,
1486
+ b: xyz.x * 0.0557 + xyz.y * -0.2040 + xyz.z * 1.0570
1487
+ };
1488
+
1489
+ rgb.r = (rgb.r > 0.0031308) ? 1.055 * Math.pow(rgb.r, (1 / 2.4)) - 0.055 : 12.92 * rgb.r;
1490
+ rgb.g = (rgb.g > 0.0031308) ? 1.055 * Math.pow(rgb.g, (1 / 2.4)) - 0.055 : 12.92 * rgb.g;
1491
+ rgb.b = (rgb.b > 0.0031308) ? 1.055 * Math.pow(rgb.b, (1 / 2.4)) - 0.055 : 12.92 * rgb.b;
1492
+
1493
+ return rgb;
1494
+ },
1495
+ _rgb_to_hsv = function(rgb) {
1496
+ var minVal = Math.min(rgb.r, rgb.g, rgb.b),
1497
+ maxVal = Math.max(rgb.r, rgb.g, rgb.b),
1498
+ delta = maxVal - minVal,
1499
+ del_R, del_G, del_B,
1500
+ hsv = {
1501
+ h: 0,
1502
+ s: 0,
1503
+ v: maxVal
1504
+ };
1505
+
1506
+ if (delta === 0) {
1507
+ hsv.h = 0;
1508
+ hsv.s = 0;
1509
+ } else {
1510
+ hsv.s = delta / maxVal;
1511
+
1512
+ del_R = (((maxVal - rgb.r) / 6) + (delta / 2)) / delta;
1513
+ del_G = (((maxVal - rgb.g) / 6) + (delta / 2)) / delta;
1514
+ del_B = (((maxVal - rgb.b) / 6) + (delta / 2)) / delta;
1515
+
1516
+ if (rgb.r === maxVal) {
1517
+ hsv.h = del_B - del_G;
1518
+ } else if (rgb.g === maxVal) {
1519
+ hsv.h = (1 / 3) + del_R - del_B;
1520
+ } else if (rgb.b === maxVal) {
1521
+ hsv.h = (2 / 3) + del_G - del_R;
1522
+ }
1523
+
1524
+ if (hsv.h < 0) {
1525
+ hsv.h += 1;
1526
+ } else if (hsv.h > 1) {
1527
+ hsv.h -= 1;
1528
+ }
1529
+ }
1530
+
1531
+ return hsv;
1532
+ },
1533
+ _hsv_to_rgb = function(hsv) {
1534
+ var rgb = {
1535
+ r: 0,
1536
+ g: 0,
1537
+ b: 0
1538
+ },
1539
+ var_h,
1540
+ var_i,
1541
+ var_1,
1542
+ var_2,
1543
+ var_3;
1544
+
1545
+ if (hsv.s === 0) {
1546
+ rgb.r = rgb.g = rgb.b = hsv.v;
1547
+ } else {
1548
+ var_h = hsv.h === 1 ? 0 : hsv.h * 6;
1549
+ var_i = Math.floor(var_h);
1550
+ var_1 = hsv.v * (1 - hsv.s);
1551
+ var_2 = hsv.v * (1 - hsv.s * (var_h - var_i));
1552
+ var_3 = hsv.v * (1 - hsv.s * (1 - (var_h - var_i)));
1553
+
1554
+ if (var_i === 0) {
1555
+ rgb.r = hsv.v;
1556
+ rgb.g = var_3;
1557
+ rgb.b = var_1;
1558
+ } else if (var_i === 1) {
1559
+ rgb.r = var_2;
1560
+ rgb.g = hsv.v;
1561
+ rgb.b = var_1;
1562
+ } else if (var_i === 2) {
1563
+ rgb.r = var_1;
1564
+ rgb.g = hsv.v;
1565
+ rgb.b = var_3;
1566
+ } else if (var_i === 3) {
1567
+ rgb.r = var_1;
1568
+ rgb.g = var_2;
1569
+ rgb.b = hsv.v;
1570
+ } else if (var_i === 4) {
1571
+ rgb.r = var_3;
1572
+ rgb.g = var_1;
1573
+ rgb.b = hsv.v;
1574
+ } else {
1575
+ rgb.r = hsv.v;
1576
+ rgb.g = var_1;
1577
+ rgb.b = var_2;
1578
+ }
1579
+ }
1580
+
1581
+ return rgb;
1582
+ },
1583
+ _rgb_to_hsl = function(rgb) {
1584
+ var minVal = Math.min(rgb.r, rgb.g, rgb.b),
1585
+ maxVal = Math.max(rgb.r, rgb.g, rgb.b),
1586
+ delta = maxVal - minVal,
1587
+ del_R, del_G, del_B,
1588
+ hsl = {
1589
+ h: 0,
1590
+ s: 0,
1591
+ l: (maxVal + minVal) / 2
1592
+ };
1593
+
1594
+ if (delta === 0) {
1595
+ hsl.h = 0;
1596
+ hsl.s = 0;
1597
+ } else {
1598
+ hsl.s = hsl.l < 0.5 ? delta / (maxVal + minVal) : delta / (2 - maxVal - minVal);
1599
+
1600
+ del_R = (((maxVal - rgb.r) / 6) + (delta / 2)) / delta;
1601
+ del_G = (((maxVal - rgb.g) / 6) + (delta / 2)) / delta;
1602
+ del_B = (((maxVal - rgb.b) / 6) + (delta / 2)) / delta;
1603
+
1604
+ if (rgb.r === maxVal) {
1605
+ hsl.h = del_B - del_G;
1606
+ } else if (rgb.g === maxVal) {
1607
+ hsl.h = (1 / 3) + del_R - del_B;
1608
+ } else if (rgb.b === maxVal) {
1609
+ hsl.h = (2 / 3) + del_G - del_R;
1610
+ }
1611
+
1612
+ if (hsl.h < 0) {
1613
+ hsl.h += 1;
1614
+ } else if (hsl.h > 1) {
1615
+ hsl.h -= 1;
1616
+ }
1617
+ }
1618
+
1619
+ return hsl;
1620
+ },
1621
+ _hsl_to_rgb = function(hsl) {
1622
+ var var_1,
1623
+ var_2,
1624
+ hue_to_rgb = function(v1, v2, vH) {
1625
+ if (vH < 0) {
1626
+ vH += 1;
1627
+ }
1628
+ if (vH > 1) {
1629
+ vH -= 1;
1630
+ }
1631
+ if ((6 * vH) < 1) {
1632
+ return v1 + (v2 - v1) * 6 * vH;
1633
+ }
1634
+ if ((2 * vH) < 1) {
1635
+ return v2;
1636
+ }
1637
+ if ((3 * vH) < 2) {
1638
+ return v1 + (v2 - v1) * ((2 / 3) - vH) * 6;
1639
+ }
1640
+ return v1;
1641
+ };
1642
+
1643
+ if (hsl.s === 0) {
1644
+ return {
1645
+ r: hsl.l,
1646
+ g: hsl.l,
1647
+ b: hsl.l
1648
+ };
1649
+ }
1650
+
1651
+ var_2 = (hsl.l < 0.5) ? hsl.l * (1 + hsl.s) : (hsl.l + hsl.s) - (hsl.s * hsl.l);
1652
+ var_1 = 2 * hsl.l - var_2;
1653
+
1654
+ return {
1655
+ r: hue_to_rgb(var_1, var_2, hsl.h + (1 / 3)),
1656
+ g: hue_to_rgb(var_1, var_2, hsl.h),
1657
+ b: hue_to_rgb(var_1, var_2, hsl.h - (1 / 3))
1658
+ };
1659
+ },
1660
+ _xyz_to_lab = function(xyz) {
1661
+ // CIE-L*ab D65 1931
1662
+ var x = xyz.x / 0.95047,
1663
+ y = xyz.y,
1664
+ z = xyz.z / 1.08883;
1665
+
1666
+ x = (x > 0.008856) ? Math.pow(x, (1/3)) : (7.787 * x) + (16/116);
1667
+ y = (y > 0.008856) ? Math.pow(y, (1/3)) : (7.787 * y) + (16/116);
1668
+ z = (z > 0.008856) ? Math.pow(z, (1/3)) : (7.787 * z) + (16/116);
1669
+
1670
+ return {
1671
+ l: ((116 * y) - 16) / 100, // [0,100]
1672
+ a: ((500 * (x - y)) + 128) / 255, // [-128,127]
1673
+ b: ((200 * (y - z)) + 128) / 255 // [-128,127]
1674
+ };
1675
+ },
1676
+ _lab_to_xyz = function(lab) {
1677
+ var lab2 = {
1678
+ l: lab.l * 100,
1679
+ a: (lab.a * 255) - 128,
1680
+ b: (lab.b * 255) - 128
1681
+ },
1682
+ xyz = {
1683
+ x: 0,
1684
+ y: (lab2.l + 16) / 116,
1685
+ z: 0
1686
+ };
1687
+
1688
+ xyz.x = lab2.a / 500 + xyz.y;
1689
+ xyz.z = xyz.y - lab2.b / 200;
1690
+
1691
+ xyz.x = (Math.pow(xyz.x, 3) > 0.008856) ? Math.pow(xyz.x, 3) : (xyz.x - 16 / 116) / 7.787;
1692
+ xyz.y = (Math.pow(xyz.y, 3) > 0.008856) ? Math.pow(xyz.y, 3) : (xyz.y - 16 / 116) / 7.787;
1693
+ xyz.z = (Math.pow(xyz.z, 3) > 0.008856) ? Math.pow(xyz.z, 3) : (xyz.z - 16 / 116) / 7.787;
1694
+
1695
+ xyz.x *= 0.95047;
1696
+ xyz.y *= 1;
1697
+ xyz.z *= 1.08883;
1698
+
1699
+ return xyz;
1700
+ },
1701
+ _rgb_to_cmy = function(rgb) {
1702
+ return {
1703
+ c: 1 - (rgb.r),
1704
+ m: 1 - (rgb.g),
1705
+ y: 1 - (rgb.b)
1706
+ };
1707
+ },
1708
+ _cmy_to_rgb = function(cmy) {
1709
+ return {
1710
+ r: 1 - (cmy.c),
1711
+ g: 1 - (cmy.m),
1712
+ b: 1 - (cmy.y)
1713
+ };
1714
+ },
1715
+ _cmy_to_cmyk = function(cmy) {
1716
+ var K = 1;
1717
+
1718
+ if (cmy.c < K) {
1719
+ K = cmy.c;
1720
+ }
1721
+ if (cmy.m < K) {
1722
+ K = cmy.m;
1723
+ }
1724
+ if (cmy.y < K) {
1725
+ K = cmy.y;
1726
+ }
1727
+
1728
+ if (K == 1) {
1729
+ return {
1730
+ c: 0,
1731
+ m: 0,
1732
+ y: 0,
1733
+ k: 1
1734
+ };
1735
+ }
1736
+
1737
+ return {
1738
+ c: (cmy.c - K) / (1 - K),
1739
+ m: (cmy.m - K) / (1 - K),
1740
+ y: (cmy.y - K) / (1 - K),
1741
+ k: K
1742
+ };
1743
+ },
1744
+ _cmyk_to_cmy = function(cmyk) {
1745
+ return {
1746
+ c: cmyk.c * (1 - cmyk.k) + cmyk.k,
1747
+ m: cmyk.m * (1 - cmyk.k) + cmyk.k,
1748
+ y: cmyk.y * (1 - cmyk.k) + cmyk.k
1749
+ };
1750
+ };
1751
+
1752
+ this.set = true;
1753
+
1754
+ this.setAlpha = function(_a) {
1755
+ if (_a !== null) {
1756
+ a = _clip(_a);
1757
+ }
1758
+
1759
+ return this;
1760
+ };
1761
+
1762
+ this.getAlpha = function() {
1763
+ return a;
1764
+ };
1765
+
1766
+ this.setRGB = function(r, g, b) {
1767
+ spaces = {rgb: this.getRGB()};
1768
+ if (r !== null) {
1769
+ spaces.rgb.r = _clip(r);
1770
+ }
1771
+ if (g !== null) {
1772
+ spaces.rgb.g = _clip(g);
1773
+ }
1774
+ if (b !== null) {
1775
+ spaces.rgb.b = _clip(b);
1776
+ }
1777
+
1778
+ return this;
1779
+ };
1780
+
1781
+ this.setHSV = function(h, s, v) {
1782
+ spaces = {hsv: this.getHSV()};
1783
+ if (h !== null) {
1784
+ spaces.hsv.h = _clip(h);
1785
+ }
1786
+ if (s !== null) {
1787
+ spaces.hsv.s = _clip(s);
1788
+ }
1789
+ if (v !== null) {
1790
+ spaces.hsv.v = _clip(v);
1791
+ }
1792
+
1793
+ return this;
1794
+ };
1795
+
1796
+ this.setHSL = function(h, s, l) {
1797
+ spaces = {hsl: this.getHSL()};
1798
+ if (h !== null) {
1799
+ spaces.hsl.h = _clip(h);
1800
+ }
1801
+ if (s !== null) {
1802
+ spaces.hsl.s = _clip(s);
1803
+ }
1804
+ if (l !== null) {
1805
+ spaces.hsl.l = _clip(l);
1806
+ }
1807
+
1808
+ return this;
1809
+ };
1810
+
1811
+ this.setLAB = function(l, a, b) {
1812
+ spaces = {lab: this.getLAB()};
1813
+ if (l !== null) {
1814
+ spaces.lab.l = _clip(l);
1815
+ }
1816
+ if (a !== null) {
1817
+ spaces.lab.a = _clip(a);
1818
+ }
1819
+ if (b !== null) {
1820
+ spaces.lab.b = _clip(b);
1821
+ }
1822
+
1823
+ return this;
1824
+ };
1825
+
1826
+ this.setCMYK = function(c, m, y, k) {
1827
+ spaces = {cmyk: this.getCMYK()};
1828
+ if (c !== null) {
1829
+ spaces.cmyk.c = _clip(c);
1830
+ }
1831
+ if (m !== null) {
1832
+ spaces.cmyk.m = _clip(m);
1833
+ }
1834
+ if (y !== null) {
1835
+ spaces.cmyk.y = _clip(y);
1836
+ }
1837
+ if (k !== null) {
1838
+ spaces.cmyk.k = _clip(k);
1839
+ }
1840
+
1841
+ return this;
1842
+ };
1843
+
1844
+ this.getRGB = function() {
1845
+ if (!spaces.rgb) {
1846
+ spaces.rgb = spaces.lab ? _xyz_to_rgb(_lab_to_xyz(spaces.lab))
1847
+ : spaces.hsv ? _hsv_to_rgb(spaces.hsv)
1848
+ : spaces.hsl ? _hsl_to_rgb(spaces.hsl)
1849
+ : spaces.cmyk ? _cmy_to_rgb(_cmyk_to_cmy(spaces.cmyk))
1850
+ : {r: 0, g: 0, b: 0};
1851
+ spaces.rgb.r = _clip(spaces.rgb.r);
1852
+ spaces.rgb.g = _clip(spaces.rgb.g);
1853
+ spaces.rgb.b = _clip(spaces.rgb.b);
1854
+ }
1855
+ return $.extend({}, spaces.rgb);
1856
+ };
1857
+
1858
+ this.getHSV = function() {
1859
+ if (!spaces.hsv) {
1860
+ spaces.hsv = spaces.lab ? _rgb_to_hsv(this.getRGB())
1861
+ : spaces.rgb ? _rgb_to_hsv(spaces.rgb)
1862
+ : spaces.hsl ? _rgb_to_hsv(this.getRGB())
1863
+ : spaces.cmyk ? _rgb_to_hsv(this.getRGB())
1864
+ : {h: 0, s: 0, v: 0};
1865
+ spaces.hsv.h = _clip(spaces.hsv.h);
1866
+ spaces.hsv.s = _clip(spaces.hsv.s);
1867
+ spaces.hsv.v = _clip(spaces.hsv.v);
1868
+ }
1869
+ return $.extend({}, spaces.hsv);
1870
+ };
1871
+
1872
+ this.getHSL = function() {
1873
+ if (!spaces.hsl) {
1874
+ spaces.hsl = spaces.rgb ? _rgb_to_hsl(spaces.rgb)
1875
+ : spaces.hsv ? _rgb_to_hsl(this.getRGB())
1876
+ : spaces.cmyk ? _rgb_to_hsl(this.getRGB())
1877
+ : spaces.hsv ? _rgb_to_hsl(this.getRGB())
1878
+ : {h: 0, s: 0, l: 0};
1879
+ spaces.hsl.h = _clip(spaces.hsl.h);
1880
+ spaces.hsl.s = _clip(spaces.hsl.s);
1881
+ spaces.hsl.l = _clip(spaces.hsl.l);
1882
+ }
1883
+ return $.extend({}, spaces.hsl);
1884
+ };
1885
+
1886
+ this.getCMYK = function() {
1887
+ if (!spaces.cmyk) {
1888
+ spaces.cmyk = spaces.rgb ? _cmy_to_cmyk(_rgb_to_cmy(spaces.rgb))
1889
+ : spaces.hsv ? _cmy_to_cmyk(_rgb_to_cmy(this.getRGB()))
1890
+ : spaces.hsl ? _cmy_to_cmyk(_rgb_to_cmy(this.getRGB()))
1891
+ : spaces.lab ? _cmy_to_cmyk(_rgb_to_cmy(this.getRGB()))
1892
+ : {c: 0, m: 0, y: 0, k: 1};
1893
+ spaces.cmyk.c = _clip(spaces.cmyk.c);
1894
+ spaces.cmyk.m = _clip(spaces.cmyk.m);
1895
+ spaces.cmyk.y = _clip(spaces.cmyk.y);
1896
+ spaces.cmyk.k = _clip(spaces.cmyk.k);
1897
+ }
1898
+ return $.extend({}, spaces.cmyk);
1899
+ };
1900
+
1901
+ this.getLAB = function() {
1902
+ if (!spaces.lab) {
1903
+ spaces.lab = spaces.rgb ? _xyz_to_lab(_rgb_to_xyz(spaces.rgb))
1904
+ : spaces.hsv ? _xyz_to_lab(_rgb_to_xyz(this.getRGB()))
1905
+ : spaces.hsl ? _xyz_to_lab(_rgb_to_xyz(this.getRGB()))
1906
+ : spaces.cmyk ? _xyz_to_lab(_rgb_to_xyz(this.getRGB()))
1907
+ : {l: 0, a: 0, b: 0};
1908
+ spaces.lab.l = _clip(spaces.lab.l);
1909
+ spaces.lab.a = _clip(spaces.lab.a);
1910
+ spaces.lab.b = _clip(spaces.lab.b);
1911
+ }
1912
+ return $.extend({}, spaces.lab);
1913
+ };
1914
+
1915
+ this.getChannels = function() {
1916
+ return {
1917
+ r: this.getRGB().r,
1918
+ g: this.getRGB().g,
1919
+ b: this.getRGB().b,
1920
+ a: this.getAlpha(),
1921
+ h: this.getHSV().h,
1922
+ s: this.getHSV().s,
1923
+ v: this.getHSV().v,
1924
+ c: this.getCMYK().c,
1925
+ m: this.getCMYK().m,
1926
+ y: this.getCMYK().y,
1927
+ k: this.getCMYK().k,
1928
+ L: this.getLAB().l,
1929
+ A: this.getLAB().a,
1930
+ B: this.getLAB().b
1931
+ };
1932
+ };
1933
+
1934
+ this.distance = function(color) {
1935
+ var space = 'lab',
1936
+ getter = 'get'+space.toUpperCase(),
1937
+ a = this[getter](),
1938
+ b = color[getter](),
1939
+ distance = 0,
1940
+ channel;
1941
+
1942
+ for (channel in a) {
1943
+ distance += Math.pow(a[channel] - b[channel], 2);
1944
+ }
1945
+
1946
+ return distance;
1947
+ };
1948
+
1949
+ this.equals = function(color) {
1950
+ var a = this.getRGB(),
1951
+ b = color.getRGB();
1952
+
1953
+ return this.getAlpha() == color.getAlpha()
1954
+ && a.r == b.r
1955
+ && a.g == b.g
1956
+ && a.b == b.b;
1957
+ };
1958
+
1959
+ this.limit = function(steps) {
1960
+ steps -= 1;
1961
+ var rgb = this.getRGB();
1962
+ this.setRGB(
1963
+ Math.round(rgb.r * steps) / steps,
1964
+ Math.round(rgb.g * steps) / steps,
1965
+ Math.round(rgb.b * steps) / steps
1966
+ );
1967
+ };
1968
+
1969
+ this.toHex = function() {
1970
+ var rgb = this.getRGB();
1971
+ return _hexify(rgb.r * 255) + _hexify(rgb.g * 255) + _hexify(rgb.b * 255);
1972
+ };
1973
+
1974
+ this.toCSS = function() {
1975
+ return '#' + this.toHex();
1976
+ };
1977
+
1978
+ this.normalize = function() {
1979
+ this.setHSV(null, 1, 1);
1980
+ return this;
1981
+ };
1982
+
1983
+ this.copy = function() {
1984
+ var rgb = this.getRGB(),
1985
+ a = this.getAlpha();
1986
+ return new Color(rgb.r, rgb.g, rgb.b, a);
1987
+ };
1988
+
1989
+ // Construct
1990
+ if (args.length > 0) {
1991
+ this.setRGB(args[0], args[1], args[2]);
1992
+ this.setAlpha(args[3] === 0 ? 0 : args[3] || 1);
1993
+ }
1994
+ };
1995
+
1996
+ $.widget("vanderlee.colorpicker", {
1997
+ options: {
1998
+ alpha: false, // Show alpha controls and mode
1999
+ altAlpha: true, // change opacity of altField as well?
2000
+ altField: '', // selector for DOM elements which change background color on change.
2001
+ altOnChange: true, // true to update on each change, false to update only on close.
2002
+ altProperties: 'background-color', // comma separated list of any of 'background-color', 'color', 'border-color', 'outline-color'
2003
+ autoOpen: false, // Open dialog automatically upon creation
2004
+ buttonColorize: false,
2005
+ buttonImage: 'images/ui-colorpicker.png',
2006
+ buttonImageOnly: false,
2007
+ buttonText: null, // Text on the button and/or title of button image.
2008
+ closeOnEscape: true, // Close the dialog when the escape key is pressed.
2009
+ closeOnOutside: true, // Close the dialog when clicking outside the dialog (not for inline)
2010
+ color: '#00FF00', // Initial color (for inline only)
2011
+ colorFormat: 'HEX', // Format string for output color format
2012
+ draggable: true, // Make popup dialog draggable if header is visible.
2013
+ duration: 'fast',
2014
+ hsv: true, // Show HSV controls and modes
2015
+ regional: '',
2016
+ layout: {
2017
+ map: [0, 0, 1, 5], // Left, Top, Width, Height (in table cells).
2018
+ bar: [1, 0, 1, 5],
2019
+ preview: [2, 0, 1, 1],
2020
+ hsv: [2, 1, 1, 1],
2021
+ rgb: [2, 2, 1, 1],
2022
+ alpha: [2, 3, 1, 1],
2023
+ hex: [2, 4, 1, 1],
2024
+ lab: [3, 1, 1, 1],
2025
+ cmyk: [3, 2, 1, 2],
2026
+ swatches: [4, 0, 1, 5]
2027
+ },
2028
+ limit: '', // Limit color "resolution": '', 'websafe', 'nibble', 'binary', 'name'
2029
+ modal: false, // Modal dialog?
2030
+ mode: 'h', // Initial editing mode, h, s, v, r, g, b or a
2031
+ parts: '', // leave empty for automatic selection
2032
+ rgb: true, // Show RGB controls and modes
2033
+ showAnim: 'fadeIn',
2034
+ showCancelButton: true,
2035
+ showNoneButton: false,
2036
+ showCloseButton: true,
2037
+ showOn: 'focus', // 'focus', 'button', 'both'
2038
+ showOptions: {},
2039
+ swatches: null,
2040
+ title: null,
2041
+
2042
+ close: null,
2043
+ init: null,
2044
+ select: null
2045
+ },
2046
+
2047
+ _create: function () {
2048
+ var that = this,
2049
+ text;
2050
+
2051
+ ++_colorpicker_index;
2052
+
2053
+ that.widgetEventPrefix = 'color';
2054
+
2055
+ that.opened = false;
2056
+ that.generated = false;
2057
+ that.inline = false;
2058
+ that.changed = false;
2059
+
2060
+ that.dialog = null;
2061
+ that.button = null;
2062
+ that.image = null;
2063
+ that.overlay = null;
2064
+
2065
+ that.mode = that.options.mode;
2066
+
2067
+ if (that.options.swatches === null) {
2068
+ that.options.swatches = _colors;
2069
+ }
2070
+
2071
+ if (this.element[0].nodeName.toLowerCase() === 'input' || !this.inline) {
2072
+ that._setColor(that.element.val());
2073
+
2074
+ this._callback('init');
2075
+
2076
+ $('body').append(_container_popup);
2077
+ that.dialog = $('.ui-colorpicker:last');
2078
+
2079
+ // Click outside/inside
2080
+ $(document).mousedown(function (event) {
2081
+ if (!that.opened || event.target === that.element[0] || that.overlay) {
2082
+ return;
2083
+ }
2084
+
2085
+ // Check if clicked on any part of dialog
2086
+ if (that.dialog.is(event.target) || that.dialog.has(event.target).length > 0) {
2087
+ that.element.blur(); // inside window!
2088
+ return;
2089
+ }
2090
+
2091
+ // Check if clicked on button
2092
+ var p,
2093
+ parents = $(event.target).parents();
2094
+ for (p = 0; p <= parents.length; ++p) {
2095
+ if (that.button !== null && parents[p] === that.button[0]) {
2096
+ return;
2097
+ }
2098
+ }
2099
+
2100
+ // no closeOnOutside
2101
+ if (!that.options.closeOnOutside) {
2102
+ return;
2103
+ }
2104
+
2105
+ that.close();
2106
+ });
2107
+
2108
+ $(document).keydown(function (event) {
2109
+ if (event.keyCode == 27 && that.opened && that.options.closeOnEscape) {
2110
+ that.close();
2111
+ }
2112
+ });
2113
+
2114
+ if (that.options.showOn === 'focus' || that.options.showOn === 'both') {
2115
+ that.element.focus(function () {
2116
+ that.open();
2117
+ });
2118
+ }
2119
+ if (that.options.showOn === 'button' || that.options.showOn === 'both') {
2120
+ if (that.options.buttonImage !== '') {
2121
+ text = that.options.buttonText || that._getRegional('button');
2122
+
2123
+ that.image = $('<img/>').attr({
2124
+ 'src': that.options.buttonImage,
2125
+ 'alt': text,
2126
+ 'title': text
2127
+ });
2128
+
2129
+ that._setImageBackground();
2130
+ }
2131
+
2132
+ if (that.options.buttonImageOnly && that.image) {
2133
+ that.button = that.image;
2134
+ } else {
2135
+ that.button = $('<button type="button"></button>').html(that.image || that.options.buttonText).button();
2136
+ that.image = that.image ? $('img', that.button).first() : null;
2137
+ }
2138
+ that.button.insertAfter(that.element).click(function () {
2139
+ that[that.opened ? 'close' : 'open']();
2140
+ });
2141
+ }
2142
+
2143
+ if (that.options.autoOpen) {
2144
+ that.open();
2145
+ }
2146
+
2147
+ that.element.keydown(function (event) {
2148
+ if (event.keyCode === 9) {
2149
+ that.close();
2150
+ }
2151
+ }).keyup(function (event) {
2152
+ var color = _parseColor(that.element.val());
2153
+ if (!that.color.equals(color)) {
2154
+ that.color = color;
2155
+ that._change();
2156
+ }
2157
+ });
2158
+ } else {
2159
+ that.inline = true;
2160
+
2161
+ $(this.element).html(_container_inline);
2162
+ that.dialog = $('.ui-colorpicker', this.element);
2163
+
2164
+ that._generate();
2165
+
2166
+ that.opened = true;
2167
+ }
2168
+
2169
+ return this;
2170
+ },
2171
+
2172
+ _setOption: function(key, value){
2173
+ var that = this;
2174
+
2175
+ switch (key) {
2176
+ case "disabled":
2177
+ if (value) {
2178
+ that.dialog.addClass('ui-colorpicker-disabled');
2179
+ } else {
2180
+ that.dialog.removeClass('ui-colorpicker-disabled');
2181
+ }
2182
+ break;
2183
+ }
2184
+
2185
+ $.Widget.prototype._setOption.apply(that, arguments);
2186
+ },
2187
+
2188
+ /* setBackground */
2189
+ _setImageBackground: function() {
2190
+ if (this.image && this.options.buttonColorize) {
2191
+ this.image.css('background-color', this.color.set? _formatColor('RGBA', this.color) : '');
2192
+ }
2193
+ },
2194
+
2195
+ /**
2196
+ * If an alternate field is specified, set it according to the current color.
2197
+ */
2198
+ _setAltField: function () {
2199
+ if (this.options.altOnChange && this.options.altField && this.options.altProperties) {
2200
+ var index,
2201
+ property,
2202
+ properties = this.options.altProperties.split(',');
2203
+
2204
+ for (index = 0; index <= properties.length; ++index) {
2205
+ property = $.trim(properties[index]);
2206
+ switch (property) {
2207
+ case 'color':
2208
+ case 'background-color':
2209
+ case 'outline-color':
2210
+ case 'border-color':
2211
+ $(this.options.altField).css(property, this.color.set? this.color.toCSS() : '');
2212
+ break;
2213
+ }
2214
+ }
2215
+
2216
+ if (this.options.altAlpha) {
2217
+ $(this.options.altField).css('opacity', this.color.set? this.color.getAlpha() : '');
2218
+ }
2219
+ }
2220
+ },
2221
+
2222
+ _setColor: function(text) {
2223
+ this.color = _parseColor(text);
2224
+ this.currentColor = this.color.copy();
2225
+
2226
+ this._setImageBackground();
2227
+ this._setAltField();
2228
+ },
2229
+
2230
+ setColor: function(text) {
2231
+ this._setColor(text);
2232
+ this._change(this.color.set);
2233
+ },
2234
+
2235
+ _generate: function () {
2236
+ var that = this,
2237
+ index,
2238
+ part,
2239
+ parts_list,
2240
+ layout_parts;
2241
+
2242
+ // Set color based on element?
2243
+ that._setColor(that.inline? that.options.color : that.element.val());
2244
+
2245
+ // Determine the parts to include in this colorpicker
2246
+ if (typeof that.options.parts === 'string') {
2247
+ if (_parts_lists[that.options.parts]) {
2248
+ parts_list = _parts_lists[that.options.parts];
2249
+ } else {
2250
+ // automatic
2251
+ parts_list = _parts_lists[that.inline ? 'inline' : 'popup'];
2252
+ }
2253
+ } else {
2254
+ parts_list = that.options.parts;
2255
+ }
2256
+
2257
+ // Add any parts to the internal parts list
2258
+ that.parts = {};
2259
+ $.each(parts_list, function(index, part) {
2260
+ if (_parts[part]) {
2261
+ that.parts[part] = new _parts[part](that);
2262
+ }
2263
+ });
2264
+
2265
+ if (!that.generated) {
2266
+ layout_parts = [];
2267
+
2268
+ $.each(that.options.layout, function(part, pos) {
2269
+ if (that.parts[part]) {
2270
+ layout_parts.push({
2271
+ 'part': part,
2272
+ 'pos': pos
2273
+ });
2274
+ }
2275
+ });
2276
+
2277
+ $(_layoutTable(layout_parts, function(cell, x, y) {
2278
+ var classes = ['ui-colorpicker-' + cell.part + '-container'];
2279
+
2280
+ if (x > 0) {
2281
+ classes.push('ui-colorpicker-padding-left');
2282
+ }
2283
+
2284
+ if (y > 0) {
2285
+ classes.push('ui-colorpicker-padding-top');
2286
+ }
2287
+
2288
+ return '<td class="' + classes.join(' ') + '"'
2289
+ + (cell.pos[2] > 1 ? ' colspan="' + cell.pos[2] + '"' : '')
2290
+ + (cell.pos[3] > 1 ? ' rowspan="' + cell.pos[3] + '"' : '')
2291
+ + ' valign="top"></td>';
2292
+ })).appendTo(that.dialog).addClass('ui-dialog-content ui-widget-content');
2293
+
2294
+ that._initAllParts();
2295
+ that._updateAllParts();
2296
+ that.generated = true;
2297
+ }
2298
+ },
2299
+
2300
+ _effectGeneric: function (element, show, slide, fade, callback) {
2301
+ var that = this;
2302
+
2303
+ if ($.effects && $.effects[that.options.showAnim]) {
2304
+ element[show](that.options.showAnim, that.options.showOptions, that.options.duration, callback);
2305
+ } else {
2306
+ element[(that.options.showAnim === 'slideDown' ?
2307
+ slide
2308
+ : (that.options.showAnim === 'fadeIn' ?
2309
+ fade
2310
+ : show))]((that.options.showAnim ? that.options.duration : null), callback);
2311
+ if (!that.options.showAnim || !that.options.duration) {
2312
+ callback();
2313
+ }
2314
+ }
2315
+ },
2316
+
2317
+ _effectShow: function(element, callback) {
2318
+ this._effectGeneric(element, 'show', 'slideDown', 'fadeIn', callback);
2319
+ },
2320
+
2321
+ _effectHide: function(element, callback) {
2322
+ this._effectGeneric(element, 'hide', 'slideUp', 'fadeOut', callback);
2323
+ },
2324
+
2325
+ open: function() {
2326
+ var that = this,
2327
+ offset,
2328
+ bottom,
2329
+ right,
2330
+ height,
2331
+ width,
2332
+ x,
2333
+ y,
2334
+ zIndex;
2335
+
2336
+ if (!that.opened) {
2337
+ that._generate();
2338
+
2339
+ offset = that.element.offset();
2340
+ bottom = $(window).height() + $(window).scrollTop();
2341
+ right = $(window).width() + $(window).scrollLeft();
2342
+ height = that.dialog.outerHeight();
2343
+ width = that.dialog.outerWidth();
2344
+ x = offset.left;
2345
+ y = offset.top + that.element.outerHeight();
2346
+
2347
+ if (x + width > right) {
2348
+ x = Math.max(0, right - width);
2349
+ }
2350
+
2351
+ if (y + height > bottom) {
2352
+ if (offset.top - height >= $(window).scrollTop()) {
2353
+ y = offset.top - height;
2354
+ } else {
2355
+ y = Math.max(0, bottom - height);
2356
+ }
2357
+ }
2358
+
2359
+ that.dialog.css({'left': x, 'top': y});
2360
+
2361
+ // Automatically find highest z-index.
2362
+ zIndex = 0;
2363
+ $(that.element[0]).parents().each(function() {
2364
+ var z = $(this).css('z-index');
2365
+ if ((typeof(z) === 'number' || typeof(z) === 'string') && z !== '' && !isNaN(z)) {
2366
+ zIndex = z;
2367
+ return false;
2368
+ }
2369
+ });
2370
+
2371
+ //@todo zIndexOffset option, to raise above other elements?
2372
+ that.dialog.css('z-index', zIndex += 2);
2373
+
2374
+ that.overlay = that.options.modal ? new $.ui.dialog.overlay(that) : null;
2375
+
2376
+ that._effectShow(this.dialog);
2377
+ that.opened = true;
2378
+
2379
+ // Without waiting for domready the width of the map is 0 and we
2380
+ // wind up with the cursor stuck in the upper left corner
2381
+ $(function() {
2382
+ that._repaintAllParts();
2383
+ });
2384
+ }
2385
+ },
2386
+
2387
+ close: function () {
2388
+ var that = this;
2389
+
2390
+ that.currentColor = that.color.copy();
2391
+ that.changed = false;
2392
+
2393
+ // tear down the interface
2394
+ that._effectHide(that.dialog, function () {
2395
+ that.dialog.empty();
2396
+ that.generated = false;
2397
+
2398
+ that.opened = false;
2399
+ that._callback('close', true);
2400
+ });
2401
+
2402
+ if (that.overlay) {
2403
+ that.overlay.destroy();
2404
+ }
2405
+ },
2406
+
2407
+ destroy: function() {
2408
+ this.element.unbind();
2409
+
2410
+ if (this.image !== null) {
2411
+ this.image.remove();
2412
+ }
2413
+
2414
+ if (this.button !== null) {
2415
+ this.button.remove();
2416
+ }
2417
+
2418
+ if (this.dialog !== null) {
2419
+ this.dialog.remove();
2420
+ }
2421
+
2422
+ if (this.overlay) {
2423
+ this.overlay.destroy();
2424
+ }
2425
+ },
2426
+
2427
+ _callback: function (callback, spaces) {
2428
+ var that = this,
2429
+ data,
2430
+ lab;
2431
+
2432
+ if (that.color.set) {
2433
+ data = {
2434
+ formatted: _formatColor(that.options.colorFormat, that.color)
2435
+ };
2436
+
2437
+ lab = that.color.getLAB();
2438
+ lab.a = (lab.a * 2) - 1;
2439
+ lab.b = (lab.b * 2) - 1;
2440
+
2441
+ if (spaces === true) {
2442
+ data.a = that.color.getAlpha();
2443
+ data.rgb = that.color.getRGB();
2444
+ data.hsv = that.color.getHSV();
2445
+ data.cmyk = that.color.getCMYK();
2446
+ data.hsl = that.color.getHSL();
2447
+ data.lab = lab;
2448
+ }
2449
+
2450
+ return that._trigger(callback, null, data);
2451
+ } else {
2452
+ return that._trigger(callback, null, {
2453
+ formatted: ''
2454
+ });
2455
+ }
2456
+ },
2457
+
2458
+ _initAllParts: function () {
2459
+ $.each(this.parts, function (index, part) {
2460
+ if (part.init) {
2461
+ part.init();
2462
+ }
2463
+ });
2464
+ },
2465
+
2466
+ _updateAllParts: function () {
2467
+ $.each(this.parts, function (index, part) {
2468
+ if (part.update) {
2469
+ part.update();
2470
+ }
2471
+ });
2472
+ },
2473
+
2474
+ _repaintAllParts: function () {
2475
+ $.each(this.parts, function (index, part) {
2476
+ if (part.repaint) {
2477
+ part.repaint();
2478
+ }
2479
+ });
2480
+ },
2481
+
2482
+ _change: function (set /* = true */) {
2483
+ this.color.set = (set !== false);
2484
+
2485
+ this.changed = true;
2486
+
2487
+ // Limit color palette
2488
+ switch (this.options.limit) {
2489
+ case 'websafe':
2490
+ this.color.limit(6);
2491
+ break;
2492
+
2493
+ case 'nibble':
2494
+ this.color.limit(16);
2495
+ break;
2496
+
2497
+ case 'binary':
2498
+ this.color.limit(2);
2499
+ break;
2500
+
2501
+ case 'name':
2502
+ var name = _closestName(this.color);
2503
+ this.color.setRGB(_colors[name].r, _colors[name].g, _colors[name].b);
2504
+ break;
2505
+ }
2506
+
2507
+ // update input element content
2508
+ if (!this.inline) {
2509
+ if (!this.color.set) {
2510
+ this.element.val('');
2511
+ } else if (!this.color.equals(_parseColor(this.element.val()))) {
2512
+ this.element.val(_formatColor(this.options.colorFormat, this.color));
2513
+ }
2514
+
2515
+ this._setImageBackground();
2516
+ this._setAltField();
2517
+ }
2518
+
2519
+ if (this.opened) {
2520
+ this._repaintAllParts();
2521
+ }
2522
+
2523
+ // callback
2524
+ this._callback('select');
2525
+ },
2526
+
2527
+ // This will be deprecated by jQueryUI 1.9 widget
2528
+ _hoverable: function (e) {
2529
+ e.hover(function () {
2530
+ e.addClass("ui-state-hover");
2531
+ }, function () {
2532
+ e.removeClass("ui-state-hover");
2533
+ });
2534
+ },
2535
+
2536
+ // This will be deprecated by jQueryUI 1.9 widget
2537
+ _focusable: function (e) {
2538
+ e.focus(function () {
2539
+ e.addClass("ui-state-focus");
2540
+ }).blur(function () {
2541
+ e.removeClass("ui-state-focus");
2542
+ });
2543
+ },
2544
+
2545
+ _getRegional: function(name) {
2546
+ return $.colorpicker.regional[this.options.regional][name] !== undefined ?
2547
+ $.colorpicker.regional[this.options.regional][name] : $.colorpicker.regional[''][name];
2548
+ }
2549
+ });
2550
+ }(jQuery));
js/jquery-ui/jquery-ui.css CHANGED
@@ -9,8 +9,8 @@
9
  .ui-helper-hidden { display: none; }
10
  .ui-helper-hidden-accessible { position: absolute !important; clip: rect(1px 1px 1px 1px); clip: rect(1px,1px,1px,1px); }
11
  .ui-helper-reset { margin: 0; padding: 0; border: 0; outline: 0; line-height: 1.3; text-decoration: none; font-size: 100%; list-style: none; }
12
- .ui-helper-clearfix:before, .ui-helper-clearfix:after { content: ""; display: table; }
13
- .ui-helper-clearfix:after { clear: both; }
14
  .ui-helper-clearfix { zoom: 1; }
15
  .ui-helper-zfix { width: 100%; height: 100%; top: 0; left: 0; position: absolute; opacity: 0; filter:Alpha(Opacity=0); }
16
 
@@ -53,8 +53,8 @@
53
  .ui-button, .ui-button:link, .ui-button:visited, .ui-button:hover, .ui-button:active { text-decoration: none; }
54
  .ui-button-icon-only { width: 2.2em; } /* to make room for the icon, a width needs to be set here */
55
  button.ui-button-icon-only { width: 2.4em; } /* button elements seem to need a little more width */
56
- .ui-button-icons-only { width: 3.4em; }
57
- button.ui-button-icons-only { width: 3.7em; }
58
 
59
  /*button text element */
60
  .ui-button .ui-button-text { display: block; line-height: 1.4; }
@@ -80,7 +80,7 @@ input.ui-button { padding: .4em 1em; }
80
  /* workarounds */
81
  button.ui-button::-moz-focus-inner { border: 0; padding: 0; } /* reset extra padding in Firefox */
82
  .ui-dialog { position: absolute; padding: .2em; width: 300px; overflow: hidden; }
83
- .ui-dialog .ui-dialog-titlebar { padding: .4em 1em; position: relative; }
84
  .ui-dialog .ui-dialog-title { float: left; margin: .1em 16px .1em 0; }
85
  .ui-dialog .ui-dialog-titlebar-close { position: absolute; right: .3em; top: 50%; width: 19px; margin: -10px 0 0 0; padding: 1px; height: 18px; }
86
  .ui-dialog .ui-dialog-titlebar-close span { display: block; margin: 1px; }
@@ -152,9 +152,9 @@ button.ui-button::-moz-focus-inner { border: 0; padding: 0; } /* reset extra pad
152
  .ui-widget { font-family: sans-serif; font-size: 12px; }
153
  .ui-widget .ui-widget { font-size: 1em; }
154
  .ui-widget input, .ui-widget select, .ui-widget textarea, .ui-widget button { font-family: sans-serif; font-size: 1em; }
155
- .ui-widget-content { border: 1px solid #dddddd; background: #eeeeee url(images/ui-bg_highlight-soft_100_eeeeee_1x100.png) 50% top repeat-x; color: #333333; }
156
  .ui-widget-content a { color: #333333; }
157
- .ui-widget-header { border: 1px solid #b3b3b3; background: #dedede url(images/ui-bg_highlight-soft_60_dedede_1x100.png) 50% 50% repeat-x; color: #474747; font-weight: bold; }
158
  .ui-widget-header a { color: #474747; }
159
 
160
  /* Interaction states
@@ -379,5 +379,5 @@ button.ui-button::-moz-focus-inner { border: 0; padding: 0; } /* reset extra pad
379
  .ui-corner-all, .ui-corner-bottom, .ui-corner-right, .ui-corner-br { -moz-border-radius-bottomright: 4px; -webkit-border-bottom-right-radius: 4px; -khtml-border-bottom-right-radius: 4px; border-bottom-right-radius: 4px; }
380
 
381
  /* Overlays */
382
- .ui-widget-overlay { background: #666666 url(images/ui-bg_diagonals-thick_20_666666_40x40.png) 50% 50% repeat; opacity: .5;filter:Alpha(Opacity=50); }
383
  .ui-widget-shadow { margin: -5px 0 0 -5px; padding: 5px; background: #000000 url(images/ui-bg_flat_10_000000_40x100.png) 50% 50% repeat-x; opacity: .2;filter:Alpha(Opacity=20); -moz-border-radius: 5px; -khtml-border-radius: 5px; -webkit-border-radius: 5px; border-radius: 5px; }
9
  .ui-helper-hidden { display: none; }
10
  .ui-helper-hidden-accessible { position: absolute !important; clip: rect(1px 1px 1px 1px); clip: rect(1px,1px,1px,1px); }
11
  .ui-helper-reset { margin: 0; padding: 0; border: 0; outline: 0; line-height: 1.3; text-decoration: none; font-size: 100%; list-style: none; }
12
+ /*.ui-helper-clearfix:before, .ui-helper-clearfix:after { content: ""; display: table; }
13
+ .ui-helper-clearfix:after { clear: both; }*/
14
  .ui-helper-clearfix { zoom: 1; }
15
  .ui-helper-zfix { width: 100%; height: 100%; top: 0; left: 0; position: absolute; opacity: 0; filter:Alpha(Opacity=0); }
16
 
53
  .ui-button, .ui-button:link, .ui-button:visited, .ui-button:hover, .ui-button:active { text-decoration: none; }
54
  .ui-button-icon-only { width: 2.2em; } /* to make room for the icon, a width needs to be set here */
55
  button.ui-button-icon-only { width: 2.4em; } /* button elements seem to need a little more width */
56
+ .ui-button-icons-only { width: 3.4em; }
57
+ button.ui-button-icons-only { width: 3.7em; }
58
 
59
  /*button text element */
60
  .ui-button .ui-button-text { display: block; line-height: 1.4; }
80
  /* workarounds */
81
  button.ui-button::-moz-focus-inner { border: 0; padding: 0; } /* reset extra padding in Firefox */
82
  .ui-dialog { position: absolute; padding: .2em; width: 300px; overflow: hidden; }
83
+ .ui-dialog .ui-dialog-titlebar { padding: .4em 1em; height: 20px; /*background: #666;*/ color: #ccc; position: relative; }
84
  .ui-dialog .ui-dialog-title { float: left; margin: .1em 16px .1em 0; }
85
  .ui-dialog .ui-dialog-titlebar-close { position: absolute; right: .3em; top: 50%; width: 19px; margin: -10px 0 0 0; padding: 1px; height: 18px; }
86
  .ui-dialog .ui-dialog-titlebar-close span { display: block; margin: 1px; }
152
  .ui-widget { font-family: sans-serif; font-size: 12px; }
153
  .ui-widget .ui-widget { font-size: 1em; }
154
  .ui-widget input, .ui-widget select, .ui-widget textarea, .ui-widget button { font-family: sans-serif; font-size: 1em; }
155
+ .ui-widget-content { border: 1px solid #dddddd; background: #f5f5f5 50% top repeat-x; color: #333333; }
156
  .ui-widget-content a { color: #333333; }
157
+ .ui-widget-header { border: 1px solid #b3b3b3; background: #ccc; color: #474747; font-weight: bold; }
158
  .ui-widget-header a { color: #474747; }
159
 
160
  /* Interaction states
379
  .ui-corner-all, .ui-corner-bottom, .ui-corner-right, .ui-corner-br { -moz-border-radius-bottomright: 4px; -webkit-border-bottom-right-radius: 4px; -khtml-border-bottom-right-radius: 4px; border-bottom-right-radius: 4px; }
380
 
381
  /* Overlays */
382
+ .ui-widget-overlay { background: #666666; opacity: .5;filter:Alpha(Opacity=50); }
383
  .ui-widget-shadow { margin: -5px 0 0 -5px; padding: 5px; background: #000000 url(images/ui-bg_flat_10_000000_40x100.png) 50% 50% repeat-x; opacity: .2;filter:Alpha(Opacity=20); -moz-border-radius: 5px; -khtml-border-radius: 5px; -webkit-border-radius: 5px; border-radius: 5px; }
js/test.html ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <script src="tinycolor-min.js"></script>
2
+
3
+ <script>
4
+
5
+ function lighten(color) {
6
+ var hsv = color.toHsv();
7
+ hsv.v = (hsv.v + 0.3) % 1;
8
+ return tinycolor(hsv);
9
+ }
10
+
11
+ blue = tinycolor("blue");
12
+ console.log(lighten(blue).toHexString());
13
+
14
+ </script>
js/tinycolor-min.js ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // TinyColor.js - <https://github.com/bgrins/TinyColor> - 2012 Brian Grinstead - v0.9.12
2
+ (function(C){var t,u,v,w,x,y,z;function d(a,c){a=a?a:"";if("object"==typeof a&&a.hasOwnProperty("_tc_id"))return a;var b=D(a),i=b.r,j=b.g,g=b.b,f=b.a,k=e(100*f)/100,E=b.format;1>i&&(i=e(i));1>j&&(j=e(j));1>g&&(g=e(g));return{ok:b.ok,format:E,_tc_id:F++,alpha:f,toHsv:function(){var a=A(i,j,g);return{h:360*a.h,s:a.s,v:a.v,a:f}},toHsvString:function(){var a=A(i,j,g),b=e(360*a.h),c=e(100*a.s),a=e(100*a.v);return 1==f?"hsv("+b+", "+c+"%, "+a+"%)":"hsva("+b+", "+c+"%, "+a+"%, "+k+")"},toHsl:function(){var a=
3
+ B(i,j,g);return{h:360*a.h,s:a.s,l:a.l,a:f}},toHslString:function(){var a=B(i,j,g),b=e(360*a.h),c=e(100*a.s),a=e(100*a.l);return 1==f?"hsl("+b+", "+c+"%, "+a+"%)":"hsla("+b+", "+c+"%, "+a+"%, "+k+")"},toHex:function(){return q(i,j,g)},toHexString:function(){return"#"+q(i,j,g)},toRgb:function(){return{r:e(i),g:e(j),b:e(g),a:f}},toRgbString:function(){return 1==f?"rgb("+e(i)+", "+e(j)+", "+e(g)+")":"rgba("+e(i)+", "+e(j)+", "+e(g)+", "+k+")"},toPercentageRgb:function(){return{r:e(100*h(i,255))+"%",g:e(100*
4
+ h(j,255))+"%",b:e(100*h(g,255))+"%",a:f}},toPercentageRgbString:function(){return 1==f?"rgb("+e(100*h(i,255))+"%, "+e(100*h(j,255))+"%, "+e(100*h(g,255))+"%)":"rgba("+e(100*h(i,255))+"%, "+e(100*h(j,255))+"%, "+e(100*h(g,255))+"%, "+k+")"},toName:function(){return G[q(i,j,g)]||!1},toFilter:function(){var a=q(i,j,g),b=a,e=Math.round(255*parseFloat(f)).toString(16),h=e,k=c&&c.gradientType?"GradientType = 1, ":"";secondColor&&(h=d(secondColor),b=h.toHex(),h=Math.round(255*parseFloat(h.alpha)).toString(16));
5
+ return"progid:DXImageTransform.Microsoft.gradient("+k+"startColorstr=#"+o(e)+a+",endColorstr=#"+o(h)+b+")"},toString:function(a){var a=a||this.format,b=!1;"rgb"===a&&(b=this.toRgbString());"prgb"===a&&(b=this.toPercentageRgbString());"hex"===a&&(b=this.toHexString());"name"===a&&(b=this.toName());"hsl"===a&&(b=this.toHslString());"hsv"===a&&(b=this.toHsvString());return b||this.toHexString()}}}function D(a){var c={r:255,g:255,b:255},b=1,i=!1,d=!1;if("string"==typeof a)a:{var a=a.replace(H,"").replace(I,
6
+ "").toLowerCase(),g=!1;if(r[a])a=r[a],g=!0;else if("transparent"==a){a={r:0,g:0,b:0,a:0};break a}var f,a=(f=t.exec(a))?{r:f[1],g:f[2],b:f[3]}:(f=u.exec(a))?{r:f[1],g:f[2],b:f[3],a:f[4]}:(f=v.exec(a))?{h:f[1],s:f[2],l:f[3]}:(f=w.exec(a))?{h:f[1],s:f[2],l:f[3],a:f[4]}:(f=x.exec(a))?{h:f[1],s:f[2],v:f[3]}:(f=y.exec(a))?{r:parseInt(f[1],16),g:parseInt(f[2],16),b:parseInt(f[3],16),format:g?"name":"hex"}:(f=z.exec(a))?{r:parseInt(f[1]+""+f[1],16),g:parseInt(f[2]+""+f[2],16),b:parseInt(f[3]+""+f[3],16),
7
+ format:g?"name":"hex"}:!1}if("object"==typeof a){if(a.hasOwnProperty("r")&&a.hasOwnProperty("g")&&a.hasOwnProperty("b"))c={r:255*h(a.r,255),g:255*h(a.g,255),b:255*h(a.b,255)},i=!0,d="%"===(""+a.r).substr(-1)?"prgb":"rgb";else if(a.hasOwnProperty("h")&&a.hasOwnProperty("s")&&a.hasOwnProperty("v")){a.s=p(a.s);a.v=p(a.v);var d=a.h,g=a.s,c=a.v,d=6*h(d,360),g=h(g,100),c=h(c,100),i=n.floor(d),e=d-i,d=c*(1-g);f=c*(1-e*g);g=c*(1-(1-e)*g);i%=6;c={r:255*[c,f,d,d,g,c][i],g:255*[g,c,c,f,d,d][i],b:255*[d,d,g,
8
+ c,c,f][i]};i=!0;d="hsv"}else a.hasOwnProperty("h")&&a.hasOwnProperty("s")&&a.hasOwnProperty("l")&&(a.s=p(a.s),a.l=p(a.l),c=J(a.h,a.s,a.l),i=!0,d="hsl");a.hasOwnProperty("a")&&(b=a.a)}b=parseFloat(b);if(isNaN(b)||0>b||1<b)b=1;return{ok:i,format:a.format||d,r:l(255,m(c.r,0)),g:l(255,m(c.g,0)),b:l(255,m(c.b,0)),a:b}}function B(a,c,b){var a=h(a,255),c=h(c,255),b=h(b,255),d=m(a,c,b),e=l(a,c,b),g,f=(d+e)/2;if(d==e)g=e=0;else{var k=d-e,e=0.5<f?k/(2-d-e):k/(d+e);switch(d){case a:g=(c-b)/k+(c<b?6:0);break;
9
+ case c:g=(b-a)/k+2;break;case b:g=(a-c)/k+4}g/=6}return{h:g,s:e,l:f}}function J(a,c,b){function d(a,b,c){0>c&&(c+=1);1<c&&(c-=1);return c<1/6?a+6*(b-a)*c:0.5>c?b:c<2/3?a+6*(b-a)*(2/3-c):a}a=h(a,360);c=h(c,100);b=h(b,100);if(0===c)b=c=a=b;else var e=0.5>b?b*(1+c):b+c-b*c,g=2*b-e,b=d(g,e,a+1/3),c=d(g,e,a),a=d(g,e,a-1/3);return{r:255*b,g:255*c,b:255*a}}function A(a,c,b){var a=h(a,255),c=h(c,255),b=h(b,255),d=m(a,c,b),e=l(a,c,b),g,f=d-e;if(d==e)g=0;else{switch(d){case a:g=(c-b)/f+(c<b?6:0);break;case c:g=
10
+ (b-a)/f+2;break;case b:g=(a-c)/f+4}g/=6}return{h:g,s:0===d?0:f/d,v:d}}function q(a,c,b){a=[o(e(a).toString(16)),o(e(c).toString(16)),o(e(b).toString(16))];return a[0][0]==a[0][1]&&a[1][0]==a[1][1]&&a[2][0]==a[2][1]?a[0][0]+a[1][0]+a[2][0]:a.join("")}function h(a,c){"string"==typeof a&&-1!=a.indexOf(".")&&1===parseFloat(a)&&(a="100%");var b="string"===typeof a&&-1!=a.indexOf("%"),a=l(c,m(0,parseFloat(a)));b&&(a=parseInt(a*c,10)/100);return 1.0E-6>n.abs(a-c)?1:a%c/parseFloat(c)}function o(a){return 1==
11
+ a.length?"0"+a:""+a}function p(a){1>=a&&(a=100*a+"%");return a}var H=/^[\s,#]+/,I=/\s+$/,F=0,n=Math,e=n.round,l=n.min,m=n.max,s=n.random;d.fromRatio=function(a){if("object"==typeof a){var c={},b;for(b in a)c[b]=p(a[b]);a=c}return d(a)};d.equals=function(a,c){return!a||!c?!1:d(a).toRgbString()==d(c).toRgbString()};d.random=function(){return d.fromRatio({r:s(),g:s(),b:s()})};d.desaturate=function(a,c){var b=d(a).toHsl();b.s-=(c||10)/100;b.s=l(1,m(0,b.s));return d(b)};d.saturate=function(a,c){var b=
12
+ d(a).toHsl();b.s+=(c||10)/100;b.s=l(1,m(0,b.s));return d(b)};d.greyscale=function(a){return d.desaturate(a,100)};d.lighten=function(a,c){var b=d(a).toHsl();b.l+=(c||10)/100;b.l=l(1,m(0,b.l));return d(b)};d.darken=function(a,c){var b=d(a).toHsl();b.l-=(c||10)/100;b.l=l(1,m(0,b.l));return d(b)};d.complement=function(a){a=d(a).toHsl();a.h=(a.h+180)%360;return d(a)};d.triad=function(a){var c=d(a).toHsl(),b=c.h;return[d(a),d({h:(b+120)%360,s:c.s,l:c.l}),d({h:(b+240)%360,s:c.s,l:c.l})]};d.tetrad=function(a){var c=
13
+ d(a).toHsl(),b=c.h;return[d(a),d({h:(b+90)%360,s:c.s,l:c.l}),d({h:(b+180)%360,s:c.s,l:c.l}),d({h:(b+270)%360,s:c.s,l:c.l})]};d.splitcomplement=function(a){var c=d(a).toHsl(),b=c.h;return[d(a),d({h:(b+72)%360,s:c.s,l:c.l}),d({h:(b+216)%360,s:c.s,l:c.l})]};d.analogous=function(a,c,b){var c=c||6,b=b||30,e=d(a).toHsl(),b=360/b,a=[d(a)];for(e.h=(e.h-(b*c>>1)+720)%360;--c;)e.h=(e.h+b)%360,a.push(d(e));return a};d.monochromatic=function(a,c){for(var c=c||6,b=d(a).toHsv(),e=b.h,h=b.s,b=b.v,g=[],f=1/c;c--;)g.push(d({h:e,
14
+ s:h,v:b})),b=(b+f)%1;return g};d.readable=function(a,c){var b=d(a).toRgb(),e=d(c).toRgb();return 10404<(e.r-b.r)*(e.r-b.r)+(e.g-b.g)*(e.g-b.g)+(e.b-b.b)*(e.b-b.b)};var r=d.names={aliceblue:"f0f8ff",antiquewhite:"faebd7",aqua:"0ff",aquamarine:"7fffd4",azure:"f0ffff",beige:"f5f5dc",bisque:"ffe4c4",black:"000",blanchedalmond:"ffebcd",blue:"00f",blueviolet:"8a2be2",brown:"a52a2a",burlywood:"deb887",burntsienna:"ea7e5d",cadetblue:"5f9ea0",chartreuse:"7fff00",chocolate:"d2691e",coral:"ff7f50",cornflowerblue:"6495ed",
15
+ cornsilk:"fff8dc",crimson:"dc143c",cyan:"0ff",darkblue:"00008b",darkcyan:"008b8b",darkgoldenrod:"b8860b",darkgray:"a9a9a9",darkgreen:"006400",darkgrey:"a9a9a9",darkkhaki:"bdb76b",darkmagenta:"8b008b",darkolivegreen:"556b2f",darkorange:"ff8c00",darkorchid:"9932cc",darkred:"8b0000",darksalmon:"e9967a",darkseagreen:"8fbc8f",darkslateblue:"483d8b",darkslategray:"2f4f4f",darkslategrey:"2f4f4f",darkturquoise:"00ced1",darkviolet:"9400d3",deeppink:"ff1493",deepskyblue:"00bfff",dimgray:"696969",dimgrey:"696969",
16
+ dodgerblue:"1e90ff",firebrick:"b22222",floralwhite:"fffaf0",forestgreen:"228b22",fuchsia:"f0f",gainsboro:"dcdcdc",ghostwhite:"f8f8ff",gold:"ffd700",goldenrod:"daa520",gray:"808080",green:"008000",greenyellow:"adff2f",grey:"808080",honeydew:"f0fff0",hotpink:"ff69b4",indianred:"cd5c5c",indigo:"4b0082",ivory:"fffff0",khaki:"f0e68c",lavender:"e6e6fa",lavenderblush:"fff0f5",lawngreen:"7cfc00",lemonchiffon:"fffacd",lightblue:"add8e6",lightcoral:"f08080",lightcyan:"e0ffff",lightgoldenrodyellow:"fafad2",
17
+ lightgray:"d3d3d3",lightgreen:"90ee90",lightgrey:"d3d3d3",lightpink:"ffb6c1",lightsalmon:"ffa07a",lightseagreen:"20b2aa",lightskyblue:"87cefa",lightslategray:"789",lightslategrey:"789",lightsteelblue:"b0c4de",lightyellow:"ffffe0",lime:"0f0",limegreen:"32cd32",linen:"faf0e6",magenta:"f0f",maroon:"800000",mediumaquamarine:"66cdaa",mediumblue:"0000cd",mediumorchid:"ba55d3",mediumpurple:"9370db",mediumseagreen:"3cb371",mediumslateblue:"7b68ee",mediumspringgreen:"00fa9a",mediumturquoise:"48d1cc",mediumvioletred:"c71585",
18
+ midnightblue:"191970",mintcream:"f5fffa",mistyrose:"ffe4e1",moccasin:"ffe4b5",navajowhite:"ffdead",navy:"000080",oldlace:"fdf5e6",olive:"808000",olivedrab:"6b8e23",orange:"ffa500",orangered:"ff4500",orchid:"da70d6",palegoldenrod:"eee8aa",palegreen:"98fb98",paleturquoise:"afeeee",palevioletred:"db7093",papayawhip:"ffefd5",peachpuff:"ffdab9",peru:"cd853f",pink:"ffc0cb",plum:"dda0dd",powderblue:"b0e0e6",purple:"800080",red:"f00",rosybrown:"bc8f8f",royalblue:"4169e1",saddlebrown:"8b4513",salmon:"fa8072",
19
+ sandybrown:"f4a460",seagreen:"2e8b57",seashell:"fff5ee",sienna:"a0522d",silver:"c0c0c0",skyblue:"87ceeb",slateblue:"6a5acd",slategray:"708090",slategrey:"708090",snow:"fffafa",springgreen:"00ff7f",steelblue:"4682b4",tan:"d2b48c",teal:"008080",thistle:"d8bfd8",tomato:"ff6347",turquoise:"40e0d0",violet:"ee82ee",wheat:"f5deb3",white:"fff",whitesmoke:"f5f5f5",yellow:"ff0",yellowgreen:"9acd32"},G=d.hexNames=function(a){var c={},b;for(b in a)a.hasOwnProperty(b)&&(c[a[b]]=b);return c}(r);t=RegExp("rgb[\\s|\\(]+((?:[-\\+]?\\d*\\.\\d+%?)|(?:[-\\+]?\\d+%?))[,|\\s]+((?:[-\\+]?\\d*\\.\\d+%?)|(?:[-\\+]?\\d+%?))[,|\\s]+((?:[-\\+]?\\d*\\.\\d+%?)|(?:[-\\+]?\\d+%?))\\s*\\)?");
20
+ u=RegExp("rgba[\\s|\\(]+((?:[-\\+]?\\d*\\.\\d+%?)|(?:[-\\+]?\\d+%?))[,|\\s]+((?:[-\\+]?\\d*\\.\\d+%?)|(?:[-\\+]?\\d+%?))[,|\\s]+((?:[-\\+]?\\d*\\.\\d+%?)|(?:[-\\+]?\\d+%?))[,|\\s]+((?:[-\\+]?\\d*\\.\\d+%?)|(?:[-\\+]?\\d+%?))\\s*\\)?");v=RegExp("hsl[\\s|\\(]+((?:[-\\+]?\\d*\\.\\d+%?)|(?:[-\\+]?\\d+%?))[,|\\s]+((?:[-\\+]?\\d*\\.\\d+%?)|(?:[-\\+]?\\d+%?))[,|\\s]+((?:[-\\+]?\\d*\\.\\d+%?)|(?:[-\\+]?\\d+%?))\\s*\\)?");w=RegExp("hsla[\\s|\\(]+((?:[-\\+]?\\d*\\.\\d+%?)|(?:[-\\+]?\\d+%?))[,|\\s]+((?:[-\\+]?\\d*\\.\\d+%?)|(?:[-\\+]?\\d+%?))[,|\\s]+((?:[-\\+]?\\d*\\.\\d+%?)|(?:[-\\+]?\\d+%?))[,|\\s]+((?:[-\\+]?\\d*\\.\\d+%?)|(?:[-\\+]?\\d+%?))\\s*\\)?");
21
+ x=RegExp("hsv[\\s|\\(]+((?:[-\\+]?\\d*\\.\\d+%?)|(?:[-\\+]?\\d+%?))[,|\\s]+((?:[-\\+]?\\d*\\.\\d+%?)|(?:[-\\+]?\\d+%?))[,|\\s]+((?:[-\\+]?\\d*\\.\\d+%?)|(?:[-\\+]?\\d+%?))\\s*\\)?");z=/^([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/;y=/^([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/;"undefined"!==typeof module&&module.exports?module.exports=d:C.tinycolor=d})(this);
js/util.js CHANGED
@@ -1,165 +1,272 @@
1
  // To avoid duplicates conflicting
2
  var jQueryCrayon = jQuery;
3
 
4
- var CRAYON_DEBUG = false;
5
-
6
  (function ($) {
7
 
8
- $(document).ready(function() {
9
- CrayonUtil.init();
10
  });
11
-
12
- CrayonUtil = new function() {
13
-
14
- var base = this;
15
- var settings = null;
16
-
17
- base.init = function() {
18
- settings = CrayonSyntaxSettings;
19
- };
20
-
21
- base.addPrefixToID = function (id) {
22
- return id.replace(/^([#.])?(.*)$/, '$1' + settings.prefix + '$2');
23
- };
24
-
25
- base.removePrefixFromID = function(id) {
26
- var re = new RegExp('^[#.]?' + settings.prefix, 'i');
27
- return id.replace(re, '');
28
- };
29
-
30
- base.cssElem = function (id) {
31
- return $(base.addPrefixToID(id));
32
- };
33
-
34
- base.setDefault = function (v, d) {
35
- return (typeof v == 'undefined') ? d : v;
36
- };
37
-
38
- base.setMax = function (v, max) {
39
- return v <= max ? v : max;
40
- };
41
-
42
- base.setMin = function (v, min) {
43
- return v >= min ? v : min;
44
- };
45
-
46
- base.setRange = function (v, min, max) {
47
- return base.setMax(base.setMin(v, min), max);
48
- };
49
-
50
- base.initFancybox = function() {
51
- if (fancyboxInit) {
52
- // Initialise a custom version of Fancybox to avoid conflicting
53
- fancyboxInit(window, document, $, 'crayonFancybox');
54
- }
55
- }
56
-
57
- };
58
-
59
- // http://stackoverflow.com/questions/2360655/jquery-event-handlers-always-execute-in-order-they-were-bound-any-way-around-t
60
-
61
- // [name] is the name of the event "click", "mouseover", ..
62
- // same as you'd pass it to bind()
63
- // [fn] is the handler function
64
- $.fn.bindFirst = function(name, fn) {
65
- // bind as you normally would
66
- // don't want to miss out on any jQuery magic
67
- this.bind(name, fn);
68
- // Thanks to a comment by @Martin, adding support for
69
- // namespaced events too.
70
- var handlers = this.data('events')[name.split('.')[0]];
71
- // take out the handler we just inserted from the end
72
- var handler = handlers.pop();
73
- // move it at the beginning
74
- handlers.splice(0, 0, handler);
75
- };
76
 
77
- })(jQueryCrayon);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
78
 
79
- if (typeof CrayonTagEditorSettings == 'undefined') {
80
- // WP may have already added it
81
- CrayonTagEditorSettings = {};
82
- CrayonSettings = {};
83
- }
84
-
85
- RegExp.prototype.execAll = function(string) {
86
- var matches = [];
87
- var match = null;
88
- while ((match = this.exec(string)) != null) {
89
- var matchArray = [];
90
- for ( var i in match) {
91
- if (parseInt(i) == i) {
92
- matchArray.push(match[i]);
93
- }
94
- }
95
- matches.push(matchArray);
96
- }
97
- return matches;
98
- };
99
-
100
- // Escape regex chars with \
101
- RegExp.prototype.escape = function(text) {
102
- return text.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
103
- };
104
-
105
- String.prototype.sliceReplace = function(start, end, repl) {
106
- return this.substring(0, start) + repl + this.substring(end);
107
- };
108
-
109
- String.prototype.escape = function() {
110
- var tagsToReplace = {
111
- '&': '&amp;',
112
- '<': '&lt;',
113
- '>': '&gt;'
114
  };
115
- return this.replace(/[&<>]/g, function(tag) {
116
- return tagsToReplace[tag] || tag;
117
- });
118
- };
119
-
120
- String.prototype.linkify = function(target) {
121
- target = typeof target != 'undefined' ? target : '';
122
- return this.replace(/(http(s)?:\/\/(\S)+)/gmi, '<a href="$1" target="' + target + '">$1</a>');
123
- };
124
-
125
- function console_log(string) {
126
- if (typeof console != 'undefined' && CRAYON_DEBUG) {
127
- console.log(string);
128
- }
129
- }
130
-
131
- // # is left unencoded
132
- function crayon_escape(string) {
133
- if (typeof encodeURIComponent == 'function') {
134
- return encodeURIComponent(string);
135
- } else if (typeof escape != 'function') {
136
- return escape(string);
137
- } else {
138
- return string;
139
- }
140
- }
141
-
142
- function crayon_decode_html(str) {
143
- return String(str).replace(/&amp;/g, '&').replace(/&lt;/g, '<').replace(
144
- /&gt;/g, '>');
145
- }
146
-
147
- function crayon_encode_html(str) {
148
- return String(str).replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(
149
- />/g, '&gt;');
150
- }
151
-
152
- var CrayonSyntaxUtil = new function() {
153
- this.getExt = function(str) {
154
- if (str.indexOf('.') == -1) {
155
- return undefined;
156
- }
157
- var ext = str.split('.');
158
- if (ext.length) {
159
- ext = ext[ext.length - 1];
160
- } else {
161
- ext = '';
162
- }
163
- return ext;
164
- };
165
- };
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  // To avoid duplicates conflicting
2
  var jQueryCrayon = jQuery;
3
 
 
 
4
  (function ($) {
5
 
6
+ $(document).ready(function () {
7
+ CrayonUtil.init();
8
  });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
 
10
+ CrayonUtil = new function () {
11
+
12
+ var base = this;
13
+ var settings = null;
14
+
15
+ base.init = function () {
16
+ settings = CrayonSyntaxSettings;
17
+ base.initGET();
18
+ };
19
+
20
+ base.addPrefixToID = function (id) {
21
+ return id.replace(/^([#.])?(.*)$/, '$1' + settings.prefix + '$2');
22
+ };
23
+
24
+ base.removePrefixFromID = function (id) {
25
+ var re = new RegExp('^[#.]?' + settings.prefix, 'i');
26
+ return id.replace(re, '');
27
+ };
28
+
29
+ base.cssElem = function (id) {
30
+ return $(base.addPrefixToID(id));
31
+ };
32
+
33
+ base.setDefault = function (v, d) {
34
+ return (typeof v == 'undefined') ? d : v;
35
+ };
36
+
37
+ base.setMax = function (v, max) {
38
+ return v <= max ? v : max;
39
+ };
40
+
41
+ base.setMin = function (v, min) {
42
+ return v >= min ? v : min;
43
+ };
44
+
45
+ base.setRange = function (v, min, max) {
46
+ return base.setMax(base.setMin(v, min), max);
47
+ };
48
+
49
+ base.initFancybox = function () {
50
+ if (fancyboxInit) {
51
+ // Initialise a custom version of Fancybox to avoid conflicting
52
+ fancyboxInit(window, document, $, 'crayonFancybox');
53
+ }
54
+ };
55
+
56
+ base.getExt = function (str) {
57
+ if (str.indexOf('.') == -1) {
58
+ return undefined;
59
+ }
60
+ var ext = str.split('.');
61
+ if (ext.length) {
62
+ ext = ext[ext.length - 1];
63
+ } else {
64
+ ext = '';
65
+ }
66
+ return ext;
67
+ };
68
+
69
+ base.initGET = function () {
70
+ // URLs
71
+ window.currentURL = window.location.protocol + '//' + window.location.host + window.location.pathname;
72
+ window.currentDir = window.currentURL.substring(0, window.currentURL.lastIndexOf('/'));
73
+
74
+ // http://stackoverflow.com/questions/439463
75
+ function getQueryParams(qs) {
76
+ qs = qs.split("+").join(" ");
77
+ var params = {}, tokens, re = /[?&]?([^=]+)=([^&]*)/g;
78
+ while (tokens = re.exec(qs)) {
79
+ params[decodeURIComponent(tokens[1])] = decodeURIComponent(tokens[2]);
80
+ }
81
+ return params;
82
+ }
83
+
84
+ window.GET = getQueryParams(document.location.search);
85
+ };
86
+
87
+ base.getAJAX = function (args, callback) {
88
+ args.version = settings.version;
89
+ $.get(settings.ajaxurl, args, callback);
90
+ };
91
+
92
+ base.postAJAX = function (args, callback) {
93
+ args.version = settings.version;
94
+ $.post(settings.ajaxurl, args, callback);
95
+ };
96
+
97
+ base.reload = function () {
98
+ var get = '?';
99
+ for (var i in window.GET) {
100
+ get += i + '=' + window.GET[i] + '&';
101
+ }
102
+ window.location = window.currentURL + get;
103
+ };
104
+
105
+ base.escape = function (string) {
106
+ if (typeof encodeURIComponent == 'function') {
107
+ return encodeURIComponent(string);
108
+ } else if (typeof escape != 'function') {
109
+ return escape(string);
110
+ } else {
111
+ return string;
112
+ }
113
+ };
114
+
115
+ base.log = function (string) {
116
+ if (typeof console != 'undefined' && settings.debug) {
117
+ console.log(string);
118
+ }
119
+ };
120
+
121
+ base.decode_html = function (str) {
122
+ return String(str).replace(/&amp;/g, '&').replace(/&lt;/g, '<').replace(
123
+ /&gt;/g, '>');
124
+ };
125
+
126
+ base.encode_html = function (str) {
127
+ return String(str).replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(
128
+ />/g, '&gt;');
129
+ };
130
+
131
+ /**
132
+ * Returns either black or white to ensure this color is distinguishable with the given RGB hex.
133
+ * This function can be used to create a readable foreground color given a background color, or vice versa.
134
+ * It forms a radius around white where black is returned. Outside this radius, white is returned.
135
+ *
136
+ * @param hex An RGB hex (e.g. "#FFFFFF")
137
+ * @requires jQuery and TinyColor
138
+ * @param args The argument object. Properties:
139
+ * amount: a value in the range [0,1]. If the distance of the given hex from white exceeds this value,
140
+ * white is returned. Otherwise, black is returned.
141
+ * xMulti: a multiplier to the distance in the x-axis.
142
+ * yMulti: a multiplier to the distance in the y-axis.
143
+ * normalizeHue: either falsey or an [x,y] array range. If hex is a colour with hue in this range,
144
+ * then normalizeHueXMulti and normalizeHueYMulti are applied.
145
+ * normalizeHueXMulti: a multiplier to the distance in the x-axis if hue is normalized.
146
+ * normalizeHueYMulti: a multiplier to the distance in the y-axis if hue is normalized.
147
+ * @return the RGB hex string of black or white.
148
+ */
149
+ base.getReadableColor = function (hex, args) {
150
+ args = $.extend({
151
+ amount: 0.5,
152
+ xMulti: 1,
153
+ // We want to achieve white a bit sooner in the y axis
154
+ yMulti: 1.5,
155
+ normalizeHue: [20, 180],
156
+ // For colors that appear lighter (yellow, green, light blue) we reduce the distance in the x direction,
157
+ // stretching the radius in the x axis allowing more black than before.
158
+ normalizeHueXMulti: 1 / 2.5,
159
+ normalizeHueYMulti: 1
160
+ }, args);
161
+ var color = tinycolor(hex);
162
+ var hsv = color.toHsv();
163
+ // Origin is white
164
+ var coord = {x: hsv.s, y: 1 - hsv.v};
165
+ // Multipliers
166
+ coord.x *= args.xMulti;
167
+ coord.y *= args.yMulti;
168
+ if (args.normalizeHue && hsv.h > args.normalizeHue[0] && hsv.h < args.normalizeHue[1]) {
169
+ coord.x *= args.normalizeHueXMulti;
170
+ coord.y *= args.normalizeHueYMulti;
171
+ }
172
+ var dist = Math.sqrt(Math.pow(coord.x, 2) + Math.pow(coord.y, 2));
173
+ if (dist < args.amount) {
174
+ hsv.v = 0; // black
175
+ } else {
176
+ hsv.v = 1; // white
177
+ }
178
+ hsv.s = 0;
179
+ return tinycolor(hsv).toHexString();
180
+ };
181
+
182
+ base.removeChars = function (chars, str) {
183
+ var re = new RegExp('[' + chars + ']', 'gmi');
184
+ return str.replace(re, '');
185
+ }
186
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
187
  };
188
+
189
+ // http://stackoverflow.com/questions/2360655/jquery-event-handlers-always-execute-in-order-they-were-bound-any-way-around-t
190
+
191
+ // [name] is the name of the event "click", "mouseover", ..
192
+ // same as you'd pass it to bind()
193
+ // [fn] is the handler function
194
+ $.fn.bindFirst = function (name, fn) {
195
+ // bind as you normally would
196
+ // don't want to miss out on any jQuery magic
197
+ this.bind(name, fn);
198
+ // Thanks to a comment by @Martin, adding support for
199
+ // namespaced events too.
200
+ var handlers = this.data('events')[name.split('.')[0]];
201
+ // take out the handler we just inserted from the end
202
+ var handler = handlers.pop();
203
+ // move it at the beginning
204
+ handlers.splice(0, 0, handler);
205
+ };
206
+
207
+ // http://stackoverflow.com/questions/4079274/how-to-get-an-objects-properties-in-javascript-jquery
208
+ $.keys = function (obj) {
209
+ var keys = [];
210
+ for (var key in obj) {
211
+ keys.push(key);
212
+ }
213
+ return keys;
214
+ }
215
+
216
+ // Prototype modifications
217
+
218
+ RegExp.prototype.execAll = function (string) {
219
+ var matches = [];
220
+ var match = null;
221
+ while ((match = this.exec(string)) != null) {
222
+ var matchArray = [];
223
+ for (var i in match) {
224
+ if (parseInt(i) == i) {
225
+ matchArray.push(match[i]);
226
+ }
227
+ }
228
+ matches.push(matchArray);
229
+ }
230
+ return matches;
231
+ };
232
+
233
+ // Escape regex chars with \
234
+ RegExp.prototype.escape = function (text) {
235
+ return text.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
236
+ };
237
+
238
+ String.prototype.sliceReplace = function (start, end, repl) {
239
+ return this.substring(0, start) + repl + this.substring(end);
240
+ };
241
+
242
+ String.prototype.escape = function () {
243
+ var tagsToReplace = {
244
+ '&': '&amp;',
245
+ '<': '&lt;',
246
+ '>': '&gt;'
247
+ };
248
+ return this.replace(/[&<>]/g, function (tag) {
249
+ return tagsToReplace[tag] || tag;
250
+ });
251
+ };
252
+
253
+ String.prototype.linkify = function (target) {
254
+ target = typeof target != 'undefined' ? target : '';
255
+ return this.replace(/(http(s)?:\/\/(\S)+)/gmi, '<a href="$1" target="' + target + '">$1</a>');
256
+ };
257
+
258
+ String.prototype.toTitleCase = function () {
259
+ var parts = this.split(/\s+/);
260
+ var title = '';
261
+ $.each(parts, function (i, part) {
262
+ if (part != '') {
263
+ title += part.slice(0, 1).toUpperCase() + part.slice(1, part.length);
264
+ if (i != parts.length - 1 && parts[i + 1] != '') {
265
+ title += ' ';
266
+ }
267
+ }
268
+ });
269
+ return title;
270
+ };
271
+
272
+ })(jQueryCrayon);
langs/applescript/.DS_Store CHANGED
Binary file
langs/default/default.txt CHANGED
@@ -9,18 +9,18 @@
9
  PREPROCESSOR (#.*?$)
10
  STRING ((?<!\\)".*?(?<!\\)")|((?<!\\)'.*?(?<!\\)')
11
 
12
- STATEMENT \b(?alt:statement.txt)\b
13
- RESERVED \b(?<![:\.])(?alt:reserved.txt)\b
14
  # \b(?<![:\.])(?alt:reserved.txt)(?![:\.])\b
15
  TYPE \b(?alt:type.txt)\b
16
  MODIFIER \b(?alt:modifier.txt)\b
17
-
18
  # func() | func { | (Type) Var
19
- ENTITY (\b[a-z_]\w*\b(?=\s*\([^\)]*\)))|((?<!\.)(\b[a-z_]\w*\b)(?=[^},.:;"'\)]*{))|(\b[a-z_]\w+\b\s+(?=\b[a-z_]\w+\b))
20
- # C variants only: String *
21
- POINTER_TYPE:ENTITY (\b[a-z_]\w*\s*\*)
22
 
23
- VARIABLE \b(?<=\.)\s*[A-Za-z_]\w*
24
  IDENTIFIER \b[A-Za-z_]\w*\b
25
  CONSTANT (?<!\w)[0-9][\.\w]*
26
  OPERATOR (?alt:operator.txt)
9
  PREPROCESSOR (#.*?$)
10
  STRING ((?<!\\)".*?(?<!\\)")|((?<!\\)'.*?(?<!\\)')
11
 
12
+ STATEMENT \b(?alt:statement.txt)\b
13
+ RESERVED \b(?<![:\.])(?alt:reserved.txt)\b
14
  # \b(?<![:\.])(?alt:reserved.txt)(?![:\.])\b
15
  TYPE \b(?alt:type.txt)\b
16
  MODIFIER \b(?alt:modifier.txt)\b
17
+
18
  # func() | func { | (Type) Var
19
+ ENTITY (\b[a-z_]\w*\b(?=\s*\([^\)]*\)))|((?<!\.)(\b[a-z_]\w*\b)(?=[^},.:;"'\)]*{))|(\b[a-z_]\w+\b\s+(?=\b[a-z_]\w+\b))
20
+ # C variants only: String *
21
+ POINTER_TYPE:ENTITY (\b[a-z_]\w*\s*\*)
22
 
23
+ VARIABLE ((\b(?<=\.)\s*[A-Za-z_]\w*)|([A-Za-z_]\w*(?=\s*=)))
24
  IDENTIFIER \b[A-Za-z_]\w*\b
25
  CONSTANT (?<!\w)[0-9][\.\w]*
26
  OPERATOR (?alt:operator.txt)
langs/delphi/.DS_Store DELETED
Binary file
langs/objc/objc.txt CHANGED
@@ -12,16 +12,18 @@
12
 
13
  STATEMENT (?alt:statement_at.txt)\b|\b(?alt:statement.txt)\b
14
  RESERVED (?alt:reserved_at.txt)\b|\b(?alt:reserved.txt)\b
15
- TYPE \b(?alt:type.txt)\b|(\b[a-z_]\w+\b\s+(?=\b[a-z_][\w]+\b(?!\s*\:)))
 
16
  MODIFIER (?alt:modifier_at.txt)\b|\b(?alt:modifier.txt)\b
17
 
18
  CONSTANT (?default)|\b(?alt:constant.txt)\b
19
- ENTITY (\b[a-z_]\w*\b(?=\s*\([^\)]*\)))|(\b[a-z_]\w+\b\s+(?=\b[a-z_][\w]+\b(?!\s*\:)))|(?-i:NS[\w]+)
20
- FUNC:ENTITY \b\w+\b\s*(?=:[^;]*[\{;])
21
- POINTER_TYPE:TYPE (\b[a-z_]\w*\s*(?=\*)|\*(?=\s*\)))
22
- RETURN:TYPE \b\w+\b(?=\s*\)\s*\w+\s*[:;\{])
 
23
 
24
- VARIABLE (?default)|(\*\w+)
25
- IDENTIFIER (?default)
26
  OPERATOR (?default)
27
  SYMBOL (?default)
12
 
13
  STATEMENT (?alt:statement_at.txt)\b|\b(?alt:statement.txt)\b
14
  RESERVED (?alt:reserved_at.txt)\b|\b(?alt:reserved.txt)\b
15
+ TYPE \b(?alt:type.txt)\b|(?-i:\b[A-Z][\w]+)
16
+ # |(\b[a-z_]\w+\b\s+(?=\b[a-z_][\w]+\b(?!\s*\:)))
17
  MODIFIER (?alt:modifier_at.txt)\b|\b(?alt:modifier.txt)\b
18
 
19
  CONSTANT (?default)|\b(?alt:constant.txt)\b
20
+ ENTITY (\b[a-z_]\w*\b(?=\s*\([^\)]*\)))|(\b[a-z_]\w+\b\s+(?=\b[a-z_][\w]+\b(?!\s*\:)))
21
+ FUNC:ENTITY \s*(\b\w+\b\s*(?=:[^;]*[\{;])|(?<=\])\s*\w+)
22
+ #FUNC:ENTITY
23
+ POINTER_TYPE:TYPE (\b[a-z_]\w*\s*(?=\*)|\*(?=\s*\)))
24
+ RETURN:TYPE \b\w+\b(?=\s*\)\s*\w+\s*[:;\{])
25
 
26
+ VARIABLE (?default)|(\*[a-z]\w*)|((?<=\[)[a-z]\w*)|(:\s*([a-z]\w*))|([a-z]\w*)
27
+ IDENTIFIER (?<!\))(?default)
28
  OPERATOR (?default)
29
  SYMBOL (?default)
langs/php/php.txt CHANGED
@@ -20,7 +20,7 @@
20
  ENTITY (?default)|\b[a-z_]\w*::
21
  VARIABLE \$[a-z_]\w*\b
22
  OTHER_ID:IDENTIFIER \b[a-z_]\w*\b\s*(?=\([^\)]*\))
23
- CONSTANT (?-i)\b[A-Z_]*\b(?i)
24
  IDENTIFIER (?default)
25
  OPERATOR (?default)
26
  SYMBOL (?default)
20
  ENTITY (?default)|\b[a-z_]\w*::
21
  VARIABLE \$[a-z_]\w*\b
22
  OTHER_ID:IDENTIFIER \b[a-z_]\w*\b\s*(?=\([^\)]*\))
23
+ CONSTANT ((?-i)\b[A-Z_]*\b(?i))|((?default))
24
  IDENTIFIER (?default)
25
  OPERATOR (?default)
26
  SYMBOL (?default)
langs/readme.txt CHANGED
@@ -14,6 +14,10 @@ highlight them, you must add your custom CSS class into a Theme file.
14
  COMMENT [c]
15
  STRING [s]
16
 
 
 
 
 
17
  KEYWORD [k]
18
  STATEMENT [st]
19
  RESERVED [r]
14
  COMMENT [c]
15
  STRING [s]
16
 
17
+ PREPROCESSOR [p]
18
+
19
+ TAG [ta]
20
+
21
  KEYWORD [k]
22
  STATEMENT [st]
23
  RESERVED [r]
langs/vim/statement.txt ADDED
@@ -0,0 +1,180 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ filechangedshellpost
2
+ filechangedshell
3
+ spellfilemissing
4
+ usergettingbored
5
+ encodingchanged
6
+ filterwritepost
7
+ quickfixcmdpost
8
+ sessionloadpost
9
+ shellfilterpost
10
+ fileappendpost
11
+ filterreadpost
12
+ filterwritepre
13
+ quickfixcmdpre
14
+ fileappendcmd
15
+ fileappendpre
16
+ filechangedro
17
+ filewritepost
18
+ filterreadpre
19
+ funcundefined
20
+ stdinreadpost
21
+ bufwritepost
22
+ cursormovedi
23
+ filereadpost
24
+ filewritecmd
25
+ filewritepre
26
+ insertchange
27
+ shellcmdpost
28
+ stdinreadpre
29
+ termresponse
30
+ buffilepost
31
+ bufreadpost
32
+ bufwinenter
33
+ bufwinleave
34
+ bufwritecmd
35
+ bufwritepre
36
+ cmdwinenter
37
+ cmdwinleave
38
+ colorscheme
39
+ cursorholdi
40
+ cursormoved
41
+ filereadcmd
42
+ filereadpre
43
+ focusgained
44
+ insertenter
45
+ insertleave
46
+ remotereply
47
+ termchanged
48
+ vimleavepre
49
+ endfunction
50
+ buffilepre
51
+ bufnewfile
52
+ bufreadcmd
53
+ bufreadpre
54
+ bufwipeout
55
+ cursorhold
56
+ swapexists
57
+ vimresized
58
+ bufcreate
59
+ bufdelete
60
+ bufunload
61
+ cmd-event
62
+ focuslost
63
+ guifailed
64
+ highlight
65
+ menupopup
66
+ sourcecmd
67
+ sourcepre
68
+ unlockvar
69
+ bufenter
70
+ bufleave
71
+ bufwrite
72
+ continue
73
+ endwhile
74
+ filetype
75
+ function
76
+ guienter
77
+ nnoremap
78
+ setlocal
79
+ tabenter
80
+ tableave
81
+ unlockva
82
+ vimenter
83
+ vimleave
84
+ winenter
85
+ winleave
86
+ augroup
87
+ autocmd
88
+ bufread
89
+ confirm
90
+ continu
91
+ echoerr
92
+ echomsg
93
+ endwhil
94
+ execute
95
+ finally
96
+ functio
97
+ lockvar
98
+ unlockv
99
+ bufadd
100
+ bufnew
101
+ contin
102
+ echoer
103
+ echohl
104
+ echoms
105
+ elseif
106
+ endfor
107
+ endtry
108
+ endwhi
109
+ execut
110
+ finall
111
+ finish
112
+ functi
113
+ lockva
114
+ return
115
+ syntax
116
+ unlock
117
+ break
118
+ catch
119
+ conti
120
+ echoe
121
+ echoh
122
+ echom
123
+ echon
124
+ elsei
125
+ endfo
126
+ endif
127
+ endtr
128
+ endwh
129
+ execu
130
+ final
131
+ funct
132
+ lockv
133
+ match
134
+ retur
135
+ throw
136
+ unlet
137
+ unloc
138
+ while
139
+ brea
140
+ call
141
+ catc
142
+ cont
143
+ echo
144
+ else
145
+ endi
146
+ endt
147
+ endw
148
+ exec
149
+ fina
150
+ func
151
+ retu
152
+ thro
153
+ unle
154
+ unlo
155
+ user
156
+ whil
157
+ cat
158
+ con
159
+ els
160
+ end
161
+ exe
162
+ for
163
+ fun
164
+ let
165
+ map
166
+ set
167
+ thr
168
+ try
169
+ unl
170
+ whi
171
+ au
172
+ ec
173
+ el
174
+ en
175
+ hi
176
+ if
177
+ in
178
+ th
179
+ tr
180
+ wh
langs/vim/vim.txt ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ### MS DOS BATCH SCRIPT ###
2
+
3
+ # ELEMENT_NAME [optional-css-class] REGULAR_EXPRESSION
4
+
5
+ NAME Vim
6
+ VERSION 1.0
7
+
8
+ COMMENT \s*"[^"]*?$
9
+ STRING (?default)
10
+
11
+ VARIABLE (([a-z]:|&|@|&l|&g|$)\w+)|((?<=let)\b\s+\w+(:\w+)?)
12
+
13
+ STATEMENT \b(?alt:statement.txt)\b
14
+
15
+ ENTITY (?default)
16
+
17
+ IDENTIFIER (?default)
18
+ CONSTANT (?default)
19
+ OPERATOR (?default)
20
+ SYMBOL (?default)
readme.txt CHANGED
@@ -5,7 +5,7 @@ License: GPLv2 or later
5
  Tags: syntax highlighter, syntax, highlighter, highlighting, crayon, code highlighter, bbpress
6
  Requires at least: 3.0
7
  Tested up to: 3.5
8
- Stable tag: 1.17
9
 
10
  Syntax Highlighter supporting multiple languages, themes, fonts, highlighting from a URL, local file or post text.
11
 
@@ -16,6 +16,7 @@ It can highlight from a URL, a local file or Wordpress post text. Crayon makes i
16
  custom language elements with regular expressions.
17
  It also supports some neat features like:
18
 
 
19
  * <a href="http://ak.net84.net/projects/crayon-tag-editor/" target="_blank">Tag Editor</a> in both Visual & HTML editors
20
  * Toggled plain code
21
  * Toggled line numbers
@@ -105,6 +106,7 @@ See the <a href="http://ak.net84.net/projects/crayon-language-file-specification
105
  * Shell (Unix)
106
  * Transact-SQL
107
  * TeX
 
108
  * Visual Basic
109
  * YAML
110
  * Others will be added when requested
@@ -118,6 +120,7 @@ See the <a href="http://ak.net84.net/projects/crayon-language-file-specification
118
  * Italian (thanks to <a href="http://www.federicobellucci.net/" target="_blank">Federico Bellucci</a>)
119
  * Japanese (thanks to <a href="https://twitter.com/#!/west_323" target="_blank">@west_323</a>)
120
  * Lithuanian (thanks to <a href="http://www.host1free.com" target="_blank">Vincent G</a>)
 
121
  * Portuguese (thanks to <a href="http://www.adonai.eti.br" target="_blank">Adonai S. Canez</a>)
122
  * Spanish (thanks to <a href="http://www.hbravo.com/" target="_blank">Hermann Bravo</a>)
123
  * Russian (thanks to <a href="http://simplelib.com" target="_blank">Minimus</a> & <a href="http://atlocal.net/" target="_blank">Di_Skyer</a>)
@@ -170,6 +173,8 @@ A handful of articles from others written about Crayon, thanks guys!
170
 
171
  Thanks to all those who donate to my project, your support keeps the Crayons going!
172
 
 
 
173
  * Johannes Luijten, (http://www.tweaking4all.com/, http://www.weethet.nl/), USA
174
  * Jack Fruh, (http://basementjack.com/), USA
175
  * Ross Barbieri, USA
@@ -252,9 +257,26 @@ Contact me at http://twitter.com/crayonsyntax or crayon.syntax@gmail.com.
252
  2. Twilight theme.
253
  3. Mixed Language Highlighting.
254
  4. Tag Editor.
 
255
 
256
  == Changelog ==
257
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
258
  = 1.17 =
259
  * ADDED:
260
  * Selected text in the TinyMCE editor is now added into the code box of the Tag Editor
5
  Tags: syntax highlighter, syntax, highlighter, highlighting, crayon, code highlighter, bbpress
6
  Requires at least: 3.0
7
  Tested up to: 3.5
8
+ Stable tag: 2.0.0
9
 
10
  Syntax Highlighter supporting multiple languages, themes, fonts, highlighting from a URL, local file or post text.
11
 
16
  custom language elements with regular expressions.
17
  It also supports some neat features like:
18
 
19
+ * Integrated <a href="http://ak.net84.net/crayon/crayon-theme-editor/" target="_blank">Theme Editor!</a>
20
  * <a href="http://ak.net84.net/projects/crayon-tag-editor/" target="_blank">Tag Editor</a> in both Visual & HTML editors
21
  * Toggled plain code
22
  * Toggled line numbers
106
  * Shell (Unix)
107
  * Transact-SQL
108
  * TeX
109
+ * Vim
110
  * Visual Basic
111
  * YAML
112
  * Others will be added when requested
120
  * Italian (thanks to <a href="http://www.federicobellucci.net/" target="_blank">Federico Bellucci</a>)
121
  * Japanese (thanks to <a href="https://twitter.com/#!/west_323" target="_blank">@west_323</a>)
122
  * Lithuanian (thanks to <a href="http://www.host1free.com" target="_blank">Vincent G</a>)
123
+ * Polish (thanks to <a href="https://github.com/toszcze" target="_blank">Bartosz Romanowski</a>)
124
  * Portuguese (thanks to <a href="http://www.adonai.eti.br" target="_blank">Adonai S. Canez</a>)
125
  * Spanish (thanks to <a href="http://www.hbravo.com/" target="_blank">Hermann Bravo</a>)
126
  * Russian (thanks to <a href="http://simplelib.com" target="_blank">Minimus</a> & <a href="http://atlocal.net/" target="_blank">Di_Skyer</a>)
173
 
174
  Thanks to all those who donate to my project, your support keeps the Crayons going!
175
 
176
+ * Joseph DeVenuta, USA
177
+ * Iván Prego García, Spain
178
  * Johannes Luijten, (http://www.tweaking4all.com/, http://www.weethet.nl/), USA
179
  * Jack Fruh, (http://basementjack.com/), USA
180
  * Ross Barbieri, USA
257
  2. Twilight theme.
258
  3. Mixed Language Highlighting.
259
  4. Tag Editor.
260
+ 5. Theme Editor.
261
 
262
  == Changelog ==
263
 
264
+ = 2.0.0 =
265
+ * ADDED:
266
+ * Theme Editor allowing users to create and modify Crayon Themes!
267
+ * Polish translation (thanks to <a href="https://github.com/toszcze" target="_blank">Bartosz Romanowski</a>)
268
+ * Vim language
269
+ * Solarized themes (thanks to <a href="https://github.com/Greduan" target="_blank">Greduan</a>)
270
+ * Converting legacy tags now has an "encode" option. If selected, any legacy tag where the "decode" attribute is missing (neither true or false) has its code encoded and decode="true" specified.
271
+ * FIXED:
272
+ * Removed fancybox_init.js and integrated into util.js, other minor improvements in loading Tag Editor
273
+ * Improved expanding with shirt
274
+ * Issues with expanding a single line, other minor issues.
275
+ * Merged JS and PHP debugging toggle
276
+ * Moved everything towards camelCase from underscores
277
+ * Minor improvements to Objective-C
278
+ * Numerous bug fixes and improvements!
279
+
280
  = 1.17 =
281
  * ADDED:
282
  * Selected text in the TinyMCE editor is now added into the code box of the Tag Editor
screenshot-5.png ADDED
Binary file
themes/ado/ado.css CHANGED
@@ -1,172 +1,197 @@
1
- /*
2
- Theme Name: Ado
3
- Description: Classic extended.
4
- Version: 1.0
5
- Author: Andrea Dell'Orco
6
- Author URI: http://www.adostudio.it/
7
- */
8
-
9
- /* Code Style ====================== */
10
- .crayon-theme-ado {
11
- border: 1px #999 solid !important;
12
- text-shadow: none !important;
13
- background: #fdfdfd !important;
14
- }
15
-
16
- /* Inline Style */
17
- .crayon-theme-ado-inline {
18
- border: 1px solid #ddd !important;
19
- background: #fafafa !important;
20
- }
21
-
22
- /* Line Numbers */
23
- .crayon-theme-ado .crayon-nums {
24
- background: #333333 !important;
25
- color: #DEDEDE !important;
26
- border-right: 1px solid #202020 !important;
27
- }
28
-
29
- /* Selection */
30
- .crayon-theme-ado .crayon-code::selection,
31
- background: #BBEEDA !important;
32
- color: #269B6C !important;
33
- }
34
- .crayon-theme-ado::selection,
35
- .crayon-theme-ado .crayon-toolbar::selection,
36
- .crayon-theme-ado .crayon-toolbar *::selection,
37
- .crayon-theme-ado .crayon-info::selection,
38
- .crayon-theme-ado .crayon-info *::selection,
39
- .crayon-theme-ado .crayon-nums::selection,
40
- .crayon-theme-ado .crayon-nums *::selection {
41
- background: transparent !important;
42
- }
43
-
44
- /* Striped Lines */
45
- .crayon-theme-ado .crayon-striped-line {
46
- background: #f7f7f7 !important;
47
- border: 1px #CCC !important;
48
- }
49
- .crayon-theme-ado .crayon-striped-num {
50
- background: #5B5B5B !important;
51
- border: 1px #333 !important;
52
- color: #fff !important;
53
- }
54
-
55
- /* Marked Lines */
56
- .crayon-theme-ado .crayon-marked-line {
57
- background: #C7F1ED !important;
58
- border: 1px #9AE7DF !important;
59
- }
60
- .crayon-theme-ado .crayon-marked-num {
61
- color: #82DFC4 !important;
62
- background: #333333 !important;
63
- }
64
- .crayon-theme-ado .crayon-marked-line.crayon-striped-line {
65
- background: #B7EEE9 !important;
66
- }
67
- .crayon-theme-ado .crayon-marked-num.crayon-striped-num {
68
- background: #5B5B5B !important;
69
- color: #82DFC4 !important;
70
- }
71
- .crayon-theme-ado .crayon-marked-line.crayon-top,
72
- .crayon-theme-ado .crayon-marked-num.crayon-top {
73
- border-top-style: solid !important;
74
- }
75
- .crayon-theme-ado .crayon-marked-line.crayon-bottom,
76
- .crayon-theme-ado .crayon-marked-num.crayon-bottom {
77
- border-bottom-style: solid !important;
78
- }
79
-
80
- /* Info */
81
- .crayon-theme-ado .crayon-info {
82
- background: #E8E8E8 !important;
83
- border-bottom: 1px #888888 solid !important;
84
- color: #595959;
85
- }
86
-
87
- /* Toolbar */
88
- .crayon-theme-ado .crayon-toolbar {
89
- background: #DDD !important;
90
- border-bottom: 1px #BBB solid !important;
91
- }
92
- .crayon-theme-ado .crayon-toolbar > div {
93
- float: left !important;
94
- }
95
- .crayon-theme-ado .crayon-toolbar .crayon-tools {
96
- float: right !important;
97
- }
98
- .crayon-theme-ado .crayon-title {
99
- color: #333 !important;
100
- }
101
- .crayon-theme-ado .crayon-language {
102
- color: #999 !important;
103
- }
104
-
105
- /* Buttons */
106
- .crayon-theme-ado a.crayon-button {
107
- background-color: transparent;
108
- }
109
- .crayon-theme-ado a.crayon-button:hover,
110
- .crayon-theme-ado a.crayon-button.crayon-pressed:hover {
111
- background-color: #F2F2F2;
112
- color: #666;
113
- }
114
- /* :active MUST come after :hover */
115
- .crayon-theme-ado a.crayon-button.crayon-pressed,
116
- .crayon-theme-ado a.crayon-button.crayon-pressed:active,
117
- .crayon-theme-ado a.crayon-button:active {
118
- background-color: #BBB;
119
- color: #FFF;
120
- }
121
-
122
- /* End Code Style ================== */
123
-
124
- /* Syntax Highlighting ============= */
125
- .crayon-theme-ado .crayon-pre .c {
126
- color: #ff8000 !important;
127
- }
128
- .crayon-theme-ado .crayon-pre .p {
129
- color: #b85c00 !important;
130
- }
131
- .crayon-theme-ado .crayon-pre .s {
132
- color: #008000 !important;
133
- }
134
- .crayon-theme-ado .crayon-pre .k,
135
- .crayon-theme-ado .crayon-pre .st,
136
- .crayon-theme-ado .crayon-pre .r,
137
- .crayon-theme-ado .crayon-pre .t,
138
- .crayon-theme-ado .crayon-pre .m {
139
- color: #800080 !important;
140
- }
141
- .crayon-theme-ado .crayon-pre .ta {
142
- color: #FF0000 !important;
143
- }
144
- .crayon-theme-ado .crayon-pre .i {
145
- color: #000 !important;
146
- }
147
- .crayon-theme-ado .crayon-pre .v {
148
- color: #002D7A !important;
149
- }
150
- .crayon-theme-ado .crayon-pre .e {
151
- color: #004ed0 !important;
152
- }
153
- .crayon-theme-ado .crayon-pre .cn {
154
- color: #ce0000 !important;
155
- }
156
- .crayon-theme-ado .crayon-pre .o,
157
- .crayon-theme-ado .crayon-pre .h {
158
- color: #006fe0 !important;
159
- }
160
- .crayon-theme-ado .crayon-pre .sy {
161
- color: #333 !important;
162
- }
163
- .crayon-theme-ado .crayon-pre .n {
164
- color: #666 !important;
165
- font-style: italic;
166
- }
167
- .crayon-theme-ado .crayon-pre .f {
168
- color: #999 !important;
169
- }
170
- /* End Syntax Highlighting ========= */
171
-
172
- /* End Classic Scheme ============================================ */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ Name: Ado
3
+ Description: Classic extended.
4
+ Version: 1.0
5
+ Author: Andrea Dell'Orco
6
+ URL: http://www.adostudio.it/
7
+ */
8
+ .crayon-theme-ado {
9
+ border: 1px #999 solid !important;
10
+ text-shadow: none !important;
11
+ background: #fdfdfd !important;
12
+ }
13
+ .crayon-theme-ado-inline {
14
+ border: 1px solid #ddd !important;
15
+ background: #fafafa !important;
16
+ }
17
+ .crayon-theme-ado .crayon-nums {
18
+ background: #333333 !important;
19
+ color: #DEDEDE !important;
20
+ border-right: 1px solid #202020 !important;
21
+ }
22
+ .crayon-theme-ado .crayon-code::selection {
23
+ background: #BBEEDA !important;
24
+ color: #269B6C !important;
25
+ }
26
+ .crayon-theme-ado .crayon-code *::selection {
27
+ background: #BBEEDA !important;
28
+ color: #269B6C !important;
29
+ }
30
+ .crayon-theme-ado::selection {
31
+ background: transparent !important;
32
+ }
33
+ .crayon-theme-ado .crayon-toolbar::selection {
34
+ background: transparent !important;
35
+ }
36
+ .crayon-theme-ado .crayon-toolbar *::selection {
37
+ background: transparent !important;
38
+ }
39
+ .crayon-theme-ado .crayon-info::selection {
40
+ background: transparent !important;
41
+ }
42
+ .crayon-theme-ado .crayon-info *::selection {
43
+ background: transparent !important;
44
+ }
45
+ .crayon-theme-ado .crayon-nums::selection {
46
+ background: transparent !important;
47
+ }
48
+ .crayon-theme-ado .crayon-nums *::selection {
49
+ background: transparent !important;
50
+ }
51
+ .crayon-theme-ado .crayon-striped-line {
52
+ background: #f7f7f7 !important;
53
+ border: 1px #CCC !important;
54
+ }
55
+ .crayon-theme-ado .crayon-striped-num {
56
+ background: #5B5B5B !important;
57
+ border: 1px #333 !important;
58
+ color: #fff !important;
59
+ }
60
+ .crayon-theme-ado .crayon-marked-line {
61
+ background: #C7F1ED !important;
62
+ border: 1px #9AE7DF !important;
63
+ }
64
+ .crayon-theme-ado .crayon-marked-num {
65
+ color: #82DFC4 !important;
66
+ background: #333333 !important;
67
+ border-right: 1px solid #202020 !important;
68
+ }
69
+ .crayon-theme-ado .crayon-marked-line.crayon-striped-line {
70
+ background: #B7EEE9 !important;
71
+ }
72
+ .crayon-theme-ado .crayon-marked-num.crayon-striped-num {
73
+ background: #5B5B5B !important;
74
+ color: #82DFC4 !important;
75
+ }
76
+ .crayon-theme-ado .crayon-marked-line.crayon-top {
77
+ border-top-style: solid !important;
78
+ }
79
+ .crayon-theme-ado .crayon-marked-num.crayon-top {
80
+ border-top-style: solid !important;
81
+ }
82
+ .crayon-theme-ado .crayon-marked-line.crayon-bottom {
83
+ border-bottom-style: solid !important;
84
+ }
85
+ .crayon-theme-ado .crayon-marked-num.crayon-bottom {
86
+ border-bottom-style: solid !important;
87
+ }
88
+ .crayon-theme-ado .crayon-info {
89
+ background: #E8E8E8 !important;
90
+ border-bottom: 1px #888888 solid !important;
91
+ color: #595959;
92
+ }
93
+ .crayon-theme-ado .crayon-toolbar {
94
+ background: #DDD !important;
95
+ border-bottom: 1px #BBB solid !important;
96
+ }
97
+ .crayon-theme-ado .crayon-toolbar > div {
98
+ float: left !important;
99
+ }
100
+ .crayon-theme-ado .crayon-toolbar .crayon-tools {
101
+ float: right !important;
102
+ }
103
+ .crayon-theme-ado .crayon-title {
104
+ color: #333 !important;
105
+ }
106
+ .crayon-theme-ado .crayon-language {
107
+ color: #999 !important;
108
+ }
109
+ .crayon-theme-ado a.crayon-button {
110
+ background-color: transparent;
111
+ }
112
+ .crayon-theme-ado a.crayon-button:hover {
113
+ background-color: #F2F2F2;
114
+ color: #666;
115
+ }
116
+ .crayon-theme-ado a.crayon-button.crayon-pressed:hover {
117
+ background-color: #F2F2F2;
118
+ color: #666;
119
+ }
120
+ .crayon-theme-ado a.crayon-button.crayon-pressed {
121
+ background-color: #BBB;
122
+ color: #FFF;
123
+ }
124
+ .crayon-theme-ado a.crayon-button.crayon-pressed:active {
125
+ background-color: #BBB;
126
+ color: #FFF;
127
+ }
128
+ .crayon-theme-ado a.crayon-button:active {
129
+ background-color: #BBB;
130
+ color: #FFF;
131
+ }
132
+ .crayon-theme-ado .crayon-pre .c {
133
+ color: #ff8000 !important;
134
+ }
135
+ .crayon-theme-ado .crayon-pre .p {
136
+ color: #b85c00 !important;
137
+ }
138
+ .crayon-theme-ado .crayon-pre .s {
139
+ color: #008000 !important;
140
+ }
141
+ .crayon-theme-ado .crayon-pre .k {
142
+ color: #800080 !important;
143
+ }
144
+ .crayon-theme-ado .crayon-pre .st {
145
+ color: #800080 !important;
146
+ }
147
+ .crayon-theme-ado .crayon-pre .r {
148
+ color: #800080 !important;
149
+ }
150
+ .crayon-theme-ado .crayon-pre .t {
151
+ color: #800080 !important;
152
+ }
153
+ .crayon-theme-ado .crayon-pre .m {
154
+ color: #800080 !important;
155
+ }
156
+ .crayon-theme-ado .crayon-pre .ta {
157
+ color: #FF0000 !important;
158
+ }
159
+ .crayon-theme-ado .crayon-pre .i {
160
+ color: #000 !important;
161
+ }
162
+ .crayon-theme-ado .crayon-pre .v {
163
+ color: #002D7A !important;
164
+ }
165
+ .crayon-theme-ado .crayon-pre .e {
166
+ color: #004ed0 !important;
167
+ }
168
+ .crayon-theme-ado .crayon-pre .cn {
169
+ color: #ce0000 !important;
170
+ }
171
+ .crayon-theme-ado .crayon-pre .o {
172
+ color: #006fe0 !important;
173
+ }
174
+ .crayon-theme-ado .crayon-pre .h {
175
+ color: #006fe0 !important;
176
+ }
177
+ .crayon-theme-ado .crayon-pre .sy {
178
+ color: #333 !important;
179
+ }
180
+ .crayon-theme-ado .crayon-pre .n {
181
+ color: #666 !important;
182
+ font-style: italic;
183
+ }
184
+ .crayon-theme-ado .crayon-pre .f {
185
+ color: #999 !important;
186
+ }
187
+ .crayon-syntax {
188
+ -moz-border-radius: 5px;
189
+ -webkit-border-radius: 5px;
190
+ border-radius: 5px;
191
+ }
192
+ .crayon-table {
193
+ -moz-border-radius: 5px;
194
+ -webkit-border-radius: 5px;
195
+ border-radius: 5px;
196
+ overflow: hidden!important;
197
+ }
themes/classic/classic.css CHANGED
@@ -1,176 +1,171 @@
1
- /*
2
- Theme Name: Classic
3
- Description: Clean, crisp and colorful.
4
- Version: 1.3
5
- Author: Aram Kocharyan
6
- Author URI: http://ak.net84.net/
7
- */
8
-
9
- /* Code Style ====================== */
10
- .crayon-theme-classic {
11
- border: 1px #999 solid !important;
12
- text-shadow: none !important;
13
- }
14
-
15
- .crayon-theme-classic,
16
- .crayon-theme-classic .crayon-code {
17
- background: #fdfdfd !important;
18
- }
19
-
20
- /* Inline Style */
21
- .crayon-theme-classic-inline {
22
- border: 1px solid #ddd !important;
23
- background: #fafafa !important;
24
- }
25
-
26
- /* Line Numbers */
27
- .crayon-theme-classic .crayon-table .crayon-nums {
28
- background: #dfefff !important;
29
- color: #5499de !important;
30
- /* border-right: 1px solid #b3d3f3 !important; */
31
- }
32
-
33
- /* Selection */
34
- .crayon-theme-classic .crayon-code::selection,
35
- .crayon-theme-classic .crayon-code *::selection {
36
- background: #ddeeff !important;
37
- color: #316ba5 !important;
38
- }
39
- .crayon-theme-classic::selection,
40
- .crayon-theme-classic .crayon-toolbar::selection,
41
- .crayon-theme-classic .crayon-toolbar *::selection,
42
- .crayon-theme-classic .crayon-info::selection,
43
- .crayon-theme-classic .crayon-info *::selection,
44
- .crayon-theme-classic .crayon-nums::selection,
45
- .crayon-theme-classic .crayon-nums *::selection {
46
- background: transparent !important;
47
- }
48
-
49
- /* Striped Lines */
50
- .crayon-theme-classic .crayon-striped-line {
51
- background: #f7f7f7 !important;
52
- }
53
- .crayon-theme-classic .crayon-striped-num {
54
- background: #c8e1fa !important;
55
- color: #317cc5 !important;
56
- }
57
-
58
- /* Marked Lines */
59
- .crayon-theme-classic .crayon-marked-line {
60
- background: #fffee2 !important;
61
- border: 1px #e9e579 !important;
62
- }
63
- .crayon-theme-classic .crayon-marked-num {
64
- color: #1561ac !important;
65
- background: #b3d3f4 !important;
66
- border: 1px #5999d9 !important;
67
- }
68
- .crayon-theme-classic .crayon-marked-line.crayon-striped-line {
69
- background: #faf8d1 !important;
70
- }
71
- .crayon-theme-classic .crayon-marked-num.crayon-striped-num {
72
- background: #9ec5ec !important;
73
- color: #105395 !important;
74
- }
75
- .crayon-theme-classic .crayon-marked-line.crayon-top,
76
- .crayon-theme-classic .crayon-marked-num.crayon-top {
77
- border-top-style: solid !important;
78
- }
79
- .crayon-theme-classic .crayon-marked-line.crayon-bottom,
80
- .crayon-theme-classic .crayon-marked-num.crayon-bottom {
81
- border-bottom-style: solid !important;
82
- }
83
-
84
- /* Info */
85
- .crayon-theme-classic .crayon-info {
86
- background: #faf9d7 !important;
87
- border-bottom: 1px #b1af5e solid !important;
88
- color: #7e7d34;
89
- }
90
-
91
- /* Toolbar */
92
- .crayon-theme-classic .crayon-toolbar {
93
- background: #DDD !important;
94
- border-bottom: 1px #BBB solid !important;
95
- }
96
- .crayon-theme-classic .crayon-toolbar > div {
97
- float: left !important;
98
- }
99
- .crayon-theme-classic .crayon-toolbar .crayon-tools {
100
- float: right !important;
101
- }
102
- .crayon-theme-classic .crayon-title {
103
- color: #333 !important;
104
- }
105
- .crayon-theme-classic .crayon-language {
106
- color: #999 !important;
107
- }
108
-
109
- /* Buttons */
110
- .crayon-theme-classic a.crayon-button {
111
- background-color: transparent;
112
- }
113
- .crayon-theme-classic a.crayon-button:hover,
114
- .crayon-theme-classic a.crayon-button.crayon-pressed:hover {
115
- background-color: #EEE;
116
- color: #666;
117
- }
118
- /* :active MUST come after :hover */
119
- .crayon-theme-classic a.crayon-button.crayon-pressed,
120
- .crayon-theme-classic a.crayon-button.crayon-pressed:active,
121
- .crayon-theme-classic a.crayon-button:active {
122
- background-color: #BCBCBC;
123
- color: #FFF;
124
- }
125
-
126
- /* End Code Style ================== */
127
-
128
- /* Syntax Highlighting ============= */
129
- .crayon-theme-classic .crayon-pre .c {
130
- color: #ff8000 !important;
131
- }
132
- .crayon-theme-classic .crayon-pre .p {
133
- color: #b85c00 !important;
134
- }
135
- .crayon-theme-classic .crayon-pre .s {
136
- color: #008000 !important;
137
- }
138
- .crayon-theme-classic .crayon-pre .k,
139
- .crayon-theme-classic .crayon-pre .st,
140
- .crayon-theme-classic .crayon-pre .r,
141
- .crayon-theme-classic .crayon-pre .t,
142
- .crayon-theme-classic .crayon-pre .m {
143
- color: #800080 !important;
144
- }
145
- .crayon-theme-classic .crayon-pre .ta {
146
- color: #FF0000 !important;
147
- }
148
- .crayon-theme-classic .crayon-pre .i {
149
- color: #000 !important;
150
- }
151
- .crayon-theme-classic .crayon-pre .v {
152
- color: #002D7A !important;
153
- }
154
- .crayon-theme-classic .crayon-pre .e {
155
- color: #004ed0 !important;
156
- }
157
- .crayon-theme-classic .crayon-pre .cn {
158
- color: #ce0000 !important;
159
- }
160
- .crayon-theme-classic .crayon-pre .o,
161
- .crayon-theme-classic .crayon-pre .h {
162
- color: #006fe0 !important;
163
- }
164
- .crayon-theme-classic .crayon-pre .sy {
165
- color: #333 !important;
166
- }
167
- .crayon-theme-classic .crayon-pre .n {
168
- color: #666 !important;
169
- font-style: italic;
170
- }
171
- .crayon-theme-classic .crayon-pre .f {
172
- color: #999 !important;
173
- }
174
- /* End Syntax Highlighting ========= */
175
-
176
- /* End Classic Scheme ============================================ */
1
+ /*
2
+ Name: Classic
3
+ Description: Clean, crisp and colorful.
4
+ Version: 1.3
5
+ Author: Aram Kocharyan
6
+ URL: http://ak.net84.net/
7
+ */
8
+ .crayon-theme-classic {
9
+ border-width: 1px !important;
10
+ border-color: #999 !important;
11
+ border-style: solid !important;
12
+ text-shadow: none !important;
13
+ background: #fdfdfd !important;
14
+ }
15
+ .crayon-theme-classic-inline {
16
+ border-width: 1px !important;
17
+ border-color: #ddd !important;
18
+ border-style: solid !important;
19
+ background: #fafafa !important;
20
+ }
21
+ .crayon-theme-classic .crayon-table .crayon-nums {
22
+ background: #dfefff !important;
23
+ color: #5499de !important;
24
+ }
25
+ .crayon-theme-classic *::selection {
26
+ background: transparent !important;
27
+ }
28
+ .crayon-theme-classic .crayon-code *::selection {
29
+ background: #ddeeff !important;
30
+ color: #316ba5 !important;
31
+ }
32
+ .crayon-theme-classic .crayon-striped-line {
33
+ background: #f7f7f7 !important;
34
+ }
35
+ .crayon-theme-classic .crayon-striped-num {
36
+ background: #c8e1fa !important;
37
+ color: #317cc5 !important;
38
+ }
39
+ .crayon-theme-classic .crayon-marked-line {
40
+ background: #fffee2 !important;
41
+ border-width: 1px !important;
42
+ border-color: #e9e579 !important;
43
+ }
44
+ .crayon-theme-classic .crayon-marked-num {
45
+ color: #1561ac !important;
46
+ background: #b3d3f4 !important;
47
+ border-width: 1px !important;
48
+ border-color: #5999d9 !important;
49
+ }
50
+ .crayon-theme-classic .crayon-marked-line.crayon-striped-line {
51
+ background: #faf8d1 !important;
52
+ }
53
+ .crayon-theme-classic .crayon-marked-num.crayon-striped-num {
54
+ background: #9ec5ec !important;
55
+ color: #105395 !important;
56
+ }
57
+ .crayon-theme-classic .crayon-marked-line.crayon-top {
58
+ border-top-style: solid !important;
59
+ }
60
+ .crayon-theme-classic .crayon-marked-num.crayon-top {
61
+ border-top-style: solid !important;
62
+ }
63
+ .crayon-theme-classic .crayon-marked-line.crayon-bottom {
64
+ border-bottom-style: solid !important;
65
+ }
66
+ .crayon-theme-classic .crayon-marked-num.crayon-bottom {
67
+ border-bottom-style: solid !important;
68
+ }
69
+ .crayon-theme-classic .crayon-info {
70
+ background: #faf9d7 !important;
71
+ border-bottom-width: 1px !important;
72
+ border-bottom-color: #b1af5e !important;
73
+ border-bottom-style: solid !important;
74
+ color: #7e7d34;
75
+ }
76
+ .crayon-theme-classic .crayon-toolbar {
77
+ background: #DDD !important;
78
+ border-bottom-width: 1px !important;
79
+ border-bottom-color: #BBB !important;
80
+ border-bottom-style: solid !important;
81
+ }
82
+ .crayon-theme-classic .crayon-toolbar > div {
83
+ float: left !important;
84
+ }
85
+ .crayon-theme-classic .crayon-toolbar .crayon-tools {
86
+ float: right !important;
87
+ }
88
+ .crayon-theme-classic .crayon-title {
89
+ color: #333 !important;
90
+ }
91
+ .crayon-theme-classic .crayon-language {
92
+ color: #999 !important;
93
+ }
94
+ .crayon-theme-classic a.crayon-button {
95
+ background-color: transparent;
96
+ }
97
+ .crayon-theme-classic a.crayon-button:hover {
98
+ background-color: #EEE;
99
+ color: #666;
100
+ }
101
+ .crayon-theme-classic a.crayon-button.crayon-pressed:hover {
102
+ background-color: #EEE;
103
+ color: #666;
104
+ }
105
+ .crayon-theme-classic a.crayon-button.crayon-pressed {
106
+ background-color: #BCBCBC;
107
+ color: #FFF;
108
+ }
109
+ .crayon-theme-classic a.crayon-button.crayon-pressed:active {
110
+ background-color: #BCBCBC;
111
+ color: #FFF;
112
+ }
113
+ .crayon-theme-classic a.crayon-button:active {
114
+ background-color: #BCBCBC;
115
+ color: #FFF;
116
+ }
117
+ .crayon-theme-classic .crayon-pre .c {
118
+ color: #ff8000 !important;
119
+ }
120
+ .crayon-theme-classic .crayon-pre .s {
121
+ color: #008000 !important;
122
+ }
123
+ .crayon-theme-classic .crayon-pre .p {
124
+ color: #b85c00 !important;
125
+ }
126
+ .crayon-theme-classic .crayon-pre .ta {
127
+ color: #FF0000 !important;
128
+ }
129
+ .crayon-theme-classic .crayon-pre .k {
130
+ color: #800080 !important;
131
+ }
132
+ .crayon-theme-classic .crayon-pre .st {
133
+ color: #800080 !important;
134
+ }
135
+ .crayon-theme-classic .crayon-pre .r {
136
+ color: #800080 !important;
137
+ }
138
+ .crayon-theme-classic .crayon-pre .t {
139
+ color: #800080 !important;
140
+ }
141
+ .crayon-theme-classic .crayon-pre .m {
142
+ color: #800080 !important;
143
+ }
144
+ .crayon-theme-classic .crayon-pre .i {
145
+ color: #000 !important;
146
+ }
147
+ .crayon-theme-classic .crayon-pre .e {
148
+ color: #004ed0 !important;
149
+ }
150
+ .crayon-theme-classic .crayon-pre .v {
151
+ color: #002D7A !important;
152
+ }
153
+ .crayon-theme-classic .crayon-pre .cn {
154
+ color: #ce0000 !important;
155
+ }
156
+ .crayon-theme-classic .crayon-pre .o {
157
+ color: #006fe0 !important;
158
+ }
159
+ .crayon-theme-classic .crayon-pre .sy {
160
+ color: #333 !important;
161
+ }
162
+ .crayon-theme-classic .crayon-pre .n {
163
+ color: #666 !important;
164
+ font-style: italic;
165
+ }
166
+ .crayon-theme-classic .crayon-pre .f {
167
+ color: #999 !important;
168
+ }
169
+ .crayon-theme-classic .crayon-pre .h {
170
+ color: #006fe0 !important;
171
+ }
 
 
 
 
 
themes/epicgeeks/epicgeeks.css CHANGED
@@ -1,239 +1,185 @@
1
- /*
2
- Theme Name: Epicgeeks
3
- Description: Epicgeeks Theme.
4
- Version: 1.2
5
- Author: J. Newing (synmuffin)
6
- Author URI: http://epicgeeks.net/
7
- */
8
-
9
- .crayon-theme-epicgeeks {
10
- border: 1px #e1e1e1 solid !important;
11
- text-shadow: none !important;
12
- }
13
-
14
- .crayon-theme-epicgeeks,
15
- .crayon-theme-epicgeeks .crayon-code {
16
- background: #ffffe1 !important;
17
- }
18
-
19
- /* Inline Style */
20
- .crayon-theme-epicgeeks-inline {
21
- border: 1px solid #e1e1e1 !important;
22
- background: #ffffe1 !important;
23
- }
24
-
25
- .crayon-theme-epicgeeks .crayon-nums {
26
- background: #ffff9f !important;
27
- color: #333333 !important;
28
- border-right: 1px dashed #3cc0ff !important;
29
- }
30
-
31
- .crayon-theme-epicgeeks .crayon-code::selection,
32
- .crayon-theme-epicgeeks .crayon-code *::selection {
33
- background: #ddeeff !important;
34
- color: #316ba5 !important;
35
- }
36
- .crayon-theme-epicgeeks::selection,
37
- .crayon-theme-epicgeeks .crayon-toolbar::selection,
38
- .crayon-theme-epicgeeks .crayon-toolbar *::selection,
39
- .crayon-theme-epicgeeks .crayon-info::selection,
40
- .crayon-theme-epicgeeks .crayon-info *::selection,
41
- .crayon-theme-epicgeeks .crayon-nums::selection,
42
- .crayon-theme-epicgeeks .crayon-nums *::selection {
43
- background: transparent !important;
44
- }
45
-
46
- .crayon-theme-epicgeeks .crayon-striped-line {
47
- background: #ffffd2 !important;
48
- border: 1px dashed #f0f0f0;
49
- }
50
- .crayon-theme-epicgeeks .crayon-striped-line {
51
- background: #ffffd2 !important;
52
- border: 1px dashed #f0f0f0;
53
- }
54
- .crayon-theme-epicgeeks .crayon-striped-num {
55
- background: #ffff7c !important;
56
- border: 1px dashed #cccccc !important;
57
- }
58
-
59
- .crayon-theme-epicgeeks .crayon-marked-line {
60
- background: #fffee2 !important;
61
- border: 1px #e9e579 !important;
62
- }
63
-
64
- .crayon-theme-epicgeeks .crayon-marked-num {
65
- color: #1561ac !important;
66
- background: #f2f24b !important;
67
- border: 1px #E9E579 !important;
68
- }
69
-
70
- .crayon-theme-epicgeeks .crayon-striped-line,
71
- .crayon-theme-epicgeeks .crayon-striped-num {
72
- border-left: none !important;
73
- border-right: none !important;
74
- }
75
-
76
- .crayon-theme-epicgeeks .crayon-marked-line.crayon-striped-line {
77
- background: #faf8d1 !important;
78
- }
79
-
80
- .crayon-theme-epicgeeks .crayon-marked-num.crayon-striped-num {
81
- background: #dddd1c !important;
82
- color: #105395 !important;
83
- }
84
-
85
- .crayon-theme-epicgeeks .crayon-marked-line.crayon-top,
86
- .crayon-theme-epicgeeks .crayon-marked-num.crayon-top {
87
- border-top-style: solid !important;
88
- }
89
-
90
- .crayon-theme-epicgeeks .crayon-marked-line.crayon-bottom,
91
- .crayon-theme-epicgeeks .crayon-marked-num.crayon-bottom {
92
- border-bottom-style: solid !important;
93
- }
94
-
95
- .crayon-theme-epicgeeks .crayon-info {
96
- background: #faf9d7 !important;
97
- border-bottom: 1px dashed #b1af5e !important;
98
- color: #7e7d34;
99
- }
100
-
101
- .crayon-theme-epicgeeks .crayon-toolbar {
102
- background: #f9f9f9 !important;
103
- border-bottom: 1px solid #d2d2d2 !important;
104
- }
105
-
106
- .crayon-theme-epicgeeks .crayon-toolbar > div {
107
- float: left !important;
108
- }
109
-
110
- .crayon-theme-epicgeeks .crayon-toolbar .crayon-tools {
111
- float: right !important;
112
- }
113
-
114
- .crayon-theme-epicgeeks .crayon-title {
115
- color: #333333 !important;
116
- }
117
-
118
- .crayon-theme-epicgeeks .crayon-language {
119
- color: #999999 !important;
120
- }
121
- .crayon-theme-epicgeeks a.crayon-button:link {
122
- color: #666666 !important;
123
- }
124
-
125
- .crayon-theme-epicgeeks a.crayon-button:hover,
126
- .crayon-theme-epicgeeks a.crayon-button.crayon-pressed {
127
- color: #ffffff !important;
128
- }
129
-
130
- .crayon-theme-epicgeeks a.crayon-button:active {
131
- color: #666666 !important;
132
- }
133
-
134
- .crayon-syntax.crayon-theme-epicgeeks .crayon-toolbar a.crayon-button.crayon-plain-button:link {
135
- background: url('images/code.gif') no-repeat 0px -16px;
136
- }
137
-
138
- .crayon-syntax.crayon-theme-epicgeeks .crayon-toolbar a.crayon-button.crayon-plain-button:hover,
139
- .crayon-syntax.crayon-theme-epicgeeks .crayon-toolbar a.crayon-button.crayon-plain-button.crayon-pressed {
140
- background-position: 0px 0px;
141
- }
142
-
143
- .crayon-syntax.crayon-theme-epicgeeks .crayon-toolbar a.crayon-button.crayon-plain-button:active {
144
- background-position: 0px 0px;
145
- }
146
-
147
- .crayon-syntax.crayon-theme-epicgeeks .crayon-toolbar a.crayon-button.crayon-copy-button:link {
148
- background: url('images/copy.gif') no-repeat 0px -16px;
149
- }
150
-
151
- .crayon-syntax.crayon-theme-epicgeeks .crayon-toolbar a.crayon-button.crayon-copy-button:hover,
152
- .crayon-syntax.crayon-theme-epicgeeks .crayon-toolbar a.crayon-button.crayon-copy-button.crayon-pressed {
153
- background-position: 0px 0px;
154
- }
155
-
156
- .crayon-syntax.crayon-theme-epicgeeks .crayon-toolbar a.crayon-button.crayon-copy-button:active {
157
- background-position: 0px 0px;
158
- }
159
-
160
- .crayon-syntax.crayon-theme-epicgeeks .crayon-toolbar a.crayon-button.crayon-popup-button:link {
161
- background: url('images/pop.gif') no-repeat 0px -16px;
162
- }
163
-
164
- .crayon-syntax.crayon-theme-epicgeeks .crayon-toolbar a.crayon-button.crayon-popup-button:hover,
165
- .crayon-syntax.crayon-theme-epicgeeks .crayon-toolbar a.crayon-button.crayon-popup-button.crayon-pressed {
166
- background-position: 0px 0px;
167
- }
168
-
169
- .crayon-syntax.crayon-theme-epicgeeks .crayon-toolbar a.crayon-button.crayon-popup-button:active {
170
- background-position: 0px 0px;
171
- }
172
-
173
- .crayon-syntax.crayon-theme-epicgeeks .crayon-toolbar a.crayon-button.crayon-nums-button:link {
174
- background: url('images/list.gif') no-repeat 0px -16px;
175
- }
176
-
177
- .crayon-syntax.crayon-theme-epicgeeks .crayon-toolbar a.crayon-button.crayon-nums-button:hover,
178
- .crayon-syntax.crayon-theme-epicgeeks .crayon-toolbar a.crayon-button.crayon-nums-button.crayon-pressed {
179
- background-position: 0px 0px;
180
- }
181
-
182
- .crayon-syntax.crayon-theme-epicgeeks .crayon-toolbar a.crayon-button.crayon-nums-button:active {
183
- background-position: 0px 0px;
184
- }
185
-
186
- .crayon-syntax.crayon-theme-epicgeeks .crayon-title {
187
- float: left;
188
- }
189
-
190
- .crayon-theme-epicgeeks .crayon-pre .c {
191
- color: #787878 !important;
192
- }
193
- .crayon-theme-epicgeeks .crayon-pre .p {
194
- color: #a3a3a3 !important;
195
- }
196
- .crayon-theme-epicgeeks .crayon-pre .s {
197
- color: #90c300 !important;
198
- }
199
- .crayon-theme-epicgeeks .crayon-pre .k,
200
- .crayon-theme-epicgeeks .crayon-pre .st,
201
- .crayon-theme-epicgeeks .crayon-pre .r,
202
- .crayon-theme-epicgeeks .crayon-pre .t,
203
- .crayon-theme-epicgeeks .crayon-pre .m {
204
- color: #ff00aa !important;
205
- }
206
-
207
- .crayon-theme-epicgeeks .crayon-pre .i {
208
- color: #878787 !important;
209
- }
210
-
211
- .crayon-theme-epicgeeks .crayon-pre .v {
212
- color: #ca00ff !important;
213
- }
214
-
215
- .crayon-theme-epicgeeks .crayon-pre .e {
216
- color: #00d5ff !important;
217
- }
218
-
219
- .crayon-theme-epicgeeks .crayon-pre .cn {
220
- color: #e87b7b !important;
221
- }
222
-
223
- .crayon-theme-epicgeeks .crayon-pre .o,
224
- .crayon-theme-epicgeeks .crayon-pre .h {
225
- color: #006fe0 !important;
226
- }
227
-
228
- .crayon-theme-epicgeeks .crayon-pre .sy {
229
- color: #3c3c3c !important;
230
- }
231
-
232
- .crayon-theme-epicgeeks .crayon-pre .n {
233
- color: #b7b7b7 !important;
234
- font-style: italic;
235
- }
236
-
237
- .crayon-theme-epicgeeks .crayon-pre .f {
238
- color: #cfcfcf !important;
239
- }
1
+ /*
2
+ Name: Epicgeeks
3
+ Description: Epicgeeks Theme.
4
+ Version: 1.2
5
+ Author: J. Newing (synmuffin)
6
+ URL: http://epicgeeks.net/
7
+ */
8
+ .crayon-theme-epicgeeks {
9
+ border: 1px #e1e1e1 solid !important;
10
+ text-shadow: none !important;
11
+ background: #ffffe1 !important;
12
+ }
13
+ .crayon-theme-epicgeeks .crayon-code {
14
+ background: #fdfdfd !important;
15
+ }
16
+ .crayon-theme-epicgeeks-inline {
17
+ border: 1px solid #e1e1e1 !important;
18
+ background: #ffffe1 !important;
19
+ }
20
+ .crayon-theme-epicgeeks .crayon-table .crayon-nums {
21
+ background: #ffff9f !important;
22
+ color: #333333 !important;
23
+ border-right: 1px dashed #3cc0ff !important;
24
+ }
25
+ .crayon-theme-epicgeeks .crayon-code::selection {
26
+ background: #ddeeff !important;
27
+ color: #316ba5 !important;
28
+ }
29
+ .crayon-theme-epicgeeks .crayon-code *::selection {
30
+ background: #ddeeff !important;
31
+ color: #316ba5 !important;
32
+ }
33
+ .crayon-theme-epicgeeks::selection {
34
+ background: transparent !important;
35
+ }
36
+ .crayon-theme-epicgeeks .crayon-toolbar::selection {
37
+ background: transparent !important;
38
+ }
39
+ .crayon-theme-epicgeeks .crayon-toolbar *::selection {
40
+ background: transparent !important;
41
+ }
42
+ .crayon-theme-epicgeeks .crayon-info::selection {
43
+ background: transparent !important;
44
+ }
45
+ .crayon-theme-epicgeeks .crayon-info *::selection {
46
+ background: transparent !important;
47
+ }
48
+ .crayon-theme-epicgeeks .crayon-nums::selection {
49
+ background: transparent !important;
50
+ }
51
+ .crayon-theme-epicgeeks .crayon-nums *::selection {
52
+ background: transparent !important;
53
+ }
54
+ .crayon-theme-epicgeeks .crayon-striped-line {
55
+ background: #ffffd2 !important;
56
+ border: 1px dashed #f0f0f0;
57
+ }
58
+ .crayon-theme-epicgeeks .crayon-striped-num {
59
+ background: #ffff7c !important;
60
+ border: 1px dashed #cccccc !important;
61
+ }
62
+ .crayon-theme-epicgeeks .crayon-marked-line {
63
+ background: #fffee2 !important;
64
+ border: 1px #e9e579 !important;
65
+ }
66
+ .crayon-theme-epicgeeks .crayon-marked-num {
67
+ color: #1561ac !important;
68
+ background: #f2f24b !important;
69
+ border: 1px #E9E579 !important;
70
+ }
71
+ .crayon-theme-epicgeeks .crayon-marked-line.crayon-striped-line {
72
+ background: #faf8d1 !important;
73
+ }
74
+ .crayon-theme-epicgeeks .crayon-marked-num.crayon-striped-num {
75
+ background: #dddd1c !important;
76
+ color: #105395 !important;
77
+ }
78
+ .crayon-theme-epicgeeks .crayon-marked-line.crayon-top {
79
+ border-top-style: solid !important;
80
+ }
81
+ .crayon-theme-epicgeeks .crayon-marked-num.crayon-top {
82
+ border-top-style: solid !important;
83
+ }
84
+ .crayon-theme-epicgeeks .crayon-marked-line.crayon-bottom {
85
+ border-bottom-style: solid !important;
86
+ }
87
+ .crayon-theme-epicgeeks .crayon-marked-num.crayon-bottom {
88
+ border-bottom-style: solid !important;
89
+ }
90
+ .crayon-theme-epicgeeks .crayon-info {
91
+ background: #faf9d7 !important;
92
+ border-bottom: 1px #b1af5e dashed !important;
93
+ color: #7e7d34;
94
+ }
95
+ .crayon-theme-epicgeeks .crayon-toolbar {
96
+ background: #f9f9f9 !important;
97
+ border-bottom: 1px #d2d2d2 solid !important;
98
+ }
99
+ .crayon-theme-epicgeeks .crayon-toolbar > div {
100
+ float: left !important;
101
+ }
102
+ .crayon-theme-epicgeeks .crayon-toolbar .crayon-tools {
103
+ float: right !important;
104
+ }
105
+ .crayon-theme-epicgeeks .crayon-title {
106
+ color: #333 !important;
107
+ }
108
+ .crayon-theme-epicgeeks .crayon-language {
109
+ color: #999 !important;
110
+ }
111
+ .crayon-theme-epicgeeks a.crayon-button {
112
+ background-color: transparent;
113
+ }
114
+ .crayon-theme-epicgeeks a.crayon-button:hover {
115
+ background-color: #EFEFEF;
116
+ color: #666;
117
+ }
118
+ .crayon-theme-epicgeeks a.crayon-button.crayon-pressed:hover {
119
+ background-color: #EFEFEF;
120
+ color: #666;
121
+ }
122
+ .crayon-theme-epicgeeks a.crayon-button.crayon-pressed {
123
+ background-color: #DDD;
124
+ color: #FFF;
125
+ }
126
+ .crayon-theme-epicgeeks a.crayon-button.crayon-pressed:active {
127
+ background-color: #DDD;
128
+ color: #FFF;
129
+ }
130
+ .crayon-theme-epicgeeks a.crayon-button:active {
131
+ background-color: #DDD;
132
+ color: #FFF;
133
+ }
134
+ .crayon-theme-epicgeeks .crayon-pre .c {
135
+ color: #787878 !important;
136
+ }
137
+ .crayon-theme-epicgeeks .crayon-pre .p {
138
+ color: #a3a3a3 !important;
139
+ }
140
+ .crayon-theme-epicgeeks .crayon-pre .s {
141
+ color: #90c300 !important;
142
+ }
143
+ .crayon-theme-epicgeeks .crayon-pre .k {
144
+ color: #ff00aa !important;
145
+ }
146
+ .crayon-theme-epicgeeks .crayon-pre .st {
147
+ color: #ff00aa !important;
148
+ }
149
+ .crayon-theme-epicgeeks .crayon-pre .r {
150
+ color: #ff00aa !important;
151
+ }
152
+ .crayon-theme-epicgeeks .crayon-pre .t {
153
+ color: #ff00aa !important;
154
+ }
155
+ .crayon-theme-epicgeeks .crayon-pre .m {
156
+ color: #ff00aa !important;
157
+ }
158
+ .crayon-theme-epicgeeks .crayon-pre .i {
159
+ color: #878787 !important;
160
+ }
161
+ .crayon-theme-epicgeeks .crayon-pre .v {
162
+ color: #ca00ff !important;
163
+ }
164
+ .crayon-theme-epicgeeks .crayon-pre .e {
165
+ color: #00d5ff !important;
166
+ }
167
+ .crayon-theme-epicgeeks .crayon-pre .cn {
168
+ color: #e87b7b !important;
169
+ }
170
+ .crayon-theme-epicgeeks .crayon-pre .o {
171
+ color: #006fe0 !important;
172
+ }
173
+ .crayon-theme-epicgeeks .crayon-pre .h {
174
+ color: #006fe0 !important;
175
+ }
176
+ .crayon-theme-epicgeeks .crayon-pre .sy {
177
+ color: #3c3c3c !important;
178
+ }
179
+ .crayon-theme-epicgeeks .crayon-pre .n {
180
+ color: #b7b7b7 !important;
181
+ font-style: italic;
182
+ }
183
+ .crayon-theme-epicgeeks .crayon-pre .f {
184
+ color: #cfcfcf !important;
185
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
themes/neon/neon.css CHANGED
@@ -1,187 +1,201 @@
1
- /*
2
- Theme Name: Neon
3
- Description: Dark, elegant and electric.
4
- Version: 1.0
5
- Author: Di_Skyer
6
- Author URI: http://atlocal.net/
7
- */
8
-
9
- /* Code Style ====================== */
10
- .crayon-theme-neon {
11
- border: 1px #333 solid !important;
12
- text-shadow: none !important;
13
- color: #fff;
14
- }
15
-
16
- .crayon-theme-neon,
17
- .crayon-theme-neon .crayon-code {
18
- background: #2d2d2d !important;
19
- }
20
-
21
- /* Inline Style */
22
- .crayon-theme-neon-inline {
23
- border: 1px solid #333 !important;
24
- background: #333 !important;
25
- }
26
-
27
- .crayon-theme-neon span {
28
- color: #999 !important;
29
- }
30
-
31
- /* Line Numbers */
32
- .crayon-theme-neon .crayon-nums {
33
- border-right: 1px solid #333 !important;
34
- color: #333 !important;
35
- background: #777777 !important;
36
- }
37
-
38
- /* Selection */
39
- .crayon-theme-neon .crayon-code::selection,
40
- .crayon-theme-neon .crayon-code *::selection {
41
- background: #ddeeff !important;
42
- color: #316ba5 !important;
43
- }
44
- .crayon-theme-neon::selection,
45
- .crayon-theme-neon .crayon-toolbar::selection,
46
- .crayon-theme-neon .crayon-toolbar *::selection,
47
- .crayon-theme-neon .crayon-info::selection,
48
- .crayon-theme-neon .crayon-info *::selection,
49
- .crayon-theme-neon .crayon-nums::selection,
50
- .crayon-theme-neon .crayon-nums *::selection {
51
- background: #777 !important;
52
- }
53
-
54
- /* Striped Lines */
55
- .crayon-theme-neon .crayon-line {
56
- background: #050505 !important;
57
- }
58
-
59
- .crayon-theme-neon .crayon-striped-line {
60
- background: #000 !important;
61
- border: 1px #171717 !important;
62
- }
63
- .crayon-theme-neon .crayon-striped-num {
64
- background: #aaa !important;
65
- border: 1px #CCC !important;
66
- color: #555 !important;
67
- }
68
-
69
- /* Marked Lines */
70
- .crayon-theme-neon .crayon-marked-line {
71
- background: #484844 !important;
72
- border: 1px #222 !important;
73
- }
74
- .crayon-theme-neon .crayon-marked-num {
75
- color: #555 !important;
76
- background: #bbb !important;
77
- border: 1px #777 !important;
78
- }
79
- .crayon-theme-neon .crayon-marked-line.crayon-striped-line {
80
- background: #51514d !important;
81
- }
82
- .crayon-theme-neon .crayon-marked-num.crayon-striped-num {
83
- background: #ccc !important;
84
- color: #888 !important;
85
- }
86
- .crayon-theme-neon .crayon-marked-line.crayon-top,
87
- .crayon-theme-neon .crayon-marked-num.crayon-top {
88
- border-top-style: solid !important;
89
- }
90
- .crayon-theme-neon .crayon-marked-line.crayon-bottom,
91
- .crayon-theme-neon .crayon-marked-num.crayon-bottom {
92
- border-bottom-style: solid !important;
93
- }
94
-
95
- /* Info */
96
- .crayon-theme-neon .crayon-info {
97
- background: #faf9d7 !important;
98
- border-bottom: 1px #b1af5e solid !important;
99
- color: #7e7d34;
100
- }
101
-
102
- /* Toolbar */
103
- .crayon-theme-neon .crayon-toolbar {
104
- background: #b2b2b2 !important;
105
- border-bottom: 1px #666 solid !important;
106
- }
107
- .crayon-theme-neon .crayon-toolbar > div {
108
- float: left !important;
109
- }
110
- .crayon-theme-neon .crayon-toolbar .crayon-tools {
111
- float: right !important;
112
- }
113
- .crayon-theme-neon .crayon-title {
114
- color: #333 !important;
115
- }
116
- .crayon-theme-neon .crayon-language {
117
- color: #666 !important;
118
- }
119
  .crayon-theme-neon .crayon-toolbar .crayon-mixed-highlight {
120
- background-position: -24px center;
121
- }
122
-
123
- /* Buttons */
124
- .crayon-theme-neon a.crayon-button {
125
- background-color: transparent;
126
- }
127
- .crayon-theme-neon a.crayon-button:hover,
128
- .crayon-theme-neon a.crayon-button.crayon-pressed:hover {
129
- background-color: #ccc;
130
- color: #666;
131
- }
132
- /* :active MUST come after :hover */
133
- .crayon-theme-neon a.crayon-button.crayon-pressed,
134
- .crayon-theme-neon a.crayon-button.crayon-pressed:active,
135
- .crayon-theme-neon a.crayon-button:active {
136
- background-color: #999;
137
- color: #ccc;
138
- }
139
- /* End Code Style ================== */
140
-
141
- /* Syntax Highlighting ============= */
142
- .crayon-theme-neon .crayon-pre .c {
143
- color: #888 !important;
144
- }
145
- .crayon-theme-neon .crayon-pre .s {
146
- color: #99CC18 !important;
147
- }
148
- .crayon-theme-neon .crayon-pre .k,
149
- .crayon-theme-neon .crayon-pre .st,
150
- .crayon-theme-neon .crayon-pre .r,
151
- .crayon-theme-neon .crayon-pre .t,
152
- .crayon-theme-neon .crayon-pre .m {
153
- color: #EEEE33 !important;
154
- font-weight: bold;
155
- }
156
- .crayon-theme-neon .crayon-pre .ta {
157
- color: #AAA !important;
158
- }
159
- .crayon-theme-neon .crayon-pre .i {
160
- color: #fbefb1 !important;
161
- }
162
- .crayon-theme-neon .crayon-pre .v {
163
- color: #879ab2 !important;
164
- }
165
- .crayon-theme-neon .crayon-pre .e {
166
- color: #ED7218 !important;
167
- }
168
- .crayon-theme-neon .crayon-pre .cn {
169
- color: #FF2020 !important;
170
- }
171
- .crayon-theme-neon .crayon-pre .o,
172
- .crayon-theme-neon .crayon-pre .h {
173
- color: #ac99ab !important;
174
- }
175
- .crayon-theme-neon .crayon-pre .sy {
176
- color: #A069F8 !important;
177
- }
178
- .crayon-theme-neon .crayon-pre .n {
179
- color: #726e73 !important;
180
- font-style: italic;
181
- }
182
- .crayon-theme-neon .crayon-pre .f {
183
- color: #595959 !important;
184
- }
185
- /* End Syntax Highlighting ========= */
186
-
187
- /* End Classic Scheme ============================================ */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ Name: Neon
3
+ Description: Dark, elegant and electric.
4
+ Version: 1.0
5
+ Author: Di_Skyer
6
+ URL: http://atlocal.net/
7
+ */
8
+ .crayon-theme-neon {
9
+ border: 1px #333 solid !important;
10
+ text-shadow: none !important;
11
+ color: #fff;
12
+ background: #2d2d2d !important;
13
+ }
14
+ .crayon-theme-neon .crayon-code {
15
+ background: #2d2d2d !important;
16
+ }
17
+ .crayon-theme-neon-inline {
18
+ border: 1px solid #333 !important;
19
+ background: #333 !important;
20
+ }
21
+ .crayon-theme-neon span {
22
+ color: #999 !important;
23
+ }
24
+ .crayon-theme-neon .crayon-nums {
25
+ border-right: 1px solid #333 !important;
26
+ color: #333 !important;
27
+ background: #777777 !important;
28
+ }
29
+ .crayon-theme-neon .crayon-code::selection {
30
+ background: #ddeeff !important;
31
+ color: #316ba5 !important;
32
+ }
33
+ .crayon-theme-neon .crayon-code *::selection {
34
+ background: #ddeeff !important;
35
+ color: #316ba5 !important;
36
+ }
37
+ .crayon-theme-neon::selection {
38
+ background: #777 !important;
39
+ }
40
+ .crayon-theme-neon .crayon-toolbar::selection {
41
+ background: #777 !important;
42
+ }
43
+ .crayon-theme-neon .crayon-toolbar *::selection {
44
+ background: #777 !important;
45
+ }
46
+ .crayon-theme-neon .crayon-info::selection {
47
+ background: #777 !important;
48
+ }
49
+ .crayon-theme-neon .crayon-info *::selection {
50
+ background: #777 !important;
51
+ }
52
+ .crayon-theme-neon .crayon-nums::selection {
53
+ background: #777 !important;
54
+ }
55
+ .crayon-theme-neon .crayon-nums *::selection {
56
+ background: #777 !important;
57
+ }
58
+ .crayon-theme-neon .crayon-line {
59
+ background: #050505 !important;
60
+ }
61
+ .crayon-theme-neon .crayon-striped-line {
62
+ background: #000 !important;
63
+ border: 1px #171717 !important;
64
+ }
65
+ .crayon-theme-neon .crayon-striped-num {
66
+ background: #aaa !important;
67
+ border: 1px #CCC !important;
68
+ color: #555 !important;
69
+ }
70
+ .crayon-theme-neon .crayon-marked-line {
71
+ background: #484844 !important;
72
+ border: 1px #222 !important;
73
+ }
74
+ .crayon-theme-neon .crayon-marked-num {
75
+ color: #555 !important;
76
+ background: #bbb !important;
77
+ border: 1px #777 !important;
78
+ }
79
+ .crayon-theme-neon .crayon-marked-line.crayon-striped-line {
80
+ background: #51514d !important;
81
+ }
82
+ .crayon-theme-neon .crayon-marked-num.crayon-striped-num {
83
+ background: #ccc !important;
84
+ color: #888 !important;
85
+ }
86
+ .crayon-theme-neon .crayon-marked-line.crayon-top {
87
+ border-top-style: solid !important;
88
+ }
89
+ .crayon-theme-neon .crayon-marked-num.crayon-top {
90
+ border-top-style: solid !important;
91
+ }
92
+ .crayon-theme-neon .crayon-marked-line.crayon-bottom {
93
+ border-bottom-style: solid !important;
94
+ }
95
+ .crayon-theme-neon .crayon-marked-num.crayon-bottom {
96
+ border-bottom-style: solid !important;
97
+ }
98
+ .crayon-theme-neon .crayon-info {
99
+ background: #faf9d7 !important;
100
+ border-bottom: 1px #b1af5e solid !important;
101
+ color: #7e7d34;
102
+ }
103
+ .crayon-theme-neon .crayon-toolbar {
104
+ background: #b2b2b2 !important;
105
+ border-bottom: 1px #666 solid !important;
106
+ }
107
+ .crayon-theme-neon .crayon-toolbar > div {
108
+ float: left !important;
109
+ }
110
+ .crayon-theme-neon .crayon-toolbar .crayon-tools {
111
+ float: right !important;
112
+ }
113
+ .crayon-theme-neon .crayon-title {
114
+ color: #333 !important;
115
+ }
116
+ .crayon-theme-neon .crayon-language {
117
+ color: #666 !important;
118
+ }
119
  .crayon-theme-neon .crayon-toolbar .crayon-mixed-highlight {
120
+ background-position: -24px center;
121
+ }
122
+ .crayon-theme-neon a.crayon-button {
123
+ background-color: transparent;
124
+ }
125
+ .crayon-theme-neon a.crayon-button:hover {
126
+ background-color: #ccc;
127
+ color: #666;
128
+ }
129
+ .crayon-theme-neon a.crayon-button.crayon-pressed:hover {
130
+ background-color: #ccc;
131
+ color: #666;
132
+ }
133
+ .crayon-theme-neon a.crayon-button.crayon-pressed {
134
+ background-color: #999;
135
+ color: #ccc;
136
+ }
137
+ .crayon-theme-neon a.crayon-button.crayon-pressed:active {
138
+ background-color: #999;
139
+ color: #ccc;
140
+ }
141
+ .crayon-theme-neon a.crayon-button:active {
142
+ background-color: #999;
143
+ color: #ccc;
144
+ }
145
+ .crayon-theme-neon .crayon-pre .c {
146
+ color: #888 !important;
147
+ }
148
+ .crayon-theme-neon .crayon-pre .s {
149
+ color: #99CC18 !important;
150
+ }
151
+ .crayon-theme-neon .crayon-pre .k {
152
+ color: #EEEE33 !important;
153
+ font-weight: bold;
154
+ }
155
+ .crayon-theme-neon .crayon-pre .st {
156
+ color: #EEEE33 !important;
157
+ font-weight: bold;
158
+ }
159
+ .crayon-theme-neon .crayon-pre .r {
160
+ color: #EEEE33 !important;
161
+ font-weight: bold;
162
+ }
163
+ .crayon-theme-neon .crayon-pre .t {
164
+ color: #EEEE33 !important;
165
+ font-weight: bold;
166
+ }
167
+ .crayon-theme-neon .crayon-pre .m {
168
+ color: #EEEE33 !important;
169
+ font-weight: bold;
170
+ }
171
+ .crayon-theme-neon .crayon-pre .ta {
172
+ color: #AAA !important;
173
+ }
174
+ .crayon-theme-neon .crayon-pre .i {
175
+ color: #fbefb1 !important;
176
+ }
177
+ .crayon-theme-neon .crayon-pre .v {
178
+ color: #879ab2 !important;
179
+ }
180
+ .crayon-theme-neon .crayon-pre .e {
181
+ color: #ED7218 !important;
182
+ }
183
+ .crayon-theme-neon .crayon-pre .cn {
184
+ color: #FF2020 !important;
185
+ }
186
+ .crayon-theme-neon .crayon-pre .o {
187
+ color: #ac99ab !important;
188
+ }
189
+ .crayon-theme-neon .crayon-pre .h {
190
+ color: #ac99ab !important;
191
+ }
192
+ .crayon-theme-neon .crayon-pre .sy {
193
+ color: #A069F8 !important;
194
+ }
195
+ .crayon-theme-neon .crayon-pre .n {
196
+ color: #726e73 !important;
197
+ font-style: italic;
198
+ }
199
+ .crayon-theme-neon .crayon-pre .f {
200
+ color: #595959 !important;
201
+ }
themes/solarized-dark/solarized-dark.css CHANGED
@@ -1,174 +1,183 @@
1
  /*
2
- Theme Name: Solarized Dark
3
  Description: Clean, crisp and colorful.
4
  Version: 1.0.0 Beta 2
5
  Author: Ethan Schoonover
6
- Author URI: http://ethanschoonover.com/
 
 
 
7
  */
8
-
9
- /* Code Style ====================== */
10
  .crayon-theme-solarized-dark {
11
- border: 1px #999 solid !important;
12
- text-shadow: none !important;
 
13
  }
14
-
15
- .crayon-theme-solarized-dark,
16
  .crayon-theme-solarized-dark .crayon-code {
17
  background: #002b36 !important;
18
  }
19
-
20
- /* Inline Style */
21
  .crayon-theme-solarized-dark-inline {
22
  border: 1px solid #ddd !important;
23
  background: #002b36 !important;
24
  }
25
-
26
- /* Line Numbers */
27
  .crayon-theme-solarized-dark .crayon-nums {
28
  background: #073642 !important;
29
  color: #586e75 !important;
30
  border-right: 1px solid #b3d3f3 !important;
31
  }
32
-
33
- /* Selection */
34
- .crayon-theme-solarized-dark .crayon-code::selection,
 
35
  .crayon-theme-solarized-dark .crayon-code *::selection {
36
- background: #ddeeff !important;
37
- color: #316ba5 !important;
38
- }
39
- .crayon-theme-solarized-dark::selection,
40
- .crayon-theme-solarized-dark .crayon-toolbar::selection,
41
- .crayon-theme-solarized-dark .crayon-toolbar *::selection,
42
- .crayon-theme-solarized-dark .crayon-info::selection,
43
- .crayon-theme-solarized-dark .crayon-info *::selection,
44
- .crayon-theme-solarized-dark .crayon-nums::selection,
 
 
 
 
 
 
 
 
 
 
 
 
45
  .crayon-theme-solarized-dark .crayon-nums *::selection {
46
- background: transparent !important;
47
  }
48
-
49
- /* Striped Lines */
50
  .crayon-theme-solarized-dark .crayon-striped-line {
51
- background: #073642 !important;
52
- border: 1px #CCC !important;
53
  }
54
  .crayon-theme-solarized-dark .crayon-striped-num {
55
  border: 1px #CCC !important;
56
- color: #586e75 !important;
57
- background: #054150 !important;
58
  }
59
-
60
- /* Marked Lines */
61
  .crayon-theme-solarized-dark .crayon-marked-line {
62
- background: #2f4d54 !important;
63
- border-color: #446b73;
64
- border-width: 1px;
65
  }
66
  .crayon-theme-solarized-dark .crayon-marked-num {
67
- color: #586e75 !important;
68
- background: #024e61 !important;
69
- border: 1px #4e747d !important;
70
  }
71
  .crayon-theme-solarized-dark .crayon-marked-line.crayon-striped-line {
72
- background: #2b474e !important;
73
  }
74
  .crayon-theme-solarized-dark .crayon-marked-num.crayon-striped-num {
75
- background: #2a444a !important;
 
 
 
 
 
76
  }
77
- .crayon-theme-solarized-dark .crayon-marked-line.crayon-top,
78
  .crayon-theme-solarized-dark .crayon-marked-num.crayon-top {
79
- border-top-style: solid !important;
 
 
 
 
 
 
 
80
  }
81
- .crayon-theme-solarized-dark .crayon-marked-line.crayon-bottom,
82
  .crayon-theme-solarized-dark .crayon-marked-num.crayon-bottom {
83
- border-bottom-style: solid !important;
 
 
84
  }
85
-
86
- /* Info */
87
  .crayon-theme-solarized-dark .crayon-info {
88
- background: #faf9d7 !important;
89
- border-bottom: 1px #b1af5e solid !important;
90
- color: #7e7d34;
91
  }
92
-
93
- /* Toolbar */
94
  .crayon-theme-solarized-dark .crayon-toolbar {
95
- background: #DDD !important;
96
- border-bottom: 1px #BBB solid !important;
97
  }
98
  .crayon-theme-solarized-dark .crayon-toolbar > div {
99
- float: left !important;
100
  }
101
  .crayon-theme-solarized-dark .crayon-toolbar .crayon-tools {
102
- float: right !important;
103
  }
104
  .crayon-theme-solarized-dark .crayon-title {
105
- color: #333 !important;
106
  }
107
  .crayon-theme-solarized-dark .crayon-language {
108
- color: #999 !important;
109
  }
110
-
111
- /* Buttons */
112
  .crayon-theme-solarized-dark a.crayon-button {
113
  background-color: transparent;
114
  }
115
- .crayon-theme-solarized-dark a.crayon-button:hover,
 
 
 
116
  .crayon-theme-solarized-dark a.crayon-button.crayon-pressed:hover {
117
  background-color: #EEE;
118
- color: #666;
 
 
 
 
 
 
 
 
119
  }
120
- /* :active MUST come after :hover */
121
- .crayon-theme-solarized-dark a.crayon-button.crayon-pressed,
122
- .crayon-theme-solarized-dark a.crayon-button.crayon-pressed:active,
123
  .crayon-theme-solarized-dark a.crayon-button:active {
124
  background-color: #BCBCBC;
125
- color: #FFF;
126
  }
127
-
128
- /* End Code Style ================== */
129
-
130
- /* Syntax Highlighting ============= */
131
  .crayon-theme-solarized-dark .crayon-pre .c {
132
- color: #586e75 !important;
133
- }
134
- .crayon-theme-solarized-dark .crayon-pre .p {
135
- color: #839496 !important;
136
  }
137
  .crayon-theme-solarized-dark .crayon-pre .s {
138
- color: #2aa198 !important;
 
 
 
 
 
 
 
 
 
139
  }
140
- .crayon-theme-solarized-dark .crayon-pre .k,
141
- .crayon-theme-solarized-dark .crayon-pre .r,
142
- .crayon-theme-solarized-dark .crayon-pre .st,
143
  .crayon-theme-solarized-dark .crayon-pre .t {
144
- color: #b58900 !important;
145
  }
146
  .crayon-theme-solarized-dark .crayon-pre .m {
147
- color: #859900 !important;
148
- }
149
- .crayon-theme-solarized-dark .crayon-pre .ta {
150
- color: #FF0000 !important;
151
  }
152
  .crayon-theme-solarized-dark .crayon-pre .i {
153
- color: #839496 !important;
154
- }
155
- .crayon-theme-solarized-dark .crayon-pre .v {
156
- color: #839496 !important;
157
  }
158
  .crayon-theme-solarized-dark .crayon-pre .e {
159
  color: #839496 !important;
160
  }
 
 
 
161
  .crayon-theme-solarized-dark .crayon-pre .cn {
162
- color: #ce0000 !important;
163
  }
164
  .crayon-theme-solarized-dark .crayon-pre .o {
165
- color: #839496 !important;
166
- }
167
- .crayon-theme-solarized-dark .crayon-pre .h {
168
- color: #dc322f !important;
169
  }
170
  .crayon-theme-solarized-dark .crayon-pre .sy {
171
- color: #839496 !important;
172
  }
173
  .crayon-theme-solarized-dark .crayon-pre .n {
174
  color: #666 !important;
@@ -177,6 +186,12 @@ Author URI: http://ethanschoonover.com/
177
  .crayon-theme-solarized-dark .crayon-pre .f {
178
  color: #999 !important;
179
  }
180
- /* End Syntax Highlighting ========= */
181
-
182
- /* End Classic Scheme ============================================ */
 
 
 
 
 
 
1
  /*
2
+ Name: Solarized Dark
3
  Description: Clean, crisp and colorful.
4
  Version: 1.0.0 Beta 2
5
  Author: Ethan Schoonover
6
+ URL: http://ethanschoonover.com/
7
+ Maintainer: Eduan Lavaque
8
+ Maintainer URL: http://eduantech.com/
9
+ Notes: I don't provide striped lines because it would break the original purpose of this colorscheme.
10
  */
 
 
11
  .crayon-theme-solarized-dark {
12
+ border: 1px #999 solid !important;
13
+ text-shadow: none !important;
14
+ background: #002b36 !important;
15
  }
 
 
16
  .crayon-theme-solarized-dark .crayon-code {
17
  background: #002b36 !important;
18
  }
 
 
19
  .crayon-theme-solarized-dark-inline {
20
  border: 1px solid #ddd !important;
21
  background: #002b36 !important;
22
  }
 
 
23
  .crayon-theme-solarized-dark .crayon-nums {
24
  background: #073642 !important;
25
  color: #586e75 !important;
26
  border-right: 1px solid #b3d3f3 !important;
27
  }
28
+ .crayon-theme-solarized-dark .crayon-code::selection {
29
+ background: #ddeeff !important;
30
+ color: #316ba5 !important;
31
+ }
32
  .crayon-theme-solarized-dark .crayon-code *::selection {
33
+ background: #ddeeff !important;
34
+ color: #316ba5 !important;
35
+ }
36
+ .crayon-theme-solarized-dark::selection {
37
+ background: transparent !important;
38
+ }
39
+ .crayon-theme-solarized-dark .crayon-toolbar::selection {
40
+ background: transparent !important;
41
+ }
42
+ .crayon-theme-solarized-dark .crayon-toolbar *::selection {
43
+ background: transparent !important;
44
+ }
45
+ .crayon-theme-solarized-dark .crayon-info::selection {
46
+ background: transparent !important;
47
+ }
48
+ .crayon-theme-solarized-dark .crayon-info *::selection {
49
+ background: transparent !important;
50
+ }
51
+ .crayon-theme-solarized-dark .crayon-nums::selection {
52
+ background: transparent !important;
53
+ }
54
  .crayon-theme-solarized-dark .crayon-nums *::selection {
55
+ background: transparent !important;
56
  }
 
 
57
  .crayon-theme-solarized-dark .crayon-striped-line {
58
+ background: #002b36 !important;
59
+ border: 1px #CCC !important;
60
  }
61
  .crayon-theme-solarized-dark .crayon-striped-num {
62
  border: 1px #CCC !important;
63
+ color: #586e75 !important;
64
+ background: #073642 !important;
65
  }
 
 
66
  .crayon-theme-solarized-dark .crayon-marked-line {
67
+ background: #073642 !important;
 
 
68
  }
69
  .crayon-theme-solarized-dark .crayon-marked-num {
70
+ color: #586e75 !important;
71
+ background: #002b36 !important;
 
72
  }
73
  .crayon-theme-solarized-dark .crayon-marked-line.crayon-striped-line {
74
+ background: #073642 !important;
75
  }
76
  .crayon-theme-solarized-dark .crayon-marked-num.crayon-striped-num {
77
+ background: #002b36 !important;
78
+ }
79
+ .crayon-theme-solarized-dark .crayon-marked-line.crayon-top {
80
+ border-top-style: solid !important;
81
+ border-color: #657b83 !important;
82
+ border-width: 1px !important;
83
  }
 
84
  .crayon-theme-solarized-dark .crayon-marked-num.crayon-top {
85
+ border-top-style: solid !important;
86
+ border-color: #657b83 !important;
87
+ border-width: 1px !important;
88
+ }
89
+ .crayon-theme-solarized-dark .crayon-marked-line.crayon-bottom {
90
+ border-bottom-style: solid !important;
91
+ border-color: #657b83 !important;
92
+ border-width: 1px !important;
93
  }
 
94
  .crayon-theme-solarized-dark .crayon-marked-num.crayon-bottom {
95
+ border-bottom-style: solid !important;
96
+ border-color: #657b83 !important;
97
+ border-width: 1px !important;
98
  }
 
 
99
  .crayon-theme-solarized-dark .crayon-info {
100
+ background: #faf9d7 !important;
101
+ border-bottom: 1px #b1af5e solid !important;
102
+ color: #7e7d34;
103
  }
 
 
104
  .crayon-theme-solarized-dark .crayon-toolbar {
105
+ background: #DDD !important;
106
+ border-bottom: 1px #BBB solid !important;
107
  }
108
  .crayon-theme-solarized-dark .crayon-toolbar > div {
109
+ float: left !important;
110
  }
111
  .crayon-theme-solarized-dark .crayon-toolbar .crayon-tools {
112
+ float: right !important;
113
  }
114
  .crayon-theme-solarized-dark .crayon-title {
115
+ color: #333 !important;
116
  }
117
  .crayon-theme-solarized-dark .crayon-language {
118
+ color: #999 !important;
119
  }
 
 
120
  .crayon-theme-solarized-dark a.crayon-button {
121
  background-color: transparent;
122
  }
123
+ .crayon-theme-solarized-dark a.crayon-button:hover {
124
+ background-color: #EEE;
125
+ color: #666;
126
+ }
127
  .crayon-theme-solarized-dark a.crayon-button.crayon-pressed:hover {
128
  background-color: #EEE;
129
+ color: #666;
130
+ }
131
+ .crayon-theme-solarized-dark a.crayon-button.crayon-pressed {
132
+ background-color: #BCBCBC;
133
+ color: #FFF;
134
+ }
135
+ .crayon-theme-solarized-dark a.crayon-button.crayon-pressed:active {
136
+ background-color: #BCBCBC;
137
+ color: #FFF;
138
  }
 
 
 
139
  .crayon-theme-solarized-dark a.crayon-button:active {
140
  background-color: #BCBCBC;
141
+ color: #FFF;
142
  }
 
 
 
 
143
  .crayon-theme-solarized-dark .crayon-pre .c {
144
+ color: #586e75 !important;
 
 
 
145
  }
146
  .crayon-theme-solarized-dark .crayon-pre .s {
147
+ color: #2aa198 !important;
148
+ }
149
+ .crayon-theme-solarized-dark .crayon-pre .k {
150
+ color: #cb4b16 !important;
151
+ }
152
+ .crayon-theme-solarized-dark .crayon-pre .st {
153
+ color: #859900 !important;
154
+ }
155
+ .crayon-theme-solarized-dark .crayon-pre .r {
156
+ color: #cb4b16 !important;
157
  }
 
 
 
158
  .crayon-theme-solarized-dark .crayon-pre .t {
159
+ color: #b58900 !important;
160
  }
161
  .crayon-theme-solarized-dark .crayon-pre .m {
162
+ color: #b58900 !important;
 
 
 
163
  }
164
  .crayon-theme-solarized-dark .crayon-pre .i {
165
+ color: #839496 !important;
 
 
 
166
  }
167
  .crayon-theme-solarized-dark .crayon-pre .e {
168
  color: #839496 !important;
169
  }
170
+ .crayon-theme-solarized-dark .crayon-pre .v {
171
+ color: #268bd2 !important;
172
+ }
173
  .crayon-theme-solarized-dark .crayon-pre .cn {
174
+ color: #2aa198 !important;
175
  }
176
  .crayon-theme-solarized-dark .crayon-pre .o {
177
+ color: #859900 !important;
 
 
 
178
  }
179
  .crayon-theme-solarized-dark .crayon-pre .sy {
180
+ color: #dc322f !important;
181
  }
182
  .crayon-theme-solarized-dark .crayon-pre .n {
183
  color: #666 !important;
186
  .crayon-theme-solarized-dark .crayon-pre .f {
187
  color: #999 !important;
188
  }
189
+ .crayon-theme-solarized-dark .crayon-pre .h {
190
+ color: #dc322f !important;
191
+ }
192
+ .crayon-theme-solarized-dark .crayon-pre .p {
193
+ color: #dc322f !important;
194
+ }
195
+ .crayon-theme-solarized-dark .crayon-pre .ta {
196
+ color: #268bd2 !important;
197
+ }
themes/solarized-light/solarized-light.css ADDED
@@ -0,0 +1,197 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ Name: Solarized Light
3
+ Description: Clean, crisp and colorful.
4
+ Version: 1.0.0 Beta 2
5
+ Author: Ethan Schoonover
6
+ URL: http://ethanschoonover.com/
7
+ Maintainer: Eduan Lavaque
8
+ Maintainer URL: http://eduantech.com/
9
+ Notes: I don't provide striped lines because it would break the original purpose of this colorscheme.
10
+ */
11
+ .crayon-theme-solarized-light {
12
+ border: 1px #999 solid !important;
13
+ text-shadow: none !important;
14
+ background: #fdf6e3 !important;
15
+ }
16
+ .crayon-theme-solarized-light .crayon-code {
17
+ background: #fdf6e3 !important;
18
+ }
19
+ .crayon-theme-solarized-light-inline {
20
+ border: 1px solid #ddd !important;
21
+ background: #fdf6e3 !important;
22
+ }
23
+ .crayon-theme-solarized-light .crayon-nums {
24
+ background: #eee8d5 !important;
25
+ color: #93a1a1 !important;
26
+ border-right: 1px solid #b3d3f3 !important;
27
+ }
28
+ .crayon-theme-solarized-light .crayon-code::selection {
29
+ background: #ddeeff !important;
30
+ color: #316ba5 !important;
31
+ }
32
+ .crayon-theme-solarized-light .crayon-code *::selection {
33
+ background: #ddeeff !important;
34
+ color: #316ba5 !important;
35
+ }
36
+ .crayon-theme-solarized-light::selection {
37
+ background: transparent !important;
38
+ }
39
+ .crayon-theme-solarized-light .crayon-toolbar::selection {
40
+ background: transparent !important;
41
+ }
42
+ .crayon-theme-solarized-light .crayon-toolbar *::selection {
43
+ background: transparent !important;
44
+ }
45
+ .crayon-theme-solarized-light .crayon-info::selection {
46
+ background: transparent !important;
47
+ }
48
+ .crayon-theme-solarized-light .crayon-info *::selection {
49
+ background: transparent !important;
50
+ }
51
+ .crayon-theme-solarized-light .crayon-nums::selection {
52
+ background: transparent !important;
53
+ }
54
+ .crayon-theme-solarized-light .crayon-nums *::selection {
55
+ background: transparent !important;
56
+ }
57
+ .crayon-theme-solarized-light .crayon-striped-line {
58
+ background: #fdf6e3 !important;
59
+ border: 1px #CCC !important;
60
+ }
61
+ .crayon-theme-solarized-light .crayon-striped-num {
62
+ border: 1px #CCC !important;
63
+ color: #93a1a1 !important;
64
+ background: #eee8d5 !important;
65
+ }
66
+ .crayon-theme-solarized-light .crayon-marked-line {
67
+ background: #eee8d5 !important;
68
+ }
69
+ .crayon-theme-solarized-light .crayon-marked-num {
70
+ color: #93a1a1 !important;
71
+ background: #fdf6e3 !important;
72
+ }
73
+ .crayon-theme-solarized-light .crayon-marked-line.crayon-striped-line {
74
+ background: #eee8d5 !important;
75
+ }
76
+ .crayon-theme-solarized-light .crayon-marked-num.crayon-striped-num {
77
+ background: #fdf6e3 !important;
78
+ }
79
+ .crayon-theme-solarized-light .crayon-marked-line.crayon-top {
80
+ border-top-style: solid !important;
81
+ border-color: #839496 !important;
82
+ border-width: 1px !important;
83
+ }
84
+ .crayon-theme-solarized-light .crayon-marked-num.crayon-top {
85
+ border-top-style: solid !important;
86
+ border-color: #839496 !important;
87
+ border-width: 1px !important;
88
+ }
89
+ .crayon-theme-solarized-light .crayon-marked-line.crayon-bottom {
90
+ border-bottom-style: solid !important;
91
+ border-color: #839496 !important;
92
+ border-width: 1px !important;
93
+ }
94
+ .crayon-theme-solarized-light .crayon-marked-num.crayon-bottom {
95
+ border-bottom-style: solid !important;
96
+ border-color: #839496 !important;
97
+ border-width: 1px !important;
98
+ }
99
+ .crayon-theme-solarized-light .crayon-info {
100
+ background: #faf9d7 !important;
101
+ border-bottom: 1px #b1af5e solid !important;
102
+ color: #7e7d34;
103
+ }
104
+ .crayon-theme-solarized-light .crayon-toolbar {
105
+ background: #DDD !important;
106
+ border-bottom: 1px #BBB solid !important;
107
+ }
108
+ .crayon-theme-solarized-light .crayon-toolbar > div {
109
+ float: left !important;
110
+ }
111
+ .crayon-theme-solarized-light .crayon-toolbar .crayon-tools {
112
+ float: right !important;
113
+ }
114
+ .crayon-theme-solarized-light .crayon-title {
115
+ color: #333 !important;
116
+ }
117
+ .crayon-theme-solarized-light .crayon-language {
118
+ color: #999 !important;
119
+ }
120
+ .crayon-theme-solarized-light a.crayon-button {
121
+ background-color: transparent;
122
+ }
123
+ .crayon-theme-solarized-light a.crayon-button:hover {
124
+ background-color: #EEE;
125
+ color: #666;
126
+ }
127
+ .crayon-theme-solarized-light a.crayon-button.crayon-pressed:hover {
128
+ background-color: #EEE;
129
+ color: #666;
130
+ }
131
+ .crayon-theme-solarized-light a.crayon-button.crayon-pressed {
132
+ background-color: #BCBCBC;
133
+ color: #FFF;
134
+ }
135
+ .crayon-theme-solarized-light a.crayon-button.crayon-pressed:active {
136
+ background-color: #BCBCBC;
137
+ color: #FFF;
138
+ }
139
+ .crayon-theme-solarized-light a.crayon-button:active {
140
+ background-color: #BCBCBC;
141
+ color: #FFF;
142
+ }
143
+ .crayon-theme-solarized-light .crayon-pre .c {
144
+ color: #93a1a1 !important;
145
+ }
146
+ .crayon-theme-solarized-light .crayon-pre .s {
147
+ color: #2aa198 !important;
148
+ }
149
+ .crayon-theme-solarized-light .crayon-pre .k {
150
+ color: #cb4b16 !important;
151
+ }
152
+ .crayon-theme-solarized-light .crayon-pre .st {
153
+ color: #859900 !important;
154
+ }
155
+ .crayon-theme-solarized-light .crayon-pre .r {
156
+ color: #cb4b16 !important;
157
+ }
158
+ .crayon-theme-solarized-light .crayon-pre .t {
159
+ color: #b58900 !important;
160
+ }
161
+ .crayon-theme-solarized-light .crayon-pre .m {
162
+ color: #b58900 !important;
163
+ }
164
+ .crayon-theme-solarized-light .crayon-pre .i {
165
+ color: #839496 !important;
166
+ }
167
+ .crayon-theme-solarized-light .crayon-pre .e {
168
+ color: #839496 !important;
169
+ }
170
+ .crayon-theme-solarized-light .crayon-pre .v {
171
+ color: #268bd2 !important;
172
+ }
173
+ .crayon-theme-solarized-light .crayon-pre .cn {
174
+ color: #2aa198 !important;
175
+ }
176
+ .crayon-theme-solarized-light .crayon-pre .o {
177
+ color: #859900 !important;
178
+ }
179
+ .crayon-theme-solarized-light .crayon-pre .sy {
180
+ color: #dc322f !important;
181
+ }
182
+ .crayon-theme-solarized-light .crayon-pre .n {
183
+ color: #666 !important;
184
+ font-style: italic;
185
+ }
186
+ .crayon-theme-solarized-light .crayon-pre .f {
187
+ color: #999 !important;
188
+ }
189
+ .crayon-theme-solarized-light .crayon-pre .h {
190
+ color: #dc322f !important;
191
+ }
192
+ .crayon-theme-solarized-light .crayon-pre .p {
193
+ color: #dc322f !important;
194
+ }
195
+ .crayon-theme-solarized-light .crayon-pre .ta {
196
+ color: #268bd2 !important;
197
+ }
themes/son-of-obsidian/son-of-obsidian.css ADDED
@@ -0,0 +1,188 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ Name: Son Of Obsidian
3
+ Description: Inspired from http://studiostyl.es/schemes/son-of-obsidian
4
+ Version: 1.0
5
+ Original Author: http://studiostyl.es/users/135
6
+ Author: Phiphou
7
+ URL: http://blog.phiphou.com
8
+ Twitter: @__phiphou__
9
+ */
10
+ .crayon-theme-son-of-obsidian {
11
+ border: 1px solid #ddd !important;
12
+ text-shadow: none !important;
13
+ background: #fafafa !important;
14
+ }
15
+ .crayon-theme-son-of-obsidian .crayon-code {
16
+ background: #22282a !important;
17
+ color: #f1f2f3 !important;
18
+ }
19
+ .crayon-theme-son-of-obsidian .crayon-nums {
20
+ background: #22282a !important;
21
+ color: #808080 !important;
22
+ border-right: 1px solid #475459 !important;
23
+ }
24
+ .crayon-theme-son-of-obsidian .crayon-code::selection {
25
+ background: #7c9299 !important;
26
+ color: #FFFFFF !important;
27
+ }
28
+ .crayon-theme-son-of-obsidian .crayon-code *::selection {
29
+ background: #7c9299 !important;
30
+ color: #FFFFFF !important;
31
+ }
32
+ .crayon-theme-son-of-obsidian::selection {
33
+ background: transparent !important;
34
+ }
35
+ .crayon-theme-son-of-obsidian .crayon-toolbar::selection {
36
+ background: transparent !important;
37
+ }
38
+ .crayon-theme-son-of-obsidian .crayon-toolbar *::selection {
39
+ background: transparent !important;
40
+ }
41
+ .crayon-theme-son-of-obsidian .crayon-info::selection {
42
+ background: transparent !important;
43
+ }
44
+ .crayon-theme-son-of-obsidian .crayon-info *::selection {
45
+ background: transparent !important;
46
+ }
47
+ .crayon-theme-son-of-obsidian .crayon-nums::selection {
48
+ background: transparent !important;
49
+ }
50
+ .crayon-theme-son-of-obsidian .crayon-nums *::selection {
51
+ background: transparent !important;
52
+ }
53
+ .crayon-theme-son-of-obsidian .crayon-striped-line {
54
+ background: #22282a !important;
55
+ border: 1px #ccc !important;
56
+ }
57
+ .crayon-theme-son-of-obsidian .crayon-striped-num {
58
+ background: #293134 !important;
59
+ border: 1px #22282a !important;
60
+ color: #808080 !important;
61
+ }
62
+ .crayon-theme-son-of-obsidian .crayon-marked-line {
63
+ background: #40292c !important;
64
+ border: 1px #996b72 !important;
65
+ }
66
+ .crayon-theme-son-of-obsidian .crayon-marked-num {
67
+ color: #808080 !important;
68
+ background: #40292c !important;
69
+ border: 1px #996b72 !important;
70
+ }
71
+ .crayon-theme-son-of-obsidian .crayon-marked-line.crayon-striped-line {
72
+ background: #40292c !important;
73
+ }
74
+ .crayon-theme-son-of-obsidian .crayon-marked-num.crayon-striped-num {
75
+ background: #663d43 !important;
76
+ border: 1px #996b72 !important;
77
+ color: #808080 !important;
78
+ }
79
+ .crayon-theme-son-of-obsidian .crayon-marked-line.crayon-top {
80
+ border-top-style: solid !important;
81
+ }
82
+ .crayon-theme-son-of-obsidian .crayon-marked-num.crayon-top {
83
+ border-top-style: solid !important;
84
+ }
85
+ .crayon-theme-son-of-obsidian .crayon-marked-line.crayon-bottom {
86
+ border-bottom-style: solid !important;
87
+ }
88
+ .crayon-theme-son-of-obsidian .crayon-marked-num.crayon-bottom {
89
+ border-bottom-style: solid !important;
90
+ }
91
+ .crayon-theme-son-of-obsidian .crayon-info {
92
+ background: #faf9d7 !important;
93
+ border-bottom: 1px #b1af5e solid !important;
94
+ color: #7e7d34;
95
+ }
96
+ .crayon-theme-son-of-obsidian .crayon-toolbar {
97
+ background: #ddd !important;
98
+ border-bottom: 1px #bbb solid !important;
99
+ }
100
+ .crayon-theme-son-of-obsidian .crayon-toolbar > div {
101
+ float: left !important;
102
+ }
103
+ .crayon-theme-son-of-obsidian .crayon-toolbar .crayon-tools {
104
+ float: right !important;
105
+ }
106
+ .crayon-theme-son-of-obsidian .crayon-title {
107
+ color: #333 !important;
108
+ }
109
+ .crayon-theme-son-of-obsidian .crayon-language {
110
+ color: #999 !important;
111
+ }
112
+ .crayon-theme-son-of-obsidian a.crayon-button {
113
+ background-color: transparent;
114
+ }
115
+ .crayon-theme-son-of-obsidian a.crayon-button:hover {
116
+ background-color: #eee;
117
+ color: #666;
118
+ }
119
+ .crayon-theme-son-of-obsidian a.crayon-button.crayon-pressed:hover {
120
+ background-color: #eee;
121
+ color: #666;
122
+ }
123
+ .crayon-theme-son-of-obsidian a.crayon-button.crayon-pressed {
124
+ background-color: #bcbcbc;
125
+ color: #fff;
126
+ }
127
+ .crayon-theme-son-of-obsidian a.crayon-button.crayon-pressed:active {
128
+ background-color: #bcbcbc;
129
+ color: #fff;
130
+ }
131
+ .crayon-theme-son-of-obsidian a.crayon-button:active {
132
+ background-color: #bcbcbc;
133
+ color: #fff;
134
+ }
135
+ .crayon-theme-son-of-obsidian .crayon-pre .c {
136
+ color: #66747b !important;
137
+ }
138
+ .crayon-theme-son-of-obsidian .crayon-pre .p {
139
+ color: #00FF00 !important;
140
+ }
141
+ .crayon-theme-son-of-obsidian .crayon-pre .s {
142
+ color: #ec7600 !important;
143
+ }
144
+ .crayon-theme-son-of-obsidian .crayon-pre .k {
145
+ color: #a082bd !important;
146
+ }
147
+ .crayon-theme-son-of-obsidian .crayon-pre .st {
148
+ color: #a082bd !important;
149
+ }
150
+ .crayon-theme-son-of-obsidian .crayon-pre .r {
151
+ color: #a082bd !important;
152
+ }
153
+ .crayon-theme-son-of-obsidian .crayon-pre .t {
154
+ color: #a082bd !important;
155
+ }
156
+ .crayon-theme-son-of-obsidian .crayon-pre .m {
157
+ color: #a082bd !important;
158
+ }
159
+ .crayon-theme-son-of-obsidian .crayon-pre .ta {
160
+ color: #99daf9 !important;
161
+ }
162
+ .crayon-theme-son-of-obsidian .crayon-pre .i {
163
+ color: #678cb1 !important;
164
+ }
165
+ .crayon-theme-son-of-obsidian .crayon-pre .v {
166
+ color: #678cb1 !important;
167
+ }
168
+ .crayon-theme-son-of-obsidian .crayon-pre .e {
169
+ color: #95c763 !important;
170
+ }
171
+ .crayon-theme-son-of-obsidian .crayon-pre .cn {
172
+ color: #99daf9 !important;
173
+ }
174
+ .crayon-theme-son-of-obsidian .crayon-pre .o {
175
+ color: #ffcd22 !important;
176
+ }
177
+ .crayon-theme-son-of-obsidian .crayon-pre .h {
178
+ color: #ffcd22 !important;
179
+ }
180
+ .crayon-theme-son-of-obsidian .crayon-pre .sy {
181
+ color: #f1f2f3 !important;
182
+ }
183
+ .crayon-theme-son-of-obsidian .crayon-pre .n {
184
+ color: #f1f2f3 !important;
185
+ font-style: italic;
186
+ }
187
+ .crayon-theme-son-of-obsidian .crayon-pre .f {
188
+ }
themes/twilight/twilight.css CHANGED
@@ -1,185 +1,196 @@
1
- /*
2
- Theme Name: Twilight
3
- Description: Dark and elegant.
4
- Version: 1.3
5
- Author: Aram Kocharyan
6
- Author URI: http://ak.net84.net/
7
- */
8
-
9
- /* Code Style ====================== */
10
- .crayon-theme-twilight {
11
- border: 1px #333 solid !important;
12
- text-shadow: none !important;
13
- color: #fff;
14
- }
15
-
16
- .crayon-theme-twilight,
17
- .crayon-theme-twilight .crayon-code {
18
- background: #2d2d2d !important;
19
- }
20
-
21
- /* Inline Style */
22
- .crayon-theme-twilight-inline {
23
- border: 1px solid #333 !important;
24
- background: #333 !important;
25
- }
26
-
27
- .crayon-theme-twilight span {
28
- color: #999 !important;
29
- }
30
-
31
- /* Line Numbers */
32
- .crayon-theme-twilight .crayon-nums {
33
- border-right: 1px solid #333 !important;
34
- color: #333 !important;
35
- background: #909090 !important;
36
- }
37
-
38
- /* Selection */
39
- .crayon-theme-twilight .crayon-code::selection,
40
- .crayon-theme-twilight .crayon-code *::selection {
41
- background: #ddeeff !important;
42
- color: #316ba5 !important;
43
- }
44
- .crayon-theme-twilight::selection,
45
- .crayon-theme-twilight .crayon-toolbar::selection,
46
- .crayon-theme-twilight .crayon-toolbar *::selection,
47
- .crayon-theme-twilight .crayon-info::selection,
48
- .crayon-theme-twilight .crayon-info *::selection,
49
- .crayon-theme-twilight .crayon-nums::selection,
50
- .crayon-theme-twilight .crayon-nums *::selection {
51
- background: transparent !important;
52
- }
53
-
54
- /* Striped Lines */
55
- .crayon-theme-twilight .crayon-striped-line {
56
- background: #343434 !important;
57
- border: 1px #171717 !important;
58
- }
59
- .crayon-theme-twilight .crayon-striped-num {
60
- background: #aaa !important;
61
- border: 1px #CCC !important;
62
- color: #555 !important;
63
- }
64
-
65
- /* Marked Lines */
66
- .crayon-theme-twilight .crayon-marked-line {
67
- background: #484844 !important;
68
- border: 1px #222 !important;
69
- }
70
- .crayon-theme-twilight .crayon-marked-num {
71
- color: #555 !important;
72
- background: #bbb !important;
73
- border: 1px #777 !important;
74
- }
75
- .crayon-theme-twilight .crayon-marked-line.crayon-striped-line {
76
- background: #51514d !important;
77
- }
78
- .crayon-theme-twilight .crayon-marked-num.crayon-striped-num {
79
- background: #ccc !important;
80
- color: #888 !important;
81
- }
82
- .crayon-theme-twilight .crayon-marked-line.crayon-top,
83
- .crayon-theme-twilight .crayon-marked-num.crayon-top {
84
- border-top-style: solid !important;
85
- }
86
- .crayon-theme-twilight .crayon-marked-line.crayon-bottom,
87
- .crayon-theme-twilight .crayon-marked-num.crayon-bottom {
88
- border-bottom-style: solid !important;
89
- }
90
-
91
- /* Info */
92
- .crayon-theme-twilight .crayon-info {
93
- background: #faf9d7 !important;
94
- border-bottom: 1px #b1af5e solid !important;
95
- color: #7e7d34;
96
- }
97
-
98
- /* Toolbar */
99
- .crayon-theme-twilight .crayon-toolbar {
100
- background: #b2b2b2 !important;
101
- border-bottom: 1px #666 solid !important;
102
- }
103
- .crayon-theme-twilight .crayon-toolbar > div {
104
- float: left !important;
105
- }
106
- .crayon-theme-twilight .crayon-toolbar .crayon-tools {
107
- float: right !important;
108
- }
109
- .crayon-theme-twilight .crayon-title {
110
- color: #333 !important;
111
- }
112
- .crayon-theme-twilight .crayon-language {
113
- color: #666 !important;
114
- }
 
115
  .crayon-theme-twilight .crayon-toolbar .crayon-mixed-highlight {
116
- background-position: -24px center;
117
- }
118
-
119
- /* Buttons */
120
- .crayon-theme-twilight a.crayon-button {
121
- background-color: transparent;
122
- }
123
- .crayon-theme-twilight a.crayon-button:hover,
124
- .crayon-theme-twilight a.crayon-button.crayon-pressed:hover {
125
- background-color: #ccc;
126
- color: #666;
127
- }
128
- /* :active MUST come after :hover */
129
- .crayon-theme-twilight a.crayon-button.crayon-pressed,
130
- .crayon-theme-twilight a.crayon-button.crayon-pressed:active,
131
- .crayon-theme-twilight a.crayon-button:active {
132
- background-color: #999;
133
- color: #ccc;
134
- }
135
- /* End Code Style ================== */
136
-
137
- /* Syntax Highlighting ============= */
138
- .crayon-theme-twilight .crayon-pre .c {
139
- color: #7f7b80 !important;
140
- }
141
- .crayon-theme-twilight .crayon-pre .p {
142
- color: #a19ba2 !important;
143
- }
144
- .crayon-theme-twilight .crayon-pre .s {
145
- color: #a0ab83 !important;
146
- }
147
- .crayon-theme-twilight .crayon-pre .k,
148
- .crayon-theme-twilight .crayon-pre .st,
149
- .crayon-theme-twilight .crayon-pre .r,
150
- .crayon-theme-twilight .crayon-pre .t,
151
- .crayon-theme-twilight .crayon-pre .m {
152
- color: #d8b584 !important;
153
- }
154
- .crayon-theme-twilight .crayon-pre .ta {
155
- color: #AAA !important;
156
- }
157
- .crayon-theme-twilight .crayon-pre .i {
158
- color: #fbefb1 !important;
159
- }
160
- .crayon-theme-twilight .crayon-pre .v {
161
- color: #879ab2 !important;
162
- }
163
- .crayon-theme-twilight .crayon-pre .e {
164
- color: #ad8258 !important;
165
- }
166
- .crayon-theme-twilight .crayon-pre .cn {
167
- color: #db7e64 !important;
168
- }
169
- .crayon-theme-twilight .crayon-pre .o,
170
- .crayon-theme-twilight .crayon-pre .h {
171
- color: #ac99ab !important;
172
- }
173
- .crayon-theme-twilight .crayon-pre .sy {
174
- color: #ac99ab !important;
175
- }
176
- .crayon-theme-twilight .crayon-pre .n {
177
- color: #726e73 !important;
178
- font-style: italic;
179
- }
180
- .crayon-theme-twilight .crayon-pre .f {
181
- color: #595959 !important;
182
- }
183
- /* End Syntax Highlighting ========= */
184
-
185
- /* End Classic Scheme ============================================ */
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ Name: Twilight
3
+ Description: Dark and elegant.
4
+ Version: 1.3
5
+ Author: Aram Kocharyan
6
+ URL: http://ak.net84.net/
7
+ */
8
+ .crayon-theme-twilight {
9
+ border: 1px #333 solid !important;
10
+ text-shadow: none !important;
11
+ color: #fff;
12
+ background: #2d2d2d !important;
13
+ }
14
+ .crayon-theme-twilight .crayon-code {
15
+ background: #2d2d2d !important;
16
+ }
17
+ .crayon-theme-twilight-inline {
18
+ border: 1px solid #333 !important;
19
+ background: #333 !important;
20
+ }
21
+ .crayon-theme-twilight span {
22
+ color: #999 !important;
23
+ }
24
+ .crayon-theme-twilight .crayon-nums {
25
+ border-right: 1px solid #333 !important;
26
+ color: #333 !important;
27
+ background: #909090 !important;
28
+ }
29
+ .crayon-theme-twilight .crayon-code::selection {
30
+ background: #ddeeff !important;
31
+ color: #316ba5 !important;
32
+ }
33
+ .crayon-theme-twilight .crayon-code *::selection {
34
+ background: #ddeeff !important;
35
+ color: #316ba5 !important;
36
+ }
37
+ .crayon-theme-twilight::selection {
38
+ background: transparent !important;
39
+ }
40
+ .crayon-theme-twilight .crayon-toolbar::selection {
41
+ background: transparent !important;
42
+ }
43
+ .crayon-theme-twilight .crayon-toolbar *::selection {
44
+ background: transparent !important;
45
+ }
46
+ .crayon-theme-twilight .crayon-info::selection {
47
+ background: transparent !important;
48
+ }
49
+ .crayon-theme-twilight .crayon-info *::selection {
50
+ background: transparent !important;
51
+ }
52
+ .crayon-theme-twilight .crayon-nums::selection {
53
+ background: transparent !important;
54
+ }
55
+ .crayon-theme-twilight .crayon-nums *::selection {
56
+ background: transparent !important;
57
+ }
58
+ .crayon-theme-twilight .crayon-striped-line {
59
+ background: #343434 !important;
60
+ border: 1px #171717 !important;
61
+ }
62
+ .crayon-theme-twilight .crayon-striped-num {
63
+ background: #aaa !important;
64
+ border: 1px #CCC !important;
65
+ color: #555 !important;
66
+ }
67
+ .crayon-theme-twilight .crayon-marked-line {
68
+ background: #484844 !important;
69
+ border: 1px #222 !important;
70
+ }
71
+ .crayon-theme-twilight .crayon-marked-num {
72
+ color: #555 !important;
73
+ background: #bbb !important;
74
+ border: 1px #777 !important;
75
+ }
76
+ .crayon-theme-twilight .crayon-marked-line.crayon-striped-line {
77
+ background: #51514d !important;
78
+ }
79
+ .crayon-theme-twilight .crayon-marked-num.crayon-striped-num {
80
+ background: #ccc !important;
81
+ color: #888 !important;
82
+ }
83
+ .crayon-theme-twilight .crayon-marked-line.crayon-top {
84
+ border-top-style: solid !important;
85
+ }
86
+ .crayon-theme-twilight .crayon-marked-num.crayon-top {
87
+ border-top-style: solid !important;
88
+ }
89
+ .crayon-theme-twilight .crayon-marked-line.crayon-bottom {
90
+ border-bottom-style: solid !important;
91
+ }
92
+ .crayon-theme-twilight .crayon-marked-num.crayon-bottom {
93
+ border-bottom-style: solid !important;
94
+ }
95
+ .crayon-theme-twilight .crayon-info {
96
+ background: #faf9d7 !important;
97
+ border-bottom: 1px #b1af5e solid !important;
98
+ color: #7e7d34;
99
+ }
100
+ .crayon-theme-twilight .crayon-toolbar {
101
+ background: #b2b2b2 !important;
102
+ border-bottom: 1px #666 solid !important;
103
+ }
104
+ .crayon-theme-twilight .crayon-toolbar > div {
105
+ float: left !important;
106
+ }
107
+ .crayon-theme-twilight .crayon-toolbar .crayon-tools {
108
+ float: right !important;
109
+ }
110
+ .crayon-theme-twilight .crayon-title {
111
+ color: #333 !important;
112
+ }
113
+ .crayon-theme-twilight .crayon-language {
114
+ color: #666 !important;
115
+ }
116
  .crayon-theme-twilight .crayon-toolbar .crayon-mixed-highlight {
117
+ background-position: -24px center;
118
+ }
119
+ .crayon-theme-twilight a.crayon-button {
120
+ background-color: transparent;
121
+ }
122
+ .crayon-theme-twilight a.crayon-button:hover {
123
+ background-color: #ccc;
124
+ color: #666;
125
+ }
126
+ .crayon-theme-twilight a.crayon-button.crayon-pressed:hover {
127
+ background-color: #ccc;
128
+ color: #666;
129
+ }
130
+ .crayon-theme-twilight a.crayon-button.crayon-pressed {
131
+ background-color: #999;
132
+ color: #ccc;
133
+ }
134
+ .crayon-theme-twilight a.crayon-button.crayon-pressed:active {
135
+ background-color: #999;
136
+ color: #ccc;
137
+ }
138
+ .crayon-theme-twilight a.crayon-button:active {
139
+ background-color: #999;
140
+ color: #ccc;
141
+ }
142
+ .crayon-theme-twilight .crayon-pre .c {
143
+ color: #7f7b80 !important;
144
+ }
145
+ .crayon-theme-twilight .crayon-pre .p {
146
+ color: #a19ba2 !important;
147
+ }
148
+ .crayon-theme-twilight .crayon-pre .s {
149
+ color: #a0ab83 !important;
150
+ }
151
+ .crayon-theme-twilight .crayon-pre .k {
152
+ color: #d8b584 !important;
153
+ }
154
+ .crayon-theme-twilight .crayon-pre .st {
155
+ color: #d8b584 !important;
156
+ }
157
+ .crayon-theme-twilight .crayon-pre .r {
158
+ color: #d8b584 !important;
159
+ }
160
+ .crayon-theme-twilight .crayon-pre .t {
161
+ color: #d8b584 !important;
162
+ }
163
+ .crayon-theme-twilight .crayon-pre .m {
164
+ color: #d8b584 !important;
165
+ }
166
+ .crayon-theme-twilight .crayon-pre .ta {
167
+ color: #AAA !important;
168
+ }
169
+ .crayon-theme-twilight .crayon-pre .i {
170
+ color: #fbefb1 !important;
171
+ }
172
+ .crayon-theme-twilight .crayon-pre .v {
173
+ color: #879ab2 !important;
174
+ }
175
+ .crayon-theme-twilight .crayon-pre .e {
176
+ color: #ad8258 !important;
177
+ }
178
+ .crayon-theme-twilight .crayon-pre .cn {
179
+ color: #db7e64 !important;
180
+ }
181
+ .crayon-theme-twilight .crayon-pre .o {
182
+ color: #ac99ab !important;
183
+ }
184
+ .crayon-theme-twilight .crayon-pre .h {
185
+ color: #ac99ab !important;
186
+ }
187
+ .crayon-theme-twilight .crayon-pre .sy {
188
+ color: #ac99ab !important;
189
+ }
190
+ .crayon-theme-twilight .crayon-pre .n {
191
+ color: #726e73 !important;
192
+ font-style: italic;
193
+ }
194
+ .crayon-theme-twilight .crayon-pre .f {
195
+ color: #595959 !important;
196
+ }
trans/crayon-syntax-highlighter-pl_PL.mo ADDED
Binary file
trans/crayon-syntax-highlighter-pl_PL.po ADDED
@@ -0,0 +1,1014 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ msgid ""
2
+ msgstr ""
3
+ "Project-Id-Version: Crayon Syntax Highlighter v_1.17_beta\n"
4
+ "Report-Msgid-Bugs-To: \n"
5
+ "POT-Creation-Date: \n"
6
+ "PO-Revision-Date: 2012-12-14 13:59:32+0000\n"
7
+ "Last-Translator: Bartosz Romanowski <toszcze@gmail.com>\n"
8
+ "Language-Team: \n"
9
+ "MIME-Version: 1.0\n"
10
+ "Content-Type: text/plain; charset=UTF-8\n"
11
+ "Content-Transfer-Encoding: 8bit\n"
12
+ "Plural-Forms: nplurals=3; plural=n==1 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2;\n"
13
+ "X-Poedit-Language: Polish\n"
14
+ "X-Poedit-Country: POLAND\n"
15
+ "X-Poedit-SourceCharset: utf-8\n"
16
+ "X-Poedit-KeywordsList: __;_e;__ngettext:1,2;_n:1,2;__ngettext_noop:1,2;_n_noop:1,2;_c,_nc:4c,1,2;_x:1,2c;_ex:1,2c;_nx:4c,1,2;_nx_noop:4c,1,2;\n"
17
+ "X-Poedit-Basepath: ../\n"
18
+ "X-Poedit-Bookmarks: \n"
19
+ "X-Poedit-SearchPath-0: .\n"
20
+ "X-Textdomain-Support: yes"
21
+
22
+ #: crayon_formatter.class.php:274
23
+ #@ crayon-syntax-highlighter
24
+ msgid "Toggle Plain Code"
25
+ msgstr "Włącz/wyłącz czysty kod"
26
+
27
+ #: crayon_formatter.class.php:275
28
+ #@ crayon-syntax-highlighter
29
+ msgid "Toggle Line Wrap"
30
+ msgstr "Włącz/wyłącz zawijanie linii"
31
+
32
+ #: crayon_formatter.class.php:276
33
+ #@ crayon-syntax-highlighter
34
+ msgid "Expand Code"
35
+ msgstr "Rozwiń kod"
36
+
37
+ #: crayon_formatter.class.php:278
38
+ #, php-format
39
+ #@ crayon-syntax-highlighter
40
+ msgid "Press %s to Copy, %s to Paste"
41
+ msgstr "Naciśnij %s aby skopiować, %s aby wkleić"
42
+
43
+ #: crayon_formatter.class.php:278
44
+ #@ crayon-syntax-highlighter
45
+ msgid "Copy Plain Code"
46
+ msgstr "Skopiuj czysty kod"
47
+
48
+ #: crayon_formatter.class.php:280
49
+ #@ crayon-syntax-highlighter
50
+ msgid "Open Code In New Window"
51
+ msgstr "Otwórz kod w nowym oknie"
52
+
53
+ #: crayon_formatter.class.php:282
54
+ #@ crayon-syntax-highlighter
55
+ msgid "Toggle Line Numbers"
56
+ msgstr "Włącz/wyłącz numery linii"
57
+
58
+ #: crayon_formatter.class.php:285
59
+ #@ crayon-syntax-highlighter
60
+ msgid "Contains Mixed Languages"
61
+ msgstr "Zawiera kilka języków"
62
+
63
+ #: crayon_settings.class.php:145
64
+ #@ crayon-syntax-highlighter
65
+ msgid "Hourly"
66
+ msgstr "Co godzinę"
67
+
68
+ #: crayon_settings.class.php:145
69
+ #@ crayon-syntax-highlighter
70
+ msgid "Daily"
71
+ msgstr "Raz dziennie"
72
+
73
+ #: crayon_settings.class.php:146
74
+ #@ crayon-syntax-highlighter
75
+ msgid "Weekly"
76
+ msgstr "Co tydzień"
77
+
78
+ #: crayon_settings.class.php:146
79
+ #@ crayon-syntax-highlighter
80
+ msgid "Monthly"
81
+ msgstr "Co miesiąc"
82
+
83
+ #: crayon_settings.class.php:147
84
+ #@ crayon-syntax-highlighter
85
+ msgid "Immediately"
86
+ msgstr "Natychmiast"
87
+
88
+ #: crayon_settings.class.php:157
89
+ #: crayon_settings.class.php:161
90
+ #@ crayon-syntax-highlighter
91
+ msgid "Max"
92
+ msgstr "maks."
93
+
94
+ #: crayon_settings.class.php:157
95
+ #: crayon_settings.class.php:161
96
+ #@ crayon-syntax-highlighter
97
+ msgid "Min"
98
+ msgstr "min."
99
+
100
+ #: crayon_settings.class.php:157
101
+ #: crayon_settings.class.php:161
102
+ #@ crayon-syntax-highlighter
103
+ msgid "Static"
104
+ msgstr "stała"
105
+
106
+ #: crayon_settings.class.php:159
107
+ #: crayon_settings.class.php:163
108
+ #: crayon_settings_wp.class.php:680
109
+ #: crayon_settings_wp.class.php:689
110
+ #: crayon_settings_wp.class.php:951
111
+ #@ crayon-syntax-highlighter
112
+ msgid "Pixels"
113
+ msgstr "pikseli"
114
+
115
+ #: crayon_settings.class.php:159
116
+ #: crayon_settings.class.php:163
117
+ #@ crayon-syntax-highlighter
118
+ msgid "Percent"
119
+ msgstr "procent"
120
+
121
+ #: crayon_settings.class.php:172
122
+ #@ crayon-syntax-highlighter
123
+ msgid "None"
124
+ msgstr "brak"
125
+
126
+ #: crayon_settings.class.php:172
127
+ #@ crayon-syntax-highlighter
128
+ msgid "Left"
129
+ msgstr "do lewej"
130
+
131
+ #: crayon_settings.class.php:172
132
+ #@ crayon-syntax-highlighter
133
+ msgid "Center"
134
+ msgstr "wyśrodkowane"
135
+
136
+ #: crayon_settings.class.php:172
137
+ #@ crayon-syntax-highlighter
138
+ msgid "Right"
139
+ msgstr "do prawej"
140
+
141
+ #: crayon_settings.class.php:174
142
+ #: crayon_settings.class.php:198
143
+ #@ crayon-syntax-highlighter
144
+ msgid "On MouseOver"
145
+ msgstr "wskazanie myszą"
146
+
147
+ #: crayon_settings.class.php:174
148
+ #: crayon_settings.class.php:180
149
+ #@ crayon-syntax-highlighter
150
+ msgid "Always"
151
+ msgstr "zawsze"
152
+
153
+ #: crayon_settings.class.php:174
154
+ #: crayon_settings.class.php:180
155
+ #@ crayon-syntax-highlighter
156
+ msgid "Never"
157
+ msgstr "nigdy"
158
+
159
+ #: crayon_settings.class.php:180
160
+ #@ crayon-syntax-highlighter
161
+ msgid "When Found"
162
+ msgstr "gdy znaleziono"
163
+
164
+ #: crayon_settings.class.php:198
165
+ #@ crayon-syntax-highlighter
166
+ msgid "On Double Click"
167
+ msgstr "podwójne kliknięcie"
168
+
169
+ #: crayon_settings.class.php:198
170
+ #@ crayon-syntax-highlighter
171
+ msgid "On Single Click"
172
+ msgstr "pojedyncze kliknięcie"
173
+
174
+ #: crayon_settings.class.php:198
175
+ #@ crayon-syntax-highlighter
176
+ msgid "Disable Mouse Events"
177
+ msgstr "wyłącz zdarzenia myszy"
178
+
179
+ #: crayon_settings.class.php:205
180
+ #@ crayon-syntax-highlighter
181
+ msgid "An error has occurred. Please try again later."
182
+ msgstr "Wystąpił błąd. Spróbuj ponownie."
183
+
184
+ #: crayon_settings_wp.class.php:49
185
+ #: crayon_settings_wp.class.php:156
186
+ #: crayon_settings_wp.class.php:1138
187
+ #: util/tag-editor/crayon_tag_editor_wp.class.php:238
188
+ #@ crayon-syntax-highlighter
189
+ msgid "Settings"
190
+ msgstr "Ustawienia"
191
+
192
+ #: crayon_settings_wp.class.php:135
193
+ #@ crayon-syntax-highlighter
194
+ msgid "You do not have sufficient permissions to access this page."
195
+ msgstr "Nie masz wystarczających uprawnień aby uzyskać dostęp do tej strony."
196
+
197
+ #: crayon_settings_wp.class.php:171
198
+ #@ crayon-syntax-highlighter
199
+ msgid "Save Changes"
200
+ msgstr "Zapisz zmiany"
201
+
202
+ #: crayon_settings_wp.class.php:178
203
+ #@ crayon-syntax-highlighter
204
+ msgid "Reset Settings"
205
+ msgstr "Resetuj ustawienia"
206
+
207
+ #: crayon_settings_wp.class.php:423
208
+ #@ crayon-syntax-highlighter
209
+ msgid "General"
210
+ msgstr "Ogólne"
211
+
212
+ #: crayon_settings_wp.class.php:424
213
+ #@ crayon-syntax-highlighter
214
+ msgid "Theme"
215
+ msgstr "Motyw"
216
+
217
+ #: crayon_settings_wp.class.php:425
218
+ #@ crayon-syntax-highlighter
219
+ msgid "Font"
220
+ msgstr "Czcionka"
221
+
222
+ #: crayon_settings_wp.class.php:426
223
+ #@ crayon-syntax-highlighter
224
+ msgid "Metrics"
225
+ msgstr "Rozmiary"
226
+
227
+ #: crayon_settings_wp.class.php:427
228
+ #@ crayon-syntax-highlighter
229
+ msgid "Toolbar"
230
+ msgstr "Pasek narzędzi"
231
+
232
+ #: crayon_settings_wp.class.php:428
233
+ #@ crayon-syntax-highlighter
234
+ msgid "Lines"
235
+ msgstr "Linie"
236
+
237
+ #: crayon_settings_wp.class.php:429
238
+ #: util/tag-editor/crayon_tag_editor_wp.class.php:201
239
+ #@ crayon-syntax-highlighter
240
+ msgid "Code"
241
+ msgstr "Kod"
242
+
243
+ #: crayon_settings_wp.class.php:430
244
+ #@ crayon-syntax-highlighter
245
+ msgid "Tags"
246
+ msgstr "Znaczniki"
247
+
248
+ #: crayon_settings_wp.class.php:431
249
+ #@ crayon-syntax-highlighter
250
+ msgid "Languages"
251
+ msgstr "Języki"
252
+
253
+ #: crayon_settings_wp.class.php:432
254
+ #@ crayon-syntax-highlighter
255
+ msgid "Files"
256
+ msgstr "Pliki"
257
+
258
+ #: crayon_settings_wp.class.php:433
259
+ #@ crayon-syntax-highlighter
260
+ msgid "Posts"
261
+ msgstr "Wpisy"
262
+
263
+ #: crayon_settings_wp.class.php:434
264
+ #@ crayon-syntax-highlighter
265
+ msgid "Tag Editor"
266
+ msgstr "Edytor znaczników"
267
+
268
+ #: crayon_settings_wp.class.php:435
269
+ #@ crayon-syntax-highlighter
270
+ msgid "Misc"
271
+ msgstr "Różne"
272
+
273
+ #: crayon_settings_wp.class.php:438
274
+ #@ crayon-syntax-highlighter
275
+ msgid "Debug"
276
+ msgstr "Debugowanie"
277
+
278
+ #: crayon_settings_wp.class.php:439
279
+ #@ crayon-syntax-highlighter
280
+ msgid "Errors"
281
+ msgstr "Błędy"
282
+
283
+ #: crayon_settings_wp.class.php:440
284
+ #@ crayon-syntax-highlighter
285
+ msgid "Log"
286
+ msgstr "Log"
287
+
288
+ #: crayon_settings_wp.class.php:443
289
+ #@ crayon-syntax-highlighter
290
+ msgid "About"
291
+ msgstr "O wtyczce"
292
+
293
+ #: crayon_settings_wp.class.php:657
294
+ #@ crayon-syntax-highlighter
295
+ msgid "Height"
296
+ msgstr "Wysokość"
297
+
298
+ #: crayon_settings_wp.class.php:663
299
+ #@ crayon-syntax-highlighter
300
+ msgid "Width"
301
+ msgstr "Szerokość"
302
+
303
+ #: crayon_settings_wp.class.php:669
304
+ #@ crayon-syntax-highlighter
305
+ msgid "Top Margin"
306
+ msgstr "Górny margines"
307
+
308
+ #: crayon_settings_wp.class.php:670
309
+ #@ crayon-syntax-highlighter
310
+ msgid "Bottom Margin"
311
+ msgstr "Dolny margines"
312
+
313
+ #: crayon_settings_wp.class.php:671
314
+ #: crayon_settings_wp.class.php:676
315
+ #@ crayon-syntax-highlighter
316
+ msgid "Left Margin"
317
+ msgstr "Lewy margines"
318
+
319
+ #: crayon_settings_wp.class.php:672
320
+ #: crayon_settings_wp.class.php:676
321
+ #@ crayon-syntax-highlighter
322
+ msgid "Right Margin"
323
+ msgstr "Prawy margines"
324
+
325
+ #: crayon_settings_wp.class.php:682
326
+ #@ crayon-syntax-highlighter
327
+ msgid "Horizontal Alignment"
328
+ msgstr "Wyrównanie w poziomie"
329
+
330
+ #: crayon_settings_wp.class.php:685
331
+ #@ crayon-syntax-highlighter
332
+ msgid "Allow floating elements to surround Crayon"
333
+ msgstr "Pozwalaj elementom opływającym na otaczanie Crayona"
334
+
335
+ #: crayon_settings_wp.class.php:687
336
+ #@ crayon-syntax-highlighter
337
+ msgid "Inline Margin"
338
+ msgstr "Margines dla elementu liniowego"
339
+
340
+ #: crayon_settings_wp.class.php:695
341
+ #@ crayon-syntax-highlighter
342
+ msgid "Display the Toolbar"
343
+ msgstr "Pokazuj pasek narzędzi"
344
+
345
+ #: crayon_settings_wp.class.php:698
346
+ #@ crayon-syntax-highlighter
347
+ msgid "Overlay the toolbar on code rather than push it down when possible"
348
+ msgstr "Jeśli to możliwe, wyświetlaj pasek narzędzi nad kodem zamiast przesuwać go w dół"
349
+
350
+ #: crayon_settings_wp.class.php:699
351
+ #@ crayon-syntax-highlighter
352
+ msgid "Toggle the toolbar on single click when it is overlayed"
353
+ msgstr "Włączaj/wyłączaj pasek narzędzi pojedynczym kliknięciem gdy przykrywa kod"
354
+
355
+ #: crayon_settings_wp.class.php:700
356
+ #@ crayon-syntax-highlighter
357
+ msgid "Delay hiding the toolbar on MouseOut"
358
+ msgstr "Opóźniaj ukrywanie paska narzędzi po przesunięciu kursora myszy"
359
+
360
+ #: crayon_settings_wp.class.php:702
361
+ #@ crayon-syntax-highlighter
362
+ msgid "Display the title when provided"
363
+ msgstr "Pokazuj tytuł jeśli został podany"
364
+
365
+ #: crayon_settings_wp.class.php:703
366
+ #@ crayon-syntax-highlighter
367
+ msgid "Display the language"
368
+ msgstr "Pokazuj język"
369
+
370
+ #: crayon_settings_wp.class.php:710
371
+ #@ crayon-syntax-highlighter
372
+ msgid "Display striped code lines"
373
+ msgstr "Wyświetla paski dla linii kodu"
374
+
375
+ #: crayon_settings_wp.class.php:711
376
+ #@ crayon-syntax-highlighter
377
+ msgid "Enable line marking for important lines"
378
+ msgstr "Włącz możliwość oznaczania ważnych linii"
379
+
380
+ #: crayon_settings_wp.class.php:712
381
+ #@ crayon-syntax-highlighter
382
+ msgid "Enable line ranges for showing only parts of code"
383
+ msgstr "Włącz możliwość określania zakresów, aby pokazywać tylko fragmenty kodu"
384
+
385
+ #: crayon_settings_wp.class.php:713
386
+ #@ crayon-syntax-highlighter
387
+ msgid "Display line numbers by default"
388
+ msgstr "Domyślnie pokazuj numery linii"
389
+
390
+ #: crayon_settings_wp.class.php:714
391
+ #@ crayon-syntax-highlighter
392
+ msgid "Enable line number toggling"
393
+ msgstr "Włącz możliwość włączania i wyłączania numerów linii"
394
+
395
+ #: crayon_settings_wp.class.php:715
396
+ #@ crayon-syntax-highlighter
397
+ msgid "Wrap lines by default"
398
+ msgstr "Domyślnie zawijaj linie"
399
+
400
+ #: crayon_settings_wp.class.php:716
401
+ #@ crayon-syntax-highlighter
402
+ msgid "Enable line wrap toggling"
403
+ msgstr "Włącz możliwość włączania/wyłączania zawijania linii"
404
+
405
+ #: crayon_settings_wp.class.php:717
406
+ #@ crayon-syntax-highlighter
407
+ msgid "Start line numbers from"
408
+ msgstr "Zacznij numerowanie linii od"
409
+
410
+ #: crayon_settings_wp.class.php:728
411
+ #@ crayon-syntax-highlighter
412
+ msgid "When no language is provided, use the fallback"
413
+ msgstr "Gdy nie podano języka, użyj tego:"
414
+
415
+ #: crayon_settings_wp.class.php:734
416
+ #, php-format
417
+ #@ crayon-syntax-highlighter
418
+ msgid "%d language has been detected."
419
+ msgid_plural "%d languages have been detected."
420
+ msgstr[0] "%d język został wykryty."
421
+ msgstr[1] "%d języki zostały wykryty."
422
+ msgstr[2] "%d języków zostało wykrytych."
423
+
424
+ #: crayon_settings_wp.class.php:735
425
+ #@ crayon-syntax-highlighter
426
+ msgid "Parsing was successful"
427
+ msgstr "Parsowanie powiodło się"
428
+
429
+ #: crayon_settings_wp.class.php:735
430
+ #@ crayon-syntax-highlighter
431
+ msgid "Parsing was unsuccessful"
432
+ msgstr "Parsowanie nie powiodło się"
433
+
434
+ #: crayon_settings_wp.class.php:741
435
+ #, php-format
436
+ #@ crayon-syntax-highlighter
437
+ msgid "The selected language with id %s could not be loaded"
438
+ msgstr "Wybrany język o id %s nie mógł zostać załadowany"
439
+
440
+ #: crayon_settings_wp.class.php:744
441
+ #@ crayon-syntax-highlighter
442
+ msgid "Show Languages"
443
+ msgstr "Pokaż języki"
444
+
445
+ #: crayon_settings_wp.class.php:780
446
+ #@ crayon-syntax-highlighter
447
+ msgid "Show Crayon Posts"
448
+ msgstr "Pokaż wpisy ze znacznikami Crayon"
449
+
450
+ #: crayon_settings_wp.class.php:781
451
+ #@ crayon-syntax-highlighter
452
+ msgid "Refresh"
453
+ msgstr "Odśwież"
454
+
455
+ #: crayon_settings_wp.class.php:806
456
+ #@ crayon-syntax-highlighter
457
+ msgid "ID"
458
+ msgstr "ID"
459
+
460
+ #: crayon_settings_wp.class.php:806
461
+ #: util/tag-editor/crayon_tag_editor_wp.class.php:179
462
+ #@ crayon-syntax-highlighter
463
+ msgid "Title"
464
+ msgstr "Tytuł"
465
+
466
+ #: crayon_settings_wp.class.php:806
467
+ #@ crayon-syntax-highlighter
468
+ msgid "Posted"
469
+ msgstr "Opublikowany"
470
+
471
+ #: crayon_settings_wp.class.php:806
472
+ #@ crayon-syntax-highlighter
473
+ msgid "Modifed"
474
+ msgstr "Zmodyfikowany"
475
+
476
+ #: crayon_settings_wp.class.php:806
477
+ #@ crayon-syntax-highlighter
478
+ msgid "Contains Legacy Tags?"
479
+ msgstr "Zawiera stare znaczniki?"
480
+
481
+ #: crayon_settings_wp.class.php:826
482
+ #@ crayon-syntax-highlighter
483
+ msgid "Yes"
484
+ msgstr "Tak"
485
+
486
+ #: crayon_settings_wp.class.php:826
487
+ #@ crayon-syntax-highlighter
488
+ msgid "No"
489
+ msgstr "Nie"
490
+
491
+ #: crayon_settings_wp.class.php:910
492
+ #@ crayon-syntax-highlighter
493
+ msgid "Edit"
494
+ msgstr "Edytuj"
495
+
496
+ #: crayon_settings_wp.class.php:910
497
+ #@ crayon-syntax-highlighter
498
+ msgid "Duplicate"
499
+ msgstr "Duplikuj"
500
+
501
+ #: crayon_settings_wp.class.php:910
502
+ #@ crayon-syntax-highlighter
503
+ msgid "Create"
504
+ msgstr "Utwórz"
505
+
506
+ #: crayon_settings_wp.class.php:910
507
+ #@ crayon-syntax-highlighter
508
+ msgid "Delete"
509
+ msgstr "Usuń"
510
+
511
+ #: crayon_settings_wp.class.php:912
512
+ #@ crayon-syntax-highlighter
513
+ msgid "Loading..."
514
+ msgstr "Ładowanie..."
515
+
516
+ #: crayon_settings_wp.class.php:927
517
+ #, php-format
518
+ #@ crayon-syntax-highlighter
519
+ msgid "Change the %1$sfallback language%2$s to change the sample code. Lines 5-7 are marked."
520
+ msgstr "Zmień %1$sdomyślny język%2$s aby zmienić przykładowy kod. Linie 5-7 są oznaczone."
521
+
522
+ #: crayon_settings_wp.class.php:932
523
+ #@ crayon-syntax-highlighter
524
+ msgid "Enable Live Preview"
525
+ msgstr "Włącz podgląd na żywo"
526
+
527
+ #: crayon_settings_wp.class.php:934
528
+ #@ crayon-syntax-highlighter
529
+ msgid "Enqueue themes in the header (more efficient)."
530
+ msgstr "Dodawaj pliki motywów do nagłówka (bardziej wydajne)."
531
+
532
+ #: crayon_settings_wp.class.php:937
533
+ #, php-format
534
+ #@ crayon-syntax-highlighter
535
+ msgid "The selected theme with id %s could not be loaded"
536
+ msgstr "Wybrany motyw o id %s nie mógł zostać załadowany"
537
+
538
+ #: crayon_settings_wp.class.php:949
539
+ #@ crayon-syntax-highlighter
540
+ msgid "Custom Font Size"
541
+ msgstr "Własny rozmiar czcionki"
542
+
543
+ #: crayon_settings_wp.class.php:954
544
+ #, php-format
545
+ #@ crayon-syntax-highlighter
546
+ msgid "The selected font with id %s could not be loaded"
547
+ msgstr "Wybrana czcionka o id %s nie mogła zostać załadowana"
548
+
549
+ #: crayon_settings_wp.class.php:960
550
+ #@ crayon-syntax-highlighter
551
+ msgid "Enqueue fonts in the header (more efficient)."
552
+ msgstr "Dodawaj pliki czcionek do nagłówka (bardziej wydajne)."
553
+
554
+ #: crayon_settings_wp.class.php:965
555
+ #@ crayon-syntax-highlighter
556
+ msgid "Enable plain code view and display"
557
+ msgstr "Włącz widok czystego kodu"
558
+
559
+ #: crayon_settings_wp.class.php:968
560
+ #@ crayon-syntax-highlighter
561
+ msgid "Enable plain code toggling"
562
+ msgstr "Włącz włączanie/wyłączanie czystego kodu"
563
+
564
+ #: crayon_settings_wp.class.php:969
565
+ #@ crayon-syntax-highlighter
566
+ msgid "Show the plain code by default"
567
+ msgstr "Domyślnie pokazuj czysty kod"
568
+
569
+ #: crayon_settings_wp.class.php:970
570
+ #@ crayon-syntax-highlighter
571
+ msgid "Enable code copy/paste"
572
+ msgstr "Włącz kopiowanie i wklejanie kodu"
573
+
574
+ #: crayon_settings_wp.class.php:972
575
+ #@ crayon-syntax-highlighter
576
+ msgid "Enable opening code in a window"
577
+ msgstr "Włącz otwieranie kodu w nowym oknie"
578
+
579
+ #: crayon_settings_wp.class.php:973
580
+ #@ crayon-syntax-highlighter
581
+ msgid "Always display scrollbars"
582
+ msgstr "Zawsze pokazuj paski przewijania"
583
+
584
+ #: crayon_settings_wp.class.php:974
585
+ #@ crayon-syntax-highlighter
586
+ msgid "Expand code beyond page borders on mouseover"
587
+ msgstr "Rozszerz kod poza krawędzie strony po wskazaniu myszą"
588
+
589
+ #: crayon_settings_wp.class.php:975
590
+ #@ crayon-syntax-highlighter
591
+ msgid "Enable code expanding toggling when possible"
592
+ msgstr "Gdy to możliwe, włącz włączanie/wyłączanie rozszerzania kodu"
593
+
594
+ #: crayon_settings_wp.class.php:978
595
+ #@ crayon-syntax-highlighter
596
+ msgid "Decode HTML entities in code"
597
+ msgstr "Dekoduj encje HTML w kodzie"
598
+
599
+ #: crayon_settings_wp.class.php:980
600
+ #@ crayon-syntax-highlighter
601
+ msgid "Decode HTML entities in attributes"
602
+ msgstr "Dekoduj encje HTML w atrybutach"
603
+
604
+ #: crayon_settings_wp.class.php:982
605
+ #@ crayon-syntax-highlighter
606
+ msgid "Remove whitespace surrounding the shortcode content"
607
+ msgstr "Usuwaj białe spacje otaczające zawartość shortcode"
608
+
609
+ #: crayon_settings_wp.class.php:984
610
+ #@ crayon-syntax-highlighter
611
+ msgid "Allow Mixed Language Highlighting with delimiters and tags."
612
+ msgstr "Pozwalaj na kolorowanie wielu języków z separatorami i znacznikami."
613
+
614
+ #: crayon_settings_wp.class.php:986
615
+ #@ crayon-syntax-highlighter
616
+ msgid "Show Mixed Language Icon (+)"
617
+ msgstr "Pokazuj ikonę wielu języków (+)"
618
+
619
+ #: crayon_settings_wp.class.php:988
620
+ #@ crayon-syntax-highlighter
621
+ msgid "Tab size in spaces"
622
+ msgstr "Wielkość tabulatora (spacje)"
623
+
624
+ #: crayon_settings_wp.class.php:990
625
+ #@ crayon-syntax-highlighter
626
+ msgid "Blank lines before code:"
627
+ msgstr "Puste linie przed kodem:"
628
+
629
+ #: crayon_settings_wp.class.php:992
630
+ #@ crayon-syntax-highlighter
631
+ msgid "Blank lines after code:"
632
+ msgstr "Puste linie za kodem:"
633
+
634
+ #: crayon_settings_wp.class.php:997
635
+ #@ crayon-syntax-highlighter
636
+ msgid "Capture Mini Tags like [php][/php] as Crayons."
637
+ msgstr "Traktuj znaczniki w rodzaju [php][/php] jako znaczniki Crayona."
638
+
639
+ #: crayon_settings_wp.class.php:998
640
+ #@ crayon-syntax-highlighter
641
+ msgid "Capture Inline Tags like {php}{/php} inside sentences."
642
+ msgstr "Traktuj znaczniki liniowe w rodzaju {php}{/php} wewnątrz zdań jako znaczniki Crayona."
643
+
644
+ #: crayon_settings_wp.class.php:999
645
+ #@ crayon-syntax-highlighter
646
+ msgid "Wrap Inline Tags"
647
+ msgstr "Zawijaj znaczniki liniowe"
648
+
649
+ #: crayon_settings_wp.class.php:1000
650
+ #@ crayon-syntax-highlighter
651
+ msgid "Capture `backquotes` as &lt;code&gt;"
652
+ msgstr "Traktuj `odwrócone apostrofy` jako &lt;code&gt;"
653
+
654
+ #: crayon_settings_wp.class.php:1001
655
+ #@ crayon-syntax-highlighter
656
+ msgid "Capture &lt;pre&gt; tags as Crayons"
657
+ msgstr "Traktuj znaczniki &lt;pre&gt; jako znaczniki Crayona"
658
+
659
+ #: crayon_settings_wp.class.php:1002
660
+ #@ crayon-syntax-highlighter
661
+ msgid "Enable [plain][/plain] tag."
662
+ msgstr "Włącz tag [plain][/plain]."
663
+
664
+ #: crayon_settings_wp.class.php:1007
665
+ #@ crayon-syntax-highlighter
666
+ msgid "When loading local files and a relative path is given for the URL, use the absolute path"
667
+ msgstr "Gdy ładowane są lokalne pliki i podano względną ścieżkę dla adresu URL, użyj ścieżki bezwzględnej"
668
+
669
+ #: crayon_settings_wp.class.php:1010
670
+ #@ crayon-syntax-highlighter
671
+ msgid "Followed by your relative URL."
672
+ msgstr "poprzedzonej Twoim pełnym adresem URL."
673
+
674
+ #: crayon_settings_wp.class.php:1017
675
+ #@ crayon-syntax-highlighter
676
+ msgid "Convert Legacy Tags"
677
+ msgstr "Konwertuj stare znaczniki"
678
+
679
+ #: crayon_settings_wp.class.php:1020
680
+ #@ crayon-syntax-highlighter
681
+ msgid "No Legacy Tags Found"
682
+ msgstr "Nie znaleziono starych znaczników"
683
+
684
+ #: crayon_settings_wp.class.php:1025
685
+ #, php-format
686
+ #@ crayon-syntax-highlighter
687
+ msgid "Use %s to separate setting names from values in the &lt;pre&gt; class attribute"
688
+ msgstr "Użyj %s do oddzielania nazw ustawień od ich wartości w atrybucie 'class' znacznika &lt;pre&gt;"
689
+
690
+ #: crayon_settings_wp.class.php:1028
691
+ #@ crayon-syntax-highlighter
692
+ msgid "Display the Tag Editor in any TinyMCE instances on the frontend (e.g. bbPress)"
693
+ msgstr "Pokazuj edytor znaczników w TinyMCE na stronie (np. w bbPress)"
694
+
695
+ #: crayon_settings_wp.class.php:1029
696
+ #@ crayon-syntax-highlighter
697
+ msgid "Display Tag Editor settings on the frontend"
698
+ msgstr "Pokazuj ustawienia edytora znaczników na stronie"
699
+
700
+ #: crayon_settings_wp.class.php:1033
701
+ #@ crayon-syntax-highlighter
702
+ msgid "Clear the cache used to store remote code requests"
703
+ msgstr "Wyczyść cache kodu pobranego z zewnętrznych źródeł"
704
+
705
+ #: crayon_settings_wp.class.php:1035
706
+ #@ crayon-syntax-highlighter
707
+ msgid "Clear Now"
708
+ msgstr "Wyczyść teraz"
709
+
710
+ #: crayon_settings_wp.class.php:1036
711
+ #@ crayon-syntax-highlighter
712
+ msgid "Attempt to load Crayon's CSS and JavaScript only when needed"
713
+ msgstr "Spróbuj ładować pliki CSS i JavaScript Crayona tylko gdy są potrzebne"
714
+
715
+ #: crayon_settings_wp.class.php:1037
716
+ #@ crayon-syntax-highlighter
717
+ msgid "Disable enqueuing for page templates that may contain The Loop."
718
+ msgstr "Wyłącz ładowanie plików dla szablonów stron, które mogą zawierać pętlę (The Loop)."
719
+
720
+ #: crayon_settings_wp.class.php:1038
721
+ #@ crayon-syntax-highlighter
722
+ msgid "Allow Crayons inside comments"
723
+ msgstr "Pozwól na działanie Crayona w komentarzach"
724
+
725
+ #: crayon_settings_wp.class.php:1039
726
+ #@ crayon-syntax-highlighter
727
+ msgid "Remove Crayons from excerpts"
728
+ msgstr "Usuwaj znaczniki Crayona z wypisów"
729
+
730
+ #: crayon_settings_wp.class.php:1040
731
+ #@ crayon-syntax-highlighter
732
+ msgid "Load Crayons only from the main Wordpress query"
733
+ msgstr "Ładuj znaczniki Crayon tylko dla głównego zapytania WordPressa."
734
+
735
+ #: crayon_settings_wp.class.php:1041
736
+ #@ crayon-syntax-highlighter
737
+ msgid "Disable mouse gestures for touchscreen devices (eg. MouseOver)"
738
+ msgstr "Wyłącz gesty myszy dla urządzeń dotykowych (np. MouseOver)"
739
+
740
+ #: crayon_settings_wp.class.php:1042
741
+ #@ crayon-syntax-highlighter
742
+ msgid "Disable animations"
743
+ msgstr "Wyłącz animacje"
744
+
745
+ #: crayon_settings_wp.class.php:1043
746
+ #@ crayon-syntax-highlighter
747
+ msgid "Disable runtime stats"
748
+ msgstr "Wyłącz zbieranie danych o działaniu"
749
+
750
+ #: crayon_settings_wp.class.php:1049
751
+ #@ crayon-syntax-highlighter
752
+ msgid "Log errors for individual Crayons"
753
+ msgstr "Loguj błędy na poszczególnych znaczników Crayona"
754
+
755
+ #: crayon_settings_wp.class.php:1050
756
+ #@ crayon-syntax-highlighter
757
+ msgid "Log system-wide errors"
758
+ msgstr "Loguj błędy systemowe"
759
+
760
+ #: crayon_settings_wp.class.php:1051
761
+ #@ crayon-syntax-highlighter
762
+ msgid "Display custom message for errors"
763
+ msgstr "Pokazuj własne komunikaty o błędach"
764
+
765
+ #: crayon_settings_wp.class.php:1063
766
+ #@ crayon-syntax-highlighter
767
+ msgid "Show Log"
768
+ msgstr "Pokaż log"
769
+
770
+ #: crayon_settings_wp.class.php:1063
771
+ #@ crayon-syntax-highlighter
772
+ msgid "Hide Log"
773
+ msgstr "Ukryj log"
774
+
775
+ #: crayon_settings_wp.class.php:1065
776
+ #@ crayon-syntax-highlighter
777
+ msgid "Clear Log"
778
+ msgstr "Wyczyść log"
779
+
780
+ #: crayon_settings_wp.class.php:1066
781
+ #@ crayon-syntax-highlighter
782
+ msgid "Email Admin"
783
+ msgstr "Wyślij e-mailem do administratora"
784
+
785
+ #: crayon_settings_wp.class.php:1068
786
+ #@ crayon-syntax-highlighter
787
+ msgid "Email Developer"
788
+ msgstr "Wyślij e-mailem do autora"
789
+
790
+ #: crayon_settings_wp.class.php:1070
791
+ #@ crayon-syntax-highlighter
792
+ msgid "The log is currently empty."
793
+ msgstr "Log jest pusty."
794
+
795
+ #: crayon_settings_wp.class.php:1072
796
+ #@ crayon-syntax-highlighter
797
+ msgid "The log file exists and is writable."
798
+ msgstr "Plik logu istnieje i jest zapisywalny."
799
+
800
+ #: crayon_settings_wp.class.php:1072
801
+ #@ crayon-syntax-highlighter
802
+ msgid "The log file exists and is not writable."
803
+ msgstr "Plik logu istnieje, ale nie jest zapisywalny."
804
+
805
+ #: crayon_settings_wp.class.php:1074
806
+ #@ crayon-syntax-highlighter
807
+ msgid "The log file does not exist and is not writable."
808
+ msgstr "Plik logu nie istnieje i nie można go utworzyć."
809
+
810
+ #: crayon_settings_wp.class.php:1084
811
+ #@ crayon-syntax-highlighter
812
+ msgid "Version"
813
+ msgstr "Wersja"
814
+
815
+ #: crayon_settings_wp.class.php:1086
816
+ #@ crayon-syntax-highlighter
817
+ msgid "Developer"
818
+ msgstr "Autor"
819
+
820
+ #: crayon_settings_wp.class.php:1087
821
+ #@ crayon-syntax-highlighter
822
+ msgid "Translators"
823
+ msgstr "Tłumacze"
824
+
825
+ #: crayon_settings_wp.class.php:1122
826
+ #@ crayon-syntax-highlighter
827
+ msgid "The result of innumerable hours of hard work over many months. It's an ongoing project, keep me motivated!"
828
+ msgstr "Wynik niezliczonych godzin ciężkiej pracy przez wiele miesięcy. Ten projekt wciąż jest rozwijany, tak więc motywujcie mnie!"
829
+
830
+ #: crayon_settings_wp.class.php:1132
831
+ #@ crayon-syntax-highlighter
832
+ msgid "?"
833
+ msgstr "?"
834
+
835
+ #: crayon_settings_wp.class.php:1139
836
+ #@ crayon-syntax-highlighter
837
+ msgid "Donate"
838
+ msgstr "Dotacje"
839
+
840
+ #. translators: plugin header field 'Name'
841
+ #: crayon_wp.class.php:0
842
+ #@ crayon-syntax-highlighter
843
+ msgid "Crayon Syntax Highlighter"
844
+ msgstr ""
845
+
846
+ #. translators: plugin header field 'PluginURI'
847
+ #: crayon_wp.class.php:0
848
+ #@ crayon-syntax-highlighter
849
+ msgid "http://ak.net84.net/projects/crayon-syntax-highlighter"
850
+ msgstr ""
851
+
852
+ #. translators: plugin header field 'Description'
853
+ #: crayon_wp.class.php:0
854
+ #@ crayon-syntax-highlighter
855
+ msgid "Supports multiple languages, themes, highlighting from a URL, local file or post text."
856
+ msgstr "Obsługuje wiele języków, motywy, kolorowanie kodu pobieranego z adresu URL, pliku lokalnego lub treści wpisu."
857
+
858
+ #. translators: plugin header field 'Author'
859
+ #: crayon_wp.class.php:0
860
+ #@ crayon-syntax-highlighter
861
+ msgid "Aram Kocharyan"
862
+ msgstr ""
863
+
864
+ #. translators: plugin header field 'AuthorURI'
865
+ #: crayon_wp.class.php:0
866
+ #@ crayon-syntax-highlighter
867
+ msgid "http://ak.net84.net/"
868
+ msgstr ""
869
+
870
+ #: util/tag-editor/crayon_tag_editor_wp.class.php:64
871
+ #@ crayon-syntax-highlighter
872
+ msgid "Add Crayon Code"
873
+ msgstr "Dodaj kod Crayon"
874
+
875
+ #: util/tag-editor/crayon_tag_editor_wp.class.php:65
876
+ #@ crayon-syntax-highlighter
877
+ msgid "Edit Crayon Code"
878
+ msgstr "Edytuj kod Crayon"
879
+
880
+ #: util/tag-editor/crayon_tag_editor_wp.class.php:66
881
+ #@ crayon-syntax-highlighter
882
+ msgid "Add"
883
+ msgstr "Dodaj"
884
+
885
+ #: util/tag-editor/crayon_tag_editor_wp.class.php:67
886
+ #@ crayon-syntax-highlighter
887
+ msgid "Save"
888
+ msgstr "Zapisz"
889
+
890
+ #: util/tag-editor/crayon_tag_editor_wp.class.php:170
891
+ #@ crayon-syntax-highlighter
892
+ msgid "OK"
893
+ msgstr "OK"
894
+
895
+ #: util/tag-editor/crayon_tag_editor_wp.class.php:172
896
+ #@ crayon-syntax-highlighter
897
+ msgid "Cancel"
898
+ msgstr "Anuluj"
899
+
900
+ #: util/tag-editor/crayon_tag_editor_wp.class.php:181
901
+ #@ crayon-syntax-highlighter
902
+ msgid "A short description"
903
+ msgstr "Krótki opis"
904
+
905
+ #: util/tag-editor/crayon_tag_editor_wp.class.php:183
906
+ #@ crayon-syntax-highlighter
907
+ msgid "Inline"
908
+ msgstr "Liniowy"
909
+
910
+ #: util/tag-editor/crayon_tag_editor_wp.class.php:185
911
+ #@ crayon-syntax-highlighter
912
+ msgid "Don't Highlight"
913
+ msgstr "Nie koloruj"
914
+
915
+ #: util/tag-editor/crayon_tag_editor_wp.class.php:190
916
+ #@ crayon-syntax-highlighter
917
+ msgid "Language"
918
+ msgstr "Język"
919
+
920
+ #: util/tag-editor/crayon_tag_editor_wp.class.php:193
921
+ #@ crayon-syntax-highlighter
922
+ msgid "Line Range"
923
+ msgstr "Zakres linii"
924
+
925
+ #: util/tag-editor/crayon_tag_editor_wp.class.php:194
926
+ #@ crayon-syntax-highlighter
927
+ msgid "(e.g. 3-5 or 3)"
928
+ msgstr "(np. 3-5 lub 3)"
929
+
930
+ #: util/tag-editor/crayon_tag_editor_wp.class.php:195
931
+ #@ crayon-syntax-highlighter
932
+ msgid "Marked Lines"
933
+ msgstr "Oznaczone linie"
934
+
935
+ #: util/tag-editor/crayon_tag_editor_wp.class.php:196
936
+ #@ crayon-syntax-highlighter
937
+ msgid "(e.g. 1,2,3-5)"
938
+ msgstr "(np. 1,2,3-5)"
939
+
940
+ #: util/tag-editor/crayon_tag_editor_wp.class.php:203
941
+ #@ crayon-syntax-highlighter
942
+ msgid "Clear"
943
+ msgstr "Wyczyść"
944
+
945
+ #: util/tag-editor/crayon_tag_editor_wp.class.php:207
946
+ #@ crayon-syntax-highlighter
947
+ msgid "Paste your code here, or type it in manually."
948
+ msgstr "Wklej tutaj swój kod lub wpisz go ręcznie."
949
+
950
+ #: util/tag-editor/crayon_tag_editor_wp.class.php:211
951
+ #@ crayon-syntax-highlighter
952
+ msgid "URL"
953
+ msgstr "URL"
954
+
955
+ #: util/tag-editor/crayon_tag_editor_wp.class.php:213
956
+ #@ crayon-syntax-highlighter
957
+ msgid "Relative local path or absolute URL"
958
+ msgstr "Względna ścieżka lokalna lub pełny URL"
959
+
960
+ #: util/tag-editor/crayon_tag_editor_wp.class.php:216
961
+ #@ crayon-syntax-highlighter
962
+ msgid "If the URL fails to load, the code above will be shown instead. If no code exists, an error is shown."
963
+ msgstr "Jeśli nie uda się załadować tego URLa, zostanie wyświetlony powyższy kod. Jeśli żaden kod nie istnieje, zostanie wyświetlony błąd."
964
+
965
+ #: util/tag-editor/crayon_tag_editor_wp.class.php:218
966
+ #, php-format
967
+ #@ crayon-syntax-highlighter
968
+ msgid "If a relative local path is given it will be appended to %s - which is defined in %sCrayon &gt; Settings &gt; Files%s."
969
+ msgstr "Jeśli została podana względna ścieżka lokalna, zostanie ona poprzedzona przez %s. Można to zdefiniować w %sCrayon &gt; Ustawienia &gt; Pliki%s."
970
+
971
+ #: util/tag-editor/crayon_tag_editor_wp.class.php:243
972
+ #@ crayon-syntax-highlighter
973
+ msgid "Change the following settings to override their global values."
974
+ msgstr "Zmień poszczególne ustawienia aby nadpisać ich globalne wartości."
975
+
976
+ #: util/tag-editor/crayon_tag_editor_wp.class.php:245
977
+ #@ crayon-syntax-highlighter
978
+ msgid "Only changes (shown yellow) are applied."
979
+ msgstr "Tylko te z nich, które zostały zmienione (oznaczone na żółto), zostaną zapisane."
980
+
981
+ #: util/tag-editor/crayon_tag_editor_wp.class.php:247
982
+ #, php-format
983
+ #@ crayon-syntax-highlighter
984
+ msgid "Future changes to the global settings under %sCrayon &gt; Settings%s won't affect overridden settings."
985
+ msgstr "Przyszłe zmiany w globalnych ustawieniach (%sCrayon &gt; Ustawienia%s) nie będą miały wpływu na nadpisane tutaj ustawienia."
986
+
987
+ #: util/theme-editor/theme_editor_content.php:23
988
+ #@ crayon-syntax-highlighter
989
+ msgid "Theme Editor"
990
+ msgstr "Edytor motywów"
991
+
992
+ #: util/theme-editor/theme_editor_content.php:29
993
+ #, php-format
994
+ #@ crayon-syntax-highlighter
995
+ msgid "Editing \"%s\" Theme"
996
+ msgstr "Edycja motywu \"%s\""
997
+
998
+ #: util/theme-editor/theme_editor_content.php:31
999
+ #, php-format
1000
+ #@ crayon-syntax-highlighter
1001
+ msgid "Creating Theme From \"%s\""
1002
+ msgstr "Tworzenie motywu na podstawie \"%s\""
1003
+
1004
+ #: util/theme-editor/theme_editor_content.php:37
1005
+ #@ crayon-syntax-highlighter
1006
+ msgid "Back To Settings"
1007
+ msgstr "Powrót do ustawień"
1008
+
1009
+ #. translators: plugin header field 'Version'
1010
+ #: crayon_wp.class.php:0
1011
+ #@ crayon-syntax-highlighter
1012
+ msgid "_1.17_beta"
1013
+ msgstr ""
1014
+
util/ajax.php DELETED
@@ -1,20 +0,0 @@
1
- <?php
2
-
3
- // Depreciated since 1.14
4
-
5
- // Used to send requests to db from jQuery
6
-
7
- require_once('../crayon_wp.class.php');
8
-
9
- CrayonSettingsWP::load_settings(true);
10
-
11
- $allowed = array(CrayonSettings::HIDE_HELP);
12
-
13
- foreach ($allowed as $allow) {
14
- if ( array_key_exists($allow, $_GET) ) {
15
- CrayonGlobalSettings::set($allow, $_GET[$allow]);
16
- CrayonSettingsWP::save_settings();
17
- }
18
- }
19
-
20
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
util/crayon_util.class.php CHANGED
@@ -2,546 +2,801 @@
2
 
3
  /* Common utility functions mainly for formatting, parsing etc. */
4
  class CrayonUtil {
5
-
6
- // Used to detect touchscreen devices
7
- private static $touchscreen = NULL;
8
-
9
- /* Return the lines inside a file as an array, options:
10
- l - lowercase
11
- w - remove whitespace
12
- r - escape regex chars
13
- c - remove comments
14
- s - return as string */
15
- public static function lines($path, $opts = NULL) {
16
- $path = self::pathf($path);
17
- if ( ($str = self::file($path)) === FALSE ) {
18
- // Log failure, n = no log
19
- if ( strpos($opts, 'n') === FALSE ) {
20
- CrayonLog::syslog("Cannot read lines at '$path'.", "CrayonUtil::lines()");
21
- }
22
- return FALSE;
23
- }
24
- // Read the options
25
- if (is_string($opts)) {
26
- $lowercase = strpos($opts, 'l') !== FALSE;
27
- $whitespace = strpos($opts, 'w') !== FALSE;
28
- $escape_regex = strpos($opts, 'r') !== FALSE;
29
- $clean_commments = strpos($opts, 'c') !== FALSE;
30
- $return_string = strpos($opts, 's') !== FALSE;
31
  // $escape_hash = strpos($opts, 'h') !== FALSE;
32
- } else {
33
- $lowercase = $whitespace = $escape_regex = $clean_commments = $return_string = /*$escape_hash =*/ FALSE;
34
- }
35
- // Remove comments
36
- if ($clean_commments) {
37
- $str = self::clean_comments($str);
38
- }
39
-
40
- // Convert to lowercase if needed
41
- if ($lowercase) {
42
- $str = strtolower($str);
43
- }
44
- /* Match all the content on non-empty lines, also remove any whitespace to the left and
45
- right if needed */
46
- if ($whitespace) {
47
- $pattern = '[^\s]+(?:.*[^\s])?';
48
- } else {
49
- $pattern = '^(?:.*)?';
50
- }
51
-
52
- preg_match_all('|' . $pattern . '|m', $str, $matches);
53
- $lines = $matches[0];
54
- // Remove regex syntax and assume all characters are literal
55
- if ($escape_regex) {
56
- for ($i = 0; $i < count($lines); $i++) {
57
- $lines[$i] = self::esc_regex($lines[$i]);
 
58
  // if ($escape_hash || true) {
59
- // If we have used \#, then we don't want it to become \\#
60
- $lines[$i] = preg_replace('|\\\\\\\\#|', '\#', $lines[$i]);
61
  // }
62
- }
63
- }
64
-
65
- // Return as string if needed
66
- if ($return_string) {
67
- // Add line breaks if they were stripped
68
- $delimiter = '';
69
- if ($whitespace) {
70
- $delimiter = CRAYON_NL;
71
- }
72
- $lines = implode($lines, $delimiter);
73
- }
74
-
75
- return $lines;
76
- }
77
-
78
- // Returns the contents of a file
79
- public static function file($path) {
80
- if ( ($str = @file_get_contents($path)) === FALSE ) {
81
- return FALSE;
82
- } else {
83
- return $str;
84
- }
85
- }
86
-
87
- // Detects if device is touchscreen or mobile
88
- public static function is_touch() {
89
- // Only detect once
90
- if (self::$touchscreen !== NULL) {
91
- return self::$touchscreen;
92
- }
93
- if ( ($devices = self::lines(CRAYON_TOUCH_FILE, 'lw')) !== FALSE ) {
94
- // Create array of device strings from file
95
- $user_agent = strtolower($_SERVER['HTTP_USER_AGENT']);
96
- self::$touchscreen = (self::strposa($user_agent, $devices) !== FALSE);
97
- return self::$touchscreen;
98
- } else {
99
- CrayonLog::syslog('Error occurred when trying to identify touchscreen devices');
100
- }
101
- }
102
-
103
- // Removes duplicates in array, ensures they are all strings
104
- public static function array_unique_str($array) {
105
- if (!is_array($array) || empty($array)) {
106
- return array();
107
- }
108
- for ($i = 0; $i < count($array); $i++) {
109
- $array[$i] = strval($array[$i]);
110
- }
111
- return array_unique($array);
112
- }
113
-
114
- // Same as array_key_exists, but returns the key when exists, else FALSE;
115
- public static function array_key_exists($key, $array) {
116
- if (!is_array($array) || empty($array) || !is_string($key) || empty($key)) {
117
- FALSE;
118
- }
119
- if ( array_key_exists($key, $array) ) {
120
- return $array[$key];
121
- }
122
- }
123
-
124
- // Performs explode() on a string with the given delimiter and trims all whitespace
125
- public static function trim_e($str, $delimiter = ',') {
126
- if (is_string($delimiter)) {
127
- $str = trim(preg_replace('|\s*(?:' . preg_quote($delimiter) . ')\s*|', $delimiter, $str));
128
- return explode($delimiter, $str);
129
- }
130
- return $str;
131
- }
132
-
133
- /* Creates an array of integers based on a given range string of format "int - int"
134
- Eg. range_str('2 - 5'); */
135
- public static function range_str($str) {
136
- preg_match('#(\d+)\s*-\s*(\d+)#', $str, $matches);
137
- if (count($matches) == 3) {
138
- return range($matches[1], $matches[2]);
139
- }
140
- return FALSE;
141
- }
142
-
143
- // Creates an array out of a single range string (e.i "x-y")
144
- public static function range_str_single($str) {
145
- $match = preg_match('#(\d+)(?:\s*-\s*(\d+))?#', $str, $matches);
146
- if ($match > 0) {
147
- if (empty($matches[2])) {
148
- $matches[2] = $matches[1];
149
- }
150
- if ($matches[1] <= $matches[2]) {
151
- return array($matches[1], $matches[2]);
152
- }
153
- }
154
- return FALSE;
155
- }
156
-
157
- // Sets a variable to a string if valid
158
- public static function str(&$var, $str, $escape = TRUE) {
159
- if (is_string($str)) {
160
- $var = ($escape == TRUE ? self::htmlentities($str) : $str);
161
- return TRUE;
162
- }
163
- return FALSE;
164
- }
165
-
166
- // Converts all special charactres to entities
167
- public static function htmlentities($str) {
168
- return htmlentities($str, ENT_COMPAT, 'UTF-8');
169
- }
170
-
171
- public static function html_entity_decode($str) {
172
- return html_entity_decode($str, ENT_NOQUOTES, 'UTF-8');
173
- }
174
-
175
- // Converts <, >, & into entities
176
- public static function htmlspecialchars($str) {
177
- return htmlspecialchars($str, ENT_NOQUOTES, 'UTF-8');
178
- }
179
-
180
- // Sets a variable to an int if valid
181
- public static function num(&$var, $num) {
182
- if (is_numeric($num)) {
183
- $var = intval($num);
184
- return TRUE;
185
- }
186
- return FALSE;
187
- }
188
-
189
- // Sets a variable to an array if valid
190
- public static function arr(&$var, $array) {
191
- if (is_array($array)) {
192
- $var = $array;
193
- return TRUE;
194
- }
195
- return FALSE;
196
- }
197
-
198
- // Sets a variable to an array if valid
199
- public static function set_array($var, $array, $false = FALSE) {
200
- return isset($array[$var]) ? $array[$var] : $false;
201
- }
202
-
203
- // Sets a variable to null if not set
204
- public static function set_var(&$var, $false = NULL) {
205
- $var = isset($var) ? $var : $false;
206
- }
207
-
208
- // Thanks, http://www.php.net/manual/en/function.str-replace.php#102186
209
- function str_replace_once($str_pattern, $str_replacement, $string){
210
- if (strpos($string, $str_pattern) !== FALSE){
211
- $occurrence = strpos($string, $str_pattern);
212
- return substr_replace($string, $str_replacement, strpos($string, $str_pattern), strlen($str_pattern));
213
- }
214
- return $string;
215
- }
216
-
217
- // Removes non-numeric chars in string
218
- public static function clean_int($str, $return_zero = TRUE) {
219
- $str = preg_replace('#[^\d]#', '', $str);
220
- if ($return_zero) {
221
- // If '', then returns 0
222
- return strval(intval($str));
223
- } else {
224
- // Might be ''
225
- return $str;
226
- }
227
- }
228
-
229
- // Replaces whitespace with hypthens
230
- public static function space_to_hyphen($str) {
231
- return preg_replace('#\s+#', '-', $str);
232
- }
233
-
234
- // Replaces hypthens with spaces
235
- public static function hyphen_to_space($str) {
236
- return preg_replace('#-#', ' ', $str);
237
- }
238
-
239
- // Remove comments with /* */, // or #, if they occur before any other char on a line
240
- public static function clean_comments($str) {
241
- $comment_pattern = '#(?:^\s*/\*.*?^\s*\*/)|(?:^(?!\s*$)[\s]*(?://|\#)[^\r\n]*)#ms';
242
- $str = preg_replace($comment_pattern, '', $str);
243
- return $str;
244
- }
245
-
246
- // Convert to title case and replace underscores with spaces
247
- public static function ucwords($str) {
248
- $str = strval($str);
249
- $str = str_replace('_', ' ', $str);
250
- return ucwords($str);
251
- }
252
-
253
- // Escapes regex characters as literals
254
- public static function esc_regex($regex) {
255
- return /*htmlspecialchars(*/preg_quote($regex)/* , ENT_NOQUOTES)*/;
256
- }
257
-
258
- // Escapes hash character as literals
259
- public static function esc_hash($regex) {
260
- if (is_string($regex)) {
261
- return preg_replace('|(?<!\\\\)#|', '\#', $regex);
262
- } else {
263
- return FALSE;
264
- }
265
- }
266
-
267
- // Ensure all parenthesis are atomic to avoid conflicting with element matches
268
- public static function esc_atomic($regex) {
269
- return preg_replace('#(?<!\\\\)\((?!\?)#', '(?:', $regex);
270
- }
271
-
272
- // Returns the current HTTP URL
273
- public static function current_url() {
274
- return "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
275
- }
276
-
277
- // Removes crayon plugin path from absolute path
278
- public static function path_rel($url) {
279
- if (is_string($url)) {
280
- return str_replace(CRAYON_ROOT_PATH, '/', $url);
281
- }
282
- return $url;
283
- }
284
-
285
- // Returns path according to detected use of forwardslash/backslash
286
- // Depreciated from regular use after v.1.1.1
287
- public static function path($path, $detect) {
288
- $slash = self::detect_slash($detect);
289
- return str_replace(array('\\', '/'), $slash, $path);
290
- }
291
-
292
- // Detect which kind of slash is being used in a path
293
- public static function detect_slash($path) {
294
- if (strpos($path, '\\')) {
295
- // Windows
296
- return $slash = '\\';
297
- } else {
298
- // UNIX
299
- return $slash = '/';
300
- }
301
- }
302
-
303
- // Returns path using forward slashes
304
- public static function pathf($url) {
305
- return str_replace('\\', '/', trim(strval($url)));
306
- }
307
-
308
- // Returns path using back slashes
309
- public static function pathb($url) {
310
- return str_replace('/', '\\', trim(strval($url)));
311
- }
312
-
313
- // Append either forward slash or backslash based on environment to paths
314
- public static function path_slash($path) {
315
- $path = self::pathf($path);
316
- if (!empty($path) && !preg_match('#\/$#', $path)) {
317
- $path .= '/';
318
- }
319
- return $path;
320
- }
321
-
322
- // Append a forward slash to a path if needed
323
- public static function url_slash($url) {
324
- $url = self::pathf($url);
325
- if (!empty($url) && !preg_match('#\/$#', $url)) {
326
- $url .= '/';
327
- }
328
- return $url;
329
- }
330
-
331
- // Removes extension from file path
332
- public static function path_rem_ext($path) {
333
- $path = self::pathf($path);
334
- return preg_replace('#\.\w+$#m', '', $path);
335
- }
336
-
337
- // Shorten a URL into a string of given length, used to identify a URL uniquely
338
- public static function shorten_url_to_length($url, $length) {
339
- if ($length < 1) {
340
- return '';
341
- }
342
- $url = preg_replace('#(^\w+://)|([/\.])#si', '', $url);
343
- if (strlen($url) > $length) {
344
- $diff = strlen($url) - $length;
345
- $rem = floor(strlen($url)/$diff);
346
- $rem_count = 0;
347
- for ($i = $rem-1; $i < strlen($url) && $rem_count < $diff; $i=$i+$rem) {
348
- $url[$i] = '.';
349
- $rem_count++;
350
- }
351
- $url = preg_replace('#\.#s', '', $url);
352
- }
353
- return $url;
354
- }
355
-
356
- // Creates a unique ID from a string
357
- public static function get_var_str() {
358
- $get_vars = array();
359
- foreach ($_GET as $get=>$val) {
360
- $get_vars[] = $get . '=' . $val;
361
- }
362
- return implode($get_vars, '&');
363
- }
364
-
365
- // Creates a unique ID from a string
366
- public static function str_uid($str) {
367
- $uid = 0;
368
- for ($i = 1; $i < strlen($str); $i++) {
369
- $uid += round(ord($str[$i]) * ($i / strlen($str)), 2) * 100;
370
- }
371
- return strval(dechex(strlen($str))).strval(dechex($uid));
372
- }
373
-
374
- // Breaks up a version string into parts
375
- public static function version_parts($version) {
376
- preg_match('#[\d+\.]+#msi', $version, $match);
377
- if (count($match[0])) {
378
- return split('\.', $match[0]);
379
- } else {
380
- return array();
381
- }
382
- }
383
-
384
- // Compares two version strings lexicographically
385
- public static function version_compare($a, $b) {
386
- $a_parts = self::version_parts($a);
387
- $b_parts = self::version_parts($b);
388
- return self::array_compare_lexi($a_parts, $b_parts);
389
- }
390
-
391
- // Compares two arrays lexicographically
392
- // This could be extended with a compare function argument
393
- public static function array_compare_lexi($a, $b) {
394
- $short = count($a) < count($b) ? $a : $b;
395
- for ($i = 0; $i < count($short); $i++) {
396
- if ($a[$i] > $b[$i]) {
397
- return 1;
398
- } else if ($a[$i] < $b[$i]) {
399
- return -1;
400
- }
401
- }
402
- return 0;
403
- }
404
-
405
- // strpos with an array of $needles
406
- public static function strposa($haystack, $needles, $insensitive = FALSE) {
407
- if (is_array($needles)) {
408
- foreach ($needles as $str) {
409
- if (is_array($str)) {
410
- $pos = self::strposa($haystack, $str, $insensitive);
411
- } else {
412
- $pos = $insensitive ? stripos($haystack, $str) : strpos($haystack, $str);
413
- }
414
- if ($pos !== FALSE) {
415
- return $pos;
416
- }
417
- }
418
- return FALSE;
419
- } else {
420
- return strpos($haystack, $needles);
421
- }
422
- }
423
-
424
- // tests if $needle is equal to any strings in $haystack
425
- public static function str_equal_array($needle, $haystack, $case_insensitive = TRUE) {
426
- if (!is_string($needle) || !is_array($haystack)) {
427
- return FALSE;
428
- }
429
- if ($case_insensitive) {
430
- $needle = strtolower($needle);
431
- }
432
- foreach ($haystack as $hay) {
433
- if (!is_string($hay)) {
434
- continue;
435
- }
436
- if ($case_insensitive) {
437
- $hay = strtolower($hay);
438
- }
439
- if ($needle == $hay) {
440
- return TRUE;
441
- }
442
- }
443
- return FALSE;
444
- }
445
-
446
- // Support for singular and plural string variations
447
- public static function spnum($int, $singular, $plural = NULL) {
448
- if (!is_int($int) || !is_string($singular)) {
449
- $int = intval($int);
450
- $singular = strval($singular);
451
- }
452
- if ($plural == NULL || !is_string($plural)) {
453
- $plural = $singular . 's';
454
- }
455
- return $int . ' ' . (($int == 1) ? $singular : $plural);
456
- }
457
-
458
- // Turn boolean into Yes/No
459
- public static function bool_yn($bool) {
460
- return $bool ? 'Yes' : 'No';
461
- }
462
-
463
- // String to boolean, default decides what boolean value to return when not found
464
- public static function str_to_bool($str, $default = TRUE) {
465
- $str = self::tlower($str);
466
- if ($default === FALSE) {
467
- if ($str == 'true' || $str == 'yes' || $str == '1') {
468
- return TRUE;
469
- } else {
470
- return FALSE;
471
- }
472
- } else {
473
- if ($str == 'false' || $str == 'no' || $str == '0') {
474
- return FALSE;
475
- } else {
476
- return TRUE;
477
- }
478
- }
479
- }
480
-
481
- public static function bool_to_str($bool, $strict = FALSE) {
482
- if ($strict) {
483
- return $bool === TRUE ? 'true' : 'false';
484
- } else {
485
- return $bool ? 'true' : 'false';
486
- }
487
- }
488
-
489
- public static function tlower($str) {
490
- return trim(strtolower($str));
491
- }
492
-
493
- // Escapes $ and \ from the replacement to avoid becoming a backreference
494
- public static function preg_replace_escape_back($pattern, $replacement, $subject, $limit=-1, &$count=0) {
495
- return preg_replace($pattern, self::preg_escape_back($replacement), $subject, $limit, $count);
496
- }
497
-
498
- // Escape backreferences from string for use with regex
499
- public static function preg_escape_back($string) {
500
- // Replace $ with \$ and \ with \\
501
- $string = preg_replace('#(\\$|\\\\)#', '\\\\$1', $string);
502
- return $string;
503
- }
504
-
505
- // Detect if on a Mac or PC
506
- public static function is_mac($default = FALSE) {
507
- $user = $_SERVER['HTTP_USER_AGENT'];
508
- if (stripos($user, 'macintosh') !== FALSE) {
509
- return TRUE;
510
- } else if (stripos($user, 'windows') !== FALSE || stripos($user, 'linux') !== FALSE) {
511
- return FALSE;
512
- } else {
513
- return $default===TRUE;
514
- }
515
- }
516
-
517
- // Decodes WP html entities
518
- public static function html_entity_decode_wp($str) {
519
- if (!is_string($str) || empty($str)) {
520
- return $str;
521
- }
522
- // http://www.ascii.cl/htmlcodes.htm
523
- $wp_entities = array('&#8216;', '&#8217;', '&#8218;', '&#8220;', '&#8221;');
524
- $wp_replace = array('\'', '\'', ',', '"', '"');
525
- $str = str_replace($wp_entities, $wp_replace, $str);
526
- return $str;
527
- }
528
-
529
- // Constructs an html element
530
- // If $content = FALSE, then element is closed
531
- public static function html_element($name, $content = NULL, $attributes = array()) {
532
- $atts = self::html_attributes($attributes);
533
- $tag = "<$name $atts";
534
- $tag .= $content === FALSE ? '/>' : ">$content</$name>";
535
- return $tag;
536
- }
537
-
538
- public static function html_attributes($attributes, $assign = '=', $quote = '"', $glue = ' ') {
539
- $atts = '';
540
- foreach ($attributes as $k=>$v) {
541
- $atts .= $k.$assign.$quote.$v.$quote.$glue;
542
- }
543
- return $atts;
544
- }
545
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
546
  }
 
547
  ?>
2
 
3
  /* Common utility functions mainly for formatting, parsing etc. */
4
  class CrayonUtil {
5
+
6
+ // Used to detect touchscreen devices
7
+ private static $touchscreen = NULL;
8
+
9
+ /* Return the lines inside a file as an array, options:
10
+ l - lowercase
11
+ w - remove whitespace
12
+ r - escape regex chars
13
+ c - remove comments
14
+ s - return as string */
15
+ public static function lines($path, $opts = NULL) {
16
+ $path = self::pathf($path);
17
+ if (($str = self::file($path)) === FALSE) {
18
+ // Log failure, n = no log
19
+ if (strpos($opts, 'n') === FALSE) {
20
+ CrayonLog::syslog("Cannot read lines at '$path'.", "CrayonUtil::lines()");
21
+ }
22
+ return FALSE;
23
+ }
24
+ // Read the options
25
+ if (is_string($opts)) {
26
+ $lowercase = strpos($opts, 'l') !== FALSE;
27
+ $whitespace = strpos($opts, 'w') !== FALSE;
28
+ $escape_regex = strpos($opts, 'r') !== FALSE;
29
+ $clean_commments = strpos($opts, 'c') !== FALSE;
30
+ $return_string = strpos($opts, 's') !== FALSE;
31
  // $escape_hash = strpos($opts, 'h') !== FALSE;
32
+ } else {
33
+ $lowercase = $whitespace = $escape_regex = $clean_commments = $return_string = /*$escape_hash =*/
34
+ FALSE;
35
+ }
36
+ // Remove comments
37
+ if ($clean_commments) {
38
+ $str = self::clean_comments($str);
39
+ }
40
+
41
+ // Convert to lowercase if needed
42
+ if ($lowercase) {
43
+ $str = strtolower($str);
44
+ }
45
+ /* Match all the content on non-empty lines, also remove any whitespace to the left and
46
+ right if needed */
47
+ if ($whitespace) {
48
+ $pattern = '[^\s]+(?:.*[^\s])?';
49
+ } else {
50
+ $pattern = '^(?:.*)?';
51
+ }
52
+
53
+ preg_match_all('|' . $pattern . '|m', $str, $matches);
54
+ $lines = $matches[0];
55
+ // Remove regex syntax and assume all characters are literal
56
+ if ($escape_regex) {
57
+ for ($i = 0; $i < count($lines); $i++) {
58
+ $lines[$i] = self::esc_regex($lines[$i]);
59
  // if ($escape_hash || true) {
60
+ // If we have used \#, then we don't want it to become \\#
61
+ $lines[$i] = preg_replace('|\\\\\\\\#|', '\#', $lines[$i]);
62
  // }
63
+ }
64
+ }
65
+
66
+ // Return as string if needed
67
+ if ($return_string) {
68
+ // Add line breaks if they were stripped
69
+ $delimiter = '';
70
+ if ($whitespace) {
71
+ $delimiter = CRAYON_NL;
72
+ }
73
+ $lines = implode($lines, $delimiter);
74
+ }
75
+
76
+ return $lines;
77
+ }
78
+
79
+ // Returns the contents of a file
80
+ public static function file($path) {
81
+ if (($str = @file_get_contents($path)) === FALSE) {
82
+ return FALSE;
83
+ } else {
84
+ return $str;
85
+ }
86
+ }
87
+
88
+ /**
89
+ * Zips a source file or directory.
90
+ *
91
+ * @param $src A directory or file
92
+ * @param $dest A directory or zip file. If a zip file is provided it must exist beforehand.
93
+ */
94
+ public static function createZip($src, $dest, $removeExistingZip = FALSE) {
95
+ if ($src == $dest) {
96
+ throw new InvalidArgumentException("Source '$src' and '$dest' cannot be the same");
97
+ }
98
+
99
+ if (is_dir($src)) {
100
+ $src = CrayonUtil::path_slash($src);
101
+ $base = $src;
102
+ // Make sure the destination isn't in the files
103
+ $files = self::getFiles($src, array('recursive' => TRUE, 'ignore' => array($dest)));
104
+ } else if (is_file($src)) {
105
+ $files = array($src);
106
+ $base = dirname($src);
107
+ } else {
108
+ throw new InvalidArgumentException("Source '$src' is not a directory or file");
109
+ }
110
+
111
+ if (is_dir($dest)) {
112
+ $dest = CrayonUtil::path_slash($dest);
113
+ $zipFile = $dest . basename($src) . '.zip';
114
+ } else if (is_file($dest)) {
115
+ $zipFile = $dest;
116
+ } else {
117
+ throw new InvalidArgumentException("Destination '$dest' is not a directory or file");
118
+ }
119
+
120
+ if ($removeExistingZip) {
121
+ @unlink($zipFile);
122
+ }
123
+
124
+ $zip = new ZipArchive;
125
+
126
+ if ($zip->open($zipFile, ZIPARCHIVE::CREATE) === TRUE) {
127
+ foreach ($files as $file) {
128
+ $relFile = str_replace($base, '', $file);
129
+ $zip->addFile($file, $relFile);
130
+ }
131
+ $zip->close();
132
+ } else {
133
+ throw new Exception("Could not create zip file at '$zipFile'");
134
+ }
135
+
136
+ return $zipFile;
137
+ }
138
+
139
+ /**
140
+ * Sends an email in html and plain encodings with a file attachment.
141
+ *
142
+ * @param array $args Arguments associative array
143
+ * 'to' (string)
144
+ * 'from' (string)
145
+ * 'subject' (optional string)
146
+ * 'message' (HTML string)
147
+ * 'plain' (optional plain string)
148
+ * 'file' (optional file path of the attachment)
149
+ * @see http://webcheatsheet.com/php/send_email_text_html_attachment.php
150
+ */
151
+ public static function emailFile($args) {
152
+ $to = self::set_default($args['to']);
153
+ $from = self::set_default($args['from']);
154
+ $subject = self::set_default($args['subject'], '');
155
+ $message = self::set_default($args['message'], '');
156
+ $plain = self::set_default($args['plain'], '');
157
+ $file = self::set_default($args['file']);
158
+
159
+ // MIME
160
+ $random_hash = md5(date('r', time()));
161
+ $boundaryMixed = 'PHP-mixed-' . $random_hash;
162
+ $boundaryAlt = 'PHP-alt-' . $random_hash;
163
+ $charset = 'UTF-8';
164
+ $bits = '8bit';
165
+
166
+ // Headers
167
+ $headers = "MIME-Version: 1.0";
168
+ $headers .= "Reply-To: $to\r\n";
169
+ if ($from !== NULL) {
170
+ $headers .= "From: $from\r\n";
171
+ }
172
+ $headers .= "Content-Type: multipart/mixed; boundary=$boundaryMixed";
173
+ if ($file !== NULL) {
174
+ $info = pathinfo($file);
175
+ $filename = $info['filename'];
176
+ $extension = $info['extension'];
177
+ $contents = @file_get_contents($file);
178
+ if ($contents === FALSE) {
179
+ throw new Exception("File contents of '$file' could not be read");
180
+ }
181
+ $chunks = chunk_split(base64_encode($contents));
182
+ $attachment = <<<EOT
183
+ --$boundaryMixed
184
+ Content-Type: application/$extension; name=$filename.$extension
185
+ Content-Transfer-Encoding: base64
186
+ Content-Disposition: attachment
187
+
188
+ $chunks
189
+ EOT;
190
+ } else {
191
+ $attachment = '';
192
+ }
193
+
194
+ $body = <<<EOT
195
+ --$boundaryMixed
196
+ Content-Type: multipart/alternative; boundary=$boundaryAlt
197
+
198
+ --$boundaryAlt
199
+ Content-Type: text/plain; charset="$charset"
200
+ Content-Transfer-Encoding: $bits
201
+
202
+ $plain
203
+
204
+ --$boundaryAlt
205
+ Content-Type: text/html; charset="$charset"
206
+ Content-Transfer-Encoding: $bits
207
+
208
+ $message
209
+ --$boundaryAlt--
210
+
211
+ $attachment
212
+
213
+ --$boundaryMixed--
214
+ EOT;
215
+
216
+ $result = @mail($to, $subject, $body, $headers);
217
+ return $result;
218
+ }
219
+
220
+ /**
221
+ * @param $path A directory
222
+ * @param array $args Argument array:
223
+ * hidden: If true, hidden files beginning with a dot will be included
224
+ * ignoreRef: If true, . and .. are ignored
225
+ * recursive: If true, this function is recursive
226
+ * ignore: An array of paths to ignore
227
+ * @return array Files in the directory
228
+ */
229
+ public static function getFiles($path, $args = array()) {
230
+ $hidden = self::set_default($args['hidden'], TRUE);
231
+ $ignoreRef = self::set_default($args['ignoreRef'], TRUE);
232
+ $recursive = self::set_default($args['recursive'], FALSE);
233
+ $ignore = self::set_default($args['ignore'], NULL);
234
+
235
+ $ignore_map = array();
236
+ if ($ignore) {
237
+ foreach ($ignore as $i) {
238
+ if (is_dir($i)) {
239
+ $i = CrayonUtil::path_slash($i);
240
+ }
241
+ $ignore_map[$i] = TRUE;
242
+ }
243
+ }
244
+
245
+ $files = glob($path . '*', GLOB_MARK);
246
+ if ($hidden) {
247
+ $files = array_merge($files, glob($path . '.*', GLOB_MARK));
248
+ }
249
+ if ($ignoreRef || $ignore) {
250
+ $result = array();
251
+ for ($i = 0; $i < count($files); $i++) {
252
+ $file = $files[$i];
253
+ if (!isset($ignore_map[$file]) && (!$ignoreRef || (basename($file) != '.' && basename($file) != '..'))) {
254
+ $result[] = $file;
255
+ if ($recursive && is_dir($file)) {
256
+ $result = array_merge($result, self::getFiles($file, $args));
257
+ }
258
+ }
259
+ }
260
+ } else {
261
+ $result = $files;
262
+ }
263
+ return $result;
264
+ }
265
+
266
+ public static function deleteDir($path) {
267
+ if (!is_dir($path)) {
268
+ throw new InvalidArgumentException("$path is not a directory");
269
+ }
270
+ if (substr($path, strlen($path) - 1, 1) != '/') {
271
+ $path .= '/';
272
+ }
273
+ $files = self::getFiles($path);
274
+ foreach ($files as $file) {
275
+ if (is_dir($file)) {
276
+ self::deleteDir($file);
277
+ } else {
278
+ unlink($file);
279
+ }
280
+ }
281
+ rmdir($path);
282
+ }
283
+
284
+ public static function copyDir($src, $dst) {
285
+ // http://stackoverflow.com/questions/2050859
286
+ if (!is_dir($src)) {
287
+ throw new InvalidArgumentException("$src is not a directory");
288
+ }
289
+ $dir = opendir($src);
290
+ @mkdir($dst, 0777, TRUE);
291
+ while (false !== ($file = readdir($dir))) {
292
+ if (($file != '.') && ($file != '..')) {
293
+ if (is_dir($src . '/' . $file)) {
294
+ self::copyDir($src . '/' . $file, $dst . '/' . $file);
295
+ } else {
296
+ copy($src . '/' . $file, $dst . '/' . $file);
297
+ }
298
+ }
299
+ }
300
+ closedir($dir);
301
+ }
302
+
303
+ // Supports arrays in the values
304
+ public static function array_flip($array) {
305
+ $result = array();
306
+ foreach ($array as $k => $v) {
307
+ if (is_array($v)) {
308
+ foreach ($v as $u) {
309
+ self::_array_flip($result, $k, $u);
310
+ }
311
+ } else {
312
+ self::_array_flip($result, $k, $v);
313
+ }
314
+ }
315
+ return $result;
316
+ }
317
+
318
+ private static function _array_flip(&$array, $k, $v) {
319
+ if (is_string($v) || is_int($v)) {
320
+ $array[$v] = $k;
321
+ } else {
322
+ trigger_error("Values must be STRING or INTEGER", E_USER_WARNING);
323
+ }
324
+ }
325
+
326
+ // Detects if device is touchscreen or mobile
327
+ public static function is_touch() {
328
+ // Only detect once
329
+ if (self::$touchscreen !== NULL) {
330
+ return self::$touchscreen;
331
+ }
332
+ if (($devices = self::lines(CRAYON_TOUCH_FILE, 'lw')) !== FALSE) {
333
+ // Create array of device strings from file
334
+ $user_agent = strtolower($_SERVER['HTTP_USER_AGENT']);
335
+ self::$touchscreen = (self::strposa($user_agent, $devices) !== FALSE);
336
+ return self::$touchscreen;
337
+ } else {
338
+ CrayonLog::syslog('Error occurred when trying to identify touchscreen devices');
339
+ }
340
+ }
341
+
342
+ // Removes duplicates in array, ensures they are all strings
343
+ public static function array_unique_str($array) {
344
+ if (!is_array($array) || empty($array)) {
345
+ return array();
346
+ }
347
+ for ($i = 0; $i < count($array); $i++) {
348
+ $array[$i] = strval($array[$i]);
349
+ }
350
+ return array_unique($array);
351
+ }
352
+
353
+ // Same as array_key_exists, but returns the key when exists, else FALSE;
354
+ public static function array_key_exists($key, $array) {
355
+ if (!is_array($array) || empty($array) || !is_string($key) || empty($key)) {
356
+ FALSE;
357
+ }
358
+ if (array_key_exists($key, $array)) {
359
+ return $array[$key];
360
+ }
361
+ }
362
+
363
+ // Performs explode() on a string with the given delimiter and trims all whitespace
364
+ public static function trim_e($str, $delimiter = ',') {
365
+ if (is_string($delimiter)) {
366
+ $str = trim(preg_replace('|\s*(?:' . preg_quote($delimiter) . ')\s*|', $delimiter, $str));
367
+ return explode($delimiter, $str);
368
+ }
369
+ return $str;
370
+ }
371
+
372
+ /* Creates an array of integers based on a given range string of format "int - int"
373
+ Eg. range_str('2 - 5'); */
374
+ public static function range_str($str) {
375
+ preg_match('#(\d+)\s*-\s*(\d+)#', $str, $matches);
376
+ if (count($matches) == 3) {
377
+ return range($matches[1], $matches[2]);
378
+ }
379
+ return FALSE;
380
+ }
381
+
382
+ // Creates an array out of a single range string (e.i "x-y")
383
+ public static function range_str_single($str) {
384
+ $match = preg_match('#(\d+)(?:\s*-\s*(\d+))?#', $str, $matches);
385
+ if ($match > 0) {
386
+ if (empty($matches[2])) {
387
+ $matches[2] = $matches[1];
388
+ }
389
+ if ($matches[1] <= $matches[2]) {
390
+ return array($matches[1], $matches[2]);
391
+ }
392
+ }
393
+ return FALSE;
394
+ }
395
+
396
+ // Sets a variable to a string if valid
397
+ public static function str(&$var, $str, $escape = TRUE) {
398
+ if (is_string($str)) {
399
+ $var = ($escape == TRUE ? self::htmlentities($str) : $str);
400
+ return TRUE;
401
+ }
402
+ return FALSE;
403
+ }
404
+
405
+ // Converts all special characters to entities
406
+ public static function htmlentities($str) {
407
+ return htmlentities($str, ENT_COMPAT, 'UTF-8');
408
+ }
409
+
410
+ public static function html_entity_decode($str) {
411
+ return html_entity_decode($str, ENT_NOQUOTES, 'UTF-8');
412
+ }
413
+
414
+ // Converts <, >, & into entities
415
+ public static function htmlspecialchars($str) {
416
+ return htmlspecialchars($str, ENT_NOQUOTES, 'UTF-8');
417
+ }
418
+
419
+ // Sets a variable to an int if valid
420
+ public static function num(&$var, $num) {
421
+ if (is_numeric($num)) {
422
+ $var = intval($num);
423
+ return TRUE;
424
+ }
425
+ return FALSE;
426
+ }
427
+
428
+ // Sets a variable to an array if valid
429
+ public static function arr(&$var, $array) {
430
+ if (is_array($array)) {
431
+ $var = $array;
432
+ return TRUE;
433
+ }
434
+ return FALSE;
435
+ }
436
+
437
+ // Sets a variable to an array if valid
438
+ public static function set_array($var, $array, $false = FALSE) {
439
+ return isset($array[$var]) ? $array[$var] : $false;
440
+ }
441
+
442
+ // Sets a variable to null if not set
443
+ public static function set_var(&$var, $false = NULL) {
444
+ $var = isset($var) ? $var : $false;
445
+ }
446
+
447
+ // Sets a variable to null if not set
448
+ public static function set_default(&$var, $default = NULL) {
449
+ return isset($var) ? $var : $default;
450
+ }
451
+
452
+ public static function set_default_null($var, $default = NULL) {
453
+ return $var !== NULL ? $var : $default;
454
+ }
455
+
456
+ // Thanks, http://www.php.net/manual/en/function.str-replace.php#102186
457
+ function str_replace_once($str_pattern, $str_replacement, $string) {
458
+ if (strpos($string, $str_pattern) !== FALSE) {
459
+ $occurrence = strpos($string, $str_pattern);
460
+ return substr_replace($string, $str_replacement, strpos($string, $str_pattern), strlen($str_pattern));
461
+ }
462
+ return $string;
463
+ }
464
+
465
+ // Removes non-numeric chars in string
466
+ public static function clean_int($str, $return_zero = TRUE) {
467
+ $str = preg_replace('#[^\d]#', '', $str);
468
+ if ($return_zero) {
469
+ // If '', then returns 0
470
+ return strval(intval($str));
471
+ } else {
472
+ // Might be ''
473
+ return $str;
474
+ }
475
+ }
476
+
477
+ // Replaces whitespace with hypthens
478
+ public static function space_to_hyphen($str) {
479
+ return preg_replace('#\s+#', '-', $str);
480
+ }
481
+
482
+ // Replaces hypthens with spaces
483
+ public static function hyphen_to_space($str) {
484
+ return preg_replace('#-#', ' ', $str);
485
+ }
486
+
487
+ // Remove comments with /* */, // or #, if they occur before any other char on a line
488
+ public static function clean_comments($str) {
489
+ $comment_pattern = '#(?:^\s*/\*.*?^\s*\*/)|(?:^(?!\s*$)[\s]*(?://|\#)[^\r\n]*)#ms';
490
+ $str = preg_replace($comment_pattern, '', $str);
491
+ return $str;
492
+ }
493
+
494
+ // Convert to title case and replace underscores with spaces
495
+ public static function ucwords($str) {
496
+ $str = strval($str);
497
+ $str = str_replace('_', ' ', $str);
498
+ return ucwords($str);
499
+ }
500
+
501
+ // Escapes regex characters as literals
502
+ public static function esc_regex($regex) {
503
+ return /*htmlspecialchars(*/
504
+ preg_quote($regex) /* , ENT_NOQUOTES)*/
505
+ ;
506
+ }
507
+
508
+ // Escapes hash character as literals
509
+ public static function esc_hash($regex) {
510
+ if (is_string($regex)) {
511
+ return preg_replace('|(?<!\\\\)#|', '\#', $regex);
512
+ } else {
513
+ return FALSE;
514
+ }
515
+ }
516
+
517
+ // Ensure all parenthesis are atomic to avoid conflicting with element matches
518
+ public static function esc_atomic($regex) {
519
+ return preg_replace('#(?<!\\\\)\((?!\?)#', '(?:', $regex);
520
+ }
521
+
522
+ // Returns the current HTTP URL
523
+ public static function current_url() {
524
+ return "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
525
+ }
526
+
527
+ // Removes crayon plugin path from absolute path
528
+ public static function path_rel($url) {
529
+ if (is_string($url)) {
530
+ return str_replace(CRAYON_ROOT_PATH, '/', $url);
531
+ }
532
+ return $url;
533
+ }
534
+
535
+ // Returns path according to detected use of forwardslash/backslash
536
+ // Depreciated from regular use after v.1.1.1
537
+ public static function path($path, $detect) {
538
+ $slash = self::detect_slash($detect);
539
+ return str_replace(array('\\', '/'), $slash, $path);
540
+ }
541
+
542
+ // Detect which kind of slash is being used in a path
543
+ public static function detect_slash($path) {
544
+ if (strpos($path, '\\')) {
545
+ // Windows
546
+ return $slash = '\\';
547
+ } else {
548
+ // UNIX
549
+ return $slash = '/';
550
+ }
551
+ }
552
+
553
+ // Returns path using forward slashes
554
+ public static function pathf($url) {
555
+ return str_replace('\\', '/', trim(strval($url)));
556
+ }
557
+
558
+ // Returns path using back slashes
559
+ public static function pathb($url) {
560
+ return str_replace('/', '\\', trim(strval($url)));
561
+ }
562
+
563
+ // Append either forward slash or backslash based on environment to paths
564
+ public static function path_slash($path) {
565
+ $path = self::pathf($path);
566
+ if (!empty($path) && !preg_match('#\/$#', $path)) {
567
+ $path .= '/';
568
+ }
569
+ return $path;
570
+ }
571
+
572
+ public static function path_slash_remove($path) {
573
+ return preg_replace('#\/+$#', '', $path);
574
+ }
575
+
576
+ // Append a forward slash to a path if needed
577
+ public static function url_slash($url) {
578
+ $url = self::pathf($url);
579
+ if (!empty($url) && !preg_match('#\/$#', $url)) {
580
+ $url .= '/';
581
+ }
582
+ return $url;
583
+ }
584
+
585
+ // Removes extension from file path
586
+ public static function path_rem_ext($path) {
587
+ $path = self::pathf($path);
588
+ return preg_replace('#\.\w+$#m', '', $path);
589
+ }
590
+
591
+ // Shorten a URL into a string of given length, used to identify a URL uniquely
592
+ public static function shorten_url_to_length($url, $length) {
593
+ if ($length < 1) {
594
+ return '';
595
+ }
596
+ $url = preg_replace('#(^\w+://)|([/\.])#si', '', $url);
597
+ if (strlen($url) > $length) {
598
+ $diff = strlen($url) - $length;
599
+ $rem = floor(strlen($url) / $diff);
600
+ $rem_count = 0;
601
+ for ($i = $rem - 1; $i < strlen($url) && $rem_count < $diff; $i = $i + $rem) {
602
+ $url[$i] = '.';
603
+ $rem_count++;
604
+ }
605
+ $url = preg_replace('#\.#s', '', $url);
606
+ }
607
+ return $url;
608
+ }
609
+
610
+ // Creates a unique ID from a string
611
+ public static function get_var_str() {
612
+ $get_vars = array();
613
+ foreach ($_GET as $get => $val) {
614
+ $get_vars[] = $get . '=' . $val;
615
+ }
616
+ return implode($get_vars, '&');
617
+ }
618
+
619
+ // Creates a unique ID from a string
620
+ public static function str_uid($str) {
621
+ $uid = 0;
622
+ for ($i = 1; $i < strlen($str); $i++) {
623
+ $uid += round(ord($str[$i]) * ($i / strlen($str)), 2) * 100;
624
+ }
625
+ return strval(dechex(strlen($str))) . strval(dechex($uid));
626
+ }
627
+
628
+ // Breaks up a version string into parts
629
+ public static function version_parts($version) {
630
+ preg_match('#[\d+\.]+#msi', $version, $match);
631
+ if (count($match[0])) {
632
+ return split('\.', $match[0]);
633
+ } else {
634
+ return array();
635
+ }
636
+ }
637
+
638
+ // Compares two version strings lexicographically
639
+ public static function version_compare($a, $b) {
640
+ $a_parts = self::version_parts($a);
641
+ $b_parts = self::version_parts($b);
642
+ return self::array_compare_lexi($a_parts, $b_parts);
643
+ }
644
+
645
+ // Compares two arrays lexicographically
646
+ // This could be extended with a compare function argument
647
+ public static function array_compare_lexi($a, $b) {
648
+ $short = count($a) < count($b) ? $a : $b;
649
+ for ($i = 0; $i < count($short); $i++) {
650
+ if ($a[$i] > $b[$i]) {
651
+ return 1;
652
+ } else if ($a[$i] < $b[$i]) {
653
+ return -1;
654
+ }
655
+ }
656
+ return 0;
657
+ }
658
+
659
+ // strpos with an array of $needles
660
+ public static function strposa($haystack, $needles, $insensitive = FALSE) {
661
+ if (is_array($needles)) {
662
+ foreach ($needles as $str) {
663
+ if (is_array($str)) {
664
+ $pos = self::strposa($haystack, $str, $insensitive);
665
+ } else {
666
+ $pos = $insensitive ? stripos($haystack, $str) : strpos($haystack, $str);
667
+ }
668
+ if ($pos !== FALSE) {
669
+ return $pos;
670
+ }
671
+ }
672
+ return FALSE;
673
+ } else {
674
+ return strpos($haystack, $needles);
675
+ }
676
+ }
677
+
678
+ // tests if $needle is equal to any strings in $haystack
679
+ public static function str_equal_array($needle, $haystack, $case_insensitive = TRUE) {
680
+ if (!is_string($needle) || !is_array($haystack)) {
681
+ return FALSE;
682
+ }
683
+ if ($case_insensitive) {
684
+ $needle = strtolower($needle);
685
+ }
686
+ foreach ($haystack as $hay) {
687
+ if (!is_string($hay)) {
688
+ continue;
689
+ }
690
+ if ($case_insensitive) {
691
+ $hay = strtolower($hay);
692
+ }
693
+ if ($needle == $hay) {
694
+ return TRUE;
695
+ }
696
+ }
697
+ return FALSE;
698
+ }
699
+
700
+ // Support for singular and plural string variations
701
+ public static function spnum($int, $singular, $plural = NULL) {
702
+ if (!is_int($int) || !is_string($singular)) {
703
+ $int = intval($int);
704
+ $singular = strval($singular);
705
+ }
706
+ if ($plural == NULL || !is_string($plural)) {
707
+ $plural = $singular . 's';
708
+ }
709
+ return $int . ' ' . (($int == 1) ? $singular : $plural);
710
+ }
711
+
712
+ // Turn boolean into Yes/No
713
+ public static function bool_yn($bool) {
714
+ return $bool ? 'Yes' : 'No';
715
+ }
716
+
717
+ // String to boolean, default decides what boolean value to return when not found
718
+ public static function str_to_bool($str, $default = TRUE) {
719
+ $str = self::tlower($str);
720
+ if ($default === FALSE) {
721
+ if ($str == 'true' || $str == 'yes' || $str == '1') {
722
+ return TRUE;
723
+ } else {
724
+ return FALSE;
725
+ }
726
+ } else {
727
+ if ($str == 'false' || $str == 'no' || $str == '0') {
728
+ return FALSE;
729
+ } else {
730
+ return TRUE;
731
+ }
732
+ }
733
+ }
734
+
735
+ public static function bool_to_str($bool, $strict = FALSE) {
736
+ if ($strict) {
737
+ return $bool === TRUE ? 'true' : 'false';
738
+ } else {
739
+ return $bool ? 'true' : 'false';
740
+ }
741
+ }
742
+
743
+ public static function tlower($str) {
744
+ return trim(strtolower($str));
745
+ }
746
+
747
+ // Escapes $ and \ from the replacement to avoid becoming a backreference
748
+ public static function preg_replace_escape_back($pattern, $replacement, $subject, $limit = -1, &$count = 0) {
749
+ return preg_replace($pattern, self::preg_escape_back($replacement), $subject, $limit, $count);
750
+ }
751
+
752
+ // Escape backreferences from string for use with regex
753
+ public static function preg_escape_back($string) {
754
+ // Replace $ with \$ and \ with \\
755
+ $string = preg_replace('#(\\$|\\\\)#', '\\\\$1', $string);
756
+ return $string;
757
+ }
758
+
759
+ // Detect if on a Mac or PC
760
+ public static function is_mac($default = FALSE) {
761
+ $user = $_SERVER['HTTP_USER_AGENT'];
762
+ if (stripos($user, 'macintosh') !== FALSE) {
763
+ return TRUE;
764
+ } else if (stripos($user, 'windows') !== FALSE || stripos($user, 'linux') !== FALSE) {
765
+ return FALSE;
766
+ } else {
767
+ return $default === TRUE;
768
+ }
769
+ }
770
+
771
+ // Decodes WP html entities
772
+ public static function html_entity_decode_wp($str) {
773
+ if (!is_string($str) || empty($str)) {
774
+ return $str;
775
+ }
776
+ // http://www.ascii.cl/htmlcodes.htm
777
+ $wp_entities = array('&#8216;', '&#8217;', '&#8218;', '&#8220;', '&#8221;');
778
+ $wp_replace = array('\'', '\'', ',', '"', '"');
779
+ $str = str_replace($wp_entities, $wp_replace, $str);
780
+ return $str;
781
+ }
782
+
783
+ // Constructs an html element
784
+ // If $content = FALSE, then element is closed
785
+ public static function html_element($name, $content = NULL, $attributes = array()) {
786
+ $atts = self::html_attributes($attributes);
787
+ $tag = "<$name $atts";
788
+ $tag .= $content === FALSE ? '/>' : ">$content</$name>";
789
+ return $tag;
790
+ }
791
+
792
+ public static function html_attributes($attributes, $assign = '=', $quote = '"', $glue = ' ') {
793
+ $atts = '';
794
+ foreach ($attributes as $k => $v) {
795
+ $atts .= $k . $assign . $quote . $v . $quote . $glue;
796
+ }
797
+ return $atts;
798
+ }
799
+
800
  }
801
+
802
  ?>
util/{exceptions.php → depreciated/exceptions.php} RENAMED
File without changes
util/external_use.php CHANGED
@@ -1,10 +1,10 @@
1
- <?php
2
-
3
  require_once ('../global.php');
4
  require_once (CRAYON_HIGHLIGHTER_PHP);
5
 
6
  // These will depend on your framework
7
- CrayonGlobalSettings::site_http('http://localhost/crayon/wp-content/plugins/crayon-syntax-highlighter/');
8
  CrayonGlobalSettings::site_path(dirname(__FILE__));
9
  CrayonGlobalSettings::plugin_path('http://localhost/crayon/wp-content/plugins/crayon-syntax-highlighter/');
10
 
@@ -53,5 +53,5 @@ function crayon_resources() {
53
  crayon_print_script('crayon-js', $plugin_url.CRAYON_JS, $CRAYON_VERSION);
54
  crayon_print_script('crayon-jquery-popup', $plugin_url.CRAYON_JQUERY_POPUP, $CRAYON_VERSION);
55
  }
56
-
57
  ?>
1
+ <?php
2
+
3
  require_once ('../global.php');
4
  require_once (CRAYON_HIGHLIGHTER_PHP);
5
 
6
  // These will depend on your framework
7
+ CrayonGlobalSettings::site_url('http://localhost/crayon/wp-content/plugins/crayon-syntax-highlighter/');
8
  CrayonGlobalSettings::site_path(dirname(__FILE__));
9
  CrayonGlobalSettings::plugin_path('http://localhost/crayon/wp-content/plugins/crayon-syntax-highlighter/');
10
 
53
  crayon_print_script('crayon-js', $plugin_url.CRAYON_JS, $CRAYON_VERSION);
54
  crayon_print_script('crayon-jquery-popup', $plugin_url.CRAYON_JQUERY_POPUP, $CRAYON_VERSION);
55
  }
56
+
57
  ?>
util/list_langs.php DELETED
@@ -1,28 +0,0 @@
1
- <?php
2
-
3
- // Depreciated since 1.14
4
-
5
- require_once (dirname(dirname(__FILE__)) . '/global.php');
6
- require_once (CRAYON_PARSER_PHP);
7
- if (($langs = CrayonParser::parse_all()) != FALSE) {
8
- echo '<table class="crayon-table" cellspacing="0" cellpadding="0"><tr class="crayon-table-header">',
9
- '<td>ID</td><td>Name</td><td>Version</td><td>File Extensions</td><td>Aliases</td><td>State</td></tr>';
10
- $keys = array_values($langs);
11
- for ($i = 0; $i < count($langs); $i++) {
12
- $lang = $keys[$i];
13
- $tr = ($i == count($langs) - 1) ? 'crayon-table-last' : '';
14
- echo '<tr class="', $tr, '">',
15
- '<td>', $lang->id(), '</td>',
16
- '<td>', $lang->name(), '</td>',
17
- '<td>', $lang->version(), '</td>',
18
- '<td>', implode(', ', $lang->ext()), '</td>',
19
- '<td>', implode(', ', $lang->alias()), '</td>',
20
- '<td class="', strtolower(CrayonUtil::space_to_hyphen($lang->state_info())), '">',
21
- $lang->state_info(), '</td>',
22
- '</tr>';
23
- }
24
- echo '</table><br/>Languages that have the same extension as their name don\'t need to explicitly map extensions.';
25
- } else {
26
- echo 'No languages could be found.';
27
- }
28
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
util/list_posts.php DELETED
@@ -1,27 +0,0 @@
1
- <?php
2
-
3
- // Depreciated since 1.14
4
-
5
- require_once('../crayon_wp.class.php');
6
-
7
- $posts = CrayonSettingsWP::load_posts();
8
- arsort($posts);
9
-
10
- echo '<table class="crayon-table" cellspacing="0" cellpadding="0"><tr class="crayon-table-header">',
11
- '<td>ID</td><td>Title</td><td>Posted</td><td>Modified</td></tr>';
12
-
13
- for ($i = 0; $i < count($posts); $i++) {
14
- $postID = $posts[$i];
15
- $post = get_post($postID);
16
- $tr = ($i == count($posts) - 1) ? 'crayon-table-last' : '';
17
- echo '<tr class="', $tr, '">',
18
- '<td>', $postID, '</td>',
19
- '<td><a href="', $post->guid ,'" target="_blank">', $post->post_title, '</a></td>',
20
- '<td>', $post->post_date, '</td>',
21
- '<td>', $post->post_modified, '</td>',
22
- '</tr>';
23
- }
24
-
25
- echo '</table>';
26
-
27
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
util/preview.php DELETED
@@ -1,68 +0,0 @@
1
- <?php
2
-
3
- // Depreciated since 1.14
4
-
5
- require_once('../crayon_wp.class.php');
6
-
7
- echo '<link rel="stylesheet" href="', plugins_url(CRAYON_STYLE, dirname(__FILE__)),
8
- '?ver=', $CRAYON_VERSION, '" type="text/css" media="all" />';
9
- echo '<div id="content">';
10
-
11
- CrayonSettingsWP::load_settings(); // Run first to ensure global settings loaded
12
-
13
- $crayon = CrayonWP::instance();
14
-
15
- // Settings to prevent from validating
16
- $preview_settings = array();
17
-
18
- // Load settings from GET and validate
19
- foreach ($_GET as $key => $value) {
20
- // echo $key, ' ', $value , '<br/>';
21
- if (!in_array($key, $preview_settings)) {
22
- $_GET[$key] = CrayonSettings::validate($key, $value);
23
- }
24
- }
25
- $crayon->settings($_GET);
26
- if (!isset($crayon_preview_dont_override_get) || !$crayon_preview_dont_override_get) {
27
- $settings = array(CrayonSettings::TOP_SET => TRUE, CrayonSettings::TOP_MARGIN => 10,
28
- CrayonSettings::BOTTOM_SET => FALSE, CrayonSettings::BOTTOM_MARGIN => 0);
29
- $crayon->settings($settings);
30
- }
31
-
32
- // Print the theme CSS
33
- $theme_id = $crayon->setting_val(CrayonSettings::THEME);
34
- if ($theme_id != NULL) {
35
- echo CrayonResources::themes()->get_css($theme_id);
36
- }
37
-
38
- $font_id = $crayon->setting_val(CrayonSettings::FONT);
39
- if ($font_id != NULL /*&& $font_id != CrayonFonts::DEFAULT_FONT*/) {
40
- echo CrayonResources::fonts()->get_css($font_id);
41
- }
42
-
43
- // Load custom code based on language
44
- $lang = $crayon->setting_val(CrayonSettings::FALLBACK_LANG);
45
- $path = crayon_pf( dirname(__FILE__) . '/sample/' . $lang . '.txt', FALSE );
46
-
47
- if ($lang && @file_exists($path)) {
48
- $crayon->url($path);
49
- } else {
50
- $code = "
51
- // A sample class
52
- class Human {
53
- private int age = 0;
54
- public void birthday() {
55
- age++;
56
- print('Happy Birthday!');
57
- }
58
- }
59
- ";
60
- $crayon->code($code);
61
- }
62
- $crayon->title('Sample Code');
63
- $crayon->marked('5-7');
64
- $crayon->output($highlight = true, $nums = true, $print = true);
65
- echo '</div>';
66
- crayon_load_plugin_textdomain();
67
-
68
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
util/sample/vim.txt ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "Toggle word checking on or off...
2
+ function! WordCheck ()
3
+ "Toggle the flag (or set it if it doesn't yet exist)...
4
+ let w:check_words = exists('w:check_words') ? !w:check_words : 1
5
+
6
+ "Turn match mechanism on/off, according to new state of flag...
7
+ if w:check_words
8
+ exec s:words_matcher
9
+ else
10
+ match none
11
+ endif
12
+ endfunction
util/scraper/readme.txt ADDED
@@ -0,0 +1 @@
 
1
+ I created this to help scrape keywords out of text files. Mostly I use it to scrape GeSHi language files and remove the bits I need.
util/tag-editor/crayon_tag_editor_wp.class.php CHANGED
@@ -73,6 +73,9 @@ class CrayonTagEditorWP {
73
  }
74
 
75
  public static function init_tinymce($init) {
 
 
 
76
  $init['extended_valid_elements'] .= ',pre[*],code[*],iframe[*]';
77
  return $init;
78
  }
@@ -87,8 +90,9 @@ class CrayonTagEditorWP {
87
  public static function enqueue_resources() {
88
  global $CRAYON_VERSION;
89
  self::init_settings();
90
- wp_enqueue_style('crayon_fancybox', plugins_url(CRAYON_CSS_FANCYBOX, dirname(dirname(__FILE__))), array(), $CRAYON_VERSION);
91
- wp_enqueue_script('crayon_fancybox', plugins_url(CRAYON_JS_FANCYBOX, dirname(dirname(__FILE__))), array('jquery'), $CRAYON_VERSION);
 
92
  wp_enqueue_script('crayon_te_js', plugins_url(CRAYON_TE_JS, __FILE__), array('crayon_fancybox', 'crayon_util_js'), $CRAYON_VERSION);
93
  wp_enqueue_script('crayon_qt_js', plugins_url(CRAYON_QUICKTAGS_JS, __FILE__), array('quicktags', 'crayon_te_js'), $CRAYON_VERSION, TRUE);
94
  wp_localize_script('crayon_te_js', 'CrayonTagEditorSettings', self::$settings);
@@ -264,6 +268,7 @@ class CrayonTagEditorWP {
264
  </div>
265
 
266
  <?php
 
267
  }
268
 
269
  }
@@ -272,4 +277,4 @@ if (defined('ABSPATH')) {
272
  add_action('init', 'CrayonTagEditorWP::init');
273
  }
274
 
275
- ?>
73
  }
74
 
75
  public static function init_tinymce($init) {
76
+ if (!array_key_exists('extended_valid_elements', $init)) {
77
+ $init['extended_valid_elements'] = '';
78
+ }
79
  $init['extended_valid_elements'] .= ',pre[*],code[*],iframe[*]';
80
  return $init;
81
  }
90
  public static function enqueue_resources() {
91
  global $CRAYON_VERSION;
92
  self::init_settings();
93
+ $path = dirname(dirname(__FILE__));
94
+ wp_enqueue_style('crayon_fancybox', plugins_url(CRAYON_CSS_FANCYBOX, $path), array(), $CRAYON_VERSION);
95
+ wp_enqueue_script('crayon_fancybox', plugins_url(CRAYON_JS_FANCYBOX, $path), array('jquery'), $CRAYON_VERSION);
96
  wp_enqueue_script('crayon_te_js', plugins_url(CRAYON_TE_JS, __FILE__), array('crayon_fancybox', 'crayon_util_js'), $CRAYON_VERSION);
97
  wp_enqueue_script('crayon_qt_js', plugins_url(CRAYON_QUICKTAGS_JS, __FILE__), array('quicktags', 'crayon_te_js'), $CRAYON_VERSION, TRUE);
98
  wp_localize_script('crayon_te_js', 'CrayonTagEditorSettings', self::$settings);
268
  </div>
269
 
270
  <?php
271
+ exit();
272
  }
273
 
274
  }
277
  add_action('init', 'CrayonTagEditorWP::init');
278
  }
279
 
280
+ ?>
util/tag-editor/crayon_te.js CHANGED
@@ -81,7 +81,7 @@
81
  }
82
 
83
  // Load the editor content
84
- $.get(gs.ajaxurl, {action : 'crayon-tag-editor', is_admin : gs.is_admin}, function(data) {
85
  dialog = $('<div id="'+s.css+'"></div>');
86
  dialog.appendTo('body').hide();
87
  dialog.html(data);
@@ -122,7 +122,7 @@
122
  }
123
 
124
  // Check for extensions and select language automatically
125
- var ext = CrayonSyntaxUtil.getExt(url.val());
126
  if (ext) {
127
  var lang = exts[ext];
128
  // Otherwise use the extention as the lang
@@ -147,13 +147,13 @@
147
  }
148
  // Depends on type
149
  var value = base.settingValue(setting);
150
- console_log(setting.attr('id') + ' value: ' + value);
151
  var highlight = null;
152
  if (setting.is('input[type=checkbox]')) {
153
  highlight = setting.next('span');
154
  }
155
 
156
- console_log(' >>> ' + setting.attr('id') + ' is ' + orig_value + ' = ' + value);
157
  if (orig_value == value) {
158
  // No change
159
  setting.removeClass(gs.changed);
@@ -281,7 +281,7 @@
281
  highlight.addClass(gs.changed);
282
  }
283
  }
284
- console_log('loaded: ' + att + ':' + value);
285
  }
286
 
287
  editing = true;
@@ -290,14 +290,14 @@
290
  // Code
291
  var content = currCrayon.html();
292
  if (inputHTML == 'encode') {
293
- content = crayon_encode_html(content);
294
  } else if (inputHTML == 'decode') {
295
- content = crayon_decode_html(content);
296
  }
297
  code.val(content);
298
 
299
  } else {
300
- console_log('cannot load currNode of type pre');
301
  }
302
  } else {
303
  if (selectCallback) {
@@ -469,7 +469,7 @@
469
  for (var id in atts) {
470
  // Remove prefix, if exists
471
  var value = atts[id];
472
- console_log('add '+id+':'+value);
473
  shortcode += id + s.attr_sep + value + ' ';
474
  }
475
 
@@ -493,9 +493,9 @@
493
 
494
  var content = $(s.code_css).val();
495
  if (outputHTML == 'encode') {
496
- content = crayon_encode_html(content);
497
  } else if (outputHTML == 'decode') {
498
- content = crayon_decode_html(content);
499
  }
500
  content = typeof content != 'undefined' ? content : '';
501
  shortcode += '>' + content + '</' + tag + '>' + br_after;
@@ -512,14 +512,14 @@
512
  };
513
 
514
  base.submitButton = function() {
515
- console_log('submit');
516
  if (base.addCrayon() != false) {
517
  base.hideDialog();
518
  }
519
  };
520
 
521
  base.hideDialog = function() {
522
- console_log('hide');
523
  if (hideCallback) {
524
  hideCallback();
525
  }
@@ -535,7 +535,7 @@
535
  };
536
 
537
  base.resetSettings = function() {
538
- console_log('reset');
539
  $('.'+gs.setting).each(function() {
540
  var setting = $(this);
541
  base.settingValue(setting, setting.attr(gs.orig_value));
81
  }
82
 
83
  // Load the editor content
84
+ CrayonUtil.getAJAX({action : 'crayon-tag-editor', is_admin : gs.is_admin}, function(data) {
85
  dialog = $('<div id="'+s.css+'"></div>');
86
  dialog.appendTo('body').hide();
87
  dialog.html(data);
122
  }
123
 
124
  // Check for extensions and select language automatically
125
+ var ext = CrayonUtil.getExt(url.val());
126
  if (ext) {
127
  var lang = exts[ext];
128
  // Otherwise use the extention as the lang
147
  }
148
  // Depends on type
149
  var value = base.settingValue(setting);
150
+ CrayonUtil.log(setting.attr('id') + ' value: ' + value);
151
  var highlight = null;
152
  if (setting.is('input[type=checkbox]')) {
153
  highlight = setting.next('span');
154
  }
155
 
156
+ CrayonUtil.log(' >>> ' + setting.attr('id') + ' is ' + orig_value + ' = ' + value);
157
  if (orig_value == value) {
158
  // No change
159
  setting.removeClass(gs.changed);
281
  highlight.addClass(gs.changed);
282
  }
283
  }
284
+ CrayonUtil.log('loaded: ' + att + ':' + value);
285
  }
286
 
287
  editing = true;
290
  // Code
291
  var content = currCrayon.html();
292
  if (inputHTML == 'encode') {
293
+ content = CrayonUtil.encode_html(content);
294
  } else if (inputHTML == 'decode') {
295
+ content = CrayonUtil.decode_html(content);
296
  }
297
  code.val(content);
298
 
299
  } else {
300
+ CrayonUtil.log('cannot load currNode of type pre');
301
  }
302
  } else {
303
  if (selectCallback) {
469
  for (var id in atts) {
470
  // Remove prefix, if exists
471
  var value = atts[id];
472
+ CrayonUtil.log('add '+id+':'+value);
473
  shortcode += id + s.attr_sep + value + ' ';
474
  }
475
 
493
 
494
  var content = $(s.code_css).val();
495
  if (outputHTML == 'encode') {
496
+ content = CrayonUtil.encode_html(content);
497
  } else if (outputHTML == 'decode') {
498
+ content = CrayonUtil.decode_html(content);
499
  }
500
  content = typeof content != 'undefined' ? content : '';
501
  shortcode += '>' + content + '</' + tag + '>' + br_after;
512
  };
513
 
514
  base.submitButton = function() {
515
+ CrayonUtil.log('submit');
516
  if (base.addCrayon() != false) {
517
  base.hideDialog();
518
  }
519
  };
520
 
521
  base.hideDialog = function() {
522
+ CrayonUtil.log('hide');
523
  if (hideCallback) {
524
  hideCallback();
525
  }
535
  };
536
 
537
  base.resetSettings = function() {
538
+ CrayonUtil.log('reset');
539
  $('.'+gs.setting).each(function() {
540
  var setting = $(this);
541
  base.settingValue(setting, setting.attr(gs.orig_value));
util/theme-editor/images/button-pressed.png ADDED
Binary file
util/theme-editor/images/button.png ADDED
Binary file
util/theme-editor/images/frame.png ADDED
Binary file
util/theme-editor/images/highlighting.png ADDED
Binary file
util/theme-editor/images/information.png ADDED
Binary file
util/theme-editor/images/lines.png ADDED
Binary file
util/theme-editor/images/numbers.png ADDED
Binary file
util/theme-editor/images/title.png ADDED
Binary file
util/theme-editor/images/toolbar.png ADDED
Binary file
util/theme-editor/theme_editor.css CHANGED
@@ -1,11 +1,286 @@
1
  #crayon-theme-editor-button {
2
- margin-left: 10px;
3
  }
4
 
5
  #crayon-editor-controls {
6
-
 
 
 
 
 
7
  }
8
 
9
  #crayon-editor-control-wrapper {
10
-
11
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  #crayon-theme-editor-button {
2
+ margin-left: 10px;
3
  }
4
 
5
  #crayon-editor-controls {
6
+
7
+ }
8
+
9
+ #crayon-editor-preview .crayon-syntax {
10
+ margin: 0 !important;
11
+ padding: 0 !important;
12
  }
13
 
14
  #crayon-editor-control-wrapper {
15
+ padding-left: 20px;
16
+ }
17
+
18
+ #crayon-editor-control-wrapper,
19
+ #crayon-editor-controls {
20
+ width: 422px;
21
+ overflow: hidden;
22
+ }
23
+
24
+ #crayon-editor-save {
25
+ margin: 0 5px;
26
+ }
27
+
28
+ #crayon-editor-controls label {
29
+ margin-right: 10px;
30
+ width: 70px;
31
+ float: left;
32
+ }
33
+
34
+ #crayon-editor-controls .crayon-theme-editor-form .separator .content {
35
+ font-weight: bold;
36
+ color: #999;
37
+ padding-top: 8px;
38
+ border-bottom: 1px solid #ccc;
39
+ text-shadow: 0 1px 0px #fff;
40
+ text-align: center;
41
+ padding-bottom: 2px;
42
+ margin-bottom: 5px;
43
+ }
44
+
45
+ #crayon-editor-controls .crayon-theme-editor-form .separator.first .content {
46
+ padding-top: 0;
47
+ }
48
+
49
+ #crayon-editor-controls .crayon-theme-editor-form .separator.title .content {
50
+ line-height: 24px;
51
+ height: 22px;
52
+ padding-top: 0;
53
+ background: #dedede url(images/title.png) center bottom repeat-x;
54
+ border-color: #999;
55
+ }
56
+
57
+ #crayon-editor-controls .crayon-theme-editor-form .separator.title .content {
58
+ color: #333;
59
+ text-shadow: 0 1px 2px #eee;
60
+ }
61
+
62
+ #crayon-editor-controls .crayon-theme-editor-form .separator.title td {
63
+ color: #333;
64
+ padding: 0;
65
+ }
66
+
67
+ #crayon-editor-controls .crayon-theme-editor-form .field {
68
+ border: 0px;
69
+ padding-right: 5px;
70
+ vertical-align: middle;
71
+ }
72
+
73
+ #crayon-editor-controls .crayon-theme-editor-form .split-field td {
74
+ padding-right: 5px;
75
+ }
76
+
77
+ #crayon-editor-controls .crayon-theme-editor-form .split-field td.last {
78
+ padding-right: 0;
79
+ }
80
+
81
+ #crayon-editor-controls .split-field input,
82
+ #crayon-editor-controls .split-field select {
83
+ width: 100%;
84
+ }
85
+
86
+ #crayon-editor-controls .crayon-theme-editor-form table td.value.split {
87
+ padding-left: 0;
88
+ }
89
+
90
+ #crayon-editor-controls .crayon-theme-editor-form table td.field.split {
91
+ padding-right: 0;
92
+ }
93
+
94
+ #crayon-editor-controls input {
95
+ line-height: 23px;
96
+ height: 23px;
97
+ border: 1px solid #ccc;
98
+ padding: 0 5px;
99
+ margin: 2px 0;
100
+ }
101
+
102
+ #crayon-editor-controls input:focus {
103
+ border: 1px solid #999;
104
+ }
105
+
106
+ #crayon-editor-controls .ui-tabs-panel {
107
+ padding: 5px;
108
+ }
109
+
110
+ .crayon-theme-editor-form table {
111
+ width: 100%;
112
+ }
113
+
114
+ #crayon-editor-controls .crayon-theme-editor-form table,
115
+ #crayon-editor-controls .crayon-theme-editor-form tr,
116
+ #crayon-editor-controls .crayon-theme-editor-form td {
117
+ padding: 0;
118
+ margin: 0;
119
+ border-spacing: 0 !important;
120
+ }
121
+
122
+ #crayon-editor-controls .crayon-theme-editor-form table tr:first-child td,
123
+ #crayon-editor-controls .crayon-theme-editor-form table tr:last-child td {
124
+ padding: 4px;
125
+ }
126
+
127
+ #crayon-editor-controls .crayon-theme-editor-form table td {
128
+ padding: 1px 4px;
129
+ }
130
+
131
+ .crayon-theme-editor-form table .value input {
132
+ width: 100%;
133
+ }
134
+
135
+ #crayon-editor-controls .ui-tabs-nav li {
136
+ padding: 0;
137
+ margin: 0;
138
+ border-top: 0;
139
+ border-left: 0;
140
+ }
141
+
142
+ #crayon-editor-controls .ui-tabs-nav * {
143
+ border-radius: 0px;
144
+ }
145
+
146
+ #crayon-editor-controls .ui-tabs-nav {
147
+ padding: 0;
148
+ margin: 0;
149
+ }
150
+
151
+ #crayon-editor-controls .ui-tabs-nav,
152
+ #crayon-editor-controls .ui-tabs-nav li,
153
+ #crayon-editor-controls .ui-tabs-nav li a {
154
+ height: 33px;
155
+ line-height: 33px;
156
+ padding: 0;
157
+ }
158
+
159
+ #crayon-editor-controls .ui-tabs-nav li a,
160
+ #crayon-editor-controls .ui-tabs-nav li {
161
+ width: 70px;
162
+ }
163
+
164
+ #crayon-editor-controls .ui-tabs-nav li:first-child {
165
+ border-top-left-radius: 4px;
166
+ }
167
+
168
+ #crayon-editor-controls.ui-tabs {
169
+ padding: 0;
170
+ margin: 0;
171
+ }
172
+
173
+ #crayon-editor-controls .ui-widget-header {
174
+ width: 1000px;
175
+ overflow: hidden;
176
+ border-bottom-left-radius: 0;
177
+ border-bottom-right-radius: 0;
178
+ }
179
+
180
+ #crayon-editor-controls .ui-widget-header li:last-child {
181
+ border-right: none !important;
182
+ }
183
+
184
+ #crayon-editor-control-wrapper .ui-widget-content {
185
+ border: 0;
186
+ background: none;
187
+ }
188
+
189
+ #crayon-editor-controls .ui-widget-content {
190
+ border: 1px solid #bbb;
191
+ border-top-style: none;
192
+ background: #f5f5f5 50% top repeat-x;
193
+ color: #333333;
194
+ padding: 0;
195
+ }
196
+
197
+ .ui-colorpicker-preview-container .ui-colorpicker-border,
198
+ .ui-colorpicker-preview-initial,
199
+ .ui-colorpicker-preview-current {
200
+ height: 20px;
201
+ }
202
+
203
+ .ui-colorpicker .ui-colorpicker-mode {
204
+ margin-right: 5px;
205
+ }
206
+
207
+ .ui-colorpicker-swatches {
208
+ height: auto;
209
+ }
210
+
211
+ .ui-colorpicker {
212
+ z-index: 100 !important;
213
+ }
214
+
215
+ .crayon-tab-information {
216
+ background: url(images/information.png) no-repeat top center;
217
+ }
218
+
219
+ .crayon-tab-highlighting {
220
+ background: url(images/highlighting.png) no-repeat top center;
221
+ }
222
+
223
+ .crayon-tab-frame {
224
+ background: url(images/frame.png) no-repeat top center;
225
+ }
226
+
227
+ .crayon-tab-lines {
228
+ background: url(images/lines.png) no-repeat top center;
229
+ }
230
+
231
+ .crayon-tab-numbers {
232
+ background: url(images/numbers.png) no-repeat top center;
233
+ }
234
+
235
+ .crayon-tab-toolbar {
236
+ background: url(images/toolbar.png) no-repeat top center;
237
+ }
238
+
239
+ .ui-widget-header {
240
+ border: 1px solid #b3b3b3;
241
+ border-bottom: 1px solid #666;
242
+ background: #929292 url(images/button.png) center bottom repeat-x;
243
+ color: #474747;
244
+ font-weight: bold;
245
+ }
246
+
247
+ #crayon-editor-controls .ui-state-default,
248
+ #crayon-editor-controls .ui-widget-content .ui-state-default,
249
+ #crayon-editor-controls .ui-widget-header .ui-state-default {
250
+ border: none;
251
+ background: #929292 url(images/button.png) center bottom repeat-x;
252
+ font-weight: bold;
253
+ color: #545454;
254
+ border-top: 1px solid #ccc !important;
255
+ }
256
+
257
+ #crayon-editor-controls .ui-state-hover,
258
+ #crayon-editor-controls .ui-widget-content .ui-state-hover,
259
+ #crayon-editor-controls .ui-widget-header .ui-state-hover,
260
+ #crayon-editor-controls .ui-state-focus,
261
+ #crayon-editor-controls .ui-widget-content .ui-state-focus,
262
+ #crayon-editor-controls .ui-widget-header .ui-state-focus {
263
+ border: none;
264
+ background: #b3b3b3 url(images/button-pressed.png) center bottom repeat-x;
265
+ border-top: 1px solid #eee !important;
266
+ font-weight: bold;
267
+ color: #00467a;
268
+ }
269
+
270
+ #crayon-editor-controls .ui-state-active,
271
+ #crayon-editor-controls .ui-widget-content .ui-state-active,
272
+ #crayon-editor-controls .ui-widget-header .ui-state-active {
273
+ border: none;
274
+ background: #b3b3b3 url(images/button-pressed.png) center bottom repeat-x;
275
+ font-weight: bold;
276
+ color: #4f4f4f;
277
+ border-top: 1px solid #eee !important;
278
+ }
279
+
280
+ .ui-dialog-content td input {
281
+ width: 100%;
282
+ }
283
+
284
+ /* {*/
285
+ /*height: auto !important;*/
286
+ /*}*/
util/theme-editor/theme_editor.js CHANGED
@@ -6,26 +6,638 @@
6
 
7
  var base = this;
8
 
 
9
  var adminSettings = CrayonAdminSettings;
10
  var settings = CrayonThemeEditorSettings;
 
 
11
 
12
- var preview;
 
 
 
 
 
 
13
 
14
- base.init = function (callback, crayon) {
15
- console_log('editor init');
16
- preview = jQuery('#crayon-editor-preview');
17
- crayon.attr('id', 'theme-editor-instance');
18
- CrayonSyntax.process(crayon, true);
19
- preview.html(crayon);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
20
 
21
- //console.log(adminSettings.curr_theme_str);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
22
 
23
- callback();
24
- base.initUI();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
25
  };
26
 
27
- base.initUI = function() {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
28
  $('#crayon-editor-controls').tabs();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
29
  }
30
 
31
  };
6
 
7
  var base = this;
8
 
9
+ var crayonSettings = CrayonSyntaxSettings;
10
  var adminSettings = CrayonAdminSettings;
11
  var settings = CrayonThemeEditorSettings;
12
+ var strings = CrayonThemeEditorStrings;
13
+ var admin = CrayonSyntaxAdmin;
14
 
15
+ var preview, previewCrayon, previewCSS, status, title, info;
16
+ var changed, loaded;
17
+ var themeID, themeJSON, themeCSS, themeStr, themeInfo;
18
+ var reImportant = /\s+!important$/gmi;
19
+ var reSize = /^[0-9-]+px$/;
20
+ var reCopy = /-copy(-\d+)?$/;
21
+ var changedAttr = 'data-value';
22
 
23
+ base.init = function (callback) {
24
+ // Called only once
25
+ CrayonUtil.log('editor init');
26
+ base.initUI();
27
+ if (callback) {
28
+ callback();
29
+ }
30
+ };
31
+
32
+ base.show = function (callback, crayon) {
33
+ // Called each time editor is shown
34
+ previewCrayon = crayon.find('.crayon-syntax');
35
+ //crayon.attr('id', 'theme-editor-instance');
36
+ // CrayonSyntax.process(crayon, true);
37
+ // preview.html(crayon);
38
+ preview.append(crayon)
39
+ base.load();
40
+ if (callback) {
41
+ callback();
42
+ }
43
+ };
44
 
45
+ base.load = function () {
46
+ loaded = false;
47
+ themeStr = adminSettings.currThemeCSS;
48
+ themeID = adminSettings.currTheme;
49
+ changed = false;
50
+ themeJSON = CSSJSON.toJSON(themeStr, {
51
+ stripComments: true,
52
+ split: true
53
+ });
54
+ CrayonUtil.log(themeJSON);
55
+ themeInfo = base.readCSSInfo(themeStr);
56
+ base.removeExistingCSS();
57
+ base.initInfoUI();
58
+ base.updateTitle();
59
+ base.updateInfo();
60
+ base.setFieldValues(themeInfo);
61
+ base.populateAttributes();
62
+ base.updateLiveCSS();
63
+ base.updateUI();
64
+ loaded = true;
65
+ };
66
 
67
+ base.save = function () {
68
+ // Update info from form fields
69
+ themeInfo = base.getFieldValues($.keys(themeInfo));
70
+ // Get the names of the fields and map them to their values
71
+ var names = base.getFieldNames(themeInfo);
72
+ var info = {};
73
+ for (var id in themeInfo) {
74
+ info[names[id]] = themeInfo[id];
75
+ }
76
+ // Update attributes
77
+ base.persistAttributes();
78
+ // return false;
79
+ // Save
80
+ themeCSS = CSSJSON.toCSS(themeJSON);
81
+ var newThemeStr = base.writeCSSInfo(info) + themeCSS;
82
+ CrayonUtil.postAJAX({
83
+ action: 'crayon-theme-editor-save',
84
+ id: themeID,
85
+ name: base.getName(),
86
+ css: newThemeStr
87
+ }, function (result) {
88
+ status.show();
89
+ result = parseInt(result);
90
+ if (result > 0) {
91
+ status.html(strings.success);
92
+ if (result === 2) {
93
+ window.GET['theme-editor'] = 1;
94
+ CrayonUtil.reload();
95
+ }
96
+ } else {
97
+ status.html(strings.fail);
98
+ }
99
+ changed = false;
100
+ setTimeout(function () {
101
+ status.fadeOut();
102
+ }, 1000);
103
+ });
104
+ };
105
+
106
+ base.del = function (id, name) {
107
+ base.createDialog({
108
+ title: strings.del,
109
+ html: strings.deleteThemeConfirm.replace('%s', name),
110
+ yes: function () {
111
+ CrayonUtil.postAJAX({
112
+ action: 'crayon-theme-editor-delete',
113
+ id: id
114
+ }, function (result) {
115
+ if (result > 0) {
116
+ CrayonUtil.reload();
117
+ } else {
118
+ base.createAlert({
119
+ html: strings.deleteFail + ' ' + strings.checkLog
120
+ });
121
+ }
122
+ });
123
+ },
124
+ options: {
125
+ selectedButtonIndex: 2
126
+ }
127
+ });
128
+ };
129
+
130
+ base.duplicate = function (id, name) {
131
+ base.createPrompt({
132
+ //html: "Are you sure you want to duplicate the '" + name + "' theme?",
133
+ title: strings.duplicate,
134
+ text: strings.newName,
135
+ value: base.getNextAvailableName(id),
136
+ ok: function (val) {
137
+ CrayonUtil.postAJAX({
138
+ action: 'crayon-theme-editor-duplicate',
139
+ id: id,
140
+ name: val
141
+ }, function (result) {
142
+ if (result > 0) {
143
+ CrayonUtil.reload();
144
+ } else {
145
+ base.createAlert({
146
+ html: strings.duplicateFail + ' ' + strings.checkLog
147
+ });
148
+ }
149
+ });
150
+ }
151
+ });
152
+ };
153
+
154
+ base.submit = function (id, name) {
155
+ base.createPrompt({
156
+ title: strings.submit,
157
+ desc: strings.submitText,
158
+ text: strings.message,
159
+ value: strings.submitMessage,
160
+ ok: function (val) {
161
+ CrayonUtil.postAJAX({
162
+ action: 'crayon-theme-editor-submit',
163
+ id: id,
164
+ message: val
165
+ }, function (result) {
166
+ console.log(result);
167
+ var msg = result > 0 ? strings.submitSucceed : strings.submitFail + ' ' + strings.checkLog ;
168
+ base.createAlert({
169
+ html: msg
170
+ });
171
+ });
172
+ }
173
+ });
174
  };
175
 
176
+ base.getNextAvailableName = function (id) {
177
+ var next = base.getNextAvailableID(id);
178
+ return base.idToName(next[1]);
179
+ };
180
+
181
+ base.getNextAvailableID = function (id) {
182
+ var themes = adminSettings.themes;
183
+ var count = 0;
184
+ if (reCopy.test(id)) {
185
+ // Remove the "copy" if it already exists
186
+ var newID = id.replace(reCopy, '');
187
+ if (newID.length > 0) {
188
+ id = newID;
189
+ }
190
+ }
191
+ var nextID = id;
192
+ while (nextID in themes) {
193
+ count++;
194
+ if (count == 1) {
195
+ nextID = id + '-copy';
196
+ } else {
197
+ nextID = id + '-copy-' + count.toString();
198
+ }
199
+ }
200
+ return [count, nextID];
201
+ };
202
+
203
+ base.readCSSInfo = function (cssStr) {
204
+ var infoStr = /^\s*\/\*[\s\S]*?\*\//gmi.exec(cssStr);
205
+ var themeInfo = {};
206
+ var match = null;
207
+ var infoRegex = /([^\r\n:]*[^\r\n\s:])\s*:\s*([^\r\n]+)/gmi;
208
+ while ((match = infoRegex.exec(infoStr)) != null) {
209
+ // var fieldID = settings.fieldsInverse[match[1]];
210
+ // var fieldID = base.convertToID(match[1]);
211
+ // if (fieldID) {
212
+ // themeInfo[fieldID] = match[2];
213
+ // }
214
+ themeInfo[base.nameToID(match[1])] = CrayonUtil.encode_html(match[2]);
215
+ }
216
+ // Force title case on the name
217
+ if (themeInfo.name) {
218
+ themeInfo.name = base.idToName(themeInfo.name);
219
+ }
220
+ return themeInfo;
221
+ };
222
+
223
+ base.getFieldName = function (id) {
224
+ var name = '';
225
+ if (id in settings.fields) {
226
+ name = settings.fields[id];
227
+ } else {
228
+ name = base.idToName(id);
229
+ }
230
+ return name;
231
+ };
232
+
233
+ base.getFieldNames = function (fields) {
234
+ var names = {};
235
+ for (var id in fields) {
236
+ names[id] = base.getFieldName(id);
237
+ }
238
+ return names;
239
+ };
240
+
241
+ base.removeExistingCSS = function() {
242
+ // Remove the old <style> tag to prevent clashes
243
+ preview.find('link[rel="stylesheet"][href*="' + adminSettings.currThemeURL + '"]').remove()
244
+ };
245
+
246
+ base.initInfoUI = function () {
247
+ CrayonUtil.log(themeInfo);
248
+ // TODO abstract
249
+ var names = base.getFieldNames(themeInfo);
250
+ var fields = {};
251
+ for (var id in names) {
252
+ var name = names[id];
253
+ var value = themeInfo[id];
254
+ fields[name] = base.createInput(id, value);
255
+ }
256
+ $('#tabs-1-contents').html(base.createForm(fields));
257
+ base.getField('name').bind('change keydown keyup', function () {
258
+ themeInfo.name = base.getFieldValue('name');
259
+ base.updateTitle();
260
+ });
261
+ };
262
+
263
+ base.nameToID = function (name) {
264
+ return name.toLowerCase().replace(/\s+/gmi, '-');
265
+ };
266
+
267
+ base.idToName = function (id) {
268
+ id = id.replace(/-/gmi, ' ');
269
+ return id.toTitleCase();
270
+ };
271
+
272
+ base.getName = function () {
273
+ var name = themeInfo.name;
274
+ if (!name) {
275
+ name = base.idToName(themeID);
276
+ }
277
+ return name;
278
+ };
279
+
280
+ base.getField = function (id) {
281
+ return $('#' + settings.cssInputPrefix + id);
282
+ };
283
+
284
+ base.getFieldValue = function (id) {
285
+ return base.getElemValue(base.getField(id));
286
+ };
287
+
288
+ base.getElemValue = function (elem) {
289
+ if (elem) {
290
+ // TODO add support for checkboxes etc.
291
+ return elem.val();
292
+ } else {
293
+ return null;
294
+ }
295
+ };
296
+
297
+ base.getFieldValues = function (fields) {
298
+ var info = {};
299
+ $(fields).each(function (i, id) {
300
+ info[id] = base.getFieldValue(id);
301
+ });
302
+ return info;
303
+ };
304
+
305
+ base.setFieldValue = function (id, value) {
306
+ base.setElemValue(base.getField(id), value);
307
+ };
308
+
309
+ base.setFieldValues = function (obj) {
310
+ for (var i in obj) {
311
+ base.setFieldValue(i, obj[i]);
312
+ }
313
+ };
314
+
315
+ base.setElemValue = function (elem, val) {
316
+ if (elem) {
317
+ // TODO add support for checkboxes etc.
318
+ return elem.val(val);
319
+ } else {
320
+ return false;
321
+ }
322
+ };
323
+
324
+ base.getAttribute = function (element, attribute) {
325
+ return base.getField(element + '_' + attribute);
326
+ };
327
+
328
+ base.getAttributes = function () {
329
+ return $('.' + settings.cssInputPrefix + settings.attribute);
330
+ };
331
+
332
+ base.visitAttribute = function (attr, callback) {
333
+ var elems = themeJSON.children;
334
+ var root = settings.cssThemePrefix + base.nameToID(themeInfo.name);
335
+ var dataElem = attr.attr('data-element');
336
+ var dataAttr = attr.attr('data-attribute');
337
+ var elem = elems[root + dataElem];
338
+ callback(attr, elem, dataElem, dataAttr, root, elems);
339
+ };
340
+
341
+ base.persistAttributes = function (remove_default) {
342
+ remove_default = CrayonUtil.setDefault(remove_default, true);
343
+ base.getAttributes().each(function () {
344
+ base.persistAttribute($(this), remove_default);
345
+ });
346
+ };
347
+
348
+ base.persistAttribute = function (attr, remove_default) {
349
+ remove_default = CrayonUtil.setDefault(remove_default, true);
350
+ base.visitAttribute(attr, function (attr, elem, dataElem, dataAttr, root, elems) {
351
+ if (elem) {
352
+ if (remove_default && attr.prop('tagName') == 'SELECT' && attr.val() == attr.attr('data-default')) {
353
+ // If default is selected in a dropdown, then remove
354
+ delete elem.attributes[dataAttr];
355
+ return;
356
+ }
357
+ val = base.getElemValue(attr);
358
+ if ((val == null || val == '')) {
359
+ // No value given
360
+ if (remove_default) {
361
+ delete elem.attributes[dataAttr];
362
+ return;
363
+ }
364
+ } else {
365
+ val = base.addImportant(val);
366
+ }
367
+ elem.attributes[dataAttr] = val;
368
+ CrayonUtil.log(dataElem + ' ' + dataAttr);
369
+ }
370
+ });
371
+ };
372
+
373
+ base.populateAttributes = function ($change) {
374
+ var elems = themeJSON.children;
375
+ var root = settings.cssThemePrefix + base.nameToID(themeInfo.name);
376
+ CrayonUtil.log(elems, root);
377
+ base.getAttributes().each(function () {
378
+ base.visitAttribute($(this), function (attr, elem, dataElem, dataAttr, root, elems) {
379
+ if (elem) {
380
+ if (dataAttr in elem.attributes) {
381
+ var val = base.removeImportant(elem.attributes[dataAttr]);
382
+ base.setElemValue(attr, val);
383
+ attr.trigger('change');
384
+ }
385
+ }
386
+ });
387
+ });
388
+ };
389
+
390
+ base.addImportant = function (attr) {
391
+ if (!reImportant.test(attr)) {
392
+ attr = attr + ' !important';
393
+ }
394
+ return attr;
395
+ };
396
+
397
+ base.removeImportant = function (attr) {
398
+ return attr.replace(reImportant, '');
399
+ };
400
+
401
+ base.appendStyle = function (css) {
402
+ previewCSS.html('<style>' + css + '</style>');
403
+ };
404
+
405
+ base.removeStyle = function() {
406
+ previewCSS.html('');
407
+ };
408
+
409
+ base.writeCSSInfo = function (info) {
410
+ var infoStr = '/*\n';
411
+ for (field in info) {
412
+ infoStr += field + ': ' + info[field] + '\n';
413
+ }
414
+ return infoStr + '*/\n';
415
+ };
416
+
417
+ base.initUI = function () {
418
+ // Bind events
419
+ preview = $('#crayon-editor-preview');
420
+ previewCSS = $('#crayon-editor-preview-css');
421
+ status = $('#crayon-editor-status');
422
+ title = $('#crayon-theme-editor-name');
423
+ info = $('#crayon-theme-editor-info');
424
  $('#crayon-editor-controls').tabs();
425
+ $('#crayon-editor-back').click(function () {
426
+ if (changed) {
427
+ base.createDialog({
428
+ html: strings.discardConfirm,
429
+ title: strings.confirm,
430
+ yes: function () {
431
+ showMain();
432
+ }
433
+ });
434
+ } else {
435
+ showMain();
436
+ }
437
+ });
438
+ $('#crayon-editor-save').click(base.save);
439
+
440
+ // Set up jQuery UI
441
+ base.getAttributes().each(function () {
442
+ var attr = $(this);
443
+ var type = attr.attr('data-group');
444
+ if (type == 'color') {
445
+ var args = {
446
+ parts: 'full',
447
+ showNoneButton: true,
448
+ colorFormat: '#HEX'
449
+ };
450
+ args.select = function (e, color) {
451
+ attr.trigger('change');
452
+ };
453
+ args.close = function (e, color) {
454
+ // attr.val(color.formatted);
455
+ // args.select(e, color);
456
+ attr.trigger('change');
457
+ };
458
+ attr.colorpicker(args);
459
+ attr.bind('change', function () {
460
+ var hex = attr.val();
461
+ attr.css('background-color', hex);
462
+ attr.css('color', CrayonUtil.getReadableColor(hex));
463
+ });
464
+ } else if (type == 'size') {
465
+ attr.bind('change', function () {
466
+ var val = attr.val();
467
+ if (!reSize.test(val)) {
468
+ val = CrayonUtil.removeChars('^0-9-', val);
469
+ if (val != '') {
470
+ attr.val(val + 'px');
471
+ }
472
+ }
473
+ });
474
+ }
475
+ if (type != 'color') {
476
+ // For regular text boxes, capture changes on keys
477
+ attr.bind('keydown keyup', function () {
478
+ if (attr.attr(changedAttr) != attr.val()) {
479
+ CrayonUtil.log('triggering', attr.attr(changedAttr), attr.val());
480
+ attr.trigger('change');
481
+ }
482
+ });
483
+ }
484
+ // Update CSS changes to the live instance
485
+ attr.bind('change', function () {
486
+ if (attr.attr(changedAttr) == attr.val()) {
487
+ return;
488
+ } else {
489
+ attr.attr(changedAttr, attr.val());
490
+ }
491
+ if (loaded) {
492
+ base.persistAttribute(attr);
493
+ base.updateLiveCSS();
494
+ }
495
+ });
496
+ });
497
+ };
498
+
499
+ base.updateLiveCSS = function (clone) {
500
+ clone = CrayonUtil.setDefault(clone, false);
501
+ if (previewCrayon) {
502
+ var json;
503
+ if (clone) {
504
+ var id = previewCrayon.attr('id');
505
+ json = $.extend(true, {}, themeJSON);
506
+ $.each(json.children, function (child) {
507
+ json.children['#' + id + child] = json.children[child];
508
+ delete json.children[child];
509
+ });
510
+ } else {
511
+ json = themeJSON;
512
+ }
513
+ base.appendStyle(CSSJSON.toCSS(json));
514
+ }
515
+ };
516
+
517
+ base.updateUI = function () {
518
+ $('#crayon-editor-controls input, #crayon-editor-controls select').bind('change', function () {
519
+ changed = true;
520
+ });
521
+ };
522
+
523
+ base.createInput = function (id, value, type) {
524
+ value = CrayonUtil.setDefault(value, '');
525
+ type = CrayonUtil.setDefault(type, 'text');
526
+ return '<input id="' + settings.cssInputPrefix + id + '" class="' + settings.cssInputPrefix + type + '" type="' + type + '" value="' + value + '" />';
527
+ };
528
+
529
+ base.createForm = function (inputs) {
530
+ var str = '<form class="' + settings.prefix + '-form"><table>';
531
+ $.each(inputs, function (input) {
532
+ str += '<tr><td class="field">' + input + '</td><td class="value">' + inputs[input] + '</td></tr>';
533
+ });
534
+ str += '</table></form>';
535
+ return str;
536
+ };
537
+
538
+ var showMain = function () {
539
+ admin.resetPreview();
540
+ admin.preview_update();
541
+ admin.show_theme_info();
542
+ admin.show_main();
543
+ //preview.html('');
544
+ };
545
+
546
+ base.updateTitle = function () {
547
+ var name = base.getName();
548
+ if (adminSettings.editing_theme) {
549
+ title.html(strings.editingTheme.replace('%s', name));
550
+ } else {
551
+ title.html(strings.creatingTheme.replace('%s', name));
552
+ }
553
+ };
554
+
555
+ base.updateInfo = function () {
556
+ info.html('<a target="_blank" href="' + adminSettings.currThemeURL + '">' + adminSettings.currThemeURL + '</a>');
557
+ };
558
+
559
+ base.createPrompt = function (args) {
560
+ args = $.extend({
561
+ title: strings.prompt,
562
+ text: strings.value,
563
+ desc: null,
564
+ value: '',
565
+ options: {
566
+ buttons: {
567
+ "OK": function () {
568
+ if (args.ok) {
569
+ args.ok(base.getFieldValue('prompt-text'));
570
+ }
571
+ $(this).dialog('close');
572
+ },
573
+ "Cancel": function () {
574
+ $(this).dialog('close');
575
+ }
576
+ },
577
+ open: function () {
578
+ base.getField('prompt-text').val(args.value).focus();
579
+ }
580
+ }
581
+ }, args);
582
+ args.html = '<table>';
583
+ if (args.desc) {
584
+ args.html += '<tr><td colspan="2">' + args.desc + '</td></tr>';
585
+ }
586
+ args.html += '<tr><td>' + args.text + ':</td><td>' + base.createInput('prompt-text') + '</td></tr>';
587
+ args.html += '</table>';
588
+ base.createDialog(args);
589
+ };
590
+
591
+ base.createAlert = function (args) {
592
+ args = $.extend({
593
+ title: strings.alert,
594
+ options: {
595
+ buttons: {
596
+ "OK": function () {
597
+ $(this).dialog('close');
598
+ }
599
+ }
600
+ }
601
+ }, args);
602
+ base.createDialog(args);
603
+ };
604
+
605
+ base.createDialog = function (args) {
606
+ var defaultArgs = {
607
+ yesLabel: strings.yes,
608
+ noLabel: strings.no,
609
+ title: strings.confirm
610
+ };
611
+ args = $.extend(defaultArgs, args);
612
+ var options = {
613
+ modal: true, title: args.title, zIndex: 10000, autoOpen: true,
614
+ width: 'auto', resizable: false,
615
+ buttons: {
616
+ },
617
+ selectedButtonIndex: 1, // starts from 1
618
+ close: function (event, ui) {
619
+ $(this).remove();
620
+ }
621
+ };
622
+ options.open = function () {
623
+ $(this).parent().find('button:nth-child(' + options.selectedButtonIndex + ')').focus();
624
+ };
625
+ options.buttons[args.yesLabel] = function () {
626
+ if (args.yes) {
627
+ args.yes();
628
+ }
629
+ $(this).dialog('close');
630
+ };
631
+ options.buttons[args.noLabel] = function () {
632
+ if (args.no) {
633
+ args.no();
634
+ }
635
+ $(this).dialog('close');
636
+ };
637
+ options = $.extend(options, args.options);
638
+ $('<div></div>').appendTo('body').html(args.html).dialog(options);
639
+ // Can be modified afterwards
640
+ return args;
641
  }
642
 
643
  };
util/theme-editor/theme_editor.php CHANGED
@@ -1,28 +1,873 @@
1
  <?php
2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  class CrayonThemeEditorWP {
4
 
5
- public static function init() {
6
- self::admin_resources();
7
- }
8
-
9
- public static function admin_resources() {
10
- global $CRAYON_VERSION;
11
- $settings = array(
12
- // Only things the theme editor needs
13
- );
14
- wp_enqueue_script('cssjson_js', plugins_url(CRAYON_CSSJSON_JS, dirname(dirname(__FILE__))), $CRAYON_VERSION);
15
- wp_enqueue_script('jquery_ui_js', plugins_url(CRAYON_JS_JQUERY_UI, dirname(dirname(__FILE__))), array('jquery'), $CRAYON_VERSION);
16
- wp_enqueue_script('crayon_theme_editor', plugins_url(CRAYON_THEME_EDITOR_JS, dirname(dirname(__FILE__))), array('jquery', 'jquery_ui_js', 'crayon_util_js', 'cssjson_js'), $CRAYON_VERSION);
17
- wp_localize_script('crayon_theme_editor', 'CrayonThemeEditorSettings', $settings);
18
-
19
- wp_enqueue_style('jquery_ui', plugins_url(CRAYON_CSS_JQUERY_UI, dirname(dirname(__FILE__))), array(), $CRAYON_VERSION);
20
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21
 
22
  }
23
 
24
  if (defined('ABSPATH') && is_admin()) {
25
- add_action('init', 'CrayonThemeEditorWP::init');
26
  }
27
 
28
  ?>
1
  <?php
2
 
3
+ class Element {
4
+ public $id;
5
+ public $class = '';
6
+ public $tag = 'div';
7
+ public $closed = FALSE;
8
+ public $contents = '';
9
+ public $attributes = array();
10
+ const CSS_INPUT_PREFIX = "crayon-theme-input-";
11
+
12
+ public function __construct($id) {
13
+ $this->id = $id;
14
+ }
15
+
16
+ public function addClass($class) {
17
+ $this->class .= ' ' . self::CSS_INPUT_PREFIX . $class;
18
+ }
19
+
20
+ public function addAttributes($atts) {
21
+ $this->attributes = array_merge($this->attributes, $atts);
22
+ }
23
+
24
+ public function attributeString() {
25
+ $str = '';
26
+ foreach ($this->attributes as $k => $v) {
27
+ $str .= "$k=\"$v\" ";
28
+ }
29
+ return $str;
30
+ }
31
+
32
+ public function __toString() {
33
+ return '<' . $this->tag . ' id="' . self::CSS_INPUT_PREFIX . $this->id . '" class="' . self::CSS_INPUT_PREFIX . $this->class . '" ' . $this->attributeString() . ($this->closed ? ' />' : ' >' . $this->contents . "</$this->tag>");
34
+ }
35
+ }
36
+
37
+ class Input extends Element {
38
+ public $name;
39
+ public $type;
40
+
41
+ public function __construct($id, $name = NULL, $value = '', $type = 'text') {
42
+ parent::__construct($id);
43
+ $this->tag = 'input';
44
+ $this->closed = TRUE;
45
+ if ($name === NULL) {
46
+ $name = CrayonUserResource::clean_name($id);
47
+ }
48
+ $this->name = $name;
49
+ $this->class .= $type;
50
+ $this->addAttributes(array(
51
+ 'type' => $type,
52
+ 'value' => $value
53
+ ));
54
+ }
55
+ }
56
+
57
+ class Select extends Input {
58
+ public $options;
59
+ public $selected = NULL;
60
+
61
+ public function __construct($id, $name = NULL, $value = '', $options = array()) {
62
+ parent::__construct($id, $name, 'select');
63
+ $this->tag = 'select';
64
+ $this->closed = FALSE;
65
+ $this->addOptions($options);
66
+ }
67
+
68
+ public function addOptions($options, $default = NULL) {
69
+ for ($i = 0; $i < count($options); $i++) {
70
+ $key = $options[$i];
71
+ $value = isset($options[$key]) ? $options[$key] : $key;
72
+ $this->options[$key] = $value;
73
+ }
74
+ if ($default === NULL && count($options) > 1) {
75
+ $this->attributes['data-default'] = $options[0];
76
+ } else {
77
+ $this->attributes['data-default'] = $default;
78
+ }
79
+ }
80
+
81
+ public function getOptionsString() {
82
+ $str = '';
83
+ foreach ($this->options as $k => $v) {
84
+ $selected = $this->selected == $k ? 'selected="selected"' : '';
85
+ $str .= "<option value=\"$k\" $selected>$v</option>";
86
+ }
87
+ return $str;
88
+ }
89
+
90
+ public function __toString() {
91
+ $this->contents = $this->getOptionsString();
92
+ return parent::__toString();
93
+ }
94
+ }
95
+
96
+ class Separator extends Element {
97
+ public $name = '';
98
+
99
+ public function __construct($name) {
100
+ parent::__construct($name);
101
+ $this->name = $name;
102
+ }
103
+ }
104
+
105
+ class Title extends Separator {
106
+
107
+ }
108
+
109
  class CrayonThemeEditorWP {
110
 
111
+ public static $attributes = NULL;
112
+ public static $attributeGroups = NULL;
113
+ public static $attributeGroupsInverse = NULL;
114
+ public static $attributeTypes = NULL;
115
+ public static $attributeTypesInverse = NULL;
116
+ public static $infoFields = NULL;
117
+ public static $infoFieldsInverse = NULL;
118
+ public static $settings = NULL;
119
+ public static $strings = NULL;
120
+
121
+ const ATTRIBUTE = 'attribute';
122
+
123
+ const RE_COMMENT = '#^\s*\/\*[\s\S]*?\*\/#msi';
124
+
125
+ public static function init() {
126
+ self::admin_resources();
127
+ }
128
+
129
+ public static function initFields() {
130
+ if (self::$infoFields === NULL) {
131
+ self::$infoFields = array(
132
+ // These are canonical and can't be translated, since they appear in the comments of the CSS
133
+ 'name' => 'Name',
134
+ 'description' => 'Description',
135
+ 'version' => 'Version',
136
+ 'author' => 'Author',
137
+ 'url' => 'URL',
138
+ 'original-author' => 'Original Author',
139
+ 'notes' => 'Notes',
140
+ 'maintainer' => 'Maintainer',
141
+ 'maintainer-url' => 'Maintainer URL'
142
+ );
143
+ self::$infoFieldsInverse = CrayonUtil::array_flip(self::$infoFields);
144
+ // A map of CSS element name and property to name
145
+ self::$attributes = array();
146
+ // A map of CSS attribute to input type
147
+ self::$attributeGroups = array(
148
+ 'color' => array('background', 'background-color', 'border-color', 'color', 'border-top-color', 'border-bottom-color'),
149
+ 'size' => array('border-width'),
150
+ 'border-style' => array('border-style', 'border-bottom-style', 'border-top-style')
151
+ );
152
+ self::$attributeGroupsInverse = CrayonUtil::array_flip(self::$attributeGroups);
153
+ // Mapping of input type to attribute group
154
+ self::$attributeTypes = array(
155
+ 'select' => array('border-style', 'font-style', 'font-weight', 'text-decoration')
156
+ );
157
+ self::$attributeTypesInverse = CrayonUtil::array_flip(self::$attributeTypes);
158
+ }
159
+ }
160
+
161
+ public static function initSettings() {
162
+
163
+ self::initFields();
164
+ self::initStrings();
165
+ if (self::$settings === NULL) {
166
+ self::$settings = array(
167
+ // Only things the theme editor needs
168
+ 'cssThemePrefix' => CrayonThemes::CSS_PREFIX,
169
+ 'cssInputPrefix' => Element::CSS_INPUT_PREFIX,
170
+ 'attribute' => self::ATTRIBUTE,
171
+ 'fields' => self::$infoFields,
172
+ 'fieldsInverse' => self::$infoFieldsInverse,
173
+ 'prefix' => 'crayon-theme-editor'
174
+ );
175
+ }
176
+ }
177
+
178
+ public static function initStrings() {
179
+ if (self::$strings === NULL) {
180
+ self::$strings = array(
181
+ // These appear only in the UI and can be translated
182
+ // TODO add the rest
183
+ 'no' => crayon__("No"),
184
+ 'yes' => crayon__("Yes"),
185
+ 'userTheme' => crayon__("User-Defined Theme"),
186
+ 'stockTheme' => crayon__("Stock Theme"),
187
+ 'success' => crayon__("Success!"),
188
+ 'fail' => crayon__("Failed!"),
189
+ 'delete' => crayon__("Delete"),
190
+ 'deleteThemeConfirm' => crayon__("Are you sure you want to delete the \"%s\" theme?"),
191
+ 'deleteFail' => crayon__("Delete failed!"),
192
+ 'duplicate' => crayon__("Duplicate"),
193
+ 'newName' => crayon__("New Name"),
194
+ 'duplicateFail' => crayon__("Duplicate failed!"),
195
+ 'checkLog' => crayon__("Please check the log for details."),
196
+ 'discardConfirm' => crayon__("Are you sure you want to discard all changes?"),
197
+ 'confirm' => crayon__("Confirm"),
198
+ 'editingTheme' => crayon__("Editing Theme: %s"),
199
+ 'creatingTheme' => crayon__("Creating Theme: %s"),
200
+ 'prompt' => crayon__("Prompt"),
201
+ 'value' => crayon__("Value"),
202
+ 'alert' => crayon__("Alert"),
203
+ 'submit' => crayon__("Submit Your Theme"),
204
+ 'submitText' => crayon__("Submit your User Theme for inclusion as a Stock Theme in Crayon!"),
205
+ 'message' => crayon__("Message"),
206
+ 'submitMessage' => crayon__("Please include this theme in Crayon!"),
207
+ 'submitSucceed' => crayon__("Submit was successful."),
208
+ 'submitFail' => crayon__("Submit failed!"),
209
+ );
210
+ }
211
+ }
212
+
213
+ public static function admin_resources() {
214
+ global $CRAYON_VERSION;
215
+ self::initSettings();
216
+ $path = dirname(dirname(__FILE__));
217
+ wp_enqueue_script('cssjson_js', plugins_url(CRAYON_CSSJSON_JS, $path), $CRAYON_VERSION);
218
+ wp_enqueue_script('jquery_ui_js', plugins_url(CRAYON_JS_JQUERY_UI, $path), array('jquery'), $CRAYON_VERSION);
219
+ wp_enqueue_script('jquery_colorpicker_js', plugins_url(CRAYON_JS_JQUERY_COLORPICKER, $path), array('jquery'), $CRAYON_VERSION);
220
+ wp_enqueue_script('jquery_tinycolor_js', plugins_url(CRAYON_JS_TINYCOLOR, $path), array(), $CRAYON_VERSION);
221
+ wp_enqueue_script('crayon_theme_editor', plugins_url(CRAYON_THEME_EDITOR_JS, $path), array('jquery', 'jquery_ui_js', 'crayon_util_js', 'crayon_admin_js', 'cssjson_js', 'jquery_colorpicker_js', 'jquery_tinycolor_js'), $CRAYON_VERSION);
222
+ wp_localize_script('crayon_theme_editor', 'CrayonThemeEditorSettings', self::$settings);
223
+ wp_localize_script('crayon_theme_editor', 'CrayonThemeEditorStrings', self::$strings);
224
+
225
+ wp_enqueue_style('jquery_ui', plugins_url(CRAYON_CSS_JQUERY_UI, $path), array(), $CRAYON_VERSION);
226
+ wp_enqueue_style('jquery_colorpicker', plugins_url(CRAYON_CSS_JQUERY_COLORPICKER, $path), array(), $CRAYON_VERSION);
227
+ }
228
+
229
+ public static function form($inputs) {
230
+ $str = '<form class="' . self::$settings['prefix'] . '-form"><table>';
231
+ $sepCount = 0;
232
+ foreach ($inputs as $input) {
233
+ if ($input instanceof Input) {
234
+ $str .= self::formField($input->name, $input);
235
+ } else if ($input instanceof Separator) {
236
+ $sepClass = '';
237
+ if ($input instanceof Title) {
238
+ $sepClass .= ' title';
239
+ }
240
+ if ($sepCount == 0) {
241
+ $sepClass .= ' first';
242
+ }
243
+ $str .= '<tr class="separator' . $sepClass . '"><td colspan="2"><div class="content">' . $input->name . '</div></td></tr>';
244
+ $sepCount++;
245
+ } else if (is_array($input) && count($input) > 1) {
246
+ $name = $input[0];
247
+ $fields = '<table class="split-field"><tr>';
248
+ $percent = 100 / count($input);
249
+ for ($i = 1; $i < count($input); $i++) {
250
+ $class = $i == count($input) - 1 ? 'class="last"' : '';
251
+ $fields .= '<td ' . $class . ' style="width: ' . $percent . '%">' . $input[$i] . '</td>';
252
+ }
253
+ $fields .= '</tr></table>';
254
+ $str .= self::formField($name, $fields, 'split');
255
+ }
256
+ }
257
+ $str .= '</table></form>';
258
+ return $str;
259
+ }
260
+
261
+ public static function formField($name, $field, $class = '') {
262
+ return '<tr><td class="field ' . $class . '">' . $name . '</td><td class="value ' . $class . '">' . $field . '</td></tr>';
263
+ }
264
+
265
+ public static function content() {
266
+ self::initSettings();
267
+ $theme = CrayonResources::themes()->get_default();
268
+ $editing = false;
269
+
270
+ if (isset($_GET['curr_theme'])) {
271
+ $currTheme = CrayonResources::themes()->get($_GET['curr_theme']);
272
+ if ($currTheme) {
273
+ $theme = $currTheme;
274
+ }
275
+ }
276
+
277
+ if (isset($_GET['editing'])) {
278
+ $editing = CrayonUtil::str_to_bool($_GET['editing'], FALSE);
279
+ }
280
+
281
+ $tInformation = crayon__("Information");
282
+ $tHighlighting = crayon__("Highlighting");
283
+ $tFrame = crayon__("Frame");
284
+ $tLines = crayon__("Lines");
285
+ $tNumbers = crayon__("Line Numbers");
286
+ $tToolbar = crayon__("Toolbar");
287
+
288
+ $tBackground = crayon__("Background");
289
+ $tText = crayon__("Text");
290
+ $tBorder = crayon__("Border");
291
+ $tTopBorder = crayon__("Top Border");
292
+ $tBottomBorder = crayon__("Bottom Border");
293
+
294
+ $tHover = crayon__("Hover");
295
+ $tActive = crayon__("Active");
296
+ $tPressed = crayon__("Pressed");
297
+ $tHoverPressed = crayon__("Pressed & Hover");
298
+ $tActivePressed = crayon__("Pressed & Active");
299
+
300
+ $tTitle = crayon__("Title");
301
+ $tButtons = crayon__("Buttons");
302
+
303
+ $tNormal = crayon__("Normal");
304
+ $tInline = crayon__("Inline");
305
+ $tStriped = crayon__("Striped");
306
+ $tMarked = crayon__("Marked");
307
+ $tStripedMarked = crayon__("Striped & Marked");
308
+ $tLanguage = crayon__("Language");
309
+
310
+ $top = '.crayon-top';
311
+ $bottom = '.crayon-bottom';
312
+ $hover = ':hover';
313
+ $active = ':active';
314
+ $pressed = '.crayon-pressed';
315
+
316
+ ?>
317
+
318
+ <div
319
+ id="icon-options-general" class="icon32"></div>
320
+ <h2>
321
+ Crayon Syntax Highlighter
322
+ <?php crayon_e('Theme Editor'); ?>
323
+ </h2>
324
+
325
+ <h3 id="<?php echo self::$settings['prefix'] ?>-name">
326
+ <?php
327
+ // if ($editing) {
328
+ // echo sprintf(crayon__('Editing "%s" Theme'), $theme->name());
329
+ // } else {
330
+ // echo sprintf(crayon__('Creating Theme From "%s"'), $theme->name());
331
+ // }
332
+ ?>
333
+ </h3>
334
+ <div id="<?php echo self::$settings['prefix'] ?>-info"></div>
335
+
336
+ <p>
337
+ <a id="crayon-editor-back" class="button-primary"><?php crayon_e("Back To Settings"); ?></a>
338
+ <a id="crayon-editor-save" class="button-primary"><?php crayon_e("Save"); ?></a>
339
+ <span id="crayon-editor-status"></span>
340
+ </p>
341
+
342
+ <?php //crayon_e('Use the Sidebar on the right to change the Theme of the Preview window.') ?>
343
+
344
+ <div id="crayon-editor-top-controls"></div>
345
+
346
+ <table id="crayon-editor-table" style="width: 100%;" cellspacing="5"
347
+ cellpadding="0">
348
+ <tr>
349
+ <td id="crayon-editor-preview-wrapper">
350
+ <div id="crayon-editor-preview"></div>
351
+ </td>
352
+ <div id="crayon-editor-preview-css"></div>
353
+ <td id="crayon-editor-control-wrapper">
354
+ <div id="crayon-editor-controls">
355
+ <ul>
356
+ <li title="<?php echo $tInformation ?>"><a class="crayon-tab-information" href="#tabs-1"></a></li>
357
+ <li title="<?php echo $tHighlighting ?>"><a class="crayon-tab-highlighting" href="#tabs-2"></a></li>
358
+ <li title="<?php echo $tFrame ?>"><a class="crayon-tab-frame" href="#tabs-3"></a></li>
359
+ <li title="<?php echo $tLines ?>"><a class="crayon-tab-lines" href="#tabs-4"></a></li>
360
+ <li title="<?php echo $tNumbers ?>"><a class="crayon-tab-numbers" href="#tabs-5"></a></li>
361
+ <li title="<?php echo $tToolbar ?>"><a class="crayon-tab-toolbar" href="#tabs-6"></a></li>
362
+ </ul>
363
+ <div id="tabs-1">
364
+ <?php
365
+ self::createAttributesForm(array(
366
+ new Title($tInformation)
367
+ ));
368
+ ?>
369
+ <div id="tabs-1-contents"></div>
370
+ <!-- Auto-filled by theme_editor.js -->
371
+ </div>
372
+ <div id="tabs-2">
373
+ <?php
374
+ $highlight = ' .crayon-pre .';
375
+ $elems = array(
376
+ 'c' => crayon__("Comment"),
377
+ 's' => crayon__("String"),
378
+ 'p' => crayon__("Preprocessor"),
379
+ 'ta' => crayon__("Tag"),
380
+ 'k' => crayon__("Keyword"),
381
+ 'st' => crayon__("Statement"),
382
+ 'r' => crayon__("Reserved"),
383
+ 't' => crayon__("Type"),
384
+ 'm' => crayon__("Modifier"),
385
+ 'i' => crayon__("Identifier"),
386
+ 'e' => crayon__("Entity"),
387
+ 'v' => crayon__("Variable"),
388
+ 'cn' => crayon__("Constant"),
389
+ 'o' => crayon__("Operator"),
390
+ 'sy' => crayon__("Symbol"),
391
+ 'n' => crayon__("Notation"),
392
+ 'f' => crayon__("Faded"),
393
+ 'h' => crayon__("HTML")
394
+ );
395
+ $atts = array(new Title($tHighlighting));
396
+ foreach ($elems as $class => $name) {
397
+ $atts[] = array(
398
+ $name,
399
+ self::createAttribute($highlight . $class, 'color'),
400
+ self::createAttribute($highlight . $class, 'font-weight'),
401
+ self::createAttribute($highlight . $class, 'font-style'),
402
+ self::createAttribute($highlight . $class, 'text-decoration')
403
+ );
404
+ }
405
+ self::createAttributesForm($atts);
406
+ ?>
407
+ </div>
408
+ <div id="tabs-3">
409
+ <?php
410
+ $inline = '-inline';
411
+ self::createAttributesForm(array(
412
+ new Title($tFrame),
413
+ new Separator($tNormal),
414
+ // self::createAttribute('', 'background', $tBackground),
415
+ array(
416
+ $tBorder,
417
+ self::createAttribute('', 'border-width'),
418
+ self::createAttribute('', 'border-color'),
419
+ self::createAttribute('', 'border-style')
420
+ ),
421
+ new Separator($tInline),
422
+ self::createAttribute($inline, 'background', $tBackground),
423
+ array(
424
+ $tBorder,
425
+ self::createAttribute($inline, 'border-width'),
426
+ self::createAttribute($inline, 'border-color'),
427
+ self::createAttribute($inline, 'border-style')
428
+ ),
429
+ ));
430
+ ?>
431
+ </div>
432
+ <div id="tabs-4">
433
+ <?php
434
+ $stripedLine = ' .crayon-striped-line';
435
+ $markedLine = ' .crayon-marked-line';
436
+ $stripedMarkedLine = ' .crayon-marked-line.crayon-striped-line';
437
+ self::createAttributesForm(array(
438
+ new Title($tLines),
439
+ new Separator($tNormal),
440
+ self::createAttribute('', 'background', $tBackground),
441
+ new Separator($tStriped),
442
+ self::createAttribute($stripedLine, 'background', $tBackground),
443
+ new Separator($tMarked),
444
+ self::createAttribute($markedLine, 'background', $tBackground),
445
+ array(
446
+ $tBorder,
447
+ self::createAttribute($markedLine, 'border-width'),
448
+ self::createAttribute($markedLine, 'border-color'),
449
+ self::createAttribute($markedLine, 'border-style'),
450
+ ),
451
+ self::createAttribute($markedLine . $top, 'border-top-style', $tTopBorder),
452
+ self::createAttribute($markedLine . $bottom, 'border-bottom-style', $tBottomBorder),
453
+ new Separator($tStripedMarked),
454
+ self::createAttribute($stripedMarkedLine, 'background', $tBackground),
455
+ ));
456
+ ?>
457
+ </div>
458
+ <div id="tabs-5">
459
+ <?php
460
+ $nums = ' .crayon-table .crayon-nums';
461
+ $stripedNum = ' .crayon-striped-num';
462
+ $markedNum = ' .crayon-marked-num';
463
+ $stripedMarkedNum = ' .crayon-marked-num.crayon-striped-num';
464
+ self::createAttributesForm(array(
465
+ new Title($tNumbers),
466
+ new Separator($tNormal),
467
+ self::createAttribute($nums, 'background', $tBackground),
468
+ self::createAttribute($nums, 'color', $tText),
469
+ new Separator($tStriped),
470
+ self::createAttribute($stripedNum, 'background', $tBackground),
471
+ self::createAttribute($stripedNum, 'color', $tText),
472
+ new Separator($tMarked),
473
+ self::createAttribute($markedNum, 'background', $tBackground),
474
+ self::createAttribute($markedNum, 'color', $tText),
475
+ array(
476
+ $tBorder,
477
+ self::createAttribute($markedNum, 'border-width'),
478
+ self::createAttribute($markedNum, 'border-color'),
479
+ self::createAttribute($markedNum, 'border-style'),
480
+ ),
481
+ self::createAttribute($markedNum.$top, 'border-top-style', $tTopBorder),
482
+ self::createAttribute($markedNum.$bottom, 'border-bottom-style', $tBottomBorder),
483
+ new Separator($tStripedMarked),
484
+ self::createAttribute($stripedMarkedNum, 'background', $tBackground),
485
+ self::createAttribute($stripedMarkedNum, 'color', $tText),
486
+ ));
487
+ ?>
488
+ </div>
489
+ <div id="tabs-6">
490
+ <?php
491
+ $toolbar = ' .crayon-toolbar';
492
+ $title = ' .crayon-title';
493
+ $button = ' a.crayon-button';
494
+ $info = ' .crayon-info';
495
+ $language = ' .crayon-language';
496
+ self::createAttributesForm(array(
497
+ new Title($tToolbar),
498
+ new Separator($tFrame),
499
+ self::createAttribute($toolbar, 'background', $tBackground),
500
+ array(
501
+ $tBottomBorder,
502
+ self::createAttribute($toolbar, 'border-bottom-width'),
503
+ self::createAttribute($toolbar, 'border-bottom-color'),
504
+ self::createAttribute($toolbar, 'border-bottom-style'),
505
+ ),
506
+ array(
507
+ $tTitle,
508
+ self::createAttribute($title, 'color'),
509
+ self::createAttribute($title, 'font-weight'),
510
+ self::createAttribute($title, 'font-style'),
511
+ self::createAttribute($title, 'text-decoration')
512
+ ),
513
+ new Separator($tButtons),
514
+ self::createAttribute($button, 'background-color', $tBackground),
515
+ self::createAttribute($button.$hover, 'background-color', $tHover),
516
+ self::createAttribute($button.$active, 'background-color', $tActive),
517
+ self::createAttribute($button.$pressed, 'background-color', $tPressed),
518
+ self::createAttribute($button.$pressed.$hover, 'background-color', $tHoverPressed),
519
+ self::createAttribute($button.$pressed.$active, 'background-color', $tActivePressed),
520
+ new Separator($tInformation . ' ' . crayon__("(Used for Copy/Paste)")),
521
+ self::createAttribute($info, 'background', $tBackground),
522
+ array(
523
+ $tText,
524
+ self::createAttribute($info, 'color'),
525
+ self::createAttribute($info, 'font-weight'),
526
+ self::createAttribute($info, 'font-style'),
527
+ self::createAttribute($info, 'text-decoration')
528
+ ),
529
+ array(
530
+ $tBottomBorder,
531
+ self::createAttribute($info, 'border-bottom-width'),
532
+ self::createAttribute($info, 'border-bottom-color'),
533
+ self::createAttribute($info, 'border-bottom-style'),
534
+ ),
535
+ new Separator($tLanguage),
536
+ array(
537
+ $tText,
538
+ self::createAttribute($language, 'color'),
539
+ self::createAttribute($language, 'font-weight'),
540
+ self::createAttribute($language, 'font-style'),
541
+ self::createAttribute($language, 'text-decoration')
542
+ ),
543
+ // self::createAttribute($toolbar.' > div', 'float', crayon__("Title Float")),
544
+ // self::createAttribute($toolbar.' .crayon-tools', 'float', crayon__("Buttons Float"))
545
+ ));
546
+ ?>
547
+ </div>
548
+ </div>
549
+ </td>
550
+ </tr>
551
+
552
+ </table>
553
+
554
+ <?php
555
+ exit();
556
+ }
557
+
558
+ public static function createAttribute($element, $attribute, $name = NULL) {
559
+ $group = self::getAttributeGroup($attribute);
560
+ $type = self::getAttributeType($group);
561
+ if ($type == 'select') {
562
+ $input = new Select($element . '_' . $attribute, $name);
563
+ if ($group == 'border-style') {
564
+ $input->addOptions(array(
565
+ 'none',
566
+ 'hidden',
567
+ 'dotted',
568
+ 'dashed',
569
+ 'solid',
570
+ 'double',
571
+ 'groove',
572
+ 'ridge',
573
+ 'inset',
574
+ 'outset',
575
+ 'inherit'
576
+ ));
577
+ } else if ($group == 'float') {
578
+ $input->addOptions(array(
579
+ 'left',
580
+ 'right',
581
+ 'both',
582
+ 'none',
583
+ 'inherit'
584
+ ));
585
+ } else if ($group == 'font-style') {
586
+ $input->addOptions(array(
587
+ 'normal',
588
+ 'italic',
589
+ 'oblique',
590
+ 'inherit'
591
+ ));
592
+ } else if ($group == 'font-weight') {
593
+ $input->addOptions(array(
594
+ 'normal',
595
+ 'bold',
596
+ 'bolder',
597
+ 'lighter',
598
+ '100',
599
+ '200',
600
+ '300',
601
+ '400',
602
+ '500',
603
+ '600',
604
+ '700',
605
+ '800',
606
+ '900',
607
+ 'inherit'
608
+ ));
609
+ } else if ($group == 'text-decoration') {
610
+ $input->addOptions(array(
611
+ 'none',
612
+ 'underline',
613
+ 'overline',
614
+ 'line-through',
615
+ 'blink',
616
+ 'inherit'
617
+ ));
618
+ }
619
+ } else {
620
+ $input = new Input($element . '_' . $attribute, $name);
621
+ }
622
+ $input->addClass(self::ATTRIBUTE);
623
+ $input->addAttributes(array(
624
+ 'data-element' => $element,
625
+ 'data-attribute' => $attribute,
626
+ 'data-group' => $group
627
+ ));
628
+ return $input;
629
+ }
630
+
631
+ public static function createAttributesForm($atts) {
632
+ echo self::form($atts);
633
+ }
634
+
635
+ /**
636
+ * Saves the given theme id and css, making any necessary path and id changes to ensure the new theme is valid.
637
+ * Echos 0 on failure, 1 on success and 2 on success and if paths have changed.
638
+ */
639
+ public static function save($allow_edit_stock_theme = NULL) {
640
+ CrayonSettingsWP::load_settings();
641
+ $oldID = $_POST['id'];
642
+ $name = $_POST['name'];
643
+ $css = stripslashes($_POST['css']);
644
+ $change_settings = CrayonUtil::set_default($_POST['change_settings'], TRUE);
645
+ $allow_edit = CrayonUtil::set_default($_POST['allow_edit'], TRUE);
646
+ $allow_edit_stock_theme = CrayonUtil::set_default_null($allow_edit_stock_theme, CRAYON_DEBUG);
647
+ $delete = CrayonUtil::set_default($_POST['delete'], TRUE);
648
+ $oldTheme = CrayonResources::themes()->get($oldID);
649
+
650
+ if (!empty($oldID) && !empty($css) && !empty($name)) {
651
+ // By default, expect a user theme to be saved - prevents editing stock themes
652
+ // If in DEBUG mode, then allow editing stock themes.
653
+ $user = $oldTheme !== NULL && $allow_edit_stock_theme ? $oldTheme->user() : TRUE;
654
+ $oldPath = CrayonResources::themes()->path($oldID);
655
+ $oldDir = CrayonResources::themes()->dirpath($oldID);
656
+ $newID = CrayonResource::clean_id($name);
657
+ $newPath = CrayonResources::themes()->path($newID, $user);
658
+ $newDir = CrayonResources::themes()->dirpath($newID, $user);
659
+
660
+ $exists = CrayonResources::themes()->is_loaded($newID) || (is_file($newPath) && is_file($oldPath));
661
+ if ($exists && $oldPath != $newPath) {
662
+ // Never allow overwriting a theme with a different id!
663
+ echo -3;
664
+ exit();
665
+ }
666
+
667
+ if ($oldPath == $newPath && $allow_edit === FALSE) {
668
+ // Don't allow editing
669
+ echo -4;
670
+ exit();
671
+ }
672
+
673
+ // Create the new path if needed
674
+ if (!is_file($newPath)) {
675
+ if (!is_dir($newDir)) {
676
+ mkdir($newDir, 0777, TRUE);
677
+ try {
678
+ // Copy image folder
679
+ CrayonUtil::copyDir($oldDir . 'images', $newDir . 'images');
680
+ } catch (Exception $e) {
681
+ CrayonLog::syslog($e->getMessage(), "THEME SAVE");
682
+ }
683
+ }
684
+ }
685
+
686
+ $refresh = FALSE;
687
+ $replaceID = $oldID;
688
+ // Replace ids in the CSS
689
+ if (!is_file($oldPath) || strpos($css, CrayonThemes::CSS_PREFIX . $oldID) === FALSE) {
690
+ // The old path/id is no longer valid - something has gone wrong - we should refresh afterwards
691
+ $refresh = TRUE;
692
+ // Forces the ids to be updated
693
+ $replaceID = '[\w-]+';
694
+ }
695
+ // XXX This is case sensitive to avoid modifying text, but it means that CSS must be in lowercase
696
+ $css = preg_replace('#(?<=' . CrayonThemes::CSS_PREFIX . ')' . $replaceID . '\b#ms', $newID, $css);
697
+
698
+ // Replace the name with the new one
699
+ $info = self::getCSSInfo($css);
700
+ $info['name'] = $name;
701
+ $css = self::setCSSInfo($css, $info);
702
+
703
+ $result = @file_put_contents($newPath, $css);
704
+ $success = $result !== FALSE;
705
+ if ($success && $oldPath !== $newPath) {
706
+ if ($oldID !== CrayonThemes::DEFAULT_THEME && $delete) {
707
+ // Only delete the old path if it isn't the default theme
708
+ try {
709
+ // Delete the old path
710
+ CrayonUtil::deleteDir($oldDir);
711
+ } catch (Exception $e) {
712
+ CrayonLog::syslog($e->getMessage(), "THEME SAVE");
713
+ }
714
+ }
715
+ // Refresh
716
+ echo 2;
717
+ } else {
718
+ if ($refresh) {
719
+ echo 2;
720
+ } else {
721
+ if ($success) {
722
+ echo 1;
723
+ } else {
724
+ echo -2;
725
+ }
726
+ }
727
+ }
728
+ // Set the new theme in settings
729
+ if ($change_settings) {
730
+ CrayonGlobalSettings::set(CrayonSettings::THEME, $newID);
731
+ CrayonSettingsWP::save_settings();
732
+ }
733
+ } else {
734
+ CrayonLog::syslog("$oldID=$oldID\n\n$name=$name", "THEME SAVE");
735
+ echo -1;
736
+ }
737
+ exit();
738
+ }
739
+
740
+ public static function duplicate() {
741
+ CrayonSettingsWP::load_settings();
742
+ $oldID = $_POST['id'];
743
+ $oldPath = CrayonResources::themes()->path($oldID);
744
+ $_POST['css'] = file_get_contents($oldPath);
745
+ $_POST['delete'] = FALSE;
746
+ $_POST['allow_edit'] = FALSE;
747
+ self::save(FALSE);
748
+ }
749
+
750
+ public static function delete() {
751
+ CrayonSettingsWP::load_settings();
752
+ $id = $_POST['id'];
753
+ $dir = CrayonResources::themes()->dirpath($id);
754
+ if (is_dir($dir) && CrayonResources::themes()->exists($id)) {
755
+ try {
756
+ CrayonUtil::deleteDir($dir);
757
+ CrayonGlobalSettings::set(CrayonSettings::THEME, CrayonThemes::DEFAULT_THEME);
758
+ CrayonSettingsWP::save_settings();
759
+ echo 1;
760
+ } catch (Exception $e) {
761
+ CrayonLog::syslog($e->getMessage(), "THEME SAVE");
762
+ echo -2;
763
+ }
764
+ } else {
765
+ echo -1;
766
+ }
767
+ exit();
768
+ }
769
+
770
+ public static function submit() {
771
+ global $CRAYON_EMAIL;
772
+ CrayonSettingsWP::load_settings();
773
+ $id = $_POST['id'];
774
+ $message = $_POST['message'];
775
+ $dir = CrayonResources::themes()->dirpath($id);
776
+ $dest = $dir . 'tmp';
777
+ @mkdir($dest);
778
+
779
+ if (is_dir($dir) && CrayonResources::themes()->exists($id)) {
780
+ try {
781
+ $zipFile = CrayonUtil::createZip($dir, $dest, TRUE);
782
+ $result = CrayonUtil::emailFile(array(
783
+ 'to' => $CRAYON_EMAIL,
784
+ 'from' => get_bloginfo('admin_email'),
785
+ 'subject' => 'Theme Editor Submission',
786
+ 'message' => $message,
787
+ 'file' => $zipFile
788
+ ));
789
+ CrayonUtil::deleteDir($dest);
790
+ if ($result) {
791
+ echo 1;
792
+ } else {
793
+ echo -3;
794
+ }
795
+ } catch (Exception $e) {
796
+ CrayonLog::syslog($e->getMessage(), "THEME SUBMIT");
797
+ echo -2;
798
+ }
799
+ } else {
800
+ echo -1;
801
+ }
802
+ exit();
803
+ }
804
+
805
+ public static function getCSSInfo($css) {
806
+ $info = array();
807
+ preg_match(self::RE_COMMENT, $css, $matches);
808
+ if (count($matches)) {
809
+ $comment = $matches[0];
810
+ preg_match_all('#([^\r\n:]*[^\r\n\s:])\s*:\s*([^\r\n]+)#msi', $comment, $matches);
811
+ if (count($matches)) {
812
+ for ($i = 0; $i < count($matches[1]); $i++) {
813
+ $name = $matches[1][$i];
814
+ $value = $matches[2][$i];
815
+ $info[self::getFieldID($name)] = $value;
816
+ }
817
+ }
818
+ }
819
+ return $info;
820
+ }
821
+
822
+ public static function cssInfoToString($info) {
823
+ $str = "/*\n";
824
+ foreach ($info as $id => $value) {
825
+ $str .= self::getFieldName($id) . ': ' . $value . "\n";
826
+ }
827
+ $str .= "*/";
828
+ return $str;
829
+ }
830
+
831
+ public static function setCSSInfo($css, $info) {
832
+ return preg_replace(self::RE_COMMENT, self::cssInfoToString($info), $css);
833
+ }
834
+
835
+ public static function getFieldID($name) {
836
+ if (isset(self::$infoFieldsInverse[$name])) {
837
+ return self::$infoFieldsInverse[$name];
838
+ } else {
839
+ return CrayonUserResource::clean_id($name);
840
+ }
841
+ }
842
+
843
+ public static function getFieldName($id) {
844
+ if (isset(self::$infoFields[$id])) {
845
+ return self::$infoFields[$id];
846
+ } else {
847
+ return CrayonUserResource::clean_name($id);
848
+ }
849
+ }
850
+
851
+ public static function getAttributeGroup($attribute) {
852
+ if (isset(self::$attributeGroupsInverse[$attribute])) {
853
+ return self::$attributeGroupsInverse[$attribute];
854
+ } else {
855
+ return $attribute;
856
+ }
857
+ }
858
+
859
+ public static function getAttributeType($group) {
860
+ if (isset(self::$attributeTypesInverse[$group])) {
861
+ return self::$attributeTypesInverse[$group];
862
+ } else {
863
+ return 'text';
864
+ }
865
+ }
866
 
867
  }
868
 
869
  if (defined('ABSPATH') && is_admin()) {
870
+ add_action('init', 'CrayonThemeEditorWP::init');
871
  }
872
 
873
  ?>
util/theme-editor/theme_editor_content.php DELETED
@@ -1,109 +0,0 @@
1
- <?php
2
-
3
- // TODO this needs lots of work! remove the old wp_load procedure
4
-
5
- require_once('../../crayon_wp.class.php');
6
- $theme = CrayonResources::themes()->get_default();
7
- $editing = false;
8
-
9
- if ( isset($_GET['curr_theme']) ) {
10
- $theme = CrayonResources::themes()->get($_GET['curr_theme']);
11
- }
12
-
13
- if ( isset($_GET['editing']) ) {
14
- $editing = CrayonUtil::str_to_bool($_GET['editing'], FALSE);
15
- }
16
-
17
- ?>
18
-
19
- <div
20
- id="icon-options-general" class="icon32"></div>
21
- <h2>
22
- Crayon Syntax Highlighter
23
- <?php crayon_e('Theme Editor'); ?>
24
- </h2>
25
-
26
- <h3>
27
- <?php
28
- if ($editing) {
29
- echo sprintf(crayon__('Editing "%s" Theme'), $theme->name());
30
- } else {
31
- echo sprintf(crayon__('Creating Theme From "%s"'), $theme->name());
32
- }
33
- ?>
34
- </h3>
35
-
36
- <p>
37
- <a class="button-primary" onclick="CrayonSyntaxAdmin.show_main();"><?php crayon_e('Back To Settings'); ?>
38
- </a>
39
- </p>
40
-
41
- <?php //crayon_e('Use the Sidebar on the right to change the Theme of the Preview window.') ?>
42
-
43
- <div
44
- id="crayon-editor-top-controls"></div>
45
-
46
- <table id="crayon-editor-table" style="width: 100%;" cellspacing="5"
47
- cellpadding="0">
48
- <tr>
49
- <td id="crayon-editor-preview-wrapper">
50
- <div id="crayon-editor-preview"></div>
51
- </td>
52
- </tr>
53
- <tr>
54
- <td id="crayon-editor-control-wrapper">
55
- <div id="crayon-editor-controls">
56
- <ul>
57
- <li><a href="#tabs-1">Nunc tincidunt</a></li>
58
- <li><a href="#tabs-2">Proin dolor</a></li>
59
- <li><a href="#tabs-3">Aenean lacinia</a></li>
60
- </ul>
61
- <div id="tabs-1">
62
- <p>Proin elit arcu, rutrum commodo, vehicula tempus, commodo a,
63
- risus. Curabitur nec arcu. Donec sollicitudin mi sit amet mauris.
64
- Nam elementum quam ullamcorper ante. Etiam aliquet massa et lorem.
65
- Mauris dapibus lacus auctor risus. Aenean tempor ullamcorper leo.
66
- Vivamus sed magna quis ligula eleifend adipiscing. Duis orci.
67
- Aliquam sodales tortor vitae ipsum. Aliquam nulla. Duis aliquam
68
- molestie erat. Ut et mauris vel pede varius sollicitudin. Sed ut
69
- dolor nec orci tincidunt interdum. Phasellus ipsum. Nunc tristique
70
- tempus lectus.</p>
71
- </div>
72
- <div id="tabs-2">
73
- <p>Morbi tincidunt, dui sit amet facilisis feugiat, odio metus
74
- gravida ante, ut pharetra massa metus id nunc. Duis scelerisque
75
- molestie turpis. Sed fringilla, massa eget luctus malesuada, metus
76
- eros molestie lectus, ut tempus eros massa ut dolor. Aenean
77
- aliquet fringilla sem. Suspendisse sed ligula in ligula suscipit
78
- aliquam. Praesent in eros vestibulum mi adipiscing adipiscing.
79
- Morbi facilisis. Curabitur ornare consequat nunc. Aenean vel
80
- metus. Ut posuere viverra nulla. Aliquam erat volutpat.
81
- Pellentesque convallis. Maecenas feugiat, tellus pellentesque
82
- pretium posuere, felis lorem euismod felis, eu ornare leo nisi vel
83
- felis. Mauris consectetur tortor et purus.</p>
84
- </div>
85
- <div id="tabs-3">
86
- <p>Mauris eleifend est et turpis. Duis id erat. Suspendisse
87
- potenti. Aliquam vulputate, pede vel vehicula accumsan, mi neque
88
- rutrum erat, eu congue orci lorem eget lorem. Vestibulum non ante.
89
- Class aptent taciti sociosqu ad litora torquent per conubia
90
- nostra, per inceptos himenaeos. Fusce sodales. Quisque eu urna vel
91
- enim commodo pellentesque. Praesent eu risus hendrerit ligula
92
- tempus pretium. Curabitur lorem enim, pretium nec, feugiat nec,
93
- luctus a, lacus.</p>
94
- <p>Duis cursus. Maecenas ligula eros, blandit nec, pharetra at,
95
- semper at, magna. Nullam ac lacus. Nulla facilisi. Praesent
96
- viverra justo vitae neque. Praesent blandit adipiscing velit.
97
- Suspendisse potenti. Donec mattis, pede vel pharetra blandit,
98
- magna ligula faucibus eros, id euismod lacus dolor eget odio. Nam
99
- scelerisque. Donec non libero sed nulla mattis commodo. Ut
100
- sagittis. Donec nisi lectus, feugiat porttitor, tempor ac, tempor
101
- vitae, pede. Aenean vehicula velit eu tellus interdum rutrum.
102
- Maecenas commodo. Pellentesque nec elit. Fusce in lacus. Vivamus a
103
- libero vitae lectus hendrerit hendrerit.</p>
104
- </div>
105
- </div>
106
- </td>
107
- </tr>
108
-
109
- </table>