Version Description
- Fixed an issue with IE 8 throwing JS errors for setStyleProperty
- Fixed yet another issue with \r\n causing incorrect span tags, refactored code.
Download this release
Release Info
Developer | akarmenia |
Plugin | Crayon Syntax Highlighter |
Version | 1.9.11 |
Comparing to | |
See all releases |
Code changes from version 1.9.10 to 1.9.11
- crayon_formatter.class.php +23 -9
- crayon_settings_wp.class.php +12 -6
- crayon_wp.class.php +3 -2
- css/admin_style.css +8 -7
- global.php +11 -3
- js/crayon.js +207 -198
- js/crayon_admin.js +38 -30
- js/cssjson.js +163 -0
- js/util.js +3 -2
- readme.txt +5 -1
- util/tag-editor/crayon_tag_editor_wp.class.php +1 -1
- util/tag-editor/crayon_te_content.php +1 -2
- util/theme-editor/editor.js +0 -96
- util/theme-editor/editor.php +0 -38
- util/theme-editor/theme_editor.css +11 -0
- util/theme-editor/theme_editor.js +96 -0
- util/theme-editor/theme_editor.php +26 -0
- util/theme-editor/theme_editor_content.php +57 -0
crayon_formatter.class.php
CHANGED
@@ -27,6 +27,9 @@ class CrayonFormatter {
|
|
27 |
public static function format_code($code, $language, $hl = NULL) {
|
28 |
// Ensure the language is defined
|
29 |
if ($language != NULL && $hl->is_highlighted) {
|
|
|
|
|
|
|
30 |
/* Perform the replace on the code using the regex, pass the captured matches for
|
31 |
formatting before they are replaced */
|
32 |
try {
|
@@ -46,7 +49,7 @@ class CrayonFormatter {
|
|
46 |
|
47 |
return $code;
|
48 |
} else {
|
49 |
-
return self::clean_code($code);
|
50 |
}
|
51 |
}
|
52 |
|
@@ -490,19 +493,25 @@ class CrayonFormatter {
|
|
490 |
|
491 |
// Auxiliary Methods ======================================================
|
492 |
/* Prepares code for formatting. */
|
493 |
-
public static function clean_code($code, $spaces =
|
494 |
if (empty($code)) {
|
495 |
return $code;
|
496 |
}
|
497 |
/* Convert <, > and & characters to entities, as these can appear as HTML tags and entities. */
|
498 |
-
|
|
|
|
|
499 |
if ($spaces) {
|
500 |
// Replace 2 spaces with html escaped characters
|
501 |
$code = preg_replace('#[ ]{2}#msi', ' ', $code);
|
502 |
}
|
503 |
-
|
504 |
-
|
505 |
-
|
|
|
|
|
|
|
|
|
506 |
return $code;
|
507 |
}
|
508 |
|
@@ -520,9 +529,14 @@ class CrayonFormatter {
|
|
520 |
}
|
521 |
|
522 |
public static function split_lines($code, $class) {
|
523 |
-
|
524 |
-
|
525 |
-
|
|
|
|
|
|
|
|
|
|
|
526 |
return $code;
|
527 |
}
|
528 |
|
27 |
public static function format_code($code, $language, $hl = NULL) {
|
28 |
// Ensure the language is defined
|
29 |
if ($language != NULL && $hl->is_highlighted) {
|
30 |
+
|
31 |
+
$code = self::clean_code($code, FALSE, FALSE, FALSE, TRUE);
|
32 |
+
|
33 |
/* Perform the replace on the code using the regex, pass the captured matches for
|
34 |
formatting before they are replaced */
|
35 |
try {
|
49 |
|
50 |
return $code;
|
51 |
} else {
|
52 |
+
return self::clean_code($code, TRUE, TRUE, TRUE, TRUE);
|
53 |
}
|
54 |
}
|
55 |
|
493 |
|
494 |
// Auxiliary Methods ======================================================
|
495 |
/* Prepares code for formatting. */
|
496 |
+
public static function clean_code($code, $escape = TRUE, $spaces = FALSE, $tabs = FALSE, $lines = FALSE) {
|
497 |
if (empty($code)) {
|
498 |
return $code;
|
499 |
}
|
500 |
/* Convert <, > and & characters to entities, as these can appear as HTML tags and entities. */
|
501 |
+
if ($escape) {
|
502 |
+
$code = CrayonUtil::htmlspecialchars($code);
|
503 |
+
}
|
504 |
if ($spaces) {
|
505 |
// Replace 2 spaces with html escaped characters
|
506 |
$code = preg_replace('#[ ]{2}#msi', ' ', $code);
|
507 |
}
|
508 |
+
if ($tabs) {
|
509 |
+
// Replace tabs with 4 spaces
|
510 |
+
$code = preg_replace('#\t#', str_repeat(' ', CrayonGlobalSettings::val(CrayonSettings::TAB_SIZE)), $code);
|
511 |
+
}
|
512 |
+
if ($lines) {
|
513 |
+
$code = preg_replace('#(\r\n)|\r|\n#msi', "\r\n", $code);
|
514 |
+
}
|
515 |
return $code;
|
516 |
}
|
517 |
|
529 |
}
|
530 |
|
531 |
public static function split_lines($code, $class) {
|
532 |
+
|
533 |
+
// var_dump($code);
|
534 |
+
// exit;
|
535 |
+
|
536 |
+
$code = self::clean_code($code, TRUE, TRUE, TRUE, FALSE);
|
537 |
+
// $code = preg_replace('#^[^\r\n]+#m', '<span class="'.$class.'">', $code);
|
538 |
+
// $code = preg_replace('#(?<=[^\r\n])(?=\r\n|\r|\n)#m', '</span>', $code);
|
539 |
+
$code = preg_replace('#^([^\r\n]+)(?=\r\n|\r|\n|$)#m', '<span class="'.$class.'">$1</span>', $code);
|
540 |
return $code;
|
541 |
}
|
542 |
|
crayon_settings_wp.class.php
CHANGED
@@ -63,24 +63,26 @@ class CrayonSettingsWP {
|
|
63 |
public static function admin_styles() {
|
64 |
global $CRAYON_VERSION;
|
65 |
wp_enqueue_style('crayon_admin_style', plugins_url(CRAYON_STYLE_ADMIN, __FILE__), array(), $CRAYON_VERSION);
|
|
|
66 |
}
|
67 |
|
68 |
public static function admin_scripts() {
|
69 |
global $CRAYON_VERSION;
|
70 |
-
//wp_enqueue_script('crayon_jquery', plugins_url(CRAYON_JQUERY, __FILE__), array(), $CRAYON_VERSION);
|
71 |
wp_enqueue_script('crayon_util_js', plugins_url(CRAYON_JS_UTIL, __FILE__), array('jquery'), $CRAYON_VERSION);
|
72 |
wp_enqueue_script('crayon_admin_js', plugins_url(CRAYON_JS_ADMIN, __FILE__), array('jquery', 'crayon_util_js'), $CRAYON_VERSION);
|
73 |
wp_enqueue_script('crayon_jquery_popup', plugins_url(CRAYON_JQUERY_POPUP, __FILE__), array('jquery'), $CRAYON_VERSION);
|
|
|
74 |
wp_enqueue_script('crayon_js', plugins_url(CRAYON_JS, __FILE__), array('jquery', 'crayon_jquery_popup', 'crayon_util_js'), $CRAYON_VERSION);
|
75 |
if (CRAYON_THEME_EDITOR) {
|
76 |
-
wp_enqueue_script('crayon_theme_editor', plugins_url(CRAYON_THEME_EDITOR_JS, __FILE__), array('jquery'), $CRAYON_VERSION);
|
77 |
}
|
78 |
-
// Must come after
|
79 |
self::init_js_settings();
|
80 |
}
|
81 |
|
82 |
public static function init_js_settings() {
|
83 |
// TODO Create a global CrayonSyntaxSettings object here
|
|
|
84 |
if (!self::$js_settings) {
|
85 |
self::$js_settings = array(
|
86 |
'prefix' => CrayonSettings::PREFIX,
|
@@ -88,10 +90,11 @@ class CrayonSettingsWP {
|
|
88 |
'selected' => CrayonSettings::SETTING_SELECTED,
|
89 |
'changed' => CrayonSettings::SETTING_CHANGED,
|
90 |
'special' => CrayonSettings::SETTING_SPECIAL,
|
91 |
-
'orig_value' => CrayonSettings::SETTING_ORIG_VALUE
|
92 |
);
|
93 |
}
|
94 |
wp_localize_script('crayon_admin_js', 'CrayonSyntaxSettings', self::$js_settings);
|
|
|
95 |
}
|
96 |
|
97 |
public static function settings() {
|
@@ -138,7 +141,7 @@ class CrayonSettingsWP {
|
|
138 |
</form>
|
139 |
</div>
|
140 |
|
141 |
-
<div id="crayon-theme-editor-wrap" class="wrap" url="<?php echo plugins_url(
|
142 |
|
143 |
<?php
|
144 |
}
|
@@ -620,7 +623,10 @@ class CrayonSettingsWP {
|
|
620 |
}
|
621 |
// Theme editor
|
622 |
if (CRAYON_THEME_EDITOR) {
|
623 |
-
|
|
|
|
|
|
|
624 |
}
|
625 |
// Preview Box
|
626 |
echo '<div id="crayon-live-preview" url="', plugins_url(CRAYON_PREVIEW_PHP, __FILE__), '"></div>';
|
63 |
public static function admin_styles() {
|
64 |
global $CRAYON_VERSION;
|
65 |
wp_enqueue_style('crayon_admin_style', plugins_url(CRAYON_STYLE_ADMIN, __FILE__), array(), $CRAYON_VERSION);
|
66 |
+
wp_enqueue_style('crayon_theme_editor_style', plugins_url(CRAYON_THEME_EDITOR_STYLE, __FILE__), array(), $CRAYON_VERSION);
|
67 |
}
|
68 |
|
69 |
public static function admin_scripts() {
|
70 |
global $CRAYON_VERSION;
|
|
|
71 |
wp_enqueue_script('crayon_util_js', plugins_url(CRAYON_JS_UTIL, __FILE__), array('jquery'), $CRAYON_VERSION);
|
72 |
wp_enqueue_script('crayon_admin_js', plugins_url(CRAYON_JS_ADMIN, __FILE__), array('jquery', 'crayon_util_js'), $CRAYON_VERSION);
|
73 |
wp_enqueue_script('crayon_jquery_popup', plugins_url(CRAYON_JQUERY_POPUP, __FILE__), array('jquery'), $CRAYON_VERSION);
|
74 |
+
wp_enqueue_script('cssjson_js', plugins_url(CRAYON_CSSJSON_JS, __FILE__), $CRAYON_VERSION);
|
75 |
wp_enqueue_script('crayon_js', plugins_url(CRAYON_JS, __FILE__), array('jquery', 'crayon_jquery_popup', 'crayon_util_js'), $CRAYON_VERSION);
|
76 |
if (CRAYON_THEME_EDITOR) {
|
77 |
+
wp_enqueue_script('crayon_theme_editor', plugins_url(CRAYON_THEME_EDITOR_JS, __FILE__), array('jquery', 'cssjson_js'), $CRAYON_VERSION);
|
78 |
}
|
79 |
+
// XXX Must come after
|
80 |
self::init_js_settings();
|
81 |
}
|
82 |
|
83 |
public static function init_js_settings() {
|
84 |
// TODO Create a global CrayonSyntaxSettings object here
|
85 |
+
self::load_settings(TRUE);
|
86 |
if (!self::$js_settings) {
|
87 |
self::$js_settings = array(
|
88 |
'prefix' => CrayonSettings::PREFIX,
|
90 |
'selected' => CrayonSettings::SETTING_SELECTED,
|
91 |
'changed' => CrayonSettings::SETTING_CHANGED,
|
92 |
'special' => CrayonSettings::SETTING_SPECIAL,
|
93 |
+
'orig_value' => CrayonSettings::SETTING_ORIG_VALUE
|
94 |
);
|
95 |
}
|
96 |
wp_localize_script('crayon_admin_js', 'CrayonSyntaxSettings', self::$js_settings);
|
97 |
+
CrayonThemeEditorWP::admin_scripts();
|
98 |
}
|
99 |
|
100 |
public static function settings() {
|
141 |
</form>
|
142 |
</div>
|
143 |
|
144 |
+
<div id="crayon-theme-editor-wrap" class="wrap" url="<?php echo plugins_url(CRAYON_THEME_EDITOR_CONTENT_PHP, __FILE__); ?>"></div>
|
145 |
|
146 |
<?php
|
147 |
}
|
623 |
}
|
624 |
// Theme editor
|
625 |
if (CRAYON_THEME_EDITOR) {
|
626 |
+
// 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>';
|
627 |
+
echo '<div id="crayon-theme-editor-admin-buttons">',
|
628 |
+
'<a id="crayon-theme-editor-edit-button" class="button-primary crayon-admin-button" loading="', crayon__('Loading...'), '" loaded="', crayon__('Edit'), '" >', crayon__('Edit'), '</a>',
|
629 |
+
'<a id="crayon-theme-editor-create-button" class="button-primary crayon-admin-button" loading="', crayon__('Loading...'), '" loaded="', crayon__('Create'), '" >', crayon__('Create'), '</a></br></div>';
|
630 |
}
|
631 |
// Preview Box
|
632 |
echo '<div id="crayon-live-preview" url="', plugins_url(CRAYON_PREVIEW_PHP, __FILE__), '"></div>';
|
crayon_wp.class.php
CHANGED
@@ -3,7 +3,7 @@
|
|
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.9.
|
7 |
Author: Aram Kocharyan
|
8 |
Author URI: http://ak.net84.net/
|
9 |
Text Domain: crayon-syntax-highlighter
|
@@ -25,7 +25,8 @@ License: GPL2
|
|
25 |
*/
|
26 |
require_once ('global.php');
|
27 |
require_once (CRAYON_HIGHLIGHTER_PHP);
|
28 |
-
require_once (
|
|
|
29 |
require_once ('crayon_settings_wp.class.php');
|
30 |
|
31 |
if (defined('ABSPATH')) {
|
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.9.11
|
7 |
Author: Aram Kocharyan
|
8 |
Author URI: http://ak.net84.net/
|
9 |
Text Domain: crayon-syntax-highlighter
|
25 |
*/
|
26 |
require_once ('global.php');
|
27 |
require_once (CRAYON_HIGHLIGHTER_PHP);
|
28 |
+
require_once (CRAYON_TE_PHP);
|
29 |
+
require_once (CRAYON_THEME_EDITOR_PHP);
|
30 |
require_once ('crayon_settings_wp.class.php');
|
31 |
|
32 |
if (defined('ABSPATH')) {
|
css/admin_style.css
CHANGED
@@ -175,15 +175,16 @@
|
|
175 |
text-align: center;
|
176 |
}
|
177 |
|
178 |
-
#crayon-editor-
|
179 |
-
|
180 |
}
|
181 |
-
|
182 |
-
|
|
|
183 |
}
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
}
|
188 |
|
189 |
#gmail-icon, #twitter-icon, #donate-icon {
|
175 |
text-align: center;
|
176 |
}
|
177 |
|
178 |
+
#crayon-theme-editor-admin-buttons {
|
179 |
+
display: inline;
|
180 |
}
|
181 |
+
|
182 |
+
#crayon-theme-editor-admin-buttons .crayon-admin-button {
|
183 |
+
margin-left: 5px;
|
184 |
}
|
185 |
+
|
186 |
+
#crayon-editor-table td {
|
187 |
+
vertical-align: top;
|
188 |
}
|
189 |
|
190 |
#gmail-icon, #twitter-icon, #donate-icon {
|
global.php
CHANGED
@@ -51,6 +51,8 @@ define('CRAYON_LANG_PATH', CRAYON_ROOT_PATH . CRAYON_LANG_DIR);
|
|
51 |
define('CRAYON_THEME_PATH', CRAYON_ROOT_PATH . CRAYON_THEME_DIR);
|
52 |
define('CRAYON_FONT_PATH', CRAYON_ROOT_PATH . CRAYON_FONT_DIR);
|
53 |
define('CRAYON_UTIL_PATH', CRAYON_ROOT_PATH . CRAYON_UTIL_DIR);
|
|
|
|
|
54 |
|
55 |
// Files
|
56 |
|
@@ -68,16 +70,23 @@ define('CRAYON_JQUERY_POPUP', CRAYON_JS_DIR . 'jquery.popup.js');
|
|
68 |
define('CRAYON_JS', CRAYON_JS_DIR . 'crayon.js');
|
69 |
define('CRAYON_JS_ADMIN', CRAYON_JS_DIR . 'crayon_admin.js');
|
70 |
define('CRAYON_JS_UTIL', CRAYON_JS_DIR . 'util.js');
|
|
|
|
|
71 |
define('CRAYON_TE_JS', 'crayon_te.js');
|
72 |
-
define('CRAYON_TE_PHP', '
|
|
|
|
|
73 |
define('CRAYON_TINYMCE_JS', 'crayon_tinymce.js');
|
74 |
define('CRAYON_QUICKTAGS_JS', 'crayon_qt.js');
|
75 |
define('CRAYON_STYLE', CRAYON_CSS_DIR . 'style.css');
|
76 |
define('CRAYON_STYLE_ADMIN', CRAYON_CSS_DIR . 'admin_style.css');
|
77 |
define('CRAYON_LOGO', CRAYON_CSS_DIR . 'images/crayon_logo.png');
|
78 |
define('CRAYON_DONATE_BUTTON', CRAYON_CSS_DIR . 'images/donate.png');
|
|
|
|
|
|
|
|
|
79 |
define('CRAYON_THEME_EDITOR_BUTTON', CRAYON_CSS_DIR . 'images/theme_editor.png');
|
80 |
-
define('CRAYON_THEME_EDITOR_JS', CRAYON_UTIL_DIR . CRAYON_THEME_EDITOR_DIR . 'editor.js');
|
81 |
|
82 |
// PHP Files
|
83 |
define('CRAYON_FORMATTER_PHP', CRAYON_ROOT_PATH . 'crayon_formatter.class.php');
|
@@ -95,7 +104,6 @@ define('CRAYON_LOG_PHP', CRAYON_UTIL_DIR . 'crayon_log.class.php');
|
|
95 |
define('CRAYON_LIST_LANGS_PHP', CRAYON_UTIL_DIR . 'list_langs.php');
|
96 |
define('CRAYON_PREVIEW_PHP', CRAYON_UTIL_DIR . 'preview.php');
|
97 |
define('CRAYON_AJAX_PHP', CRAYON_UTIL_DIR . 'ajax.php');
|
98 |
-
define('CRAYON_THEME_EDITOR_PHP', CRAYON_UTIL_DIR . CRAYON_THEME_EDITOR_DIR . 'editor.php');
|
99 |
|
100 |
// Script time
|
101 |
|
51 |
define('CRAYON_THEME_PATH', CRAYON_ROOT_PATH . CRAYON_THEME_DIR);
|
52 |
define('CRAYON_FONT_PATH', CRAYON_ROOT_PATH . CRAYON_FONT_DIR);
|
53 |
define('CRAYON_UTIL_PATH', CRAYON_ROOT_PATH . CRAYON_UTIL_DIR);
|
54 |
+
define('CRAYON_TAG_EDITOR_PATH', CRAYON_ROOT_PATH . CRAYON_UTIL_DIR . CRAYON_TAG_EDITOR_DIR);
|
55 |
+
define('CRAYON_THEME_EDITOR_PATH', CRAYON_ROOT_PATH . CRAYON_UTIL_DIR . CRAYON_THEME_EDITOR_DIR);
|
56 |
|
57 |
// Files
|
58 |
|
70 |
define('CRAYON_JS', CRAYON_JS_DIR . 'crayon.js');
|
71 |
define('CRAYON_JS_ADMIN', CRAYON_JS_DIR . 'crayon_admin.js');
|
72 |
define('CRAYON_JS_UTIL', CRAYON_JS_DIR . 'util.js');
|
73 |
+
define('CRAYON_CSSJSON_JS', CRAYON_JS_DIR . 'cssjson.js');
|
74 |
+
// TODO rename TE
|
75 |
define('CRAYON_TE_JS', 'crayon_te.js');
|
76 |
+
define('CRAYON_TE_PHP', CRAYON_TAG_EDITOR_PATH . 'crayon_tag_editor_wp.class.php');
|
77 |
+
// TODO Fix these
|
78 |
+
define('CRAYON_TE_CONTENT_PHP', 'crayon_te_content.php');
|
79 |
define('CRAYON_TINYMCE_JS', 'crayon_tinymce.js');
|
80 |
define('CRAYON_QUICKTAGS_JS', 'crayon_qt.js');
|
81 |
define('CRAYON_STYLE', CRAYON_CSS_DIR . 'style.css');
|
82 |
define('CRAYON_STYLE_ADMIN', CRAYON_CSS_DIR . 'admin_style.css');
|
83 |
define('CRAYON_LOGO', CRAYON_CSS_DIR . 'images/crayon_logo.png');
|
84 |
define('CRAYON_DONATE_BUTTON', CRAYON_CSS_DIR . 'images/donate.png');
|
85 |
+
define('CRAYON_THEME_EDITOR_PHP', CRAYON_THEME_EDITOR_PATH . 'theme_editor.php');
|
86 |
+
define('CRAYON_THEME_EDITOR_CONTENT_PHP', CRAYON_UTIL_DIR . CRAYON_THEME_EDITOR_DIR . 'theme_editor_content.php');
|
87 |
+
define('CRAYON_THEME_EDITOR_JS', CRAYON_UTIL_DIR . CRAYON_THEME_EDITOR_DIR . 'theme_editor.js');
|
88 |
+
define('CRAYON_THEME_EDITOR_STYLE', CRAYON_UTIL_DIR . CRAYON_THEME_EDITOR_DIR . 'theme_editor.css');
|
89 |
define('CRAYON_THEME_EDITOR_BUTTON', CRAYON_CSS_DIR . 'images/theme_editor.png');
|
|
|
90 |
|
91 |
// PHP Files
|
92 |
define('CRAYON_FORMATTER_PHP', CRAYON_ROOT_PATH . 'crayon_formatter.class.php');
|
104 |
define('CRAYON_LIST_LANGS_PHP', CRAYON_UTIL_DIR . 'list_langs.php');
|
105 |
define('CRAYON_PREVIEW_PHP', CRAYON_UTIL_DIR . 'preview.php');
|
106 |
define('CRAYON_AJAX_PHP', CRAYON_UTIL_DIR . 'ajax.php');
|
|
|
107 |
|
108 |
// Script time
|
109 |
|
js/crayon.js
CHANGED
@@ -57,7 +57,7 @@ jQuery.fn.style = function(styleName, value, priority) {
|
|
57 |
if (typeof value != 'undefined') {
|
58 |
// Set style property
|
59 |
var priority = typeof priority != 'undefined' ? priority : '';
|
60 |
-
if (
|
61 |
style.setProperty(styleName, value, priority);
|
62 |
} else {
|
63 |
style.styleName = value + ' ' + priority;
|
@@ -109,205 +109,214 @@ var CrayonSyntax = new function() {
|
|
109 |
}
|
110 |
|
111 |
jQuery(CRAYON_SYNTAX).each(function() {
|
112 |
-
|
113 |
-
if (uid == 'crayon-') {
|
114 |
-
// No ID, generate one
|
115 |
-
uid += getUID();
|
116 |
-
}
|
117 |
-
jQuery(this).attr('id', uid);
|
118 |
-
console_log(uid);
|
119 |
-
|
120 |
-
if (!make_uid(uid)) {
|
121 |
-
// Already a Crayon
|
122 |
-
return;
|
123 |
-
}
|
124 |
-
|
125 |
-
var toolbar = jQuery(this).find(CRAYON_TOOLBAR);
|
126 |
-
var info = jQuery(this).find(CRAYON_INFO);
|
127 |
-
var plain = jQuery(this).find(CRAYON_PLAIN);
|
128 |
-
var main = jQuery(this).find(CRAYON_MAIN);
|
129 |
-
var table = jQuery(this).find(CRAYON_TABLE);
|
130 |
-
var code = jQuery(this).find(CRAYON_CODE);
|
131 |
-
var nums = jQuery(this).find(CRAYON_NUMS);
|
132 |
-
var nums_content = jQuery(this).find(CRAYON_NUMS_CONTENT);
|
133 |
-
var nums_button = jQuery(this).find(CRAYON_NUMS_BUTTON);
|
134 |
-
var popup_button = jQuery(this).find(CRAYON_POPUP_BUTTON);
|
135 |
-
var copy_button = jQuery(this).find(CRAYON_COPY_BUTTON);
|
136 |
-
var plain_button = jQuery(this).find(CRAYON_PLAIN_BUTTON);
|
137 |
-
|
138 |
-
crayon[uid] = jQuery(this);
|
139 |
-
crayon[uid].toolbar = toolbar;
|
140 |
-
crayon[uid].plain = plain;
|
141 |
-
crayon[uid].info = info;
|
142 |
-
crayon[uid].main = main;
|
143 |
-
crayon[uid].table = table;
|
144 |
-
crayon[uid].code = code;
|
145 |
-
crayon[uid].nums = nums;
|
146 |
-
crayon[uid].nums_content = nums_content;
|
147 |
-
crayon[uid].nums_button = nums_button;
|
148 |
-
crayon[uid].popup_button = popup_button;
|
149 |
-
crayon[uid].copy_button = copy_button;
|
150 |
-
crayon[uid].plain_button = plain_button;
|
151 |
-
crayon[uid].nums_visible = true;
|
152 |
-
crayon[uid].plain_visible = false;
|
153 |
-
|
154 |
-
crayon[uid].toolbar_delay = 0;
|
155 |
-
crayon[uid].time = 1;
|
156 |
-
|
157 |
-
// Set plain
|
158 |
-
jQuery(CRAYON_PLAIN).css('z-index', 0);
|
159 |
-
|
160 |
-
// XXX Remember CSS dimensions
|
161 |
-
var main_style = main.style();
|
162 |
-
crayon[uid].main_style = {
|
163 |
-
height: main_style && main_style.height || '',
|
164 |
-
max_height: main_style && main_style.maxHeight || '',
|
165 |
-
min_height: main_style && main_style.minHeight || '',
|
166 |
-
width: main_style && main_style.width || ''
|
167 |
-
};
|
168 |
-
|
169 |
-
var load_timer;
|
170 |
-
var i = 0;
|
171 |
-
crayon[uid].loading = true;
|
172 |
-
crayon[uid].scroll_block_fix = false;
|
173 |
-
|
174 |
-
// Register click events
|
175 |
-
nums_button.click(function() { CrayonSyntax.toggle_nums(uid); });
|
176 |
-
plain_button.click(function() { CrayonSyntax.toggle_plain(uid); });
|
177 |
-
copy_button.click(function() { CrayonSyntax.copy_plain(uid); });
|
178 |
-
|
179 |
-
var load_func = function() {
|
180 |
-
if (main.height() < 30) {
|
181 |
-
crayon[uid].scroll_block_fix = true;
|
182 |
-
}
|
183 |
-
|
184 |
-
// reconsile_dimensions(uid);
|
185 |
-
|
186 |
-
// If nums hidden by default
|
187 |
-
if (nums.filter('[data-settings~="hide"]').length != 0) {
|
188 |
-
nums_content.ready(function() {
|
189 |
-
console_log('function' + uid);
|
190 |
-
CrayonSyntax.toggle_nums(uid, true, true);
|
191 |
-
});
|
192 |
-
} else {
|
193 |
-
update_nums_button(uid);
|
194 |
-
}
|
195 |
-
|
196 |
-
// TODO If width has changed or timeout, stop timer
|
197 |
-
if (/*last_num_width != nums.width() ||*/ i == 5) {
|
198 |
-
clearInterval(load_timer);
|
199 |
-
crayon[uid].loading = false;
|
200 |
-
}
|
201 |
-
i++;
|
202 |
-
};
|
203 |
-
// main.ready(function() {
|
204 |
-
// alert();
|
205 |
-
load_timer = setInterval(load_func, 300);
|
206 |
-
fix_scroll_blank(uid);
|
207 |
-
// });
|
208 |
-
|
209 |
-
// Used for toggling
|
210 |
-
main.css('position', 'relative');
|
211 |
-
main.css('z-index', 1);
|
212 |
-
|
213 |
-
// Update clickable buttons
|
214 |
-
update_nums_button(uid);
|
215 |
-
update_plain_button(uid);
|
216 |
-
|
217 |
-
// Disable certain features for touchscreen devices
|
218 |
-
touchscreen = (jQuery(this).filter('[data-settings~="touchscreen"]').length != 0);
|
219 |
-
|
220 |
-
// Used to hide info
|
221 |
-
if (!touchscreen) {
|
222 |
-
main.click(function() { crayon_info(uid, '', false); });
|
223 |
-
plain.click(function() { crayon_info(uid, '', false); });
|
224 |
-
info.click(function() { crayon_info(uid, '', false); });
|
225 |
-
}
|
226 |
-
|
227 |
-
// Used for code popup
|
228 |
-
crayon[uid].popup_settings = popupWindow(popup_button, {
|
229 |
-
height:screen.height - 200,
|
230 |
-
width:screen.width - 100,
|
231 |
-
top:75,
|
232 |
-
left:50,
|
233 |
-
scrollbars:1,
|
234 |
-
windowURL:'',
|
235 |
-
data:'' // Data overrides URL
|
236 |
-
}, function() {
|
237 |
-
code_popup(uid);
|
238 |
-
}, function() {
|
239 |
-
//console_log('after');
|
240 |
-
});
|
241 |
-
|
242 |
-
plain.css('opacity', 0);
|
243 |
-
// If a toolbar with mouseover was found
|
244 |
-
if (toolbar.filter('[data-settings~="mouseover"]').length != 0 && !touchscreen) {
|
245 |
-
crayon[uid].toolbar_mouseover = true;
|
246 |
-
|
247 |
-
toolbar.css('margin-top', '-' + toolbar.height() + 'px');
|
248 |
-
toolbar.hide();
|
249 |
-
// Overlay the toolbar if needed, only if doing so will not hide the
|
250 |
-
// whole code!
|
251 |
-
if (toolbar.filter('[data-settings~="overlay"]').length != 0
|
252 |
-
&& main.height() > toolbar.height() * 2) {
|
253 |
-
toolbar.css('position', 'absolute');
|
254 |
-
toolbar.css('z-index', 2);
|
255 |
-
// Hide on single click when overlayed
|
256 |
-
if (toolbar.filter('[data-settings~="hide"]').length != 0) {
|
257 |
-
main.click(function() { toolbar_toggle(uid, undefined, undefined, 0); });
|
258 |
-
plain.click(function() { toolbar_toggle(uid, false, undefined, 0); });
|
259 |
-
}
|
260 |
-
} else {
|
261 |
-
toolbar.css('z-index', 4);
|
262 |
-
}
|
263 |
-
// Enable delay on mouseout
|
264 |
-
if (toolbar.filter('[data-settings~="delay"]').length != 0) {
|
265 |
-
crayon[uid].toolbar_delay = 500;
|
266 |
-
}
|
267 |
-
// Use .hover() for chrome, but in firefox mouseover/mouseout worked best
|
268 |
-
jQuery(this).mouseenter(function() { toolbar_toggle(uid, true); })
|
269 |
-
.mouseleave(function() { toolbar_toggle(uid, false); });
|
270 |
-
|
271 |
-
} else if (touchscreen) {
|
272 |
-
toolbar.show();
|
273 |
-
}
|
274 |
-
// Plain show events
|
275 |
-
if (plain.length != 0 && !touchscreen) {
|
276 |
-
if (plain.filter('[data-settings~="dblclick"]').length != 0) {
|
277 |
-
main.dblclick(function() { CrayonSyntax.toggle_plain(uid); });
|
278 |
-
} else if (plain.filter('[data-settings~="click"]').length != 0) {
|
279 |
-
main.click(function() { CrayonSyntax.toggle_plain(uid); });
|
280 |
-
} else if (plain.filter('[data-settings~="mouseover"]').length != 0) {
|
281 |
-
jQuery(this).mouseenter(function() { CrayonSyntax.toggle_plain(uid, true); })
|
282 |
-
.mouseleave(function() { CrayonSyntax.toggle_plain(uid, false); });
|
283 |
-
nums_button.hide();
|
284 |
-
}
|
285 |
-
if (plain.filter('[data-settings~="show-plain-default"]').length != 0) {
|
286 |
-
// XXX
|
287 |
-
CrayonSyntax.toggle_plain(uid, true);
|
288 |
-
}
|
289 |
-
}
|
290 |
-
// Scrollbar show events
|
291 |
-
if (!touchscreen && jQuery(this).filter('[data-settings~="scroll-mouseover"]').length != 0) {
|
292 |
-
// Disable on touchscreen devices and when set to mouseover
|
293 |
-
main.css('overflow', 'hidden');
|
294 |
-
plain.css('overflow', 'hidden');
|
295 |
-
|
296 |
-
console_log(plain.css('overflow'));
|
297 |
-
|
298 |
-
jQuery(this).mouseenter(function() { toggle_scroll(uid, true); })
|
299 |
-
.mouseleave(function() { toggle_scroll(uid, false); });
|
300 |
-
}
|
301 |
-
// Disable animations
|
302 |
-
if ( jQuery(this).filter('[data-settings~="disable-anim"]').length != 0 ) {
|
303 |
-
crayon[uid].time = 0;
|
304 |
-
}
|
305 |
-
|
306 |
-
// Determine if Mac
|
307 |
-
crayon[uid].mac = jQuery(this).hasClass('crayon-os-mac');
|
308 |
});
|
309 |
};
|
310 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
311 |
var make_uid = function(uid) {
|
312 |
console_log(crayon);
|
313 |
if (typeof crayon[uid] == 'undefined') {
|
@@ -740,7 +749,7 @@ var CrayonSyntax = new function() {
|
|
740 |
crayon[uid].plain.height(crayon[uid].main.height());
|
741 |
//crayon[uid].plain.width(crayon[uid].main.width());
|
742 |
|
743 |
-
console_log('main: ' + crayon[uid].main.height() + ' plain: ' + crayon[uid].plain.height());
|
744 |
};
|
745 |
|
746 |
var animt = function(x, uid) {
|
57 |
if (typeof value != 'undefined') {
|
58 |
// Set style property
|
59 |
var priority = typeof priority != 'undefined' ? priority : '';
|
60 |
+
if (typeof style.setProperty != 'undefined') {
|
61 |
style.setProperty(styleName, value, priority);
|
62 |
} else {
|
63 |
style.styleName = value + ' ' + priority;
|
109 |
}
|
110 |
|
111 |
jQuery(CRAYON_SYNTAX).each(function() {
|
112 |
+
CrayonSyntax.process(this);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
113 |
});
|
114 |
};
|
115 |
|
116 |
+
this.process = function(c, replace) {
|
117 |
+
c = jQuery(c);
|
118 |
+
var uid = c.attr('id');
|
119 |
+
if (uid == 'crayon-') {
|
120 |
+
// No ID, generate one
|
121 |
+
uid += getUID();
|
122 |
+
}
|
123 |
+
c.attr('id', uid);
|
124 |
+
console_log(uid);
|
125 |
+
|
126 |
+
if (typeof replace == 'undefined') {
|
127 |
+
replace = false;
|
128 |
+
}
|
129 |
+
|
130 |
+
if (!replace && !make_uid(uid)) {
|
131 |
+
// Already a Crayon
|
132 |
+
return;
|
133 |
+
}
|
134 |
+
|
135 |
+
var toolbar = c.find(CRAYON_TOOLBAR);
|
136 |
+
var info = c.find(CRAYON_INFO);
|
137 |
+
var plain = c.find(CRAYON_PLAIN);
|
138 |
+
var main = c.find(CRAYON_MAIN);
|
139 |
+
var table = c.find(CRAYON_TABLE);
|
140 |
+
var code = c.find(CRAYON_CODE);
|
141 |
+
var nums = c.find(CRAYON_NUMS);
|
142 |
+
var nums_content = c.find(CRAYON_NUMS_CONTENT);
|
143 |
+
var nums_button = c.find(CRAYON_NUMS_BUTTON);
|
144 |
+
var popup_button = c.find(CRAYON_POPUP_BUTTON);
|
145 |
+
var copy_button = c.find(CRAYON_COPY_BUTTON);
|
146 |
+
var plain_button = c.find(CRAYON_PLAIN_BUTTON);
|
147 |
+
|
148 |
+
crayon[uid] = c;
|
149 |
+
crayon[uid].toolbar = toolbar;
|
150 |
+
crayon[uid].plain = plain;
|
151 |
+
crayon[uid].info = info;
|
152 |
+
crayon[uid].main = main;
|
153 |
+
crayon[uid].table = table;
|
154 |
+
crayon[uid].code = code;
|
155 |
+
crayon[uid].nums = nums;
|
156 |
+
crayon[uid].nums_content = nums_content;
|
157 |
+
crayon[uid].nums_button = nums_button;
|
158 |
+
crayon[uid].popup_button = popup_button;
|
159 |
+
crayon[uid].copy_button = copy_button;
|
160 |
+
crayon[uid].plain_button = plain_button;
|
161 |
+
crayon[uid].nums_visible = true;
|
162 |
+
crayon[uid].plain_visible = false;
|
163 |
+
|
164 |
+
crayon[uid].toolbar_delay = 0;
|
165 |
+
crayon[uid].time = 1;
|
166 |
+
|
167 |
+
// Set plain
|
168 |
+
jQuery(CRAYON_PLAIN).css('z-index', 0);
|
169 |
+
|
170 |
+
// XXX Remember CSS dimensions
|
171 |
+
var main_style = main.style();
|
172 |
+
crayon[uid].main_style = {
|
173 |
+
height: main_style && main_style.height || '',
|
174 |
+
max_height: main_style && main_style.maxHeight || '',
|
175 |
+
min_height: main_style && main_style.minHeight || '',
|
176 |
+
width: main_style && main_style.width || ''
|
177 |
+
};
|
178 |
+
|
179 |
+
var load_timer;
|
180 |
+
var i = 0;
|
181 |
+
crayon[uid].loading = true;
|
182 |
+
crayon[uid].scroll_block_fix = false;
|
183 |
+
|
184 |
+
// Register click events
|
185 |
+
nums_button.click(function() { CrayonSyntax.toggle_nums(uid); });
|
186 |
+
plain_button.click(function() { CrayonSyntax.toggle_plain(uid); });
|
187 |
+
copy_button.click(function() { CrayonSyntax.copy_plain(uid); });
|
188 |
+
|
189 |
+
var load_func = function() {
|
190 |
+
if (main.height() < 30) {
|
191 |
+
crayon[uid].scroll_block_fix = true;
|
192 |
+
}
|
193 |
+
|
194 |
+
// reconsile_dimensions(uid);
|
195 |
+
|
196 |
+
// If nums hidden by default
|
197 |
+
if (nums.filter('[data-settings~="hide"]').length != 0) {
|
198 |
+
nums_content.ready(function() {
|
199 |
+
console_log('function' + uid);
|
200 |
+
CrayonSyntax.toggle_nums(uid, true, true);
|
201 |
+
});
|
202 |
+
} else {
|
203 |
+
update_nums_button(uid);
|
204 |
+
}
|
205 |
+
|
206 |
+
// TODO If width has changed or timeout, stop timer
|
207 |
+
if (/*last_num_width != nums.width() ||*/ i == 5) {
|
208 |
+
clearInterval(load_timer);
|
209 |
+
crayon[uid].loading = false;
|
210 |
+
}
|
211 |
+
i++;
|
212 |
+
};
|
213 |
+
// main.ready(function() {
|
214 |
+
// alert();
|
215 |
+
load_timer = setInterval(load_func, 300);
|
216 |
+
fix_scroll_blank(uid);
|
217 |
+
// });
|
218 |
+
|
219 |
+
// Used for toggling
|
220 |
+
main.css('position', 'relative');
|
221 |
+
main.css('z-index', 1);
|
222 |
+
|
223 |
+
// Update clickable buttons
|
224 |
+
update_nums_button(uid);
|
225 |
+
update_plain_button(uid);
|
226 |
+
|
227 |
+
// Disable certain features for touchscreen devices
|
228 |
+
touchscreen = (c.filter('[data-settings~="touchscreen"]').length != 0);
|
229 |
+
|
230 |
+
// Used to hide info
|
231 |
+
if (!touchscreen) {
|
232 |
+
main.click(function() { crayon_info(uid, '', false); });
|
233 |
+
plain.click(function() { crayon_info(uid, '', false); });
|
234 |
+
info.click(function() { crayon_info(uid, '', false); });
|
235 |
+
}
|
236 |
+
|
237 |
+
// Used for code popup
|
238 |
+
crayon[uid].popup_settings = popupWindow(popup_button, {
|
239 |
+
height:screen.height - 200,
|
240 |
+
width:screen.width - 100,
|
241 |
+
top:75,
|
242 |
+
left:50,
|
243 |
+
scrollbars:1,
|
244 |
+
windowURL:'',
|
245 |
+
data:'' // Data overrides URL
|
246 |
+
}, function() {
|
247 |
+
code_popup(uid);
|
248 |
+
}, function() {
|
249 |
+
//console_log('after');
|
250 |
+
});
|
251 |
+
|
252 |
+
plain.css('opacity', 0);
|
253 |
+
// If a toolbar with mouseover was found
|
254 |
+
if (toolbar.filter('[data-settings~="mouseover"]').length != 0 && !touchscreen) {
|
255 |
+
crayon[uid].toolbar_mouseover = true;
|
256 |
+
|
257 |
+
toolbar.css('margin-top', '-' + toolbar.height() + 'px');
|
258 |
+
toolbar.hide();
|
259 |
+
// Overlay the toolbar if needed, only if doing so will not hide the
|
260 |
+
// whole code!
|
261 |
+
if (toolbar.filter('[data-settings~="overlay"]').length != 0
|
262 |
+
&& main.height() > toolbar.height() * 2) {
|
263 |
+
toolbar.css('position', 'absolute');
|
264 |
+
toolbar.css('z-index', 2);
|
265 |
+
// Hide on single click when overlayed
|
266 |
+
if (toolbar.filter('[data-settings~="hide"]').length != 0) {
|
267 |
+
main.click(function() { toolbar_toggle(uid, undefined, undefined, 0); });
|
268 |
+
plain.click(function() { toolbar_toggle(uid, false, undefined, 0); });
|
269 |
+
}
|
270 |
+
} else {
|
271 |
+
toolbar.css('z-index', 4);
|
272 |
+
}
|
273 |
+
// Enable delay on mouseout
|
274 |
+
if (toolbar.filter('[data-settings~="delay"]').length != 0) {
|
275 |
+
crayon[uid].toolbar_delay = 500;
|
276 |
+
}
|
277 |
+
// Use .hover() for chrome, but in firefox mouseover/mouseout worked best
|
278 |
+
c.mouseenter(function() { toolbar_toggle(uid, true); })
|
279 |
+
.mouseleave(function() { toolbar_toggle(uid, false); });
|
280 |
+
|
281 |
+
} else if (touchscreen) {
|
282 |
+
toolbar.show();
|
283 |
+
}
|
284 |
+
// Plain show events
|
285 |
+
if (plain.length != 0 && !touchscreen) {
|
286 |
+
if (plain.filter('[data-settings~="dblclick"]').length != 0) {
|
287 |
+
main.dblclick(function() { CrayonSyntax.toggle_plain(uid); });
|
288 |
+
} else if (plain.filter('[data-settings~="click"]').length != 0) {
|
289 |
+
main.click(function() { CrayonSyntax.toggle_plain(uid); });
|
290 |
+
} else if (plain.filter('[data-settings~="mouseover"]').length != 0) {
|
291 |
+
c.mouseenter(function() { CrayonSyntax.toggle_plain(uid, true); })
|
292 |
+
.mouseleave(function() { CrayonSyntax.toggle_plain(uid, false); });
|
293 |
+
nums_button.hide();
|
294 |
+
}
|
295 |
+
if (plain.filter('[data-settings~="show-plain-default"]').length != 0) {
|
296 |
+
// XXX
|
297 |
+
CrayonSyntax.toggle_plain(uid, true);
|
298 |
+
}
|
299 |
+
}
|
300 |
+
// Scrollbar show events
|
301 |
+
if (!touchscreen && c.filter('[data-settings~="scroll-mouseover"]').length != 0) {
|
302 |
+
// Disable on touchscreen devices and when set to mouseover
|
303 |
+
main.css('overflow', 'hidden');
|
304 |
+
plain.css('overflow', 'hidden');
|
305 |
+
|
306 |
+
console_log(plain.css('overflow'));
|
307 |
+
|
308 |
+
c.mouseenter(function() { toggle_scroll(uid, true); })
|
309 |
+
.mouseleave(function() { toggle_scroll(uid, false); });
|
310 |
+
}
|
311 |
+
// Disable animations
|
312 |
+
if ( c.filter('[data-settings~="disable-anim"]').length != 0 ) {
|
313 |
+
crayon[uid].time = 0;
|
314 |
+
}
|
315 |
+
|
316 |
+
// Determine if Mac
|
317 |
+
crayon[uid].mac = c.hasClass('crayon-os-mac');
|
318 |
+
};
|
319 |
+
|
320 |
var make_uid = function(uid) {
|
321 |
console_log(crayon);
|
322 |
if (typeof crayon[uid] == 'undefined') {
|
749 |
crayon[uid].plain.height(crayon[uid].main.height());
|
750 |
//crayon[uid].plain.width(crayon[uid].main.width());
|
751 |
|
752 |
+
// console_log('main: ' + crayon[uid].main.height() + ' plain: ' + crayon[uid].plain.height());
|
753 |
};
|
754 |
|
755 |
var animt = function(x, uid) {
|
js/crayon_admin.js
CHANGED
@@ -18,9 +18,9 @@ var CrayonSyntaxAdmin = new function() {
|
|
18 |
// Log
|
19 |
var log_button = log_text = null;
|
20 |
|
21 |
-
var main_wrap = theme_editor_wrap = editor_url =
|
22 |
-
var theme_editor_loaded = false;
|
23 |
-
var theme_editor_loading = false;
|
24 |
|
25 |
var settings = CrayonSyntaxSettings;
|
26 |
var me = this;
|
@@ -46,8 +46,10 @@ var CrayonSyntaxAdmin = new function() {
|
|
46 |
main_wrap = jQuery('#crayon-main-wrap');
|
47 |
theme_editor_wrap = jQuery('#crayon-theme-editor-wrap');
|
48 |
editor_url = theme_editor_wrap.attr('url');
|
49 |
-
|
50 |
-
|
|
|
|
|
51 |
|
52 |
// Theme editor
|
53 |
var get_vars = this.get_vars();
|
@@ -296,48 +298,54 @@ var CrayonSyntaxAdmin = new function() {
|
|
296 |
return false;
|
297 |
};
|
298 |
|
299 |
-
this.show_theme_editor_now = function() {
|
300 |
main_wrap.hide();
|
301 |
theme_editor_wrap.show();
|
302 |
jQuery(window).scrollTop(0);
|
303 |
|
304 |
theme_editor_loading = false;
|
305 |
-
|
306 |
};
|
307 |
|
308 |
-
this.show_theme_editor = function() {
|
309 |
-
if (theme_editor_loading) {
|
310 |
-
return;
|
311 |
-
}
|
312 |
-
theme_editor_button.css('width', theme_editor_button.width());
|
313 |
-
if (!theme_editor_loaded) {
|
314 |
-
theme_editor_loading = true;
|
315 |
-
|
316 |
|
317 |
// Simulate loading with timer
|
318 |
// editor_timer = setInterval(function() {
|
319 |
// clearInterval(editor_timer);
|
320 |
|
321 |
-
|
322 |
-
|
323 |
-
|
|
|
|
|
|
|
324 |
// CrayonSyntax.init();
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
|
|
|
|
|
|
332 |
// show_theme_editor_now();
|
333 |
-
|
334 |
|
335 |
// }, 2000);
|
336 |
|
337 |
-
theme_editor_loaded = true;
|
338 |
-
} else {
|
339 |
-
this.show_theme_editor_now();
|
340 |
-
}
|
341 |
return false;
|
342 |
};
|
343 |
|
18 |
// Log
|
19 |
var log_button = log_text = null;
|
20 |
|
21 |
+
var main_wrap = theme_editor_wrap = editor_url = theme_editor_edit_button = theme_editor_create_button = null;
|
22 |
+
// var theme_editor_loaded = false;
|
23 |
+
// var theme_editor_loading = false;
|
24 |
|
25 |
var settings = CrayonSyntaxSettings;
|
26 |
var me = this;
|
46 |
main_wrap = jQuery('#crayon-main-wrap');
|
47 |
theme_editor_wrap = jQuery('#crayon-theme-editor-wrap');
|
48 |
editor_url = theme_editor_wrap.attr('url');
|
49 |
+
theme_editor_edit_button = jQuery('#crayon-theme-editor-edit-button');
|
50 |
+
theme_editor_create_button = jQuery('#crayon-theme-editor-create-button');
|
51 |
+
theme_editor_edit_button.click(function() { CrayonSyntaxAdmin.show_theme_editor(theme_editor_edit_button, true); });
|
52 |
+
theme_editor_create_button.click(function() { CrayonSyntaxAdmin.show_theme_editor(theme_editor_create_button, false); });
|
53 |
|
54 |
// Theme editor
|
55 |
var get_vars = this.get_vars();
|
298 |
return false;
|
299 |
};
|
300 |
|
301 |
+
this.show_theme_editor_now = function(button) {
|
302 |
main_wrap.hide();
|
303 |
theme_editor_wrap.show();
|
304 |
jQuery(window).scrollTop(0);
|
305 |
|
306 |
theme_editor_loading = false;
|
307 |
+
button.html(button.attr('loaded'));
|
308 |
};
|
309 |
|
310 |
+
this.show_theme_editor = function(button, editing) {
|
311 |
+
// if (theme_editor_loading) {
|
312 |
+
// return;
|
313 |
+
// }
|
314 |
+
// theme_editor_button.css('width', theme_editor_button.width());
|
315 |
+
// if (!theme_editor_loaded) {
|
316 |
+
// theme_editor_loading = true;
|
317 |
+
button.html(button.attr('loading'));
|
318 |
|
319 |
// Simulate loading with timer
|
320 |
// editor_timer = setInterval(function() {
|
321 |
// clearInterval(editor_timer);
|
322 |
|
323 |
+
CrayonThemeEditorSettings.curr_theme = jQuery('#crayon-theme').val();
|
324 |
+
CrayonThemeEditorSettings.editing = editing;
|
325 |
+
|
326 |
+
// Load theme editor
|
327 |
+
jQuery.get(editor_url + '?curr_theme=' + CrayonThemeEditorSettings.curr_theme + '&editing=' + editing, function(data) {
|
328 |
+
theme_editor_wrap.html(data);
|
329 |
// CrayonSyntax.init();
|
330 |
+
|
331 |
+
// Load url from preview into theme editor
|
332 |
+
// jQuery('#crayon-editor-preview').attr('url', preview_url);
|
333 |
+
|
334 |
+
// Load preview into editor
|
335 |
+
CrayonSyntaxThemeEditor.init(function () {
|
336 |
+
CrayonSyntaxAdmin.show_theme_editor_now(button);
|
337 |
+
}, preview.clone()
|
338 |
+
);
|
339 |
+
|
340 |
// show_theme_editor_now();
|
341 |
+
});
|
342 |
|
343 |
// }, 2000);
|
344 |
|
345 |
+
// theme_editor_loaded = true;
|
346 |
+
// } else {
|
347 |
+
// this.show_theme_editor_now();
|
348 |
+
// }
|
349 |
return false;
|
350 |
};
|
351 |
|
js/cssjson.js
ADDED
@@ -0,0 +1,163 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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
|
82 |
+
return node;
|
83 |
+
} else if (!isEmpty(match[capAttr])) {
|
84 |
+
var line = match[capAttr].trim();
|
85 |
+
var attr = lineAttrX.exec(line);
|
86 |
+
if (attr) {
|
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 |
+
}
|
js/util.js
CHANGED
@@ -1,6 +1,9 @@
|
|
|
|
|
|
1 |
if (typeof CrayonTagEditorSettings == 'undefined') {
|
2 |
// WP may have already added it
|
3 |
CrayonTagEditorSettings = {};
|
|
|
4 |
}
|
5 |
|
6 |
RegExp.prototype.execAll = function(string) {
|
@@ -18,8 +21,6 @@ RegExp.prototype.execAll = function(string) {
|
|
18 |
return matches;
|
19 |
};
|
20 |
|
21 |
-
var CRAYON_DEBUG = false;
|
22 |
-
|
23 |
function console_log(string) {
|
24 |
if (typeof console != 'undefined' && CRAYON_DEBUG) {
|
25 |
console.log(string);
|
1 |
+
var CRAYON_DEBUG = false;
|
2 |
+
|
3 |
if (typeof CrayonTagEditorSettings == 'undefined') {
|
4 |
// WP may have already added it
|
5 |
CrayonTagEditorSettings = {};
|
6 |
+
CrayonSettings = {};
|
7 |
}
|
8 |
|
9 |
RegExp.prototype.execAll = function(string) {
|
21 |
return matches;
|
22 |
};
|
23 |
|
|
|
|
|
24 |
function console_log(string) {
|
25 |
if (typeof console != 'undefined' && CRAYON_DEBUG) {
|
26 |
console.log(string);
|
readme.txt
CHANGED
@@ -4,7 +4,7 @@ Donate link: https://www.paypal.com/au/cgi-bin/webscr?cmd=_flow&SESSION=PPqWIQJ0
|
|
4 |
Tags: syntax highlighter, syntax, highlighter, highlighting, crayon, code highlighter
|
5 |
Requires at least: 3.0
|
6 |
Tested up to: 3.4
|
7 |
-
Stable tag:
|
8 |
|
9 |
Syntax Highlighter supporting multiple languages, themes, fonts, highlighting from a URL, local file or post text.
|
10 |
|
@@ -199,6 +199,10 @@ Contact me at http://twitter.com/crayonsyntax or crayon.syntax@gmail.com.
|
|
199 |
|
200 |
== Changelog ==
|
201 |
|
|
|
|
|
|
|
|
|
202 |
= 1.9.10 =
|
203 |
* Another fix regarding the \r\n line breaks
|
204 |
|
4 |
Tags: syntax highlighter, syntax, highlighter, highlighting, crayon, code highlighter
|
5 |
Requires at least: 3.0
|
6 |
Tested up to: 3.4
|
7 |
+
Stable tag: 1.9.11
|
8 |
|
9 |
Syntax Highlighter supporting multiple languages, themes, fonts, highlighting from a URL, local file or post text.
|
10 |
|
199 |
|
200 |
== Changelog ==
|
201 |
|
202 |
+
= 1.9.11 =
|
203 |
+
* Fixed an issue with IE 8 throwing JS errors for setStyleProperty
|
204 |
+
* Fixed yet another issue with \r\n causing incorrect span tags, refactored code.
|
205 |
+
|
206 |
= 1.9.10 =
|
207 |
* Another fix regarding the \r\n line breaks
|
208 |
|
util/tag-editor/crayon_tag_editor_wp.class.php
CHANGED
@@ -26,7 +26,7 @@ class CrayonTagEditorWP {
|
|
26 |
// Add settings
|
27 |
CrayonSettingsWP::load_settings(TRUE);
|
28 |
self::$settings = array(
|
29 |
-
'url' => plugins_url(
|
30 |
'home_url' => home_url(),
|
31 |
'css' => 'crayon-te',
|
32 |
'used' => CrayonGlobalSettings::val(CrayonSettings::TINYMCE_USED),
|
26 |
// Add settings
|
27 |
CrayonSettingsWP::load_settings(TRUE);
|
28 |
self::$settings = array(
|
29 |
+
'url' => plugins_url(CRAYON_TE_CONTENT_PHP, __FILE__),
|
30 |
'home_url' => home_url(),
|
31 |
'css' => 'crayon-te',
|
32 |
'used' => CrayonGlobalSettings::val(CrayonSettings::TINYMCE_USED),
|
util/tag-editor/crayon_te_content.php
CHANGED
@@ -4,9 +4,8 @@
|
|
4 |
|
5 |
$crayon_root_te = dirname(dirname(dirname(__FILE__)));
|
6 |
require_once ($crayon_root_te . '/crayon_wp.class.php');
|
7 |
-
require_once ($crayon_root_te.'/crayon_settings_wp.class.php');
|
8 |
require_once (CrayonWP::wp_load_path());
|
9 |
-
require_once (
|
10 |
require_once (CRAYON_PARSER_PHP);
|
11 |
|
12 |
CrayonSettingsWP::load_settings();
|
4 |
|
5 |
$crayon_root_te = dirname(dirname(dirname(__FILE__)));
|
6 |
require_once ($crayon_root_te . '/crayon_wp.class.php');
|
|
|
7 |
require_once (CrayonWP::wp_load_path());
|
8 |
+
require_once (CRAYON_TE_PHP);
|
9 |
require_once (CRAYON_PARSER_PHP);
|
10 |
|
11 |
CrayonSettingsWP::load_settings();
|
util/theme-editor/editor.js
DELETED
@@ -1,96 +0,0 @@
|
|
1 |
-
<!--
|
2 |
-
// Crayon Syntax Highlighter Theme Editor JavaScript
|
3 |
-
|
4 |
-
if (typeof DEBUG == 'undefined') {
|
5 |
-
var DEBUG = false;
|
6 |
-
}
|
7 |
-
|
8 |
-
if (typeof crayon_log == 'undefined') {
|
9 |
-
function crayon_log(string) {
|
10 |
-
if (typeof console != 'undefined' && DEBUG) {
|
11 |
-
console.log(string);
|
12 |
-
}
|
13 |
-
}
|
14 |
-
}
|
15 |
-
|
16 |
-
//jQuery(document).ready(function() {
|
17 |
-
// crayon_log('editor loaded');
|
18 |
-
// CrayonSyntaxThemeEditor.init();
|
19 |
-
//});
|
20 |
-
|
21 |
-
var CrayonSyntaxThemeEditor = new function() {
|
22 |
-
|
23 |
-
var preview, preview_loaded, preview_url, preview_get, preview_callback, editor_controls, editor_top_controls;
|
24 |
-
var preview_objects;
|
25 |
-
var theme_dropdown;
|
26 |
-
var theme_css, is_theme_changed;
|
27 |
-
|
28 |
-
this.init = function() {
|
29 |
-
crayon_log('editor init');
|
30 |
-
preview = jQuery('#crayon-editor-preview');
|
31 |
-
preview_loaded = false;
|
32 |
-
editor_controls = jQuery('#crayon-editor-controls');
|
33 |
-
editor_top_controls = jQuery('#crayon-editor-top-controls');
|
34 |
-
preview_url = preview.attr('url');
|
35 |
-
theme_css = {};
|
36 |
-
preview_objects = {};
|
37 |
-
is_theme_changed = false;
|
38 |
-
|
39 |
-
preview_callback = function() {
|
40 |
-
preview_update();
|
41 |
-
};
|
42 |
-
|
43 |
-
// Duplicate controls from settings screen
|
44 |
-
// theme_dropdown = jQuery('#theme').clone();
|
45 |
-
// theme_dropdown.attr('id', 'editor-theme');
|
46 |
-
|
47 |
-
theme_dropdown = add_preview_object('#theme');
|
48 |
-
|
49 |
-
editor_top_controls.html(theme_dropdown);
|
50 |
-
|
51 |
-
// obj.change(preview_callback);
|
52 |
-
|
53 |
-
// Initial load
|
54 |
-
preview_update();
|
55 |
-
}
|
56 |
-
|
57 |
-
var preview_update = function() {
|
58 |
-
crayon_log('editor_preview_update');
|
59 |
-
update_get();
|
60 |
-
// Load Preview
|
61 |
-
jQuery.get(preview_url + preview_get, function(data) {
|
62 |
-
preview.html(data);
|
63 |
-
CrayonSyntax.init();
|
64 |
-
if (!preview_loaded) {
|
65 |
-
CrayonSyntaxAdmin.show_theme_editor_now();
|
66 |
-
preview_loaded = true;
|
67 |
-
}
|
68 |
-
});
|
69 |
-
}
|
70 |
-
|
71 |
-
var add_preview_object = function(selector) {
|
72 |
-
var obj = jQuery(selector);
|
73 |
-
if (obj.length == 0) {
|
74 |
-
crayon_log('add_preview_object selector: ' + selector + ' gives null');
|
75 |
-
return null;
|
76 |
-
}
|
77 |
-
obj = obj.clone();
|
78 |
-
obj.attr('old-id', obj.attr('id'));
|
79 |
-
obj.attr('id', 'editor-' + obj.attr('id'));
|
80 |
-
preview_objects[obj.attr('old-id')] = obj;
|
81 |
-
obj.change(preview_callback);
|
82 |
-
return obj;
|
83 |
-
}
|
84 |
-
|
85 |
-
var update_get = function() {
|
86 |
-
preview_get = '?toolbar=1&';
|
87 |
-
for (id in preview_objects) {
|
88 |
-
obj = preview_objects[id];
|
89 |
-
preview_get += id + '=' + obj.val() + '&';
|
90 |
-
}
|
91 |
-
crayon_log(preview_get);
|
92 |
-
}
|
93 |
-
|
94 |
-
}
|
95 |
-
|
96 |
-
//-->
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
util/theme-editor/editor.php
DELETED
@@ -1,38 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
$crayon_root_theme = dirname(dirname(dirname(__FILE__))) . '/';
|
4 |
-
require_once $crayon_root_theme . 'global.php';
|
5 |
-
|
6 |
-
//class CrayonThemeEditor {
|
7 |
-
//
|
8 |
-
//}
|
9 |
-
|
10 |
-
?>
|
11 |
-
|
12 |
-
<div id="icon-options-general" class="icon32"><br>
|
13 |
-
</div>
|
14 |
-
<h2>Crayon Syntax Highlighter <?php crayon_e('Theme Editor'); ?></h2>
|
15 |
-
|
16 |
-
<p><a class="button-primary" onclick="CrayonSyntaxAdmin.show_main();"><?php crayon_e('Back To Settings'); ?></a></p>
|
17 |
-
|
18 |
-
<?php //crayon_e('Use the Sidebar on the right to change the Theme of the Preview window.') ?>
|
19 |
-
|
20 |
-
<div id="crayon-editor-top-controls"></div>
|
21 |
-
|
22 |
-
<table id="crayon-editor-table" style="width: 100%;" cellspacing="5" cellpadding="0">
|
23 |
-
<tr>
|
24 |
-
<td class="crayon-editor-preview-wrapper">
|
25 |
-
<div id="crayon-editor-preview">
|
26 |
-
<?php
|
27 |
-
$crayon_preview_text_hide = TRUE;
|
28 |
-
$crayon_preview_settings = TRUE;
|
29 |
-
// require_once $root_path . CRAYON_PREVIEW_PHP;
|
30 |
-
?>
|
31 |
-
</div>
|
32 |
-
</td>
|
33 |
-
<td class="crayon-editor-control-wrapper">
|
34 |
-
<div id="crayon-editor-controls"></div>
|
35 |
-
</td>
|
36 |
-
</tr>
|
37 |
-
|
38 |
-
</table>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
util/theme-editor/theme_editor.css
ADDED
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
}
|
util/theme-editor/theme_editor.js
ADDED
@@ -0,0 +1,96 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
// Crayon Syntax Highlighter Theme Editor JavaScript
|
2 |
+
|
3 |
+
var CrayonSyntaxThemeEditor = new function() {
|
4 |
+
|
5 |
+
// var preview, preview_url, preview_get; //, preview_callback, editor_controls, editor_top_controls;
|
6 |
+
// var preview_objects, preview_loaded;
|
7 |
+
// var theme_dropdown;
|
8 |
+
// var theme_css, is_theme_changed;
|
9 |
+
|
10 |
+
var settings = CrayonThemeEditorSettings;
|
11 |
+
|
12 |
+
this.init = function(callback, crayon) {
|
13 |
+
|
14 |
+
console_log(CrayonThemeEditorSettings);
|
15 |
+
|
16 |
+
console_log('editor init');
|
17 |
+
preview = jQuery('#crayon-editor-preview');
|
18 |
+
|
19 |
+
crayon.attr('id', 'theme-editor-instance');
|
20 |
+
CrayonSyntax.process(crayon, true);
|
21 |
+
preview.html(crayon);
|
22 |
+
|
23 |
+
jQuery.get(settings.themes_url + settings.curr_theme + '/' + settings.curr_theme + '.css' , function(css) {
|
24 |
+
console_log(css);
|
25 |
+
|
26 |
+
var json = CSSJSON.toJSON(css, true);
|
27 |
+
console_log(json);
|
28 |
+
});
|
29 |
+
|
30 |
+
// preview_loaded = false;
|
31 |
+
// editor_controls = jQuery('#crayon-editor-controls');
|
32 |
+
// editor_top_controls = jQuery('#crayon-editor-top-controls');
|
33 |
+
// preview_url = preview.attr('url');
|
34 |
+
// theme_css = {};
|
35 |
+
// preview_objects = {};
|
36 |
+
// is_theme_changed = false;
|
37 |
+
//
|
38 |
+
// preview_callback = function() {
|
39 |
+
// preview_update();
|
40 |
+
// };
|
41 |
+
|
42 |
+
// Duplicate controls from settings screen
|
43 |
+
// theme_dropdown = jQuery('#theme').clone();
|
44 |
+
// theme_dropdown.attr('id', 'editor-theme');
|
45 |
+
|
46 |
+
// theme_dropdown = add_preview_object('#theme');
|
47 |
+
// editor_top_controls.html(theme_dropdown);
|
48 |
+
|
49 |
+
// Initial load
|
50 |
+
// preview_update();
|
51 |
+
|
52 |
+
callback();
|
53 |
+
|
54 |
+
};
|
55 |
+
|
56 |
+
// var preview_update =
|
57 |
+
// function() {
|
58 |
+
// console_log('editor_preview_update');
|
59 |
+
// update_get();
|
60 |
+
//
|
61 |
+
// // Load Preview
|
62 |
+
// jQuery.get(preview_url + preview_get, function(data) {
|
63 |
+
// preview.html(data);
|
64 |
+
// CrayonSyntax.init();
|
65 |
+
// if (!self.preview_loaded) {
|
66 |
+
// CrayonSyntaxAdmin.show_theme_editor_now();
|
67 |
+
// preview_loaded = true;
|
68 |
+
// }
|
69 |
+
// });
|
70 |
+
// };
|
71 |
+
|
72 |
+
// var add_preview_object = function(selector) {
|
73 |
+
// var obj = jQuery(selector);
|
74 |
+
// if (obj.length == 0) {
|
75 |
+
// console_log('add_preview_object selector: ' + selector + ' gives null');
|
76 |
+
// return null;
|
77 |
+
// }
|
78 |
+
// obj = obj.clone();
|
79 |
+
// obj.attr('old-id', obj.attr('id'));
|
80 |
+
// obj.attr('id', 'editor-' + obj.attr('id'));
|
81 |
+
// preview_objects[obj.attr('old-id')] = obj;
|
82 |
+
// obj.change(preview_callback);
|
83 |
+
// return obj;
|
84 |
+
// }
|
85 |
+
|
86 |
+
// var update_get = function() {
|
87 |
+
// preview_get = '?toolbar=1&theme=' + CrayonThemeEditorSettings.curr_theme;
|
88 |
+
//// for (id in preview_objects) {
|
89 |
+
//// obj = preview_objects[id];
|
90 |
+
//// preview_get += id + '=' + obj.val() + '&';
|
91 |
+
//// }
|
92 |
+
//// console_log('show_theme_editor ' + preview_get);
|
93 |
+
//// console_log('TEST');
|
94 |
+
// };
|
95 |
+
|
96 |
+
};
|
util/theme-editor/theme_editor.php
ADDED
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
$crayon_root_theme = dirname(dirname(dirname(__FILE__))) . '/';
|
4 |
+
require_once $crayon_root_theme . 'global.php';
|
5 |
+
|
6 |
+
class CrayonThemeEditorWP {
|
7 |
+
|
8 |
+
public static function admin_scripts() {
|
9 |
+
|
10 |
+
$themes_ = CrayonResources::themes()->get();
|
11 |
+
$themes = array();
|
12 |
+
|
13 |
+
foreach ($themes_ as $theme) {
|
14 |
+
$themes[$theme->id()] = $theme->name();
|
15 |
+
}
|
16 |
+
|
17 |
+
$settings = array(
|
18 |
+
'themes' => $themes,
|
19 |
+
'themes_url' => plugins_url(CRAYON_THEME_DIR, dirname(dirname(__FILE__)))
|
20 |
+
);
|
21 |
+
wp_localize_script('crayon_theme_editor', 'CrayonThemeEditorSettings', $settings);
|
22 |
+
}
|
23 |
+
|
24 |
+
}
|
25 |
+
|
26 |
+
?>
|
util/theme-editor/theme_editor_content.php
ADDED
@@ -0,0 +1,57 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
$crayon_root_theme_editor = dirname(dirname(dirname(__FILE__)));
|
4 |
+
require_once ($crayon_root_theme_editor . '/crayon_wp.class.php');
|
5 |
+
require_once (CrayonWP::wp_load_path());
|
6 |
+
|
7 |
+
$theme = CrayonResources::themes()->get_default();
|
8 |
+
$editing = false;
|
9 |
+
|
10 |
+
if ( isset($_GET['curr_theme']) ) {
|
11 |
+
$theme = CrayonResources::themes()->get($_GET['curr_theme']);
|
12 |
+
}
|
13 |
+
|
14 |
+
if ( isset($_GET['editing']) ) {
|
15 |
+
$editing = CrayonUtil::str_to_bool($_GET['editing'], FALSE);
|
16 |
+
}
|
17 |
+
|
18 |
+
// var_dump($_GET);
|
19 |
+
|
20 |
+
// var_dump($theme);
|
21 |
+
// var_dump($editing);
|
22 |
+
|
23 |
+
?>
|
24 |
+
|
25 |
+
<div id="icon-options-general" class="icon32"><br>
|
26 |
+
</div>
|
27 |
+
<h2>Crayon Syntax Highlighter <?php crayon_e('Theme Editor'); ?></h2>
|
28 |
+
|
29 |
+
<h3>
|
30 |
+
<?php
|
31 |
+
if ($editing) {
|
32 |
+
echo sprintf(crayon__('Editing "%s" Theme'), $theme->name());
|
33 |
+
} else {
|
34 |
+
echo sprintf(crayon__('Creating Theme From "%s"'), $theme->name());
|
35 |
+
}
|
36 |
+
?>
|
37 |
+
</h3>
|
38 |
+
|
39 |
+
<p><a class="button-primary" onclick="CrayonSyntaxAdmin.show_main();"><?php crayon_e('Back To Settings'); ?></a></p>
|
40 |
+
|
41 |
+
<?php //crayon_e('Use the Sidebar on the right to change the Theme of the Preview window.') ?>
|
42 |
+
|
43 |
+
<div id="crayon-editor-top-controls"></div>
|
44 |
+
|
45 |
+
<table id="crayon-editor-table" style="width: 100%;" cellspacing="5" cellpadding="0">
|
46 |
+
<tr>
|
47 |
+
<td id="crayon-editor-preview-wrapper">
|
48 |
+
<div id="crayon-editor-preview"></div>
|
49 |
+
</td>
|
50 |
+
</tr>
|
51 |
+
<tr>
|
52 |
+
<td id="crayon-editor-control-wrapper">
|
53 |
+
<div id="crayon-editor-controls"></div>
|
54 |
+
</td>
|
55 |
+
</tr>
|
56 |
+
|
57 |
+
</table>
|