Scripts n Styles - Version 3.1

Version Description

  • Feature: Dynamic Shortcodes.
  • Feature: LESS.js support.
  • Bug Fix: Proper output escaping.
Download this release

Release Info

Developer WraithKenny
Plugin Icon wp plugin Scripts n Styles
Version 3.1
Comparing to
See all releases

Code changes from version 3.0.3 to 3.1

Files changed (49) hide show
  1. README.txt +13 -6
  2. css/code-editor.css +20 -0
  3. css/less.css +24 -0
  4. includes/class.SnS_AJAX.php +21 -6
  5. includes/class.SnS_Admin.php +41 -52
  6. includes/class.SnS_Admin_Code_Editor.php +90 -0
  7. includes/class.SnS_Admin_Meta_Box.php +108 -104
  8. includes/class.SnS_Form.php +10 -10
  9. includes/class.SnS_Global_Page.php +58 -25
  10. includes/class.SnS_Settings_Page.php +55 -50
  11. includes/class.SnS_Usage_Page.php +9 -9
  12. js/code-editor.js +42 -0
  13. js/global-page.js +76 -2
  14. js/meta-box-scripts.js +20 -27
  15. js/settings-page.js +1 -1
  16. languages/scripts-n-styles.pot +398 -398
  17. libraries/CodeMirror2/LICENSE +5 -1
  18. libraries/CodeMirror2/lib/codemirror.css +62 -13
  19. libraries/CodeMirror2/lib/codemirror.js +1046 -769
  20. libraries/CodeMirror2/mode/clike/clike.js +6 -19
  21. libraries/CodeMirror2/mode/clike/index.html +4 -5
  22. libraries/CodeMirror2/mode/css/css.js +1 -1
  23. libraries/CodeMirror2/mode/css/index.html +3 -4
  24. libraries/CodeMirror2/mode/htmlmixed/htmlmixed.js +4 -2
  25. libraries/CodeMirror2/mode/htmlmixed/index.html +3 -4
  26. libraries/CodeMirror2/mode/javascript/index.html +3 -4
  27. libraries/CodeMirror2/mode/javascript/javascript.js +13 -10
  28. libraries/CodeMirror2/mode/less/less.js +232 -0
  29. libraries/CodeMirror2/mode/php/index.html +4 -5
  30. libraries/CodeMirror2/mode/php/php.js +58 -28
  31. libraries/CodeMirror2/mode/xml/index.html +4 -5
  32. libraries/CodeMirror2/mode/xml/xml.js +120 -28
  33. libraries/CodeMirror2/theme/ambiance.css +82 -0
  34. libraries/CodeMirror2/theme/blackboard.css +25 -0
  35. libraries/CodeMirror2/theme/cobalt.css +2 -1
  36. libraries/CodeMirror2/theme/default.css +0 -19
  37. libraries/CodeMirror2/theme/eclipse.css +4 -3
  38. libraries/CodeMirror2/theme/elegant.css +3 -2
  39. libraries/CodeMirror2/theme/lesser-dark.css +45 -0
  40. libraries/CodeMirror2/theme/monokai.css +22 -21
  41. libraries/CodeMirror2/theme/neat.css +4 -3
  42. libraries/CodeMirror2/theme/night.css +2 -1
  43. libraries/CodeMirror2/theme/rubyblue.css +3 -2
  44. libraries/CodeMirror2/theme/xq-dark.css +46 -0
  45. libraries/less/LICENSE +179 -0
  46. libraries/less/dist/less-1.3.0.js +3478 -0
  47. libraries/less/dist/less-1.3.0.min.js +9 -0
  48. license.txt +651 -258
  49. scripts-n-styles.php +62 -33
README.txt CHANGED
@@ -1,11 +1,10 @@
1
  === Scripts n Styles ===
2
  Contributors: WraithKenny, Touvan
3
- Donate link: http://wordpressfoundation.org/donate/
4
  Tags: admin, CSS, javascript, code, custom, Style
5
  Requires at least: 3.3
6
- Tested up to: 3.3
7
- Stable tag: 3.0.3
8
- License: GPLv2 or later
9
 
10
  This plugin allows Admin users to individually add custom CSS, Classes and JavaScript directly to Post, Pages or any other custom post types.
11
 
@@ -53,8 +52,13 @@ Sure, if you are an Admin, just go to the plugin editor and wipe out the uninsta
53
 
54
  == Changelog ==
55
 
 
 
 
 
 
56
  = 3.0.3 =
57
- * Bug Fix: formatting on ajax
58
 
59
  = 3.0.2 =
60
  * Bug Fix: Fatal Error on post save
@@ -103,8 +107,11 @@ Sure, if you are an Admin, just go to the plugin editor and wipe out the uninsta
103
 
104
  == Upgrade Notice ==
105
 
 
 
 
106
  = 3.0.3 =
107
- Bug Fix: formatting on ajax
108
 
109
  = 3.0.2 =
110
  Bug fix
1
  === Scripts n Styles ===
2
  Contributors: WraithKenny, Touvan
 
3
  Tags: admin, CSS, javascript, code, custom, Style
4
  Requires at least: 3.3
5
+ Tested up to: 3.4-beta3
6
+ Stable tag: 3.1
7
+ License: GPLv3 or later
8
 
9
  This plugin allows Admin users to individually add custom CSS, Classes and JavaScript directly to Post, Pages or any other custom post types.
10
 
52
 
53
  == Changelog ==
54
 
55
+ = 3.1 =
56
+ * Feature: Dynamic Shortcodes.
57
+ * Feature: LESS.js support.
58
+ * Bug Fix: Proper output escaping.
59
+
60
  = 3.0.3 =
61
+ * Bug Fix: wpautop formatting.
62
 
63
  = 3.0.2 =
64
  * Bug Fix: Fatal Error on post save
107
 
108
  == Upgrade Notice ==
109
 
110
+ = 3.1 =
111
+ New Features and Bug fixes
112
+
113
  = 3.0.3 =
114
+ Bug fix (wpauto issue)
115
 
116
  = 3.0.2 =
117
  Bug fix
css/code-editor.css ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #newcontent {
2
+ display: block;
3
+ }
4
+ .CodeMirror {
5
+ border: 1px solid #DFDFDF;
6
+ background-color: white;
7
+ border-radius: 3px;
8
+ margin: 8px 0;
9
+ -moz-background-clip: padding;
10
+ -webkit-background-clip: padding-box;
11
+ background-clip: padding-box;
12
+ overflow: hidden;
13
+ }
14
+ body .CodeMirror-scroll {
15
+ height: auto;
16
+ overflow: auto;
17
+ }
18
+ #template .CodeMirror div {
19
+ margin-right: 0;
20
+ }
css/less.css ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* Loosely based on the Midlesscss Textmate theme */
2
+
3
+ .cm-s-lesscss { background: #262626; color: #f8f8f8; }
4
+ .cm-s-lesscss span.CodeMirror-selected { background: #a8f !important; }
5
+ .cm-s-lesscss .CodeMirror-gutter { background: #0a001f; border-right: 1px solid #aaa; }
6
+ .cm-s-lesscss .CodeMirror-gutter-text { color: #f8f8f8; }
7
+ .cm-s-lesscss .CodeMirror-cursor { border-left: 1px solid white !important; }
8
+
9
+ .cm-s-lesscss span.cm-variable { color: #D9BF8C; }
10
+ .cm-s-lesscss span.cm-comment { color: #666; }
11
+ .cm-s-lesscss span.cm-atom { color: #C2B470; /*#845dc4;*/ }
12
+ .cm-s-lesscss span.cm-number,
13
+ .cm-s-lesscss span.cm-attribute { color: #B35E4D; }
14
+ .cm-s-lesscss span.cm-keyword { color: #599eff; }
15
+ .cm-s-lesscss span.cm-string { color: #BCD279; }
16
+ .cm-s-lesscss span.cm-meta { color: #738C73; }
17
+ .cm-s-lesscss span.cm-variable-2,
18
+ .cm-s-lesscss span.cm-tag { color: #669199; }
19
+ .cm-s-lesscss span.cm-variable-3,
20
+ .cm-s-lesscss span.cm-def { color: white; }
21
+ .cm-s-lesscss span.cm-error { color: #9d1e15; }
22
+ .cm-s-lesscss span.cm-bracket { color: #EBEFE7; }
23
+ .cm-s-lesscss span.cm-builtin,
24
+ .cm-s-lesscss span.cm-special { color: #ff9e59; }
includes/class.SnS_AJAX.php CHANGED
@@ -58,8 +58,12 @@ class SnS_AJAX
58
  $styles = self::maybe_set( $styles, 'classes_body' );
59
  $styles = self::maybe_set( $styles, 'classes_post' );
60
 
61
- if ( ! empty( $styles ) )
 
 
 
62
  $SnS[ 'styles' ] = $styles;
 
63
  self::maybe_update( $post_id, '_SnS', $SnS );
64
 
65
  header('Content-Type: application/json; charset=' . get_option('blog_charset'));
@@ -84,8 +88,12 @@ class SnS_AJAX
84
  $scripts = self::maybe_set( $scripts, 'scripts_in_head' );
85
  $scripts = self::maybe_set( $scripts, 'scripts' );
86
 
87
- if ( ! empty( $scripts ) )
 
 
 
88
  $SnS[ 'scripts' ] = $scripts;
 
89
  self::maybe_update( $post_id, '_SnS', $SnS );
90
 
91
  header('Content-Type: application/json; charset=' . get_option('blog_charset'));
@@ -109,8 +117,12 @@ class SnS_AJAX
109
 
110
  $styles = self::maybe_set( $styles, 'styles' );
111
 
112
- if ( ! empty( $styles ) )
 
 
 
113
  $SnS[ 'styles' ] = $styles;
 
114
  self::maybe_update( $post_id, '_SnS', $SnS );
115
 
116
  header('Content-Type: application/json; charset=' . get_option('blog_charset'));
@@ -144,8 +156,7 @@ class SnS_AJAX
144
  // pass title as key to be able to delete.
145
  $styles[ 'classes_mce' ][ $_REQUEST[ 'format' ][ 'title' ] ] = $_REQUEST[ 'format' ];
146
 
147
- if ( ! empty( $styles ) )
148
- $SnS[ 'styles' ] = $styles;
149
  update_post_meta( $post_id, '_SnS', $SnS );
150
 
151
  header('Content-Type: application/json; charset=' . get_option('blog_charset'));
@@ -171,8 +182,12 @@ class SnS_AJAX
171
 
172
  if ( empty( $styles[ 'classes_mce' ] ) ) unset( $styles[ 'classes_mce' ] );
173
 
174
- if ( ! empty( $styles ) )
 
 
 
175
  $SnS[ 'styles' ] = $styles;
 
176
  self::maybe_update( $post_id, '_SnS', $SnS );
177
 
178
  if ( ! isset( $styles[ 'classes_mce' ] ) ) $styles[ 'classes_mce' ] = array( 'Empty' );
58
  $styles = self::maybe_set( $styles, 'classes_body' );
59
  $styles = self::maybe_set( $styles, 'classes_post' );
60
 
61
+ if ( empty( $styles ) ) {
62
+ if ( isset( $SnS['styles'] ) )
63
+ unset( $SnS['styles'] );
64
+ } else {
65
  $SnS[ 'styles' ] = $styles;
66
+ }
67
  self::maybe_update( $post_id, '_SnS', $SnS );
68
 
69
  header('Content-Type: application/json; charset=' . get_option('blog_charset'));
88
  $scripts = self::maybe_set( $scripts, 'scripts_in_head' );
89
  $scripts = self::maybe_set( $scripts, 'scripts' );
90
 
91
+ if ( empty( $scripts ) ) {
92
+ if ( isset( $SnS['scripts'] ) )
93
+ unset( $SnS['scripts'] );
94
+ } else {
95
  $SnS[ 'scripts' ] = $scripts;
96
+ }
97
  self::maybe_update( $post_id, '_SnS', $SnS );
98
 
99
  header('Content-Type: application/json; charset=' . get_option('blog_charset'));
117
 
118
  $styles = self::maybe_set( $styles, 'styles' );
119
 
120
+ if ( empty( $styles ) ) {
121
+ if ( isset( $SnS['styles'] ) )
122
+ unset( $SnS['styles'] );
123
+ } else {
124
  $SnS[ 'styles' ] = $styles;
125
+ }
126
  self::maybe_update( $post_id, '_SnS', $SnS );
127
 
128
  header('Content-Type: application/json; charset=' . get_option('blog_charset'));
156
  // pass title as key to be able to delete.
157
  $styles[ 'classes_mce' ][ $_REQUEST[ 'format' ][ 'title' ] ] = $_REQUEST[ 'format' ];
158
 
159
+ $SnS[ 'styles' ] = $styles;
 
160
  update_post_meta( $post_id, '_SnS', $SnS );
161
 
162
  header('Content-Type: application/json; charset=' . get_option('blog_charset'));
182
 
183
  if ( empty( $styles[ 'classes_mce' ] ) ) unset( $styles[ 'classes_mce' ] );
184
 
185
+ if ( empty( $styles ) ) {
186
+ if ( isset( $SnS['styles'] ) )
187
+ unset( $SnS['styles'] );
188
+ } else {
189
  $SnS[ 'styles' ] = $styles;
190
+ }
191
  self::maybe_update( $post_id, '_SnS', $SnS );
192
 
193
  if ( ! isset( $styles[ 'classes_mce' ] ) ) $styles[ 'classes_mce' ] = array( 'Empty' );
includes/class.SnS_Admin.php CHANGED
@@ -8,6 +8,7 @@
8
  */
9
 
10
  require_once( 'class.SnS_Admin_Meta_Box.php' );
 
11
  require_once( 'class.SnS_Settings_Page.php' );
12
  require_once( 'class.SnS_Usage_Page.php' );
13
  require_once( 'class.SnS_Global_Page.php' );
@@ -16,20 +17,22 @@ require_once( 'class.SnS_Form.php' );
16
 
17
  class SnS_Admin
18
  {
19
- /**#@+
20
- * Constants
21
- */
22
  const OPTION_GROUP = 'scripts_n_styles';
23
  const MENU_SLUG = 'sns';
24
  static $parent_slug = '';
25
- /**#@-*/
26
 
27
- /**
28
  * Initializing method.
29
- * @static
30
- */
31
  static function init() {
32
  add_action( 'admin_menu', array( 'SnS_Admin_Meta_Box', 'init' ) );
 
 
33
 
34
  add_action( 'admin_menu', array( __CLASS__, 'menu' ) );
35
 
@@ -75,9 +78,9 @@ class SnS_Admin
75
  SnS_Usage_Page::init();
76
  }
77
 
78
- /**
79
  * Nav Tabs
80
- */
81
  function nav() {
82
  $options = get_option( 'SnS_options' );
83
  $page = $_REQUEST[ 'page' ];
@@ -94,54 +97,40 @@ class SnS_Admin
94
  <?php
95
  }
96
 
97
- /**
98
  * Settings Page help
99
- */
100
  function help() {
101
- global $wp_version; // Back Compat for now
102
- if ( version_compare( $wp_version, '3.2.1', '>') ) {
103
- $screen = get_current_screen();
104
- if ( 'post' != $screen->id ) {
105
- $screen->add_help_tab( array(
106
- 'title' => __( 'Scripts n Styles', 'scripts-n-styles' ),
107
- 'id' => 'scripts-n-styles',
108
- 'content' =>
109
- '<p>' . __( '<p>In default (non MultiSite) WordPress installs, both <em>Administrators</em> and
110
- <em>Editors</em> can access <em>Scripts-n-Styles</em> on individual edit screens.
111
- Only <em>Administrators</em> can access this Options Page. In MultiSite WordPress installs, only
112
- <em>"Super Admin"</em> users can access either
113
- <em>Scripts-n-Styles</em> on individual edit screens or this Options Page. If other plugins change
114
- capabilities (specifically "unfiltered_html"),
115
- other users can be granted access.</p>', 'scripts-n-styles' ) . '</p>'
116
- )
117
- );
118
- $screen->set_help_sidebar(
119
- '<p><strong>' . __( 'For more information:', 'scripts-n-styles' ) . '</strong></p>' .
120
  '<p>' . __( '<a href="http://wordpress.org/extend/plugins/scripts-n-styles/faq/" target="_blank">Frequently Asked Questions</a>', 'scripts-n-styles' ) . '</p>' .
121
  '<p>' . __( '<a href="https://github.com/unFocus/Scripts-n-Styles" target="_blank">Source on github</a>', 'scripts-n-styles' ) . '</p>' .
122
- '<p>' . __( '<a href="http://wordpress.org/tags/scripts-n-styles" target="_blank">Support Forums</a>', 'scripts-n-styles' ) . '</p>'
123
- );
124
- } else {
125
- $screen->add_help_tab( array(
126
- 'title' => __( 'Scripts n Styles', 'scripts-n-styles' ),
127
- 'id' => 'scripts-n-styles',
128
- 'content' =>
129
- '<p>' . __( '<p>In default (non MultiSite) WordPress installs, both <em>Administrators</em> and
130
- <em>Editors</em> can access <em>Scripts-n-Styles</em> on individual edit screens.
131
- Only <em>Administrators</em> can access this Options Page. In MultiSite WordPress installs, only
132
- <em>"Super Admin"</em> users can access either
133
- <em>Scripts-n-Styles</em> on individual edit screens or this Options Page. If other plugins change
134
- capabilities (specifically "unfiltered_html"),
135
- other users can be granted access.</p>', 'scripts-n-styles' ) . '</p>'
136
- )
137
- );
138
- }
139
  }
140
  }
141
 
142
- /**
143
  * Utility Method: Sets defaults if not previously set. Sets stored 'version' to VERSION.
144
- */
145
  static function upgrade() {
146
  $options = get_option( 'SnS_options' );
147
  if ( ! $options ) $options = array();
@@ -190,14 +179,14 @@ class SnS_Admin
190
  delete_post_meta( $post->ID, '_SnS_styles' );
191
  delete_post_meta( $post->ID, '_SnS_scripts' );
192
  }
193
-
194
  }
195
 
196
- /**
197
  * Adds link to the Settings Page in the WordPress "Plugin Action Links" array.
198
  * @param array $actions
199
  * @return array
200
- */
201
  static function plugin_action_links( $actions ) {
202
  $actions[ 'settings' ] = '<a href="' . menu_page_url( SnS_Settings_Page::MENU_SLUG, false ) . '"/>' . __( 'Settings' ) . '</a>';
203
  return $actions;
8
  */
9
 
10
  require_once( 'class.SnS_Admin_Meta_Box.php' );
11
+ require_once( 'class.SnS_Admin_Code_Editor.php' );
12
  require_once( 'class.SnS_Settings_Page.php' );
13
  require_once( 'class.SnS_Usage_Page.php' );
14
  require_once( 'class.SnS_Global_Page.php' );
17
 
18
  class SnS_Admin
19
  {
20
+ /**#@+
21
+ * Constants
22
+ */
23
  const OPTION_GROUP = 'scripts_n_styles';
24
  const MENU_SLUG = 'sns';
25
  static $parent_slug = '';
26
+ /**#@-*/
27
 
28
+ /**
29
  * Initializing method.
30
+ * @static
31
+ */
32
  static function init() {
33
  add_action( 'admin_menu', array( 'SnS_Admin_Meta_Box', 'init' ) );
34
+ add_action( 'admin_menu', array( 'SnS_Admin_Code_Editor', 'init' ) );
35
+ add_action( 'network_admin_menu', array( 'SnS_Admin_Code_Editor', 'init' ) );
36
 
37
  add_action( 'admin_menu', array( __CLASS__, 'menu' ) );
38
 
78
  SnS_Usage_Page::init();
79
  }
80
 
81
+ /**
82
  * Nav Tabs
83
+ */
84
  function nav() {
85
  $options = get_option( 'SnS_options' );
86
  $page = $_REQUEST[ 'page' ];
97
  <?php
98
  }
99
 
100
+ /**
101
  * Settings Page help
102
+ */
103
  function help() {
104
+ $help = '<p>' . __( 'In default (non MultiSite) WordPress installs, both <em>Administrators</em> and <em>Editors</em> can access <em>Scripts-n-Styles</em> on individual edit screens. Only <em>Administrators</em> can access this Options Page. In MultiSite WordPress installs, only <em>"Super Admin"</em> users can access either <em>Scripts-n-Styles</em> on individual edit screens or this Options Page. If other plugins change capabilities (specifically "unfiltered_html"), other users can be granted access.', 'scripts-n-styles' ) . '</p>';
105
+ $help .= '<p><strong>' . __( 'Reference: jQuery Wrappers', 'scripts-n-styles' ) . '</strong></p>' .
106
+ '<pre><code>jQuery(document).ready(function($) {
107
+ // $() will work as an alias for jQuery() inside of this function
108
+ });</code></pre>';
109
+ $help .= '<pre><code>(function($) {
110
+ // $() will work as an alias for jQuery() inside of this function
111
+ })(jQuery);</code></pre>';
112
+ $sidebar = '<p><strong>' . __( 'For more information:', 'scripts-n-styles' ) . '</strong></p>' .
 
 
 
 
 
 
 
 
 
 
113
  '<p>' . __( '<a href="http://wordpress.org/extend/plugins/scripts-n-styles/faq/" target="_blank">Frequently Asked Questions</a>', 'scripts-n-styles' ) . '</p>' .
114
  '<p>' . __( '<a href="https://github.com/unFocus/Scripts-n-Styles" target="_blank">Source on github</a>', 'scripts-n-styles' ) . '</p>' .
115
+ '<p>' . __( '<a href="http://wordpress.org/tags/scripts-n-styles" target="_blank">Support Forums</a>', 'scripts-n-styles' ) . '</p>';
116
+ $screen = get_current_screen();
117
+ if ( method_exists( $screen, 'add_help_tab' ) ) {
118
+ $screen->add_help_tab( array(
119
+ 'title' => __( 'Scripts n Styles', 'scripts-n-styles' ),
120
+ 'id' => 'scripts-n-styles',
121
+ 'content' => $help
122
+ )
123
+ );
124
+ if ( 'post' != $screen->id )
125
+ $screen->set_help_sidebar( $sidebar );
126
+ } else {
127
+ add_contextual_help( $screen, $help . $sidebar );
 
 
 
 
128
  }
129
  }
130
 
131
+ /**
132
  * Utility Method: Sets defaults if not previously set. Sets stored 'version' to VERSION.
133
+ */
134
  static function upgrade() {
135
  $options = get_option( 'SnS_options' );
136
  if ( ! $options ) $options = array();
179
  delete_post_meta( $post->ID, '_SnS_styles' );
180
  delete_post_meta( $post->ID, '_SnS_scripts' );
181
  }
182
+
183
  }
184
 
185
+ /**
186
  * Adds link to the Settings Page in the WordPress "Plugin Action Links" array.
187
  * @param array $actions
188
  * @return array
189
+ */
190
  static function plugin_action_links( $actions ) {
191
  $actions[ 'settings' ] = '<a href="' . menu_page_url( SnS_Settings_Page::MENU_SLUG, false ) . '"/>' . __( 'Settings' ) . '</a>';
192
  return $actions;
includes/class.SnS_Admin_Code_Editor.php ADDED
@@ -0,0 +1,90 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * SnS_Admin_Code_Editor
4
+ */
5
+
6
+ class SnS_Admin_Code_Editor
7
+ {
8
+ /**
9
+ * Initializing method.
10
+ */
11
+ function init() {
12
+ add_action( 'admin_head-theme-editor.php', array( __CLASS__, 'styles' ) );
13
+ add_action( 'admin_head-plugin-editor.php', array( __CLASS__, 'styles' ) );
14
+
15
+ }
16
+
17
+ function styles() {
18
+ $options = get_option( 'SnS_options' );
19
+ $cm_theme = isset( $options[ 'cm_theme' ] ) ? $options[ 'cm_theme' ] : 'default';
20
+
21
+ wp_enqueue_style( 'codemirror', plugins_url( 'libraries/CodeMirror2/lib/codemirror.css', Scripts_n_Styles::$file), array(), '2.2' );
22
+
23
+ if ( in_array( $cm_theme, array( 'cobalt', 'eclipse', 'elegant', 'monokai', 'neat', 'night', 'rubyblue' ) ) )
24
+ wp_enqueue_style( "codemirror-$cm_theme", plugins_url( "libraries/CodeMirror2/theme/$cm_theme.css", Scripts_n_Styles::$file), array( 'codemirror' ), '2.2' );
25
+
26
+ wp_enqueue_style( 'sns-code-editor', plugins_url( 'css/code-editor.css', Scripts_n_Styles::$file), array( 'codemirror' ), Scripts_n_Styles::VERSION );
27
+
28
+ wp_enqueue_script(
29
+ 'codemirror',
30
+ plugins_url( 'libraries/CodeMirror2/lib/codemirror.js', Scripts_n_Styles::$file),
31
+ array(),
32
+ '2.2' );
33
+ wp_enqueue_script(
34
+ 'codemirror-css',
35
+ plugins_url( 'libraries/CodeMirror2/mode/css/css.js', Scripts_n_Styles::$file),
36
+ array( 'codemirror' ),
37
+ '2.2' );
38
+ wp_enqueue_script(
39
+ 'codemirror-less',
40
+ plugins_url( 'libraries/CodeMirror2/mode/less/less.js', Scripts_n_Styles::$file),
41
+ array( 'codemirror' ),
42
+ '2.2' );
43
+ wp_enqueue_script(
44
+ 'codemirror-javascript',
45
+ plugins_url( 'libraries/CodeMirror2/mode/javascript/javascript.js', Scripts_n_Styles::$file),
46
+ array( 'codemirror' ),
47
+ '2.2' );
48
+ wp_register_script(
49
+ 'codemirror-xml',
50
+ plugins_url( 'libraries/CodeMirror2/mode/xml/xml.js', Scripts_n_Styles::$file),
51
+ array( 'codemirror' ),
52
+ '2.2' );
53
+ wp_register_script(
54
+ 'codemirror-htmlmixed',
55
+ plugins_url( 'libraries/CodeMirror2/mode/htmlmixed/htmlmixed.js', Scripts_n_Styles::$file),
56
+ array( 'codemirror-xml',
57
+ 'codemirror-css',
58
+ 'codemirror-javascript'
59
+ ),
60
+ '2.2' );
61
+ wp_register_script(
62
+ 'codemirror-clike',
63
+ plugins_url( 'libraries/CodeMirror2/mode/clike/clike.js', Scripts_n_Styles::$file),
64
+ array( 'codemirror' ),
65
+ '2.2' );
66
+ wp_register_script(
67
+ 'codemirror-php',
68
+ plugins_url( 'libraries/CodeMirror2/mode/php/php.js', Scripts_n_Styles::$file),
69
+ array( 'codemirror-xml',
70
+ 'codemirror-css',
71
+ 'codemirror-javascript',
72
+ 'codemirror-clike'
73
+ ),
74
+ '2.2' );
75
+ wp_enqueue_script(
76
+ 'sns-code-editor',
77
+ plugins_url( 'js/code-editor.js', Scripts_n_Styles::$file),
78
+ array( 'editor',
79
+ 'jquery-ui-tabs',
80
+ 'codemirror-javascript',
81
+ 'codemirror-css',
82
+ 'codemirror-htmlmixed',
83
+ 'codemirror-php'
84
+ ),
85
+ Scripts_n_Styles::VERSION, true );
86
+
87
+ wp_localize_script( 'sns-code-editor', 'codemirror_options', array( 'theme' => $cm_theme ) );
88
+ }
89
+ }
90
+ ?>
includes/class.SnS_Admin_Meta_Box.php CHANGED
@@ -9,23 +9,19 @@
9
 
10
  class SnS_Admin_Meta_Box
11
  {
12
- /*
13
- * Constants
14
- */
15
  const NONCE_NAME = 'scripts_n_styles_noncename';
16
 
17
  static $post_types;
18
 
19
- /**
20
  * Initializing method.
21
  */
22
  static function init() {
23
  add_action( 'add_meta_boxes', array( __CLASS__, 'add_meta_boxes' ) );
24
  add_action( 'save_post', array( __CLASS__, 'save_post' ) );
25
-
26
- add_filter( 'mce_buttons_2', array( __CLASS__, 'mce_buttons_2' ) );
27
- add_filter( 'tiny_mce_before_init', array( __CLASS__, 'tiny_mce_before_init' ) );
28
- add_filter( 'mce_css', array( __CLASS__, 'mce_css' ) );
29
  }
30
 
31
  function mce_buttons_2( $buttons ) {
@@ -72,10 +68,10 @@ class SnS_Admin_Meta_Box
72
  return $initArray;
73
  }
74
 
75
- /**
76
  * Admin Action: 'mce_css'
77
  * Adds a styles sheet to TinyMCE via ajax that contains the current styles data.
78
- */
79
  static function mce_css( $mce_css ) {
80
  global $post;
81
  $url = admin_url( 'admin-ajax.php' );
@@ -85,48 +81,49 @@ class SnS_Admin_Meta_Box
85
  $mce_css .= ',' . $url;
86
  return $mce_css;
87
  }
88
-
89
- /**
90
  * Admin Action: 'add_meta_boxes'
91
  * Main Meta Box function. Checks restriction options and display options, calls add_meta_box() and adds actions for adding admin CSS and JavaScript.
92
- */
93
  static function add_meta_boxes() {
94
  if ( current_user_can( 'unfiltered_html' ) ) {
95
- self::$post_types = get_post_types( array('show_ui' => true, 'public' => true) ); // updated for http://core.trac.wordpress.org/changeset/18234
96
- foreach ( self::$post_types as $post_type ) {
97
  add_meta_box( 'SnS_meta_box', __( 'Scripts n Styles', 'scripts-n-styles' ), array( __CLASS__, 'admin_meta_box' ), $post_type, 'normal', 'high' );
 
 
 
 
 
 
 
98
  }
99
- add_filter( 'default_hidden_meta_boxes', array( __CLASS__, 'default_hidden_meta_boxes' ) );
100
- add_action( "admin_print_styles", array( __CLASS__, 'meta_box_styles'));
101
- add_action( "admin_print_scripts", array( __CLASS__, 'meta_box_scripts'));
102
- add_filter( 'contextual_help', array( 'SnS_Admin', 'help' ) );
103
  }
104
  }
105
 
106
  static function default_hidden_meta_boxes( $hidden ) {
107
  $options = get_option( 'SnS_options' );
108
- if ( ! isset( $options[ 'metabox' ] ) )
109
- $hidden[] = 'SnS_meta_box';
110
- else if ( 'yes' == $options[ 'metabox' ] )
111
  $hidden[] = 'SnS_meta_box';
112
-
113
- return $hidden;
 
114
  }
115
 
116
- /**
117
  * Admin Action: 'add_meta_boxes'
118
  * Outputs the Meta Box. Only called on callback from add_meta_box() during the add_meta_boxes action.
119
  * @param unknown_type WordPress Post object.
120
- */
121
  static function admin_meta_box( $post ) {
122
  $registered_handles = Scripts_n_Styles::get_wp_registered();
123
  $SnS = get_post_meta( $post->ID, '_SnS', true );
124
  $styles = isset( $SnS['styles'] ) ? $SnS[ 'styles' ]: array();
125
  $scripts = isset( $SnS['scripts'] ) ? $SnS[ 'scripts' ]: array();
126
 
127
- $screen = get_current_screen();
128
  $position = get_user_option( "current_sns_tab" );
129
- if ( ! in_array( $position, array( 's0', 's1', 's2', 's3' ) ) ) $position = 's0';
130
  wp_nonce_field( Scripts_n_Styles::$file, self::NONCE_NAME );
131
  ?>
132
  <ul class="wp-tab-bar">
@@ -134,21 +131,22 @@ class SnS_Admin_Meta_Box
134
  <li<?php echo ( 's1' == $position ) ? ' class="wp-tab-active"': ''; ?>><a href="#SnS_styles-tab"><?php _e( 'Styles', 'scripts-n-styles' ) ?></a></li>
135
  <li<?php echo ( 's2' == $position ) ? ' class="wp-tab-active"': ''; ?>><a href="#SnS_classes_body-tab"><?php _e( 'Classes', 'scripts-n-styles' ) ?></a></li>
136
  <li<?php echo ( 's3' == $position ) ? ' class="wp-tab-active"': ''; ?>><a href="#SnS_enqueue_scripts-tab"><?php _e( 'Include Scripts', 'scripts-n-styles' ) ?></a></li>
 
137
  </ul>
138
 
139
  <div class="wp-tab-panel" id="SnS_scripts-tab">
140
  <p><em><?php _e( "This code will be included <strong>verbatim</strong> in <code>&lt;script></code> tags at the end of your page's (or post's)", 'scripts-n-styles' ) ?> ...</em></p>
141
  <label for="SnS_scripts_in_head" class="title"><?php _e( '<strong>Scripts</strong> (for the <code>head</code> element):', 'scripts-n-styles' ) ?> </label>
142
- <textarea class="codemirror js" name="SnS_scripts_in_head" id="SnS_scripts_in_head" rows="5" cols="40" style="width: 98%;"><?php echo isset( $scripts[ 'scripts_in_head' ] ) ? $scripts[ 'scripts_in_head' ] : ''; ?></textarea>
143
  <p><em>... <code>&lt;/head></code> <?php _e( 'tag', 'scripts-n-styles' ) ?>.</em></p>
144
  <label for="SnS_scripts" class="title"><strong>Scripts</strong>: </label>
145
- <textarea class="codemirror js" name="SnS_scripts" id="SnS_scripts" rows="5" cols="40" style="width: 98%;"><?php echo isset( $scripts[ 'scripts' ] ) ? $scripts[ 'scripts' ] : ''; ?></textarea>
146
  <p><em>... <code>&lt;/body></code> <?php _e( 'tag', 'scripts-n-styles' ) ?>.</em></p>
147
  </div>
148
 
149
  <div class="wp-tab-panel" id="SnS_styles-tab">
150
  <label for="SnS_styles" class="title"><?php _e( '<strong>Styles</strong>:', 'scripts-n-styles' ) ?> </label>
151
- <textarea class="codemirror css" name="SnS_styles" id="SnS_styles" rows="5" cols="40" style="width: 98%;"><?php echo isset( $styles[ 'styles' ] ) ? $styles[ 'styles' ] : ''; ?></textarea>
152
  <p><em><?php _e( 'This code will be included <strong>verbatim</strong> in <code>&lt;style></code> tags in the <code>&lt;head></code> tag of your page (or post).', 'scripts-n-styles' ) ?></em></p>
153
  </div>
154
 
@@ -158,13 +156,13 @@ class SnS_Admin_Meta_Box
158
  <p>
159
  <label for="SnS_classes_body"><?php _e( '<strong>Body Classes</strong>:', 'scripts-n-styles' ) ?> </label>
160
  <input name="SnS_classes_body" id="SnS_classes_body" type="text" class="code" style="width: 99%;"
161
- value="<?php echo isset( $styles[ 'classes_body' ] ) ? $styles[ 'classes_body' ] : ''; ?>" />
162
  <small><?php _e( 'Standard:', 'scripts-n-styles' ) ?> <code><?php self::current_classes( 'body', $post->ID ); ?></code></small>
163
  </p>
164
  <p>
165
  <label for="SnS_classes_post"><strong>Post Classes</strong>: </label>
166
  <input name="SnS_classes_post" id="SnS_classes_post" type="text" class="code" style="width: 99%;"
167
- value="<?php echo isset( $styles[ 'classes_post' ] ) ? $styles[ 'classes_post' ] : ''; ?>" />
168
  <small><?php _e( 'Standard:', 'scripts-n-styles' ) ?> <code><?php self::current_classes( 'post', $post->ID ); ?></code></small>
169
  </p>
170
  <p><em><?php _e( 'These <strong>space separated</strong> class names will be added to the <code>body_class()</code> or <code>post_class()</code> function (provided your theme uses these functions).', 'scripts-n-styles' ) ?></em></p>
@@ -220,21 +218,44 @@ class SnS_Admin_Meta_Box
220
  <?php
221
  if ( ! empty( $scripts[ 'enqueue_scripts' ] ) && is_array( $scripts[ 'enqueue_scripts' ] ) ) {
222
  foreach ( $registered_handles as $value ) { ?>
223
- <option value="<?php echo $value ?>"<?php foreach ( $scripts[ 'enqueue_scripts' ] as $handle ) selected( $handle, $value ); ?>><?php echo $value ?></option>
224
  <?php }
225
  } else {
226
  foreach ( $registered_handles as $value ) { ?>
227
- <option value="<?php echo $value ?>"><?php echo $value ?></option>
228
  <?php }
229
  } ?>
230
  </select>
231
  <?php if ( ! empty( $scripts[ 'enqueue_scripts' ] ) && is_array( $scripts[ 'enqueue_scripts' ] ) ) { ?>
232
  <p><?php _e( 'Currently Enqueued Scripts:', 'scripts-n-styles' ) ?>
233
- <?php foreach ( $scripts[ 'enqueue_scripts' ] as $handle ) echo '<code>' . $handle . '</code> '; ?>
234
  </p>
235
  <?php } ?>
236
  <p><em><?php _e( 'The chosen scripts will be enqueued and placed before your codes if your code is dependant on certain scripts (like jQuery).', 'scripts-n-styles' ) ?></em></p>
237
  </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
238
  <?php
239
  }
240
 
@@ -259,89 +280,51 @@ class SnS_Admin_Meta_Box
259
  }
260
  }
261
 
262
- /**
263
  * Admin Action: 'admin_print_styles' Action added during 'add_meta_boxes' (which restricts output to Edit Screens).
264
  * Enqueues the CSS for admin styling of the Meta Box.
265
- */
266
  static function meta_box_styles() {
267
  $options = get_option( 'SnS_options' );
268
  $cm_theme = isset( $options[ 'cm_theme' ] ) ? $options[ 'cm_theme' ] : 'default';
269
-
270
- wp_enqueue_style( 'codemirror', plugins_url( 'libraries/CodeMirror2/lib/codemirror.css', Scripts_n_Styles::$file), array(), '2.18' );
271
- wp_enqueue_style( "codemirror-$cm_theme", plugins_url( "libraries/CodeMirror2/theme/$cm_theme.css", Scripts_n_Styles::$file), array( 'codemirror' ), '2.18' );
 
272
  wp_enqueue_style( 'sns-meta-box-styles', plugins_url( 'css/meta-box-styles.css', Scripts_n_Styles::$file), array( 'codemirror' ), Scripts_n_Styles::VERSION );
273
  }
274
 
275
- /**
276
  * Admin Action: 'admin_print_styles' Action added during 'add_meta_boxes' (which restricts output to Edit Screens).
277
  * Enqueues the JavaScript for the admin Meta Box.
278
- */
279
  static function meta_box_scripts() {
280
  $options = get_option( 'SnS_options' );
281
  $cm_theme = isset( $options[ 'cm_theme' ] ) ? $options[ 'cm_theme' ] : 'default';
 
 
282
 
283
- wp_enqueue_script(
284
- 'codemirror',
285
- plugins_url( 'libraries/CodeMirror2/lib/codemirror.js', Scripts_n_Styles::$file),
286
- array(),
287
- '2.18' );
288
- wp_enqueue_script(
289
- 'codemirror-css',
290
- plugins_url( 'libraries/CodeMirror2/mode/css/css.js', Scripts_n_Styles::$file),
291
- array( 'codemirror' ),
292
- '2.18' );
293
- wp_enqueue_script(
294
- 'codemirror-javascript',
295
- plugins_url( 'libraries/CodeMirror2/mode/javascript/javascript.js', Scripts_n_Styles::$file),
296
- array( 'codemirror' ),
297
- '2.18' );
298
- /*wp_register_script(
299
- 'codemirror-xml',
300
- plugins_url( 'libraries/CodeMirror2/mode/xml/xml.js', Scripts_n_Styles::$file),
301
- array( 'codemirror' ),
302
- '2.11' );*/
303
- /*wp_register_script(
304
- 'codemirror-htmlmixed',
305
- plugins_url( 'libraries/CodeMirror2/mode/htmlmixed/htmlmixed.js', Scripts_n_Styles::$file),
306
- array( 'codemirror-xml',
307
- 'codemirror-css',
308
- 'codemirror-javascript'
309
- ),
310
- '2.11' );*/
311
- /*wp_register_script(
312
- 'codemirror-clike',
313
- plugins_url( 'libraries/CodeMirror2/mode/clike/clike.js', Scripts_n_Styles::$file),
314
- array( 'codemirror' ),
315
- '2.11' );
316
- wp_register_script(
317
- 'codemirror-php',
318
- plugins_url( 'libraries/CodeMirror2/mode/php/php.js', Scripts_n_Styles::$file),
319
- array( 'codemirror-xml',
320
- 'codemirror-css',
321
- 'codemirror-javascript',
322
- 'codemirror-clike'
323
- ),
324
- '2.11' );*/
325
- wp_enqueue_script(
326
- 'sns-meta-box-scripts',
327
- plugins_url( 'js/meta-box-scripts.js', Scripts_n_Styles::$file),
328
- array( 'editor',
329
- 'jquery-ui-tabs',
330
- 'codemirror-javascript',
331
- 'codemirror-css'//,
332
- //'codemirror-htmlmixed',
333
- //'codemirror-php'
334
- ),
335
- Scripts_n_Styles::VERSION, true );
336
 
337
  wp_localize_script( 'sns-meta-box-scripts', 'codemirror_options', array( 'theme' => $cm_theme ) );
338
  }
339
 
340
- /**
341
  * Admin Action: 'save_post'
342
  * Saves the values entered in the Meta Box when a post is saved (on the Edit Screen only, excluding autosaves) if the user has permission.
343
  * @param int $post_id ID value of the WordPress post.
344
- */
345
  static function save_post( $post_id ) {
346
  if ( ! isset( $_POST[ self::NONCE_NAME ] ) || ! wp_verify_nonce( $_POST[ self::NONCE_NAME ], Scripts_n_Styles::$file )
347
  || ! current_user_can( 'unfiltered_html' )
@@ -359,14 +342,28 @@ class SnS_Admin_Meta_Box
359
 
360
  $SnS = get_post_meta( $post_id, '_SnS', true );
361
  $scripts = isset( $SnS['scripts'] ) ? $SnS[ 'scripts' ]: array();
362
- $styles = isset( $SnS['styles'] ) ? $SnS[ 'styles' ]: array();
363
 
364
  $scripts = self::maybe_set( $scripts, 'scripts_in_head' );
365
  $scripts = self::maybe_set( $scripts, 'scripts' );
366
  $scripts = self::maybe_set( $scripts, 'enqueue_scripts' );
367
- $styles = self::maybe_set( $styles, 'styles' );
368
- $styles = self::maybe_set( $styles, 'classes_body' );
369
- $styles = self::maybe_set( $styles, 'classes_post' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
370
 
371
  // This one isn't posted, it's ajax only. Cleanup anyway.
372
  if ( isset( $styles[ 'classes_mce' ] ) && empty( $styles[ 'classes_mce' ] ) )
@@ -386,16 +383,23 @@ class SnS_Admin_Meta_Box
386
  $SnS['styles'] = $styles;
387
  }
388
 
 
 
 
 
 
 
 
389
  if ( empty( $SnS ) )
390
  delete_post_meta( $post_id, '_SnS' );
391
  else
392
  update_post_meta( $post_id, '_SnS', $SnS );
393
  }
394
 
395
- /**
396
  * maybe_set()
397
  * Filters $o and Checks if the sent data $i is empty (intended to clear). If not, updates.
398
- */
399
  function maybe_set( $o, $i, $p = 'SnS_' ) {
400
  if ( empty( $_REQUEST[ $p . $i ] ) ) {
401
  if ( isset( $o[ $i ] ) ) unset( $o[ $i ] );
9
 
10
  class SnS_Admin_Meta_Box
11
  {
12
+ /*
13
+ * Constants
14
+ */
15
  const NONCE_NAME = 'scripts_n_styles_noncename';
16
 
17
  static $post_types;
18
 
19
+ /**
20
  * Initializing method.
21
  */
22
  static function init() {
23
  add_action( 'add_meta_boxes', array( __CLASS__, 'add_meta_boxes' ) );
24
  add_action( 'save_post', array( __CLASS__, 'save_post' ) );
 
 
 
 
25
  }
26
 
27
  function mce_buttons_2( $buttons ) {
68
  return $initArray;
69
  }
70
 
71
+ /**
72
  * Admin Action: 'mce_css'
73
  * Adds a styles sheet to TinyMCE via ajax that contains the current styles data.
74
+ */
75
  static function mce_css( $mce_css ) {
76
  global $post;
77
  $url = admin_url( 'admin-ajax.php' );
81
  $mce_css .= ',' . $url;
82
  return $mce_css;
83
  }
84
+
85
+ /**
86
  * Admin Action: 'add_meta_boxes'
87
  * Main Meta Box function. Checks restriction options and display options, calls add_meta_box() and adds actions for adding admin CSS and JavaScript.
88
+ */
89
  static function add_meta_boxes() {
90
  if ( current_user_can( 'unfiltered_html' ) ) {
91
+ $post_type = get_current_screen()->post_type;
92
+ if ( in_array( $post_type, get_post_types( array('show_ui' => true, 'public' => true ) ) ) ) {
93
  add_meta_box( 'SnS_meta_box', __( 'Scripts n Styles', 'scripts-n-styles' ), array( __CLASS__, 'admin_meta_box' ), $post_type, 'normal', 'high' );
94
+ add_filter( 'default_hidden_meta_boxes', array( __CLASS__, 'default_hidden_meta_boxes' ) );
95
+ add_action( "admin_print_styles", array( __CLASS__, 'meta_box_styles'));
96
+ add_action( "admin_print_scripts", array( __CLASS__, 'meta_box_scripts'));
97
+ add_filter( 'contextual_help', array( 'SnS_Admin', 'help' ) );
98
+ add_filter( 'mce_buttons_2', array( __CLASS__, 'mce_buttons_2' ) );
99
+ add_filter( 'tiny_mce_before_init', array( __CLASS__, 'tiny_mce_before_init' ) );
100
+ add_filter( 'mce_css', array( __CLASS__, 'mce_css' ) );
101
  }
 
 
 
 
102
  }
103
  }
104
 
105
  static function default_hidden_meta_boxes( $hidden ) {
106
  $options = get_option( 'SnS_options' );
107
+ if ( ! ( isset( $options[ 'metabox' ] ) && 'yes' == $options[ 'metabox' ] ) ) {
 
 
108
  $hidden[] = 'SnS_meta_box';
109
+ $hidden[] = 'SnS_shortcode';
110
+ }
111
+ return $hidden;
112
  }
113
 
114
+ /**
115
  * Admin Action: 'add_meta_boxes'
116
  * Outputs the Meta Box. Only called on callback from add_meta_box() during the add_meta_boxes action.
117
  * @param unknown_type WordPress Post object.
118
+ */
119
  static function admin_meta_box( $post ) {
120
  $registered_handles = Scripts_n_Styles::get_wp_registered();
121
  $SnS = get_post_meta( $post->ID, '_SnS', true );
122
  $styles = isset( $SnS['styles'] ) ? $SnS[ 'styles' ]: array();
123
  $scripts = isset( $SnS['scripts'] ) ? $SnS[ 'scripts' ]: array();
124
 
 
125
  $position = get_user_option( "current_sns_tab" );
126
+ if ( ! in_array( $position, array( 's0', 's1', 's2', 's3', 's4' ) ) ) $position = 's0';
127
  wp_nonce_field( Scripts_n_Styles::$file, self::NONCE_NAME );
128
  ?>
129
  <ul class="wp-tab-bar">
131
  <li<?php echo ( 's1' == $position ) ? ' class="wp-tab-active"': ''; ?>><a href="#SnS_styles-tab"><?php _e( 'Styles', 'scripts-n-styles' ) ?></a></li>
132
  <li<?php echo ( 's2' == $position ) ? ' class="wp-tab-active"': ''; ?>><a href="#SnS_classes_body-tab"><?php _e( 'Classes', 'scripts-n-styles' ) ?></a></li>
133
  <li<?php echo ( 's3' == $position ) ? ' class="wp-tab-active"': ''; ?>><a href="#SnS_enqueue_scripts-tab"><?php _e( 'Include Scripts', 'scripts-n-styles' ) ?></a></li>
134
+ <li<?php echo ( 's4' == $position ) ? ' class="wp-tab-active"': ''; ?>><a href="#SnS_shortcodes-tab"><?php _e( 'Shortcodes', 'scripts-n-styles' ) ?></a></li>
135
  </ul>
136
 
137
  <div class="wp-tab-panel" id="SnS_scripts-tab">
138
  <p><em><?php _e( "This code will be included <strong>verbatim</strong> in <code>&lt;script></code> tags at the end of your page's (or post's)", 'scripts-n-styles' ) ?> ...</em></p>
139
  <label for="SnS_scripts_in_head" class="title"><?php _e( '<strong>Scripts</strong> (for the <code>head</code> element):', 'scripts-n-styles' ) ?> </label>
140
+ <textarea class="codemirror js" name="SnS_scripts_in_head" id="SnS_scripts_in_head" rows="5" cols="40" style="width: 98%;"><?php echo isset( $scripts[ 'scripts_in_head' ] ) ? esc_textarea( $scripts[ 'scripts_in_head' ] ) : ''; ?></textarea>
141
  <p><em>... <code>&lt;/head></code> <?php _e( 'tag', 'scripts-n-styles' ) ?>.</em></p>
142
  <label for="SnS_scripts" class="title"><strong>Scripts</strong>: </label>
143
+ <textarea class="codemirror js" name="SnS_scripts" id="SnS_scripts" rows="5" cols="40" style="width: 98%;"><?php echo isset( $scripts[ 'scripts' ] ) ? esc_textarea( $scripts[ 'scripts' ] ) : ''; ?></textarea>
144
  <p><em>... <code>&lt;/body></code> <?php _e( 'tag', 'scripts-n-styles' ) ?>.</em></p>
145
  </div>
146
 
147
  <div class="wp-tab-panel" id="SnS_styles-tab">
148
  <label for="SnS_styles" class="title"><?php _e( '<strong>Styles</strong>:', 'scripts-n-styles' ) ?> </label>
149
+ <textarea class="codemirror css" name="SnS_styles" id="SnS_styles" rows="5" cols="40" style="width: 98%;"><?php echo isset( $styles[ 'styles' ] ) ? esc_textarea( $styles[ 'styles' ] ) : ''; ?></textarea>
150
  <p><em><?php _e( 'This code will be included <strong>verbatim</strong> in <code>&lt;style></code> tags in the <code>&lt;head></code> tag of your page (or post).', 'scripts-n-styles' ) ?></em></p>
151
  </div>
152
 
156
  <p>
157
  <label for="SnS_classes_body"><?php _e( '<strong>Body Classes</strong>:', 'scripts-n-styles' ) ?> </label>
158
  <input name="SnS_classes_body" id="SnS_classes_body" type="text" class="code" style="width: 99%;"
159
+ value="<?php echo isset( $styles[ 'classes_body' ] ) ? esc_attr( $styles[ 'classes_body' ] ) : ''; ?>" />
160
  <small><?php _e( 'Standard:', 'scripts-n-styles' ) ?> <code><?php self::current_classes( 'body', $post->ID ); ?></code></small>
161
  </p>
162
  <p>
163
  <label for="SnS_classes_post"><strong>Post Classes</strong>: </label>
164
  <input name="SnS_classes_post" id="SnS_classes_post" type="text" class="code" style="width: 99%;"
165
+ value="<?php echo isset( $styles[ 'classes_post' ] ) ? esc_attr( $styles[ 'classes_post' ] ) : ''; ?>" />
166
  <small><?php _e( 'Standard:', 'scripts-n-styles' ) ?> <code><?php self::current_classes( 'post', $post->ID ); ?></code></small>
167
  </p>
168
  <p><em><?php _e( 'These <strong>space separated</strong> class names will be added to the <code>body_class()</code> or <code>post_class()</code> function (provided your theme uses these functions).', 'scripts-n-styles' ) ?></em></p>
218
  <?php
219
  if ( ! empty( $scripts[ 'enqueue_scripts' ] ) && is_array( $scripts[ 'enqueue_scripts' ] ) ) {
220
  foreach ( $registered_handles as $value ) { ?>
221
+ <option value="<?php echo esc_attr( $value ) ?>"<?php foreach ( $scripts[ 'enqueue_scripts' ] as $handle ) selected( $handle, $value ); ?>><?php echo esc_html( $value ) ?></option>
222
  <?php }
223
  } else {
224
  foreach ( $registered_handles as $value ) { ?>
225
+ <option value="<?php echo esc_attr( $value ) ?>"><?php echo esc_html( $value ) ?></option>
226
  <?php }
227
  } ?>
228
  </select>
229
  <?php if ( ! empty( $scripts[ 'enqueue_scripts' ] ) && is_array( $scripts[ 'enqueue_scripts' ] ) ) { ?>
230
  <p><?php _e( 'Currently Enqueued Scripts:', 'scripts-n-styles' ) ?>
231
+ <?php foreach ( $scripts[ 'enqueue_scripts' ] as $handle ) echo '<code>' . esc_html( $handle ) . '</code> '; ?>
232
  </p>
233
  <?php } ?>
234
  <p><em><?php _e( 'The chosen scripts will be enqueued and placed before your codes if your code is dependant on certain scripts (like jQuery).', 'scripts-n-styles' ) ?></em></p>
235
  </div>
236
+
237
+ <div class="wp-tab-panel" id="SnS_shortcodes-tab">
238
+ <?php
239
+ $meta_name = 'SnS_shortcodes';
240
+ $SnS = get_post_meta( $post->ID, '_SnS', true );
241
+ $shortcodes = isset( $SnS['shortcodes'] ) ? $SnS[ 'shortcodes' ] : array();
242
+ ?>
243
+ <strong class="title">Shortcodes</strong>
244
+ <h4>Add New</h4>
245
+ <label for="<?php echo $meta_name; ?>">Name: </label>
246
+ <input id="<?php echo $meta_name; ?>" name="<?php echo $meta_name . '[new][name]'; ?>" type="text" />
247
+ <textarea class="codemirror htmlmixed" name="<?php echo $meta_name . '[new][value]'; ?>" rows="5" cols="40" style="width: 98%;"></textarea>
248
+ <?php if ( ! empty( $shortcodes ) ) { ?>
249
+ <h4>Existing</h4>
250
+ <?php
251
+ foreach ( $shortcodes as $key => $value ) {
252
+ ?>
253
+ <label for="<?php echo $meta_name . '[existing][' . $key . ']'; ?>">[sns_shortcode name="<?php echo $key ?>"]</label>
254
+ <textarea class="codemirror htmlmixed" name="<?php echo $meta_name . '[existing][' . $key . ']'; ?>" rows="5" cols="40" style="width: 98%;"><?php echo esc_textarea( $value ); ?></textarea>
255
+ <?php
256
+ }
257
+ } ?>
258
+ </div>
259
  <?php
260
  }
261
 
280
  }
281
  }
282
 
283
+ /**
284
  * Admin Action: 'admin_print_styles' Action added during 'add_meta_boxes' (which restricts output to Edit Screens).
285
  * Enqueues the CSS for admin styling of the Meta Box.
286
+ */
287
  static function meta_box_styles() {
288
  $options = get_option( 'SnS_options' );
289
  $cm_theme = isset( $options[ 'cm_theme' ] ) ? $options[ 'cm_theme' ] : 'default';
290
+ $cm_version = '2.4';
291
+ wp_enqueue_style( 'codemirror', plugins_url( 'libraries/CodeMirror2/lib/codemirror.css', Scripts_n_Styles::$file), array(), $cm_version );
292
+ if ( in_array( $cm_theme, array( 'cobalt', 'eclipse', 'elegant', 'monokai', 'neat', 'night', 'rubyblue' ) ) )
293
+ wp_enqueue_style( "codemirror-$cm_theme", plugins_url( "libraries/CodeMirror2/theme/$cm_theme.css", Scripts_n_Styles::$file), array( 'codemirror' ), $cm_version );
294
  wp_enqueue_style( 'sns-meta-box-styles', plugins_url( 'css/meta-box-styles.css', Scripts_n_Styles::$file), array( 'codemirror' ), Scripts_n_Styles::VERSION );
295
  }
296
 
297
+ /**
298
  * Admin Action: 'admin_print_styles' Action added during 'add_meta_boxes' (which restricts output to Edit Screens).
299
  * Enqueues the JavaScript for the admin Meta Box.
300
+ */
301
  static function meta_box_scripts() {
302
  $options = get_option( 'SnS_options' );
303
  $cm_theme = isset( $options[ 'cm_theme' ] ) ? $options[ 'cm_theme' ] : 'default';
304
+ $cm_version = '2.4';
305
+ $cm_dir = plugins_url( 'libraries/CodeMirror2/', Scripts_n_Styles::$file);
306
 
307
+ wp_register_script( 'codemirror', $cm_dir . 'lib/codemirror.js', array(), $cm_version );
308
+ wp_register_script( 'codemirror-css', $cm_dir . 'mode/css/css.js', array( 'codemirror' ), $cm_version );
309
+ wp_register_script( 'codemirror-less', $cm_dir . 'mode/less/less.js', array( 'codemirror-css' ), $cm_version ); // load css first so less doesn't overwrite mime.
310
+ wp_register_script( 'codemirror-javascript', $cm_dir . 'mode/javascript/javascript.js', array( 'codemirror' ), $cm_version );
311
+ wp_register_script( 'codemirror-htmlmixed', $cm_dir . 'mode/htmlmixed/htmlmixed.js', array( 'codemirror-xml', 'codemirror-css', 'codemirror-javascript' ), $cm_version );
312
+ wp_register_script( 'codemirror-clike', $cm_dir . 'mode/clike/clike.js', array( 'codemirror' ), $cm_version );
313
+ wp_register_script( 'codemirror-xml', $cm_dir . 'mode/xml/xml.js', array( 'codemirror' ), $cm_version );
314
+ wp_register_script( 'codemirror-php', $cm_dir . 'mode/php/php.js', array( 'codemirror-xml', 'codemirror-css', 'codemirror-javascript', 'codemirror-clike' ), $cm_version );
315
+
316
+ wp_enqueue_script( 'sns-meta-box-scripts', plugins_url( 'js/meta-box-scripts.js', Scripts_n_Styles::$file), array( 'editor', 'jquery-ui-tabs', 'codemirror-less', 'codemirror-htmlmixed',
317
+ //'codemirror-php',
318
+ ), Scripts_n_Styles::VERSION, true );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
319
 
320
  wp_localize_script( 'sns-meta-box-scripts', 'codemirror_options', array( 'theme' => $cm_theme ) );
321
  }
322
 
323
+ /**
324
  * Admin Action: 'save_post'
325
  * Saves the values entered in the Meta Box when a post is saved (on the Edit Screen only, excluding autosaves) if the user has permission.
326
  * @param int $post_id ID value of the WordPress post.
327
+ */
328
  static function save_post( $post_id ) {
329
  if ( ! isset( $_POST[ self::NONCE_NAME ] ) || ! wp_verify_nonce( $_POST[ self::NONCE_NAME ], Scripts_n_Styles::$file )
330
  || ! current_user_can( 'unfiltered_html' )
342
 
343
  $SnS = get_post_meta( $post_id, '_SnS', true );
344
  $scripts = isset( $SnS['scripts'] ) ? $SnS[ 'scripts' ]: array();
345
+ $styles = isset( $SnS['styles'] ) ? $SnS[ 'styles' ]: array();
346
 
347
  $scripts = self::maybe_set( $scripts, 'scripts_in_head' );
348
  $scripts = self::maybe_set( $scripts, 'scripts' );
349
  $scripts = self::maybe_set( $scripts, 'enqueue_scripts' );
350
+ $styles = self::maybe_set( $styles, 'styles' );
351
+ $styles = self::maybe_set( $styles, 'classes_body' );
352
+ $styles = self::maybe_set( $styles, 'classes_post' );
353
+
354
+ $shortcodes = array();
355
+ $SnS_shortcodes = isset( $_REQUEST[ 'SnS_shortcodes' ] ) ? $_REQUEST[ 'SnS_shortcodes' ]: array();
356
+
357
+ $existing_shortcodes = isset( $SnS_shortcodes[ 'existing' ] ) ? $SnS_shortcodes[ 'existing' ]: array();
358
+ foreach ( $existing_shortcodes as $key => $value )
359
+ if ( ! empty( $value ) )
360
+ $shortcodes[ $key ] = $value;
361
+
362
+ $new_shortcode = isset( $SnS_shortcodes[ 'new' ] ) ? $SnS_shortcodes[ 'new' ]: array();
363
+ if ( ! empty( $new_shortcode[ 'value' ] ) ) {
364
+ $key = ( empty( $new_shortcode[ 'name' ] ) ) ? count( $shortcodes ): $new_shortcode[ 'name' ];
365
+ $shortcodes[ $key ] = $new_shortcode[ 'value' ];
366
+ }
367
 
368
  // This one isn't posted, it's ajax only. Cleanup anyway.
369
  if ( isset( $styles[ 'classes_mce' ] ) && empty( $styles[ 'classes_mce' ] ) )
383
  $SnS['styles'] = $styles;
384
  }
385
 
386
+ if ( empty( $shortcodes ) ) {
387
+ if ( isset( $SnS['shortcodes'] ) )
388
+ unset( $SnS['shortcodes'] );
389
+ } else {
390
+ $SnS['shortcodes'] = $shortcodes;
391
+ }
392
+
393
  if ( empty( $SnS ) )
394
  delete_post_meta( $post_id, '_SnS' );
395
  else
396
  update_post_meta( $post_id, '_SnS', $SnS );
397
  }
398
 
399
+ /**
400
  * maybe_set()
401
  * Filters $o and Checks if the sent data $i is empty (intended to clear). If not, updates.
402
+ */
403
  function maybe_set( $o, $i, $p = 'SnS_' ) {
404
  if ( empty( $_REQUEST[ $p . $i ] ) ) {
405
  if ( isset( $o[ $i ] ) ) unset( $o[ $i ] );
includes/class.SnS_Form.php CHANGED
@@ -9,10 +9,10 @@
9
 
10
  class SnS_Form
11
  {
12
- /**
13
  * Settings Page
14
  * Outputs a textarea for setting 'scripts_in_head'.
15
- */
16
  function textarea( $args ) {
17
  extract( $args );
18
  $options = get_option( $setting );
@@ -24,7 +24,7 @@ class SnS_Form
24
  $output .= ( $cols ) ? ' cols="' . $cols . '"': '';
25
  $output .= ' name="' . $setting . '[' . $label_for . ']"';
26
  $output .= ' id="' . $label_for . '">';
27
- $output .= $value . '</textarea>';
28
  if ( $description ) {
29
  $output .= $description;
30
  }
@@ -49,7 +49,7 @@ class SnS_Form
49
  $output .= checked( $value, $choice, false );
50
  $output .= ' value="' . $choice . '" name="' . $setting . '[' . $label_for . ']"> ' . $choice;
51
  $output .= '</label>';
52
- $output .= '<br>';
53
  }
54
  $output .= '</p></fieldset>';
55
  if ( $description ) {
@@ -58,10 +58,10 @@ class SnS_Form
58
  echo $output;
59
  }
60
 
61
- /**
62
  * Settings Page
63
  * Outputs a select element for selecting options to set scripts for including.
64
- */
65
  function select( $args ) {
66
  extract( $args );
67
  $options = get_option( $setting );
@@ -94,10 +94,10 @@ class SnS_Form
94
  echo $output;
95
  }
96
 
97
- /**
98
  * Settings Page
99
  * Outputs the Admin Page and calls the Settings registered with the Settings API.
100
- */
101
  function take_action() {
102
  global $action, $option_page, $page, $new_whitelist_options;
103
 
@@ -149,10 +149,10 @@ class SnS_Form
149
  return;
150
  }
151
 
152
- /**
153
  * Settings Page
154
  * Outputs the Admin Page and calls the Settings registered with the Settings API in init_options_page().
155
- */
156
  function page() {
157
  ?>
158
  <div class="wrap">
9
 
10
  class SnS_Form
11
  {
12
+ /**
13
  * Settings Page
14
  * Outputs a textarea for setting 'scripts_in_head'.
15
+ */
16
  function textarea( $args ) {
17
  extract( $args );
18
  $options = get_option( $setting );
24
  $output .= ( $cols ) ? ' cols="' . $cols . '"': '';
25
  $output .= ' name="' . $setting . '[' . $label_for . ']"';
26
  $output .= ' id="' . $label_for . '">';
27
+ $output .= esc_textarea( $value ) . '</textarea>';
28
  if ( $description ) {
29
  $output .= $description;
30
  }
49
  $output .= checked( $value, $choice, false );
50
  $output .= ' value="' . $choice . '" name="' . $setting . '[' . $label_for . ']"> ' . $choice;
51
  $output .= '</label>';
52
+ $output .= ( ! isset( $layout ) || 'horizontal' != $layout ) ? '<br>' : ' &nbsp; ';
53
  }
54
  $output .= '</p></fieldset>';
55
  if ( $description ) {
58
  echo $output;
59
  }
60
 
61
+ /**
62
  * Settings Page
63
  * Outputs a select element for selecting options to set scripts for including.
64
+ */
65
  function select( $args ) {
66
  extract( $args );
67
  $options = get_option( $setting );
94
  echo $output;
95
  }
96
 
97
+ /**
98
  * Settings Page
99
  * Outputs the Admin Page and calls the Settings registered with the Settings API.
100
+ */
101
  function take_action() {
102
  global $action, $option_page, $page, $new_whitelist_options;
103
 
149
  return;
150
  }
151
 
152
+ /**
153
  * Settings Page
154
  * Outputs the Admin Page and calls the Settings registered with the Settings API in init_options_page().
155
+ */
156
  function page() {
157
  ?>
158
  <div class="wrap">
includes/class.SnS_Global_Page.php CHANGED
@@ -9,10 +9,10 @@
9
 
10
  class SnS_Global_Page
11
  {
12
- /**
13
  * Initializing method.
14
- * @static
15
- */
16
  function init() {
17
  if ( SnS_Admin::$parent_slug == SnS_Admin::MENU_SLUG ) $menu_title = __( 'Global', 'scripts-n-styles' );
18
  else $menu_title = __( 'Scripts n Styles', 'scripts-n-styles' );
@@ -28,20 +28,29 @@ class SnS_Global_Page
28
  function admin_enqueue_scripts() {
29
  $options = get_option( 'SnS_options' );
30
  $cm_theme = isset( $options[ 'cm_theme' ] ) ? $options[ 'cm_theme' ] : 'default';
 
 
 
31
  wp_enqueue_style( 'sns-options-styles', plugins_url('css/options-styles.css', Scripts_n_Styles::$file), array( 'codemirror' ), Scripts_n_Styles::VERSION );
32
- wp_enqueue_style( 'codemirror', plugins_url( 'libraries/CodeMirror2/lib/codemirror.css', Scripts_n_Styles::$file), array(), '2.18' );
33
- wp_enqueue_style( "codemirror-$cm_theme", plugins_url( "libraries/CodeMirror2/theme/$cm_theme.css", Scripts_n_Styles::$file), array( 'codemirror' ), '2.18' );
 
 
 
 
34
 
35
- wp_enqueue_script( 'sns-global-page-scripts', plugins_url('js/global-page.js', Scripts_n_Styles::$file), array( 'jquery', 'codemirror-css', 'codemirror-javascript' ), Scripts_n_Styles::VERSION, true );
36
- wp_localize_script( 'sns-global-page-scripts', 'codemirror_options', array( 'theme' => $cm_theme ) );
37
- wp_enqueue_script( 'codemirror', plugins_url( 'libraries/CodeMirror2/lib/codemirror.js', Scripts_n_Styles::$file), array(), '2.18' );
38
- wp_enqueue_script( 'codemirror-css', plugins_url( 'libraries/CodeMirror2/mode/css/css.js', Scripts_n_Styles::$file), array( 'codemirror' ), '2.18' );
39
- wp_enqueue_script( 'codemirror-javascript', plugins_url( 'libraries/CodeMirror2/mode/javascript/javascript.js', Scripts_n_Styles::$file), array( 'codemirror' ), '2.18' );
 
 
40
  }
41
- /**
42
  * Settings Page
43
  * Adds Admin Menu Item via WordPress' "Administration Menus" API. Also hook actions to register options via WordPress' Settings API.
44
- */
45
  function admin_load() {
46
 
47
  register_setting(
@@ -55,20 +64,12 @@ class SnS_Global_Page
55
  SnS_Admin::MENU_SLUG );
56
 
57
  add_settings_field(
58
- 'scripts',
59
- __( '<strong>Scripts:</strong> ', 'scripts-n-styles' ),
60
- array( 'SnS_Form', 'textarea' ),
61
  SnS_Admin::MENU_SLUG,
62
  'global',
63
- array(
64
- 'label_for' => 'scripts',
65
- 'setting' => 'SnS_options',
66
- 'class' => 'code js',
67
- 'rows' => 5,
68
- 'cols' => 40,
69
- 'style' => 'min-width: 500px; width:97%;',
70
- 'description' => __( '<span class="description" style="max-width: 500px; display: inline-block;">The "Scripts" will be included <strong>verbatim</strong> in <code>&lt;script></code> tags at the bottom of the <code>&lt;body></code> element of your html.</span>', 'scripts-n-styles' )
71
- ) );
72
  add_settings_field(
73
  'styles',
74
  __( '<strong>Styles:</strong> ', 'scripts-n-styles' ),
@@ -99,6 +100,21 @@ class SnS_Global_Page
99
  'style' => 'min-width: 500px; width:97%;',
100
  'description' => __( '<span class="description" style="max-width: 500px; display: inline-block;">The "Scripts (in head)" will be included <strong>verbatim</strong> in <code>&lt;script></code> tags in the <code>&lt;head></code> element of your html.</span>', 'scripts-n-styles' )
101
  ) );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
102
  add_settings_field(
103
  'enqueue_scripts',
104
  __( '<strong>Enqueue Scripts</strong>: ', 'scripts-n-styles' ),
@@ -116,7 +132,24 @@ class SnS_Global_Page
116
  ) );
117
  }
118
 
119
- /**
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
120
  * Settings Page
121
  * Outputs Description text for the Global Section.
122
  */
9
 
10
  class SnS_Global_Page
11
  {
12
+ /**
13
  * Initializing method.
14
+ * @static
15
+ */
16
  function init() {
17
  if ( SnS_Admin::$parent_slug == SnS_Admin::MENU_SLUG ) $menu_title = __( 'Global', 'scripts-n-styles' );
18
  else $menu_title = __( 'Scripts n Styles', 'scripts-n-styles' );
28
  function admin_enqueue_scripts() {
29
  $options = get_option( 'SnS_options' );
30
  $cm_theme = isset( $options[ 'cm_theme' ] ) ? $options[ 'cm_theme' ] : 'default';
31
+ $localize = array( 'theme' => $cm_theme );
32
+ $cm_version = '2.4';
33
+
34
  wp_enqueue_style( 'sns-options-styles', plugins_url('css/options-styles.css', Scripts_n_Styles::$file), array( 'codemirror' ), Scripts_n_Styles::VERSION );
35
+ wp_enqueue_style( 'codemirror', plugins_url( 'libraries/CodeMirror2/lib/codemirror.css', Scripts_n_Styles::$file), array(), $cm_version );
36
+ if ( in_array( $cm_theme, array( 'cobalt', 'eclipse', 'elegant', 'lesser-dark', 'monokai', 'neat', 'night', 'rubyblue', 'xq-dark' ) ) )
37
+ wp_enqueue_style( "codemirror-$cm_theme", plugins_url( "libraries/CodeMirror2/theme/$cm_theme.css", Scripts_n_Styles::$file), array( 'codemirror' ), $cm_version );
38
+
39
+ wp_enqueue_script( 'sns-global-page-scripts', plugins_url('js/global-page.js', Scripts_n_Styles::$file), array( 'jquery', 'codemirror-less', 'codemirror-css', 'codemirror-javascript', 'less.js' ), Scripts_n_Styles::VERSION, true );
40
+ wp_localize_script( 'sns-global-page-scripts', '_SnS_options', $localize );
41
 
42
+ wp_enqueue_script( 'less.js', plugins_url( 'libraries/less/dist/less-1.3.0.min.js', Scripts_n_Styles::$file), array(), '1.3.0' );
43
+ wp_enqueue_script( 'codemirror', plugins_url( 'libraries/CodeMirror2/lib/codemirror.js', Scripts_n_Styles::$file), array(), $cm_version );
44
+ wp_enqueue_script( 'codemirror-css', plugins_url( 'libraries/CodeMirror2/mode/css/css.js', Scripts_n_Styles::$file), array( 'codemirror' ), $cm_version );
45
+ wp_enqueue_script( 'codemirror-javascript', plugins_url( 'libraries/CodeMirror2/mode/javascript/javascript.js', Scripts_n_Styles::$file), array( 'codemirror' ), $cm_version );
46
+ wp_enqueue_script( 'codemirror-less', plugins_url( 'libraries/CodeMirror2/mode/less/less.js', Scripts_n_Styles::$file), array( 'codemirror-css' ), $cm_version ); // load css first so less doesn't overwrite mime.
47
+ wp_enqueue_script( 'codemirror-htmlmixed', plugins_url( 'libraries/CodeMirror2/mode/php/php.js', Scripts_n_Styles::$file), array( 'codemirror-xml', 'codemirror-css', 'codemirror-javascript' ), $cm_version );
48
+ wp_enqueue_script( 'codemirror-php', plugins_url( 'libraries/CodeMirror2/mode/php/php.js', Scripts_n_Styles::$file), array( 'codemirror-xml', 'codemirror-css', 'codemirror-javascript', 'codemirror-clike' ), $cm_version );
49
  }
50
+ /**
51
  * Settings Page
52
  * Adds Admin Menu Item via WordPress' "Administration Menus" API. Also hook actions to register options via WordPress' Settings API.
53
+ */
54
  function admin_load() {
55
 
56
  register_setting(
64
  SnS_Admin::MENU_SLUG );
65
 
66
  add_settings_field(
67
+ 'less',
68
+ __( '<strong>LESS:</strong> ', 'scripts-n-styles' ),
69
+ array( __CLASS__, 'less_fields' ),
70
  SnS_Admin::MENU_SLUG,
71
  'global',
72
+ array( 'label_for' => 'less' ) );
 
 
 
 
 
 
 
 
73
  add_settings_field(
74
  'styles',
75
  __( '<strong>Styles:</strong> ', 'scripts-n-styles' ),
100
  'style' => 'min-width: 500px; width:97%;',
101
  'description' => __( '<span class="description" style="max-width: 500px; display: inline-block;">The "Scripts (in head)" will be included <strong>verbatim</strong> in <code>&lt;script></code> tags in the <code>&lt;head></code> element of your html.</span>', 'scripts-n-styles' )
102
  ) );
103
+ add_settings_field(
104
+ 'scripts',
105
+ __( '<strong>Scripts:</strong> ', 'scripts-n-styles' ),
106
+ array( 'SnS_Form', 'textarea' ),
107
+ SnS_Admin::MENU_SLUG,
108
+ 'global',
109
+ array(
110
+ 'label_for' => 'scripts',
111
+ 'setting' => 'SnS_options',
112
+ 'class' => 'code js',
113
+ 'rows' => 5,
114
+ 'cols' => 40,
115
+ 'style' => 'min-width: 500px; width:97%;',
116
+ 'description' => __( '<span class="description" style="max-width: 500px; display: inline-block;">The "Scripts" will be included <strong>verbatim</strong> in <code>&lt;script></code> tags at the bottom of the <code>&lt;body></code> element of your html.</span>', 'scripts-n-styles' )
117
+ ) );
118
  add_settings_field(
119
  'enqueue_scripts',
120
  __( '<strong>Enqueue Scripts</strong>: ', 'scripts-n-styles' ),
132
  ) );
133
  }
134
 
135
+ function less_fields() {
136
+ $options = get_option( 'SnS_options' );
137
+ $less = isset( $options[ 'less' ] ) ? $options[ 'less' ] : '';
138
+ $compiled = isset( $options[ 'compiled' ] ) ? $options[ 'compiled' ] : '';
139
+ ?>
140
+ <div style="overflow: hidden;">
141
+ <div style="width: 49%; float: left; overflow: hidden; margin-right: 2%;">
142
+ <textarea id="less" name="SnS_options[less]" style="min-width: 250px; width:47%; float: left" class="code less" rows="5" cols="40"><?php echo esc_textarea( $less ) ?></textarea>
143
+ </div>
144
+ <div style="width: 49%; float: left; overflow: hidden;">
145
+ <textarea id="compiled" name="SnS_options[compiled]" style="min-width: 250px; width:47%;" class="code css" rows="5" cols="40"><?php echo esc_textarea( $compiled ) ?></textarea>
146
+ <div id="compiled_error" style="display: none" class="error settings-error below-h2"></div>
147
+ </div>
148
+ </div>
149
+ <?php
150
+ }
151
+
152
+ /**
153
  * Settings Page
154
  * Outputs Description text for the Global Section.
155
  */
includes/class.SnS_Settings_Page.php CHANGED
@@ -9,15 +9,15 @@
9
 
10
  class SnS_Settings_Page
11
  {
12
- /**
13
- * Constants
14
- */
15
  const MENU_SLUG = 'sns_settings';
16
 
17
- /**
18
  * Initializing method.
19
- * @static
20
- */
21
  function init() {
22
  $hook_suffix = add_submenu_page( SnS_Admin::$parent_slug, __( 'Scripts n Styles', 'scripts-n-styles' ), __( 'Settings' ), 'unfiltered_html', self::MENU_SLUG, array( 'SnS_Form', 'page' ) );
23
 
@@ -35,23 +35,25 @@ class SnS_Settings_Page
35
 
36
  function admin_enqueue_scripts() {
37
  $options = get_option( 'SnS_options' );
38
- $cm_theme = isset( $options[ 'cm_theme' ] ) ? $options[ 'cm_theme' ] : 'default';
39
-
40
  wp_enqueue_style( 'sns-options-styles', plugins_url('css/options-styles.css', Scripts_n_Styles::$file), array( 'codemirror' ), Scripts_n_Styles::VERSION );
41
- wp_enqueue_style( 'codemirror', plugins_url( 'libraries/CodeMirror2/lib/codemirror.css', Scripts_n_Styles::$file), array(), '2.18' );
42
 
43
- foreach ( array( 'cobalt', 'default', 'eclipse', 'elegant', 'monokai', 'neat', 'night', 'rubyblue' ) as $theme )
44
- wp_enqueue_style( "codemirror-$theme", plugins_url( "libraries/CodeMirror2/theme/$theme.css", Scripts_n_Styles::$file), array( 'codemirror' ), '2.18' );
45
 
46
- wp_enqueue_script( 'sns-settings-page-scripts', plugins_url('js/settings-page.js', Scripts_n_Styles::$file), array( 'jquery', 'codemirror-css', 'codemirror-javascript' ), Scripts_n_Styles::VERSION, true );
47
  wp_localize_script( 'sns-settings-page-scripts', 'codemirror_options', array( 'theme' => $cm_theme ) );
48
- wp_enqueue_script( 'codemirror', plugins_url( 'libraries/CodeMirror2/lib/codemirror.js', Scripts_n_Styles::$file), array(), '2.18' );
49
- wp_enqueue_script( 'codemirror-css', plugins_url( 'libraries/CodeMirror2/mode/css/css.js', Scripts_n_Styles::$file), array( 'codemirror' ), '2.18' );
50
- wp_enqueue_script( 'codemirror-javascript', plugins_url( 'libraries/CodeMirror2/mode/javascript/javascript.js', Scripts_n_Styles::$file), array( 'codemirror' ), '2.18' );
51
-
52
- wp_enqueue_script( 'codemirror-xml', plugins_url( 'libraries/CodeMirror2/mode/xml/xml.js', Scripts_n_Styles::$file), array( 'codemirror' ), '2.18' );
53
- wp_enqueue_script( 'codemirror-clike', plugins_url( 'libraries/CodeMirror2/mode/clike/clike.js', Scripts_n_Styles::$file), array( 'codemirror' ), '2.18' );
54
- wp_enqueue_script( 'codemirror-php', plugins_url( 'libraries/CodeMirror2/mode/php/php.js', Scripts_n_Styles::$file), array( 'codemirror-xml', 'codemirror-css', 'codemirror-javascript', 'codemirror-clike' ), '2.18' );
 
 
55
  }
56
 
57
  static function parent_file( $parent_file ) {
@@ -59,12 +61,12 @@ class SnS_Settings_Page
59
  if ( self::MENU_SLUG == $plugin_page ) $submenu_file = SnS_Admin::MENU_SLUG;
60
  return $parent_file;
61
  }
62
-
63
 
64
- /**
 
65
  * Settings Page
66
  * Adds Admin Menu Item via WordPress' "Administration Menus" API. Also hook actions to register options via WordPress' Settings API.
67
- */
68
  function admin_load() {
69
  wp_enqueue_style( 'sns-options-styles', plugins_url('css/options-styles.css', Scripts_n_Styles::$file), array(), Scripts_n_Styles::VERSION );
70
 
@@ -79,56 +81,59 @@ class SnS_Settings_Page
79
  SnS_Admin::MENU_SLUG );
80
 
81
  add_settings_field(
82
- 'menu_position',
83
- __( '<strong>Menu Position</strong>: ', 'scripts-n-styles' ),
84
- array( 'SnS_Form', 'select' ),
85
  SnS_Admin::MENU_SLUG,
86
  'settings',
87
  array(
88
- 'label_for' => 'menu_position',
89
  'setting' => 'SnS_options',
90
- 'choices' => array( 'menu', 'object', 'utility', 'tools.php', 'options-general.php', 'themes.php' ),
91
- 'size' => 6,
92
- 'style' => 'height: auto;'
 
 
93
  ) );
94
 
95
  add_settings_field(
96
- 'cm_theme',
97
- __( '<strong>CodeMirror Theme</strong>: ', 'scripts-n-styles' ),
98
  array( 'SnS_Form', 'select' ),
99
  SnS_Admin::MENU_SLUG,
100
  'settings',
101
  array(
102
- 'label_for' => 'cm_theme',
103
  'setting' => 'SnS_options',
104
- 'choices' => array( 'cobalt', 'default', 'eclipse', 'elegant', 'monokai', 'neat', 'night', 'rubyblue' ),
105
- 'size' => 8,
106
  'style' => 'height: auto;'
107
  ) );
108
 
 
 
 
 
 
 
109
  add_settings_field(
110
- 'metabox',
111
- __( '<strong>Hide Metabox by default</strong>: ', 'scripts-n-styles' ),
112
  array( 'SnS_Form', 'radio' ),
113
  SnS_Admin::MENU_SLUG,
114
- 'settings',
115
  array(
116
- 'label_for' => 'metabox',
117
  'setting' => 'SnS_options',
118
- 'choices' => array( 'yes', 'no' ),
119
- 'default' => 'yes',
120
- 'legend' => __( 'Hide Metabox by default', 'scripts-n-styles' ),
121
- 'description' => __( '<span class="description" style="max-width: 500px; display: inline-block;">This is overridable via Screen Options on each edit screen.</span>', 'scripts-n-styles' )
 
122
  ) );
123
-
124
- add_settings_section(
125
- 'demo',
126
- __( 'Code Mirror Demo', 'scripts-n-styles' ),
127
- array( __CLASS__, 'demo_section' ),
128
- SnS_Admin::MENU_SLUG );
129
  }
130
 
131
- /**
132
  * Settings Page
133
  * Outputs Description text for the Global Section.
134
  */
@@ -140,7 +145,7 @@ class SnS_Settings_Page
140
  <?php
141
  }
142
 
143
- /**
144
  * Settings Page
145
  * Outputs Description text for the Global Section.
146
  */
9
 
10
  class SnS_Settings_Page
11
  {
12
+ /**
13
+ * Constants
14
+ */
15
  const MENU_SLUG = 'sns_settings';
16
 
17
+ /**
18
  * Initializing method.
19
+ * @static
20
+ */
21
  function init() {
22
  $hook_suffix = add_submenu_page( SnS_Admin::$parent_slug, __( 'Scripts n Styles', 'scripts-n-styles' ), __( 'Settings' ), 'unfiltered_html', self::MENU_SLUG, array( 'SnS_Form', 'page' ) );
23
 
35
 
36
  function admin_enqueue_scripts() {
37
  $options = get_option( 'SnS_options' );
38
+ $cm_theme = isset( $options[ 'cm_theme' ] ) ? $options[ 'cm_theme' ] : '';
39
+ $cm_version = '2.4';
40
  wp_enqueue_style( 'sns-options-styles', plugins_url('css/options-styles.css', Scripts_n_Styles::$file), array( 'codemirror' ), Scripts_n_Styles::VERSION );
41
+ wp_enqueue_style( 'codemirror', plugins_url( 'libraries/CodeMirror2/lib/codemirror.css', Scripts_n_Styles::$file), array(), $cm_version );
42
 
43
+ foreach ( array( 'cobalt', 'eclipse', 'elegant', 'lesser-dark', 'monokai', 'neat', 'night', 'rubyblue', 'xq-dark' ) as $theme )
44
+ wp_enqueue_style( "codemirror-$theme", plugins_url( "libraries/CodeMirror2/theme/$theme.css", Scripts_n_Styles::$file), array( 'codemirror' ), $cm_version );
45
 
46
+ wp_enqueue_script( 'sns-settings-page-scripts', plugins_url('js/settings-page.js', Scripts_n_Styles::$file), array( 'jquery', 'codemirror-less', 'codemirror-css', 'codemirror-javascript' ), Scripts_n_Styles::VERSION, true );
47
  wp_localize_script( 'sns-settings-page-scripts', 'codemirror_options', array( 'theme' => $cm_theme ) );
48
+ wp_enqueue_script( 'codemirror', plugins_url( 'libraries/CodeMirror2/lib/codemirror.js', Scripts_n_Styles::$file), array(), $cm_version );
49
+ wp_enqueue_script( 'codemirror-css', plugins_url( 'libraries/CodeMirror2/mode/css/css.js', Scripts_n_Styles::$file), array( 'codemirror' ), $cm_version );
50
+ wp_enqueue_script( 'codemirror-less', plugins_url( 'libraries/CodeMirror2/mode/less/less.js', Scripts_n_Styles::$file), array( 'codemirror-css' ), $cm_version ); // load css first so less doesn't overwrite mime.
51
+ wp_enqueue_script( 'codemirror-javascript', plugins_url( 'libraries/CodeMirror2/mode/javascript/javascript.js', Scripts_n_Styles::$file), array( 'codemirror' ), $cm_version );
52
+ wp_enqueue_script( 'codemirror-htmlmixed', plugins_url( 'libraries/CodeMirror2/mode/php/php.js', Scripts_n_Styles::$file), array( 'codemirror-xml', 'codemirror-css', 'codemirror-javascript' ), $cm_version );
53
+
54
+ wp_enqueue_script( 'codemirror-xml', plugins_url( 'libraries/CodeMirror2/mode/xml/xml.js', Scripts_n_Styles::$file), array( 'codemirror' ), $cm_version );
55
+ wp_enqueue_script( 'codemirror-clike', plugins_url( 'libraries/CodeMirror2/mode/clike/clike.js', Scripts_n_Styles::$file), array( 'codemirror' ), $cm_version );
56
+ wp_enqueue_script( 'codemirror-php', plugins_url( 'libraries/CodeMirror2/mode/php/php.js', Scripts_n_Styles::$file), array( 'codemirror-xml', 'codemirror-css', 'codemirror-javascript', 'codemirror-clike' ), $cm_version );
57
  }
58
 
59
  static function parent_file( $parent_file ) {
61
  if ( self::MENU_SLUG == $plugin_page ) $submenu_file = SnS_Admin::MENU_SLUG;
62
  return $parent_file;
63
  }
 
64
 
65
+
66
+ /**
67
  * Settings Page
68
  * Adds Admin Menu Item via WordPress' "Administration Menus" API. Also hook actions to register options via WordPress' Settings API.
69
+ */
70
  function admin_load() {
71
  wp_enqueue_style( 'sns-options-styles', plugins_url('css/options-styles.css', Scripts_n_Styles::$file), array(), Scripts_n_Styles::VERSION );
72
 
81
  SnS_Admin::MENU_SLUG );
82
 
83
  add_settings_field(
84
+ 'metabox',
85
+ __( '<strong>Hide Metabox by default</strong>: ', 'scripts-n-styles' ),
86
+ array( 'SnS_Form', 'radio' ),
87
  SnS_Admin::MENU_SLUG,
88
  'settings',
89
  array(
90
+ 'label_for' => 'metabox',
91
  'setting' => 'SnS_options',
92
+ 'choices' => array( 'yes', 'no' ),
93
+ 'layout' => 'horizontal',
94
+ 'default' => 'yes',
95
+ 'legend' => __( 'Hide Metabox by default', 'scripts-n-styles' ),
96
+ 'description' => __( '<span class="description" style="max-width: 500px; display: inline-block;">This is overridable via Screen Options on each edit screen.</span>', 'scripts-n-styles' )
97
  ) );
98
 
99
  add_settings_field(
100
+ 'menu_position',
101
+ __( '<strong>Menu Position</strong>: ', 'scripts-n-styles' ),
102
  array( 'SnS_Form', 'select' ),
103
  SnS_Admin::MENU_SLUG,
104
  'settings',
105
  array(
106
+ 'label_for' => 'menu_position',
107
  'setting' => 'SnS_options',
108
+ 'choices' => array( 'menu', 'object', 'utility', 'tools.php', 'options-general.php', 'themes.php' ),
109
+ 'size' => 6,
110
  'style' => 'height: auto;'
111
  ) );
112
 
113
+ add_settings_section(
114
+ 'demo',
115
+ __( 'Code Mirror Demo', 'scripts-n-styles' ),
116
+ array( __CLASS__, 'demo_section' ),
117
+ SnS_Admin::MENU_SLUG );
118
+
119
  add_settings_field(
120
+ 'cm_theme',
121
+ __( '<strong>Theme</strong>: ', 'scripts-n-styles' ),
122
  array( 'SnS_Form', 'radio' ),
123
  SnS_Admin::MENU_SLUG,
124
+ 'demo',
125
  array(
126
+ 'label_for' => 'cm_theme',
127
  'setting' => 'SnS_options',
128
+ 'choices' => array( 'cobalt', 'eclipse', 'elegant', 'lesser-dark', 'monokai', 'neat', 'night', 'rubyblue', 'xq-dark' ),
129
+ 'default' => 'default',
130
+ 'legend' => __( 'Theme', 'scripts-n-styles' ),
131
+ 'layout' => 'horizontal',
132
+ 'description' => ''
133
  ) );
 
 
 
 
 
 
134
  }
135
 
136
+ /**
137
  * Settings Page
138
  * Outputs Description text for the Global Section.
139
  */
145
  <?php
146
  }
147
 
148
+ /**
149
  * Settings Page
150
  * Outputs Description text for the Global Section.
151
  */
includes/class.SnS_Usage_Page.php CHANGED
@@ -9,15 +9,15 @@
9
 
10
  class SnS_Usage_Page
11
  {
12
- /**
13
- * Constants
14
- */
15
  const MENU_SLUG = 'sns_usage';
16
 
17
- /**
18
  * Initializing method.
19
- * @static
20
- */
21
  function init() {
22
  $hook_suffix = add_submenu_page( SnS_Admin::$parent_slug, __( 'Scripts n Styles', 'scripts-n-styles' ), __( 'Usage', 'scripts-n-styles' ), 'unfiltered_html', self::MENU_SLUG, array( 'SnS_Form', 'page' ) );
23
 
@@ -37,10 +37,10 @@ class SnS_Usage_Page
37
  return $parent_file;
38
  }
39
 
40
- /**
41
  * Settings Page
42
  * Adds Admin Menu Item via WordPress' "Administration Menus" API. Also hook actions to register options via WordPress' Settings API.
43
- */
44
  function admin_load() {
45
  wp_enqueue_style( 'sns-options-styles', plugins_url('css/options-styles.css', Scripts_n_Styles::$file), array(), Scripts_n_Styles::VERSION );
46
 
@@ -69,7 +69,7 @@ class SnS_Usage_Page
69
  return $value;
70
  }
71
 
72
- /**
73
  * Settings Page
74
  * Outputs the Usage Section.
75
  */
9
 
10
  class SnS_Usage_Page
11
  {
12
+ /**
13
+ * Constants
14
+ */
15
  const MENU_SLUG = 'sns_usage';
16
 
17
+ /**
18
  * Initializing method.
19
+ * @static
20
+ */
21
  function init() {
22
  $hook_suffix = add_submenu_page( SnS_Admin::$parent_slug, __( 'Scripts n Styles', 'scripts-n-styles' ), __( 'Usage', 'scripts-n-styles' ), 'unfiltered_html', self::MENU_SLUG, array( 'SnS_Form', 'page' ) );
23
 
37
  return $parent_file;
38
  }
39
 
40
+ /**
41
  * Settings Page
42
  * Adds Admin Menu Item via WordPress' "Administration Menus" API. Also hook actions to register options via WordPress' Settings API.
43
+ */
44
  function admin_load() {
45
  wp_enqueue_style( 'sns-options-styles', plugins_url('css/options-styles.css', Scripts_n_Styles::$file), array(), Scripts_n_Styles::VERSION );
46
 
69
  return $value;
70
  }
71
 
72
+ /**
73
  * Settings Page
74
  * Outputs the Usage Section.
75
  */
js/code-editor.js ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // Options JavaScript
2
+
3
+ jQuery( document ).ready( function( $ ) {
4
+ var theme = codemirror_options.theme ? codemirror_options.theme: 'default';
5
+ var file = $( 'input[name="file"]' ).val();
6
+ var fileType = file.slice( file.lastIndexOf(".")+1 );
7
+
8
+ var $submitWrap = $( '#submit' ).parent();
9
+ var modHeight = $submitWrap.height()
10
+ + parseInt( $submitWrap.css( 'marginTop' ) )
11
+ + parseInt( $submitWrap.css( 'marginBottom' ) )
12
+ + parseInt( $submitWrap.css( 'paddingTop' ) )
13
+ + parseInt( $submitWrap.css( 'paddingBottom' ) );
14
+
15
+ var $documentation = $( '#documentation:visible' );
16
+ if ( $documentation.length ) {
17
+ modHeight += $documentation.height() + parseInt( $documentation.css( 'marginTop' ) );
18
+ }
19
+
20
+ var height = $(window).height() - $( '#newcontent' ).offset().top - $( '#wpadminbar' ).height() - modHeight;
21
+
22
+ var config = { lineNumbers: true, mode: "javascript", theme: theme };
23
+
24
+ if ( "js" == fileType )
25
+ config.mode = "javascript";
26
+ else if ( "css" == fileType )
27
+ config.mode = "css";
28
+ else if ( "less" == fileType )
29
+ config.mode = "less";
30
+ else if ( "html" == fileType || "htm" == fileType )
31
+ config.mode = "html";
32
+ else if ( "php" == fileType )
33
+ config.mode = "php";
34
+ else
35
+ config.mode = "txt";
36
+
37
+ CodeMirror.commands.save = function (){ jQuery('#submit').click(); };
38
+
39
+ CodeMirror.fromTextArea( $( '#newcontent' ).get(0), config );
40
+
41
+ if ( height < $( '.CodeMirror-scroll ' ).height() ) $( '.CodeMirror-scroll ' ).height( height );
42
+ });
js/global-page.js CHANGED
@@ -1,11 +1,85 @@
1
  // Options JavaScript
2
 
3
  jQuery( document ).ready( function( $ ) {
4
- var theme = codemirror_options.theme ? codemirror_options.theme: 'default';
 
 
 
 
 
 
5
  $( "textarea.js" ).each( function() {
6
  CodeMirror.fromTextArea( this, { lineNumbers: true, mode: "javascript", theme: theme } );
7
  });
8
- $( "textarea.css" ).each( function() {
 
9
  CodeMirror.fromTextArea( this, { lineNumbers: true, mode: "css", theme: theme } );
10
  });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11
  });
1
  // Options JavaScript
2
 
3
  jQuery( document ).ready( function( $ ) {
4
+ var theme = _SnS_options.theme ? _SnS_options.theme: 'default';
5
+ var lessMirror, lessOutput, errorLine, errorText, errors, loaded,
6
+ lessMirrorConfig = { lineNumbers: true, mode: "text/x-less", theme: theme, indentWithTabs: true };
7
+
8
+ CodeMirror.commands.save = saveLessMirror;
9
+ lessMirrorConfig.onChange = compile;
10
+
11
  $( "textarea.js" ).each( function() {
12
  CodeMirror.fromTextArea( this, { lineNumbers: true, mode: "javascript", theme: theme } );
13
  });
14
+
15
+ $( "textarea.css" ).not( '#compiled' ).each( function() {
16
  CodeMirror.fromTextArea( this, { lineNumbers: true, mode: "css", theme: theme } );
17
  });
18
+
19
+ lessOutput = CodeMirror.fromTextArea( $( '#compiled' ).get(0), { lineNumbers: true, mode: "css", theme: theme, readOnly: true } );
20
+
21
+ $( "textarea.less" ).each( function() {
22
+ lessMirror = CodeMirror.fromTextArea( this, lessMirrorConfig );
23
+ });
24
+
25
+ compile();
26
+ loaded = true;
27
+ $( "#less" ).closest('form').submit( compile );
28
+
29
+ function saveLessMirror(){
30
+ // Ajax Save.
31
+ }
32
+ function compile() {
33
+ lessMirror.save();
34
+ var parser = new( less.Parser );
35
+ parser.parse( lessMirror.getValue(), function ( err, tree ) {
36
+ if ( err ){
37
+ doError( err );
38
+ } else {
39
+ try {
40
+ $( '#compiled_error' ).hide();
41
+ lessOutput.setValue( tree.toCSS() );
42
+ lessOutput.save();
43
+ $( '#compiled' ).next( '.CodeMirror' ).show();
44
+ lessOutput.refresh();
45
+ clearCompileError();
46
+ }
47
+ catch ( err ) {
48
+ doError( err );
49
+ }
50
+ }
51
+ });
52
+ }
53
+ function doError( err ) {
54
+ //console.dir( err );
55
+ $( '#compiled' ).next( '.CodeMirror' ).hide();
56
+ if ( loaded ) {
57
+ $( '#compiled_error' ).removeClass( 'error' ).addClass( 'updated' );
58
+ $( '#compiled_error' ).show().html( "<p><strong>Warning: &nbsp; </strong>" + err.message + "</p>" );
59
+ } else {
60
+ $( '#compiled_error' ).show().html( "<p><strong>Error: &nbsp; </strong>" + err.message + "</p>" );
61
+ }
62
+ clearCompileError();
63
+
64
+ errorLine = lessMirror.setMarker( err.line - 1, '<strong>*%N%</strong>', "cm-error");
65
+ lessMirror.setLineClass( errorLine, "cm-error");
66
+
67
+ var pos = lessMirror.posFromIndex( err.index + 1 );
68
+ var token = lessMirror.getTokenAt( pos );
69
+ var start = lessMirror.posFromIndex( err.index );
70
+ var end = lessMirror.posFromIndex( err.index + token.string.length )
71
+ errorText = lessMirror.markText( start, end, "cm-error");
72
+
73
+ lessOutput.setValue( "" );
74
+ lessOutput.save();
75
+ }
76
+ function clearCompileError() {
77
+ if ( errorLine ) {
78
+ lessMirror.clearMarker( errorLine );
79
+ lessMirror.setLineClass( errorLine, null );
80
+ errorLine = false;
81
+ }
82
+ if ( errorText ) errorText.clear();
83
+ errorText = false;
84
+ }
85
  });
js/meta-box-scripts.js CHANGED
@@ -1,7 +1,7 @@
1
  jQuery( document ).ready( function( $ ) {
2
 
3
  // For compat: 3.3 || 3.2
4
- var initData = tinyMCEPreInit.mceInit["content"] || tinyMCEPreInit.mceInit,
5
  context = '#SnS_meta_box',
6
  currentCodeMirror = [],
7
  mceBodyClass = getMCEBodyClasses(),
@@ -266,22 +266,32 @@ jQuery( document ).ready( function( $ ) {
266
  indentUnit: 4,
267
  indentWithTabs: true
268
  };
269
- /*else if ( $(this).hasClass( 'htmlmixed' ) )
 
 
 
 
 
 
 
 
 
270
  settings = {
271
  mode: "text/html",
 
272
  lineNumbers: true,
273
  tabMode: "shift",
274
- indentUnit: 8,
275
  indentWithTabs: true,
276
  enterMode: "keep",
277
  matchBrackets: true
278
  };
279
- else if ( $(this).hasClass( 'php' ) )
280
  settings = {
281
  mode: "application/x-httpd-php",
282
  lineNumbers: true,
283
  tabMode: "shift",
284
- indentUnit: 8,
285
  indentWithTabs: true,
286
  enterMode: "keep",
287
  matchBrackets: true
@@ -339,8 +349,6 @@ jQuery( document ).ready( function( $ ) {
339
  function refreshBodyClass( data ) {
340
  initData.body_class = mceBodyClass + ' ' + data.classes_body + ' ' + data.classes_post;
341
 
342
- // needed for < 3.3
343
- if ( tinymce.settings ) tinymce.settings.body_class = initData.body_class;
344
  refreshMCE();
345
  }
346
  function refreshStyleFormats( data ) {
@@ -373,22 +381,16 @@ jQuery( document ).ready( function( $ ) {
373
  }
374
  initData.style_formats = style_formats;
375
 
376
- // needed for < 3.3
377
- if ( tinymce.settings ) tinymce.settings.style_formats = initData.style_formats;
378
  if ( initData.theme_advanced_buttons2.indexOf( "styleselect" ) == -1 ) {
379
  var tempString = "styleselect,";
380
  initData.theme_advanced_buttons2 = tempString.concat(initData.theme_advanced_buttons2);
381
  }
382
 
383
- // needed for < 3.3
384
- if ( tinymce.settings ) tinymce.settings.theme_advanced_buttons2 = initData.theme_advanced_buttons2;
385
  $( '#delete-mce-dropdown-names', context ).show();
386
  } else {
387
  delete initData.style_formats;
388
  initData.theme_advanced_buttons2 = initData.theme_advanced_buttons2.replace("styleselect,", "");
389
 
390
- // needed for < 3.3
391
- if ( tinymce.settings ) tinymce.settings.theme_advanced_buttons2 = initData.theme_advanced_buttons2;
392
  $( '#delete-mce-dropdown-names', context ).hide();
393
  }
394
 
@@ -399,26 +401,16 @@ jQuery( document ).ready( function( $ ) {
399
  var ed = tinyMCE.editors["content"];
400
  // If Visual has been activated.
401
  if ( ed ) {
402
- // needed for < 3.3 editor initialization.
403
- if ( ! $( '#content' ).hasClass( '.theEditor' ) ) $( '#content' ).addClass( 'theEditor' );
404
-
405
  if ( ed.isHidden() ) {
406
  refreshMCEhelper(ed);
407
  } else {
408
- // you've got to be kidding me.
409
- if ( 1 == $('#content-html').length )
410
- $('#content-html').click(); // 3.3
411
- else if( 1 == $('#edButtonHTML').length )
412
- switchEditors.go('content', 'html'); // 3.2
413
 
414
  refreshMCEhelper(ed);
415
 
416
- if ( 1 == $('#content-tmce').length )
417
- $('#content-tmce').click(); // 3.3
418
- else if( 1 == $('#edButtonPreview').length )
419
- switchEditors.go('content', 'tinymce'); // 3.2
420
  }
421
-
422
  }
423
  // Else nothing.
424
 
@@ -433,5 +425,6 @@ jQuery( document ).ready( function( $ ) {
433
  ed = new tinymce.Editor( 'content', initData );
434
  ed.render();
435
  ed.hide();
436
- }
 
437
  });
1
  jQuery( document ).ready( function( $ ) {
2
 
3
  // For compat: 3.3 || 3.2
4
+ var initData = tinyMCEPreInit.mceInit["content"],
5
  context = '#SnS_meta_box',
6
  currentCodeMirror = [],
7
  mceBodyClass = getMCEBodyClasses(),
266
  indentUnit: 4,
267
  indentWithTabs: true
268
  };
269
+ else if ( $(this).hasClass( 'less' ) )
270
+ settings = {
271
+ mode: "text/x-less",
272
+ theme: theme,
273
+ lineNumbers: true,
274
+ tabMode: "shift",
275
+ indentUnit: 4,
276
+ indentWithTabs: true,
277
+ };
278
+ else if ( $(this).hasClass( 'htmlmixed' ) )
279
  settings = {
280
  mode: "text/html",
281
+ theme: theme,
282
  lineNumbers: true,
283
  tabMode: "shift",
284
+ indentUnit: 4,
285
  indentWithTabs: true,
286
  enterMode: "keep",
287
  matchBrackets: true
288
  };
289
+ /*else if ( $(this).hasClass( 'php' ) )
290
  settings = {
291
  mode: "application/x-httpd-php",
292
  lineNumbers: true,
293
  tabMode: "shift",
294
+ indentUnit: 4,
295
  indentWithTabs: true,
296
  enterMode: "keep",
297
  matchBrackets: true
349
  function refreshBodyClass( data ) {
350
  initData.body_class = mceBodyClass + ' ' + data.classes_body + ' ' + data.classes_post;
351
 
 
 
352
  refreshMCE();
353
  }
354
  function refreshStyleFormats( data ) {
381
  }
382
  initData.style_formats = style_formats;
383
 
 
 
384
  if ( initData.theme_advanced_buttons2.indexOf( "styleselect" ) == -1 ) {
385
  var tempString = "styleselect,";
386
  initData.theme_advanced_buttons2 = tempString.concat(initData.theme_advanced_buttons2);
387
  }
388
 
 
 
389
  $( '#delete-mce-dropdown-names', context ).show();
390
  } else {
391
  delete initData.style_formats;
392
  initData.theme_advanced_buttons2 = initData.theme_advanced_buttons2.replace("styleselect,", "");
393
 
 
 
394
  $( '#delete-mce-dropdown-names', context ).hide();
395
  }
396
 
401
  var ed = tinyMCE.editors["content"];
402
  // If Visual has been activated.
403
  if ( ed ) {
 
 
 
404
  if ( ed.isHidden() ) {
405
  refreshMCEhelper(ed);
406
  } else {
407
+ $('#content-html').click(); // 3.3
 
 
 
 
408
 
409
  refreshMCEhelper(ed);
410
 
411
+ $('#content-tmce').click(); // 3.3
 
 
 
412
  }
413
+
414
  }
415
  // Else nothing.
416
 
425
  ed = new tinymce.Editor( 'content', initData );
426
  ed.render();
427
  ed.hide();
428
+ }
429
+
430
  });
js/settings-page.js CHANGED
@@ -12,7 +12,7 @@ jQuery( document ).ready( function( $ ) {
12
  tabMode: "shift",
13
  theme: theme
14
  });
15
- $('#cm_theme').change( function(){
16
  editor.setOption("theme", $(this).val());
17
  });
18
  });
12
  tabMode: "shift",
13
  theme: theme
14
  });
15
+ $('input[name="SnS_options[cm_theme]"]').change( function(){
16
  editor.setOption("theme", $(this).val());
17
  });
18
  });
languages/scripts-n-styles.pot CHANGED
@@ -1,398 +1,398 @@
1
- # Copyright (C) 2010 Scripts n Styles
2
- # This file is distributed under the same license as the Scripts n Styles package.
3
- msgid ""
4
- msgstr ""
5
- "Project-Id-Version: Scripts n Styles 3.0\n"
6
- "Report-Msgid-Bugs-To: http://wordpress.org/tag/scripts-n-styles\n"
7
- "POT-Creation-Date: 2011-12-09 20:20:28+00:00\n"
8
- "MIME-Version: 1.0\n"
9
- "Content-Type: text/plain; charset=UTF-8\n"
10
- "Content-Transfer-Encoding: 8bit\n"
11
- "PO-Revision-Date: 2010-MO-DA HO:MI+ZONE\n"
12
- "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
13
- "Language-Team: LANGUAGE <LL@li.org>\n"
14
-
15
- #. #-#-#-#-# plugin.pot (Scripts n Styles 3.0) #-#-#-#-#
16
- #. Plugin Name of the plugin/theme
17
- #: includes/class.SnS_Usage_Page.php:22 includes/class.SnS_Admin.php:60
18
- #: includes/class.SnS_Admin.php:63 includes/class.SnS_Admin.php:66
19
- #: includes/class.SnS_Admin.php:102 includes/class.SnS_Admin.php:122
20
- #: includes/class.SnS_Settings_Page.php:22
21
- #: includes/class.SnS_Global_Page.php:18 includes/class.SnS_Global_Page.php:20
22
- #: includes/class.SnS_Admin_Meta_Box.php:97
23
- msgid "Scripts n Styles"
24
- msgstr ""
25
-
26
- #: includes/class.SnS_Usage_Page.php:22 includes/class.SnS_Admin.php:88
27
- msgid "Usage"
28
- msgstr ""
29
-
30
- #: includes/class.SnS_Usage_Page.php:47
31
- msgid "Per Page"
32
- msgstr ""
33
-
34
- #: includes/class.SnS_Usage_Page.php:54
35
- msgid "Scripts n Styles Usage"
36
- msgstr ""
37
-
38
- #: includes/class.SnS_Usage_Page.php:78
39
- msgid "The following table shows content that utilizes Scripts n Styles."
40
- msgstr ""
41
-
42
- #: includes/class.SnS_List_Usage.php:20
43
- msgid "Scripts (head)"
44
- msgstr ""
45
-
46
- #: includes/class.SnS_List_Usage.php:23
47
- #: includes/class.SnS_Admin_Meta_Box.php:133
48
- msgid "Scripts"
49
- msgstr ""
50
-
51
- #: includes/class.SnS_List_Usage.php:26
52
- msgid "Enqueued Scripts"
53
- msgstr ""
54
-
55
- #: includes/class.SnS_List_Usage.php:31
56
- msgid "TinyMCE Formats"
57
- msgstr ""
58
-
59
- #: includes/class.SnS_List_Usage.php:34
60
- #: includes/class.SnS_Admin_Meta_Box.php:134
61
- msgid "Styles"
62
- msgstr ""
63
-
64
- #: includes/class.SnS_List_Usage.php:37
65
- msgid "Post Classes"
66
- msgstr ""
67
-
68
- #: includes/class.SnS_List_Usage.php:40
69
- msgid "Body Classes"
70
- msgstr ""
71
-
72
- #: includes/class.SnS_List_Usage.php:50
73
- msgid "Edit &#8220;%s&#8221;"
74
- msgstr ""
75
-
76
- #: includes/class.SnS_List_Usage.php:53
77
- msgid "Edit"
78
- msgstr ""
79
-
80
- #: includes/class.SnS_List_Usage.php:75
81
- msgid "Title"
82
- msgstr ""
83
-
84
- #: includes/class.SnS_List_Usage.php:76
85
- msgid "ID"
86
- msgstr ""
87
-
88
- #: includes/class.SnS_List_Usage.php:77
89
- msgid "Status"
90
- msgstr ""
91
-
92
- #: includes/class.SnS_List_Usage.php:78
93
- msgid "Post Type"
94
- msgstr ""
95
-
96
- #: includes/class.SnS_List_Usage.php:79
97
- msgid "Script Data"
98
- msgstr ""
99
-
100
- #: includes/class.SnS_List_Usage.php:80
101
- msgid "Style Data"
102
- msgstr ""
103
-
104
- #: includes/class.SnS_List_Usage.php:133
105
- msgid "Password protected"
106
- msgstr ""
107
-
108
- #: includes/class.SnS_List_Usage.php:135
109
- msgid "Private"
110
- msgstr ""
111
-
112
- #: includes/class.SnS_List_Usage.php:137
113
- msgid "Draft"
114
- msgstr ""
115
-
116
- #. translators: post state
117
- #: includes/class.SnS_List_Usage.php:140
118
- msgctxt "post state"
119
- msgid "Pending"
120
- msgstr ""
121
-
122
- #: includes/class.SnS_List_Usage.php:142
123
- msgid "Sticky"
124
- msgstr ""
125
-
126
- #: includes/class.SnS_Admin.php:86 includes/class.SnS_Global_Page.php:17
127
- msgid "Global"
128
- msgstr ""
129
-
130
- #: includes/class.SnS_Admin.php:87 includes/class.SnS_Admin.php:198
131
- #: includes/class.SnS_Settings_Page.php:22
132
- msgid "Settings"
133
- msgstr ""
134
-
135
- #: includes/class.SnS_Admin.php:105 includes/class.SnS_Admin.php:125
136
- msgid ""
137
- "<p>In default (non MultiSite) WordPress installs, both <em>Administrators</"
138
- "em> and \r\n"
139
- "\t\t\t\t\t\t<em>Editors</em> can access <em>Scripts-n-Styles</em> on "
140
- "individual edit screens. \r\n"
141
- "\t\t\t\t\t\tOnly <em>Administrators</em> can access this Options Page. In "
142
- "MultiSite WordPress installs, only \r\n"
143
- "\t\t\t\t\t\t<em>\"Super Admin\"</em> users can access either\r\n"
144
- "\t\t\t\t\t\t<em>Scripts-n-Styles</em> on individual edit screens or this "
145
- "Options Page. If other plugins change \r\n"
146
- "\t\t\t\t\t\tcapabilities (specifically \"unfiltered_html\"), \r\n"
147
- "\t\t\t\t\t\tother users can be granted access.</p>"
148
- msgstr ""
149
-
150
- #: includes/class.SnS_Admin.php:115
151
- msgid "For more information:"
152
- msgstr ""
153
-
154
- #: includes/class.SnS_Admin.php:116
155
- msgid ""
156
- "<a href=\"http://wordpress.org/extend/plugins/scripts-n-styles/faq/\" target="
157
- "\"_blank\">Frequently Asked Questions</a>"
158
- msgstr ""
159
-
160
- #: includes/class.SnS_Admin.php:117
161
- msgid ""
162
- "<a href=\"https://github.com/unFocus/Scripts-n-Styles\" target=\"_blank"
163
- "\">Source on github</a>"
164
- msgstr ""
165
-
166
- #: includes/class.SnS_Admin.php:118
167
- msgid ""
168
- "<a href=\"http://wordpress.org/tags/scripts-n-styles\" target=\"_blank"
169
- "\">Support Forums</a>"
170
- msgstr ""
171
-
172
- #: includes/class.SnS_Settings_Page.php:77
173
- msgid "Scripts n Styles Settings"
174
- msgstr ""
175
-
176
- #: includes/class.SnS_Settings_Page.php:83
177
- msgid "<strong>Menu Position</strong>: "
178
- msgstr ""
179
-
180
- #: includes/class.SnS_Settings_Page.php:97
181
- msgid "<strong>CodeMirror Theme</strong>: "
182
- msgstr ""
183
-
184
- #: includes/class.SnS_Settings_Page.php:111
185
- msgid "<strong>Hide Metabox by default</strong>: "
186
- msgstr ""
187
-
188
- #: includes/class.SnS_Settings_Page.php:120
189
- msgid "Hide Metabox by default"
190
- msgstr ""
191
-
192
- #: includes/class.SnS_Settings_Page.php:121
193
- msgid ""
194
- "<span class=\"description\" style=\"max-width: 500px; display: inline-block;"
195
- "\">This is overridable via Screen Options on each edit screen.</span>"
196
- msgstr ""
197
-
198
- #: includes/class.SnS_Settings_Page.php:126
199
- msgid "Code Mirror Demo"
200
- msgstr ""
201
-
202
- #: includes/class.SnS_Settings_Page.php:138
203
- msgid ""
204
- "Control how and where Scripts n Styles menus and metaboxes appear. These "
205
- "options are here because sometimes users really care about this stuff. Feel "
206
- "free to adjust to your liking. :-)"
207
- msgstr ""
208
-
209
- #: includes/class.SnS_Form.php:105
210
- msgid "Cheatin&#8217; uh?"
211
- msgstr ""
212
-
213
- #: includes/class.SnS_Form.php:108 includes/class.SnS_Form.php:135
214
- msgid "Settings saved."
215
- msgstr ""
216
-
217
- #: includes/class.SnS_Global_Page.php:53
218
- msgid "Global Scripts n Styles"
219
- msgstr ""
220
-
221
- #: includes/class.SnS_Global_Page.php:59
222
- msgid "<strong>Scripts:</strong> "
223
- msgstr ""
224
-
225
- #: includes/class.SnS_Global_Page.php:70
226
- msgid ""
227
- "<span class=\"description\" style=\"max-width: 500px; display: inline-block;"
228
- "\">The \"Scripts\" will be included <strong>verbatim</strong> in <code>&lt;"
229
- "script></code> tags at the bottom of the <code>&lt;body></code> element of "
230
- "your html.</span>"
231
- msgstr ""
232
-
233
- #: includes/class.SnS_Global_Page.php:74
234
- msgid "<strong>Styles:</strong> "
235
- msgstr ""
236
-
237
- #: includes/class.SnS_Global_Page.php:85
238
- msgid ""
239
- "<span class=\"description\" style=\"max-width: 500px; display: inline-block;"
240
- "\">The \"Styles\" will be included <strong>verbatim</strong> in <code>&lt;"
241
- "style></code> tags in the <code>&lt;head></code> element of your html.</span>"
242
- msgstr ""
243
-
244
- #: includes/class.SnS_Global_Page.php:89
245
- msgid "<strong>Scripts</strong><br />(for the <code>head</code> element): "
246
- msgstr ""
247
-
248
- #: includes/class.SnS_Global_Page.php:100
249
- msgid ""
250
- "<span class=\"description\" style=\"max-width: 500px; display: inline-block;"
251
- "\">The \"Scripts (in head)\" will be included <strong>verbatim</strong> in "
252
- "<code>&lt;script></code> tags in the <code>&lt;head></code> element of your "
253
- "html.</span>"
254
- msgstr ""
255
-
256
- #: includes/class.SnS_Global_Page.php:104
257
- msgid "<strong>Enqueue Scripts</strong>: "
258
- msgstr ""
259
-
260
- #: includes/class.SnS_Global_Page.php:115
261
- msgid "Currently Enqueued Scripts: "
262
- msgstr ""
263
-
264
- #: includes/class.SnS_Global_Page.php:126
265
- msgid ""
266
- "Code entered here will be included in <em>every page (and post) of your "
267
- "site</em>, including the homepage and archives. The code will appear "
268
- "<strong>before</strong> Scripts and Styles registered individually."
269
- msgstr ""
270
-
271
- #: includes/class.SnS_Admin_Meta_Box.php:135
272
- #: includes/class.SnS_Admin_Meta_Box.php:156
273
- msgid "Classes"
274
- msgstr ""
275
-
276
- #: includes/class.SnS_Admin_Meta_Box.php:136
277
- msgid "Include Scripts"
278
- msgstr ""
279
-
280
- #: includes/class.SnS_Admin_Meta_Box.php:140
281
- msgid ""
282
- "This code will be included <strong>verbatim</strong> in <code>&lt;script></"
283
- "code> tags at the end of your page's (or post's)"
284
- msgstr ""
285
-
286
- #: includes/class.SnS_Admin_Meta_Box.php:141
287
- msgid "<strong>Scripts</strong> (for the <code>head</code> element):"
288
- msgstr ""
289
-
290
- #: includes/class.SnS_Admin_Meta_Box.php:143
291
- #: includes/class.SnS_Admin_Meta_Box.php:146
292
- msgid "tag"
293
- msgstr ""
294
-
295
- #: includes/class.SnS_Admin_Meta_Box.php:150
296
- msgid "<strong>Styles</strong>:"
297
- msgstr ""
298
-
299
- #: includes/class.SnS_Admin_Meta_Box.php:152
300
- msgid ""
301
- "This code will be included <strong>verbatim</strong> in <code>&lt;style></"
302
- "code> tags in the <code>&lt;head></code> tag of your page (or post)."
303
- msgstr ""
304
-
305
- #: includes/class.SnS_Admin_Meta_Box.php:159
306
- msgid "<strong>Body Classes</strong>:"
307
- msgstr ""
308
-
309
- #: includes/class.SnS_Admin_Meta_Box.php:162
310
- #: includes/class.SnS_Admin_Meta_Box.php:168
311
- msgid "Standard:"
312
- msgstr ""
313
-
314
- #: includes/class.SnS_Admin_Meta_Box.php:170
315
- msgid ""
316
- "These <strong>space separated</strong> class names will be added to the "
317
- "<code>body_class()</code> or <code>post_class()</code> function (provided "
318
- "your theme uses these functions)."
319
- msgstr ""
320
-
321
- #: includes/class.SnS_Admin_Meta_Box.php:179
322
- msgid "The Styles Dropdown"
323
- msgstr ""
324
-
325
- #: includes/class.SnS_Admin_Meta_Box.php:181
326
- msgid "Add (or update) a class for the \"Styles\" drop-down:"
327
- msgstr ""
328
-
329
- #: includes/class.SnS_Admin_Meta_Box.php:183
330
- msgid "Title:"
331
- msgstr ""
332
-
333
- #: includes/class.SnS_Admin_Meta_Box.php:188
334
- msgid "Type:"
335
- msgstr ""
336
-
337
- #: includes/class.SnS_Admin_Meta_Box.php:190
338
- msgctxt "css type"
339
- msgid "Inline"
340
- msgstr ""
341
-
342
- #: includes/class.SnS_Admin_Meta_Box.php:191
343
- msgctxt "css type"
344
- msgid "Block"
345
- msgstr ""
346
-
347
- #: includes/class.SnS_Admin_Meta_Box.php:192
348
- msgctxt "css type"
349
- msgid "Selector:"
350
- msgstr ""
351
-
352
- #: includes/class.SnS_Admin_Meta_Box.php:196
353
- msgid "Element:"
354
- msgstr ""
355
-
356
- #: includes/class.SnS_Admin_Meta_Box.php:201
357
- msgid "Classes:"
358
- msgstr ""
359
-
360
- #: includes/class.SnS_Admin_Meta_Box.php:206
361
- msgid "Wrapper:"
362
- msgstr ""
363
-
364
- #: includes/class.SnS_Admin_Meta_Box.php:212
365
- msgid "Classes currently in the dropdown:"
366
- msgstr ""
367
-
368
- #: includes/class.SnS_Admin_Meta_Box.php:232
369
- msgid "Currently Enqueued Scripts:"
370
- msgstr ""
371
-
372
- #: includes/class.SnS_Admin_Meta_Box.php:236
373
- msgid ""
374
- "The chosen scripts will be enqueued and placed before your codes if your "
375
- "code is dependant on certain scripts (like jQuery)."
376
- msgstr ""
377
-
378
- #: includes/class.SnS_Admin_Meta_Box.php:247
379
- msgid "(plus others once saved.)"
380
- msgstr ""
381
-
382
- #. Plugin URI of the plugin/theme
383
- msgid "http://www.unfocus.com/projects/scripts-n-styles/"
384
- msgstr ""
385
-
386
- #. Description of the plugin/theme
387
- msgid ""
388
- "Allows WordPress admin users the ability to add custom CSS and JavaScript "
389
- "directly to individual Post, Pages or custom post types."
390
- msgstr ""
391
-
392
- #. Author of the plugin/theme
393
- msgid "unFocus Projects"
394
- msgstr ""
395
-
396
- #. Author URI of the plugin/theme
397
- msgid "http://www.unfocus.com/"
398
- msgstr ""
1
+ # Copyright (C) 2010 Scripts n Styles
2
+ # This file is distributed under the same license as the Scripts n Styles package.
3
+ msgid ""
4
+ msgstr ""
5
+ "Project-Id-Version: Scripts n Styles 3.0\n"
6
+ "Report-Msgid-Bugs-To: http://wordpress.org/tag/scripts-n-styles\n"
7
+ "POT-Creation-Date: 2011-12-09 20:46:53+00:00\n"
8
+ "MIME-Version: 1.0\n"
9
+ "Content-Type: text/plain; charset=UTF-8\n"
10
+ "Content-Transfer-Encoding: 8bit\n"
11
+ "PO-Revision-Date: 2010-MO-DA HO:MI+ZONE\n"
12
+ "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
13
+ "Language-Team: LANGUAGE <LL@li.org>\n"
14
+
15
+ #. #-#-#-#-# plugin.pot (Scripts n Styles 3.0) #-#-#-#-#
16
+ #. Plugin Name of the plugin/theme
17
+ #: includes/class.SnS_Admin_Meta_Box.php:97
18
+ #: includes/class.SnS_Settings_Page.php:22
19
+ #: includes/class.SnS_Usage_Page.php:22 includes/class.SnS_Global_Page.php:18
20
+ #: includes/class.SnS_Global_Page.php:20 includes/class.SnS_Admin.php:64
21
+ #: includes/class.SnS_Admin.php:67 includes/class.SnS_Admin.php:70
22
+ #: includes/class.SnS_Admin.php:106 includes/class.SnS_Admin.php:126
23
+ msgid "Scripts n Styles"
24
+ msgstr ""
25
+
26
+ #: includes/class.SnS_Admin_Meta_Box.php:133
27
+ #: includes/class.SnS_List_Usage.php:23
28
+ msgid "Scripts"
29
+ msgstr ""
30
+
31
+ #: includes/class.SnS_Admin_Meta_Box.php:134
32
+ #: includes/class.SnS_List_Usage.php:34
33
+ msgid "Styles"
34
+ msgstr ""
35
+
36
+ #: includes/class.SnS_Admin_Meta_Box.php:135
37
+ #: includes/class.SnS_Admin_Meta_Box.php:156
38
+ msgid "Classes"
39
+ msgstr ""
40
+
41
+ #: includes/class.SnS_Admin_Meta_Box.php:136
42
+ msgid "Include Scripts"
43
+ msgstr ""
44
+
45
+ #: includes/class.SnS_Admin_Meta_Box.php:140
46
+ msgid ""
47
+ "This code will be included <strong>verbatim</strong> in <code>&lt;script></"
48
+ "code> tags at the end of your page's (or post's)"
49
+ msgstr ""
50
+
51
+ #: includes/class.SnS_Admin_Meta_Box.php:141
52
+ msgid "<strong>Scripts</strong> (for the <code>head</code> element):"
53
+ msgstr ""
54
+
55
+ #: includes/class.SnS_Admin_Meta_Box.php:143
56
+ #: includes/class.SnS_Admin_Meta_Box.php:146
57
+ msgid "tag"
58
+ msgstr ""
59
+
60
+ #: includes/class.SnS_Admin_Meta_Box.php:150
61
+ msgid "<strong>Styles</strong>:"
62
+ msgstr ""
63
+
64
+ #: includes/class.SnS_Admin_Meta_Box.php:152
65
+ msgid ""
66
+ "This code will be included <strong>verbatim</strong> in <code>&lt;style></"
67
+ "code> tags in the <code>&lt;head></code> tag of your page (or post)."
68
+ msgstr ""
69
+
70
+ #: includes/class.SnS_Admin_Meta_Box.php:159
71
+ msgid "<strong>Body Classes</strong>:"
72
+ msgstr ""
73
+
74
+ #: includes/class.SnS_Admin_Meta_Box.php:162
75
+ #: includes/class.SnS_Admin_Meta_Box.php:168
76
+ msgid "Standard:"
77
+ msgstr ""
78
+
79
+ #: includes/class.SnS_Admin_Meta_Box.php:170
80
+ msgid ""
81
+ "These <strong>space separated</strong> class names will be added to the "
82
+ "<code>body_class()</code> or <code>post_class()</code> function (provided "
83
+ "your theme uses these functions)."
84
+ msgstr ""
85
+
86
+ #: includes/class.SnS_Admin_Meta_Box.php:179
87
+ msgid "The Styles Dropdown"
88
+ msgstr ""
89
+
90
+ #: includes/class.SnS_Admin_Meta_Box.php:181
91
+ msgid "Add (or update) a class for the \"Styles\" drop-down:"
92
+ msgstr ""
93
+
94
+ #: includes/class.SnS_Admin_Meta_Box.php:183
95
+ msgid "Title:"
96
+ msgstr ""
97
+
98
+ #: includes/class.SnS_Admin_Meta_Box.php:188
99
+ msgid "Type:"
100
+ msgstr ""
101
+
102
+ #: includes/class.SnS_Admin_Meta_Box.php:190
103
+ msgctxt "css type"
104
+ msgid "Inline"
105
+ msgstr ""
106
+
107
+ #: includes/class.SnS_Admin_Meta_Box.php:191
108
+ msgctxt "css type"
109
+ msgid "Block"
110
+ msgstr ""
111
+
112
+ #: includes/class.SnS_Admin_Meta_Box.php:192
113
+ msgctxt "css type"
114
+ msgid "Selector:"
115
+ msgstr ""
116
+
117
+ #: includes/class.SnS_Admin_Meta_Box.php:196
118
+ msgid "Element:"
119
+ msgstr ""
120
+
121
+ #: includes/class.SnS_Admin_Meta_Box.php:201
122
+ msgid "Classes:"
123
+ msgstr ""
124
+
125
+ #: includes/class.SnS_Admin_Meta_Box.php:206
126
+ msgid "Wrapper:"
127
+ msgstr ""
128
+
129
+ #: includes/class.SnS_Admin_Meta_Box.php:212
130
+ msgid "Classes currently in the dropdown:"
131
+ msgstr ""
132
+
133
+ #: includes/class.SnS_Admin_Meta_Box.php:232
134
+ msgid "Currently Enqueued Scripts:"
135
+ msgstr ""
136
+
137
+ #: includes/class.SnS_Admin_Meta_Box.php:236
138
+ msgid ""
139
+ "The chosen scripts will be enqueued and placed before your codes if your "
140
+ "code is dependant on certain scripts (like jQuery)."
141
+ msgstr ""
142
+
143
+ #: includes/class.SnS_Admin_Meta_Box.php:247
144
+ msgid "(plus others once saved.)"
145
+ msgstr ""
146
+
147
+ #: includes/class.SnS_Settings_Page.php:22 includes/class.SnS_Admin.php:91
148
+ #: includes/class.SnS_Admin.php:202
149
+ msgid "Settings"
150
+ msgstr ""
151
+
152
+ #: includes/class.SnS_Settings_Page.php:77
153
+ msgid "Scripts n Styles Settings"
154
+ msgstr ""
155
+
156
+ #: includes/class.SnS_Settings_Page.php:83
157
+ msgid "<strong>Menu Position</strong>: "
158
+ msgstr ""
159
+
160
+ #: includes/class.SnS_Settings_Page.php:97
161
+ msgid "<strong>CodeMirror Theme</strong>: "
162
+ msgstr ""
163
+
164
+ #: includes/class.SnS_Settings_Page.php:111
165
+ msgid "<strong>Hide Metabox by default</strong>: "
166
+ msgstr ""
167
+
168
+ #: includes/class.SnS_Settings_Page.php:120
169
+ msgid "Hide Metabox by default"
170
+ msgstr ""
171
+
172
+ #: includes/class.SnS_Settings_Page.php:121
173
+ msgid ""
174
+ "<span class=\"description\" style=\"max-width: 500px; display: inline-block;"
175
+ "\">This is overridable via Screen Options on each edit screen.</span>"
176
+ msgstr ""
177
+
178
+ #: includes/class.SnS_Settings_Page.php:126
179
+ msgid "Code Mirror Demo"
180
+ msgstr ""
181
+
182
+ #: includes/class.SnS_Settings_Page.php:138
183
+ msgid ""
184
+ "Control how and where Scripts n Styles menus and metaboxes appear. These "
185
+ "options are here because sometimes users really care about this stuff. Feel "
186
+ "free to adjust to your liking. :-)"
187
+ msgstr ""
188
+
189
+ #: includes/class.SnS_List_Usage.php:20
190
+ msgid "Scripts (head)"
191
+ msgstr ""
192
+
193
+ #: includes/class.SnS_List_Usage.php:26
194
+ msgid "Enqueued Scripts"
195
+ msgstr ""
196
+
197
+ #: includes/class.SnS_List_Usage.php:31
198
+ msgid "TinyMCE Formats"
199
+ msgstr ""
200
+
201
+ #: includes/class.SnS_List_Usage.php:37
202
+ msgid "Post Classes"
203
+ msgstr ""
204
+
205
+ #: includes/class.SnS_List_Usage.php:40
206
+ msgid "Body Classes"
207
+ msgstr ""
208
+
209
+ #: includes/class.SnS_List_Usage.php:50
210
+ msgid "Edit &#8220;%s&#8221;"
211
+ msgstr ""
212
+
213
+ #: includes/class.SnS_List_Usage.php:53
214
+ msgid "Edit"
215
+ msgstr ""
216
+
217
+ #: includes/class.SnS_List_Usage.php:75
218
+ msgid "Title"
219
+ msgstr ""
220
+
221
+ #: includes/class.SnS_List_Usage.php:76
222
+ msgid "ID"
223
+ msgstr ""
224
+
225
+ #: includes/class.SnS_List_Usage.php:77
226
+ msgid "Status"
227
+ msgstr ""
228
+
229
+ #: includes/class.SnS_List_Usage.php:78
230
+ msgid "Post Type"
231
+ msgstr ""
232
+
233
+ #: includes/class.SnS_List_Usage.php:79
234
+ msgid "Script Data"
235
+ msgstr ""
236
+
237
+ #: includes/class.SnS_List_Usage.php:80
238
+ msgid "Style Data"
239
+ msgstr ""
240
+
241
+ #: includes/class.SnS_List_Usage.php:133
242
+ msgid "Password protected"
243
+ msgstr ""
244
+
245
+ #: includes/class.SnS_List_Usage.php:135
246
+ msgid "Private"
247
+ msgstr ""
248
+
249
+ #: includes/class.SnS_List_Usage.php:137
250
+ msgid "Draft"
251
+ msgstr ""
252
+
253
+ #. translators: post state
254
+ #: includes/class.SnS_List_Usage.php:140
255
+ msgctxt "post state"
256
+ msgid "Pending"
257
+ msgstr ""
258
+
259
+ #: includes/class.SnS_List_Usage.php:142
260
+ msgid "Sticky"
261
+ msgstr ""
262
+
263
+ #: includes/class.SnS_Usage_Page.php:22 includes/class.SnS_Admin.php:92
264
+ msgid "Usage"
265
+ msgstr ""
266
+
267
+ #: includes/class.SnS_Usage_Page.php:47
268
+ msgid "Per Page"
269
+ msgstr ""
270
+
271
+ #: includes/class.SnS_Usage_Page.php:54
272
+ msgid "Scripts n Styles Usage"
273
+ msgstr ""
274
+
275
+ #: includes/class.SnS_Usage_Page.php:78
276
+ msgid "The following table shows content that utilizes Scripts n Styles."
277
+ msgstr ""
278
+
279
+ #: includes/class.SnS_Global_Page.php:17 includes/class.SnS_Admin.php:90
280
+ msgid "Global"
281
+ msgstr ""
282
+
283
+ #: includes/class.SnS_Global_Page.php:53
284
+ msgid "Global Scripts n Styles"
285
+ msgstr ""
286
+
287
+ #: includes/class.SnS_Global_Page.php:59
288
+ msgid "<strong>Scripts:</strong> "
289
+ msgstr ""
290
+
291
+ #: includes/class.SnS_Global_Page.php:70
292
+ msgid ""
293
+ "<span class=\"description\" style=\"max-width: 500px; display: inline-block;"
294
+ "\">The \"Scripts\" will be included <strong>verbatim</strong> in <code>&lt;"
295
+ "script></code> tags at the bottom of the <code>&lt;body></code> element of "
296
+ "your html.</span>"
297
+ msgstr ""
298
+
299
+ #: includes/class.SnS_Global_Page.php:74
300
+ msgid "<strong>Styles:</strong> "
301
+ msgstr ""
302
+
303
+ #: includes/class.SnS_Global_Page.php:85
304
+ msgid ""
305
+ "<span class=\"description\" style=\"max-width: 500px; display: inline-block;"
306
+ "\">The \"Styles\" will be included <strong>verbatim</strong> in <code>&lt;"
307
+ "style></code> tags in the <code>&lt;head></code> element of your html.</span>"
308
+ msgstr ""
309
+
310
+ #: includes/class.SnS_Global_Page.php:89
311
+ msgid "<strong>Scripts</strong><br />(for the <code>head</code> element): "
312
+ msgstr ""
313
+
314
+ #: includes/class.SnS_Global_Page.php:100
315
+ msgid ""
316
+ "<span class=\"description\" style=\"max-width: 500px; display: inline-block;"
317
+ "\">The \"Scripts (in head)\" will be included <strong>verbatim</strong> in "
318
+ "<code>&lt;script></code> tags in the <code>&lt;head></code> element of your "
319
+ "html.</span>"
320
+ msgstr ""
321
+
322
+ #: includes/class.SnS_Global_Page.php:104
323
+ msgid "<strong>Enqueue Scripts</strong>: "
324
+ msgstr ""
325
+
326
+ #: includes/class.SnS_Global_Page.php:115
327
+ msgid "Currently Enqueued Scripts: "
328
+ msgstr ""
329
+
330
+ #: includes/class.SnS_Global_Page.php:126
331
+ msgid ""
332
+ "Code entered here will be included in <em>every page (and post) of your "
333
+ "site</em>, including the homepage and archives. The code will appear "
334
+ "<strong>before</strong> Scripts and Styles registered individually."
335
+ msgstr ""
336
+
337
+ #: includes/class.SnS_Form.php:105
338
+ msgid "Cheatin&#8217; uh?"
339
+ msgstr ""
340
+
341
+ #: includes/class.SnS_Form.php:108 includes/class.SnS_Form.php:135
342
+ msgid "Settings saved."
343
+ msgstr ""
344
+
345
+ #: includes/class.SnS_Admin.php:109 includes/class.SnS_Admin.php:129
346
+ msgid ""
347
+ "<p>In default (non MultiSite) WordPress installs, both <em>Administrators</"
348
+ "em> and \r\n"
349
+ "\t\t\t\t\t\t<em>Editors</em> can access <em>Scripts-n-Styles</em> on "
350
+ "individual edit screens. \r\n"
351
+ "\t\t\t\t\t\tOnly <em>Administrators</em> can access this Options Page. In "
352
+ "MultiSite WordPress installs, only \r\n"
353
+ "\t\t\t\t\t\t<em>\"Super Admin\"</em> users can access either\r\n"
354
+ "\t\t\t\t\t\t<em>Scripts-n-Styles</em> on individual edit screens or this "
355
+ "Options Page. If other plugins change \r\n"
356
+ "\t\t\t\t\t\tcapabilities (specifically \"unfiltered_html\"), \r\n"
357
+ "\t\t\t\t\t\tother users can be granted access.</p>"
358
+ msgstr ""
359
+
360
+ #: includes/class.SnS_Admin.php:119
361
+ msgid "For more information:"
362
+ msgstr ""
363
+
364
+ #: includes/class.SnS_Admin.php:120
365
+ msgid ""
366
+ "<a href=\"http://wordpress.org/extend/plugins/scripts-n-styles/faq/\" target="
367
+ "\"_blank\">Frequently Asked Questions</a>"
368
+ msgstr ""
369
+
370
+ #: includes/class.SnS_Admin.php:121
371
+ msgid ""
372
+ "<a href=\"https://github.com/unFocus/Scripts-n-Styles\" target=\"_blank"
373
+ "\">Source on github</a>"
374
+ msgstr ""
375
+
376
+ #: includes/class.SnS_Admin.php:122
377
+ msgid ""
378
+ "<a href=\"http://wordpress.org/tags/scripts-n-styles\" target=\"_blank"
379
+ "\">Support Forums</a>"
380
+ msgstr ""
381
+
382
+ #. Plugin URI of the plugin/theme
383
+ msgid "http://www.unfocus.com/projects/scripts-n-styles/"
384
+ msgstr ""
385
+
386
+ #. Description of the plugin/theme
387
+ msgid ""
388
+ "Allows WordPress admin users the ability to add custom CSS and JavaScript "
389
+ "directly to individual Post, Pages or custom post types."
390
+ msgstr ""
391
+
392
+ #. Author of the plugin/theme
393
+ msgid "unFocus Projects"
394
+ msgstr ""
395
+
396
+ #. Author URI of the plugin/theme
397
+ msgid "http://www.unfocus.com/"
398
+ msgstr ""
libraries/CodeMirror2/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (C) 2011 by Marijn Haverbeke <marijnh@gmail.com>
2
 
3
  Permission is hereby granted, free of charge, to any person obtaining a copy
4
  of this software and associated documentation files (the "Software"), to deal
@@ -17,3 +17,7 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
  THE SOFTWARE.
 
 
 
 
1
+ Copyright (C) 2012 by Marijn Haverbeke <marijnh@gmail.com>
2
 
3
  Permission is hereby granted, free of charge, to any person obtaining a copy
4
  of this software and associated documentation files (the "Software"), to deal
17
  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
  THE SOFTWARE.
20
+
21
+ Please note that some subdirectories of the CodeMirror distribution
22
+ include their own LICENSE files, and are released under different
23
+ licences.
libraries/CodeMirror2/lib/codemirror.css CHANGED
@@ -9,6 +9,7 @@
9
  /* This is needed to prevent an IE[67] bug where the scrolled content
10
  is visible outside of the scrolling box. */
11
  position: relative;
 
12
  }
13
 
14
  .CodeMirror-gutter {
@@ -27,6 +28,7 @@
27
  }
28
  .CodeMirror-lines {
29
  padding: .4em;
 
30
  }
31
 
32
  .CodeMirror pre {
@@ -40,38 +42,85 @@
40
  padding: 0; margin: 0;
41
  white-space: pre;
42
  word-wrap: normal;
 
 
43
  }
44
 
45
  .CodeMirror-wrap pre {
46
  word-wrap: break-word;
47
  white-space: pre-wrap;
 
48
  }
49
  .CodeMirror-wrap .CodeMirror-scroll {
50
  overflow-x: hidden;
51
  }
52
 
53
  .CodeMirror textarea {
54
- font-family: inherit !important;
55
- font-size: inherit !important;
56
  }
57
 
58
- .CodeMirror-cursor {
59
  z-index: 10;
60
  position: absolute;
61
  visibility: hidden;
62
- border-left: 1px solid black !important;
 
 
 
 
 
 
 
 
 
63
  }
64
- .CodeMirror-focused .CodeMirror-cursor {
 
 
 
 
 
65
  visibility: visible;
66
  }
67
 
68
- span.CodeMirror-selected {
69
- background: #ccc !important;
70
- color: HighlightText !important;
71
- }
72
- .CodeMirror-focused span.CodeMirror-selected {
73
- background: Highlight !important;
74
  }
75
 
76
- .CodeMirror-matchingbracket {color: #0f0 !important;}
77
- .CodeMirror-nonmatchingbracket {color: #f22 !important;}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
  /* This is needed to prevent an IE[67] bug where the scrolled content
10
  is visible outside of the scrolling box. */
11
  position: relative;
12
+ outline: none;
13
  }
14
 
15
  .CodeMirror-gutter {
28
  }
29
  .CodeMirror-lines {
30
  padding: .4em;
31
+ white-space: pre;
32
  }
33
 
34
  .CodeMirror pre {
42
  padding: 0; margin: 0;
43
  white-space: pre;
44
  word-wrap: normal;
45
+ line-height: inherit;
46
+ color: inherit;
47
  }
48
 
49
  .CodeMirror-wrap pre {
50
  word-wrap: break-word;
51
  white-space: pre-wrap;
52
+ word-break: normal;
53
  }
54
  .CodeMirror-wrap .CodeMirror-scroll {
55
  overflow-x: hidden;
56
  }
57
 
58
  .CodeMirror textarea {
59
+ outline: none !important;
 
60
  }
61
 
62
+ .CodeMirror pre.CodeMirror-cursor {
63
  z-index: 10;
64
  position: absolute;
65
  visibility: hidden;
66
+ border-left: 1px solid black;
67
+ border-right: none;
68
+ width: 0;
69
+ }
70
+ .cm-keymap-fat-cursor pre.CodeMirror-cursor {
71
+ width: auto;
72
+ border: 0;
73
+ background: transparent;
74
+ background: rgba(0, 200, 0, .4);
75
+ filter: progid:DXImageTransform.Microsoft.gradient(startColorstr=#6600c800, endColorstr=#4c00c800);
76
  }
77
+ /* Kludge to turn off filter in ie9+, which also accepts rgba */
78
+ .cm-keymap-fat-cursor pre.CodeMirror-cursor:not(#nonsense_id) {
79
+ filter: progid:DXImageTransform.Microsoft.gradient(enabled=false);
80
+ }
81
+ .CodeMirror pre.CodeMirror-cursor.CodeMirror-overwrite {}
82
+ .CodeMirror-focused pre.CodeMirror-cursor {
83
  visibility: visible;
84
  }
85
 
86
+ div.CodeMirror-selected { background: #d9d9d9; }
87
+ .CodeMirror-focused div.CodeMirror-selected { background: #d7d4f0; }
88
+
89
+ .CodeMirror-searching {
90
+ background: #ffa;
91
+ background: rgba(255, 255, 0, .4);
92
  }
93
 
94
+ /* Default theme */
95
+
96
+ .cm-s-default span.cm-keyword {color: #708;}
97
+ .cm-s-default span.cm-atom {color: #219;}
98
+ .cm-s-default span.cm-number {color: #164;}
99
+ .cm-s-default span.cm-def {color: #00f;}
100
+ .cm-s-default span.cm-variable {color: black;}
101
+ .cm-s-default span.cm-variable-2 {color: #05a;}
102
+ .cm-s-default span.cm-variable-3 {color: #085;}
103
+ .cm-s-default span.cm-property {color: black;}
104
+ .cm-s-default span.cm-operator {color: black;}
105
+ .cm-s-default span.cm-comment {color: #a50;}
106
+ .cm-s-default span.cm-string {color: #a11;}
107
+ .cm-s-default span.cm-string-2 {color: #f50;}
108
+ .cm-s-default span.cm-meta {color: #555;}
109
+ .cm-s-default span.cm-error {color: #f00;}
110
+ .cm-s-default span.cm-qualifier {color: #555;}
111
+ .cm-s-default span.cm-builtin {color: #30a;}
112
+ .cm-s-default span.cm-bracket {color: #cc7;}
113
+ .cm-s-default span.cm-tag {color: #170;}
114
+ .cm-s-default span.cm-attribute {color: #00c;}
115
+ .cm-s-default span.cm-header {color: blue;}
116
+ .cm-s-default span.cm-quote {color: #090;}
117
+ .cm-s-default span.cm-hr {color: #999;}
118
+ .cm-s-default span.cm-link {color: #00c;}
119
+
120
+ span.cm-header, span.cm-strong {font-weight: bold;}
121
+ span.cm-em {font-style: italic;}
122
+ span.cm-emstrong {font-style: italic; font-weight: bold;}
123
+ span.cm-link {text-decoration: underline;}
124
+
125
+ div.CodeMirror span.CodeMirror-matchingbracket {color: #0f0;}
126
+ div.CodeMirror span.CodeMirror-nonmatchingbracket {color: #f22;}
libraries/CodeMirror2/lib/codemirror.js CHANGED
@@ -1,12 +1,10 @@
1
- // CodeMirror v2.18
2
-
3
  // All functions that need access to the editor's state live inside
4
  // the CodeMirror function. Below that, at the bottom of the file,
5
  // some utilities are defined.
6
 
7
  // CodeMirror is the only global var we claim
8
  var CodeMirror = (function() {
9
- // This is the function that produces an editor instance. It's
10
  // closure is used to store the editor state.
11
  function CodeMirror(place, givenOptions) {
12
  // Determine effective options based on given values and defaults.
@@ -15,24 +13,23 @@ var CodeMirror = (function() {
15
  if (defaults.hasOwnProperty(opt))
16
  options[opt] = (givenOptions && givenOptions.hasOwnProperty(opt) ? givenOptions : defaults)[opt];
17
 
18
- var targetDocument = options["document"];
19
  // The element in which the editor lives.
20
- var wrapper = targetDocument.createElement("div");
21
  wrapper.className = "CodeMirror" + (options.lineWrapping ? " CodeMirror-wrap" : "");
22
  // This mess creates the base DOM structure for the editor.
23
  wrapper.innerHTML =
24
- '<div style="overflow: hidden; position: relative; width: 1px; height: 0px;">' + // Wraps and hides input textarea
25
- '<textarea style="position: absolute; width: 10000px;" wrap="off" ' +
26
  'autocorrect="off" autocapitalize="off"></textarea></div>' +
27
- '<div class="CodeMirror-scroll cm-s-' + options.theme + '">' +
28
  '<div style="position: relative">' + // Set to the height of the text, causes scrolling
29
  '<div style="position: relative">' + // Moved around its parent to cover visible view
30
  '<div class="CodeMirror-gutter"><div class="CodeMirror-gutter-text"></div></div>' +
31
  // Provides positioning relative to (visible) text origin
32
- '<div class="CodeMirror-lines"><div style="position: relative">' +
33
- '<div style="position: absolute; width: 100%; height: 0; overflow: hidden; visibility: hidden"></div>' +
34
  '<pre class="CodeMirror-cursor">&#160;</pre>' + // Absolutely positioned blinky cursor
35
- '<div></div>' + // This DIV contains the actual code
36
  '</div></div></div></div></div>';
37
  if (place.appendChild) place.appendChild(wrapper); else place(wrapper);
38
  // I've never seen more elegant code in my life.
@@ -40,16 +37,24 @@ var CodeMirror = (function() {
40
  scroller = wrapper.lastChild, code = scroller.firstChild,
41
  mover = code.firstChild, gutter = mover.firstChild, gutterText = gutter.firstChild,
42
  lineSpace = gutter.nextSibling.firstChild, measure = lineSpace.firstChild,
43
- cursor = measure.nextSibling, lineDiv = cursor.nextSibling;
 
 
 
 
44
  if (!webkit) lineSpace.draggable = true;
45
- if (options.tabindex != null) input.tabindex = options.tabindex;
 
 
46
  if (!options.gutter && !options.lineNumbers) gutter.style.display = "none";
 
 
47
 
48
  // Check for problem with IE innerHTML not working when we have a
49
  // P (or similar) parent node.
50
  try { stringWidth("x"); }
51
  catch (e) {
52
- if (e.message.match(/unknown runtime/i))
53
  e = new Error("A CodeMirror inside a P-style element does not work in Internet Explorer. (innerHTML bug)");
54
  throw e;
55
  }
@@ -67,69 +72,75 @@ var CodeMirror = (function() {
67
  // selecting bottom-to-top.
68
  var sel = {from: {line: 0, ch: 0}, to: {line: 0, ch: 0}, inverted: false};
69
  // Selection-related flags. shiftSelecting obviously tracks
70
- // whether the user is holding shift. reducedSelection is a hack
71
- // to get around the fact that we can't create inverted
72
- // selections. See below.
73
- var shiftSelecting, reducedSelection, lastClick, lastDoubleClick, draggingText;
74
  // Variables used by startOperation/endOperation to track what
75
  // happened during the operation.
76
- var updateInput, changes, textChanged, selectionChanged, leaveInputAlone, gutterDirty;
 
77
  // Current visible range (may be bigger than the view window).
78
- var displayOffset = 0, showingFrom = 0, showingTo = 0, lastHeight = 0, curKeyId = null;
79
- // editing will hold an object describing the things we put in the
80
- // textarea, to help figure out whether something changed.
81
- // bracketHighlighted is used to remember that a backet has been
82
  // marked.
83
- var editing, bracketHighlighted;
84
  // Tracks the maximum line length so that the horizontal scrollbar
85
  // can be kept static when scrolling.
86
  var maxLine = "", maxWidth;
 
87
 
88
  // Initialize the content.
89
  operation(function(){setValue(options.value || ""); updateInput = false;})();
90
  var history = new History();
91
 
92
- var slowPollInterval = 2000;
93
- // Gecko and Opera Linux do not reliably fire any event when starting an IME compose
94
- var alwaysPollForIME = (!win && !mac) && (gecko || window.opera);
95
- if (options.pollForIME && alwaysPollForIME) slowPollInterval = 50;
96
- function keyMightStartIME(keyCode) {
97
- return (win && ((gecko && keyCode == 229) || (window.opera && keyCode == 197))) || (mac && gecko);
98
- }
99
-
100
  // Register our event handlers.
101
  connect(scroller, "mousedown", operation(onMouseDown));
102
  connect(scroller, "dblclick", operation(onDoubleClick));
103
- connect(lineSpace, "dragstart", onDragStart);
104
  connect(lineSpace, "selectstart", e_preventDefault);
105
  // Gecko browsers fire contextmenu *after* opening the menu, at
106
  // which point we can't mess with it anymore. Context menu is
107
  // handled in onMouseDown for Gecko.
108
  if (!gecko) connect(scroller, "contextmenu", onContextMenu);
109
  connect(scroller, "scroll", function() {
 
110
  updateDisplay([]);
111
  if (options.fixedGutter) gutter.style.left = scroller.scrollLeft + "px";
112
  if (options.onScroll) options.onScroll(instance);
113
  });
114
  connect(window, "resize", function() {updateDisplay(true);});
115
  connect(input, "keyup", operation(onKeyUp));
116
- connect(input, "input", function() {fastPoll(curKeyId);});
117
  connect(input, "keydown", operation(onKeyDown));
118
  connect(input, "keypress", operation(onKeyPress));
119
  connect(input, "focus", onFocus);
120
  connect(input, "blur", onBlur);
121
 
122
- connect(scroller, "dragenter", e_stop);
123
- connect(scroller, "dragover", e_stop);
124
- connect(scroller, "drop", operation(onDrop));
 
 
 
 
 
 
 
125
  connect(scroller, "paste", function(){focusInput(); fastPoll();});
126
- connect(input, "paste", function(){fastPoll();});
127
- connect(input, "cut", function(){fastPoll();});
 
 
 
 
 
 
 
 
128
 
129
  // IE throws unspecified error in certain cases, when
130
  // trying to access activeElement before onload
131
- var hasFocus; try { hasFocus = (targetDocument.activeElement == input); } catch(e) { }
132
- if (hasFocus) setTimeout(onFocus, 20);
133
  else onBlur();
134
 
135
  function isLine(l) {return l >= 0 && l < doc.size;}
@@ -143,24 +154,33 @@ var CodeMirror = (function() {
143
  setValue: operation(setValue),
144
  getSelection: getSelection,
145
  replaceSelection: operation(replaceSelection),
146
- focus: function(){focusInput(); onFocus(); fastPoll();},
147
  setOption: function(option, value) {
148
  var oldVal = options[option];
149
  options[option] = value;
150
  if (option == "mode" || option == "indentUnit") loadMode();
151
- else if (option == "readOnly" && value == "nocursor") input.blur();
152
- else if (option == "theme") scroller.className = scroller.className.replace(/cm-s-\w+/, "cm-s-" + value);
 
153
  else if (option == "lineWrapping" && oldVal != value) operation(wrappingChanged)();
154
- else if (option == "pollForIME" && alwaysPollForIME) slowPollInterval = value ? 50 : 2000;
155
- if (option == "lineNumbers" || option == "gutter" || option == "firstLineNumber" || option == "theme")
156
- operation(gutterChanged)();
 
 
 
157
  },
158
  getOption: function(option) {return options[option];},
159
  undo: operation(undo),
160
  redo: operation(redo),
161
  indentLine: operation(function(n, dir) {
162
- if (isLine(n)) indentLine(n, dir == null ? "smart" : dir ? "add" : "subtract");
 
 
 
 
163
  }),
 
164
  historySize: function() {return {undo: history.done.length, redo: history.undone.length};},
165
  clearHistory: function() {history = new History();},
166
  matchBrackets: operation(function(){matchBrackets(true);}),
@@ -172,23 +192,36 @@ var CodeMirror = (function() {
172
  line = clipLine(line == null ? doc.size - 1: line);
173
  return getStateBefore(line + 1);
174
  },
175
- cursorCoords: function(start){
176
  if (start == null) start = sel.inverted;
177
- return pageCoords(start ? sel.from : sel.to);
 
 
 
 
 
 
178
  },
179
- charCoords: function(pos){return pageCoords(clipPos(pos));},
180
  coordsChar: function(coords) {
181
  var off = eltOffset(lineSpace);
182
  return coordsChar(coords.x - off.left, coords.y - off.top);
183
  },
184
- getSearchCursor: function(query, pos, caseFold) {return new SearchCursor(query, pos, caseFold);},
185
  markText: operation(markText),
186
  setBookmark: setBookmark,
 
187
  setMarker: operation(addGutterMarker),
188
  clearMarker: operation(removeGutterMarker),
189
  setLineClass: operation(setLineClass),
190
  hideLine: operation(function(h) {return setLineHidden(h, true);}),
191
  showLine: operation(function(h) {return setLineHidden(h, false);}),
 
 
 
 
 
 
 
 
192
  lineInfo: lineInfo,
193
  addWidget: function(pos, node, scroll, vert, horiz) {
194
  pos = localCoords(clipPos(pos));
@@ -219,17 +252,21 @@ var CodeMirror = (function() {
219
  },
220
 
221
  lineCount: function() {return doc.size;},
 
222
  getCursor: function(start) {
223
  if (start == null) start = sel.inverted;
224
  return copyPos(start ? sel.from : sel.to);
225
  },
226
  somethingSelected: function() {return !posEq(sel.from, sel.to);},
227
- setCursor: operation(function(line, ch) {
228
- if (ch == null && typeof line.line == "number") setCursor(line.line, line.ch);
229
- else setCursor(line, ch);
 
 
 
230
  }),
231
- setSelection: operation(function(from, to) {setSelection(clipPos(from), clipPos(to || from));}),
232
  getLine: function(line) {if (isLine(line)) return getLine(line).text;},
 
233
  setLine: operation(function(line, text) {
234
  if (isLine(line)) replaceRange(text, {line: line, ch: 0}, {line: line, ch: getLine(line).text.length});
235
  }),
@@ -239,7 +276,23 @@ var CodeMirror = (function() {
239
  replaceRange: operation(replaceRange),
240
  getRange: function(from, to) {return getRange(clipPos(from), clipPos(to));},
241
 
242
- coordsFromIndex: function(off) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
243
  var lineNo = 0, ch;
244
  doc.iter(0, doc.size, function(line) {
245
  var sz = line.text.length + 1;
@@ -249,9 +302,27 @@ var CodeMirror = (function() {
249
  });
250
  return clipPos({line: lineNo, ch: ch});
251
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
252
 
253
  operation: function(f){return operation(f)();},
254
- refresh: function(){updateDisplay(true);},
 
 
 
 
 
255
  getInputField: function(){return input;},
256
  getWrapperElement: function(){return wrapper;},
257
  getScrollerElement: function(){return scroller;},
@@ -271,13 +342,14 @@ var CodeMirror = (function() {
271
  splitLines(code), top, top);
272
  updateInput = true;
273
  }
274
- function getValue(code) {
275
  var text = [];
276
  doc.iter(0, doc.size, function(line) { text.push(line.text); });
277
  return text.join("\n");
278
  }
279
 
280
  function onMouseDown(e) {
 
281
  // Check whether this is a click in a widget
282
  for (var n = e_target(e); n != wrapper; n = n.parentNode)
283
  if (n.parentNode == code && n != mover) return;
@@ -298,6 +370,7 @@ var CodeMirror = (function() {
298
  return;
299
  case 2:
300
  if (start) setCursor(start.line, start.ch, true);
 
301
  return;
302
  }
303
  // For button 1, if it was clicked inside the editor
@@ -319,21 +392,25 @@ var CodeMirror = (function() {
319
  } else { lastClick = {time: now, pos: start}; }
320
 
321
  var last = start, going;
322
- if (dragAndDrop && !posEq(sel.from, sel.to) &&
323
  !posLess(start, sel.from) && !posLess(sel.to, start)) {
324
  // Let the drag handler handle this.
325
  if (webkit) lineSpace.draggable = true;
326
- var up = connect(targetDocument, "mouseup", operation(function(e2) {
327
  if (webkit) lineSpace.draggable = false;
328
  draggingText = false;
329
- up();
330
  if (Math.abs(e.clientX - e2.clientX) + Math.abs(e.clientY - e2.clientY) < 10) {
331
  e_preventDefault(e2);
332
  setCursor(start.line, start.ch, true);
333
  focusInput();
334
  }
335
- }), true);
 
 
336
  draggingText = true;
 
 
337
  return;
338
  }
339
  e_preventDefault(e);
@@ -352,12 +429,7 @@ var CodeMirror = (function() {
352
  }
353
  }
354
 
355
- var move = connect(targetDocument, "mousemove", operation(function(e) {
356
- clearTimeout(going);
357
- e_preventDefault(e);
358
- extend(e);
359
- }), true);
360
- var up = connect(targetDocument, "mouseup", operation(function(e) {
361
  clearTimeout(going);
362
  var cur = posFromMouse(e);
363
  if (cur) setSelectionUser(start, cur);
@@ -365,7 +437,14 @@ var CodeMirror = (function() {
365
  focusInput();
366
  updateInput = true;
367
  move(); up();
 
 
 
 
 
 
368
  }), true);
 
369
  }
370
  function onDoubleClick(e) {
371
  for (var n = e_target(e); n != wrapper; n = n.parentNode)
@@ -377,6 +456,7 @@ var CodeMirror = (function() {
377
  selectWordAt(start);
378
  }
379
  function onDrop(e) {
 
380
  e.preventDefault();
381
  var pos = posFromMouse(e, true), files = e.dataTransfer.files;
382
  if (!pos || options.readOnly) return;
@@ -386,12 +466,12 @@ var CodeMirror = (function() {
386
  reader.onload = function() {
387
  text[i] = reader.result;
388
  if (++read == n) {
389
- pos = clipPos(pos);
390
- operation(function() {
391
  var end = replaceRange(text.join(""), pos, pos);
392
  setSelectionUser(pos, end);
393
  })();
394
- }
395
  };
396
  reader.readAsText(file);
397
  }
@@ -402,92 +482,130 @@ var CodeMirror = (function() {
402
  try {
403
  var text = e.dataTransfer.getData("Text");
404
  if (text) {
405
- var end = replaceRange(text, pos, pos);
406
- var curFrom = sel.from, curTo = sel.to;
407
- setSelectionUser(pos, end);
408
- if (draggingText) replaceRange("", curFrom, curTo);
409
- focusInput();
410
- }
 
 
411
  }
412
  catch(e){}
413
  }
414
  }
415
  function onDragStart(e) {
416
  var txt = getSelection();
417
- // This will reset escapeElement
418
- htmlEscape(txt);
419
- e.dataTransfer.setDragImage(escapeElement, 0, 0);
420
  e.dataTransfer.setData("Text", txt);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
421
  }
422
- function onKeyDown(e) {
423
- if (!focused) onFocus();
424
-
425
- var code = e.keyCode;
426
- // IE does strange things with escape.
427
- if (ie && code == 27) { e.returnValue = false; }
428
- // Tries to detect ctrl on non-mac, cmd on mac.
429
- var mod = (mac ? e.metaKey : e.ctrlKey) && !e.altKey, anyMod = e.ctrlKey || e.altKey || e.metaKey;
430
- if (code == 16 || e.shiftKey) shiftSelecting = shiftSelecting || (sel.inverted ? sel.to : sel.from);
431
- else shiftSelecting = null;
432
- // First give onKeyEvent option a chance to handle this.
433
- if (options.onKeyEvent && options.onKeyEvent(instance, addStop(e))) return;
434
-
435
- if (code == 33 || code == 34) {scrollPage(code == 34); return e_preventDefault(e);} // page up/down
436
- if (mod && ((code == 36 || code == 35) || // ctrl-home/end
437
- mac && (code == 38 || code == 40))) { // cmd-up/down
438
- scrollEnd(code == 36 || code == 38); return e_preventDefault(e);
439
- }
440
- if (mod && code == 65) {selectAll(); return e_preventDefault(e);} // ctrl-a
441
- if (!options.readOnly) {
442
- if (!anyMod && code == 13) {return;} // enter
443
- if (!anyMod && code == 9 && handleTab(e.shiftKey)) return e_preventDefault(e); // tab
444
- if (mod && code == 90) {undo(); return e_preventDefault(e);} // ctrl-z
445
- if (mod && ((e.shiftKey && code == 90) || code == 89)) {redo(); return e_preventDefault(e);} // ctrl-shift-z, ctrl-y
446
- }
447
- if (code == 36) { if (options.smartHome) { smartHome(); return e_preventDefault(e); } }
448
-
449
- // Key id to use in the movementKeys map. We also pass it to
450
- // fastPoll in order to 'self learn'. We need this because
451
- // reducedSelection, the hack where we collapse the selection to
452
- // its start when it is inverted and a movement key is pressed
453
- // (and later restore it again), shouldn't be used for
454
- // non-movement keys.
455
- curKeyId = (mod ? "c" : "") + (e.altKey ? "a" : "") + code;
456
- if (sel.inverted && movementKeys[curKeyId] === true) {
457
- var range = selRange(input);
458
- if (range) {
459
- reducedSelection = {anchor: range.start};
460
- setSelRange(input, range.start, range.start);
461
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
462
  }
463
- // Don't save the key as a movementkey unless it had a modifier
464
- if (!mod && !e.altKey) curKeyId = null;
465
- fastPoll(curKeyId);
466
-
467
- if (options.pollForIME && keyMightStartIME(code)) slowPollInterval = 50;
 
 
468
  }
469
- function onKeyUp(e) {
470
- if (options.onKeyEvent && options.onKeyEvent(instance, addStop(e))) return;
471
- if (reducedSelection) {
472
- reducedSelection = null;
473
- updateInput = true;
 
474
  }
475
- if (e.keyCode == 16) shiftSelecting = null;
 
476
 
477
- if (slowPollInterval < 2000 && !alwaysPollForIME) slowPollInterval = 2000;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
478
  }
479
  function onKeyPress(e) {
 
480
  if (options.onKeyEvent && options.onKeyEvent(instance, addStop(e))) return;
481
- if (options.electricChars && mode.electricChars) {
482
- var ch = String.fromCharCode(e.charCode == null ? e.keyCode : e.charCode);
 
 
 
483
  if (mode.electricChars.indexOf(ch) > -1)
484
- setTimeout(operation(function() {indentLine(sel.to.line, "smart");}), 50);
485
  }
486
- var code = e.keyCode;
487
- // Re-stop tab and enter. Necessary on some browsers.
488
- if (code == 13) {if (!options.readOnly) handleEnter(); e_preventDefault(e);}
489
- else if (!e.ctrlKey && !e.altKey && !e.metaKey && code == 9 && options.tabMode != "default") e_preventDefault(e);
490
- else fastPoll(curKeyId);
 
491
  }
492
 
493
  function onFocus() {
@@ -497,7 +615,7 @@ var CodeMirror = (function() {
497
  focused = true;
498
  if (wrapper.className.search(/\bCodeMirror-focused\b/) == -1)
499
  wrapper.className += " CodeMirror-focused";
500
- if (!leaveInputAlone) prepareInput();
501
  }
502
  slowPoll();
503
  restartBlink();
@@ -506,6 +624,10 @@ var CodeMirror = (function() {
506
  if (focused) {
507
  if (options.onBlur) options.onBlur(instance);
508
  focused = false;
 
 
 
 
509
  wrapper.className = wrapper.className.replace(" CodeMirror-focused", "");
510
  }
511
  clearInterval(blinker);
@@ -515,6 +637,7 @@ var CodeMirror = (function() {
515
  // Replace the range from from to to by the strings in newText.
516
  // Afterwards, set the selection to selFrom, selTo.
517
  function updateLines(from, to, newText, selFrom, selTo) {
 
518
  if (history) {
519
  var old = [];
520
  doc.iter(from.line, to.line + 1, function(line) { old.push(line.text); });
@@ -524,30 +647,47 @@ var CodeMirror = (function() {
524
  updateLinesNoUndo(from, to, newText, selFrom, selTo);
525
  }
526
  function unredoHelper(from, to) {
527
- var change = from.pop();
528
- if (change) {
 
 
529
  var replaced = [], end = change.start + change.added;
530
  doc.iter(change.start, end, function(line) { replaced.push(line.text); });
531
- to.push({start: change.start, added: change.old.length, old: replaced});
532
  var pos = clipPos({line: change.start + change.old.length - 1,
533
  ch: editEnd(replaced[replaced.length-1], change.old[change.old.length-1])});
534
  updateLinesNoUndo({line: change.start, ch: 0}, {line: end - 1, ch: getLine(end-1).text.length}, change.old, pos, pos);
535
- updateInput = true;
536
  }
 
 
537
  }
538
  function undo() {unredoHelper(history.done, history.undone);}
539
  function redo() {unredoHelper(history.undone, history.done);}
540
 
541
  function updateLinesNoUndo(from, to, newText, selFrom, selTo) {
 
542
  var recomputeMaxLength = false, maxLineLength = maxLine.length;
543
  if (!options.lineWrapping)
544
- doc.iter(from.line, to.line, function(line) {
545
  if (line.text.length == maxLineLength) {recomputeMaxLength = true; return true;}
546
  });
 
547
 
548
  var nlines = to.line - from.line, firstLine = getLine(from.line), lastLine = getLine(to.line);
549
  // First adjust the line structure, taking some care to leave highlighting intact.
550
- if (firstLine == lastLine) {
 
 
 
 
 
 
 
 
 
 
 
 
551
  if (newText.length == 1)
552
  firstLine.replace(from.ch, to.ch, newText[0]);
553
  else {
@@ -560,32 +700,30 @@ var CodeMirror = (function() {
560
  added.push(lastLine);
561
  doc.insert(from.line + 1, added);
562
  }
563
- }
564
- else if (newText.length == 1) {
565
  firstLine.replace(from.ch, null, newText[0]);
566
  lastLine.replace(null, to.ch, "");
567
  firstLine.append(lastLine);
568
- doc.remove(from.line + 1, nlines);
569
- }
570
- else {
571
  var added = [];
572
  firstLine.replace(from.ch, null, newText[0]);
573
  lastLine.replace(null, to.ch, newText[newText.length-1]);
574
  firstLine.fixMarkEnds(lastLine);
575
  for (var i = 1, e = newText.length - 1; i < e; ++i)
576
  added.push(Line.inheritMarks(newText[i], firstLine));
577
- if (nlines > 1) doc.remove(from.line + 1, nlines - 1);
578
  doc.insert(from.line + 1, added);
579
  }
580
  if (options.lineWrapping) {
581
- var perLine = scroller.clientWidth / charWidth() - 3;
582
  doc.iter(from.line, from.line + newText.length, function(line) {
583
  if (line.hidden) return;
584
  var guess = Math.ceil(line.text.length / perLine) || 1;
585
  if (guess != line.height) updateLineHeight(line, guess);
586
  });
587
  } else {
588
- doc.iter(from.line, i + newText.length, function(line) {
589
  var l = line.text;
590
  if (l.length > maxLineLength) {
591
  maxLine = l; maxLineLength = l.length; maxWidth = null;
@@ -618,14 +756,19 @@ var CodeMirror = (function() {
618
  startWorker(100);
619
  // Remember that these lines changed, for updating the display
620
  changes.push({from: from.line, to: to.line + 1, diff: lendiff});
621
- textChanged = {from: from, to: to, text: newText};
 
 
 
 
622
 
623
  // Update the selection
624
  function updateLine(n) {return n <= Math.min(to.line, to.line + lendiff) ? n : n + lendiff;}
625
  setSelection(selFrom, selTo, updateLine(sel.from.line), updateLine(sel.to.line));
626
 
627
  // Make sure the scroll-size div has the correct height.
628
- code.style.height = (doc.height * textHeight() + 2 * paddingTop()) + "px";
 
629
  }
630
 
631
  function replaceRange(code, from, to) {
@@ -676,117 +819,55 @@ var CodeMirror = (function() {
676
  var pollingFast = false; // Ensures slowPoll doesn't cancel fastPoll
677
  function slowPoll() {
678
  if (pollingFast) return;
679
- poll.set(slowPollInterval, function() {
680
  startOperation();
681
  readInput();
682
  if (focused) slowPoll();
683
  endOperation();
684
  });
685
  }
686
- function fastPoll(keyId) {
687
  var missed = false;
688
  pollingFast = true;
689
  function p() {
690
  startOperation();
691
  var changed = readInput();
692
- if (changed && keyId) {
693
- if (changed == "moved" && movementKeys[keyId] == null) movementKeys[keyId] = true;
694
- if (changed == "changed") movementKeys[keyId] = false;
695
- }
696
- if (!changed && !missed) {missed = true; poll.set(80, p);}
697
  else {pollingFast = false; slowPoll();}
698
  endOperation();
699
  }
700
  poll.set(20, p);
701
  }
702
 
703
- // Inspects the textarea, compares its state (content, selection)
704
- // to the data in the editing variable, and updates the editor
705
- // content or cursor if something changed.
 
 
 
706
  function readInput() {
707
- if (leaveInputAlone || !focused) return;
708
- var changed = false, text = input.value, sr = selRange(input);
709
- if (!sr) return false;
710
- var changed = editing.text != text, rs = reducedSelection;
711
- var moved = changed || sr.start != editing.start || sr.end != (rs ? editing.start : editing.end);
712
- if (!moved && !rs) return false;
713
- if (changed) {
714
- shiftSelecting = reducedSelection = null;
715
- if (options.readOnly) {updateInput = true; return "changed";}
716
- }
717
-
718
- // Compute selection start and end based on start/end offsets in textarea
719
- function computeOffset(n, startLine) {
720
- var pos = 0;
721
- for (;;) {
722
- var found = text.indexOf("\n", pos);
723
- if (found == -1 || (text.charAt(found-1) == "\r" ? found - 1 : found) >= n)
724
- return {line: startLine, ch: n - pos};
725
- ++startLine;
726
- pos = found + 1;
727
- }
728
- }
729
- var from = computeOffset(sr.start, editing.from),
730
- to = computeOffset(sr.end, editing.from);
731
- // Here we have to take the reducedSelection hack into account,
732
- // so that you can, for example, press shift-up at the start of
733
- // your selection and have the right thing happen.
734
- if (rs) {
735
- var head = sr.start == rs.anchor ? to : from;
736
- var tail = shiftSelecting ? sel.to : sr.start == rs.anchor ? from : to;
737
- if (sel.inverted = posLess(head, tail)) { from = head; to = tail; }
738
- else { reducedSelection = null; from = tail; to = head; }
739
- }
740
-
741
- // In some cases (cursor on same line as before), we don't have
742
- // to update the textarea content at all.
743
- if (from.line == to.line && from.line == sel.from.line && from.line == sel.to.line && !shiftSelecting)
744
- updateInput = false;
745
-
746
- // Magic mess to extract precise edited range from the changed
747
- // string.
748
- if (changed) {
749
- var start = 0, end = text.length, len = Math.min(end, editing.text.length);
750
- var c, line = editing.from, nl = -1;
751
- while (start < len && (c = text.charAt(start)) == editing.text.charAt(start)) {
752
- ++start;
753
- if (c == "\n") {line++; nl = start;}
754
- }
755
- var ch = nl > -1 ? start - nl : start, endline = editing.to - 1, edend = editing.text.length;
756
- for (;;) {
757
- c = editing.text.charAt(edend);
758
- if (text.charAt(end) != c) {++end; ++edend; break;}
759
- if (c == "\n") endline--;
760
- if (edend <= start || end <= start) break;
761
- --end; --edend;
762
- }
763
- var nl = editing.text.lastIndexOf("\n", edend - 1), endch = nl == -1 ? edend : edend - nl - 1;
764
- updateLines({line: line, ch: ch}, {line: endline, ch: endch}, splitLines(text.slice(start, end)), from, to);
765
- if (line != endline || from.line != line) updateInput = true;
766
- }
767
- else setSelection(from, to);
768
-
769
- editing.text = text; editing.start = sr.start; editing.end = sr.end;
770
- return changed ? "changed" : moved ? "moved" : false;
771
  }
772
-
773
- // Set the textarea content and selection range to match the
774
- // editor state.
775
- function prepareInput() {
776
- var text = [];
777
- var from = Math.max(0, sel.from.line - 1), to = Math.min(doc.size, sel.to.line + 2);
778
- doc.iter(from, to, function(line) { text.push(line.text); });
779
- text = input.value = text.join(lineSep);
780
- var startch = sel.from.ch, endch = sel.to.ch;
781
- doc.iter(from, sel.from.line, function(line) {
782
- startch += lineSep.length + line.text.length;
783
- });
784
- doc.iter(from, sel.to.line, function(line) {
785
- endch += lineSep.length + line.text.length;
786
- });
787
- editing = {text: text, from: from, to: to, start: startch, end: endch};
788
- setSelRange(input, startch, reducedSelection ? startch : endch);
789
  }
 
790
  function focusInput() {
791
  if (options.readOnly != "nocursor") input.focus();
792
  }
@@ -794,6 +875,8 @@ var CodeMirror = (function() {
794
  function scrollEditorIntoView() {
795
  if (!cursor.getBoundingClientRect) return;
796
  var rect = cursor.getBoundingClientRect();
 
 
797
  var winH = window.innerHeight || Math.max(document.body.offsetHeight, document.documentElement.offsetHeight);
798
  if (rect.top < 0 || rect.bottom > winH) cursor.scrollIntoView();
799
  }
@@ -803,20 +886,21 @@ var CodeMirror = (function() {
803
  return scrollIntoView(x, cursor.y, x, cursor.yBot);
804
  }
805
  function scrollIntoView(x1, y1, x2, y2) {
806
- var pl = paddingLeft(), pt = paddingTop(), lh = textHeight();
807
  y1 += pt; y2 += pt; x1 += pl; x2 += pl;
808
  var screen = scroller.clientHeight, screentop = scroller.scrollTop, scrolled = false, result = true;
809
- if (y1 < screentop) {scroller.scrollTop = Math.max(0, y1 - 2*lh); scrolled = true;}
810
- else if (y2 > screentop + screen) {scroller.scrollTop = y2 + lh - screen; scrolled = true;}
811
 
812
  var screenw = scroller.clientWidth, screenleft = scroller.scrollLeft;
813
  var gutterw = options.fixedGutter ? gutter.clientWidth : 0;
814
- if (x1 < screenleft + gutterw) {
815
- if (x1 < 50) x1 = 0;
 
816
  scroller.scrollLeft = Math.max(0, x1 - 10 - gutterw);
817
  scrolled = true;
818
  }
819
- else if (x2 > screenw + screenleft) {
820
  scroller.scrollLeft = x2 + 10 - screenw;
821
  scrolled = true;
822
  if (x2 > code.clientWidth) result = false;
@@ -827,15 +911,15 @@ var CodeMirror = (function() {
827
 
828
  function visibleLines() {
829
  var lh = textHeight(), top = scroller.scrollTop - paddingTop();
830
- var from_height = Math.max(0, Math.floor(top / lh));
831
- var to_height = Math.ceil((top + scroller.clientHeight) / lh);
832
- return {from: lineAtHeight(doc, from_height),
833
- to: lineAtHeight(doc, to_height)};
834
  }
835
  // Uses a set of changes plus the current scroll position to
836
  // determine which DOM updates have to be made, and makes the
837
  // updates.
838
- function updateDisplay(changes) {
839
  if (!scroller.clientWidth) {
840
  showingFrom = showingTo = displayOffset = 0;
841
  return;
@@ -843,7 +927,7 @@ var CodeMirror = (function() {
843
  // Compute the new visible window
844
  var visible = visibleLines();
845
  // Bail out if the visible area is already rendered and nothing changed.
846
- if (changes !== true && changes.length == 0 && visible.from >= showingFrom && visible.to <= showingTo) return;
847
  var from = Math.max(visible.from - 100, 0), to = Math.min(doc.size, visible.to + 100);
848
  if (showingFrom < from && from - showingFrom < 20) from = showingFrom;
849
  if (showingTo > to && showingTo - to < 20) to = Math.min(doc.size, showingTo);
@@ -861,22 +945,25 @@ var CodeMirror = (function() {
861
  if (range.from >= range.to) intact.splice(i--, 1);
862
  else intactLines += range.to - range.from;
863
  }
864
- if (intactLines == to - from) return;
865
  intact.sort(function(a, b) {return a.domStart - b.domStart;});
866
 
867
  var th = textHeight(), gutterDisplay = gutter.style.display;
868
- lineDiv.style.display = gutter.style.display = "none";
869
  patchDisplay(from, to, intact);
870
- lineDiv.style.display = "";
871
 
872
  // Position the mover div to align with the lines it's supposed
873
  // to be showing (which will cover the visible display)
874
- var different = from != showingFrom || to != showingTo || lastHeight != scroller.clientHeight;
875
- if (different) lastHeight = scroller.clientHeight;
 
 
876
  showingFrom = from; showingTo = to;
877
  displayOffset = heightAtLine(doc, from);
878
  mover.style.top = (displayOffset * th) + "px";
879
- code.style.height = (doc.height * th + 2 * paddingTop()) + "px";
 
880
 
881
  // Since this is all rather error prone, it is honoured with the
882
  // only assertion in the whole file.
@@ -884,16 +971,26 @@ var CodeMirror = (function() {
884
  throw new Error("BAD PATCH! " + JSON.stringify(intact) + " size=" + (showingTo - showingFrom) +
885
  " nodes=" + lineDiv.childNodes.length);
886
 
887
- if (options.lineWrapping) {
888
  maxWidth = scroller.clientWidth;
889
- var curNode = lineDiv.firstChild;
890
  doc.iter(showingFrom, showingTo, function(line) {
891
  if (!line.hidden) {
892
  var height = Math.round(curNode.offsetHeight / th) || 1;
893
- if (line.height != height) {updateLineHeight(line, height); gutterDirty = true;}
 
 
 
894
  }
895
  curNode = curNode.nextSibling;
896
  });
 
 
 
 
 
 
 
897
  } else {
898
  if (maxWidth == null) maxWidth = stringWidth(maxLine);
899
  if (maxWidth > scroller.clientWidth) {
@@ -905,9 +1002,15 @@ var CodeMirror = (function() {
905
  lineSpace.style.width = code.style.width = "";
906
  }
907
  }
 
908
  gutter.style.display = gutterDisplay;
909
- if (different || gutterDirty) updateGutter();
910
- updateCursor();
 
 
 
 
 
911
  }
912
 
913
  function computeIntact(intact, changes) {
@@ -952,21 +1055,20 @@ var CodeMirror = (function() {
952
  }
953
  // This pass fills in the lines that actually changed.
954
  var nextIntact = intact.shift(), curNode = lineDiv.firstChild, j = from;
955
- var sfrom = sel.from.line, sto = sel.to.line, inSel = sfrom < from && sto >= from;
956
- var scratch = targetDocument.createElement("div"), newElt;
957
  doc.iter(from, to, function(line) {
958
- var ch1 = null, ch2 = null;
959
- if (inSel) {
960
- ch1 = 0;
961
- if (sto == j) {inSel = false; ch2 = sel.to.ch;}
962
- } else if (sfrom == j) {
963
- if (sto == j) {ch1 = sel.from.ch; ch2 = sel.to.ch;}
964
- else {inSel = true; ch1 = sel.from.ch;}
965
- }
966
  if (nextIntact && nextIntact.to == j) nextIntact = intact.shift();
967
  if (!nextIntact || nextIntact.from > j) {
968
- if (line.hidden) scratch.innerHTML = "<pre></pre>";
969
- else scratch.innerHTML = line.getHTML(ch1, ch2, true);
 
 
 
 
 
 
 
 
970
  lineDiv.insertBefore(scratch.firstChild, curNode);
971
  } else {
972
  curNode = curNode.nextSibling;
@@ -979,7 +1081,7 @@ var CodeMirror = (function() {
979
  if (!options.gutter && !options.lineNumbers) return;
980
  var hText = mover.offsetHeight, hEditor = scroller.clientHeight;
981
  gutter.style.height = (hText - hEditor < 2 ? hEditor : hText) + "px";
982
- var html = [], i = showingFrom;
983
  doc.iter(showingFrom, Math.max(showingTo, showingFrom + 1), function(line) {
984
  if (line.hidden) {
985
  html.push("<pre></pre>");
@@ -991,34 +1093,70 @@ var CodeMirror = (function() {
991
  else if (text == null)
992
  text = "\u00a0";
993
  html.push((marker && marker.style ? '<pre class="' + marker.style + '">' : "<pre>"), text);
994
- for (var j = 1; j < line.height; ++j) html.push("<br>&nbsp;");
995
  html.push("</pre>");
 
996
  }
997
  ++i;
998
  });
999
  gutter.style.display = "none";
1000
  gutterText.innerHTML = html.join("");
1001
- var minwidth = String(doc.size).length, firstNode = gutterText.firstChild, val = eltText(firstNode), pad = "";
1002
- while (val.length + pad.length < minwidth) pad += "\u00a0";
1003
- if (pad) firstNode.insertBefore(targetDocument.createTextNode(pad), firstNode.firstChild);
 
 
 
 
1004
  gutter.style.display = "";
 
1005
  lineSpace.style.marginLeft = gutter.offsetWidth + "px";
1006
  gutterDirty = false;
1007
- }
1008
- function updateCursor() {
1009
- var head = sel.inverted ? sel.from : sel.to, lh = textHeight();
1010
- var pos = localCoords(head, true);
1011
- var globalY = pos.y + displayOffset * textHeight();
1012
- inputDiv.style.top = Math.max(Math.min(globalY, scroller.offsetHeight), 0) + "px";
1013
- inputDiv.style.left = (pos.x - scroller.scrollLeft) + "px";
1014
- if (posEq(sel.from, sel.to)) {
1015
- cursor.style.top = pos.y + "px";
1016
- cursor.style.left = (options.lineWrapping ? Math.min(pos.x, lineSpace.offsetWidth) : pos.x) + "px";
 
 
 
1017
  cursor.style.display = "";
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1018
  }
1019
- else cursor.style.display = "none";
1020
  }
1021
 
 
 
 
 
1022
  function setSelectionUser(from, to) {
1023
  var sh = shiftSelecting && clipPos(shiftSelecting);
1024
  if (sh) {
@@ -1026,47 +1164,44 @@ var CodeMirror = (function() {
1026
  else if (posLess(to, sh)) to = sh;
1027
  }
1028
  setSelection(from, to);
 
1029
  }
1030
  // Update the selection. Last two args are only used by
1031
  // updateLines, since they have to be expressed in the line
1032
  // numbers before the update.
1033
  function setSelection(from, to, oldFrom, oldTo) {
 
1034
  if (oldFrom == null) {oldFrom = sel.from.line; oldTo = sel.to.line;}
1035
  if (posEq(sel.from, from) && posEq(sel.to, to)) return;
1036
  if (posLess(to, from)) {var tmp = to; to = from; from = tmp;}
1037
 
1038
  // Skip over hidden lines.
1039
- if (from.line != oldFrom) from = skipHidden(from, oldFrom, sel.from.ch);
 
 
 
 
 
1040
  if (to.line != oldTo) to = skipHidden(to, oldTo, sel.to.ch);
1041
 
1042
  if (posEq(from, to)) sel.inverted = false;
1043
  else if (posEq(from, sel.to)) sel.inverted = false;
1044
  else if (posEq(to, sel.from)) sel.inverted = true;
1045
 
1046
- // Some ugly logic used to only mark the lines that actually did
1047
- // see a change in selection as changed, rather than the whole
1048
- // selected range.
1049
- if (posEq(from, to)) {
1050
- if (!posEq(sel.from, sel.to))
1051
- changes.push({from: oldFrom, to: oldTo + 1});
1052
- }
1053
- else if (posEq(sel.from, sel.to)) {
1054
- changes.push({from: from.line, to: to.line + 1});
1055
- }
1056
- else {
1057
- if (!posEq(from, sel.from)) {
1058
- if (from.line < oldFrom)
1059
- changes.push({from: from.line, to: Math.min(to.line, oldFrom) + 1});
1060
- else
1061
- changes.push({from: oldFrom, to: Math.min(oldTo, from.line) + 1});
1062
- }
1063
- if (!posEq(to, sel.to)) {
1064
- if (to.line < oldTo)
1065
- changes.push({from: Math.max(oldFrom, from.line), to: oldTo + 1});
1066
- else
1067
- changes.push({from: Math.max(from.line, oldTo), to: to.line + 1});
1068
  }
1069
  }
 
1070
  sel.from = from; sel.to = to;
1071
  selectionChanged = true;
1072
  }
@@ -1077,13 +1212,14 @@ var CodeMirror = (function() {
1077
  var line = getLine(lNo);
1078
  if (!line.hidden) {
1079
  var ch = pos.ch;
1080
- if (ch > oldCh || ch > line.text.length) ch = line.text.length;
1081
  return {line: lNo, ch: ch};
1082
  }
1083
  lNo += dir;
1084
  }
1085
  }
1086
  var line = getLine(pos.line);
 
1087
  if (!line.hidden) return pos;
1088
  if (pos.line >= oldLine) return getNonHidden(1) || getNonHidden(-1);
1089
  else return getNonHidden(-1) || getNonHidden(1);
@@ -1103,76 +1239,88 @@ var CodeMirror = (function() {
1103
  else return pos;
1104
  }
1105
 
1106
- function scrollPage(down) {
1107
- var linesPerPage = Math.floor(scroller.clientHeight / textHeight()), head = sel.inverted ? sel.from : sel.to;
1108
- var target = heightAtLine(doc, head.line) + (Math.max(linesPerPage - 1, 1) * (down ? 1 : -1));
1109
- setCursor(lineAtHeight(doc, target), head.ch, true);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1110
  }
1111
- function scrollEnd(top) {
1112
- var pos = top ? {line: 0, ch: 0} : {line: doc.size - 1, ch: getLine(doc.size-1).text.length};
1113
- setSelectionUser(pos, pos);
 
 
1114
  }
1115
- function selectAll() {
1116
- var endLine = doc.size - 1;
1117
- setSelection({line: 0, ch: 0}, {line: endLine, ch: getLine(endLine).text.length});
 
 
 
 
 
 
 
1118
  }
 
1119
  function selectWordAt(pos) {
1120
  var line = getLine(pos.line).text;
1121
  var start = pos.ch, end = pos.ch;
1122
- while (start > 0 && /\w/.test(line.charAt(start - 1))) --start;
1123
- while (end < line.length && /\w/.test(line.charAt(end))) ++end;
1124
  setSelectionUser({line: pos.line, ch: start}, {line: pos.line, ch: end});
1125
  }
1126
  function selectLine(line) {
1127
- setSelectionUser({line: line, ch: 0}, {line: line, ch: getLine(line).text.length});
1128
- }
1129
- function handleEnter() {
1130
- replaceSelection("\n", "end");
1131
- if (options.enterMode != "flat")
1132
- indentLine(sel.from.line, options.enterMode == "keep" ? "prev" : "smart");
1133
- }
1134
- function handleTab(shift) {
1135
- function indentSelected(mode) {
1136
- if (posEq(sel.from, sel.to)) return indentLine(sel.from.line, mode);
1137
- var e = sel.to.line - (sel.to.ch ? 0 : 1);
1138
- for (var i = sel.from.line; i <= e; ++i) indentLine(i, mode);
1139
- }
1140
- shiftSelecting = null;
1141
- switch (options.tabMode) {
1142
- case "default":
1143
- return false;
1144
- case "indent":
1145
- indentSelected("smart");
1146
- break;
1147
- case "classic":
1148
- if (posEq(sel.from, sel.to)) {
1149
- if (shift) indentLine(sel.from.line, "smart");
1150
- else replaceSelection("\t", "end");
1151
- break;
1152
- }
1153
- case "shift":
1154
- indentSelected(shift ? "subtract" : "add");
1155
- break;
1156
- }
1157
- return true;
1158
  }
1159
- function smartHome() {
1160
- var firstNonWS = Math.max(0, getLine(sel.from.line).text.search(/\S/));
1161
- setCursor(sel.from.line, sel.from.ch <= firstNonWS && sel.from.ch ? 0 : firstNonWS, true);
 
1162
  }
1163
 
1164
  function indentLine(n, how) {
 
1165
  if (how == "smart") {
1166
  if (!mode.indent) how = "prev";
1167
  else var state = getStateBefore(n);
1168
  }
1169
 
1170
- var line = getLine(n), curSpace = line.indentation(), curSpaceString = line.text.match(/^\s*/)[0], indentation;
 
1171
  if (how == "prev") {
1172
- if (n) indentation = getLine(n-1).indentation();
1173
  else indentation = 0;
1174
  }
1175
- else if (how == "smart") indentation = mode.indent(state, line.text.slice(curSpaceString.length));
1176
  else if (how == "add") indentation = curSpace + options.indentUnit;
1177
  else if (how == "subtract") indentation = curSpace - options.indentUnit;
1178
  indentation = Math.max(0, indentation);
@@ -1185,7 +1333,7 @@ var CodeMirror = (function() {
1185
  else {
1186
  var indentString = "", pos = 0;
1187
  if (options.indentWithTabs)
1188
- for (var i = Math.floor(indentation / tabSize); i; --i) {pos += tabSize; indentString += "\t";}
1189
  while (pos < indentation) {++pos; indentString += " ";}
1190
  }
1191
 
@@ -1224,18 +1372,35 @@ var CodeMirror = (function() {
1224
  }
1225
  changes.push({from: 0, to: doc.size});
1226
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1227
 
1228
  function TextMarker() { this.set = []; }
1229
  TextMarker.prototype.clear = operation(function() {
 
1230
  for (var i = 0, e = this.set.length; i < e; ++i) {
1231
- var mk = this.set[i].marked;
1232
- if (!mk) continue;
 
 
1233
  for (var j = 0; j < mk.length; ++j)
1234
- if (mk[j].set == this.set) mk.splice(j--, 1);
1235
  }
1236
- // We don't know the exact lines that changed. Refreshing is
1237
- // cheaper than finding them.
1238
- changes.push({from: 0, to: doc.size});
1239
  });
1240
  TextMarker.prototype.find = function() {
1241
  var from, to;
@@ -1243,7 +1408,7 @@ var CodeMirror = (function() {
1243
  var line = this.set[i], mk = line.marked;
1244
  for (var j = 0; j < mk.length; ++j) {
1245
  var mark = mk[j];
1246
- if (mark.set == this.set) {
1247
  if (mark.from != null || mark.to != null) {
1248
  var found = lineNo(line);
1249
  if (found != null) {
@@ -1260,8 +1425,9 @@ var CodeMirror = (function() {
1260
  function markText(from, to, className) {
1261
  from = clipPos(from); to = clipPos(to);
1262
  var tm = new TextMarker();
 
1263
  function add(line, from, to, className) {
1264
- mark = getLine(line).addMark(new MarkedText(from, to, className, tm.set));
1265
  }
1266
  if (from.line == to.line) add(from.line, from.ch, to.ch, className);
1267
  else {
@@ -1281,6 +1447,19 @@ var CodeMirror = (function() {
1281
  return bm;
1282
  }
1283
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1284
  function addGutterMarker(line, text, className) {
1285
  if (typeof line == "number") line = getLine(clipLine(line));
1286
  line.gutterMarker = {text: text, style: className};
@@ -1299,12 +1478,14 @@ var CodeMirror = (function() {
1299
  else no = lineNo(handle);
1300
  if (no == null) return null;
1301
  if (op(line, no)) changes.push({from: no, to: no + 1});
 
1302
  return line;
1303
  }
1304
- function setLineClass(handle, className) {
1305
  return changeLine(handle, function(line) {
1306
- if (line.className != className) {
1307
  line.className = className;
 
1308
  return true;
1309
  }
1310
  });
@@ -1314,9 +1495,14 @@ var CodeMirror = (function() {
1314
  if (line.hidden != hidden) {
1315
  line.hidden = hidden;
1316
  updateLineHeight(line, hidden ? 0 : 1);
1317
- if (hidden && (sel.from.line == no || sel.to.line == no))
1318
- setSelection(skipHidden(sel.from, sel.from.line, sel.from.ch),
1319
- skipHidden(sel.to, sel.to.line, sel.to.ch));
 
 
 
 
 
1320
  return (gutterDirty = true);
1321
  }
1322
  });
@@ -1335,7 +1521,7 @@ var CodeMirror = (function() {
1335
  }
1336
  var marker = line.gutterMarker;
1337
  return {line: n, handle: line, text: line.text, markerText: marker && marker.text,
1338
- markerClass: marker && marker.style, lineClass: line.className};
1339
  }
1340
 
1341
  function stringWidth(str) {
@@ -1349,8 +1535,7 @@ var CodeMirror = (function() {
1349
  if (x <= 0) return 0;
1350
  var lineObj = getLine(line), text = lineObj.text;
1351
  function getX(len) {
1352
- measure.innerHTML = "<pre><span>" + lineObj.getHTML(null, null, false, len) + "</span></pre>";
1353
- return measure.firstChild.firstChild.offsetWidth;
1354
  }
1355
  var from = 0, fromX = 0, to = text.length, toX;
1356
  // Guess a suitable upper bound for our search.
@@ -1373,21 +1558,16 @@ var CodeMirror = (function() {
1373
  }
1374
  }
1375
 
1376
- var tempId = Math.floor(Math.random() * 0xffffff).toString(16);
1377
  function measureLine(line, ch) {
1378
- var extra = "";
1379
- // Include extra text at the end to make sure the measured line is wrapped in the right way.
1380
- if (options.lineWrapping) {
1381
- var end = line.text.indexOf(" ", ch + 2);
1382
- extra = line.text.slice(ch + 1, end < 0 ? line.text.length : end + (ie ? 5 : 0));
1383
- }
1384
- measure.innerHTML = "<pre>" + line.getHTML(null, null, false, ch) +
1385
- '<span id="CodeMirror-temp-' + tempId + '">' + (line.text.charAt(ch) || " ") + "</span>" +
1386
- extra + "</pre>";
1387
- var elt = document.getElementById("CodeMirror-temp-" + tempId);
1388
  var top = elt.offsetTop, left = elt.offsetLeft;
1389
  // Older IEs report zero offsets for spans directly after a wrap
1390
- if (ie && ch && top == 0 && left == 0) {
1391
  var backup = document.createElement("span");
1392
  backup.innerHTML = "x";
1393
  elt.parentNode.insertBefore(backup, elt.nextSibling);
@@ -1410,7 +1590,7 @@ var CodeMirror = (function() {
1410
  if (y < 0) y = 0;
1411
  var th = textHeight(), cw = charWidth(), heightPos = displayOffset + Math.floor(y / th);
1412
  var lineNo = lineAtHeight(doc, heightPos);
1413
- if (lineNo >= doc.size) return {line: doc.size - 1, ch: 0};
1414
  var lineObj = getLine(lineNo), text = lineObj.text;
1415
  var tw = options.lineWrapping, innerOff = tw ? heightPos - heightAtLine(doc, lineNo) : 0;
1416
  if (x <= 0 && innerOff == 0) return {line: lineNo, ch: 0};
@@ -1447,18 +1627,25 @@ var CodeMirror = (function() {
1447
  return {x: off.left + local.x, y: off.top + local.y, yBot: off.top + local.yBot};
1448
  }
1449
 
1450
- var cachedHeight, cachedFor;
1451
  function textHeight() {
1452
- var offsetHeight = lineDiv.offsetHeight;
1453
- if (offsetHeight == cachedFor) return cachedHeight;
1454
- cachedFor = offsetHeight;
1455
- measure.innerHTML = "<pre>x<br>x<br>x<br>x<br>x<br>x<br>x<br>x<br>x<br>x</pre>";
1456
- return (cachedHeight = measure.firstChild.offsetHeight / 10 || 1);
1457
- }
1458
- var cachedWidth, cachedFor = 0;
 
 
 
 
 
 
 
1459
  function charWidth() {
1460
- if (scroller.clientWidth == cachedFor) return cachedWidth;
1461
- cachedFor = scroller.clientWidth;
1462
  return (cachedWidth = stringWidth("x"));
1463
  }
1464
  function paddingTop() {return lineSpace.offsetTop;}
@@ -1477,7 +1664,7 @@ var CodeMirror = (function() {
1477
  return coordsChar(x - offL.left, y - offL.top);
1478
  }
1479
  function onContextMenu(e) {
1480
- var pos = posFromMouse(e);
1481
  if (!pos || window.opera) return; // Opera is difficult.
1482
  if (posEq(sel.from, sel.to) || posLess(pos, sel.from) || !posLess(pos, sel.to))
1483
  operation(setCursor)(pos.line, pos.ch);
@@ -1490,14 +1677,15 @@ var CodeMirror = (function() {
1490
  leaveInputAlone = true;
1491
  var val = input.value = getSelection();
1492
  focusInput();
1493
- setSelRange(input, 0, input.value.length);
1494
  function rehide() {
1495
  var newVal = splitLines(input.value).join("\n");
1496
  if (newVal != val) operation(replaceSelection)(newVal, "end");
1497
  inputDiv.style.position = "relative";
1498
  input.style.cssText = oldCSS;
 
1499
  leaveInputAlone = false;
1500
- prepareInput();
1501
  slowPoll();
1502
  }
1503
 
@@ -1507,8 +1695,7 @@ var CodeMirror = (function() {
1507
  mouseup();
1508
  setTimeout(rehide, 20);
1509
  }, true);
1510
- }
1511
- else {
1512
  setTimeout(rehide, 50);
1513
  }
1514
  }
@@ -1574,7 +1761,7 @@ var CodeMirror = (function() {
1574
  if (search == 0) return 0;
1575
  var line = getLine(search-1);
1576
  if (line.stateAfter) return search;
1577
- var indented = line.indentation();
1578
  if (minline == null || minindent > indented) {
1579
  minline = search - 1;
1580
  minindent = indented;
@@ -1587,7 +1774,7 @@ var CodeMirror = (function() {
1587
  if (!state) state = startState(mode);
1588
  else state = copyState(mode, state);
1589
  doc.iter(start, n, function(line) {
1590
- line.highlight(mode, state);
1591
  line.stateAfter = copyState(mode, state);
1592
  });
1593
  if (start < n) changes.push({from: start, to: n});
@@ -1597,7 +1784,7 @@ var CodeMirror = (function() {
1597
  function highlightLines(start, end) {
1598
  var state = getStateBefore(start);
1599
  doc.iter(start, end, function(line) {
1600
- line.highlight(mode, state);
1601
  line.stateAfter = copyState(mode, state);
1602
  });
1603
  }
@@ -1622,15 +1809,20 @@ var CodeMirror = (function() {
1622
  if (realChange) changes.push({from: task, to: i + 1});
1623
  return (bail = true);
1624
  }
1625
- var changed = line.highlight(mode, state);
1626
  if (changed) realChange = true;
1627
  line.stateAfter = copyState(mode, state);
 
1628
  if (compare) {
1629
- if (hadState && compare(hadState, state)) return true;
1630
- } else {
 
 
1631
  if (changed !== false || !hadState) unchanged = 0;
1632
- else if (++unchanged > 3) return true;
 
1633
  }
 
1634
  ++i;
1635
  });
1636
  if (bail) return;
@@ -1649,35 +1841,36 @@ var CodeMirror = (function() {
1649
  // be awkward, slow, and error-prone), but instead updates are
1650
  // batched and then all combined and executed at once.
1651
  function startOperation() {
1652
- updateInput = null; changes = []; textChanged = selectionChanged = false;
 
1653
  }
1654
  function endOperation() {
1655
- var reScroll = false;
1656
  if (selectionChanged) reScroll = !scrollCursorIntoView();
1657
- if (changes.length) updateDisplay(changes);
1658
  else {
1659
- if (selectionChanged) updateCursor();
1660
  if (gutterDirty) updateGutter();
1661
  }
1662
  if (reScroll) scrollCursorIntoView();
1663
  if (selectionChanged) {scrollEditorIntoView(); restartBlink();}
1664
 
1665
- // updateInput can be set to a boolean value to force/prevent an
1666
- // update.
1667
  if (focused && !leaveInputAlone &&
1668
  (updateInput === true || (updateInput !== false && selectionChanged)))
1669
- prepareInput();
1670
 
1671
  if (selectionChanged && options.matchBrackets)
1672
  setTimeout(operation(function() {
1673
  if (bracketHighlighted) {bracketHighlighted(); bracketHighlighted = null;}
1674
- matchBrackets(false);
1675
  }), 20);
1676
- var tc = textChanged; // textChanged can be reset by cursoractivity callback
1677
  if (selectionChanged && options.onCursorActivity)
1678
  options.onCursorActivity(instance);
1679
  if (tc && options.onChange && instance)
1680
  options.onChange(instance, tc);
 
 
1681
  }
1682
  var nestedOperation = 0;
1683
  function operation(f) {
@@ -1689,120 +1882,11 @@ var CodeMirror = (function() {
1689
  };
1690
  }
1691
 
1692
- function SearchCursor(query, pos, caseFold) {
1693
- this.atOccurrence = false;
1694
- if (caseFold == null) caseFold = typeof query == "string" && query == query.toLowerCase();
1695
-
1696
- if (pos && typeof pos == "object") pos = clipPos(pos);
1697
- else pos = {line: 0, ch: 0};
1698
- this.pos = {from: pos, to: pos};
1699
-
1700
- // The matches method is filled in based on the type of query.
1701
- // It takes a position and a direction, and returns an object
1702
- // describing the next occurrence of the query, or null if no
1703
- // more matches were found.
1704
- if (typeof query != "string") // Regexp match
1705
- this.matches = function(reverse, pos) {
1706
- if (reverse) {
1707
- var line = getLine(pos.line).text.slice(0, pos.ch), match = line.match(query), start = 0;
1708
- while (match) {
1709
- var ind = line.indexOf(match[0]);
1710
- start += ind;
1711
- line = line.slice(ind + 1);
1712
- var newmatch = line.match(query);
1713
- if (newmatch) match = newmatch;
1714
- else break;
1715
- start++;
1716
- }
1717
- }
1718
- else {
1719
- var line = getLine(pos.line).text.slice(pos.ch), match = line.match(query),
1720
- start = match && pos.ch + line.indexOf(match[0]);
1721
- }
1722
- if (match)
1723
- return {from: {line: pos.line, ch: start},
1724
- to: {line: pos.line, ch: start + match[0].length},
1725
- match: match};
1726
- };
1727
- else { // String query
1728
- if (caseFold) query = query.toLowerCase();
1729
- var fold = caseFold ? function(str){return str.toLowerCase();} : function(str){return str;};
1730
- var target = query.split("\n");
1731
- // Different methods for single-line and multi-line queries
1732
- if (target.length == 1)
1733
- this.matches = function(reverse, pos) {
1734
- var line = fold(getLine(pos.line).text), len = query.length, match;
1735
- if (reverse ? (pos.ch >= len && (match = line.lastIndexOf(query, pos.ch - len)) != -1)
1736
- : (match = line.indexOf(query, pos.ch)) != -1)
1737
- return {from: {line: pos.line, ch: match},
1738
- to: {line: pos.line, ch: match + len}};
1739
- };
1740
- else
1741
- this.matches = function(reverse, pos) {
1742
- var ln = pos.line, idx = (reverse ? target.length - 1 : 0), match = target[idx], line = fold(getLine(ln).text);
1743
- var offsetA = (reverse ? line.indexOf(match) + match.length : line.lastIndexOf(match));
1744
- if (reverse ? offsetA >= pos.ch || offsetA != match.length
1745
- : offsetA <= pos.ch || offsetA != line.length - match.length)
1746
- return;
1747
- for (;;) {
1748
- if (reverse ? !ln : ln == doc.size - 1) return;
1749
- line = fold(getLine(ln += reverse ? -1 : 1).text);
1750
- match = target[reverse ? --idx : ++idx];
1751
- if (idx > 0 && idx < target.length - 1) {
1752
- if (line != match) return;
1753
- else continue;
1754
- }
1755
- var offsetB = (reverse ? line.lastIndexOf(match) : line.indexOf(match) + match.length);
1756
- if (reverse ? offsetB != line.length - match.length : offsetB != match.length)
1757
- return;
1758
- var start = {line: pos.line, ch: offsetA}, end = {line: ln, ch: offsetB};
1759
- return {from: reverse ? end : start, to: reverse ? start : end};
1760
- }
1761
- };
1762
- }
1763
  }
1764
 
1765
- SearchCursor.prototype = {
1766
- findNext: function() {return this.find(false);},
1767
- findPrevious: function() {return this.find(true);},
1768
-
1769
- find: function(reverse) {
1770
- var self = this, pos = clipPos(reverse ? this.pos.from : this.pos.to);
1771
- function savePosAndFail(line) {
1772
- var pos = {line: line, ch: 0};
1773
- self.pos = {from: pos, to: pos};
1774
- self.atOccurrence = false;
1775
- return false;
1776
- }
1777
-
1778
- for (;;) {
1779
- if (this.pos = this.matches(reverse, pos)) {
1780
- this.atOccurrence = true;
1781
- return this.pos.match || true;
1782
- }
1783
- if (reverse) {
1784
- if (!pos.line) return savePosAndFail(0);
1785
- pos = {line: pos.line-1, ch: getLine(pos.line-1).text.length};
1786
- }
1787
- else {
1788
- if (pos.line == doc.size - 1) return savePosAndFail(doc.size);
1789
- pos = {line: pos.line+1, ch: 0};
1790
- }
1791
- }
1792
- },
1793
-
1794
- from: function() {if (this.atOccurrence) return copyPos(this.pos.from);},
1795
- to: function() {if (this.atOccurrence) return copyPos(this.pos.to);},
1796
-
1797
- replace: function(newText) {
1798
- var self = this;
1799
- if (this.atOccurrence)
1800
- operation(function() {
1801
- self.pos.to = replaceRange(newText, self.pos.from, self.pos.to);
1802
- })();
1803
- }
1804
- };
1805
-
1806
  for (var ext in extensions)
1807
  if (extensions.propertyIsEnumerable(ext) &&
1808
  !instance.propertyIsEnumerable(ext))
@@ -1817,53 +1901,66 @@ var CodeMirror = (function() {
1817
  theme: "default",
1818
  indentUnit: 2,
1819
  indentWithTabs: false,
1820
- tabMode: "classic",
1821
- enterMode: "indent",
 
 
1822
  electricChars: true,
 
1823
  onKeyEvent: null,
 
1824
  lineWrapping: false,
1825
  lineNumbers: false,
1826
  gutter: false,
1827
  fixedGutter: false,
1828
  firstLineNumber: 1,
1829
  readOnly: false,
1830
- smartHome: true,
1831
  onChange: null,
1832
  onCursorActivity: null,
1833
  onGutterClick: null,
1834
  onHighlightComplete: null,
 
1835
  onFocus: null, onBlur: null, onScroll: null,
1836
  matchBrackets: false,
1837
  workTime: 100,
1838
  workDelay: 200,
 
1839
  undoDepth: 40,
1840
  tabindex: null,
1841
- pollForIME: false,
1842
- document: window.document
1843
  };
1844
 
 
 
 
 
1845
  // Known modes, by name and by MIME
1846
- var modes = {}, mimeModes = {};
1847
  CodeMirror.defineMode = function(name, mode) {
1848
  if (!CodeMirror.defaults.mode && name != "null") CodeMirror.defaults.mode = name;
 
 
 
 
1849
  modes[name] = mode;
1850
  };
1851
  CodeMirror.defineMIME = function(mime, spec) {
1852
  mimeModes[mime] = spec;
1853
  };
1854
- CodeMirror.getMode = function(options, spec) {
1855
  if (typeof spec == "string" && mimeModes.hasOwnProperty(spec))
1856
  spec = mimeModes[spec];
1857
- if (typeof spec == "string")
1858
- var mname = spec, config = {};
1859
- else if (spec != null)
1860
- var mname = spec.name, config = spec;
1861
- var mfactory = modes[mname];
1862
- if (!mfactory) {
1863
- if (window.console) console.warn("No mode " + mname + " found, falling back to plain text.");
1864
- return CodeMirror.getMode(options, "text/plain");
1865
- }
1866
- return mfactory(options, config || {});
1867
  };
1868
  CodeMirror.listModes = function() {
1869
  var list = [];
@@ -1878,16 +1975,137 @@ var CodeMirror = (function() {
1878
  return list;
1879
  };
1880
 
1881
- var extensions = {};
1882
  CodeMirror.defineExtension = function(name, func) {
1883
  extensions[name] = func;
1884
  };
1885
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1886
  CodeMirror.fromTextArea = function(textarea, options) {
1887
  if (!options) options = {};
1888
  options.value = textarea.value;
1889
  if (!options.tabindex && textarea.tabindex)
1890
  options.tabindex = textarea.tabindex;
 
 
1891
 
1892
  function save() {textarea.value = instance.getValue();}
1893
  if (textarea.form) {
@@ -1910,6 +2128,7 @@ var CodeMirror = (function() {
1910
  textarea.parentNode.insertBefore(node, textarea.nextSibling);
1911
  }, options);
1912
  instance.save = save;
 
1913
  instance.toTextArea = function() {
1914
  save();
1915
  textarea.parentNode.removeChild(instance.getWrapperElement());
@@ -1943,9 +2162,10 @@ var CodeMirror = (function() {
1943
  CodeMirror.startState = startState;
1944
 
1945
  // The character stream used by a mode's parser.
1946
- function StringStream(string) {
1947
  this.pos = this.start = 0;
1948
  this.string = string;
 
1949
  }
1950
  StringStream.prototype = {
1951
  eol: function() {return this.pos >= this.string.length;},
@@ -1977,8 +2197,8 @@ var CodeMirror = (function() {
1977
  if (found > -1) {this.pos = found; return true;}
1978
  },
1979
  backUp: function(n) {this.pos -= n;},
1980
- column: function() {return countColumn(this.string, this.start);},
1981
- indentation: function() {return countColumn(this.string);},
1982
  match: function(pattern, consume, caseInsensitive) {
1983
  if (typeof pattern == "string") {
1984
  function cased(str) {return caseInsensitive ? str.toLowerCase() : str;}
@@ -1997,34 +2217,34 @@ var CodeMirror = (function() {
1997
  };
1998
  CodeMirror.StringStream = StringStream;
1999
 
2000
- function MarkedText(from, to, className, set) {
2001
- this.from = from; this.to = to; this.style = className; this.set = set;
2002
  }
2003
  MarkedText.prototype = {
2004
- attach: function(line) { this.set.push(line); },
2005
  detach: function(line) {
2006
- var ix = indexOf(this.set, line);
2007
- if (ix > -1) this.set.splice(ix, 1);
2008
  },
2009
  split: function(pos, lenBefore) {
2010
  if (this.to <= pos && this.to != null) return null;
2011
  var from = this.from < pos || this.from == null ? null : this.from - pos + lenBefore;
2012
  var to = this.to == null ? null : this.to - pos + lenBefore;
2013
- return new MarkedText(from, to, this.style, this.set);
2014
  },
2015
- dup: function() { return new MarkedText(null, null, this.style, this.set); },
2016
  clipTo: function(fromOpen, from, toOpen, to, diff) {
2017
- if (this.from != null && this.from >= from)
2018
- this.from = Math.max(to, this.from) + diff;
2019
- if (this.to != null && this.to > from)
2020
- this.to = to < this.to ? this.to + diff : from;
2021
  if (fromOpen && to > this.from && (to < this.to || this.to == null))
2022
  this.from = null;
 
 
2023
  if (toOpen && (from < this.to || this.to == null) && (from > this.from || this.from == null))
2024
  this.to = null;
 
 
2025
  },
2026
  isDead: function() { return this.from != null && this.to != null && this.from >= this.to; },
2027
- sameSet: function(x) { return this.set == x.set; }
2028
  };
2029
 
2030
  function Bookmark(pos) {
@@ -2067,11 +2287,11 @@ var CodeMirror = (function() {
2067
  this.styles = styles || [text, null];
2068
  this.text = text;
2069
  this.height = 1;
2070
- this.marked = this.gutterMarker = this.className = null;
2071
  this.stateAfter = this.parent = this.hidden = null;
2072
  }
2073
  Line.inheritMarks = function(text, orig) {
2074
- var ln = new Line(text), mk = orig.marked;
2075
  if (mk) {
2076
  for (var i = 0; i < mk.length; ++i) {
2077
  if (mk[i].to == null && mk[i].style) {
@@ -2085,9 +2305,6 @@ var CodeMirror = (function() {
2085
  Line.prototype = {
2086
  // Replace a piece of a line, keeping the styles around it intact.
2087
  replace: function(from, to_, text) {
2088
- // Reset line class if the whole text was replaced.
2089
- if (!from && (to_ == null || to_ == this.text.length))
2090
- this.className = this.gutterMarker = null;
2091
  var st = [], mk = this.marked, to = to_ == null ? this.text.length : to_;
2092
  copyStyles(0, from, this.styles, st);
2093
  if (text) st.push(text, null);
@@ -2097,7 +2314,8 @@ var CodeMirror = (function() {
2097
  this.stateAfter = null;
2098
  if (mk) {
2099
  var diff = text.length - (to - from);
2100
- for (var i = 0, mark = mk[i]; i < mk.length; ++i) {
 
2101
  mark.clipTo(from == null, from || 0, to_ == null, to, diff);
2102
  if (mark.isDead()) {mark.detach(this); mk.splice(i--, 1);}
2103
  }
@@ -2115,6 +2333,7 @@ var CodeMirror = (function() {
2115
  if (newmark) {
2116
  if (!taken.marked) taken.marked = [];
2117
  taken.marked.push(newmark); newmark.attach(taken);
 
2118
  }
2119
  }
2120
  }
@@ -2164,6 +2383,12 @@ var CodeMirror = (function() {
2164
  if (close) mark.to = this.text.length;
2165
  }
2166
  },
 
 
 
 
 
 
2167
  addMark: function(mark) {
2168
  mark.attach(this);
2169
  if (this.marked == null) this.marked = [];
@@ -2173,8 +2398,8 @@ var CodeMirror = (function() {
2173
  // Run the given mode's parser over a line, update the styles
2174
  // array, which contains alternating fragments of text and CSS
2175
  // classes.
2176
- highlight: function(mode, state) {
2177
- var stream = new StringStream(this.text), st = this.styles, pos = 0;
2178
  var changed = false, curWord = st[0], prevWord;
2179
  if (this.text == "" && mode.blankLine) mode.blankLine(state);
2180
  while (!stream.eol()) {
@@ -2215,76 +2440,119 @@ var CodeMirror = (function() {
2215
  className: style || null,
2216
  state: state};
2217
  },
2218
- indentation: function() {return countColumn(this.text);},
2219
  // Produces an HTML fragment for the line, taking selection,
2220
  // marking, and highlighting into account.
2221
- getHTML: function(sfrom, sto, includePre, endAt) {
2222
- var html = [], first = true;
2223
- if (includePre)
2224
- html.push(this.className ? '<pre class="' + this.className + '">': "<pre>");
2225
- function span(text, style) {
2226
  if (!text) return;
2227
  // Work around a bug where, in some compat modes, IE ignores leading spaces
2228
  if (first && ie && text.charAt(0) == " ") text = "\u00a0" + text.slice(1);
2229
  first = false;
2230
- if (style) html.push('<span class="', style, '">', htmlEscape(text), "</span>");
2231
- else html.push(htmlEscape(text));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2232
  }
 
2233
  var st = this.styles, allText = this.text, marked = this.marked;
2234
- if (sfrom == sto) sfrom = null;
2235
  var len = allText.length;
2236
- if (endAt != null) len = Math.min(endAt, len);
 
 
 
2237
 
2238
- if (!allText && endAt == null)
2239
- span(" ", sfrom != null && sto == null ? "CodeMirror-selected" : null);
2240
- else if (!marked && sfrom == null)
2241
  for (var i = 0, ch = 0; ch < len; i+=2) {
2242
  var str = st[i], style = st[i+1], l = str.length;
2243
  if (ch + l > len) str = str.slice(0, len - ch);
2244
  ch += l;
2245
- span(str, style && "cm-" + style);
2246
  }
2247
- else {
2248
  var pos = 0, i = 0, text = "", style, sg = 0;
2249
- var markpos = -1, mark = null;
2250
- function nextMark() {
2251
- if (marked) {
2252
- markpos += 1;
2253
- mark = (markpos < marked.length) ? marked[markpos] : null;
 
 
 
 
 
 
 
 
2254
  }
2255
  }
2256
- nextMark();
2257
  while (pos < len) {
2258
- var upto = len;
2259
- var extraStyle = "";
2260
- if (sfrom != null) {
2261
- if (sfrom > pos) upto = sfrom;
2262
- else if (sto == null || sto > pos) {
2263
- extraStyle = " CodeMirror-selected";
2264
- if (sto != null) upto = Math.min(upto, sto);
 
 
 
 
2265
  }
2266
- }
2267
- while (mark && mark.to != null && mark.to <= pos) nextMark();
2268
- if (mark) {
2269
- if (mark.from > pos) upto = Math.min(upto, mark.from);
2270
- else {
2271
- extraStyle += " " + mark.style;
2272
- if (mark.to != null) upto = Math.min(upto, mark.to);
2273
- }
2274
- }
2275
- for (;;) {
2276
- var end = pos + text.length;
2277
- var appliedStyle = style;
2278
- if (extraStyle) appliedStyle = style ? style + extraStyle : extraStyle;
2279
- span(end > upto ? text.slice(0, upto - pos) : text, appliedStyle);
2280
- if (end >= upto) {text = text.slice(upto - pos); pos = upto; break;}
2281
- pos = end;
2282
- text = st[i++]; style = "cm-" + st[i++];
2283
  }
2284
  }
2285
- if (sfrom != null && sto == null) span(" ", "CodeMirror-selected");
2286
  }
2287
- if (includePre) html.push("</pre>");
2288
  return html.join("");
2289
  },
2290
  cleanUp: function() {
@@ -2321,11 +2589,13 @@ var CodeMirror = (function() {
2321
  }
2322
  LeafChunk.prototype = {
2323
  chunkSize: function() { return this.lines.length; },
2324
- remove: function(at, n) {
2325
  for (var i = at, e = at + n; i < e; ++i) {
2326
  var line = this.lines[i];
2327
- line.cleanUp();
2328
  this.height -= line.height;
 
 
 
2329
  }
2330
  this.lines.splice(at, n);
2331
  },
@@ -2334,7 +2604,11 @@ var CodeMirror = (function() {
2334
  },
2335
  insertHeight: function(at, lines, height) {
2336
  this.height += height;
2337
- this.lines.splice.apply(this.lines, [at, 0].concat(lines));
 
 
 
 
2338
  for (var i = 0, e = lines.length; i < e; ++i) lines[i].parent = this;
2339
  },
2340
  iterN: function(at, n, op) {
@@ -2356,13 +2630,13 @@ var CodeMirror = (function() {
2356
  }
2357
  BranchChunk.prototype = {
2358
  chunkSize: function() { return this.size; },
2359
- remove: function(at, n) {
2360
  this.size -= n;
2361
  for (var i = 0; i < this.children.length; ++i) {
2362
  var child = this.children[i], sz = child.chunkSize();
2363
  if (at < sz) {
2364
  var rm = Math.min(n, sz - at), oldHeight = child.height;
2365
- child.remove(at, rm);
2366
  this.height -= oldHeight - child.height;
2367
  if (sz == rm) { this.children.splice(i--, 1); child.parent = null; }
2368
  if ((n -= rm) == 0) break;
@@ -2373,6 +2647,7 @@ var CodeMirror = (function() {
2373
  var lines = [];
2374
  this.collapse(lines);
2375
  this.children = [new LeafChunk(lines)];
 
2376
  }
2377
  },
2378
  collapse: function(lines) {
@@ -2441,14 +2716,14 @@ var CodeMirror = (function() {
2441
  };
2442
 
2443
  function getLineAt(chunk, n) {
2444
- for (;;) {
2445
- for (var i = 0, e = chunk.children.length; i < e; ++i) {
2446
  var child = chunk.children[i], sz = child.chunkSize();
2447
  if (n < sz) { chunk = child; break; }
2448
  n -= sz;
2449
  }
2450
- if (chunk.lines) return chunk.lines[n];
2451
  }
 
2452
  }
2453
  function lineNo(line) {
2454
  if (line.parent == null) return null;
@@ -2499,31 +2774,36 @@ var CodeMirror = (function() {
2499
  function History() {
2500
  this.time = 0;
2501
  this.done = []; this.undone = [];
 
 
2502
  }
2503
  History.prototype = {
2504
  addChange: function(start, added, old) {
2505
  this.undone.length = 0;
2506
- var time = +new Date, last = this.done[this.done.length - 1];
2507
- if (time - this.time > 400 || !last ||
2508
- last.start > start + added || last.start + last.added < start - last.added + last.old.length)
2509
- this.done.push({start: start, added: added, old: old});
2510
- else {
2511
- var oldoff = 0;
2512
- if (start < last.start) {
2513
- for (var i = last.start - start - 1; i >= 0; --i)
2514
- last.old.unshift(old[i]);
2515
- last.added += last.start - start;
2516
- last.start = start;
2517
- }
2518
- else if (last.start < start) {
2519
- oldoff = start - last.start;
2520
- added += oldoff;
2521
- }
2522
- for (var i = last.added - oldoff, e = old.length; i < e; ++i)
2523
- last.old.push(old[i]);
2524
- if (last.added < added) last.added = added;
2525
  }
2526
  this.time = time;
 
 
 
 
 
 
2527
  }
2528
  };
2529
 
@@ -2543,6 +2823,10 @@ var CodeMirror = (function() {
2543
  else e.cancelBubble = true;
2544
  }
2545
  function e_stop(e) {e_preventDefault(e); e_stopPropagation(e);}
 
 
 
 
2546
  function e_target(e) {return e.target || e.srcElement;}
2547
  function e_button(e) {
2548
  if (e.which) return e.which;
@@ -2551,54 +2835,74 @@ var CodeMirror = (function() {
2551
  else if (e.button & 4) return 2;
2552
  }
2553
 
 
 
 
 
 
 
 
2554
  // Event handler registration. If disconnect is true, it'll return a
2555
  // function that unregisters the handler.
2556
  function connect(node, type, handler, disconnect) {
2557
- function wrapHandler(event) {handler(event || window.event);}
2558
  if (typeof node.addEventListener == "function") {
2559
- node.addEventListener(type, wrapHandler, false);
2560
- if (disconnect) return function() {node.removeEventListener(type, wrapHandler, false);};
2561
  }
2562
  else {
 
2563
  node.attachEvent("on" + type, wrapHandler);
2564
  if (disconnect) return function() {node.detachEvent("on" + type, wrapHandler);};
2565
  }
2566
  }
 
2567
 
2568
  function Delayed() {this.id = null;}
2569
  Delayed.prototype = {set: function(ms, f) {clearTimeout(this.id); this.id = setTimeout(f, ms);}};
2570
 
2571
- // Detect drag-and-drop
2572
- var dragAndDrop = function() {
2573
- // IE8 has ondragstart and ondrop properties, but doesn't seem to
2574
- // actually support ondragstart the way it's supposed to work.
2575
- if (/MSIE [1-8]\b/.test(navigator.userAgent)) return false;
2576
- var div = document.createElement('div');
2577
- return "draggable" in div;
2578
- }();
2579
 
2580
  var gecko = /gecko\/\d{7}/i.test(navigator.userAgent);
2581
  var ie = /MSIE \d/.test(navigator.userAgent);
 
 
2582
  var webkit = /WebKit\//.test(navigator.userAgent);
 
 
 
 
 
 
 
 
 
 
 
 
2583
 
2584
- var lineSep = "\n";
2585
  // Feature-detect whether newlines in textareas are converted to \r\n
2586
- (function () {
2587
  var te = document.createElement("textarea");
2588
  te.value = "foo\nbar";
2589
- if (te.value.indexOf("\r") > -1) lineSep = "\r\n";
2590
- }());
 
2591
 
2592
- var tabSize = 8;
2593
- var mac = /Mac/.test(navigator.platform);
2594
- var win = /Win/.test(navigator.platform);
2595
- var movementKeys = {};
2596
- for (var i = 35; i <= 40; ++i)
2597
- movementKeys[i] = movementKeys["c" + i] = true;
 
 
 
 
 
2598
 
2599
  // Counts the column offset in a string, taking tabs into account.
2600
  // Used mostly to find indentation.
2601
- function countColumn(string, end) {
2602
  if (end == null) {
2603
  end = string.search(/[^\s\u00a0]/);
2604
  if (end == -1) end = string.length;
@@ -2656,6 +2960,12 @@ var CodeMirror = (function() {
2656
  function eltText(node) {
2657
  return node.textContent || node.innerText || node.nodeValue || "";
2658
  }
 
 
 
 
 
 
2659
 
2660
  // Operations on {line, ch} objects.
2661
  function posEq(a, b) {return a.line == b.line && a.ch == b.ch;}
@@ -2664,21 +2974,29 @@ var CodeMirror = (function() {
2664
 
2665
  var escapeElement = document.createElement("pre");
2666
  function htmlEscape(str) {
2667
- if (badTextContent) {
2668
- escapeElement.innerHTML = "";
2669
- escapeElement.appendChild(document.createTextNode(str));
2670
- } else {
2671
- escapeElement.textContent = str;
2672
- }
2673
  return escapeElement.innerHTML;
2674
  }
2675
- var badTextContent = htmlEscape("\t") != "\t";
 
 
 
 
 
 
 
 
 
 
 
 
 
2676
  CodeMirror.htmlEscape = htmlEscape;
2677
 
2678
  // Used to position the cursor after an undo/redo by finding the
2679
  // last edited character.
2680
  function editEnd(from, to) {
2681
- if (!to) return from ? from.length : 0;
2682
  if (!from) return to.length;
2683
  for (var i = from.length, j = to.length; i >= 0 && j >= 0; --i, --j)
2684
  if (from.charAt(i) != to.charAt(j)) break;
@@ -2691,95 +3009,54 @@ var CodeMirror = (function() {
2691
  if (collection[i] == elt) return i;
2692
  return -1;
2693
  }
 
 
 
2694
 
2695
  // See if "".split is the broken IE version, if so, provide an
2696
  // alternative way to split lines.
2697
- var splitLines, selRange, setSelRange;
2698
- if ("\n\nb".split(/\n/).length != 3)
2699
- splitLines = function(string) {
2700
- var pos = 0, nl, result = [];
2701
- while ((nl = string.indexOf("\n", pos)) > -1) {
2702
- result.push(string.slice(pos, string.charAt(nl-1) == "\r" ? nl - 1 : nl));
2703
- pos = nl + 1;
2704
- }
2705
- result.push(string.slice(pos));
2706
- return result;
2707
- };
2708
- else
2709
- splitLines = function(string){return string.split(/\r?\n/);};
2710
  CodeMirror.splitLines = splitLines;
2711
 
2712
- // Sane model of finding and setting the selection in a textarea
2713
- if (window.getSelection) {
2714
- selRange = function(te) {
2715
- try {return {start: te.selectionStart, end: te.selectionEnd};}
2716
- catch(e) {return null;}
2717
- };
2718
- if (webkit)
2719
- // On Safari, selection set with setSelectionRange are in a sort
2720
- // of limbo wrt their anchor. If you press shift-left in them,
2721
- // the anchor is put at the end, and the selection expanded to
2722
- // the left. If you press shift-right, the anchor ends up at the
2723
- // front. This is not what CodeMirror wants, so it does a
2724
- // spurious modify() call to get out of limbo.
2725
- setSelRange = function(te, start, end) {
2726
- if (start == end)
2727
- te.setSelectionRange(start, end);
2728
- else {
2729
- te.setSelectionRange(start, end - 1);
2730
- window.getSelection().modify("extend", "forward", "character");
2731
- }
2732
- };
2733
- else
2734
- setSelRange = function(te, start, end) {
2735
- try {te.setSelectionRange(start, end);}
2736
- catch(e) {} // Fails on Firefox when textarea isn't part of the document
2737
- };
2738
- }
2739
- // IE model. Don't ask.
2740
- else {
2741
- selRange = function(te) {
2742
- try {var range = te.ownerDocument.selection.createRange();}
2743
- catch(e) {return null;}
2744
- if (!range || range.parentElement() != te) return null;
2745
- var val = te.value, len = val.length, localRange = te.createTextRange();
2746
- localRange.moveToBookmark(range.getBookmark());
2747
- var endRange = te.createTextRange();
2748
- endRange.collapse(false);
2749
-
2750
- if (localRange.compareEndPoints("StartToEnd", endRange) > -1)
2751
- return {start: len, end: len};
2752
-
2753
- var start = -localRange.moveStart("character", -len);
2754
- for (var i = val.indexOf("\r"); i > -1 && i < start; i = val.indexOf("\r", i+1), start++) {}
2755
-
2756
- if (localRange.compareEndPoints("EndToEnd", endRange) > -1)
2757
- return {start: start, end: len};
2758
-
2759
- var end = -localRange.moveEnd("character", -len);
2760
- for (var i = val.indexOf("\r"); i > -1 && i < end; i = val.indexOf("\r", i+1), end++) {}
2761
- return {start: start, end: end};
2762
- };
2763
- setSelRange = function(te, start, end) {
2764
- var range = te.createTextRange();
2765
- range.collapse(true);
2766
- var endrange = range.duplicate();
2767
- var newlines = 0, txt = te.value;
2768
- for (var pos = txt.indexOf("\n"); pos > -1 && pos < start; pos = txt.indexOf("\n", pos + 1))
2769
- ++newlines;
2770
- range.move("character", start - newlines);
2771
- for (; pos > -1 && pos < end; pos = txt.indexOf("\n", pos + 1))
2772
- ++newlines;
2773
- endrange.move("character", end - newlines);
2774
- range.setEndPoint("EndToEnd", endrange);
2775
- range.select();
2776
- };
2777
- }
2778
 
2779
  CodeMirror.defineMode("null", function() {
2780
  return {token: function(stream) {stream.skipToEnd();}};
2781
  });
2782
  CodeMirror.defineMIME("text/plain", "null");
2783
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2784
  return CodeMirror;
2785
  })();
 
 
1
  // All functions that need access to the editor's state live inside
2
  // the CodeMirror function. Below that, at the bottom of the file,
3
  // some utilities are defined.
4
 
5
  // CodeMirror is the only global var we claim
6
  var CodeMirror = (function() {
7
+ // This is the function that produces an editor instance. Its
8
  // closure is used to store the editor state.
9
  function CodeMirror(place, givenOptions) {
10
  // Determine effective options based on given values and defaults.
13
  if (defaults.hasOwnProperty(opt))
14
  options[opt] = (givenOptions && givenOptions.hasOwnProperty(opt) ? givenOptions : defaults)[opt];
15
 
 
16
  // The element in which the editor lives.
17
+ var wrapper = document.createElement("div");
18
  wrapper.className = "CodeMirror" + (options.lineWrapping ? " CodeMirror-wrap" : "");
19
  // This mess creates the base DOM structure for the editor.
20
  wrapper.innerHTML =
21
+ '<div style="overflow: hidden; position: relative; width: 3px; height: 0px;">' + // Wraps and hides input textarea
22
+ '<textarea style="position: absolute; padding: 0; width: 1px; height: 1em" wrap="off" ' +
23
  'autocorrect="off" autocapitalize="off"></textarea></div>' +
24
+ '<div class="CodeMirror-scroll" tabindex="-1">' +
25
  '<div style="position: relative">' + // Set to the height of the text, causes scrolling
26
  '<div style="position: relative">' + // Moved around its parent to cover visible view
27
  '<div class="CodeMirror-gutter"><div class="CodeMirror-gutter-text"></div></div>' +
28
  // Provides positioning relative to (visible) text origin
29
+ '<div class="CodeMirror-lines"><div style="position: relative; z-index: 0">' +
30
+ '<div style="position: absolute; width: 100%; height: 0; overflow: hidden; visibility: hidden;"></div>' +
31
  '<pre class="CodeMirror-cursor">&#160;</pre>' + // Absolutely positioned blinky cursor
32
+ '<div style="position: relative; z-index: -1"></div><div></div>' + // DIVs containing the selection and the actual code
33
  '</div></div></div></div></div>';
34
  if (place.appendChild) place.appendChild(wrapper); else place(wrapper);
35
  // I've never seen more elegant code in my life.
37
  scroller = wrapper.lastChild, code = scroller.firstChild,
38
  mover = code.firstChild, gutter = mover.firstChild, gutterText = gutter.firstChild,
39
  lineSpace = gutter.nextSibling.firstChild, measure = lineSpace.firstChild,
40
+ cursor = measure.nextSibling, selectionDiv = cursor.nextSibling,
41
+ lineDiv = selectionDiv.nextSibling;
42
+ themeChanged(); keyMapChanged();
43
+ // Needed to hide big blue blinking cursor on Mobile Safari
44
+ if (ios) input.style.width = "0px";
45
  if (!webkit) lineSpace.draggable = true;
46
+ lineSpace.style.outline = "none";
47
+ if (options.tabindex != null) input.tabIndex = options.tabindex;
48
+ if (options.autofocus) focusInput();
49
  if (!options.gutter && !options.lineNumbers) gutter.style.display = "none";
50
+ // Needed to handle Tab key in KHTML
51
+ if (khtml) inputDiv.style.height = "1px", inputDiv.style.position = "absolute";
52
 
53
  // Check for problem with IE innerHTML not working when we have a
54
  // P (or similar) parent node.
55
  try { stringWidth("x"); }
56
  catch (e) {
57
+ if (e.message.match(/runtime/i))
58
  e = new Error("A CodeMirror inside a P-style element does not work in Internet Explorer. (innerHTML bug)");
59
  throw e;
60
  }
72
  // selecting bottom-to-top.
73
  var sel = {from: {line: 0, ch: 0}, to: {line: 0, ch: 0}, inverted: false};
74
  // Selection-related flags. shiftSelecting obviously tracks
75
+ // whether the user is holding shift.
76
+ var shiftSelecting, lastClick, lastDoubleClick, lastScrollPos = 0, draggingText,
77
+ overwrite = false, suppressEdits = false;
 
78
  // Variables used by startOperation/endOperation to track what
79
  // happened during the operation.
80
+ var updateInput, userSelChange, changes, textChanged, selectionChanged, leaveInputAlone,
81
+ gutterDirty, callbacks;
82
  // Current visible range (may be bigger than the view window).
83
+ var displayOffset = 0, showingFrom = 0, showingTo = 0, lastSizeC = 0;
84
+ // bracketHighlighted is used to remember that a bracket has been
 
 
85
  // marked.
86
+ var bracketHighlighted;
87
  // Tracks the maximum line length so that the horizontal scrollbar
88
  // can be kept static when scrolling.
89
  var maxLine = "", maxWidth;
90
+ var tabCache = {};
91
 
92
  // Initialize the content.
93
  operation(function(){setValue(options.value || ""); updateInput = false;})();
94
  var history = new History();
95
 
 
 
 
 
 
 
 
 
96
  // Register our event handlers.
97
  connect(scroller, "mousedown", operation(onMouseDown));
98
  connect(scroller, "dblclick", operation(onDoubleClick));
 
99
  connect(lineSpace, "selectstart", e_preventDefault);
100
  // Gecko browsers fire contextmenu *after* opening the menu, at
101
  // which point we can't mess with it anymore. Context menu is
102
  // handled in onMouseDown for Gecko.
103
  if (!gecko) connect(scroller, "contextmenu", onContextMenu);
104
  connect(scroller, "scroll", function() {
105
+ lastScrollPos = scroller.scrollTop;
106
  updateDisplay([]);
107
  if (options.fixedGutter) gutter.style.left = scroller.scrollLeft + "px";
108
  if (options.onScroll) options.onScroll(instance);
109
  });
110
  connect(window, "resize", function() {updateDisplay(true);});
111
  connect(input, "keyup", operation(onKeyUp));
112
+ connect(input, "input", fastPoll);
113
  connect(input, "keydown", operation(onKeyDown));
114
  connect(input, "keypress", operation(onKeyPress));
115
  connect(input, "focus", onFocus);
116
  connect(input, "blur", onBlur);
117
 
118
+ if (options.dragDrop) {
119
+ connect(lineSpace, "dragstart", onDragStart);
120
+ function drag_(e) {
121
+ if (options.onDragEvent && options.onDragEvent(instance, addStop(e))) return;
122
+ e_stop(e);
123
+ }
124
+ connect(scroller, "dragenter", drag_);
125
+ connect(scroller, "dragover", drag_);
126
+ connect(scroller, "drop", operation(onDrop));
127
+ }
128
  connect(scroller, "paste", function(){focusInput(); fastPoll();});
129
+ connect(input, "paste", fastPoll);
130
+ connect(input, "cut", operation(function(){
131
+ if (!options.readOnly) replaceSelection("");
132
+ }));
133
+
134
+ // Needed to handle Tab key in KHTML
135
+ if (khtml) connect(code, "mouseup", function() {
136
+ if (document.activeElement == input) input.blur();
137
+ focusInput();
138
+ });
139
 
140
  // IE throws unspecified error in certain cases, when
141
  // trying to access activeElement before onload
142
+ var hasFocus; try { hasFocus = (document.activeElement == input); } catch(e) { }
143
+ if (hasFocus || options.autofocus) setTimeout(onFocus, 20);
144
  else onBlur();
145
 
146
  function isLine(l) {return l >= 0 && l < doc.size;}
154
  setValue: operation(setValue),
155
  getSelection: getSelection,
156
  replaceSelection: operation(replaceSelection),
157
+ focus: function(){window.focus(); focusInput(); onFocus(); fastPoll();},
158
  setOption: function(option, value) {
159
  var oldVal = options[option];
160
  options[option] = value;
161
  if (option == "mode" || option == "indentUnit") loadMode();
162
+ else if (option == "readOnly" && value == "nocursor") {onBlur(); input.blur();}
163
+ else if (option == "readOnly" && !value) {resetInput(true);}
164
+ else if (option == "theme") themeChanged();
165
  else if (option == "lineWrapping" && oldVal != value) operation(wrappingChanged)();
166
+ else if (option == "tabSize") updateDisplay(true);
167
+ else if (option == "keyMap") keyMapChanged();
168
+ if (option == "lineNumbers" || option == "gutter" || option == "firstLineNumber" || option == "theme") {
169
+ gutterChanged();
170
+ updateDisplay(true);
171
+ }
172
  },
173
  getOption: function(option) {return options[option];},
174
  undo: operation(undo),
175
  redo: operation(redo),
176
  indentLine: operation(function(n, dir) {
177
+ if (typeof dir != "string") {
178
+ if (dir == null) dir = options.smartIndent ? "smart" : "prev";
179
+ else dir = dir ? "add" : "subtract";
180
+ }
181
+ if (isLine(n)) indentLine(n, dir);
182
  }),
183
+ indentSelection: operation(indentSelected),
184
  historySize: function() {return {undo: history.done.length, redo: history.undone.length};},
185
  clearHistory: function() {history = new History();},
186
  matchBrackets: operation(function(){matchBrackets(true);}),
192
  line = clipLine(line == null ? doc.size - 1: line);
193
  return getStateBefore(line + 1);
194
  },
195
+ cursorCoords: function(start, mode) {
196
  if (start == null) start = sel.inverted;
197
+ return this.charCoords(start ? sel.from : sel.to, mode);
198
+ },
199
+ charCoords: function(pos, mode) {
200
+ pos = clipPos(pos);
201
+ if (mode == "local") return localCoords(pos, false);
202
+ if (mode == "div") return localCoords(pos, true);
203
+ return pageCoords(pos);
204
  },
 
205
  coordsChar: function(coords) {
206
  var off = eltOffset(lineSpace);
207
  return coordsChar(coords.x - off.left, coords.y - off.top);
208
  },
 
209
  markText: operation(markText),
210
  setBookmark: setBookmark,
211
+ findMarksAt: findMarksAt,
212
  setMarker: operation(addGutterMarker),
213
  clearMarker: operation(removeGutterMarker),
214
  setLineClass: operation(setLineClass),
215
  hideLine: operation(function(h) {return setLineHidden(h, true);}),
216
  showLine: operation(function(h) {return setLineHidden(h, false);}),
217
+ onDeleteLine: function(line, f) {
218
+ if (typeof line == "number") {
219
+ if (!isLine(line)) return null;
220
+ line = getLine(line);
221
+ }
222
+ (line.handlers || (line.handlers = [])).push(f);
223
+ return line;
224
+ },
225
  lineInfo: lineInfo,
226
  addWidget: function(pos, node, scroll, vert, horiz) {
227
  pos = localCoords(clipPos(pos));
252
  },
253
 
254
  lineCount: function() {return doc.size;},
255
+ clipPos: clipPos,
256
  getCursor: function(start) {
257
  if (start == null) start = sel.inverted;
258
  return copyPos(start ? sel.from : sel.to);
259
  },
260
  somethingSelected: function() {return !posEq(sel.from, sel.to);},
261
+ setCursor: operation(function(line, ch, user) {
262
+ if (ch == null && typeof line.line == "number") setCursor(line.line, line.ch, user);
263
+ else setCursor(line, ch, user);
264
+ }),
265
+ setSelection: operation(function(from, to, user) {
266
+ (user ? setSelectionUser : setSelection)(clipPos(from), clipPos(to || from));
267
  }),
 
268
  getLine: function(line) {if (isLine(line)) return getLine(line).text;},
269
+ getLineHandle: function(line) {if (isLine(line)) return getLine(line);},
270
  setLine: operation(function(line, text) {
271
  if (isLine(line)) replaceRange(text, {line: line, ch: 0}, {line: line, ch: getLine(line).text.length});
272
  }),
276
  replaceRange: operation(replaceRange),
277
  getRange: function(from, to) {return getRange(clipPos(from), clipPos(to));},
278
 
279
+ triggerOnKeyDown: operation(onKeyDown),
280
+ execCommand: function(cmd) {return commands[cmd](instance);},
281
+ // Stuff used by commands, probably not much use to outside code.
282
+ moveH: operation(moveH),
283
+ deleteH: operation(deleteH),
284
+ moveV: operation(moveV),
285
+ toggleOverwrite: function() {
286
+ if(overwrite){
287
+ overwrite = false;
288
+ cursor.className = cursor.className.replace(" CodeMirror-overwrite", "");
289
+ } else {
290
+ overwrite = true;
291
+ cursor.className += " CodeMirror-overwrite";
292
+ }
293
+ },
294
+
295
+ posFromIndex: function(off) {
296
  var lineNo = 0, ch;
297
  doc.iter(0, doc.size, function(line) {
298
  var sz = line.text.length + 1;
302
  });
303
  return clipPos({line: lineNo, ch: ch});
304
  },
305
+ indexFromPos: function (coords) {
306
+ if (coords.line < 0 || coords.ch < 0) return 0;
307
+ var index = coords.ch;
308
+ doc.iter(0, coords.line, function (line) {
309
+ index += line.text.length + 1;
310
+ });
311
+ return index;
312
+ },
313
+ scrollTo: function(x, y) {
314
+ if (x != null) scroller.scrollLeft = x;
315
+ if (y != null) scroller.scrollTop = y;
316
+ updateDisplay([]);
317
+ },
318
 
319
  operation: function(f){return operation(f)();},
320
+ compoundChange: function(f){return compoundChange(f);},
321
+ refresh: function(){
322
+ updateDisplay(true);
323
+ if (scroller.scrollHeight > lastScrollPos)
324
+ scroller.scrollTop = lastScrollPos;
325
+ },
326
  getInputField: function(){return input;},
327
  getWrapperElement: function(){return wrapper;},
328
  getScrollerElement: function(){return scroller;},
342
  splitLines(code), top, top);
343
  updateInput = true;
344
  }
345
+ function getValue() {
346
  var text = [];
347
  doc.iter(0, doc.size, function(line) { text.push(line.text); });
348
  return text.join("\n");
349
  }
350
 
351
  function onMouseDown(e) {
352
+ setShift(e_prop(e, "shiftKey"));
353
  // Check whether this is a click in a widget
354
  for (var n = e_target(e); n != wrapper; n = n.parentNode)
355
  if (n.parentNode == code && n != mover) return;
370
  return;
371
  case 2:
372
  if (start) setCursor(start.line, start.ch, true);
373
+ setTimeout(focusInput, 20);
374
  return;
375
  }
376
  // For button 1, if it was clicked inside the editor
392
  } else { lastClick = {time: now, pos: start}; }
393
 
394
  var last = start, going;
395
+ if (options.dragDrop && dragAndDrop && !options.readOnly && !posEq(sel.from, sel.to) &&
396
  !posLess(start, sel.from) && !posLess(sel.to, start)) {
397
  // Let the drag handler handle this.
398
  if (webkit) lineSpace.draggable = true;
399
+ function dragEnd(e2) {
400
  if (webkit) lineSpace.draggable = false;
401
  draggingText = false;
402
+ up(); drop();
403
  if (Math.abs(e.clientX - e2.clientX) + Math.abs(e.clientY - e2.clientY) < 10) {
404
  e_preventDefault(e2);
405
  setCursor(start.line, start.ch, true);
406
  focusInput();
407
  }
408
+ }
409
+ var up = connect(document, "mouseup", operation(dragEnd), true);
410
+ var drop = connect(scroller, "drop", operation(dragEnd), true);
411
  draggingText = true;
412
+ // IE's approach to draggable
413
+ if (lineSpace.dragDrop) lineSpace.dragDrop();
414
  return;
415
  }
416
  e_preventDefault(e);
429
  }
430
  }
431
 
432
+ function done(e) {
 
 
 
 
 
433
  clearTimeout(going);
434
  var cur = posFromMouse(e);
435
  if (cur) setSelectionUser(start, cur);
437
  focusInput();
438
  updateInput = true;
439
  move(); up();
440
+ }
441
+ var move = connect(document, "mousemove", operation(function(e) {
442
+ clearTimeout(going);
443
+ e_preventDefault(e);
444
+ if (!ie && !e_button(e)) done(e);
445
+ else extend(e);
446
  }), true);
447
+ var up = connect(document, "mouseup", operation(done), true);
448
  }
449
  function onDoubleClick(e) {
450
  for (var n = e_target(e); n != wrapper; n = n.parentNode)
456
  selectWordAt(start);
457
  }
458
  function onDrop(e) {
459
+ if (options.onDragEvent && options.onDragEvent(instance, addStop(e))) return;
460
  e.preventDefault();
461
  var pos = posFromMouse(e, true), files = e.dataTransfer.files;
462
  if (!pos || options.readOnly) return;
466
  reader.onload = function() {
467
  text[i] = reader.result;
468
  if (++read == n) {
469
+ pos = clipPos(pos);
470
+ operation(function() {
471
  var end = replaceRange(text.join(""), pos, pos);
472
  setSelectionUser(pos, end);
473
  })();
474
+ }
475
  };
476
  reader.readAsText(file);
477
  }
482
  try {
483
  var text = e.dataTransfer.getData("Text");
484
  if (text) {
485
+ compoundChange(function() {
486
+ var curFrom = sel.from, curTo = sel.to;
487
+ setSelectionUser(pos, pos);
488
+ if (draggingText) replaceRange("", curFrom, curTo);
489
+ replaceSelection(text);
490
+ focusInput();
491
+ });
492
+ }
493
  }
494
  catch(e){}
495
  }
496
  }
497
  function onDragStart(e) {
498
  var txt = getSelection();
 
 
 
499
  e.dataTransfer.setData("Text", txt);
500
+
501
+ // Use dummy image instead of default browsers image.
502
+ if (gecko || chrome) {
503
+ var img = document.createElement('img');
504
+ img.scr = 'data:image/gif;base64,R0lGODdhAgACAIAAAAAAAP///ywAAAAAAgACAAACAoRRADs='; //1x1 image
505
+ e.dataTransfer.setDragImage(img, 0, 0);
506
+ }
507
+ }
508
+
509
+ function doHandleBinding(bound, dropShift) {
510
+ if (typeof bound == "string") {
511
+ bound = commands[bound];
512
+ if (!bound) return false;
513
+ }
514
+ var prevShift = shiftSelecting;
515
+ try {
516
+ if (options.readOnly) suppressEdits = true;
517
+ if (dropShift) shiftSelecting = null;
518
+ bound(instance);
519
+ } catch(e) {
520
+ if (e != Pass) throw e;
521
+ return false;
522
+ } finally {
523
+ shiftSelecting = prevShift;
524
+ suppressEdits = false;
525
+ }
526
+ return true;
527
  }
528
+ function handleKeyBinding(e) {
529
+ // Handle auto keymap transitions
530
+ var startMap = getKeyMap(options.keyMap), next = startMap.auto;
531
+ clearTimeout(maybeTransition);
532
+ if (next && !isModifierKey(e)) maybeTransition = setTimeout(function() {
533
+ if (getKeyMap(options.keyMap) == startMap) {
534
+ options.keyMap = (next.call ? next.call(null, instance) : next);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
535
  }
536
+ }, 50);
537
+
538
+ var name = keyNames[e_prop(e, "keyCode")], handled = false;
539
+ if (name == null || e.altGraphKey) return false;
540
+ if (e_prop(e, "altKey")) name = "Alt-" + name;
541
+ if (e_prop(e, "ctrlKey")) name = "Ctrl-" + name;
542
+ if (e_prop(e, "metaKey")) name = "Cmd-" + name;
543
+
544
+ var stopped = false;
545
+ function stop() { stopped = true; }
546
+
547
+ if (e_prop(e, "shiftKey")) {
548
+ handled = lookupKey("Shift-" + name, options.extraKeys, options.keyMap,
549
+ function(b) {return doHandleBinding(b, true);}, stop)
550
+ || lookupKey(name, options.extraKeys, options.keyMap, function(b) {
551
+ if (typeof b == "string" && /^go[A-Z]/.test(b)) return doHandleBinding(b);
552
+ }, stop);
553
+ } else {
554
+ handled = lookupKey(name, options.extraKeys, options.keyMap, doHandleBinding, stop);
555
  }
556
+ if (stopped) handled = false;
557
+ if (handled) {
558
+ e_preventDefault(e);
559
+ restartBlink();
560
+ if (ie) { e.oldKeyCode = e.keyCode; e.keyCode = 0; }
561
+ }
562
+ return handled;
563
  }
564
+ function handleCharBinding(e, ch) {
565
+ var handled = lookupKey("'" + ch + "'", options.extraKeys,
566
+ options.keyMap, function(b) { return doHandleBinding(b, true); });
567
+ if (handled) {
568
+ e_preventDefault(e);
569
+ restartBlink();
570
  }
571
+ return handled;
572
+ }
573
 
574
+ var lastStoppedKey = null, maybeTransition;
575
+ function onKeyDown(e) {
576
+ if (!focused) onFocus();
577
+ if (ie && e.keyCode == 27) { e.returnValue = false; }
578
+ if (pollingFast) { if (readInput()) pollingFast = false; }
579
+ if (options.onKeyEvent && options.onKeyEvent(instance, addStop(e))) return;
580
+ var code = e_prop(e, "keyCode");
581
+ // IE does strange things with escape.
582
+ setShift(code == 16 || e_prop(e, "shiftKey"));
583
+ // First give onKeyEvent option a chance to handle this.
584
+ var handled = handleKeyBinding(e);
585
+ if (window.opera) {
586
+ lastStoppedKey = handled ? code : null;
587
+ // Opera has no cut event... we try to at least catch the key combo
588
+ if (!handled && code == 88 && e_prop(e, mac ? "metaKey" : "ctrlKey"))
589
+ replaceSelection("");
590
+ }
591
  }
592
  function onKeyPress(e) {
593
+ if (pollingFast) readInput();
594
  if (options.onKeyEvent && options.onKeyEvent(instance, addStop(e))) return;
595
+ var keyCode = e_prop(e, "keyCode"), charCode = e_prop(e, "charCode");
596
+ if (window.opera && keyCode == lastStoppedKey) {lastStoppedKey = null; e_preventDefault(e); return;}
597
+ if (((window.opera && !e.which) || khtml) && handleKeyBinding(e)) return;
598
+ var ch = String.fromCharCode(charCode == null ? keyCode : charCode);
599
+ if (options.electricChars && mode.electricChars && options.smartIndent && !options.readOnly) {
600
  if (mode.electricChars.indexOf(ch) > -1)
601
+ setTimeout(operation(function() {indentLine(sel.to.line, "smart");}), 75);
602
  }
603
+ if (handleCharBinding(e, ch)) return;
604
+ fastPoll();
605
+ }
606
+ function onKeyUp(e) {
607
+ if (options.onKeyEvent && options.onKeyEvent(instance, addStop(e))) return;
608
+ if (e_prop(e, "keyCode") == 16) shiftSelecting = null;
609
  }
610
 
611
  function onFocus() {
615
  focused = true;
616
  if (wrapper.className.search(/\bCodeMirror-focused\b/) == -1)
617
  wrapper.className += " CodeMirror-focused";
618
+ if (!leaveInputAlone) resetInput(true);
619
  }
620
  slowPoll();
621
  restartBlink();
624
  if (focused) {
625
  if (options.onBlur) options.onBlur(instance);
626
  focused = false;
627
+ if (bracketHighlighted)
628
+ operation(function(){
629
+ if (bracketHighlighted) { bracketHighlighted(); bracketHighlighted = null; }
630
+ })();
631
  wrapper.className = wrapper.className.replace(" CodeMirror-focused", "");
632
  }
633
  clearInterval(blinker);
637
  // Replace the range from from to to by the strings in newText.
638
  // Afterwards, set the selection to selFrom, selTo.
639
  function updateLines(from, to, newText, selFrom, selTo) {
640
+ if (suppressEdits) return;
641
  if (history) {
642
  var old = [];
643
  doc.iter(from.line, to.line + 1, function(line) { old.push(line.text); });
647
  updateLinesNoUndo(from, to, newText, selFrom, selTo);
648
  }
649
  function unredoHelper(from, to) {
650
+ if (!from.length) return;
651
+ var set = from.pop(), out = [];
652
+ for (var i = set.length - 1; i >= 0; i -= 1) {
653
+ var change = set[i];
654
  var replaced = [], end = change.start + change.added;
655
  doc.iter(change.start, end, function(line) { replaced.push(line.text); });
656
+ out.push({start: change.start, added: change.old.length, old: replaced});
657
  var pos = clipPos({line: change.start + change.old.length - 1,
658
  ch: editEnd(replaced[replaced.length-1], change.old[change.old.length-1])});
659
  updateLinesNoUndo({line: change.start, ch: 0}, {line: end - 1, ch: getLine(end-1).text.length}, change.old, pos, pos);
 
660
  }
661
+ updateInput = true;
662
+ to.push(out);
663
  }
664
  function undo() {unredoHelper(history.done, history.undone);}
665
  function redo() {unredoHelper(history.undone, history.done);}
666
 
667
  function updateLinesNoUndo(from, to, newText, selFrom, selTo) {
668
+ if (suppressEdits) return;
669
  var recomputeMaxLength = false, maxLineLength = maxLine.length;
670
  if (!options.lineWrapping)
671
+ doc.iter(from.line, to.line + 1, function(line) {
672
  if (line.text.length == maxLineLength) {recomputeMaxLength = true; return true;}
673
  });
674
+ if (from.line != to.line || newText.length > 1) gutterDirty = true;
675
 
676
  var nlines = to.line - from.line, firstLine = getLine(from.line), lastLine = getLine(to.line);
677
  // First adjust the line structure, taking some care to leave highlighting intact.
678
+ if (from.ch == 0 && to.ch == 0 && newText[newText.length - 1] == "") {
679
+ // This is a whole-line replace. Treated specially to make
680
+ // sure line objects move the way they are supposed to.
681
+ var added = [], prevLine = null;
682
+ if (from.line) {
683
+ prevLine = getLine(from.line - 1);
684
+ prevLine.fixMarkEnds(lastLine);
685
+ } else lastLine.fixMarkStarts();
686
+ for (var i = 0, e = newText.length - 1; i < e; ++i)
687
+ added.push(Line.inheritMarks(newText[i], prevLine));
688
+ if (nlines) doc.remove(from.line, nlines, callbacks);
689
+ if (added.length) doc.insert(from.line, added);
690
+ } else if (firstLine == lastLine) {
691
  if (newText.length == 1)
692
  firstLine.replace(from.ch, to.ch, newText[0]);
693
  else {
700
  added.push(lastLine);
701
  doc.insert(from.line + 1, added);
702
  }
703
+ } else if (newText.length == 1) {
 
704
  firstLine.replace(from.ch, null, newText[0]);
705
  lastLine.replace(null, to.ch, "");
706
  firstLine.append(lastLine);
707
+ doc.remove(from.line + 1, nlines, callbacks);
708
+ } else {
 
709
  var added = [];
710
  firstLine.replace(from.ch, null, newText[0]);
711
  lastLine.replace(null, to.ch, newText[newText.length-1]);
712
  firstLine.fixMarkEnds(lastLine);
713
  for (var i = 1, e = newText.length - 1; i < e; ++i)
714
  added.push(Line.inheritMarks(newText[i], firstLine));
715
+ if (nlines > 1) doc.remove(from.line + 1, nlines - 1, callbacks);
716
  doc.insert(from.line + 1, added);
717
  }
718
  if (options.lineWrapping) {
719
+ var perLine = Math.max(5, scroller.clientWidth / charWidth() - 3);
720
  doc.iter(from.line, from.line + newText.length, function(line) {
721
  if (line.hidden) return;
722
  var guess = Math.ceil(line.text.length / perLine) || 1;
723
  if (guess != line.height) updateLineHeight(line, guess);
724
  });
725
  } else {
726
+ doc.iter(from.line, from.line + newText.length, function(line) {
727
  var l = line.text;
728
  if (l.length > maxLineLength) {
729
  maxLine = l; maxLineLength = l.length; maxWidth = null;
756
  startWorker(100);
757
  // Remember that these lines changed, for updating the display
758
  changes.push({from: from.line, to: to.line + 1, diff: lendiff});
759
+ var changeObj = {from: from, to: to, text: newText};
760
+ if (textChanged) {
761
+ for (var cur = textChanged; cur.next; cur = cur.next) {}
762
+ cur.next = changeObj;
763
+ } else textChanged = changeObj;
764
 
765
  // Update the selection
766
  function updateLine(n) {return n <= Math.min(to.line, to.line + lendiff) ? n : n + lendiff;}
767
  setSelection(selFrom, selTo, updateLine(sel.from.line), updateLine(sel.to.line));
768
 
769
  // Make sure the scroll-size div has the correct height.
770
+ if (scroller.clientHeight)
771
+ code.style.height = (doc.height * textHeight() + 2 * paddingTop()) + "px";
772
  }
773
 
774
  function replaceRange(code, from, to) {
819
  var pollingFast = false; // Ensures slowPoll doesn't cancel fastPoll
820
  function slowPoll() {
821
  if (pollingFast) return;
822
+ poll.set(options.pollInterval, function() {
823
  startOperation();
824
  readInput();
825
  if (focused) slowPoll();
826
  endOperation();
827
  });
828
  }
829
+ function fastPoll() {
830
  var missed = false;
831
  pollingFast = true;
832
  function p() {
833
  startOperation();
834
  var changed = readInput();
835
+ if (!changed && !missed) {missed = true; poll.set(60, p);}
 
 
 
 
836
  else {pollingFast = false; slowPoll();}
837
  endOperation();
838
  }
839
  poll.set(20, p);
840
  }
841
 
842
+ // Previnput is a hack to work with IME. If we reset the textarea
843
+ // on every change, that breaks IME. So we look for changes
844
+ // compared to the previous content instead. (Modern browsers have
845
+ // events that indicate IME taking place, but these are not widely
846
+ // supported or compatible enough yet to rely on.)
847
+ var prevInput = "";
848
  function readInput() {
849
+ if (leaveInputAlone || !focused || hasSelection(input) || options.readOnly) return false;
850
+ var text = input.value;
851
+ if (text == prevInput) return false;
852
+ shiftSelecting = null;
853
+ var same = 0, l = Math.min(prevInput.length, text.length);
854
+ while (same < l && prevInput[same] == text[same]) ++same;
855
+ if (same < prevInput.length)
856
+ sel.from = {line: sel.from.line, ch: sel.from.ch - (prevInput.length - same)};
857
+ else if (overwrite && posEq(sel.from, sel.to))
858
+ sel.to = {line: sel.to.line, ch: Math.min(getLine(sel.to.line).text.length, sel.to.ch + (text.length - same))};
859
+ replaceSelection(text.slice(same), "end");
860
+ prevInput = text;
861
+ return true;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
862
  }
863
+ function resetInput(user) {
864
+ if (!posEq(sel.from, sel.to)) {
865
+ prevInput = "";
866
+ input.value = getSelection();
867
+ selectInput(input);
868
+ } else if (user) prevInput = input.value = "";
 
 
 
 
 
 
 
 
 
 
 
869
  }
870
+
871
  function focusInput() {
872
  if (options.readOnly != "nocursor") input.focus();
873
  }
875
  function scrollEditorIntoView() {
876
  if (!cursor.getBoundingClientRect) return;
877
  var rect = cursor.getBoundingClientRect();
878
+ // IE returns bogus coordinates when the instance sits inside of an iframe and the cursor is hidden
879
+ if (ie && rect.top == rect.bottom) return;
880
  var winH = window.innerHeight || Math.max(document.body.offsetHeight, document.documentElement.offsetHeight);
881
  if (rect.top < 0 || rect.bottom > winH) cursor.scrollIntoView();
882
  }
886
  return scrollIntoView(x, cursor.y, x, cursor.yBot);
887
  }
888
  function scrollIntoView(x1, y1, x2, y2) {
889
+ var pl = paddingLeft(), pt = paddingTop();
890
  y1 += pt; y2 += pt; x1 += pl; x2 += pl;
891
  var screen = scroller.clientHeight, screentop = scroller.scrollTop, scrolled = false, result = true;
892
+ if (y1 < screentop) {scroller.scrollTop = Math.max(0, y1); scrolled = true;}
893
+ else if (y2 > screentop + screen) {scroller.scrollTop = y2 - screen; scrolled = true;}
894
 
895
  var screenw = scroller.clientWidth, screenleft = scroller.scrollLeft;
896
  var gutterw = options.fixedGutter ? gutter.clientWidth : 0;
897
+ var atLeft = x1 < gutterw + pl + 10;
898
+ if (x1 < screenleft + gutterw || atLeft) {
899
+ if (atLeft) x1 = 0;
900
  scroller.scrollLeft = Math.max(0, x1 - 10 - gutterw);
901
  scrolled = true;
902
  }
903
+ else if (x2 > screenw + screenleft - 3) {
904
  scroller.scrollLeft = x2 + 10 - screenw;
905
  scrolled = true;
906
  if (x2 > code.clientWidth) result = false;
911
 
912
  function visibleLines() {
913
  var lh = textHeight(), top = scroller.scrollTop - paddingTop();
914
+ var fromHeight = Math.max(0, Math.floor(top / lh));
915
+ var toHeight = Math.ceil((top + scroller.clientHeight) / lh);
916
+ return {from: lineAtHeight(doc, fromHeight),
917
+ to: lineAtHeight(doc, toHeight)};
918
  }
919
  // Uses a set of changes plus the current scroll position to
920
  // determine which DOM updates have to be made, and makes the
921
  // updates.
922
+ function updateDisplay(changes, suppressCallback) {
923
  if (!scroller.clientWidth) {
924
  showingFrom = showingTo = displayOffset = 0;
925
  return;
927
  // Compute the new visible window
928
  var visible = visibleLines();
929
  // Bail out if the visible area is already rendered and nothing changed.
930
+ if (changes !== true && changes.length == 0 && visible.from > showingFrom && visible.to < showingTo) return;
931
  var from = Math.max(visible.from - 100, 0), to = Math.min(doc.size, visible.to + 100);
932
  if (showingFrom < from && from - showingFrom < 20) from = showingFrom;
933
  if (showingTo > to && showingTo - to < 20) to = Math.min(doc.size, showingTo);
945
  if (range.from >= range.to) intact.splice(i--, 1);
946
  else intactLines += range.to - range.from;
947
  }
948
+ if (intactLines == to - from && from == showingFrom && to == showingTo) return;
949
  intact.sort(function(a, b) {return a.domStart - b.domStart;});
950
 
951
  var th = textHeight(), gutterDisplay = gutter.style.display;
952
+ lineDiv.style.display = "none";
953
  patchDisplay(from, to, intact);
954
+ lineDiv.style.display = gutter.style.display = "";
955
 
956
  // Position the mover div to align with the lines it's supposed
957
  // to be showing (which will cover the visible display)
958
+ var different = from != showingFrom || to != showingTo || lastSizeC != scroller.clientHeight + th;
959
+ // This is just a bogus formula that detects when the editor is
960
+ // resized or the font size changes.
961
+ if (different) lastSizeC = scroller.clientHeight + th;
962
  showingFrom = from; showingTo = to;
963
  displayOffset = heightAtLine(doc, from);
964
  mover.style.top = (displayOffset * th) + "px";
965
+ if (scroller.clientHeight)
966
+ code.style.height = (doc.height * th + 2 * paddingTop()) + "px";
967
 
968
  // Since this is all rather error prone, it is honoured with the
969
  // only assertion in the whole file.
971
  throw new Error("BAD PATCH! " + JSON.stringify(intact) + " size=" + (showingTo - showingFrom) +
972
  " nodes=" + lineDiv.childNodes.length);
973
 
974
+ function checkHeights() {
975
  maxWidth = scroller.clientWidth;
976
+ var curNode = lineDiv.firstChild, heightChanged = false;
977
  doc.iter(showingFrom, showingTo, function(line) {
978
  if (!line.hidden) {
979
  var height = Math.round(curNode.offsetHeight / th) || 1;
980
+ if (line.height != height) {
981
+ updateLineHeight(line, height);
982
+ gutterDirty = heightChanged = true;
983
+ }
984
  }
985
  curNode = curNode.nextSibling;
986
  });
987
+ if (heightChanged)
988
+ code.style.height = (doc.height * th + 2 * paddingTop()) + "px";
989
+ return heightChanged;
990
+ }
991
+
992
+ if (options.lineWrapping) {
993
+ checkHeights();
994
  } else {
995
  if (maxWidth == null) maxWidth = stringWidth(maxLine);
996
  if (maxWidth > scroller.clientWidth) {
1002
  lineSpace.style.width = code.style.width = "";
1003
  }
1004
  }
1005
+
1006
  gutter.style.display = gutterDisplay;
1007
+ if (different || gutterDirty) {
1008
+ // If the gutter grew in size, re-check heights. If those changed, re-draw gutter.
1009
+ updateGutter() && options.lineWrapping && checkHeights() && updateGutter();
1010
+ }
1011
+ updateSelection();
1012
+ if (!suppressCallback && options.onUpdate) options.onUpdate(instance);
1013
+ return true;
1014
  }
1015
 
1016
  function computeIntact(intact, changes) {
1055
  }
1056
  // This pass fills in the lines that actually changed.
1057
  var nextIntact = intact.shift(), curNode = lineDiv.firstChild, j = from;
1058
+ var scratch = document.createElement("div");
 
1059
  doc.iter(from, to, function(line) {
 
 
 
 
 
 
 
 
1060
  if (nextIntact && nextIntact.to == j) nextIntact = intact.shift();
1061
  if (!nextIntact || nextIntact.from > j) {
1062
+ if (line.hidden) var html = scratch.innerHTML = "<pre></pre>";
1063
+ else {
1064
+ var html = '<pre' + (line.className ? ' class="' + line.className + '"' : '') + '>'
1065
+ + line.getHTML(makeTab) + '</pre>';
1066
+ // Kludge to make sure the styled element lies behind the selection (by z-index)
1067
+ if (line.bgClassName)
1068
+ html = '<div style="position: relative"><pre class="' + line.bgClassName +
1069
+ '" style="position: absolute; left: 0; right: 0; top: 0; bottom: 0; z-index: -2">&#160;</pre>' + html + "</div>";
1070
+ }
1071
+ scratch.innerHTML = html;
1072
  lineDiv.insertBefore(scratch.firstChild, curNode);
1073
  } else {
1074
  curNode = curNode.nextSibling;
1081
  if (!options.gutter && !options.lineNumbers) return;
1082
  var hText = mover.offsetHeight, hEditor = scroller.clientHeight;
1083
  gutter.style.height = (hText - hEditor < 2 ? hEditor : hText) + "px";
1084
+ var html = [], i = showingFrom, normalNode;
1085
  doc.iter(showingFrom, Math.max(showingTo, showingFrom + 1), function(line) {
1086
  if (line.hidden) {
1087
  html.push("<pre></pre>");
1093
  else if (text == null)
1094
  text = "\u00a0";
1095
  html.push((marker && marker.style ? '<pre class="' + marker.style + '">' : "<pre>"), text);
1096
+ for (var j = 1; j < line.height; ++j) html.push("<br/>&#160;");
1097
  html.push("</pre>");
1098
+ if (!marker) normalNode = i;
1099
  }
1100
  ++i;
1101
  });
1102
  gutter.style.display = "none";
1103
  gutterText.innerHTML = html.join("");
1104
+ // Make sure scrolling doesn't cause number gutter size to pop
1105
+ if (normalNode != null) {
1106
+ var node = gutterText.childNodes[normalNode - showingFrom];
1107
+ var minwidth = String(doc.size).length, val = eltText(node), pad = "";
1108
+ while (val.length + pad.length < minwidth) pad += "\u00a0";
1109
+ if (pad) node.insertBefore(document.createTextNode(pad), node.firstChild);
1110
+ }
1111
  gutter.style.display = "";
1112
+ var resized = Math.abs((parseInt(lineSpace.style.marginLeft) || 0) - gutter.offsetWidth) > 2;
1113
  lineSpace.style.marginLeft = gutter.offsetWidth + "px";
1114
  gutterDirty = false;
1115
+ return resized;
1116
+ }
1117
+ function updateSelection() {
1118
+ var collapsed = posEq(sel.from, sel.to);
1119
+ var fromPos = localCoords(sel.from, true);
1120
+ var toPos = collapsed ? fromPos : localCoords(sel.to, true);
1121
+ var headPos = sel.inverted ? fromPos : toPos, th = textHeight();
1122
+ var wrapOff = eltOffset(wrapper), lineOff = eltOffset(lineDiv);
1123
+ inputDiv.style.top = Math.max(0, Math.min(scroller.offsetHeight, headPos.y + lineOff.top - wrapOff.top)) + "px";
1124
+ inputDiv.style.left = Math.max(0, Math.min(scroller.offsetWidth, headPos.x + lineOff.left - wrapOff.left)) + "px";
1125
+ if (collapsed) {
1126
+ cursor.style.top = headPos.y + "px";
1127
+ cursor.style.left = (options.lineWrapping ? Math.min(headPos.x, lineSpace.offsetWidth) : headPos.x) + "px";
1128
  cursor.style.display = "";
1129
+ selectionDiv.style.display = "none";
1130
+ } else {
1131
+ var sameLine = fromPos.y == toPos.y, html = "";
1132
+ var clientWidth = lineSpace.clientWidth || lineSpace.offsetWidth;
1133
+ var clientHeight = lineSpace.clientHeight || lineSpace.offsetHeight;
1134
+ function add(left, top, right, height) {
1135
+ var rstyle = quirksMode ? "width: " + (!right ? clientWidth : clientWidth - right - left) + "px"
1136
+ : "right: " + right + "px";
1137
+ html += '<div class="CodeMirror-selected" style="position: absolute; left: ' + left +
1138
+ 'px; top: ' + top + 'px; ' + rstyle + '; height: ' + height + 'px"></div>';
1139
+ }
1140
+ if (sel.from.ch && fromPos.y >= 0) {
1141
+ var right = sameLine ? clientWidth - toPos.x : 0;
1142
+ add(fromPos.x, fromPos.y, right, th);
1143
+ }
1144
+ var middleStart = Math.max(0, fromPos.y + (sel.from.ch ? th : 0));
1145
+ var middleHeight = Math.min(toPos.y, clientHeight) - middleStart;
1146
+ if (middleHeight > 0.2 * th)
1147
+ add(0, middleStart, 0, middleHeight);
1148
+ if ((!sameLine || !sel.from.ch) && toPos.y < clientHeight - .5 * th)
1149
+ add(0, toPos.y, clientWidth - toPos.x, th);
1150
+ selectionDiv.innerHTML = html;
1151
+ cursor.style.display = "none";
1152
+ selectionDiv.style.display = "";
1153
  }
 
1154
  }
1155
 
1156
+ function setShift(val) {
1157
+ if (val) shiftSelecting = shiftSelecting || (sel.inverted ? sel.to : sel.from);
1158
+ else shiftSelecting = null;
1159
+ }
1160
  function setSelectionUser(from, to) {
1161
  var sh = shiftSelecting && clipPos(shiftSelecting);
1162
  if (sh) {
1164
  else if (posLess(to, sh)) to = sh;
1165
  }
1166
  setSelection(from, to);
1167
+ userSelChange = true;
1168
  }
1169
  // Update the selection. Last two args are only used by
1170
  // updateLines, since they have to be expressed in the line
1171
  // numbers before the update.
1172
  function setSelection(from, to, oldFrom, oldTo) {
1173
+ goalColumn = null;
1174
  if (oldFrom == null) {oldFrom = sel.from.line; oldTo = sel.to.line;}
1175
  if (posEq(sel.from, from) && posEq(sel.to, to)) return;
1176
  if (posLess(to, from)) {var tmp = to; to = from; from = tmp;}
1177
 
1178
  // Skip over hidden lines.
1179
+ if (from.line != oldFrom) {
1180
+ var from1 = skipHidden(from, oldFrom, sel.from.ch);
1181
+ // If there is no non-hidden line left, force visibility on current line
1182
+ if (!from1) setLineHidden(from.line, false);
1183
+ else from = from1;
1184
+ }
1185
  if (to.line != oldTo) to = skipHidden(to, oldTo, sel.to.ch);
1186
 
1187
  if (posEq(from, to)) sel.inverted = false;
1188
  else if (posEq(from, sel.to)) sel.inverted = false;
1189
  else if (posEq(to, sel.from)) sel.inverted = true;
1190
 
1191
+ if (options.autoClearEmptyLines && posEq(sel.from, sel.to)) {
1192
+ var head = sel.inverted ? from : to;
1193
+ if (head.line != sel.from.line && sel.from.line < doc.size) {
1194
+ var oldLine = getLine(sel.from.line);
1195
+ if (/^\s+$/.test(oldLine.text))
1196
+ setTimeout(operation(function() {
1197
+ if (oldLine.parent && /^\s+$/.test(oldLine.text)) {
1198
+ var no = lineNo(oldLine);
1199
+ replaceRange("", {line: no, ch: 0}, {line: no, ch: oldLine.text.length});
1200
+ }
1201
+ }, 10));
 
 
 
 
 
 
 
 
 
 
 
1202
  }
1203
  }
1204
+
1205
  sel.from = from; sel.to = to;
1206
  selectionChanged = true;
1207
  }
1212
  var line = getLine(lNo);
1213
  if (!line.hidden) {
1214
  var ch = pos.ch;
1215
+ if (toEnd || ch > oldCh || ch > line.text.length) ch = line.text.length;
1216
  return {line: lNo, ch: ch};
1217
  }
1218
  lNo += dir;
1219
  }
1220
  }
1221
  var line = getLine(pos.line);
1222
+ var toEnd = pos.ch == line.text.length && pos.ch != oldCh;
1223
  if (!line.hidden) return pos;
1224
  if (pos.line >= oldLine) return getNonHidden(1) || getNonHidden(-1);
1225
  else return getNonHidden(-1) || getNonHidden(1);
1239
  else return pos;
1240
  }
1241
 
1242
+ function findPosH(dir, unit) {
1243
+ var end = sel.inverted ? sel.from : sel.to, line = end.line, ch = end.ch;
1244
+ var lineObj = getLine(line);
1245
+ function findNextLine() {
1246
+ for (var l = line + dir, e = dir < 0 ? -1 : doc.size; l != e; l += dir) {
1247
+ var lo = getLine(l);
1248
+ if (!lo.hidden) { line = l; lineObj = lo; return true; }
1249
+ }
1250
+ }
1251
+ function moveOnce(boundToLine) {
1252
+ if (ch == (dir < 0 ? 0 : lineObj.text.length)) {
1253
+ if (!boundToLine && findNextLine()) ch = dir < 0 ? lineObj.text.length : 0;
1254
+ else return false;
1255
+ } else ch += dir;
1256
+ return true;
1257
+ }
1258
+ if (unit == "char") moveOnce();
1259
+ else if (unit == "column") moveOnce(true);
1260
+ else if (unit == "word") {
1261
+ var sawWord = false;
1262
+ for (;;) {
1263
+ if (dir < 0) if (!moveOnce()) break;
1264
+ if (isWordChar(lineObj.text.charAt(ch))) sawWord = true;
1265
+ else if (sawWord) {if (dir < 0) {dir = 1; moveOnce();} break;}
1266
+ if (dir > 0) if (!moveOnce()) break;
1267
+ }
1268
+ }
1269
+ return {line: line, ch: ch};
1270
+ }
1271
+ function moveH(dir, unit) {
1272
+ var pos = dir < 0 ? sel.from : sel.to;
1273
+ if (shiftSelecting || posEq(sel.from, sel.to)) pos = findPosH(dir, unit);
1274
+ setCursor(pos.line, pos.ch, true);
1275
  }
1276
+ function deleteH(dir, unit) {
1277
+ if (!posEq(sel.from, sel.to)) replaceRange("", sel.from, sel.to);
1278
+ else if (dir < 0) replaceRange("", findPosH(dir, unit), sel.to);
1279
+ else replaceRange("", sel.from, findPosH(dir, unit));
1280
+ userSelChange = true;
1281
  }
1282
+ var goalColumn = null;
1283
+ function moveV(dir, unit) {
1284
+ var dist = 0, pos = localCoords(sel.inverted ? sel.from : sel.to, true);
1285
+ if (goalColumn != null) pos.x = goalColumn;
1286
+ if (unit == "page") dist = Math.min(scroller.clientHeight, window.innerHeight || document.documentElement.clientHeight);
1287
+ else if (unit == "line") dist = textHeight();
1288
+ var target = coordsChar(pos.x, pos.y + dist * dir + 2);
1289
+ if (unit == "page") scroller.scrollTop += localCoords(target, true).y - pos.y;
1290
+ setCursor(target.line, target.ch, true);
1291
+ goalColumn = pos.x;
1292
  }
1293
+
1294
  function selectWordAt(pos) {
1295
  var line = getLine(pos.line).text;
1296
  var start = pos.ch, end = pos.ch;
1297
+ while (start > 0 && isWordChar(line.charAt(start - 1))) --start;
1298
+ while (end < line.length && isWordChar(line.charAt(end))) ++end;
1299
  setSelectionUser({line: pos.line, ch: start}, {line: pos.line, ch: end});
1300
  }
1301
  function selectLine(line) {
1302
+ setSelectionUser({line: line, ch: 0}, clipPos({line: line + 1, ch: 0}));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1303
  }
1304
+ function indentSelected(mode) {
1305
+ if (posEq(sel.from, sel.to)) return indentLine(sel.from.line, mode);
1306
+ var e = sel.to.line - (sel.to.ch ? 0 : 1);
1307
+ for (var i = sel.from.line; i <= e; ++i) indentLine(i, mode);
1308
  }
1309
 
1310
  function indentLine(n, how) {
1311
+ if (!how) how = "add";
1312
  if (how == "smart") {
1313
  if (!mode.indent) how = "prev";
1314
  else var state = getStateBefore(n);
1315
  }
1316
 
1317
+ var line = getLine(n), curSpace = line.indentation(options.tabSize),
1318
+ curSpaceString = line.text.match(/^\s*/)[0], indentation;
1319
  if (how == "prev") {
1320
+ if (n) indentation = getLine(n-1).indentation(options.tabSize);
1321
  else indentation = 0;
1322
  }
1323
+ else if (how == "smart") indentation = mode.indent(state, line.text.slice(curSpaceString.length), line.text);
1324
  else if (how == "add") indentation = curSpace + options.indentUnit;
1325
  else if (how == "subtract") indentation = curSpace - options.indentUnit;
1326
  indentation = Math.max(0, indentation);
1333
  else {
1334
  var indentString = "", pos = 0;
1335
  if (options.indentWithTabs)
1336
+ for (var i = Math.floor(indentation / options.tabSize); i; --i) {pos += options.tabSize; indentString += "\t";}
1337
  while (pos < indentation) {++pos; indentString += " ";}
1338
  }
1339
 
1372
  }
1373
  changes.push({from: 0, to: doc.size});
1374
  }
1375
+ function makeTab(col) {
1376
+ var w = options.tabSize - col % options.tabSize, cached = tabCache[w];
1377
+ if (cached) return cached;
1378
+ for (var str = '<span class="cm-tab">', i = 0; i < w; ++i) str += " ";
1379
+ return (tabCache[w] = {html: str + "</span>", width: w});
1380
+ }
1381
+ function themeChanged() {
1382
+ scroller.className = scroller.className.replace(/\s*cm-s-\S+/g, "") +
1383
+ options.theme.replace(/(^|\s)\s*/g, " cm-s-");
1384
+ }
1385
+ function keyMapChanged() {
1386
+ var style = keyMap[options.keyMap].style;
1387
+ wrapper.className = wrapper.className.replace(/\s*cm-keymap-\S+/g, "") +
1388
+ (style ? " cm-keymap-" + style : "");
1389
+ }
1390
 
1391
  function TextMarker() { this.set = []; }
1392
  TextMarker.prototype.clear = operation(function() {
1393
+ var min = Infinity, max = -Infinity;
1394
  for (var i = 0, e = this.set.length; i < e; ++i) {
1395
+ var line = this.set[i], mk = line.marked;
1396
+ if (!mk || !line.parent) continue;
1397
+ var lineN = lineNo(line);
1398
+ min = Math.min(min, lineN); max = Math.max(max, lineN);
1399
  for (var j = 0; j < mk.length; ++j)
1400
+ if (mk[j].marker == this) mk.splice(j--, 1);
1401
  }
1402
+ if (min != Infinity)
1403
+ changes.push({from: min, to: max + 1});
 
1404
  });
1405
  TextMarker.prototype.find = function() {
1406
  var from, to;
1408
  var line = this.set[i], mk = line.marked;
1409
  for (var j = 0; j < mk.length; ++j) {
1410
  var mark = mk[j];
1411
+ if (mark.marker == this) {
1412
  if (mark.from != null || mark.to != null) {
1413
  var found = lineNo(line);
1414
  if (found != null) {
1425
  function markText(from, to, className) {
1426
  from = clipPos(from); to = clipPos(to);
1427
  var tm = new TextMarker();
1428
+ if (!posLess(from, to)) return tm;
1429
  function add(line, from, to, className) {
1430
+ getLine(line).addMark(new MarkedText(from, to, className, tm));
1431
  }
1432
  if (from.line == to.line) add(from.line, from.ch, to.ch, className);
1433
  else {
1447
  return bm;
1448
  }
1449
 
1450
+ function findMarksAt(pos) {
1451
+ pos = clipPos(pos);
1452
+ var markers = [], marked = getLine(pos.line).marked;
1453
+ if (!marked) return markers;
1454
+ for (var i = 0, e = marked.length; i < e; ++i) {
1455
+ var m = marked[i];
1456
+ if ((m.from == null || m.from <= pos.ch) &&
1457
+ (m.to == null || m.to >= pos.ch))
1458
+ markers.push(m.marker || m);
1459
+ }
1460
+ return markers;
1461
+ }
1462
+
1463
  function addGutterMarker(line, text, className) {
1464
  if (typeof line == "number") line = getLine(clipLine(line));
1465
  line.gutterMarker = {text: text, style: className};
1478
  else no = lineNo(handle);
1479
  if (no == null) return null;
1480
  if (op(line, no)) changes.push({from: no, to: no + 1});
1481
+ else return null;
1482
  return line;
1483
  }
1484
+ function setLineClass(handle, className, bgClassName) {
1485
  return changeLine(handle, function(line) {
1486
+ if (line.className != className || line.bgClassName != bgClassName) {
1487
  line.className = className;
1488
+ line.bgClassName = bgClassName;
1489
  return true;
1490
  }
1491
  });
1495
  if (line.hidden != hidden) {
1496
  line.hidden = hidden;
1497
  updateLineHeight(line, hidden ? 0 : 1);
1498
+ var fline = sel.from.line, tline = sel.to.line;
1499
+ if (hidden && (fline == no || tline == no)) {
1500
+ var from = fline == no ? skipHidden({line: fline, ch: 0}, fline, 0) : sel.from;
1501
+ var to = tline == no ? skipHidden({line: tline, ch: 0}, tline, 0) : sel.to;
1502
+ // Can't hide the last visible line, we'd have no place to put the cursor
1503
+ if (!to) return;
1504
+ setSelection(from, to);
1505
+ }
1506
  return (gutterDirty = true);
1507
  }
1508
  });
1521
  }
1522
  var marker = line.gutterMarker;
1523
  return {line: n, handle: line, text: line.text, markerText: marker && marker.text,
1524
+ markerClass: marker && marker.style, lineClass: line.className, bgClass: line.bgClassName};
1525
  }
1526
 
1527
  function stringWidth(str) {
1535
  if (x <= 0) return 0;
1536
  var lineObj = getLine(line), text = lineObj.text;
1537
  function getX(len) {
1538
+ return measureLine(lineObj, len).left;
 
1539
  }
1540
  var from = 0, fromX = 0, to = text.length, toX;
1541
  // Guess a suitable upper bound for our search.
1558
  }
1559
  }
1560
 
1561
+ var tempId = "CodeMirror-temp-" + Math.floor(Math.random() * 0xffffff).toString(16);
1562
  function measureLine(line, ch) {
1563
+ if (ch == 0) return {top: 0, left: 0};
1564
+ var wbr = options.lineWrapping && ch < line.text.length &&
1565
+ spanAffectsWrapping.test(line.text.slice(ch - 1, ch + 1));
1566
+ measure.innerHTML = "<pre>" + line.getHTML(makeTab, ch, tempId, wbr) + "</pre>";
1567
+ var elt = document.getElementById(tempId);
 
 
 
 
 
1568
  var top = elt.offsetTop, left = elt.offsetLeft;
1569
  // Older IEs report zero offsets for spans directly after a wrap
1570
+ if (ie && top == 0 && left == 0) {
1571
  var backup = document.createElement("span");
1572
  backup.innerHTML = "x";
1573
  elt.parentNode.insertBefore(backup, elt.nextSibling);
1590
  if (y < 0) y = 0;
1591
  var th = textHeight(), cw = charWidth(), heightPos = displayOffset + Math.floor(y / th);
1592
  var lineNo = lineAtHeight(doc, heightPos);
1593
+ if (lineNo >= doc.size) return {line: doc.size - 1, ch: getLine(doc.size - 1).text.length};
1594
  var lineObj = getLine(lineNo), text = lineObj.text;
1595
  var tw = options.lineWrapping, innerOff = tw ? heightPos - heightAtLine(doc, lineNo) : 0;
1596
  if (x <= 0 && innerOff == 0) return {line: lineNo, ch: 0};
1627
  return {x: off.left + local.x, y: off.top + local.y, yBot: off.top + local.yBot};
1628
  }
1629
 
1630
+ var cachedHeight, cachedHeightFor, measureText;
1631
  function textHeight() {
1632
+ if (measureText == null) {
1633
+ measureText = "<pre>";
1634
+ for (var i = 0; i < 49; ++i) measureText += "x<br/>";
1635
+ measureText += "x</pre>";
1636
+ }
1637
+ var offsetHeight = lineDiv.clientHeight;
1638
+ if (offsetHeight == cachedHeightFor) return cachedHeight;
1639
+ cachedHeightFor = offsetHeight;
1640
+ measure.innerHTML = measureText;
1641
+ cachedHeight = measure.firstChild.offsetHeight / 50 || 1;
1642
+ measure.innerHTML = "";
1643
+ return cachedHeight;
1644
+ }
1645
+ var cachedWidth, cachedWidthFor = 0;
1646
  function charWidth() {
1647
+ if (scroller.clientWidth == cachedWidthFor) return cachedWidth;
1648
+ cachedWidthFor = scroller.clientWidth;
1649
  return (cachedWidth = stringWidth("x"));
1650
  }
1651
  function paddingTop() {return lineSpace.offsetTop;}
1664
  return coordsChar(x - offL.left, y - offL.top);
1665
  }
1666
  function onContextMenu(e) {
1667
+ var pos = posFromMouse(e), scrollPos = scroller.scrollTop;
1668
  if (!pos || window.opera) return; // Opera is difficult.
1669
  if (posEq(sel.from, sel.to) || posLess(pos, sel.from) || !posLess(pos, sel.to))
1670
  operation(setCursor)(pos.line, pos.ch);
1677
  leaveInputAlone = true;
1678
  var val = input.value = getSelection();
1679
  focusInput();
1680
+ selectInput(input);
1681
  function rehide() {
1682
  var newVal = splitLines(input.value).join("\n");
1683
  if (newVal != val) operation(replaceSelection)(newVal, "end");
1684
  inputDiv.style.position = "relative";
1685
  input.style.cssText = oldCSS;
1686
+ if (ie_lt9) scroller.scrollTop = scrollPos;
1687
  leaveInputAlone = false;
1688
+ resetInput(true);
1689
  slowPoll();
1690
  }
1691
 
1695
  mouseup();
1696
  setTimeout(rehide, 20);
1697
  }, true);
1698
+ } else {
 
1699
  setTimeout(rehide, 50);
1700
  }
1701
  }
1761
  if (search == 0) return 0;
1762
  var line = getLine(search-1);
1763
  if (line.stateAfter) return search;
1764
+ var indented = line.indentation(options.tabSize);
1765
  if (minline == null || minindent > indented) {
1766
  minline = search - 1;
1767
  minindent = indented;
1774
  if (!state) state = startState(mode);
1775
  else state = copyState(mode, state);
1776
  doc.iter(start, n, function(line) {
1777
+ line.highlight(mode, state, options.tabSize);
1778
  line.stateAfter = copyState(mode, state);
1779
  });
1780
  if (start < n) changes.push({from: start, to: n});
1784
  function highlightLines(start, end) {
1785
  var state = getStateBefore(start);
1786
  doc.iter(start, end, function(line) {
1787
+ line.highlight(mode, state, options.tabSize);
1788
  line.stateAfter = copyState(mode, state);
1789
  });
1790
  }
1809
  if (realChange) changes.push({from: task, to: i + 1});
1810
  return (bail = true);
1811
  }
1812
+ var changed = line.highlight(mode, state, options.tabSize);
1813
  if (changed) realChange = true;
1814
  line.stateAfter = copyState(mode, state);
1815
+ var done = null;
1816
  if (compare) {
1817
+ var same = hadState && compare(hadState, state);
1818
+ if (same != Pass) done = !!same;
1819
+ }
1820
+ if (done == null) {
1821
  if (changed !== false || !hadState) unchanged = 0;
1822
+ else if (++unchanged > 3 && (!mode.indent || mode.indent(hadState, "") == mode.indent(state, "")))
1823
+ done = true;
1824
  }
1825
+ if (done) return true;
1826
  ++i;
1827
  });
1828
  if (bail) return;
1841
  // be awkward, slow, and error-prone), but instead updates are
1842
  // batched and then all combined and executed at once.
1843
  function startOperation() {
1844
+ updateInput = userSelChange = textChanged = null;
1845
+ changes = []; selectionChanged = false; callbacks = [];
1846
  }
1847
  function endOperation() {
1848
+ var reScroll = false, updated;
1849
  if (selectionChanged) reScroll = !scrollCursorIntoView();
1850
+ if (changes.length) updated = updateDisplay(changes, true);
1851
  else {
1852
+ if (selectionChanged) updateSelection();
1853
  if (gutterDirty) updateGutter();
1854
  }
1855
  if (reScroll) scrollCursorIntoView();
1856
  if (selectionChanged) {scrollEditorIntoView(); restartBlink();}
1857
 
 
 
1858
  if (focused && !leaveInputAlone &&
1859
  (updateInput === true || (updateInput !== false && selectionChanged)))
1860
+ resetInput(userSelChange);
1861
 
1862
  if (selectionChanged && options.matchBrackets)
1863
  setTimeout(operation(function() {
1864
  if (bracketHighlighted) {bracketHighlighted(); bracketHighlighted = null;}
1865
+ if (posEq(sel.from, sel.to)) matchBrackets(false);
1866
  }), 20);
1867
+ var tc = textChanged, cbs = callbacks; // these can be reset by callbacks
1868
  if (selectionChanged && options.onCursorActivity)
1869
  options.onCursorActivity(instance);
1870
  if (tc && options.onChange && instance)
1871
  options.onChange(instance, tc);
1872
+ for (var i = 0; i < cbs.length; ++i) cbs[i](instance);
1873
+ if (updated && options.onUpdate) options.onUpdate(instance);
1874
  }
1875
  var nestedOperation = 0;
1876
  function operation(f) {
1882
  };
1883
  }
1884
 
1885
+ function compoundChange(f) {
1886
+ history.startCompound();
1887
+ try { return f(); } finally { history.endCompound(); }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1888
  }
1889
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1890
  for (var ext in extensions)
1891
  if (extensions.propertyIsEnumerable(ext) &&
1892
  !instance.propertyIsEnumerable(ext))
1901
  theme: "default",
1902
  indentUnit: 2,
1903
  indentWithTabs: false,
1904
+ smartIndent: true,
1905
+ tabSize: 4,
1906
+ keyMap: "default",
1907
+ extraKeys: null,
1908
  electricChars: true,
1909
+ autoClearEmptyLines: false,
1910
  onKeyEvent: null,
1911
+ onDragEvent: null,
1912
  lineWrapping: false,
1913
  lineNumbers: false,
1914
  gutter: false,
1915
  fixedGutter: false,
1916
  firstLineNumber: 1,
1917
  readOnly: false,
1918
+ dragDrop: true,
1919
  onChange: null,
1920
  onCursorActivity: null,
1921
  onGutterClick: null,
1922
  onHighlightComplete: null,
1923
+ onUpdate: null,
1924
  onFocus: null, onBlur: null, onScroll: null,
1925
  matchBrackets: false,
1926
  workTime: 100,
1927
  workDelay: 200,
1928
+ pollInterval: 100,
1929
  undoDepth: 40,
1930
  tabindex: null,
1931
+ autofocus: null
 
1932
  };
1933
 
1934
+ var ios = /AppleWebKit/.test(navigator.userAgent) && /Mobile\/\w+/.test(navigator.userAgent);
1935
+ var mac = ios || /Mac/.test(navigator.platform);
1936
+ var win = /Win/.test(navigator.platform);
1937
+
1938
  // Known modes, by name and by MIME
1939
+ var modes = CodeMirror.modes = {}, mimeModes = CodeMirror.mimeModes = {};
1940
  CodeMirror.defineMode = function(name, mode) {
1941
  if (!CodeMirror.defaults.mode && name != "null") CodeMirror.defaults.mode = name;
1942
+ if (arguments.length > 2) {
1943
+ mode.dependencies = [];
1944
+ for (var i = 2; i < arguments.length; ++i) mode.dependencies.push(arguments[i]);
1945
+ }
1946
  modes[name] = mode;
1947
  };
1948
  CodeMirror.defineMIME = function(mime, spec) {
1949
  mimeModes[mime] = spec;
1950
  };
1951
+ CodeMirror.resolveMode = function(spec) {
1952
  if (typeof spec == "string" && mimeModes.hasOwnProperty(spec))
1953
  spec = mimeModes[spec];
1954
+ else if (typeof spec == "string" && /^[\w\-]+\/[\w\-]+\+xml$/.test(spec))
1955
+ return CodeMirror.resolveMode("application/xml");
1956
+ if (typeof spec == "string") return {name: spec};
1957
+ else return spec || {name: "null"};
1958
+ };
1959
+ CodeMirror.getMode = function(options, spec) {
1960
+ var spec = CodeMirror.resolveMode(spec);
1961
+ var mfactory = modes[spec.name];
1962
+ if (!mfactory) return CodeMirror.getMode(options, "text/plain");
1963
+ return mfactory(options, spec);
1964
  };
1965
  CodeMirror.listModes = function() {
1966
  var list = [];
1975
  return list;
1976
  };
1977
 
1978
+ var extensions = CodeMirror.extensions = {};
1979
  CodeMirror.defineExtension = function(name, func) {
1980
  extensions[name] = func;
1981
  };
1982
 
1983
+ var commands = CodeMirror.commands = {
1984
+ selectAll: function(cm) {cm.setSelection({line: 0, ch: 0}, {line: cm.lineCount() - 1});},
1985
+ killLine: function(cm) {
1986
+ var from = cm.getCursor(true), to = cm.getCursor(false), sel = !posEq(from, to);
1987
+ if (!sel && cm.getLine(from.line).length == from.ch) cm.replaceRange("", from, {line: from.line + 1, ch: 0});
1988
+ else cm.replaceRange("", from, sel ? to : {line: from.line});
1989
+ },
1990
+ deleteLine: function(cm) {var l = cm.getCursor().line; cm.replaceRange("", {line: l, ch: 0}, {line: l});},
1991
+ undo: function(cm) {cm.undo();},
1992
+ redo: function(cm) {cm.redo();},
1993
+ goDocStart: function(cm) {cm.setCursor(0, 0, true);},
1994
+ goDocEnd: function(cm) {cm.setSelection({line: cm.lineCount() - 1}, null, true);},
1995
+ goLineStart: function(cm) {cm.setCursor(cm.getCursor().line, 0, true);},
1996
+ goLineStartSmart: function(cm) {
1997
+ var cur = cm.getCursor();
1998
+ var text = cm.getLine(cur.line), firstNonWS = Math.max(0, text.search(/\S/));
1999
+ cm.setCursor(cur.line, cur.ch <= firstNonWS && cur.ch ? 0 : firstNonWS, true);
2000
+ },
2001
+ goLineEnd: function(cm) {cm.setSelection({line: cm.getCursor().line}, null, true);},
2002
+ goLineUp: function(cm) {cm.moveV(-1, "line");},
2003
+ goLineDown: function(cm) {cm.moveV(1, "line");},
2004
+ goPageUp: function(cm) {cm.moveV(-1, "page");},
2005
+ goPageDown: function(cm) {cm.moveV(1, "page");},
2006
+ goCharLeft: function(cm) {cm.moveH(-1, "char");},
2007
+ goCharRight: function(cm) {cm.moveH(1, "char");},
2008
+ goColumnLeft: function(cm) {cm.moveH(-1, "column");},
2009
+ goColumnRight: function(cm) {cm.moveH(1, "column");},
2010
+ goWordLeft: function(cm) {cm.moveH(-1, "word");},
2011
+ goWordRight: function(cm) {cm.moveH(1, "word");},
2012
+ delCharLeft: function(cm) {cm.deleteH(-1, "char");},
2013
+ delCharRight: function(cm) {cm.deleteH(1, "char");},
2014
+ delWordLeft: function(cm) {cm.deleteH(-1, "word");},
2015
+ delWordRight: function(cm) {cm.deleteH(1, "word");},
2016
+ indentAuto: function(cm) {cm.indentSelection("smart");},
2017
+ indentMore: function(cm) {cm.indentSelection("add");},
2018
+ indentLess: function(cm) {cm.indentSelection("subtract");},
2019
+ insertTab: function(cm) {cm.replaceSelection("\t", "end");},
2020
+ defaultTab: function(cm) {
2021
+ if (cm.somethingSelected()) cm.indentSelection("add");
2022
+ else cm.replaceSelection("\t", "end");
2023
+ },
2024
+ transposeChars: function(cm) {
2025
+ var cur = cm.getCursor(), line = cm.getLine(cur.line);
2026
+ if (cur.ch > 0 && cur.ch < line.length - 1)
2027
+ cm.replaceRange(line.charAt(cur.ch) + line.charAt(cur.ch - 1),
2028
+ {line: cur.line, ch: cur.ch - 1}, {line: cur.line, ch: cur.ch + 1});
2029
+ },
2030
+ newlineAndIndent: function(cm) {
2031
+ cm.replaceSelection("\n", "end");
2032
+ cm.indentLine(cm.getCursor().line);
2033
+ },
2034
+ toggleOverwrite: function(cm) {cm.toggleOverwrite();}
2035
+ };
2036
+
2037
+ var keyMap = CodeMirror.keyMap = {};
2038
+ keyMap.basic = {
2039
+ "Left": "goCharLeft", "Right": "goCharRight", "Up": "goLineUp", "Down": "goLineDown",
2040
+ "End": "goLineEnd", "Home": "goLineStartSmart", "PageUp": "goPageUp", "PageDown": "goPageDown",
2041
+ "Delete": "delCharRight", "Backspace": "delCharLeft", "Tab": "defaultTab", "Shift-Tab": "indentAuto",
2042
+ "Enter": "newlineAndIndent", "Insert": "toggleOverwrite"
2043
+ };
2044
+ // Note that the save and find-related commands aren't defined by
2045
+ // default. Unknown commands are simply ignored.
2046
+ keyMap.pcDefault = {
2047
+ "Ctrl-A": "selectAll", "Ctrl-D": "deleteLine", "Ctrl-Z": "undo", "Shift-Ctrl-Z": "redo", "Ctrl-Y": "redo",
2048
+ "Ctrl-Home": "goDocStart", "Alt-Up": "goDocStart", "Ctrl-End": "goDocEnd", "Ctrl-Down": "goDocEnd",
2049
+ "Ctrl-Left": "goWordLeft", "Ctrl-Right": "goWordRight", "Alt-Left": "goLineStart", "Alt-Right": "goLineEnd",
2050
+ "Ctrl-Backspace": "delWordLeft", "Ctrl-Delete": "delWordRight", "Ctrl-S": "save", "Ctrl-F": "find",
2051
+ "Ctrl-G": "findNext", "Shift-Ctrl-G": "findPrev", "Shift-Ctrl-F": "replace", "Shift-Ctrl-R": "replaceAll",
2052
+ "Ctrl-[": "indentLess", "Ctrl-]": "indentMore",
2053
+ fallthrough: "basic"
2054
+ };
2055
+ keyMap.macDefault = {
2056
+ "Cmd-A": "selectAll", "Cmd-D": "deleteLine", "Cmd-Z": "undo", "Shift-Cmd-Z": "redo", "Cmd-Y": "redo",
2057
+ "Cmd-Up": "goDocStart", "Cmd-End": "goDocEnd", "Cmd-Down": "goDocEnd", "Alt-Left": "goWordLeft",
2058
+ "Alt-Right": "goWordRight", "Cmd-Left": "goLineStart", "Cmd-Right": "goLineEnd", "Alt-Backspace": "delWordLeft",
2059
+ "Ctrl-Alt-Backspace": "delWordRight", "Alt-Delete": "delWordRight", "Cmd-S": "save", "Cmd-F": "find",
2060
+ "Cmd-G": "findNext", "Shift-Cmd-G": "findPrev", "Cmd-Alt-F": "replace", "Shift-Cmd-Alt-F": "replaceAll",
2061
+ "Cmd-[": "indentLess", "Cmd-]": "indentMore",
2062
+ fallthrough: ["basic", "emacsy"]
2063
+ };
2064
+ keyMap["default"] = mac ? keyMap.macDefault : keyMap.pcDefault;
2065
+ keyMap.emacsy = {
2066
+ "Ctrl-F": "goCharRight", "Ctrl-B": "goCharLeft", "Ctrl-P": "goLineUp", "Ctrl-N": "goLineDown",
2067
+ "Alt-F": "goWordRight", "Alt-B": "goWordLeft", "Ctrl-A": "goLineStart", "Ctrl-E": "goLineEnd",
2068
+ "Ctrl-V": "goPageUp", "Shift-Ctrl-V": "goPageDown", "Ctrl-D": "delCharRight", "Ctrl-H": "delCharLeft",
2069
+ "Alt-D": "delWordRight", "Alt-Backspace": "delWordLeft", "Ctrl-K": "killLine", "Ctrl-T": "transposeChars"
2070
+ };
2071
+
2072
+ function getKeyMap(val) {
2073
+ if (typeof val == "string") return keyMap[val];
2074
+ else return val;
2075
+ }
2076
+ function lookupKey(name, extraMap, map, handle, stop) {
2077
+ function lookup(map) {
2078
+ map = getKeyMap(map);
2079
+ var found = map[name];
2080
+ if (found != null && handle(found)) return true;
2081
+ if (map.nofallthrough) {
2082
+ if (stop) stop();
2083
+ return true;
2084
+ }
2085
+ var fallthrough = map.fallthrough;
2086
+ if (fallthrough == null) return false;
2087
+ if (Object.prototype.toString.call(fallthrough) != "[object Array]")
2088
+ return lookup(fallthrough);
2089
+ for (var i = 0, e = fallthrough.length; i < e; ++i) {
2090
+ if (lookup(fallthrough[i])) return true;
2091
+ }
2092
+ return false;
2093
+ }
2094
+ if (extraMap && lookup(extraMap)) return true;
2095
+ return lookup(map);
2096
+ }
2097
+ function isModifierKey(event) {
2098
+ var name = keyNames[e_prop(event, "keyCode")];
2099
+ return name == "Ctrl" || name == "Alt" || name == "Shift" || name == "Mod";
2100
+ }
2101
+
2102
  CodeMirror.fromTextArea = function(textarea, options) {
2103
  if (!options) options = {};
2104
  options.value = textarea.value;
2105
  if (!options.tabindex && textarea.tabindex)
2106
  options.tabindex = textarea.tabindex;
2107
+ if (options.autofocus == null && textarea.getAttribute("autofocus") != null)
2108
+ options.autofocus = true;
2109
 
2110
  function save() {textarea.value = instance.getValue();}
2111
  if (textarea.form) {
2128
  textarea.parentNode.insertBefore(node, textarea.nextSibling);
2129
  }, options);
2130
  instance.save = save;
2131
+ instance.getTextArea = function() { return textarea; };
2132
  instance.toTextArea = function() {
2133
  save();
2134
  textarea.parentNode.removeChild(instance.getWrapperElement());
2162
  CodeMirror.startState = startState;
2163
 
2164
  // The character stream used by a mode's parser.
2165
+ function StringStream(string, tabSize) {
2166
  this.pos = this.start = 0;
2167
  this.string = string;
2168
+ this.tabSize = tabSize || 8;
2169
  }
2170
  StringStream.prototype = {
2171
  eol: function() {return this.pos >= this.string.length;},
2197
  if (found > -1) {this.pos = found; return true;}
2198
  },
2199
  backUp: function(n) {this.pos -= n;},
2200
+ column: function() {return countColumn(this.string, this.start, this.tabSize);},
2201
+ indentation: function() {return countColumn(this.string, null, this.tabSize);},
2202
  match: function(pattern, consume, caseInsensitive) {
2203
  if (typeof pattern == "string") {
2204
  function cased(str) {return caseInsensitive ? str.toLowerCase() : str;}
2217
  };
2218
  CodeMirror.StringStream = StringStream;
2219
 
2220
+ function MarkedText(from, to, className, marker) {
2221
+ this.from = from; this.to = to; this.style = className; this.marker = marker;
2222
  }
2223
  MarkedText.prototype = {
2224
+ attach: function(line) { this.marker.set.push(line); },
2225
  detach: function(line) {
2226
+ var ix = indexOf(this.marker.set, line);
2227
+ if (ix > -1) this.marker.set.splice(ix, 1);
2228
  },
2229
  split: function(pos, lenBefore) {
2230
  if (this.to <= pos && this.to != null) return null;
2231
  var from = this.from < pos || this.from == null ? null : this.from - pos + lenBefore;
2232
  var to = this.to == null ? null : this.to - pos + lenBefore;
2233
+ return new MarkedText(from, to, this.style, this.marker);
2234
  },
2235
+ dup: function() { return new MarkedText(null, null, this.style, this.marker); },
2236
  clipTo: function(fromOpen, from, toOpen, to, diff) {
 
 
 
 
2237
  if (fromOpen && to > this.from && (to < this.to || this.to == null))
2238
  this.from = null;
2239
+ else if (this.from != null && this.from >= from)
2240
+ this.from = Math.max(to, this.from) + diff;
2241
  if (toOpen && (from < this.to || this.to == null) && (from > this.from || this.from == null))
2242
  this.to = null;
2243
+ else if (this.to != null && this.to > from)
2244
+ this.to = to < this.to ? this.to + diff : from;
2245
  },
2246
  isDead: function() { return this.from != null && this.to != null && this.from >= this.to; },
2247
+ sameSet: function(x) { return this.marker == x.marker; }
2248
  };
2249
 
2250
  function Bookmark(pos) {
2287
  this.styles = styles || [text, null];
2288
  this.text = text;
2289
  this.height = 1;
2290
+ this.marked = this.gutterMarker = this.className = this.bgClassName = this.handlers = null;
2291
  this.stateAfter = this.parent = this.hidden = null;
2292
  }
2293
  Line.inheritMarks = function(text, orig) {
2294
+ var ln = new Line(text), mk = orig && orig.marked;
2295
  if (mk) {
2296
  for (var i = 0; i < mk.length; ++i) {
2297
  if (mk[i].to == null && mk[i].style) {
2305
  Line.prototype = {
2306
  // Replace a piece of a line, keeping the styles around it intact.
2307
  replace: function(from, to_, text) {
 
 
 
2308
  var st = [], mk = this.marked, to = to_ == null ? this.text.length : to_;
2309
  copyStyles(0, from, this.styles, st);
2310
  if (text) st.push(text, null);
2314
  this.stateAfter = null;
2315
  if (mk) {
2316
  var diff = text.length - (to - from);
2317
+ for (var i = 0; i < mk.length; ++i) {
2318
+ var mark = mk[i];
2319
  mark.clipTo(from == null, from || 0, to_ == null, to, diff);
2320
  if (mark.isDead()) {mark.detach(this); mk.splice(i--, 1);}
2321
  }
2333
  if (newmark) {
2334
  if (!taken.marked) taken.marked = [];
2335
  taken.marked.push(newmark); newmark.attach(taken);
2336
+ if (newmark == mark) mk.splice(i--, 1);
2337
  }
2338
  }
2339
  }
2383
  if (close) mark.to = this.text.length;
2384
  }
2385
  },
2386
+ fixMarkStarts: function() {
2387
+ var mk = this.marked;
2388
+ if (!mk) return;
2389
+ for (var i = 0; i < mk.length; ++i)
2390
+ if (mk[i].from == null) mk[i].from = 0;
2391
+ },
2392
  addMark: function(mark) {
2393
  mark.attach(this);
2394
  if (this.marked == null) this.marked = [];
2398
  // Run the given mode's parser over a line, update the styles
2399
  // array, which contains alternating fragments of text and CSS
2400
  // classes.
2401
+ highlight: function(mode, state, tabSize) {
2402
+ var stream = new StringStream(this.text, tabSize), st = this.styles, pos = 0;
2403
  var changed = false, curWord = st[0], prevWord;
2404
  if (this.text == "" && mode.blankLine) mode.blankLine(state);
2405
  while (!stream.eol()) {
2440
  className: style || null,
2441
  state: state};
2442
  },
2443
+ indentation: function(tabSize) {return countColumn(this.text, null, tabSize);},
2444
  // Produces an HTML fragment for the line, taking selection,
2445
  // marking, and highlighting into account.
2446
+ getHTML: function(makeTab, wrapAt, wrapId, wrapWBR) {
2447
+ var html = [], first = true, col = 0;
2448
+ function span_(text, style) {
 
 
2449
  if (!text) return;
2450
  // Work around a bug where, in some compat modes, IE ignores leading spaces
2451
  if (first && ie && text.charAt(0) == " ") text = "\u00a0" + text.slice(1);
2452
  first = false;
2453
+ if (text.indexOf("\t") == -1) {
2454
+ col += text.length;
2455
+ var escaped = htmlEscape(text);
2456
+ } else {
2457
+ var escaped = "";
2458
+ for (var pos = 0;;) {
2459
+ var idx = text.indexOf("\t", pos);
2460
+ if (idx == -1) {
2461
+ escaped += htmlEscape(text.slice(pos));
2462
+ col += text.length - pos;
2463
+ break;
2464
+ } else {
2465
+ col += idx - pos;
2466
+ var tab = makeTab(col);
2467
+ escaped += htmlEscape(text.slice(pos, idx)) + tab.html;
2468
+ col += tab.width;
2469
+ pos = idx + 1;
2470
+ }
2471
+ }
2472
+ }
2473
+ if (style) html.push('<span class="', style, '">', escaped, "</span>");
2474
+ else html.push(escaped);
2475
+ }
2476
+ var span = span_;
2477
+ if (wrapAt != null) {
2478
+ var outPos = 0, open = "<span id=\"" + wrapId + "\">";
2479
+ span = function(text, style) {
2480
+ var l = text.length;
2481
+ if (wrapAt >= outPos && wrapAt < outPos + l) {
2482
+ if (wrapAt > outPos) {
2483
+ span_(text.slice(0, wrapAt - outPos), style);
2484
+ // See comment at the definition of spanAffectsWrapping
2485
+ if (wrapWBR) html.push("<wbr>");
2486
+ }
2487
+ html.push(open);
2488
+ var cut = wrapAt - outPos;
2489
+ span_(window.opera ? text.slice(cut, cut + 1) : text.slice(cut), style);
2490
+ html.push("</span>");
2491
+ if (window.opera) span_(text.slice(cut + 1), style);
2492
+ wrapAt--;
2493
+ outPos += l;
2494
+ } else {
2495
+ outPos += l;
2496
+ span_(text, style);
2497
+ // Output empty wrapper when at end of line
2498
+ if (outPos == wrapAt && outPos == len) html.push(open + " </span>");
2499
+ // Stop outputting HTML when gone sufficiently far beyond measure
2500
+ else if (outPos > wrapAt + 10 && /\s/.test(text)) span = function(){};
2501
+ }
2502
+ }
2503
  }
2504
+
2505
  var st = this.styles, allText = this.text, marked = this.marked;
 
2506
  var len = allText.length;
2507
+ function styleToClass(style) {
2508
+ if (!style) return null;
2509
+ return "cm-" + style.replace(/ +/g, " cm-");
2510
+ }
2511
 
2512
+ if (!allText && wrapAt == null) {
2513
+ span(" ");
2514
+ } else if (!marked || !marked.length) {
2515
  for (var i = 0, ch = 0; ch < len; i+=2) {
2516
  var str = st[i], style = st[i+1], l = str.length;
2517
  if (ch + l > len) str = str.slice(0, len - ch);
2518
  ch += l;
2519
+ span(str, styleToClass(style));
2520
  }
2521
+ } else {
2522
  var pos = 0, i = 0, text = "", style, sg = 0;
2523
+ var nextChange = marked[0].from || 0, marks = [], markpos = 0;
2524
+ function advanceMarks() {
2525
+ var m;
2526
+ while (markpos < marked.length &&
2527
+ ((m = marked[markpos]).from == pos || m.from == null)) {
2528
+ if (m.style != null) marks.push(m);
2529
+ ++markpos;
2530
+ }
2531
+ nextChange = markpos < marked.length ? marked[markpos].from : Infinity;
2532
+ for (var i = 0; i < marks.length; ++i) {
2533
+ var to = marks[i].to || Infinity;
2534
+ if (to == pos) marks.splice(i--, 1);
2535
+ else nextChange = Math.min(to, nextChange);
2536
  }
2537
  }
2538
+ var m = 0;
2539
  while (pos < len) {
2540
+ if (nextChange == pos) advanceMarks();
2541
+ var upto = Math.min(len, nextChange);
2542
+ while (true) {
2543
+ if (text) {
2544
+ var end = pos + text.length;
2545
+ var appliedStyle = style;
2546
+ for (var j = 0; j < marks.length; ++j)
2547
+ appliedStyle = (appliedStyle ? appliedStyle + " " : "") + marks[j].style;
2548
+ span(end > upto ? text.slice(0, upto - pos) : text, appliedStyle);
2549
+ if (end >= upto) {text = text.slice(upto - pos); pos = upto; break;}
2550
+ pos = end;
2551
  }
2552
+ text = st[i++]; style = styleToClass(st[i++]);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2553
  }
2554
  }
 
2555
  }
 
2556
  return html.join("");
2557
  },
2558
  cleanUp: function() {
2589
  }
2590
  LeafChunk.prototype = {
2591
  chunkSize: function() { return this.lines.length; },
2592
+ remove: function(at, n, callbacks) {
2593
  for (var i = at, e = at + n; i < e; ++i) {
2594
  var line = this.lines[i];
 
2595
  this.height -= line.height;
2596
+ line.cleanUp();
2597
+ if (line.handlers)
2598
+ for (var j = 0; j < line.handlers.length; ++j) callbacks.push(line.handlers[j]);
2599
  }
2600
  this.lines.splice(at, n);
2601
  },
2604
  },
2605
  insertHeight: function(at, lines, height) {
2606
  this.height += height;
2607
+ // The trick below is apparently too advanced for IE, which
2608
+ // occasionally corrupts this.lines (duplicating elements) when
2609
+ // it is used.
2610
+ if (ie) this.lines = this.lines.slice(0, at).concat(lines).concat(this.lines.slice(at));
2611
+ else this.lines.splice.apply(this.lines, [at, 0].concat(lines));
2612
  for (var i = 0, e = lines.length; i < e; ++i) lines[i].parent = this;
2613
  },
2614
  iterN: function(at, n, op) {
2630
  }
2631
  BranchChunk.prototype = {
2632
  chunkSize: function() { return this.size; },
2633
+ remove: function(at, n, callbacks) {
2634
  this.size -= n;
2635
  for (var i = 0; i < this.children.length; ++i) {
2636
  var child = this.children[i], sz = child.chunkSize();
2637
  if (at < sz) {
2638
  var rm = Math.min(n, sz - at), oldHeight = child.height;
2639
+ child.remove(at, rm, callbacks);
2640
  this.height -= oldHeight - child.height;
2641
  if (sz == rm) { this.children.splice(i--, 1); child.parent = null; }
2642
  if ((n -= rm) == 0) break;
2647
  var lines = [];
2648
  this.collapse(lines);
2649
  this.children = [new LeafChunk(lines)];
2650
+ this.children[0].parent = this;
2651
  }
2652
  },
2653
  collapse: function(lines) {
2716
  };
2717
 
2718
  function getLineAt(chunk, n) {
2719
+ while (!chunk.lines) {
2720
+ for (var i = 0;; ++i) {
2721
  var child = chunk.children[i], sz = child.chunkSize();
2722
  if (n < sz) { chunk = child; break; }
2723
  n -= sz;
2724
  }
 
2725
  }
2726
+ return chunk.lines[n];
2727
  }
2728
  function lineNo(line) {
2729
  if (line.parent == null) return null;
2774
  function History() {
2775
  this.time = 0;
2776
  this.done = []; this.undone = [];
2777
+ this.compound = 0;
2778
+ this.closed = false;
2779
  }
2780
  History.prototype = {
2781
  addChange: function(start, added, old) {
2782
  this.undone.length = 0;
2783
+ var time = +new Date, cur = this.done[this.done.length - 1], last = cur && cur[cur.length - 1];
2784
+ var dtime = time - this.time;
2785
+
2786
+ if (this.compound && cur && !this.closed) {
2787
+ cur.push({start: start, added: added, old: old});
2788
+ } else if (dtime > 400 || !last || this.closed ||
2789
+ last.start > start + old.length || last.start + last.added < start) {
2790
+ this.done.push([{start: start, added: added, old: old}]);
2791
+ this.closed = false;
2792
+ } else {
2793
+ var startBefore = Math.max(0, last.start - start),
2794
+ endAfter = Math.max(0, (start + old.length) - (last.start + last.added));
2795
+ for (var i = startBefore; i > 0; --i) last.old.unshift(old[i - 1]);
2796
+ for (var i = endAfter; i > 0; --i) last.old.push(old[old.length - i]);
2797
+ if (startBefore) last.start = start;
2798
+ last.added += added - (old.length - startBefore - endAfter);
 
 
 
2799
  }
2800
  this.time = time;
2801
+ },
2802
+ startCompound: function() {
2803
+ if (!this.compound++) this.closed = true;
2804
+ },
2805
+ endCompound: function() {
2806
+ if (!--this.compound) this.closed = true;
2807
  }
2808
  };
2809
 
2823
  else e.cancelBubble = true;
2824
  }
2825
  function e_stop(e) {e_preventDefault(e); e_stopPropagation(e);}
2826
+ CodeMirror.e_stop = e_stop;
2827
+ CodeMirror.e_preventDefault = e_preventDefault;
2828
+ CodeMirror.e_stopPropagation = e_stopPropagation;
2829
+
2830
  function e_target(e) {return e.target || e.srcElement;}
2831
  function e_button(e) {
2832
  if (e.which) return e.which;
2835
  else if (e.button & 4) return 2;
2836
  }
2837
 
2838
+ // Allow 3rd-party code to override event properties by adding an override
2839
+ // object to an event object.
2840
+ function e_prop(e, prop) {
2841
+ var overridden = e.override && e.override.hasOwnProperty(prop);
2842
+ return overridden ? e.override[prop] : e[prop];
2843
+ }
2844
+
2845
  // Event handler registration. If disconnect is true, it'll return a
2846
  // function that unregisters the handler.
2847
  function connect(node, type, handler, disconnect) {
 
2848
  if (typeof node.addEventListener == "function") {
2849
+ node.addEventListener(type, handler, false);
2850
+ if (disconnect) return function() {node.removeEventListener(type, handler, false);};
2851
  }
2852
  else {
2853
+ var wrapHandler = function(event) {handler(event || window.event);};
2854
  node.attachEvent("on" + type, wrapHandler);
2855
  if (disconnect) return function() {node.detachEvent("on" + type, wrapHandler);};
2856
  }
2857
  }
2858
+ CodeMirror.connect = connect;
2859
 
2860
  function Delayed() {this.id = null;}
2861
  Delayed.prototype = {set: function(ms, f) {clearTimeout(this.id); this.id = setTimeout(f, ms);}};
2862
 
2863
+ var Pass = CodeMirror.Pass = {toString: function(){return "CodeMirror.Pass";}};
 
 
 
 
 
 
 
2864
 
2865
  var gecko = /gecko\/\d{7}/i.test(navigator.userAgent);
2866
  var ie = /MSIE \d/.test(navigator.userAgent);
2867
+ var ie_lt9 = /MSIE [1-8]\b/.test(navigator.userAgent);
2868
+ var quirksMode = ie && document.documentMode == 5;
2869
  var webkit = /WebKit\//.test(navigator.userAgent);
2870
+ var chrome = /Chrome\//.test(navigator.userAgent);
2871
+ var safari = /Apple Computer/.test(navigator.vendor);
2872
+ var khtml = /KHTML\//.test(navigator.userAgent);
2873
+
2874
+ // Detect drag-and-drop
2875
+ var dragAndDrop = function() {
2876
+ // There is *some* kind of drag-and-drop support in IE6-8, but I
2877
+ // couldn't get it to work yet.
2878
+ if (ie_lt9) return false;
2879
+ var div = document.createElement('div');
2880
+ return "draggable" in div || "dragDrop" in div;
2881
+ }();
2882
 
 
2883
  // Feature-detect whether newlines in textareas are converted to \r\n
2884
+ var lineSep = function () {
2885
  var te = document.createElement("textarea");
2886
  te.value = "foo\nbar";
2887
+ if (te.value.indexOf("\r") > -1) return "\r\n";
2888
+ return "\n";
2889
+ }();
2890
 
2891
+ // For a reason I have yet to figure out, some browsers disallow
2892
+ // word wrapping between certain characters *only* if a new inline
2893
+ // element is started between them. This makes it hard to reliably
2894
+ // measure the position of things, since that requires inserting an
2895
+ // extra span. This terribly fragile set of regexps matches the
2896
+ // character combinations that suffer from this phenomenon on the
2897
+ // various browsers.
2898
+ var spanAffectsWrapping = /^$/; // Won't match any two-character string
2899
+ if (gecko) spanAffectsWrapping = /$'/;
2900
+ else if (safari) spanAffectsWrapping = /\-[^ \-?]|\?[^ !'\"\),.\-\/:;\?\]\}]/;
2901
+ else if (chrome) spanAffectsWrapping = /\-[^ \-\.?]|\?[^ \-\.?\]\}:;!'\"\),\/]|[\.!\"#&%\)*+,:;=>\]|\}~][\(\{\[<]|\$'/;
2902
 
2903
  // Counts the column offset in a string, taking tabs into account.
2904
  // Used mostly to find indentation.
2905
+ function countColumn(string, end, tabSize) {
2906
  if (end == null) {
2907
  end = string.search(/[^\s\u00a0]/);
2908
  if (end == -1) end = string.length;
2960
  function eltText(node) {
2961
  return node.textContent || node.innerText || node.nodeValue || "";
2962
  }
2963
+ function selectInput(node) {
2964
+ if (ios) { // Mobile Safari apparently has a bug where select() is broken.
2965
+ node.selectionStart = 0;
2966
+ node.selectionEnd = node.value.length;
2967
+ } else node.select();
2968
+ }
2969
 
2970
  // Operations on {line, ch} objects.
2971
  function posEq(a, b) {return a.line == b.line && a.ch == b.ch;}
2974
 
2975
  var escapeElement = document.createElement("pre");
2976
  function htmlEscape(str) {
2977
+ escapeElement.textContent = str;
 
 
 
 
 
2978
  return escapeElement.innerHTML;
2979
  }
2980
+ // Recent (late 2011) Opera betas insert bogus newlines at the start
2981
+ // of the textContent, so we strip those.
2982
+ if (htmlEscape("a") == "\na")
2983
+ htmlEscape = function(str) {
2984
+ escapeElement.textContent = str;
2985
+ return escapeElement.innerHTML.slice(1);
2986
+ };
2987
+ // Some IEs don't preserve tabs through innerHTML
2988
+ else if (htmlEscape("\t") != "\t")
2989
+ htmlEscape = function(str) {
2990
+ escapeElement.innerHTML = "";
2991
+ escapeElement.appendChild(document.createTextNode(str));
2992
+ return escapeElement.innerHTML;
2993
+ };
2994
  CodeMirror.htmlEscape = htmlEscape;
2995
 
2996
  // Used to position the cursor after an undo/redo by finding the
2997
  // last edited character.
2998
  function editEnd(from, to) {
2999
+ if (!to) return 0;
3000
  if (!from) return to.length;
3001
  for (var i = from.length, j = to.length; i >= 0 && j >= 0; --i, --j)
3002
  if (from.charAt(i) != to.charAt(j)) break;
3009
  if (collection[i] == elt) return i;
3010
  return -1;
3011
  }
3012
+ function isWordChar(ch) {
3013
+ return /\w/.test(ch) || ch.toUpperCase() != ch.toLowerCase();
3014
+ }
3015
 
3016
  // See if "".split is the broken IE version, if so, provide an
3017
  // alternative way to split lines.
3018
+ var splitLines = "\n\nb".split(/\n/).length != 3 ? function(string) {
3019
+ var pos = 0, nl, result = [];
3020
+ while ((nl = string.indexOf("\n", pos)) > -1) {
3021
+ result.push(string.slice(pos, string.charAt(nl-1) == "\r" ? nl - 1 : nl));
3022
+ pos = nl + 1;
3023
+ }
3024
+ result.push(string.slice(pos));
3025
+ return result;
3026
+ } : function(string){return string.split(/\r?\n/);};
 
 
 
 
3027
  CodeMirror.splitLines = splitLines;
3028
 
3029
+ var hasSelection = window.getSelection ? function(te) {
3030
+ try { return te.selectionStart != te.selectionEnd; }
3031
+ catch(e) { return false; }
3032
+ } : function(te) {
3033
+ try {var range = te.ownerDocument.selection.createRange();}
3034
+ catch(e) {}
3035
+ if (!range || range.parentElement() != te) return false;
3036
+ return range.compareEndPoints("StartToEnd", range) != 0;
3037
+ };
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3038
 
3039
  CodeMirror.defineMode("null", function() {
3040
  return {token: function(stream) {stream.skipToEnd();}};
3041
  });
3042
  CodeMirror.defineMIME("text/plain", "null");
3043
 
3044
+ var keyNames = {3: "Enter", 8: "Backspace", 9: "Tab", 13: "Enter", 16: "Shift", 17: "Ctrl", 18: "Alt",
3045
+ 19: "Pause", 20: "CapsLock", 27: "Esc", 32: "Space", 33: "PageUp", 34: "PageDown", 35: "End",
3046
+ 36: "Home", 37: "Left", 38: "Up", 39: "Right", 40: "Down", 44: "PrintScrn", 45: "Insert",
3047
+ 46: "Delete", 59: ";", 91: "Mod", 92: "Mod", 93: "Mod", 127: "Delete", 186: ";", 187: "=", 188: ",",
3048
+ 189: "-", 190: ".", 191: "/", 192: "`", 219: "[", 220: "\\", 221: "]", 222: "'", 63276: "PageUp",
3049
+ 63277: "PageDown", 63275: "End", 63273: "Home", 63234: "Left", 63232: "Up", 63235: "Right",
3050
+ 63233: "Down", 63302: "Insert", 63272: "Delete"};
3051
+ CodeMirror.keyNames = keyNames;
3052
+ (function() {
3053
+ // Number keys
3054
+ for (var i = 0; i < 10; i++) keyNames[i + 48] = String(i);
3055
+ // Alphabetic keys
3056
+ for (var i = 65; i <= 90; i++) keyNames[i] = String.fromCharCode(i);
3057
+ // Function keys
3058
+ for (var i = 1; i <= 12; i++) keyNames[i + 111] = keyNames[i + 63235] = "F" + i;
3059
+ })();
3060
+
3061
  return CodeMirror;
3062
  })();
libraries/CodeMirror2/mode/clike/clike.js CHANGED
@@ -21,7 +21,7 @@ CodeMirror.defineMode("clike", function(config, parserConfig) {
21
  }
22
  if (/[\[\]{}\(\),;\:\.]/.test(ch)) {
23
  curPunc = ch;
24
- return null
25
  }
26
  if (/\d/.test(ch)) {
27
  stream.eatWhile(/[\w\.]/);
@@ -59,7 +59,7 @@ CodeMirror.defineMode("clike", function(config, parserConfig) {
59
  escaped = !escaped && next == "\\";
60
  }
61
  if (end || !(escaped || multiLineStrings))
62
- state.tokenize = tokenBase;
63
  return "string";
64
  };
65
  }
@@ -68,7 +68,7 @@ CodeMirror.defineMode("clike", function(config, parserConfig) {
68
  var maybeEnd = false, ch;
69
  while (ch = stream.next()) {
70
  if (ch == "/" && maybeEnd) {
71
- state.tokenize = tokenBase;
72
  break;
73
  }
74
  maybeEnd = (ch == "*");
@@ -136,7 +136,9 @@ CodeMirror.defineMode("clike", function(config, parserConfig) {
136
 
137
  indent: function(state, textAfter) {
138
  if (state.tokenize != tokenBase && state.tokenize != null) return 0;
139
- var firstChar = textAfter && textAfter.charAt(0), ctx = state.context, closing = firstChar == ctx.type;
 
 
140
  if (ctx.type == "statement") return ctx.indented + (firstChar == "{" ? 0 : indentUnit);
141
  else if (ctx.align) return ctx.column + (closing ? 0 : 1);
142
  else return ctx.indented + (closing ? 0 : indentUnit);
@@ -229,19 +231,4 @@ CodeMirror.defineMode("clike", function(config, parserConfig) {
229
  }
230
  }
231
  });
232
- CodeMirror.defineMIME("text/x-groovy", {
233
- name: "clike",
234
- keywords: words("abstract as assert boolean break byte case catch char class const continue def default " +
235
- "do double else enum extends final finally float for goto if implements import " +
236
- "in instanceof int interface long native new package property private protected public " +
237
- "return short static strictfp super switch synchronized this throw throws transient " +
238
- "try void volatile while"),
239
- atoms: words("true false null"),
240
- hooks: {
241
- "@": function(stream, state) {
242
- stream.eatWhile(/[\w\$_]/);
243
- return "meta";
244
- }
245
- }
246
- });
247
  }());
21
  }
22
  if (/[\[\]{}\(\),;\:\.]/.test(ch)) {
23
  curPunc = ch;
24
+ return null;
25
  }
26
  if (/\d/.test(ch)) {
27
  stream.eatWhile(/[\w\.]/);
59
  escaped = !escaped && next == "\\";
60
  }
61
  if (end || !(escaped || multiLineStrings))
62
+ state.tokenize = null;
63
  return "string";
64
  };
65
  }
68
  var maybeEnd = false, ch;
69
  while (ch = stream.next()) {
70
  if (ch == "/" && maybeEnd) {
71
+ state.tokenize = null;
72
  break;
73
  }
74
  maybeEnd = (ch == "*");
136
 
137
  indent: function(state, textAfter) {
138
  if (state.tokenize != tokenBase && state.tokenize != null) return 0;
139
+ var ctx = state.context, firstChar = textAfter && textAfter.charAt(0);
140
+ if (ctx.type == "statement" && firstChar == "}") ctx = ctx.prev;
141
+ var closing = firstChar == ctx.type;
142
  if (ctx.type == "statement") return ctx.indented + (firstChar == "{" ? 0 : indentUnit);
143
  else if (ctx.align) return ctx.column + (closing ? 0 : 1);
144
  else return ctx.indented + (closing ? 0 : indentUnit);
231
  }
232
  }
233
  });
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
234
  }());
libraries/CodeMirror2/mode/clike/index.html CHANGED
@@ -1,16 +1,15 @@
1
  <!doctype html>
2
  <html>
3
  <head>
4
- <title>CodeMirror 2: C-like mode</title>
5
  <link rel="stylesheet" href="../../lib/codemirror.css">
6
  <script src="../../lib/codemirror.js"></script>
7
  <script src="clike.js"></script>
8
- <link rel="stylesheet" href="../../theme/default.css">
9
- <link rel="stylesheet" href="../../css/docs.css">
10
  <style>.CodeMirror {border: 2px inset #dee;}</style>
11
  </head>
12
  <body>
13
- <h1>CodeMirror 2: C-like mode</h1>
14
 
15
  <form><textarea id="code" name="code">
16
  /* C demo code */
@@ -97,6 +96,6 @@ void* zmq_thread_init(void* zmq_context, int signal_fd) {
97
  <p><strong>MIME types defined:</strong> <code>text/x-csrc</code>
98
  (C code), <code>text/x-c++src</code> (C++
99
  code), <code>text/x-java</code> (Java
100
- code), <code>text/x-groovy</code> (Groovy code).</p>
101
  </body>
102
  </html>
1
  <!doctype html>
2
  <html>
3
  <head>
4
+ <title>CodeMirror: C-like mode</title>
5
  <link rel="stylesheet" href="../../lib/codemirror.css">
6
  <script src="../../lib/codemirror.js"></script>
7
  <script src="clike.js"></script>
8
+ <link rel="stylesheet" href="../../doc/docs.css">
 
9
  <style>.CodeMirror {border: 2px inset #dee;}</style>
10
  </head>
11
  <body>
12
+ <h1>CodeMirror: C-like mode</h1>
13
 
14
  <form><textarea id="code" name="code">
15
  /* C demo code */
96
  <p><strong>MIME types defined:</strong> <code>text/x-csrc</code>
97
  (C code), <code>text/x-c++src</code> (C++
98
  code), <code>text/x-java</code> (Java
99
+ code), <code>text/x-csharp</code> (C#).</p>
100
  </body>
101
  </html>
libraries/CodeMirror2/mode/css/css.js CHANGED
@@ -92,7 +92,7 @@ CodeMirror.defineMode("css", function(config) {
92
  var style = state.tokenize(stream, state);
93
 
94
  var context = state.stack[state.stack.length-1];
95
- if (type == "hash" && context == "rule") style = "atom";
96
  else if (style == "variable") {
97
  if (context == "rule") style = "number";
98
  else if (!context || context == "@media{") style = "tag";
92
  var style = state.tokenize(stream, state);
93
 
94
  var context = state.stack[state.stack.length-1];
95
+ if (type == "hash" && context != "rule") style = "string-2";
96
  else if (style == "variable") {
97
  if (context == "rule") style = "number";
98
  else if (!context || context == "@media{") style = "tag";
libraries/CodeMirror2/mode/css/index.html CHANGED
@@ -1,16 +1,15 @@
1
  <!doctype html>
2
  <html>
3
  <head>
4
- <title>CodeMirror 2: CSS mode</title>
5
  <link rel="stylesheet" href="../../lib/codemirror.css">
6
  <script src="../../lib/codemirror.js"></script>
7
  <script src="css.js"></script>
8
- <link rel="stylesheet" href="../../theme/default.css">
9
  <style>.CodeMirror {background: #f8f8f8;}</style>
10
- <link rel="stylesheet" href="../../css/docs.css">
11
  </head>
12
  <body>
13
- <h1>CodeMirror 2: CSS mode</h1>
14
  <form><textarea id="code" name="code">
15
  /* Some example CSS */
16
 
1
  <!doctype html>
2
  <html>
3
  <head>
4
+ <title>CodeMirror: CSS mode</title>
5
  <link rel="stylesheet" href="../../lib/codemirror.css">
6
  <script src="../../lib/codemirror.js"></script>
7
  <script src="css.js"></script>
 
8
  <style>.CodeMirror {background: #f8f8f8;}</style>
9
+ <link rel="stylesheet" href="../../doc/docs.css">
10
  </head>
11
  <body>
12
+ <h1>CodeMirror: CSS mode</h1>
13
  <form><textarea id="code" name="code">
14
  /* Some example CSS */
15
 
libraries/CodeMirror2/mode/htmlmixed/htmlmixed.js CHANGED
@@ -28,7 +28,7 @@ CodeMirror.defineMode("htmlmixed", function(config, parserConfig) {
28
  function javascript(stream, state) {
29
  if (stream.match(/^<\/\s*script\s*>/i, false)) {
30
  state.token = html;
31
- state.curState = null;
32
  state.mode = "html";
33
  return html(stream, state);
34
  }
@@ -73,11 +73,13 @@ CodeMirror.defineMode("htmlmixed", function(config, parserConfig) {
73
  },
74
 
75
  compareStates: function(a, b) {
 
 
76
  return htmlMode.compareStates(a.htmlState, b.htmlState);
77
  },
78
 
79
  electricChars: "/{}:"
80
  }
81
- });
82
 
83
  CodeMirror.defineMIME("text/html", "htmlmixed");
28
  function javascript(stream, state) {
29
  if (stream.match(/^<\/\s*script\s*>/i, false)) {
30
  state.token = html;
31
+ state.localState = null;
32
  state.mode = "html";
33
  return html(stream, state);
34
  }
73
  },
74
 
75
  compareStates: function(a, b) {
76
+ if (a.mode != b.mode) return false;
77
+ if (a.localState) return CodeMirror.Pass;
78
  return htmlMode.compareStates(a.htmlState, b.htmlState);
79
  },
80
 
81
  electricChars: "/{}:"
82
  }
83
+ }, "xml", "javascript", "css");
84
 
85
  CodeMirror.defineMIME("text/html", "htmlmixed");
libraries/CodeMirror2/mode/htmlmixed/index.html CHANGED
@@ -1,19 +1,18 @@
1
  <!doctype html>
2
  <html>
3
  <head>
4
- <title>CodeMirror 2: HTML mixed mode</title>
5
  <link rel="stylesheet" href="../../lib/codemirror.css">
6
  <script src="../../lib/codemirror.js"></script>
7
  <script src="../xml/xml.js"></script>
8
  <script src="../javascript/javascript.js"></script>
9
  <script src="../css/css.js"></script>
10
- <link rel="stylesheet" href="../../theme/default.css">
11
  <script src="htmlmixed.js"></script>
12
- <link rel="stylesheet" href="../../css/docs.css">
13
  <style>.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
14
  </head>
15
  <body>
16
- <h1>CodeMirror 2: HTML mixed mode</h1>
17
  <form><textarea id="code" name="code">
18
  <html style="color: green">
19
  <!-- this is a comment -->
1
  <!doctype html>
2
  <html>
3
  <head>
4
+ <title>CodeMirror: HTML mixed mode</title>
5
  <link rel="stylesheet" href="../../lib/codemirror.css">
6
  <script src="../../lib/codemirror.js"></script>
7
  <script src="../xml/xml.js"></script>
8
  <script src="../javascript/javascript.js"></script>
9
  <script src="../css/css.js"></script>
 
10
  <script src="htmlmixed.js"></script>
11
+ <link rel="stylesheet" href="../../doc/docs.css">
12
  <style>.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
13
  </head>
14
  <body>
15
+ <h1>CodeMirror: HTML mixed mode</h1>
16
  <form><textarea id="code" name="code">
17
  <html style="color: green">
18
  <!-- this is a comment -->
libraries/CodeMirror2/mode/javascript/index.html CHANGED
@@ -1,16 +1,15 @@
1
  <!doctype html>
2
  <html>
3
  <head>
4
- <title>CodeMirror 2: JavaScript mode</title>
5
  <link rel="stylesheet" href="../../lib/codemirror.css">
6
  <script src="../../lib/codemirror.js"></script>
7
  <script src="javascript.js"></script>
8
- <link rel="stylesheet" href="../../theme/default.css">
9
- <link rel="stylesheet" href="../../css/docs.css">
10
  <style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
11
  </head>
12
  <body>
13
- <h1>CodeMirror 2: JavaScript mode</h1>
14
 
15
  <div><textarea id="code" name="code">
16
  // Demo code (the actual new parser character stream implementation)
1
  <!doctype html>
2
  <html>
3
  <head>
4
+ <title>CodeMirror: JavaScript mode</title>
5
  <link rel="stylesheet" href="../../lib/codemirror.css">
6
  <script src="../../lib/codemirror.js"></script>
7
  <script src="javascript.js"></script>
8
+ <link rel="stylesheet" href="../../doc/docs.css">
 
9
  <style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
10
  </head>
11
  <body>
12
+ <h1>CodeMirror: JavaScript mode</h1>
13
 
14
  <div><textarea id="code" name="code">
15
  // Demo code (the actual new parser character stream implementation)
libraries/CodeMirror2/mode/javascript/javascript.js CHANGED
@@ -54,7 +54,7 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
54
  stream.eatWhile(/[\da-f]/i);
55
  return ret("number", "number");
56
  }
57
- else if (/\d/.test(ch)) {
58
  stream.match(/^\d*(?:\.\d*)?(?:[eE][+\-]?\d+)?/);
59
  return ret("number", "number");
60
  }
@@ -69,7 +69,7 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
69
  else if (state.reAllowed) {
70
  nextUntilUnescaped(stream, "/");
71
  stream.eatWhile(/[gimy]/); // 'y' is "sticky" option in Mozilla
72
- return ret("regexp", "string");
73
  }
74
  else {
75
  stream.eatWhile(isOperatorChar);
@@ -87,7 +87,7 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
87
  else {
88
  stream.eatWhile(/[\w\$_]/);
89
  var word = stream.current(), known = keywords.propertyIsEnumerable(word) && keywords[word];
90
- return known ? ret(known.type, known.style, word) :
91
  ret("variable", "variable", word);
92
  }
93
  }
@@ -230,7 +230,7 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
230
  if (atomicTypes.hasOwnProperty(type)) return cont(maybeoperator);
231
  if (type == "function") return cont(functiondef);
232
  if (type == "keyword c") return cont(maybeexpression);
233
- if (type == "(") return cont(pushlex(")"), expression, expect(")"), poplex, maybeoperator);
234
  if (type == "operator") return cont(expression);
235
  if (type == "[") return cont(pushlex("]"), commasep(expression, "]"), poplex, maybeoperator);
236
  if (type == "{") return cont(pushlex("}"), commasep(objprop, "}"), poplex, maybeoperator);
@@ -243,7 +243,7 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
243
 
244
  function maybeoperator(type, value) {
245
  if (type == "operator" && /\+\+|--/.test(value)) return cont(maybeoperator);
246
- if (type == "operator") return cont(expression);
247
  if (type == ";") return;
248
  if (type == "(") return cont(pushlex(")"), commasep(expression, ")"), poplex, maybeoperator);
249
  if (type == ".") return cont(property, maybeoperator);
@@ -316,10 +316,11 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
316
  return {
317
  tokenize: jsTokenBase,
318
  reAllowed: true,
 
319
  cc: [],
320
  lexical: new JSLexical((basecolumn || 0) - indentUnit, 0, "block", false),
321
- localVars: null,
322
- context: null,
323
  indented: 0
324
  };
325
  },
@@ -333,14 +334,16 @@ CodeMirror.defineMode("javascript", function(config, parserConfig) {
333
  if (stream.eatSpace()) return null;
334
  var style = state.tokenize(stream, state);
335
  if (type == "comment") return style;
336
- state.reAllowed = type == "operator" || type == "keyword c" || type.match(/^[\[{}\(,;:]$/);
 
337
  return parseJS(state, style, type, content, stream);
338
  },
339
 
340
  indent: function(state, textAfter) {
341
  if (state.tokenize != jsTokenBase) return 0;
342
- var firstChar = textAfter && textAfter.charAt(0), lexical = state.lexical,
343
- type = lexical.type, closing = firstChar == type;
 
344
  if (type == "vardef") return lexical.indented + 4;
345
  else if (type == "form" && firstChar == "{") return lexical.indented;
346
  else if (type == "stat" || type == "form") return lexical.indented + indentUnit;
54
  stream.eatWhile(/[\da-f]/i);
55
  return ret("number", "number");
56
  }
57
+ else if (/\d/.test(ch) || ch == "-" && stream.eat(/\d/)) {
58
  stream.match(/^\d*(?:\.\d*)?(?:[eE][+\-]?\d+)?/);
59
  return ret("number", "number");
60
  }
69
  else if (state.reAllowed) {
70
  nextUntilUnescaped(stream, "/");
71
  stream.eatWhile(/[gimy]/); // 'y' is "sticky" option in Mozilla
72
+ return ret("regexp", "string-2");
73
  }
74
  else {
75
  stream.eatWhile(isOperatorChar);
87
  else {
88
  stream.eatWhile(/[\w\$_]/);
89
  var word = stream.current(), known = keywords.propertyIsEnumerable(word) && keywords[word];
90
+ return (known && state.kwAllowed) ? ret(known.type, known.style, word) :
91
  ret("variable", "variable", word);
92
  }
93
  }
230
  if (atomicTypes.hasOwnProperty(type)) return cont(maybeoperator);
231
  if (type == "function") return cont(functiondef);
232
  if (type == "keyword c") return cont(maybeexpression);
233
+ if (type == "(") return cont(pushlex(")"), maybeexpression, expect(")"), poplex, maybeoperator);
234
  if (type == "operator") return cont(expression);
235
  if (type == "[") return cont(pushlex("]"), commasep(expression, "]"), poplex, maybeoperator);
236
  if (type == "{") return cont(pushlex("}"), commasep(objprop, "}"), poplex, maybeoperator);
243
 
244
  function maybeoperator(type, value) {
245
  if (type == "operator" && /\+\+|--/.test(value)) return cont(maybeoperator);
246
+ if (type == "operator" || type == ":") return cont(expression);
247
  if (type == ";") return;
248
  if (type == "(") return cont(pushlex(")"), commasep(expression, ")"), poplex, maybeoperator);
249
  if (type == ".") return cont(property, maybeoperator);
316
  return {
317
  tokenize: jsTokenBase,
318
  reAllowed: true,
319
+ kwAllowed: true,
320
  cc: [],
321
  lexical: new JSLexical((basecolumn || 0) - indentUnit, 0, "block", false),
322
+ localVars: parserConfig.localVars,
323
+ context: parserConfig.localVars && {vars: parserConfig.localVars},
324
  indented: 0
325
  };
326
  },
334
  if (stream.eatSpace()) return null;
335
  var style = state.tokenize(stream, state);
336
  if (type == "comment") return style;
337
+ state.reAllowed = !!(type == "operator" || type == "keyword c" || type.match(/^[\[{}\(,;:]$/));
338
+ state.kwAllowed = type != '.';
339
  return parseJS(state, style, type, content, stream);
340
  },
341
 
342
  indent: function(state, textAfter) {
343
  if (state.tokenize != jsTokenBase) return 0;
344
+ var firstChar = textAfter && textAfter.charAt(0), lexical = state.lexical;
345
+ if (lexical.type == "stat" && firstChar == "}") lexical = lexical.prev;
346
+ var type = lexical.type, closing = firstChar == type;
347
  if (type == "vardef") return lexical.indented + 4;
348
  else if (type == "form" && firstChar == "{") return lexical.indented;
349
  else if (type == "stat" || type == "form") return lexical.indented + indentUnit;
libraries/CodeMirror2/mode/less/less.js ADDED
@@ -0,0 +1,232 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ LESS mode - http://www.lesscss.org/
3
+ Ported to CodeMirror by Peter Kroon
4
+ */
5
+
6
+ CodeMirror.defineMode("less", function(config) {
7
+ var indentUnit = config.indentUnit, type;
8
+ function ret(style, tp) {type = tp; return style;}
9
+ //html5 tags
10
+ var tags = ["a","abbr","acronym","address","applet","area","article","aside","audio","b","base","basefont","bdi","bdo","big","blockquote","body","br","button","canvas","caption","cite","code","col","colgroup","command","datalist","dd","del","details","dfn","dir","div","dl","dt","em","embed","fieldset","figcaption","figure","font","footer","form","frame","frameset","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","iframe","img","input","ins","keygen","kbd","label","legend","li","link","map","mark","menu","meta","meter","nav","noframes","noscript","object","ol","optgroup","option","output","p","param","pre","progress","q","rp","rt","ruby","s","samp","script","section","select","small","source","span","strike","strong","style","sub","summary","sup","table","tbody","td","textarea","tfoot","th","thead","time","title","tr","track","tt","u","ul","var","video","wbr"];
11
+
12
+ function inTagsArray(val){
13
+ for(var i=0; i<tags.length; i++){
14
+ if(val === tags[i]){
15
+ return true;
16
+ }
17
+ }
18
+ }
19
+
20
+ function tokenBase(stream, state) {
21
+ var ch = stream.next();
22
+
23
+ if (ch == "@") {stream.eatWhile(/[\w\-]/); return ret("meta", stream.current());}
24
+ else if (ch == "/" && stream.eat("*")) {
25
+ state.tokenize = tokenCComment;
26
+ return tokenCComment(stream, state);
27
+ }
28
+ else if (ch == "<" && stream.eat("!")) {
29
+ state.tokenize = tokenSGMLComment;
30
+ return tokenSGMLComment(stream, state);
31
+ }
32
+ else if (ch == "=") ret(null, "compare");
33
+ else if ((ch == "~" || ch == "|") && stream.eat("=")) return ret(null, "compare");
34
+ else if (ch == "\"" || ch == "'") {
35
+ state.tokenize = tokenString(ch);
36
+ return state.tokenize(stream, state);
37
+ }
38
+ else if (ch == "/") { // lesscss e.g.: .png will not be parsed as a class
39
+ if(stream.eat("/")){
40
+ state.tokenize = tokenSComment
41
+ return tokenSComment(stream, state);
42
+ }else{
43
+ stream.eatWhile(/[\a-zA-Z0-9\-_.\s]/);
44
+ if(/\/|\)|#/.test(stream.peek() || stream.eol() || (stream.eatSpace() && stream.peek() == ")")))return ret("string", "string");//let url(/images/logo.png) without quotes return as string
45
+ return ret("number", "unit");
46
+ }
47
+ }
48
+ else if (ch == "!") {
49
+ stream.match(/^\s*\w*/);
50
+ return ret("keyword", "important");
51
+ }
52
+ else if (/\d/.test(ch)) {
53
+ stream.eatWhile(/[\w.%]/);
54
+ return ret("number", "unit");
55
+ }
56
+ else if (/[,+<>*\/]/.test(ch)) {//removed . dot character original was [,.+>*\/]
57
+ return ret(null, "select-op");
58
+ }
59
+ else if (/[;{}:\[\]()]/.test(ch)) { //added () char for lesscss original was [;{}:\[\]]
60
+ if(ch == ":"){
61
+ stream.eatWhile(/[active|hover|link|visited]/);
62
+ if( stream.current().match(/active|hover|link|visited/)){
63
+ return ret("tag", "tag");
64
+ }else{
65
+ return ret(null, ch);
66
+ }
67
+ }else{
68
+ return ret(null, ch);
69
+ }
70
+ }
71
+ else if (ch == ".") { // lesscss
72
+ stream.eatWhile(/[\a-zA-Z0-9\-_]/);
73
+ return ret("tag", "tag");
74
+ }
75
+ else if (ch == "#") { // lesscss
76
+ //we don't eat white-space, we want the hex color and or id only
77
+ stream.eatWhile(/[A-Za-z0-9]/);
78
+ //check if there is a proper hex color length e.g. #eee || #eeeEEE
79
+ if(stream.current().length ===4 || stream.current().length ===7){
80
+ if(stream.current().match(/[A-Fa-f0-9]{6}|[A-Fa-f0-9]{3}/,false) != null){//is there a valid hex color value present in the current stream
81
+ //when not a valid hex value, parse as id
82
+ if(stream.current().substring(1) != stream.current().match(/[A-Fa-f0-9]{6}|[A-Fa-f0-9]{3}/,false))return ret("atom", "tag");
83
+ //eat white-space
84
+ stream.eatSpace();
85
+ //when hex value declaration doesn't end with [;,] but is does with a slash/cc comment treat it as an id, just like the other hex values that don't end with[;,]
86
+ if( /[\/<>.(){!$%^&*_\-\\?=+\|#'~`]/.test(stream.peek()) )return ret("atom", "tag");
87
+ //#time { color: #aaa }
88
+ else if(stream.peek() == "}" )return ret("number", "unit");
89
+ //we have a valid hex color value, parse as id whenever an element/class is defined after the hex(id) value e.g. #eee aaa || #eee .aaa
90
+ else if( /[a-zA-Z\\]/.test(stream.peek()) )return ret("atom", "tag");
91
+ //when a hex value is on the end of a line, parse as id
92
+ else if(stream.eol())return ret("atom", "tag");
93
+ //default
94
+ else return ret("number", "unit");
95
+ }else{//when not a valid hexvalue in the current stream e.g. #footer
96
+ stream.eatWhile(/[\w\\\-]/);
97
+ return ret("atom", "tag");
98
+ }
99
+ }else{
100
+ stream.eatWhile(/[\w\\\-]/);
101
+ return ret("atom", "tag");
102
+ }
103
+ }
104
+ else if (ch == "&") {
105
+ stream.eatWhile(/[\w\-]/);
106
+ return ret(null, ch);
107
+ }
108
+ else {
109
+ stream.eatWhile(/[\w\\\-_%.{]/);
110
+ if(stream.current().match(/http|https/) != null){
111
+ stream.eatWhile(/[\w\\\-_%.{:\/]/);
112
+ return ret("string", "string");
113
+ }else if(stream.peek() == "<" || stream.peek() == ">"){
114
+ return ret("tag", "tag");
115
+ }else if( stream.peek().match(/\(/) != null ){// lessc
116
+ return ret(null, ch);
117
+ }else if (stream.peek() == "/" && state.stack[state.stack.length-1] != undefined){ // url(dir/center/image.png)
118
+ return ret("string", "string");
119
+ }else if( stream.current().match(/\-\d|\-.\d/) ){ // lesscss match e.g.: -5px -0.4 etc... only colorize the minus sign
120
+ //stream.backUp(stream.current().length-1); //commment out these 2 comment if you want the minus sign to be parsed as null -500px
121
+ //return ret(null, ch);
122
+ return ret("number", "unit");
123
+ }else if( inTagsArray(stream.current()) ){ // lesscss match html tags
124
+ return ret("tag", "tag");
125
+ }else if( /\/|[\s\)]/.test(stream.peek() || stream.eol() || (stream.eatSpace() && stream.peek() == "/")) && stream.current().indexOf(".") !== -1){
126
+ if(stream.current().substring(stream.current().length-1,stream.current().length) == "{"){
127
+ stream.backUp(1);
128
+ return ret("tag", "tag");
129
+ }//end if
130
+ if( (stream.eatSpace() && stream.peek().match(/[{<>.a-zA-Z]/) != null) || stream.eol() )return ret("tag", "tag");//e.g. button.icon-plus
131
+ return ret("string", "string");//let url(/images/logo.png) without quotes return as string
132
+ }else if( stream.eol() ){
133
+ if(stream.current().substring(stream.current().length-1,stream.current().length) == "{")stream.backUp(1);
134
+ return ret("tag", "tag");
135
+ }else{
136
+ return ret("variable", "variable");
137
+ }
138
+ }
139
+
140
+ }
141
+
142
+ function tokenSComment(stream, state) {// SComment = Slash comment
143
+ stream.skipToEnd();
144
+ state.tokenize = tokenBase;
145
+ return ret("comment", "comment");
146
+ }
147
+
148
+ function tokenCComment(stream, state) {
149
+ var maybeEnd = false, ch;
150
+ while ((ch = stream.next()) != null) {
151
+ if (maybeEnd && ch == "/") {
152
+ state.tokenize = tokenBase;
153
+ break;
154
+ }
155
+ maybeEnd = (ch == "*");
156
+ }
157
+ return ret("comment", "comment");
158
+ }
159
+
160
+ function tokenSGMLComment(stream, state) {
161
+ var dashes = 0, ch;
162
+ while ((ch = stream.next()) != null) {
163
+ if (dashes >= 2 && ch == ">") {
164
+ state.tokenize = tokenBase;
165
+ break;
166
+ }
167
+ dashes = (ch == "-") ? dashes + 1 : 0;
168
+ }
169
+ return ret("comment", "comment");
170
+ }
171
+
172
+ function tokenString(quote) {
173
+ return function(stream, state) {
174
+ var escaped = false, ch;
175
+ while ((ch = stream.next()) != null) {
176
+ if (ch == quote && !escaped)
177
+ break;
178
+ escaped = !escaped && ch == "\\";
179
+ }
180
+ if (!escaped) state.tokenize = tokenBase;
181
+ return ret("string", "string");
182
+ };
183
+ }
184
+
185
+ return {
186
+ startState: function(base) {
187
+ return {tokenize: tokenBase,
188
+ baseIndent: base || 0,
189
+ stack: []};
190
+ },
191
+
192
+ token: function(stream, state) {
193
+ if (stream.eatSpace()) return null;
194
+ var style = state.tokenize(stream, state);
195
+
196
+ var context = state.stack[state.stack.length-1];
197
+ if (type == "hash" && context == "rule") style = "atom";
198
+ else if (style == "variable") {
199
+ if (context == "rule") style = null; //"tag"
200
+ else if (!context || context == "@media{"){
201
+ style = stream.current() == "when" ? "variable" :
202
+ stream.string.match(/#/g) != undefined ? null :
203
+ /[\s,|\s\)]/.test(stream.peek()) ? "tag" : null;
204
+ }
205
+ }
206
+
207
+ if (context == "rule" && /^[\{\};]$/.test(type))
208
+ state.stack.pop();
209
+ if (type == "{") {
210
+ if (context == "@media") state.stack[state.stack.length-1] = "@media{";
211
+ else state.stack.push("{");
212
+ }
213
+ else if (type == "}") state.stack.pop();
214
+ else if (type == "@media") state.stack.push("@media");
215
+ else if (context == "{" && type != "comment") state.stack.push("rule");
216
+ return style;
217
+ },
218
+
219
+ indent: function(state, textAfter) {
220
+ var n = state.stack.length;
221
+ if (/^\}/.test(textAfter))
222
+ n -= state.stack[state.stack.length-1] == "rule" ? 2 : 1;
223
+ return state.baseIndent + n * indentUnit;
224
+ },
225
+
226
+ electricChars: "}"
227
+ };
228
+ });
229
+
230
+ CodeMirror.defineMIME("text/x-less", "less");
231
+ if (!CodeMirror.mimeModes.hasOwnProperty("text/css"))
232
+ CodeMirror.defineMIME("text/css", "less");
libraries/CodeMirror2/mode/php/index.html CHANGED
@@ -1,7 +1,7 @@
1
  <!doctype html>
2
  <html>
3
  <head>
4
- <title>CodeMirror 2: PHP mode</title>
5
  <link rel="stylesheet" href="../../lib/codemirror.css">
6
  <script src="../../lib/codemirror.js"></script>
7
  <script src="../xml/xml.js"></script>
@@ -9,12 +9,11 @@
9
  <script src="../css/css.js"></script>
10
  <script src="../clike/clike.js"></script>
11
  <script src="php.js"></script>
12
- <link rel="stylesheet" href="../../theme/default.css">
13
  <style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
14
- <link rel="stylesheet" href="../../css/docs.css">
15
  </head>
16
  <body>
17
- <h1>CodeMirror 2: PHP mode</h1>
18
 
19
  <form><textarea id="code" name="code">
20
  <?php
@@ -33,7 +32,7 @@ function hello($who) {
33
  lineNumbers: true,
34
  matchBrackets: true,
35
  mode: "application/x-httpd-php",
36
- indentUnit: 8,
37
  indentWithTabs: true,
38
  enterMode: "keep",
39
  tabMode: "shift"
1
  <!doctype html>
2
  <html>
3
  <head>
4
+ <title>CodeMirror: PHP mode</title>
5
  <link rel="stylesheet" href="../../lib/codemirror.css">
6
  <script src="../../lib/codemirror.js"></script>
7
  <script src="../xml/xml.js"></script>
9
  <script src="../css/css.js"></script>
10
  <script src="../clike/clike.js"></script>
11
  <script src="php.js"></script>
 
12
  <style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
13
+ <link rel="stylesheet" href="../../doc/docs.css">
14
  </head>
15
  <body>
16
+ <h1>CodeMirror: PHP mode</h1>
17
 
18
  <form><textarea id="code" name="code">
19
  <?php
32
  lineNumbers: true,
33
  matchBrackets: true,
34
  mode: "application/x-httpd-php",
35
+ indentUnit: 4,
36
  indentWithTabs: true,
37
  enterMode: "keep",
38
  tabMode: "shift"
libraries/CodeMirror2/mode/php/php.js CHANGED
@@ -13,11 +13,12 @@
13
  }
14
  var phpConfig = {
15
  name: "clike",
16
- keywords: keywords("abstract and array as break case catch cfunction class clone const continue declare " +
17
- "default do else elseif enddeclare endfor endforeach endif endswitch endwhile extends " +
18
- "final for foreach function global goto if implements interface instanceof namespace " +
19
- "new or private protected public static switch throw try use var while xor return" +
20
- "die echo empty exit eval include include_once isset list require require_once print unset"),
 
21
  blockKeywords: keywords("catch do else elseif for foreach if switch try while"),
22
  atoms: keywords("true false null TRUE FALSE NULL"),
23
  multiLineStrings: true,
@@ -35,51 +36,77 @@
35
  return false;
36
  },
37
  "#": function(stream, state) {
38
- stream.skipToEnd();
39
  return "comment";
 
 
 
 
 
 
 
40
  }
41
  }
42
  };
43
 
44
  CodeMirror.defineMode("php", function(config, parserConfig) {
45
- var htmlMode = CodeMirror.getMode(config, "text/html");
46
- var jsMode = CodeMirror.getMode(config, "text/javascript");
47
- var cssMode = CodeMirror.getMode(config, "text/css");
48
  var phpMode = CodeMirror.getMode(config, phpConfig);
49
 
50
  function dispatch(stream, state) { // TODO open PHP inside text/css
 
 
51
  if (state.curMode == htmlMode) {
52
- var style = htmlMode.token(stream, state.curState);
53
- if (style == "meta" && /^<\?/.test(stream.current())) {
54
  state.curMode = phpMode;
55
  state.curState = state.php;
56
- state.curClose = /^\?>/;
57
- state.mode = 'php';
 
58
  }
59
- else if (style == "tag" && stream.current() == ">" && state.curState.context) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
60
  if (/^script$/i.test(state.curState.context.tagName)) {
61
  state.curMode = jsMode;
62
  state.curState = jsMode.startState(htmlMode.indent(state.curState, ""));
63
  state.curClose = /^<\/\s*script\s*>/i;
64
- state.mode = 'javascript';
65
  }
66
  else if (/^style$/i.test(state.curState.context.tagName)) {
67
  state.curMode = cssMode;
68
  state.curState = cssMode.startState(htmlMode.indent(state.curState, ""));
69
- state.curClose = /^<\/\s*style\s*>/i;
70
- state.mode = 'css';
71
  }
72
  }
73
  return style;
74
- }
75
- else if (stream.match(state.curClose, false)) {
76
  state.curMode = htmlMode;
77
  state.curState = state.html;
78
  state.curClose = null;
79
- state.mode = 'html';
80
- return dispatch(stream, state);
 
 
 
81
  }
82
- else return state.curMode.token(stream, state.curState);
83
  }
84
 
85
  return {
@@ -87,10 +114,11 @@
87
  var html = htmlMode.startState();
88
  return {html: html,
89
  php: phpMode.startState(),
90
- curMode: parserConfig.startOpen ? phpMode : htmlMode,
91
- curState: parserConfig.startOpen ? phpMode.startState() : html,
92
- curClose: parserConfig.startOpen ? /^\?>/ : null,
93
- mode: parserConfig.startOpen ? 'php' : 'html'}
 
94
  },
95
 
96
  copyState: function(state) {
@@ -99,7 +127,9 @@
99
  if (state.curState == html) cur = htmlNew;
100
  else if (state.curState == php) cur = phpNew;
101
  else cur = CodeMirror.copyState(state.curMode, state.curState);
102
- return {html: htmlNew, php: phpNew, curMode: state.curMode, curState: cur, curClose: state.curClose};
 
 
103
  },
104
 
105
  token: dispatch,
@@ -113,7 +143,7 @@
113
 
114
  electricChars: "/{}:"
115
  }
116
- });
117
  CodeMirror.defineMIME("application/x-httpd-php", "php");
118
  CodeMirror.defineMIME("application/x-httpd-php-open", {name: "php", startOpen: true});
119
  CodeMirror.defineMIME("text/x-php", phpConfig);
13
  }
14
  var phpConfig = {
15
  name: "clike",
16
+ keywords: keywords("abstract and array as break case catch class clone const continue declare default " +
17
+ "do else elseif enddeclare endfor endforeach endif endswitch endwhile extends final " +
18
+ "for foreach function global goto if implements interface instanceof namespace " +
19
+ "new or private protected public static switch throw trait try use var while xor " +
20
+ "die echo empty exit eval include include_once isset list require require_once return " +
21
+ "print unset __halt_compiler self static parent"),
22
  blockKeywords: keywords("catch do else elseif for foreach if switch try while"),
23
  atoms: keywords("true false null TRUE FALSE NULL"),
24
  multiLineStrings: true,
36
  return false;
37
  },
38
  "#": function(stream, state) {
39
+ while (!stream.eol() && !stream.match("?>", false)) stream.next();
40
  return "comment";
41
+ },
42
+ "/": function(stream, state) {
43
+ if (stream.eat("/")) {
44
+ while (!stream.eol() && !stream.match("?>", false)) stream.next();
45
+ return "comment";
46
+ }
47
+ return false;
48
  }
49
  }
50
  };
51
 
52
  CodeMirror.defineMode("php", function(config, parserConfig) {
53
+ var htmlMode = CodeMirror.getMode(config, {name: "xml", htmlMode: true});
54
+ var jsMode = CodeMirror.getMode(config, "javascript");
55
+ var cssMode = CodeMirror.getMode(config, "css");
56
  var phpMode = CodeMirror.getMode(config, phpConfig);
57
 
58
  function dispatch(stream, state) { // TODO open PHP inside text/css
59
+ var isPHP = state.mode == "php";
60
+ if (stream.sol() && state.pending != '"') state.pending = null;
61
  if (state.curMode == htmlMode) {
62
+ if (stream.match(/^<\?\w*/)) {
 
63
  state.curMode = phpMode;
64
  state.curState = state.php;
65
+ state.curClose = "?>";
66
+ state.mode = "php";
67
+ return "meta";
68
  }
69
+ if (state.pending == '"') {
70
+ while (!stream.eol() && stream.next() != '"') {}
71
+ var style = "string";
72
+ } else if (state.pending && stream.pos < state.pending.end) {
73
+ stream.pos = state.pending.end;
74
+ var style = state.pending.style;
75
+ } else {
76
+ var style = htmlMode.token(stream, state.curState);
77
+ }
78
+ state.pending = null;
79
+ var cur = stream.current(), openPHP = cur.search(/<\?/);
80
+ if (openPHP != -1) {
81
+ if (style == "string" && /\"$/.test(cur) && !/\?>/.test(cur)) state.pending = '"';
82
+ else state.pending = {end: stream.pos, style: style};
83
+ stream.backUp(cur.length - openPHP);
84
+ } else if (style == "tag" && stream.current() == ">" && state.curState.context) {
85
  if (/^script$/i.test(state.curState.context.tagName)) {
86
  state.curMode = jsMode;
87
  state.curState = jsMode.startState(htmlMode.indent(state.curState, ""));
88
  state.curClose = /^<\/\s*script\s*>/i;
89
+ state.mode = "javascript";
90
  }
91
  else if (/^style$/i.test(state.curState.context.tagName)) {
92
  state.curMode = cssMode;
93
  state.curState = cssMode.startState(htmlMode.indent(state.curState, ""));
94
+ state.curClose = /^<\/\s*style\s*>/i;
95
+ state.mode = "css";
96
  }
97
  }
98
  return style;
99
+ } else if ((!isPHP || state.php.tokenize == null) &&
100
+ stream.match(state.curClose, isPHP)) {
101
  state.curMode = htmlMode;
102
  state.curState = state.html;
103
  state.curClose = null;
104
+ state.mode = "html";
105
+ if (isPHP) return "meta";
106
+ else return dispatch(stream, state);
107
+ } else {
108
+ return state.curMode.token(stream, state.curState);
109
  }
 
110
  }
111
 
112
  return {
114
  var html = htmlMode.startState();
115
  return {html: html,
116
  php: phpMode.startState(),
117
+ curMode: parserConfig.startOpen ? phpMode : htmlMode,
118
+ curState: parserConfig.startOpen ? phpMode.startState() : html,
119
+ curClose: parserConfig.startOpen ? /^\?>/ : null,
120
+ mode: parserConfig.startOpen ? "php" : "html",
121
+ pending: null}
122
  },
123
 
124
  copyState: function(state) {
127
  if (state.curState == html) cur = htmlNew;
128
  else if (state.curState == php) cur = phpNew;
129
  else cur = CodeMirror.copyState(state.curMode, state.curState);
130
+ return {html: htmlNew, php: phpNew, curMode: state.curMode, curState: cur,
131
+ curClose: state.curClose, mode: state.mode,
132
+ pending: state.pending};
133
  },
134
 
135
  token: dispatch,
143
 
144
  electricChars: "/{}:"
145
  }
146
+ }, "xml", "clike", "javascript", "css");
147
  CodeMirror.defineMIME("application/x-httpd-php", "php");
148
  CodeMirror.defineMIME("application/x-httpd-php-open", {name: "php", startOpen: true});
149
  CodeMirror.defineMIME("text/x-php", phpConfig);
libraries/CodeMirror2/mode/xml/index.html CHANGED
@@ -1,16 +1,15 @@
1
  <!doctype html>
2
  <html>
3
  <head>
4
- <title>CodeMirror 2: XML mode</title>
5
  <link rel="stylesheet" href="../../lib/codemirror.css">
6
  <script src="../../lib/codemirror.js"></script>
7
  <script src="xml.js"></script>
8
- <link rel="stylesheet" href="../../theme/default.css">
9
  <style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
10
- <link rel="stylesheet" href="../../css/docs.css">
11
  </head>
12
  <body>
13
- <h1>CodeMirror 2: XML mode</h1>
14
  <form><textarea id="code" name="code">
15
  &lt;html style="color: green"&gt;
16
  &lt;!-- this is a comment --&gt;
@@ -25,7 +24,7 @@
25
  </textarea></form>
26
  <script>
27
  var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
28
- mode: {name: "xml", htmlMode: true},
29
  lineNumbers: true
30
  });
31
  </script>
1
  <!doctype html>
2
  <html>
3
  <head>
4
+ <title>CodeMirror: XML mode</title>
5
  <link rel="stylesheet" href="../../lib/codemirror.css">
6
  <script src="../../lib/codemirror.js"></script>
7
  <script src="xml.js"></script>
 
8
  <style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
9
+ <link rel="stylesheet" href="../../doc/docs.css">
10
  </head>
11
  <body>
12
+ <h1>CodeMirror: XML mode</h1>
13
  <form><textarea id="code" name="code">
14
  &lt;html style="color: green"&gt;
15
  &lt;!-- this is a comment --&gt;
24
  </textarea></form>
25
  <script>
26
  var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
27
+ mode: {name: "xml", alignCDATA: true},
28
  lineNumbers: true
29
  });
30
  </script>
libraries/CodeMirror2/mode/xml/xml.js CHANGED
@@ -1,11 +1,44 @@
1
  CodeMirror.defineMode("xml", function(config, parserConfig) {
2
  var indentUnit = config.indentUnit;
3
  var Kludges = parserConfig.htmlMode ? {
4
- autoSelfClosers: {"br": true, "img": true, "hr": true, "link": true, "input": true,
5
- "meta": true, "col": true, "frame": true, "base": true, "area": true},
6
- doNotIndent: {"pre": true, "!cdata": true},
7
- allowUnquoted: true
8
- } : {autoSelfClosers: {}, doNotIndent: {"!cdata": true}, allowUnquoted: false};
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
  var alignCDATA = parserConfig.alignCDATA;
10
 
11
  // Return variables for tokenizers
@@ -27,7 +60,7 @@ CodeMirror.defineMode("xml", function(config, parserConfig) {
27
  else if (stream.match("--")) return chain(inBlock("comment", "-->"));
28
  else if (stream.match("DOCTYPE", true, true)) {
29
  stream.eatWhile(/[\w\._\-]/);
30
- return chain(inBlock("meta", ">"));
31
  }
32
  else return null;
33
  }
@@ -47,9 +80,17 @@ CodeMirror.defineMode("xml", function(config, parserConfig) {
47
  }
48
  }
49
  else if (ch == "&") {
50
- stream.eatWhile(/[^;]/);
51
- stream.eat(";");
52
- return "atom";
 
 
 
 
 
 
 
 
53
  }
54
  else {
55
  stream.eatWhile(/[^&<]/);
@@ -102,6 +143,26 @@ CodeMirror.defineMode("xml", function(config, parserConfig) {
102
  return style;
103
  };
104
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
105
 
106
  var curState, setStyle;
107
  function pass() {
@@ -127,30 +188,38 @@ CodeMirror.defineMode("xml", function(config, parserConfig) {
127
  }
128
 
129
  function element(type) {
130
- if (type == "openTag") {curState.tagName = tagName; return cont(attributes, endtag(curState.startOfLine));}
131
- else if (type == "closeTag") {
 
 
132
  var err = false;
133
  if (curState.context) {
134
- err = curState.context.tagName != tagName;
 
 
 
 
 
135
  } else {
136
  err = true;
137
  }
138
  if (err) setStyle = "error";
139
  return cont(endclosetag(err));
140
  }
141
- else if (type == "string") {
142
- if (!curState.context || curState.context.name != "!cdata") pushContext("!cdata");
143
- if (curState.tokenize == inText) popContext();
144
- return cont();
145
- }
146
- else return cont();
147
  }
148
  function endtag(startOfLine) {
149
  return function(type) {
150
  if (type == "selfcloseTag" ||
151
- (type == "endTag" && Kludges.autoSelfClosers.hasOwnProperty(curState.tagName.toLowerCase())))
 
 
 
 
 
 
152
  return cont();
153
- if (type == "endTag") {pushContext(curState.tagName, startOfLine); return cont();}
154
  return cont();
155
  };
156
  }
@@ -162,17 +231,37 @@ CodeMirror.defineMode("xml", function(config, parserConfig) {
162
  return cont(arguments.callee);
163
  }
164
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
165
 
166
  function attributes(type) {
167
- if (type == "word") {setStyle = "attribute"; return cont(attributes);}
 
 
 
 
 
168
  if (type == "equals") return cont(attvalue, attributes);
169
- if (type == "string") {setStyle = "error"; return cont(attributes);}
170
- return pass();
171
  }
172
  function attvalue(type) {
173
- if (type == "word" && Kludges.allowUnquoted) {setStyle = "string"; return cont();}
174
  if (type == "string") return cont(attvaluemaybe);
175
- return pass();
 
 
176
  }
177
  function attvaluemaybe(type) {
178
  if (type == "string") return cont(attvaluemaybe);
@@ -205,9 +294,11 @@ CodeMirror.defineMode("xml", function(config, parserConfig) {
205
  return setStyle || style;
206
  },
207
 
208
- indent: function(state, textAfter) {
209
  var context = state.context;
210
- if (context && context.noIndent) return 0;
 
 
211
  if (alignCDATA && /<!\[CDATA\[/.test(textAfter)) return 0;
212
  if (context && /^<\//.test(textAfter))
213
  context = context.prev;
@@ -230,4 +321,5 @@ CodeMirror.defineMode("xml", function(config, parserConfig) {
230
  });
231
 
232
  CodeMirror.defineMIME("application/xml", "xml");
233
- CodeMirror.defineMIME("text/html", {name: "xml", htmlMode: true});
 
1
  CodeMirror.defineMode("xml", function(config, parserConfig) {
2
  var indentUnit = config.indentUnit;
3
  var Kludges = parserConfig.htmlMode ? {
4
+ autoSelfClosers: {'area': true, 'base': true, 'br': true, 'col': true, 'command': true,
5
+ 'embed': true, 'frame': true, 'hr': true, 'img': true, 'input': true,
6
+ 'keygen': true, 'link': true, 'meta': true, 'param': true, 'source': true,
7
+ 'track': true, 'wbr': true},
8
+ implicitlyClosed: {'dd': true, 'li': true, 'optgroup': true, 'option': true, 'p': true,
9
+ 'rp': true, 'rt': true, 'tbody': true, 'td': true, 'tfoot': true,
10
+ 'th': true, 'tr': true},
11
+ contextGrabbers: {
12
+ 'dd': {'dd': true, 'dt': true},
13
+ 'dt': {'dd': true, 'dt': true},
14
+ 'li': {'li': true},
15
+ 'option': {'option': true, 'optgroup': true},
16
+ 'optgroup': {'optgroup': true},
17
+ 'p': {'address': true, 'article': true, 'aside': true, 'blockquote': true, 'dir': true,
18
+ 'div': true, 'dl': true, 'fieldset': true, 'footer': true, 'form': true,
19
+ 'h1': true, 'h2': true, 'h3': true, 'h4': true, 'h5': true, 'h6': true,
20
+ 'header': true, 'hgroup': true, 'hr': true, 'menu': true, 'nav': true, 'ol': true,
21
+ 'p': true, 'pre': true, 'section': true, 'table': true, 'ul': true},
22
+ 'rp': {'rp': true, 'rt': true},
23
+ 'rt': {'rp': true, 'rt': true},
24
+ 'tbody': {'tbody': true, 'tfoot': true},
25
+ 'td': {'td': true, 'th': true},
26
+ 'tfoot': {'tbody': true},
27
+ 'th': {'td': true, 'th': true},
28
+ 'thead': {'tbody': true, 'tfoot': true},
29
+ 'tr': {'tr': true}
30
+ },
31
+ doNotIndent: {"pre": true},
32
+ allowUnquoted: true,
33
+ allowMissing: false
34
+ } : {
35
+ autoSelfClosers: {},
36
+ implicitlyClosed: {},
37
+ contextGrabbers: {},
38
+ doNotIndent: {},
39
+ allowUnquoted: false,
40
+ allowMissing: false
41
+ };
42
  var alignCDATA = parserConfig.alignCDATA;
43
 
44
  // Return variables for tokenizers
60
  else if (stream.match("--")) return chain(inBlock("comment", "-->"));
61
  else if (stream.match("DOCTYPE", true, true)) {
62
  stream.eatWhile(/[\w\._\-]/);
63
+ return chain(doctype(1));
64
  }
65
  else return null;
66
  }
80
  }
81
  }
82
  else if (ch == "&") {
83
+ var ok;
84
+ if (stream.eat("#")) {
85
+ if (stream.eat("x")) {
86
+ ok = stream.eatWhile(/[a-fA-F\d]/) && stream.eat(";");
87
+ } else {
88
+ ok = stream.eatWhile(/[\d]/) && stream.eat(";");
89
+ }
90
+ } else {
91
+ ok = stream.eatWhile(/[\w\.\-:]/) && stream.eat(";");
92
+ }
93
+ return ok ? "atom" : "error";
94
  }
95
  else {
96
  stream.eatWhile(/[^&<]/);
143
  return style;
144
  };
145
  }
146
+ function doctype(depth) {
147
+ return function(stream, state) {
148
+ var ch;
149
+ while ((ch = stream.next()) != null) {
150
+ if (ch == "<") {
151
+ state.tokenize = doctype(depth + 1);
152
+ return state.tokenize(stream, state);
153
+ } else if (ch == ">") {
154
+ if (depth == 1) {
155
+ state.tokenize = inText;
156
+ break;
157
+ } else {
158
+ state.tokenize = doctype(depth - 1);
159
+ return state.tokenize(stream, state);
160
+ }
161
+ }
162
+ }
163
+ return "meta";
164
+ };
165
+ }
166
 
167
  var curState, setStyle;
168
  function pass() {
188
  }
189
 
190
  function element(type) {
191
+ if (type == "openTag") {
192
+ curState.tagName = tagName;
193
+ return cont(attributes, endtag(curState.startOfLine));
194
+ } else if (type == "closeTag") {
195
  var err = false;
196
  if (curState.context) {
197
+ if (curState.context.tagName != tagName) {
198
+ if (Kludges.implicitlyClosed.hasOwnProperty(curState.context.tagName.toLowerCase())) {
199
+ popContext();
200
+ }
201
+ err = !curState.context || curState.context.tagName != tagName;
202
+ }
203
  } else {
204
  err = true;
205
  }
206
  if (err) setStyle = "error";
207
  return cont(endclosetag(err));
208
  }
209
+ return cont();
 
 
 
 
 
210
  }
211
  function endtag(startOfLine) {
212
  return function(type) {
213
  if (type == "selfcloseTag" ||
214
+ (type == "endTag" && Kludges.autoSelfClosers.hasOwnProperty(curState.tagName.toLowerCase()))) {
215
+ maybePopContext(curState.tagName.toLowerCase());
216
+ return cont();
217
+ }
218
+ if (type == "endTag") {
219
+ maybePopContext(curState.tagName.toLowerCase());
220
+ pushContext(curState.tagName, startOfLine);
221
  return cont();
222
+ }
223
  return cont();
224
  };
225
  }
231
  return cont(arguments.callee);
232
  }
233
  }
234
+ function maybePopContext(nextTagName) {
235
+ var parentTagName;
236
+ while (true) {
237
+ if (!curState.context) {
238
+ return;
239
+ }
240
+ parentTagName = curState.context.tagName.toLowerCase();
241
+ if (!Kludges.contextGrabbers.hasOwnProperty(parentTagName) ||
242
+ !Kludges.contextGrabbers[parentTagName].hasOwnProperty(nextTagName)) {
243
+ return;
244
+ }
245
+ popContext();
246
+ }
247
+ }
248
 
249
  function attributes(type) {
250
+ if (type == "word") {setStyle = "attribute"; return cont(attribute, attributes);}
251
+ if (type == "endTag" || type == "selfcloseTag") return pass();
252
+ setStyle = "error";
253
+ return cont(attributes);
254
+ }
255
+ function attribute(type) {
256
  if (type == "equals") return cont(attvalue, attributes);
257
+ if (!Kludges.allowMissing) setStyle = "error";
258
+ return (type == "endTag" || type == "selfcloseTag") ? pass() : cont();
259
  }
260
  function attvalue(type) {
 
261
  if (type == "string") return cont(attvaluemaybe);
262
+ if (type == "word" && Kludges.allowUnquoted) {setStyle = "string"; return cont();}
263
+ setStyle = "error";
264
+ return (type == "endTag" || type == "selfCloseTag") ? pass() : cont();
265
  }
266
  function attvaluemaybe(type) {
267
  if (type == "string") return cont(attvaluemaybe);
294
  return setStyle || style;
295
  },
296
 
297
+ indent: function(state, textAfter, fullLine) {
298
  var context = state.context;
299
+ if ((state.tokenize != inTag && state.tokenize != inText) ||
300
+ context && context.noIndent)
301
+ return fullLine ? fullLine.match(/^(\s*)/)[0].length : 0;
302
  if (alignCDATA && /<!\[CDATA\[/.test(textAfter)) return 0;
303
  if (context && /^<\//.test(textAfter))
304
  context = context.prev;
321
  });
322
 
323
  CodeMirror.defineMIME("application/xml", "xml");
324
+ if (!CodeMirror.mimeModes.hasOwnProperty("text/html"))
325
+ CodeMirror.defineMIME("text/html", {name: "xml", htmlMode: true});
libraries/CodeMirror2/theme/ambiance.css ADDED
@@ -0,0 +1,82 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* ambiance theme for code-mirror */
2
+
3
+ /* Color scheme */
4
+
5
+ .cm-s-ambiance .cm-keyword { color: #cda869; }
6
+ .cm-s-ambiance .cm-atom { color: #CF7EA9; }
7
+ .cm-s-ambiance .cm-number { color: #78CF8A; }
8
+ .cm-s-ambiance .cm-def { color: #aac6e3; }
9
+ .cm-s-ambiance .cm-variable { color: #ffb795; }
10
+ .cm-s-ambiance .cm-variable-2 { color: #eed1b3; }
11
+ .cm-s-ambiance .cm-variable-3 { color: #faded3; }
12
+ .cm-s-ambiance .cm-property { color: #eed1b3; }
13
+ .cm-s-ambiance .cm-operator {color: #fa8d6a;}
14
+ .cm-s-ambiance .cm-comment { color: #555; font-style:italic; }
15
+ .cm-s-ambiance .cm-string { color: #8f9d6a; }
16
+ .cm-s-ambiance .cm-string-2 { color: #9d937c; }
17
+ .cm-s-ambiance .cm-meta { color: #D2A8A1; }
18
+ .cm-s-ambiance .cm-error { color: #AF2018; }
19
+ .cm-s-ambiance .cm-qualifier { color: yellow; }
20
+ .cm-s-ambiance .cm-builtin { color: #9999cc; }
21
+ .cm-s-ambiance .cm-bracket { color: #24C2C7; }
22
+ .cm-s-ambiance .cm-tag { color: #fee4ff }
23
+ .cm-s-ambiance .cm-attribute { color: #9B859D; }
24
+ .cm-s-ambiance .cm-header {color: #blue;}
25
+ .cm-s-ambiance .cm-quote { color: #24C2C7; }
26
+ .cm-s-ambiance .cm-hr { color: pink; }
27
+ .cm-s-ambiance .cm-link { color: #F4C20B; }
28
+ .cm-s-ambiance .cm-special { color: #FF9D00; }
29
+
30
+ .cm-s-ambiance .CodeMirror-matchingbracket { color: #0f0; }
31
+ .cm-s-ambiance .CodeMirror-nonmatchingbracket { color: #f22; }
32
+
33
+ .cm-s-ambiance .CodeMirror-selected {
34
+ background: rgba(255, 255, 255, 0.15);
35
+ }
36
+ .CodeMirror-focused .cm-s-ambiance .CodeMirror-selected {
37
+ background: rgba(255, 255, 255, 0.10);
38
+ }
39
+
40
+ /* Editor styling */
41
+
42
+ .cm-s-ambiance {
43
+ line-height: 1.40em;
44
+ font-family: Monaco, Menlo,"Andale Mono","lucida console","Courier New",monospace !important;
45
+ font-size: 12px;
46
+ color: #E6E1DC;
47
+ background-color: #202020;
48
+ -webkit-box-shadow: inset 0 0 10px black;
49
+ -moz-box-shadow: inset 0 0 10px black;
50
+ -o-box-shadow: inset 0 0 10px black;
51
+ box-shadow: inset 0 0 10px black;
52
+ }
53
+
54
+ .cm-s-ambiance .CodeMirror-gutter {
55
+ background: #3D3D3D;
56
+ padding: 0 5px;
57
+ text-shadow: #333 1px 1px;
58
+ border-right: 1px solid #4D4D4D;
59
+ box-shadow: 0 10px 20px black;
60
+ }
61
+
62
+ .cm-s-ambiance .CodeMirror-gutter .CodeMirror-gutter-text {
63
+ text-shadow: 0px 1px 1px #4d4d4d;
64
+ color: #222;
65
+ }
66
+
67
+ .cm-s-ambiance .CodeMirror-lines {
68
+
69
+ }
70
+
71
+ .cm-s-ambiance .CodeMirror-lines .CodeMirror-cursor {
72
+ border-left: 1px solid #7991E8;
73
+ }
74
+
75
+ .cm-s-ambiance .activeline {
76
+ background: none repeat scroll 0% 0% rgba(255, 255, 255, 0.031);
77
+ }
78
+
79
+ .cm-s-ambiance,
80
+ .cm-s-ambiance .CodeMirror-gutter {
81
+ background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMgAAADICAQAAAAHUWYVAABFFUlEQVQYGbzBCeDVU/74/6fj9HIcx/FRHx9JCFmzMyGRURhLZIkUsoeRfUjS2FNDtr6WkMhO9sm+S8maJfu+Jcsg+/o/c+Z4z/t97/vezy3z+z8ekGlnYICG/o7gdk+wmSHZ1z4pJItqapjoKXWahm8NmV6eOTbWUOp6/6a/XIg6GQqmenJ2lDHyvCFZ2cBDbmtHA043VFhHwXxClWmeYAdLhV00Bd85go8VmaFCkbVkzlQENzfBDZ5gtN7HwF0KDrTwJ0dypSOzpaKCMwQHKTIreYIxlmhXTzTWkVm+LTynZhiSBT3RZQ7aGfjGEd3qyXQ1FDymqbKxpspERQN2MiRjNZlFFQXfCNFm9nM1zpAsoYjmtRTc5ajwuaXc5xrWskT97RaKzAGe5ARHhVUsDbjKklziiX5WROcJwSNCNI+9w1Jwv4Zb2r7lCMZ4oq5C0EdTx+2GzNuKpJ+iFf38JEWkHJn9DNF7mmBDITrWEg0VWL3pHU20tSZnuqWu+R3BtYa8XxV1HO7GyD32UkOpL/yDloINFTmvtId+nmAjxRw40VMwVKiwrKLE4bK5UOVntYwhOcSSXKrJHKPJedocpGjVz/ZMIbnYUPB10/eKCrs5apqpgVmWzBYWpmtKHecJPjaUuEgRDDaU0oZghCJ6zNMQ5ZhDYx05r5v2muQdM0EILtXUsaKiQX9WMEUotagQzFbUNN6NUPC2nm5pxEWGCjMc3GdJHjSU2kORLK/JGSrkfGEIjncU/CYUnOipoYemwj8tST9NsJmB7TUVXtbUtXATJVZXBMvYeTXJfobgJUPmGMP/yFaWonaa6BcFO3nqcIqCozSZoZoSr1g4zJOzuyGnxTEX3lUEJ7WcZgme8ddaWvWJo2AJR9DZU3CUIbhCSG6ybSwN6qtJVnCU2svDTP2ZInOw2cBTrqtQahtNZn9NcJ4l2NaSmSkkP1noZWnVwkLmdUPOwLZEwy2Z3S3R+4rIG9hcbpPXHFVWcQdZkn2FOta3cKWQnNRC5g1LsJah4GCzSVsKnCOY5OAFRTBekyyryeyilhFKva75r4Mc0aWanGEaThcy31s439KKxTzJYY5WTHPU1FtIHjQU3Oip4xlNzj/lBw23dYZVliQa7WAXf4shetcQfatI+jWRDBPmyNeW6A1P5kdDgyYJlba0BIM8BZu1JfrFwItyjcAMR3K0BWOIrtMEXyhyrlVEx3ui5dUBjmB/Q3CXW85R4mBD0s7B+4q5tKUjOlb9qqmhi5AZ6GFIC5HXtOobdYGlVdMVbNJ8toNTFcHxnoL+muBagcctjWnbNMuR00uI7nQESwg5q2qqrKWIfrNUmeQocY6HuyxJV02wj36w00yhpmUFenv4p6fUkZYqLyuinx2RGOjhCXYyJF84oiU00YMOOhhquNdfbOB7gU88pY4xJO8LVdp6/q2voeB4R04vIdhSE40xZObx1HGGJ/ja0LBthFInKaLPPFzuCaYaoj8JjPME8yoyxo6zlBqkiUZYgq00OYMswbWO5NGmq+xhipxHLRW29ARjNKXO0wRnear8XSg4XFPLKEPUS1GqvyLwiuBUoa7zpZ0l5xxFwWmWZC1H5h5FwU8eQ7K+g8UcVY6TMQreVQT/8uQ8Z+ALIXnSEa2pYZQneE9RZbSBNYXfWYJzW/h/4j4Dp1tYVcFIC5019Vyi4ThPqSFCzjGWaHQTBU8q6vrVwgxP9Lkm840imWKpcLCjYTtrKuwvsKSnrvHCXGkSMk9p6lhckfRpIeis+N2PiszT+mFLspyGleUhDwcLrZqmyeylxwjBcKHEapqkmyangyLZRVOijwOtCY5SsG5zL0OwlCJ4y5KznF3EUNDDrinwiyLZRzOXtlBbK5ITHFGLp8Q0R6ab6mS7enI2cFrxOyHvOCFaT1HThS1krjCwqWeurCkk+willhCC+RSZnRXBiZaC5RXRIZYKp2lyfrHwiKPKR0JDzrdU2EFgpidawlFDR6FgXUMNa+g1FY3bUQh2cLCwosRdnuQTS/S+JVrGLeWIvtQUvONJxlqSQYYKpwoN2kaocLjdVsis4Mk80ESF2YpSkzwldjHkjFCUutI/r+EHDU8oCs6yzL3PhWiEooZdFMkymlas4AcI3KmoMMNSQ3tHzjGWCrcJJdYyZC7QFGwjRL9p+MrRkAGWzIaWCn9W0F3TsK01c2ZvQw0byvxuQU0r1lM0qJO7wW0kRIMdDTtXEdzi4VIh+EoIHm0mWtAtpCixlabgn83fKTI7anJe9ST7WIK1DMGpQmYeA58ImV6ezOGOzK2Kgq01pd60cKWiUi9Lievb/0vIDPHQ05Kzt4ddPckQBQtoaurjyHnek/nKzpQLrVgKPjIkh2v4uyezpv+Xoo7fPFXaGFp1vaLKxQ4uUpQQS5VuQs7BCq4xRJv7fwpVvvFEB3j+620haOuocqMhWd6TTPAEx+mdFNGHdranFe95WrWmIvlY4F1Dle2ECgc6cto7SryuqGGGha0tFQ5V53migUKmg6XKAo4qS3mik+0OZpAhOLeZKicacgaYcyx5hypYQE02ZA4xi/pNhOQxR4klNKyqacj+mpxnLTnnGSo85++3ZCZq6lrZkXlGEX3o+C9FieccJbZWVFjC0Yo1FZnJhoYMFoI1hEZ9r6hwg75HwzBNhbZCdJEfJwTPGzJvaKImw1yYX1HDAmpXR+ZJQ/SmgqMNVQb5vgamGwLtt7VwvP7Qk1xpiM5x5Cyv93E06MZmgs0Nya2azIKOYKCGBQQW97RmhKNKF02JZqHEJ4o58qp7X5EcZmc56trXEqzjCBZ1MFGR87Ql2tSTs6CGxS05PTzRQorkbw7aKoKXFDXsYW42VJih/q+FP2BdTzDTwVqOYB13liM50vG7wy28qagyuIXMeQI/Oqq8bcn5wJI50xH00CRntyfpL1T4hydYpoXgNiFzoIUTDZnLNRzh4TBHwbYGDvZkxmlyJloyr6tRihpeUG94GnKtIznREF0tzJG/OOr73JBcrSh1k6WuTprgLU+mnSGnv6Zge0NNz+kTDdH8nuAuTdJDCNb21LCiIuqlYbqGzT3RAoZofQfjFazkqeNWdYaGvYTM001EW2oKPvVk1ldUGSgUtHFwjKM1h9jnFcmy5lChoLNaQMGGDsYbKixlaMBmmsx1QjCfflwTfO/gckW0ruZ3jugKR3R5W9hGUWqCgxuFgsuaCHorotGKzGaeZB9DMsaTnKCpMtwTvOzhYk0rdrArKCqcaWmVk1+F372ur1YkKxgatI8Qfe1gIX9wE9FgS8ESmuABIXnRUbCapcKe+nO7slClSZFzpV/LkLncEb1qiO42fS3R855Su2mCLh62t1SYZZYVmKwIHjREF2uihTzB20JOkz7dkxzYQnK0UOU494wh+VWRc6Un2kpTaVgLDFEkJ/uhzRcI0YKGgpGWOlocBU/a4fKoJ/pEaNV6jip3+Es9VXY078rGnmAdf7t9ylPXS34RBSuYPs1UecZTU78WanhBCHpZ5sAoTz0LGZKjPf9TRypqWEiTvOFglL1fCEY3wY/++rbk7C8bWebA6p6om6PgOL2kp44TFJlVNBXae2rqqdZztOJpT87GQsE9jqCPIe9VReZuQ/CIgacsyZdCpIScSYqcZk8r+nsyCzhyfhOqHGOIvrLknC8wTpFcaYiGC/RU1NRbUeUpocQOnkRpGOrIOcNRx+1uA0UrzhSSt+VyS3SJpnFWkzNDqOFGIWcfR86DnmARTQ1HKIL33ExPiemeOhYSSjzlSUZZuE4TveoJLnBUOFof6KiysCbnAEcZgcUNTDOwkqWu3RWtmGpZwlHhJENdZ3miGz0lJlsKnjbwqSHQjpxnFDlTLLwqJPMZMjd7KrzkSG7VsxXBZE+F8YZkb01Oe00yyRK9psh5SYh29ySPKBo2ylNht7ZkZnsKenjKNJu9PNEyZpaCHv4Kt6RQsLvAVp7M9kIimmCUwGeWqLMmGuIotYMmWNpSahkhZw9FqZsVnKJhsjAHvtHMsTM9fCI06Dx/u3vfUXCqfsKRc4oFY2jMsoo/7DJDwZ1CsIKnJu+J9ldkpmiCxQx1rWjI+T9FwcWWzOuaYH0Hj7klNRVWEQpmaqosakiGNTFHdjS/qnUdmf0NJW5xsL0HhimCCZZSRzmSPTXJQ4aaztAwtZnoabebJ+htCaZ7Cm535ByoqXKbX1WRc4Eh2MkRXWzImVc96Cj4VdOKVxR84VdQsIUM8Psoou2byVHyZFuq7O8otbSQ2UAoeEWTudATLGSpZzVLlXVkPU2Jc+27lsw2jmg5T5VhbeE3BT083K9WsTTkFU/Osi0rC5lRlpwRHUiesNS0sOvmqGML1aRbPAxTJD9ZKtxuob+hhl8cwYGWpJ8nub7t5p6coYbMovZ1BTdaKn1jYD6h4GFDNFyT/Kqe1XCXphXHOKLZmuRSRdBPEfVUXQzJm5YGPGGJdvAEr7hHNdGZnuBvrpciGmopOLf5N0uVMy0FfYToJk90uUCbJupaVpO53UJXR2bVpoU00V2KOo4zMFrBd0Jtz2pa0clT5Q5L8IpQ177mWQejPMEJhuQjS10ref6HHjdEhy1P1EYR7GtO0uSsKJQYLiTnG1rVScj5lyazpqWGl5uBbRWl7m6ixGOOnEsMJR7z8J0n6KMnCdxhiNYQCoZ6CmYLnO8omC3MkW3bktlPmEt/VQQHejL3+dOE5FlPdK/Mq8hZxxJtLyRrepLThYKbLZxkSb5W52vYxNOaOxUF0yxMUPwBTYqCzy01XayYK0sJyWBLqX0MwU5CzoymRzV0EjjeUeLgDpTo6ij42ZAzvD01dHUUTPLU96MdLbBME8nFBn7zJCMtJcZokn8YoqU0FS5WFKyniHobguMcmW8N0XkWZjkyN3hqOMtS08r+/xTBwpZSZ3qiVRX8SzMHHjfUNFjgHEPmY9PL3ykEzxkSre/1ZD6z/NuznuB0RcE1TWTm9zRgfUWVJiG6yrzgmWPXC8EAR4Wxhlad0ZbgQyEz3pG5RVEwwDJH2mgKpjcTiCOzn1lfUWANFbZ2BA8balnEweJC9J0iuaeZoI+ippFCztEKVvckR2iice1JvhVytrQwUAZpgsubCPaU7xUe9vWnaOpaSBEspalykhC9bUlOMpT42ZHca6hyrqKmw/wMR8H5ZmdFoBVJb03O4UL0tSNnvIeRmkrLWqrs78gcrEn2tpcboh0UPOW3UUR9PMk4T4nnNKWmCjlrefhCwxRNztfmIQVdDElvS4m1/WuOujoZCs5XVOjtKPGokJzsYCtFYoWonSPT21DheU/wWhM19FcElwqNGOsp9Q8N/cwXaiND1MmeL1Q5XROtYYgGeFq1aTMsoMmcrKjQrOFQTQ1fmBYhmW6o8Jkjc7iDJRTBIo5kgJD5yMEYA3srCg7VFKwiVJkmRCc5ohGOKhsYMn/XBLdo5taZjlb9YAlGWRimqbCsoY7HFAXLa5I1HPRxMMsQDHFkWtRNniqT9UEeNjcE7RUlrCJ4R2CSJuqlKHWvJXjAUNcITYkenuBRB84TbeepcqTj3zZyFJzgYQdHnqfgI0ddUwS6GqWpsKWhjq9cV0vBAEMN2znq+EBfIWT+pClYw5xsTlJU6GeIBsjGmmANTzJZiIYpgrM0Oa8ZMjd7NP87jxhqGOhJlnQtjuQpB+8aEE00wZFznSJPyHxgH3HkPOsJFvYk8zqCHzTs1BYOa4J3PFU+UVRZxlHDM4YavlNUuMoRveiZA2d7grMNc2g+RbSCEKzmgYsUmWmazFJyoiOZ4KnyhKOGRzWJa0+moyV4TVHDzn51Awtqaphfk/lRQ08FX1iiqxTB/kLwd0VynKfEvI6cd4XMV5bMhZ7gZUWVzYQ6Nm2BYzxJbw3bGthEUUMfgbGeorae6DxHtJoZ6alhZ0+ytiVoK1R4z5PTrOECT/SugseEOlb1MMNR4VRNcJy+V1Hg9ONClSZFZjdHlc6W6FBLdJja2MC5hhpu0DBYEY1TFGwiFAxRRCsYkiM9JRb0JNMVkW6CZYT/2EiTGWmo8k+h4FhDNE7BvppoTSFnmCV5xZKzvcCdDo7VVPnIU+I+Rc68juApC90MwcFCsJ5hDqxgScYKreruyQwTqrzoqDCmhWi4IbhB0Yrt3RGa6GfDv52rKXWhh28dyZaWUvcZeMTBaZoSGyiCtRU5J8iviioHaErs7Jkj61syVzTTgOcUOQ8buFBTYWdL5g3T4qlpe0+wvD63heAXRfCCIed9RbCsp2CiI7raUOYOTU13N8PNHvpaGvayo4a3LLT1lDrVEPT2zLUlheB1R+ZTRfKWJ+dcocLJfi11vyJ51lLqJ0WD7tRwryezjiV5W28uJO9qykzX8JDe2lHl/9oyBwa2UMfOngpXCixvKdXTk3wrsKmiVYdZIqsoWEERjbcUNDuiaQomGoIbFdEHmsyWnuR+IeriKDVLnlawlyNHKwKlSU631PKep8J4Q+ayjkSLKYLhalNHlYvttb6fHm0p6OApsZ4l2VfdqZkjuysy6ysKLlckf1KUutCTs39bmCgEyyoasIWlVaMF7mgmWtBT8Kol5xpH9IGllo8cJdopcvZ2sImlDmMIbtDk3KIpeNiS08lQw11NFPTwVFlPP6pJ2gvRfI7gQUfmNAtf6Gs0wQxDsKGlVBdF8rCa3jzdwMaGHOsItrZk7hAyOzpK9VS06j5F49b0VNGOOfKs3lDToMsMBe9ZWtHFEgxTJLs7qrygKZjUnmCYoeAqeU6jqWuLJup4WghOdvCYJnrSkSzoyRkm5M2StQwVltPkfCAk58tET/CSg+8MUecmotMEnhBKfWBIZsg2ihruMJQaoIm+tkTLKEqspMh00w95gvFCQRtDwTT1gVDDSEVdlwqZfxoQRbK0g+tbiBZxzKlpnpypejdDwTaeOvorMk/IJE10h9CqRe28hhLbe0pMsdSwv4ZbhKivo2BjDWfL8UKJgeavwlwb5KlwhyE4u4XkGE2ytZCznKLCDZZq42VzT8HLCrpruFbIfOIINmh/qCdZ1ZBc65kLHR1Bkyf5zn6pN3SvGKIlFNGplhrO9QSXanLOMQTLCa0YJCRrCZm/CZmrLTm7WzCK4GJDiWUdFeYx1LCFg3NMd0XmCuF3Y5rITLDUsYS9zoHVzwnJoYpSTQoObyEzr4cFBNqYTopoaU/wkyLZ2lPhX/5Y95ulxGTV7KjhWrOZgl8MyUUafjYraNjNU1N3IWcjT5WzWqjwtoarHSUObGYO3GCJZpsBlnJGPd6ZYLyl1GdCA2625IwwJDP8GUKymbzuyPlZlvTUsaUh5zFDhRWFzPKKZLAlWdcQbObgF9tOqOsmB1dqcqYJmWstFbZRRI9poolmqiLnU0POvxScpah2iSL5UJNzgScY5+AuIbpO0YD3NCW+dLMszFSdFCWGqG6eVq2uYVNDdICGD6W7EPRWZEY5gpsE9rUkS3mijzzJnm6UpUFXG1hCUeVoS5WfNcFpblELL2qqrCvMvRfd45oalvKU2tiQ6ePJOVMRXase9iTtLJztPxJKLWpo2CRDcJwn2sWSLKIO1WQWNTCvpVUvOZhgSC40JD0dOctaSqzkCRbXsKlb11Oip6PCJ0IwSJM31j3akRxlP7Rwn6aGaUL0qiLnJkvB3xWZ2+Q1TfCwpQH3G0o92UzmX4o/oJNQMMSQc547wVHhdk+VCw01DFYEnTxzZKAm74QmeNNR1w6WzEhNK15VJzuCdxQ53dRUDws5KvwgBMOEgpcVNe0hZI6RXT1Jd0cyj5nsaEAHgVmGaJIlWdsc5Ui2ElrRR6jrRAttNMEAIWrTDFubkZaok7/AkzfIwfuWVq0jHzuCK4QabtLUMVPB3kJ0oyHTSVFlqMALilJf2Rf8k5aaHtMfayocLBS8L89oKoxpJvnAkDPa0qp5DAUTHKWmCcnthlou8iCKaFFLHWcINd1nyIwXqrSxMNmSs6KmoL2QrKuWtlQ5V0120xQ5vRyZS1rgFkWwhiOwiuQbR0OOVhQM9iS3tiXp4RawRPMp5tDletOOBL95MpM01dZTBM9pkn5qF010rIeHFcFZhmSGpYpTsI6nwhqe5C9ynhlpp5ophuRb6WcJFldkVnVEwwxVfrVkvnWUuNLCg5bgboFHPDlDPDmnK7hUrWiIbjadDclujlZcaokOFup4Ri1kacV6jmrrK1hN9bGwpKEBQ4Q6DvIUXOmo6U5LqQM6EPyiKNjVkPnJkDPNEaxhiFay5ExW1NXVUGqcpYYdPcGiCq7z/TSlbhL4pplWXKd7NZO5QQFrefhRQW/NHOsqcIglc4UhWklR8K0QzbAw08CBDnpbgqXdeD/QUsM4RZXDFBW6WJKe/mFPdH0LtBgiq57wFLzlyQzz82qYx5D5WJP5yVJDW01BfyHnS6HKO/reZqId1WGa4Hkh2kWodJ8i6KoIPlAj2hPt76CzXsVR6koPRzWTfKqIentatYpQw2me4AA3y1Kind3SwoOKZDcFXTwl9tWU6mfgRk9d71sKtlNwrjnYw5tC5n5LdKiGry3JKNlHEd3oaMCFHrazBPMp/uNJ+V7IudcSbeOIdjUEdwl0VHCOZo5t6YluEuaC9mQeMgSfOyKnYGFHcIeQ84yQWbuJYJpZw5CzglDH7gKnWqqM9ZTaXcN0TeYhR84eQtJT76JJ1lREe7WnnvsMmRc9FQ7SBBM9mV3lCUdmHk/S2RAMt0QjFNFqQpWjDPQ01DXWUdDBkXziKPjGEP3VP+zIWU2t7im41FOloyWzn/L6dkUy3VLDaZ6appgDLHPjJEsyvJngWEPUyVBiAaHCTEXwrLvSEbV1e1gKJniicWorC1MUrVjB3uDhJE/wgSOzk1DXpk0k73qCM8xw2UvD5kJmDUfOomqMpWCkJRlvKXGmoeBm18USjVIk04SClxTB6YrgLAPLWYK9HLUt5cmc0vYES8GnTeRc6skZbQkWdxRsIcyBRzx1DbTk9FbU0caTPOgJHhJKnOGIVhQqvKmo0llRw9sabrZkDtdg3PqaKi9oatjY8B+G371paMg6+mZFNNtQ04mWBq3rYLOmtWWQp8KJnpy9DdFensyjdqZ+yY40VJlH8wcdLzC8PZnvHMFUTZUrDTkLyQaGus5X5LzpYAf3i+e/ZlhqGqWhh6Ou6xTR9Z6oi5AZZtp7Mj2EEm8oSpxiYZCHU/1fbGdNNNRRoZMhmilEb2gqHOEJDtXkHK/JnG6IrvbPCwV3NhONVdS1thBMs1T4QOBcTWa2IzhMk2nW5Kyn9tXUtpv9RsG2msxk+ZsQzRQacJncpgke0+T8y5Fzj8BiGo7XlJjaTIlpQs7KFjpqGnKuoyEPeIKnFMkZHvopgh81ySxNFWvJWcKRs70j2FOT012IllEEO1n4pD1513Yg2ssQPOThOkvyrqHUdEXOSEsihmBbTbKX1kLBPWqWkLOqJbjB3GBIZmoa8qWl4CG/iZ7oiA72ZL7TJNeZUY7kFQftDcHHluBzRbCegzMtrRjVQpX2lgoPKKLJAkcbMl01XK2p7yhL8pCBbQ3BN2avJgKvttcrWDK3CiUOVxQ8ZP+pqXKyIxnmBymCg5vJjNfkPK4+c8cIfK8ocVt7kmfd/I5SR1hKvCzUtb+lhgc00ZaO6CyhIQP1Uv4yIZjload72PXX0OIJvnFU+0Zf6MhsJwTfW0r0UwQfW4LNLZl5HK261JCZ4qnBaAreVAS3WrjV0LBnNDUNNDToCEeFfwgcb4gOEqLRhirWkexrCEYKVV711DLYEE1XBEsp5tpTGjorkomKYF9FDXv7fR3BGwbettSxnyL53MBPjsxDZjMh+VUW9NRxq1DhVk+FSxQcaGjV9Pawv6eGByw5qzoy7xk4RsOShqjJwWKe/1pEEfzkobeD/dQJmpqedcyBTy2sr4nGNRH0c0SPWTLrqAc0OQcb/gemKgqucQT7ySWKCn2EUotoCvpZct7RO2sy/QW0IWcXd7pQRQyZVwT2USRO87uhjioTLKV2brpMUcMQRbKH/N2T+UlTpaMls6cmc6CCNy3JdYYSUzzJQ4oSD3oKLncULOiJvjBEC2oqnCJkJluCYy2ZQ5so9YYlZ1VLlQU1mXEW1jZERwj/MUSRc24TdexlqLKfQBtDTScJUV8FszXBEY5ktpD5Ur9hYB4Nb1iikw3JoYpkKX+RodRKFt53MMuRnKSpY31PwYaGaILh3wxJGz9TkTPEETxoCWZrgvOlmyMzxFEwVJE5xZKzvyJ4WxEc16Gd4Xe3Weq4XH2jKRikqOkGQ87hQnC7wBmGYLAnesX3M+S87eFATauuN+Qcrh7xIxXJbUIdMw3JGE3ylCWzrieaqCn4zhGM19TQ3z1oH1AX+pWEqIc7wNGAkULBo/ZxRaV9NNyh4Br3rCHZzbzmSfawBL0dNRwpW1kK9mxPXR9povcdrGSZK9c2k0xwFGzjuniCtRSZCZ6ccZ7gaktmgAOtKbG/JnOkJrjcQTdFMsxRQ2cLY3WTIrlCw1eWKn8R6pvt4GFDso3QoL4a3nLk3G6JrtME3dSenpx7PNFTmga0EaJTLQ061sEeQoWXhSo9LTXsaSjoJQRXeZLtDclbCrYzfzHHeaKjHCVOUkQHO3JeEepr56mhiyaYYKjjNU+Fed1wS5VlhWSqI/hYUdDOkaxiKehoyOnrCV5yBHtbWFqTHCCwtpDcYolesVR5yUzTZBb3RNMd0d6WP+SvhuBmRcGxnuQzT95IC285cr41cLGQ6aJJhmi4TMGempxeimBRQw1tFKV+8jd6KuzoSTqqDxzRtpZkurvKEHxlqXKRIjjfUNNXQsNOsRScoWFLT+YeRZVD3GRN0MdQcKqQjHDMrdGGVu3iYJpQx3WGUvfbmxwFfR20WBq0oYY7LMFhhgYtr8jpaEnaOzjawWWaTP8mMr0t/EPDPoqcnxTBI5o58L7uoWnMrpoqPwgVrlAUWE+V+TQl9rawoyP6QGAlQw2TPRX+YSkxyBC8Z6jhHkXBgQL7WII3DVFnRfCrBfxewv9D6xsyjys4VkhWb9pUU627JllV0YDNHMku/ldNMMXDEo4aFnAkk4U6frNEU4XgZUPmEKHUl44KrzmYamjAbh0JFvGnaTLPu1s9jPCwjFpYiN7z1DTOk/nc07CfDFzmCf7i+bfNHXhDtLeBXzTBT5rkMvWOIxpl4EMh2LGJBu2syDnAEx2naEhHDWMMzPZEhygyS1mS5RTJr5ZkoKbEUoYqr2kqdDUE8ztK7OaIntJkFrIECwv8LJTaVx5XJE86go8dFeZ3FN3rjabCAYpoYEeC9zzJVULBbmZhDyd7ko09ydpNZ3nm2Kee4FPPXHnYEF1nqOFEC08LUVcDvYXkJHW8gTaKCk9YGOeIJhqiE4ToPEepdp7IWFjdwnWaufGMwJJCMtUTTBBK9BGCOy2tGGrJTHIwyEOzp6aPzNMOtlZkDvcEWpP5SVNhfkvDxhmSazTJXYrM9U1E0xwFVwqZQwzJxw6+kGGGUj2FglGGmnb1/G51udRSMNlTw6GGnCcUwVcOpmsqTHa06o72sw1RL02p9z0VbnMLOaIX3QKaYKSCFQzBKEUNHTSc48k53RH9wxGMtpQa5KjjW0W0n6XCCCG4yxNNdhQ4R4l1Ff+2sSd6UFHiIEOyqqFgT01mEUMD+joy75jPhOA+oVVLm309FR4yVOlp4RhLiScNmSmaYF5Pw0STrOIoWMSR2UkRXOMp+M4SHW8o8Zoi6OZgjKOaFar8zZDzkWzvKOjkKBjmCXby8JahhjXULY4KlzgKLvAwxVGhvyd4zxB1d9T0piazmKLCVZY5sKiD0y2ZSYrkUEPUbIk+dlQ4SJHTR50k1DPaUWIdTZW9NJwnJMOECgd7ou/MnppMJ02O1VT4Wsh85MnZzcFTngpXGKo84qmwgKbCL/orR/SzJ2crA+t6Mp94KvxJUeIbT3CQu1uIdlQEOzlKfS3UMcrTiFmOuroocrZrT2AcmamOKg8YomeEKm/rlT2sociMaybaUlFhuqHCM2qIJ+rg4EcDFymiDSxzaHdPcpE62pD5kyM5SBMoA1PaUtfIthS85ig1VPiPPYXgYEMNk4Qq7TXBgo7oT57gPUdwgCHzhIVFPFU6OYJzHAX9m5oNrVjeE61miDrqQ4VSa1oiURTsKHC0IfjNwU2WzK6eqK8jWln4g15TVBnqmDteCJ501PGAocJhhqjZdtBEB6lnhLreFJKxmlKbeGrqLiSThVIbCdGzloasa6lpMQXHCME2boLpJgT7yWaemu6wBONbqGNVRS0PKIL7LckbjmQtR7K8I5qtqel+T/ChJTNIKLjdUMNIRyvOEko9YYl2cwQveBikCNawJKcLBbc7+JM92mysNvd/Fqp8a0k6CNEe7cnZrxlW0wQXaXjaktnRwNOGZKYiONwS7a1JVheq3WgJHlQUGKHKmp4KAxXR/ULURcNgoa4zhKSLpZR3kxRRb0NmD0OFn+UCS7CzI1nbP6+o4x47QZE5xRCt3ZagnYcvmpYQktXdk5YKXTzBC57kKEe0VVuiSYqapssMS3C9p2CKkHOg8B8Pa8p5atrIw3qezIWanMGa5HRDNF6RM9wcacl0N+Q8Z8hsIkSnaIIdHRUOEebAPy1zbCkhM062FCJtif7PU+UtoVXzWKqM1PxXO8cfdruhFQ/a6x3JKYagvVDhQEtNiyiiSQ7OsuRsZUku0CRNDs4Sog6KKjsZgk2bYJqijgsEenoKeniinRXBn/U3lgpPdyDZynQx8IiioMnCep5Ky8mjGs6Wty0l1hUQTcNWswS3WRp2kCNZwJG8omG8JphPUaFbC8lEfabwP7VtM9yoaNCAjpR41VNhrD9LkbN722v0CoZMByFzhaW+MyzRYEWFDQwN2M4/JiT76PuljT3VU/A36eaIThb+R9oZGOAJ9tewkgGvqOMNRWYjT/Cwu99Q8LqDE4TgbLWxJ1jaDDAERsFOFrobgjUsBScaguXU8kKm2RL19tRypSHnHNlHiIZqgufs4opgQdVdwxBNNFBR6kVFqb8ogimOzB6a6HTzrlDHEpYaxjiiA4TMQobkDg2vejjfwJGWmnbVFAw3H3hq2NyQfG7hz4aC+w3BbwbesG0swYayvpAs6++Ri1Vfzx93mFChvyN5xVHTS+0p9aqCAxyZ6ZacZyw5+7uuQkFPR9DDk9NOiE7X1PCYJVjVUqq7JlrHwWALF5nfHNGjApdpqgzx5OwilDhCiDYTgnc9waGW4BdLNNUQvOtpzDOWHDH8D7TR/A/85KljEQu3NREc4Pl/6B1Hhc8Umb5CsKMmGC9EPcxoT2amwHNCmeOEnOPbklnMkbOgIvO5UMOpQrS9UGVdt6iH/fURjhI/WOpaW9OKLYRod6HCUEdOX000wpDZQ6hwg6LgZfOqo1RfT/CrJzjekXOGhpc1VW71ZLbXyyp+93ILbC1kPtIEYx0FIx1VDrLoVzXRKRYWk809yYlC9ImcrinxtabKnzRJk3lAU1OLEN1j2zrYzr2myHRXJFf4h4QKT1qSTzTB5+ZNTzTRkAxX8FcLV2uS8eoQQ2aAkFzvCM72sJIcJET3WPjRk5wi32uSS9rfZajpWEvj9hW42F4o5NytSXYy8IKHay10VYdrcl4SkqscrXpMwyGOgtkajheSxdQqmpxP1L3t4R5PqasFnrQEjytq6qgp9Y09Qx9o4S1FzhUCn1kyHSzBWLemoSGvOqLNhZyBjmCaAUYpMgt4Ck7wBBMMwWKWgjsUwTaGVsxWC1mYoKiyqqeGKYqonSIRQ3KIkHO0pmAxTdBHkbOvfllfr+AA+7gnc50huVKYK393FOyg7rbPO/izI7hE4CnHHHnJ0ogNPRUGeUpsrZZTBJcrovUcJe51BPsr6GkJdhCCsZ6aTtMEb2pqWkqeVtDXE/QVggsU/Nl86d9RMF3DxvZTA58agu810RWawCiSzzXBeU3MMW9oyJUedvNEvQyNu1f10BSMddR1vaLCYpYa/mGocLSiYDcLbQz8aMn5iyF4xBNMs1P0QEOV7o5gaWGuzSeLue4tt3ro7y4Tgm4G/mopdZgl6q0o6KzJWE3mMksNr3r+a6CbT8g5wZNzT9O7fi/zpaOmnz3BRoqos+tv9zMbdpxsqDBOEewtJLt7cg5wtKKbvldpSzRRCD43VFheCI7yZLppggMVBS/KMAdHODJvOwq2NQSbKKKPLdFWQs7Fqo+mpl01JXYRgq8dnGLhTiFzqmWsUMdpllZdbKlyvSdYxhI9YghOtxR8LgSLWHK62mGGVoxzBE8LNWzqH9CUesQzFy5RQzTc56mhi6fgXEWwpKfE5Z7M05ZgZUPmo6auiv8YKzDYwWBLMErIbKHJvOwIrvEdhOBcQ9JdU1NHQ7CXn2XIDFBKU2WAgcX9UAUzDXWd5alwuyJ41Z9rjKLCL4aCp4WarhPm2rH+SaHUYE001JDZ2ZAzXPjdMpZWvC9wmqIB2lLhQ01D5jO06hghWMndbM7yRJMsoCj1vYbnFQVrW9jak3OlEJ3s/96+p33dEPRV5GxiqaGjIthUU6FFEZyqCa5qJrpBdzSw95IUnOPIrCUUjRZQFrbw5PR0R1qiYx3cb6nrWUMrBmmiBQxVHtTew5ICP/ip6g4hed/Akob/32wvBHsIOX83cI8hGeNeNPCIkPmXe8fPKx84OMSRM1MTdXSwjCZ4S30jVGhvqTRak/OVhgGazHuOCud5onEO1lJr6ecVyaOK6H7zqlBlIaHE0oroCgfvGJIdPcmfLNGLjpz7hZwZQpUbFME0A1cIJa7VNORkgfsMBatbKgwwJM9bSvQXeNOvbIjelg6WWvo5kvbKaJJNHexkKNHL9xRyFlH8Ti2riB5wVPhUk7nGkJnoCe428LR/wRGdYIlmWebCyxou1rCk4g/ShugBDX0V0ZQWkh0dOVsagkM0yV6OoLd5ye+pRlsCr0n+KiQrGuq5yJDzrTAXHtLUMduTDBVKrSm3eHL+6ijxhFDX9Z5gVU/wliHYTMiMFpKLNMEywu80wd3meoFmt6VbRMPenhrOc6DVe4pgXU8DnnHakLOIIrlF4FZPIw6R+zxBP0dyq6OOZ4Q5sLKCcz084ok+VsMMyQhNZmmBgX5xIXOEJTmi7VsGTvMTNdHHhpzdbE8Du2oKxgvBqQKdDDnTFOylCFaxR1syz2iqrOI/FEpNc3C6f11/7+ASS6l2inq2ciTrCCzgyemrCL5SVPjQkdPZUmGy2c9Sw9FtR1sS30RmsKPCS4rkIC/2U0MduwucYolGaPjKEyhzmiPYXagyWbYz8LWBDdzRimAXzxx4z8K9hpzlhLq+NiQ97HuKorMUfK/OVvC2JfiHUPCQI/q7J2gjK+tTDNxkCc4TMssqCs4TGtLVwQihyoAWgj9bosU80XGW6Ac9TJGziaUh5+hnFcHOnlaM1iRn29NaqGENTTTSUHCH2tWTeV0osUhH6psuVLjRUmGWhm6OZEshGeNowABHcJ2Bpy2ZszRcKkRXd2QuKVEeXnbfaEq825FguqfgfE2whlChSRMdron+LATTPQ2Z369t4B9C5gs/ylzv+CMmepIDPclFQl13W0rspPd1JOcbghGOEutqCv5qacURQl3dDKyvyJlqKXGPgcM9FfawJAMVmdcspcYKOZc4GjDYkFlK05olNMHyHn4zFNykyOxt99RkHlfwmiHo60l2EKI+mhreEKp080Tbug08BVPcgoqC5zWt+NLDTZ7oNSF51N1qie7Va3uCCwyZbkINf/NED6jzOsBdZjFN8oqG3wxVunqCSYYKf3EdhJyf9YWGf7tRU2oH3VHgPr1fe5J9hOgHd7xQ0y7qBwXr23aGErP0cm64JVjZwsOGqL+mhNgZmhJLW2oY4UhedsyBgzrCKrq7BmcpNVhR6jBPq64Vgi+kn6XE68pp8J5/+0wRHGOpsKenQn9DZntPzjRLZpDAdD2fnSgkG9tmIXnUwQ6WVighs7Yi2MxQ0N3CqYaCXkJ0oyOztMDJjmSSpcpvlrk0RMMOjmArQ04PRV1DO1FwhCVaUVPpKUM03JK5SxPsIWRu8/CGHi8UHChiqGFDTbSRJWeYUDDcH6vJWUxR4k1FXbMUwV6e4AJFXS8oMqsZKqzvYQ9DDQdZckY4aGsIhtlubbd2r3j4QBMoTamdPZk7O/Bf62lacZwneNjQoGcdVU7zJOd7ghsUHOkosagic6cnWc8+4gg285R6zZP5s1/LUbCKIznTwK36PkdwlOrl4U1LwfdCCa+IrvFkmgw1PCAUXKWo0sURXWcI2muKJlgyFzhynCY4RBOsqCjoI1R5zREco0n2Vt09BQtYSizgKNHfUmUrQ5UOCh51BFcLmY7umhYqXKQomOop8bUnWNNQcIiBcYaC6xzMNOS8JQQfeqKBmmglB+97ok/lfk3ygaHSyZaCRTzRxQo6GzLfa2jWBPepw+UmT7SQEJyiyRkhBLMVOfcoMjcK0eZChfUNzFAUzCsEN5vP/X1uP/n/aoMX+K+nw/Hjr/9xOo7j7Pju61tLcgvJpTWXNbfN5jLpi6VfCOviTktKlFusQixdEKWmEBUKNaIpjZRSSOXSgzaaKLdabrm1/9nZ+/f+vd/vz/v9+Xy+zZ7PRorYoZqyLrCwQdEAixxVOEXNNnjX2nUSRlkqGmWowk8lxR50JPy9Bo6qJXaXwNvREBvnThPEPrewryLhcAnj5WE15Fqi8W7R1sAuEu86S4ENikItFN4xkv9Af4nXSnUVcLiA9xzesFpivRRVeFKtsMRaKBhuSbjOELnAUtlSQUpXgdfB4Z1oSbnFEetbQ0IrAe+Y+pqnDcEJFj6S8LDZzZHwY4e3XONNlARraomNEt2bkvGsosA3ioyHm+6jCMbI59wqt4eeara28IzEmyPgoRaUOEDhTVdEJhmCoTWfC0p8aNkCp0oYqih2iqGi4yXeMkOsn4LdLLnmKfh/YogjNsPebeFGR4m9BJHLzB61XQ3BtpISfS2FugsK9FAtLWX1dCRcrCnUp44CNzuCowUZmxSRgYaE6Za0W2u/E7CVXCiI/UOR8aAm1+OSyE3mOUcwyc1zBBeoX1kiKy0Zfxck1Gsyulti11i83QTBF5Kg3pDQThFMVHiPSlK+0cSedng/VaS8bOZbtsBcTcZAR8JP5KeqQ1OYKAi20njdNNRpgnsU//K+JnaXJaGTomr7aYIphoRn9aeShJWKEq9LcozSF7QleEfDI5LYm5bgVkFkRwVDBCVu0DDIkGupo8TZBq+/pMQURYErJQmPKGKjNDkWOLx7Jd5QizdUweIaKrlP7SwJDhZvONjLkOsBBX9UpGxnydhXkfBLQ8IxgojQbLFnJf81JytSljclYYyEFyx0kVBvKWOFJmONpshGAcsduQY5giVNCV51eOdJYo/pLhbvM0uDHSevNKRcrKZIqnCtJeEsO95RoqcgGK4ocZcho1tTYtcZvH41pNQ7vA0WrhIfOSraIIntIAi+NXWCErdbkvrWwjRLrt0NKUdL6KSOscTOdMSOUtBHwL6OLA0vNSdynaWQEnCpIvKaIrJJEbvHkmuNhn6OjM8VkSGSqn1uYJCGHnq9I3aLhNME3t6GjIkO7xrNFumpyTNX/NrwX7CrIRiqqWijI9JO4d1iieykyfiposQIQ8YjjsjlBh6oHWbwRjgYJQn2NgSnNycmJAk3NiXhx44Sxykihxm8ybUwT1OVKySc7vi3OXVkdBJ4AyXBeksDXG0IhgtYY0lY5ahCD0ehborIk5aUWRJviMA7Xt5kyRjonrXENkm8yYqgs8VzgrJmClK20uMM3jRJ0FiQICQF9hdETlLQWRIb5ki6WDfWRPobvO6a4GP5mcOrNzDFELtTkONLh9dXE8xypEg7z8A9jkhrQ6Fhjlg/QVktJXxt4WXzT/03Q8IaQWSqIuEvloQ2mqC9Jfi7wRul4RX3pSPlzpoVlmCtI2jvKHCFhjcM3sN6lqF6HxnKelLjXWbwrpR4xzuCrTUZx2qq9oAh8p6ixCUGr78g8oyjRAtB5CZFwi80VerVpI0h+IeBxa6Zg6kWvpDHaioYYuEsRbDC3eOmC2JvGYLeioxGknL2UATNJN6hmtj1DlpLvDVmocYbrGCVJKOrg4X6DgddLA203BKMFngdJJFtFd7vJLm6KEpc5yjQrkk7M80SGe34X24nSex1Ra5Omgb71JKyg8SrU3i/kARKwWpH0kOGhKkObyfd0ZGjvyXlAkVZ4xRbYJ2irFMkFY1SwyWxr2oo4zlNiV+7zmaweFpT4kR3kaDAFW6xpSqzJay05FtYR4HmZhc9UxKbbfF2V8RG1MBmSaE+kmC6JnaRXK9gsiXhJHl/U0qM0WTcbyhwkYIvFGwjSbjfwhiJt8ZSQU+Bd5+marPMOkVkD0muxYLIfEuhh60x/J92itguihJSEMySVPQnTewnEm+620rTQEMsOfo4/kP/0ARvWjitlpSX7GxBgcMEsd3EEeYWvdytd+Saawi6aCIj1CkGb6Aj9rwhx16Cf3vAwFy5pyLhVonXzy51FDpdEblbkdJbUcEPDEFzQ8qNmhzzLTmmKWKbFCXeEuRabp6rxbvAtLF442QjQ+wEA9eL1xSR7Q0JXzlSHjJ4exq89yR0laScJ/FW6z4a73pFMEfDiRZvuvijIt86RaSFOl01riV2mD1UEvxGk/Geg5aWwGki1zgKPG9J2U8PEg8qYvMsZeytiTRXBMslCU8JSlxi8EabjwUldlDNLfzTUmCgxWsjqWCOHavYAqsknKFIO0yQ61VL5AVFxk6WhEaCAkdJgt9aSkzXlKNX2jEa79waYuc7gq0N3GDJGCBhoiTXUEPsdknCUE1CK0fwsiaylSF2uiDyO4XX3pFhNd7R4itFGc0k/ElBZwWvq+GC6szVeEoS/MZ+qylwpKNKv9Z469UOjqCjwlusicyTxG6VpNxcQ8IncoR4RhLbR+NdpGGmJWOcIzJGUuKPGpQg8rrG21dOMqQssJQ4RxH5jaUqnZuQ0F4Q+cjxLwPtpZbIAk3QTJHQWBE5S1BokoVtDd6lhqr9UpHSUxMcIYl9pojsb8h4SBOsMQcqvOWC2E8EVehqiJ1hrrAEbQxeK0NGZ0Gkq+guSRgniM23bIHVkqwx4hiHd7smaOyglyIyQuM978j4VS08J/A2G1KeMBRo4fBaSNhKUEZfQewVQ/C1I+MgfbEleEzCUw7mKXI0M3hd1EESVji8x5uQ41nxs1q4RMJCCXs7Iq9acpxn22oSDnQ/sJTxsCbHIYZiLyhY05TY0ZLIOQrGaSJDDN4t8pVaIrsqqFdEegtizc1iTew5Q4ayBDMUsQMkXocaYkc0hZua412siZ1rSXlR460zRJ5SlHGe5j801RLMlJTxtaOM3Q1pvxJ45zUlWFD7rsAbpfEm1JHxG0eh8w2R7QQVzBUw28FhFp5QZzq8t2rx2joqulYTWSuJdTYfWwqMFMcovFmSyJPNyLhE4E10pHzYjOC3huArRa571ZsGajQpQx38SBP5pyZB6lMU3khDnp0MBV51BE9o2E+TY5Ml2E8S7C0o6w1xvCZjf0HkVEHCzFoyNmqC+9wdcqN+Tp7jSDheE9ws8Y5V0NJCn2bk2tqSY4okdrEhx1iDN8cSudwepWmAGXKcJXK65H9to8jYQRH7SBF01ESUJdd0TayVInaWhLkOjlXE5irKGOnI6GSWGCJa482zBI9rCr0jyTVcEuzriC1vcr6mwFGSiqy5zMwxBH/TJHwjSPhL8+01kaaSUuMFKTcLEvaUePcrSmwn8DZrgikWb7CGPxkSjhQwrRk57tctmxLsb9sZvL9LSlyuSLlWkqOjwduo8b6Uv1DkmudIeFF2dHCgxVtk8dpIvHpBxhEOdhKk7OLIUSdJ+cSRY57B+0DgGUUlNfpthTfGkauzxrvTsUUaCVhlKeteTXCoJDCa2NOKhOmC4G1H8JBd4OBZReSRGkqcb/CO1PyLJTLB4j1q8JYaIutEjSLX8YKM+a6phdMsdLFUoV5RTm9JSkuDN8WcIon0NZMNZWh1q8C7SJEwV5HxrmnnTrf3KoJBlmCYI2ilSLlfEvlE4011NNgjgthzEua0oKK7JLE7HZHlEl60BLMVFewg4EWNt0ThrVNEVkkiTwpKXSWJzdRENgvKGq4IhjsiezgSFtsfCUq8qki5S1LRQeYQQ4nemmCkImWMw3tFUoUBZk4NOeZYEp4XRKTGa6wJjrWNHBVJR4m3FCnbuD6aak2WsMTh3SZImGCIPKNgsDpVwnsa70K31lCFJZYcwwSMFcQulGTsZuEaSdBXkPGZhu0FsdUO73RHjq8MPGGIfaGIbVTk6iuI3GFgucHrIQkmWSJdBd7BBu+uOryWAhY7+Lki9rK5wtEQzWwvtbqGhIMFwWRJsElsY4m9IIg9L6lCX0VklaPAYkfkZEGDnOWowlBJjtMUkcGK4Lg6EtoZInMUBVYLgn0UsdmCyCz7gIGHFfk+k1QwTh5We7A9x+IdJ6CvIkEagms0hR50eH9UnTQJ+2oiKyVlLFUE+8gBGu8MQ3CppUHesnjTHN4QB/UGPhCTHLFPHMFrCqa73gqObUJGa03wgbhHkrCfpEpzNLE7JDS25FMKhlhKKWKfCgqstLCPu1zBXy0J2ztwjtixBu8UTRn9LVtkmCN2iyFhtME70JHRQ1KVZXqKI/KNIKYMCYs1GUMEKbM1bKOI9LDXC7zbHS+bt+1MTWS9odA9DtrYtpbImQJ2VHh/lisEwaHqUk1kjKTAKknkBEXkbkdMGwq0dnhzLJF3NJH3JVwrqOB4Sca2hti75nmJN0WzxS6UxDYoEpxpa4htVlRjkYE7DZGzJVU72uC9IyhQL4i8YfGWSYLLNcHXloyz7QhNifmKSE9JgfGmuyLhc403Xm9vqcp6gXe3xuuv8F6VJNxkyTHEkHG2g0aKXL0MsXc1bGfgas2//dCONXiNLCX+5mB7eZIl1kHh7ajwpikyzlUUWOVOsjSQlsS+M0R+pPje/dzBXRZGO0rMtgQrLLG9VSu9n6CMXS3BhwYmSoIBhsjNBmZbgusE9BCPCP5triU4VhNbJfE+swSP27aayE8tuTpYYjtrYjMVGZdp2NpS1s6aBnKSHDsbKuplKbHM4a0wMFd/5/DmGyKrJSUaW4IBrqUhx0vyfzTBBLPIUcnZdrAkNsKR0sWRspumSns6Ch0v/qqIbBYUWKvPU/CFoyrDJGwSNFhbA/MlzKqjrO80hRbpKx0Jewsi/STftwGSlKc1JZyAzx05dhLEdnfQvhZOqiHWWEAHC7+30FuRcZUgaO5gpaIK+xsiHRUsqaPElTV40xQZQ107Q9BZE1nryDVGU9ZSQ47bmhBpLcYpUt7S+xuK/FiT8qKjwXYw5ypS2iuCv7q1gtgjhuBuB8LCFY5cUuCNtsQOFcT+4Ih9JX+k8Ea6v0iCIRZOtCT0Et00JW5UeC85Cg0ScK0k411HcG1zKtre3SeITBRk7WfwDhEvaYLTHP9le0m8By0JDwn4TlLW/aJOvGHxdjYUes+ScZigCkYQdNdEOhkiezgShqkx8ueKjI8lDfK2oNiOFvrZH1hS+tk7NV7nOmLHicGWEgubkXKdwdtZknCLJXaCpkrjZBtLZFsDP9CdxWsSr05Sxl6CMmoFbCOgryX40uDtamB7SVmXW4Ihlgpmq+00tBKUUa83WbjLUNkzDmY7cow1JDygyPGlhgGKYKz4vcV7QBNbJIgM11TUqZaMdwTeSguH6rOaw1JRKzaaGyxVm2EJ/uCIrVWUcZUkcp2grMsEjK+DMwS59jQk3Kd6SEq1d0S6uVmO4Bc1lDXTUcHjluCXEq+1OlBDj1pi9zgiXxnKuE0SqTXwhqbETW6RggMEnGl/q49UT2iCzgJvRwVXS2K/d6+ZkyUl7jawSVLit46EwxVljDZwoSQ20sDBihztHfk2yA8NVZghiXwrYHQdfKAOtzsayjhY9bY0yE2CWEeJ9xfzO423xhL5syS2TFJofO2pboHob0nY4GiAgRrvGQEDa/FWSsoaaYl0syRsEt3kWoH3B01shCXhTUWe9w3Bt44SC9QCh3eShQctwbaK2ApLroGCMlZrYqvlY3qYhM0aXpFkPOuoqJ3Dm6fxXrGwVF9gCWZagjPqznfkuMKQ8DPTQRO8ZqG1hPGKEm9IgpGW4DZDgTNriTxvFiq+Lz+0cKfp4wj6OCK9JSnzNSn9LFU7UhKZZMnYwcJ8s8yRsECScK4j5UOB95HFO0CzhY4xJxuCix0lDlEUeMdS6EZBkTsUkZ4K74dugyTXS7aNgL8aqjDfkCE0ZbwkCXpaWCKhl8P7VD5jxykivSyxyZrYERbe168LYu9ZYh86IkscgVLE7tWPKmJv11CgoyJltMEbrohtVAQfO4ImltiHEroYEs7RxAarVpY8AwXMcMReFOTYWe5iiLRQxJ5Q8DtJ8LQhWOhIeFESPGsILhbNDRljNbHzNRlTFbk2S3L0NOS6V1KFJYKUbSTcIIhM0wQ/s2TM0SRMNcQmSap3jCH4yhJZKSkwyRHpYYgsFeQ4U7xoCB7VVOExhXepo9ABBsYbvGWKXPME3lyH95YioZ0gssQRWWbI+FaSMkXijZXwgiTlYdPdkNLaETxlyDVIwqeaEus0aTcYcg0RVOkpR3CSJqIddK+90JCxzsDVloyrFd5ZAr4TBKfaWa6boEA7C7s6EpYaeFPjveooY72mjIccLHJ9HUwVlDhKkmutJDJBwnp1rvulJZggKDRfbXAkvC/4l3ozQOG9a8lxjx0i7nV4jSXc7vhe3OwIxjgSHjdEhhsif9YkPGlus3iLFDnWOFhtCZbJg0UbQcIaR67JjthoCyMEZRwhiXWyxO5QxI6w5NhT4U1WsJvDO60J34fW9hwzwlKij6ZAW9ne4L0s8C6XeBMEkd/LQy1VucBRot6QMlbivaBhoBgjqGiCJNhsqVp/S2SsG6DIONCR0dXhvWbJ+MRRZJkkuEjgDXJjFQW6SSL7GXK8Z2CZg7cVsbWGoKmEpzQ5elpiy8Ryg7dMkLLUEauzeO86CuwlSOlgYLojZWeJ9xM3S1PWfEfKl5ISLQ0MEKR8YOB2QfCxJBjrKPCN4f9MkaSsqoVXJBmP7EpFZ9UQfOoOFwSzBN4MQ8LsGrymlipcJQhmy0GaQjPqCHaXRwuCZwRbqK2Fg9wlClZqYicrIgMdZfxTQ0c7TBIbrChxmuzoKG8XRaSrIhhiyNFJkrC7oIAWMEOQa5aBekPCRknCo4IKPrYkvCDI8aYmY7WFtprgekcJZ3oLIqssCSMtFbQTJKwXYy3BY5oCh2iKPCpJOE+zRdpYgi6O2KmOAgvVCYaU4ySRek1sgyFhJ403QFHiVEmJHwtybO1gs8Hr5+BETQX3War0qZngYGgtVZtoqd6vFSk/UwdZElYqyjrF4HXUeFspIi9IGKf4j92pKGAdCYMVsbcV3kRF0N+R8LUd5PCsIGWoxDtBkCI0nKofdJQxT+LtZflvuc8Q3CjwWkq8KwUpHzkK/NmSsclCL0nseQdj5FRH5CNHSgtLiW80Of5HU9Hhlsga9bnBq3fEVltKfO5IaSTmGjjc4J0otcP7QsJUSQM8pEj5/wCuUuC2DWz8AAAAAElFTkSuQmCC");
82
+ }
libraries/CodeMirror2/theme/blackboard.css ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* Port of TextMate's Blackboard theme */
2
+
3
+ .cm-s-blackboard { background: #0C1021; color: #F8F8F8; }
4
+ .cm-s-blackboard .CodeMirror-selected { background: #253B76 !important; }
5
+ .cm-s-blackboard .CodeMirror-gutter { background: #0C1021; border-right: 0; }
6
+ .cm-s-blackboard .CodeMirror-gutter-text { color: #888; }
7
+ .cm-s-blackboard .CodeMirror-cursor { border-left: 1px solid #A7A7A7 !important; }
8
+
9
+ .cm-s-blackboard .cm-keyword { color: #FBDE2D; }
10
+ .cm-s-blackboard .cm-atom { color: #D8FA3C; }
11
+ .cm-s-blackboard .cm-number { color: #D8FA3C; }
12
+ .cm-s-blackboard .cm-def { color: #8DA6CE; }
13
+ .cm-s-blackboard .cm-variable { color: #FF6400; }
14
+ .cm-s-blackboard .cm-operator { color: #FBDE2D;}
15
+ .cm-s-blackboard .cm-comment { color: #AEAEAE; }
16
+ .cm-s-blackboard .cm-string { color: #61CE3C; }
17
+ .cm-s-blackboard .cm-string-2 { color: #61CE3C; }
18
+ .cm-s-blackboard .cm-meta { color: #D8FA3C; }
19
+ .cm-s-blackboard .cm-error { background: #9D1E15; color: #F8F8F8; }
20
+ .cm-s-blackboard .cm-builtin { color: #8DA6CE; }
21
+ .cm-s-blackboard .cm-tag { color: #8DA6CE; }
22
+ .cm-s-blackboard .cm-attribute { color: #8DA6CE; }
23
+ .cm-s-blackboard .cm-header { color: #FF6400; }
24
+ .cm-s-blackboard .cm-hr { color: #AEAEAE; }
25
+ .cm-s-blackboard .cm-link { color: #8DA6CE; }
libraries/CodeMirror2/theme/cobalt.css CHANGED
@@ -1,5 +1,5 @@
1
  .cm-s-cobalt { background: #002240; color: white; }
2
- .cm-s-cobalt span.CodeMirror-selected { background: #b36539 !important; }
3
  .cm-s-cobalt .CodeMirror-gutter { background: #002240; border-right: 1px solid #aaa; }
4
  .cm-s-cobalt .CodeMirror-gutter-text { color: #d0d0d0; }
5
  .cm-s-cobalt .CodeMirror-cursor { border-left: 1px solid white !important; }
@@ -15,3 +15,4 @@
15
  .cm-s-cobalt span.cm-error { color: #9d1e15; }
16
  .cm-s-cobalt span.cm-bracket { color: #d8d8d8; }
17
  .cm-s-cobalt span.cm-builtin, .cm-s-cobalt span.cm-special { color: #ff9e59; }
 
1
  .cm-s-cobalt { background: #002240; color: white; }
2
+ .cm-s-cobalt div.CodeMirror-selected { background: #b36539 !important; }
3
  .cm-s-cobalt .CodeMirror-gutter { background: #002240; border-right: 1px solid #aaa; }
4
  .cm-s-cobalt .CodeMirror-gutter-text { color: #d0d0d0; }
5
  .cm-s-cobalt .CodeMirror-cursor { border-left: 1px solid white !important; }
15
  .cm-s-cobalt span.cm-error { color: #9d1e15; }
16
  .cm-s-cobalt span.cm-bracket { color: #d8d8d8; }
17
  .cm-s-cobalt span.cm-builtin, .cm-s-cobalt span.cm-special { color: #ff9e59; }
18
+ .cm-s-cobalt span.cm-link { color: #845dc4; }
libraries/CodeMirror2/theme/default.css DELETED
@@ -1,19 +0,0 @@
1
- .cm-s-default span.cm-keyword {color: #708;}
2
- .cm-s-default span.cm-atom {color: #219;}
3
- .cm-s-default span.cm-number {color: #164;}
4
- .cm-s-default span.cm-def {color: #00f;}
5
- .cm-s-default span.cm-variable {color: black;}
6
- .cm-s-default span.cm-variable-2 {color: #05a;}
7
- .cm-s-default span.cm-variable-3 {color: #085;}
8
- .cm-s-default span.cm-property {color: black;}
9
- .cm-s-default span.cm-operator {color: black;}
10
- .cm-s-default span.cm-comment {color: #a50;}
11
- .cm-s-default span.cm-string {color: #a11;}
12
- .cm-s-default span.cm-string-2 {color: #f50;}
13
- .cm-s-default span.cm-meta {color: #555;}
14
- .cm-s-default span.cm-error {color: #f00;}
15
- .cm-s-default span.cm-qualifier {color: #555;}
16
- .cm-s-default span.cm-builtin {color: #30a;}
17
- .cm-s-default span.cm-bracket {color: #cc7;}
18
- .cm-s-default span.cm-tag {color: #170;}
19
- .cm-s-default span.cm-attribute {color: #00c;}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
libraries/CodeMirror2/theme/eclipse.css CHANGED
@@ -1,5 +1,5 @@
1
  .cm-s-eclipse span.cm-meta {color: #FF1717;}
2
- .cm-s-eclipse span.cm-keyword { font-weight: bold; color: #7F0055; }
3
  .cm-s-eclipse span.cm-atom {color: #219;}
4
  .cm-s-eclipse span.cm-number {color: #164;}
5
  .cm-s-eclipse span.cm-def {color: #00f;}
@@ -17,8 +17,9 @@
17
  .cm-s-eclipse span.cm-bracket {color: #cc7;}
18
  .cm-s-eclipse span.cm-tag {color: #170;}
19
  .cm-s-eclipse span.cm-attribute {color: #00c;}
 
20
 
21
- .CodeMirror-matchingbracket{
22
  border:1px solid grey;
23
  color:black !important;;
24
- }
1
  .cm-s-eclipse span.cm-meta {color: #FF1717;}
2
+ .cm-s-eclipse span.cm-keyword { line-height: 1em; font-weight: bold; color: #7F0055; }
3
  .cm-s-eclipse span.cm-atom {color: #219;}
4
  .cm-s-eclipse span.cm-number {color: #164;}
5
  .cm-s-eclipse span.cm-def {color: #00f;}
17
  .cm-s-eclipse span.cm-bracket {color: #cc7;}
18
  .cm-s-eclipse span.cm-tag {color: #170;}
19
  .cm-s-eclipse span.cm-attribute {color: #00c;}
20
+ .cm-s-eclipse span.cm-link {color: #219;}
21
 
22
+ .cm-s-eclipse .CodeMirror-matchingbracket {
23
  border:1px solid grey;
24
  color:black !important;;
25
+ }
libraries/CodeMirror2/theme/elegant.css CHANGED
@@ -1,9 +1,10 @@
1
  .cm-s-elegant span.cm-number, .cm-s-elegant span.cm-string, .cm-s-elegant span.cm-atom {color: #762;}
2
- .cm-s-elegant span.cm-comment {color: #262;font-style: italic;}
3
- .cm-s-elegant span.cm-meta {color: #555;font-style: italic;}
4
  .cm-s-elegant span.cm-variable {color: black;}
5
  .cm-s-elegant span.cm-variable-2 {color: #b11;}
6
  .cm-s-elegant span.cm-qualifier {color: #555;}
7
  .cm-s-elegant span.cm-keyword {color: #730;}
8
  .cm-s-elegant span.cm-builtin {color: #30a;}
9
  .cm-s-elegant span.cm-error {background-color: #fdd;}
 
1
  .cm-s-elegant span.cm-number, .cm-s-elegant span.cm-string, .cm-s-elegant span.cm-atom {color: #762;}
2
+ .cm-s-elegant span.cm-comment {color: #262; font-style: italic; line-height: 1em;}
3
+ .cm-s-elegant span.cm-meta {color: #555; font-style: italic; line-height: 1em;}
4
  .cm-s-elegant span.cm-variable {color: black;}
5
  .cm-s-elegant span.cm-variable-2 {color: #b11;}
6
  .cm-s-elegant span.cm-qualifier {color: #555;}
7
  .cm-s-elegant span.cm-keyword {color: #730;}
8
  .cm-s-elegant span.cm-builtin {color: #30a;}
9
  .cm-s-elegant span.cm-error {background-color: #fdd;}
10
+ .cm-s-elegant span.cm-link {color: #762;}
libraries/CodeMirror2/theme/lesser-dark.css ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ http://lesscss.org/ dark theme
3
+ Ported to CodeMirror by Peter Kroon
4
+ */
5
+ .CodeMirror{
6
+ line-height: 15px;
7
+ }
8
+ .cm-s-lesser-dark {
9
+ font-family: 'Bitstream Vera Sans Mono', 'DejaVu Sans Mono', 'Monaco', Courier, monospace !important;
10
+ font-size:12px;
11
+ }
12
+
13
+ .cm-s-lesser-dark { background: #262626; color: #EBEFE7; text-shadow: 0 -1px 1px #262626; }
14
+ .cm-s-lesser-dark div.CodeMirror-selected {background: #45443B !important;} /* 33322B*/
15
+ .cm-s-lesser-dark .CodeMirror-cursor { border-left: 1px solid white !important; }
16
+ .cm-s-lesser-dark .CodeMirror-lines { margin-left:3px; margin-right:3px; }/*editable code holder*/
17
+
18
+ div.CodeMirror span.CodeMirror-matchingbracket { color: #7EFC7E; }/*65FC65*/
19
+
20
+ .cm-s-lesser-dark .CodeMirror-gutter { background: #262626; border-right:1px solid #aaa; padding-right:3px; min-width:2.5em; }
21
+ .cm-s-lesser-dark .CodeMirror-gutter-text { color: #777; }
22
+
23
+ .cm-s-lesser-dark span.cm-keyword { color: #599eff; }
24
+ .cm-s-lesser-dark span.cm-atom { color: #C2B470; }
25
+ .cm-s-lesser-dark span.cm-number { color: #B35E4D; }
26
+ .cm-s-lesser-dark span.cm-def {color: white;}
27
+ .cm-s-lesser-dark span.cm-variable { color:#D9BF8C; }
28
+ .cm-s-lesser-dark span.cm-variable-2 { color: #669199; }
29
+ .cm-s-lesser-dark span.cm-variable-3 { color: white; }
30
+ .cm-s-lesser-dark span.cm-property {color: #92A75C;}
31
+ .cm-s-lesser-dark span.cm-operator {color: #92A75C;}
32
+ .cm-s-lesser-dark span.cm-comment { color: #666; }
33
+ .cm-s-lesser-dark span.cm-string { color: #BCD279; }
34
+ .cm-s-lesser-dark span.cm-string-2 {color: #f50;}
35
+ .cm-s-lesser-dark span.cm-meta { color: #738C73; }
36
+ .cm-s-lesser-dark span.cm-error { color: #9d1e15; }
37
+ .cm-s-lesser-dark span.cm-qualifier {color: #555;}
38
+ .cm-s-lesser-dark span.cm-builtin { color: #ff9e59; }
39
+ .cm-s-lesser-dark span.cm-bracket { color: #EBEFE7; }
40
+ .cm-s-lesser-dark span.cm-tag { color: #669199; }
41
+ .cm-s-lesser-dark span.cm-attribute {color: #00c;}
42
+ .cm-s-lesser-dark span.cm-header {color: #a0a;}
43
+ .cm-s-lesser-dark span.cm-quote {color: #090;}
44
+ .cm-s-lesser-dark span.cm-hr {color: #999;}
45
+ .cm-s-lesser-dark span.cm-link {color: #00c;}
libraries/CodeMirror2/theme/monokai.css CHANGED
@@ -1,27 +1,28 @@
1
  /* Based on Sublime Text's Monokai theme */
2
 
3
- .cm-s-monokai { background: #272822; color: #F8F8F2; }
4
- .cm-s-monokai span.CodeMirror-selected { background: #FFE792 !important; }
5
- .cm-s-monokai .CodeMirror-gutter { background: #272822; border-right: 0px; }
6
- .cm-s-monokai .CodeMirror-gutter-text { color: #d0d0d0; }
7
- .cm-s-monokai .CodeMirror-cursor { border-left: 1px solid #F8F8F0 !important; }
8
 
9
- .cm-s-monokai span.cm-comment { color: #75715E; }
10
- .cm-s-monokai span.cm-atom { color: #AE81FF; }
11
- .cm-s-monokai span.cm-number { color: #AE81FF; }
12
 
13
- .cm-s-monokai span.cm-property, .cm-s-monokai span.cm-attribute {color: #A6E22E;}
14
- .cm-s-monokai span.cm-keyword { color: #F92672; }
15
- .cm-s-monokai span.cm-string { color: #E6DB74; }
16
 
17
- .cm-s-monokai span.cm-variable {color: #A6E22E;}
18
- .cm-s-monokai span.cm-variable-2 { color: #9effff; }
19
- .cm-s-monokai span.cm-def { color: #FD971F; }
20
- .cm-s-monokai span.cm-error { background: #F92672; color: #F8F8F0; }
21
- .cm-s-monokai span.cm-bracket { color: #f8F8F2; }
22
- .cm-s-monokai span.cm-tag {color: #F92672;}
 
23
 
24
- .CodeMirror-matchingbracket{
25
- text-decoration: underline;
26
- color: white !important;
27
- }
1
  /* Based on Sublime Text's Monokai theme */
2
 
3
+ .cm-s-monokai {background: #272822; color: #f8f8f2;}
4
+ .cm-s-monokai div.CodeMirror-selected {background: #49483E !important;}
5
+ .cm-s-monokai .CodeMirror-gutter {background: #272822; border-right: 0px;}
6
+ .cm-s-monokai .CodeMirror-gutter-text {color: #d0d0d0;}
7
+ .cm-s-monokai .CodeMirror-cursor {border-left: 1px solid #f8f8f0 !important;}
8
 
9
+ .cm-s-monokai span.cm-comment {color: #75715e;}
10
+ .cm-s-monokai span.cm-atom {color: #ae81ff;}
11
+ .cm-s-monokai span.cm-number {color: #ae81ff;}
12
 
13
+ .cm-s-monokai span.cm-property, .cm-s-monokai span.cm-attribute {color: #a6e22e;}
14
+ .cm-s-monokai span.cm-keyword {color: #f92672;}
15
+ .cm-s-monokai span.cm-string {color: #e6db74;}
16
 
17
+ .cm-s-monokai span.cm-variable {color: #a6e22e;}
18
+ .cm-s-monokai span.cm-variable-2 {color: #9effff;}
19
+ .cm-s-monokai span.cm-def {color: #fd971f;}
20
+ .cm-s-monokai span.cm-error {background: #f92672; color: #f8f8f0;}
21
+ .cm-s-monokai span.cm-bracket {color: #f8f8f2;}
22
+ .cm-s-monokai span.cm-tag {color: #f92672;}
23
+ .cm-s-monokai span.cm-link {color: #ae81ff;}
24
 
25
+ .cm-s-monokai .CodeMirror-matchingbracket {
26
+ text-decoration: underline;
27
+ color: white !important;
28
+ }
libraries/CodeMirror2/theme/neat.css CHANGED
@@ -1,8 +1,9 @@
1
  .cm-s-neat span.cm-comment { color: #a86; }
2
- .cm-s-neat span.cm-keyword { font-weight: bold; color: blue; }
3
  .cm-s-neat span.cm-string { color: #a22; }
4
- .cm-s-neat span.cm-builtin { font-weight: bold; color: #077; }
5
- .cm-s-neat span.cm-special { font-weight: bold; color: #0aa; }
6
  .cm-s-neat span.cm-variable { color: black; }
7
  .cm-s-neat span.cm-number, .cm-s-neat span.cm-atom { color: #3a3; }
8
  .cm-s-neat span.cm-meta {color: #555;}
 
1
  .cm-s-neat span.cm-comment { color: #a86; }
2
+ .cm-s-neat span.cm-keyword { line-height: 1em; font-weight: bold; color: blue; }
3
  .cm-s-neat span.cm-string { color: #a22; }
4
+ .cm-s-neat span.cm-builtin { line-height: 1em; font-weight: bold; color: #077; }
5
+ .cm-s-neat span.cm-special { line-height: 1em; font-weight: bold; color: #0aa; }
6
  .cm-s-neat span.cm-variable { color: black; }
7
  .cm-s-neat span.cm-number, .cm-s-neat span.cm-atom { color: #3a3; }
8
  .cm-s-neat span.cm-meta {color: #555;}
9
+ .cm-s-neat span.cm-link { color: #3a3; }
libraries/CodeMirror2/theme/night.css CHANGED
@@ -1,7 +1,7 @@
1
  /* Loosely based on the Midnight Textmate theme */
2
 
3
  .cm-s-night { background: #0a001f; color: #f8f8f8; }
4
- .cm-s-night span.CodeMirror-selected { background: #a8f !important; }
5
  .cm-s-night .CodeMirror-gutter { background: #0a001f; border-right: 1px solid #aaa; }
6
  .cm-s-night .CodeMirror-gutter-text { color: #f8f8f8; }
7
  .cm-s-night .CodeMirror-cursor { border-left: 1px solid white !important; }
@@ -18,3 +18,4 @@
18
  .cm-s-night span.cm-bracket { color: #8da6ce; }
19
  .cm-s-night span.cm-comment { color: #6900a1; }
20
  .cm-s-night span.cm-builtin, .cm-s-night span.cm-special { color: #ff9e59; }
 
1
  /* Loosely based on the Midnight Textmate theme */
2
 
3
  .cm-s-night { background: #0a001f; color: #f8f8f8; }
4
+ .cm-s-night div.CodeMirror-selected { background: #a8f !important; }
5
  .cm-s-night .CodeMirror-gutter { background: #0a001f; border-right: 1px solid #aaa; }
6
  .cm-s-night .CodeMirror-gutter-text { color: #f8f8f8; }
7
  .cm-s-night .CodeMirror-cursor { border-left: 1px solid white !important; }
18
  .cm-s-night span.cm-bracket { color: #8da6ce; }
19
  .cm-s-night span.cm-comment { color: #6900a1; }
20
  .cm-s-night span.cm-builtin, .cm-s-night span.cm-special { color: #ff9e59; }
21
+ .cm-s-night span.cm-link { color: #845dc4; }
libraries/CodeMirror2/theme/rubyblue.css CHANGED
@@ -1,12 +1,12 @@
1
  .cm-s-rubyblue { font:13px/1.4em Trebuchet, Verdana, sans-serif; } /* - customized editor font - */
2
 
3
  .cm-s-rubyblue { background: #112435; color: white; }
4
- .cm-s-rubyblue span.CodeMirror-selected { background: #0000FF !important; }
5
  .cm-s-rubyblue .CodeMirror-gutter { background: #1F4661; border-right: 7px solid #3E7087; min-width:2.5em; }
6
  .cm-s-rubyblue .CodeMirror-gutter-text { color: white; }
7
  .cm-s-rubyblue .CodeMirror-cursor { border-left: 1px solid white !important; }
8
 
9
- .cm-s-rubyblue span.cm-comment { color: #999; font-style:italic; }
10
  .cm-s-rubyblue span.cm-atom { color: #F4C20B; }
11
  .cm-s-rubyblue span.cm-number, .cm-s-rubyblue span.cm-attribute { color: #82C6E0; }
12
  .cm-s-rubyblue span.cm-keyword { color: #F0F; }
@@ -16,5 +16,6 @@
16
  .cm-s-rubyblue span.cm-variable-3, .cm-s-rubyblue span.cm-def { color: white; }
17
  .cm-s-rubyblue span.cm-error { color: #AF2018; }
18
  .cm-s-rubyblue span.cm-bracket { color: #F0F; }
 
19
  .cm-s-rubyblue span.CodeMirror-matchingbracket { color:#F0F !important; }
20
  .cm-s-rubyblue span.cm-builtin, .cm-s-rubyblue span.cm-special { color: #FF9D00; }
1
  .cm-s-rubyblue { font:13px/1.4em Trebuchet, Verdana, sans-serif; } /* - customized editor font - */
2
 
3
  .cm-s-rubyblue { background: #112435; color: white; }
4
+ .cm-s-rubyblue div.CodeMirror-selected { background: #38566F !important; }
5
  .cm-s-rubyblue .CodeMirror-gutter { background: #1F4661; border-right: 7px solid #3E7087; min-width:2.5em; }
6
  .cm-s-rubyblue .CodeMirror-gutter-text { color: white; }
7
  .cm-s-rubyblue .CodeMirror-cursor { border-left: 1px solid white !important; }
8
 
9
+ .cm-s-rubyblue span.cm-comment { color: #999; font-style:italic; line-height: 1em; }
10
  .cm-s-rubyblue span.cm-atom { color: #F4C20B; }
11
  .cm-s-rubyblue span.cm-number, .cm-s-rubyblue span.cm-attribute { color: #82C6E0; }
12
  .cm-s-rubyblue span.cm-keyword { color: #F0F; }
16
  .cm-s-rubyblue span.cm-variable-3, .cm-s-rubyblue span.cm-def { color: white; }
17
  .cm-s-rubyblue span.cm-error { color: #AF2018; }
18
  .cm-s-rubyblue span.cm-bracket { color: #F0F; }
19
+ .cm-s-rubyblue span.cm-link { color: #F4C20B; }
20
  .cm-s-rubyblue span.CodeMirror-matchingbracket { color:#F0F !important; }
21
  .cm-s-rubyblue span.cm-builtin, .cm-s-rubyblue span.cm-special { color: #FF9D00; }
libraries/CodeMirror2/theme/xq-dark.css ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ Copyright (C) 2011 by MarkLogic Corporation
3
+ Author: Mike Brevoort <mike@brevoort.com>
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
22
+ */
23
+ .cm-s-xq-dark { background: #0a001f; color: #f8f8f8; }
24
+ .cm-s-xq-dark span.CodeMirror-selected { background: #a8f !important; }
25
+ .cm-s-xq-dark .CodeMirror-gutter { background: #0a001f; border-right: 1px solid #aaa; }
26
+ .cm-s-xq-dark .CodeMirror-gutter-text { color: #f8f8f8; }
27
+ .cm-s-xq-dark .CodeMirror-cursor { border-left: 1px solid white !important; }
28
+
29
+ .cm-s-xq-dark span.cm-keyword {color: #FFBD40;}
30
+ .cm-s-xq-dark span.cm-atom {color: #6C8CD5;}
31
+ .cm-s-xq-dark span.cm-number {color: #164;}
32
+ .cm-s-xq-dark span.cm-def {color: #FFF; text-decoration:underline;}
33
+ .cm-s-xq-dark span.cm-variable {color: #FFF;}
34
+ .cm-s-xq-dark span.cm-variable-2 {color: #EEE;}
35
+ .cm-s-xq-dark span.cm-variable-3 {color: #DDD;}
36
+ .cm-s-xq-dark span.cm-property {}
37
+ .cm-s-xq-dark span.cm-operator {}
38
+ .cm-s-xq-dark span.cm-comment {color: gray;}
39
+ .cm-s-xq-dark span.cm-string {color: #9FEE00;}
40
+ .cm-s-xq-dark span.cm-meta {color: yellow;}
41
+ .cm-s-xq-dark span.cm-error {color: #f00;}
42
+ .cm-s-xq-dark span.cm-qualifier {color: #FFF700;}
43
+ .cm-s-xq-dark span.cm-builtin {color: #30a;}
44
+ .cm-s-xq-dark span.cm-bracket {color: #cc7;}
45
+ .cm-s-xq-dark span.cm-tag {color: #FFBD40;}
46
+ .cm-s-xq-dark span.cm-attribute {color: #FFF700;}
libraries/less/LICENSE ADDED
@@ -0,0 +1,179 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ Copyright (c) 2009-2010 Alexis Sellier
libraries/less/dist/less-1.3.0.js ADDED
@@ -0,0 +1,3478 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ //
2
+ // LESS - Leaner CSS v1.3.0
3
+ // http://lesscss.org
4
+ //
5
+ // Copyright (c) 2009-2011, Alexis Sellier
6
+ // Licensed under the Apache 2.0 License.
7
+ //
8
+ (function (window, undefined) {
9
+ //
10
+ // Stub out `require` in the browser
11
+ //
12
+ function require(arg) {
13
+ return window.less[arg.split('/')[1]];
14
+ };
15
+
16
+ // amd.js
17
+ //
18
+ // Define Less as an AMD module.
19
+ if (typeof define === "function" && define.amd) {
20
+ define("less", [], function () { return less; } );
21
+ }
22
+
23
+ // ecma-5.js
24
+ //
25
+ // -- kriskowal Kris Kowal Copyright (C) 2009-2010 MIT License
26
+ // -- tlrobinson Tom Robinson
27
+ // dantman Daniel Friesen
28
+
29
+ //
30
+ // Array
31
+ //
32
+ if (!Array.isArray) {
33
+ Array.isArray = function(obj) {
34
+ return Object.prototype.toString.call(obj) === "[object Array]" ||
35
+ (obj instanceof Array);
36
+ };
37
+ }
38
+ if (!Array.prototype.forEach) {
39
+ Array.prototype.forEach = function(block, thisObject) {
40
+ var len = this.length >>> 0;
41
+ for (var i = 0; i < len; i++) {
42
+ if (i in this) {
43
+ block.call(thisObject, this[i], i, this);
44
+ }
45
+ }
46
+ };
47
+ }
48
+ if (!Array.prototype.map) {
49
+ Array.prototype.map = function(fun /*, thisp*/) {
50
+ var len = this.length >>> 0;
51
+ var res = new Array(len);
52
+ var thisp = arguments[1];
53
+
54
+ for (var i = 0; i < len; i++) {
55
+ if (i in this) {
56
+ res[i] = fun.call(thisp, this[i], i, this);
57
+ }
58
+ }
59
+ return res;
60
+ };
61
+ }
62
+ if (!Array.prototype.filter) {
63
+ Array.prototype.filter = function (block /*, thisp */) {
64
+ var values = [];
65
+ var thisp = arguments[1];
66
+ for (var i = 0; i < this.length; i++) {
67
+ if (block.call(thisp, this[i])) {
68
+ values.push(this[i]);
69
+ }
70
+ }
71
+ return values;
72
+ };
73
+ }
74
+ if (!Array.prototype.reduce) {
75
+ Array.prototype.reduce = function(fun /*, initial*/) {
76
+ var len = this.length >>> 0;
77
+ var i = 0;
78
+
79
+ // no value to return if no initial value and an empty array
80
+ if (len === 0 && arguments.length === 1) throw new TypeError();
81
+
82
+ if (arguments.length >= 2) {
83
+ var rv = arguments[1];
84
+ } else {
85
+ do {
86
+ if (i in this) {
87
+ rv = this[i++];
88
+ break;
89
+ }
90
+ // if array contains no values, no initial value to return
91
+ if (++i >= len) throw new TypeError();
92
+ } while (true);
93
+ }
94
+ for (; i < len; i++) {
95
+ if (i in this) {
96
+ rv = fun.call(null, rv, this[i], i, this);
97
+ }
98
+ }
99
+ return rv;
100
+ };
101
+ }
102
+ if (!Array.prototype.indexOf) {
103
+ Array.prototype.indexOf = function (value /*, fromIndex */ ) {
104
+ var length = this.length;
105
+ var i = arguments[1] || 0;
106
+
107
+ if (!length) return -1;
108
+ if (i >= length) return -1;
109
+ if (i < 0) i += length;
110
+
111
+ for (; i < length; i++) {
112
+ if (!Object.prototype.hasOwnProperty.call(this, i)) { continue }
113
+ if (value === this[i]) return i;
114
+ }
115
+ return -1;
116
+ };
117
+ }
118
+
119
+ //
120
+ // Object
121
+ //
122
+ if (!Object.keys) {
123
+ Object.keys = function (object) {
124
+ var keys = [];
125
+ for (var name in object) {
126
+ if (Object.prototype.hasOwnProperty.call(object, name)) {
127
+ keys.push(name);
128
+ }
129
+ }
130
+ return keys;
131
+ };
132
+ }
133
+
134
+ //
135
+ // String
136
+ //
137
+ if (!String.prototype.trim) {
138
+ String.prototype.trim = function () {
139
+ return String(this).replace(/^\s\s*/, '').replace(/\s\s*$/, '');
140
+ };
141
+ }
142
+ var less, tree;
143
+
144
+ if (typeof environment === "object" && ({}).toString.call(environment) === "[object Environment]") {
145
+ // Rhino
146
+ // Details on how to detect Rhino: https://github.com/ringo/ringojs/issues/88
147
+ if (typeof(window) === 'undefined') { less = {} }
148
+ else { less = window.less = {} }
149
+ tree = less.tree = {};
150
+ less.mode = 'rhino';
151
+ } else if (typeof(window) === 'undefined') {
152
+ // Node.js
153
+ less = exports,
154
+ tree = require('./tree');
155
+ less.mode = 'node';
156
+ } else {
157
+ // Browser
158
+ if (typeof(window.less) === 'undefined') { window.less = {} }
159
+ less = window.less,
160
+ tree = window.less.tree = {};
161
+ less.mode = 'browser';
162
+ }
163
+ //
164
+ // less.js - parser
165
+ //
166
+ // A relatively straight-forward predictive parser.
167
+ // There is no tokenization/lexing stage, the input is parsed
168
+ // in one sweep.
169
+ //
170
+ // To make the parser fast enough to run in the browser, several
171
+ // optimization had to be made:
172
+ //
173
+ // - Matching and slicing on a huge input is often cause of slowdowns.
174
+ // The solution is to chunkify the input into smaller strings.
175
+ // The chunks are stored in the `chunks` var,
176
+ // `j` holds the current chunk index, and `current` holds
177
+ // the index of the current chunk in relation to `input`.
178
+ // This gives us an almost 4x speed-up.
179
+ //
180
+ // - In many cases, we don't need to match individual tokens;
181
+ // for example, if a value doesn't hold any variables, operations
182
+ // or dynamic references, the parser can effectively 'skip' it,
183
+ // treating it as a literal.
184
+ // An example would be '1px solid #000' - which evaluates to itself,
185
+ // we don't need to know what the individual components are.
186
+ // The drawback, of course is that you don't get the benefits of
187
+ // syntax-checking on the CSS. This gives us a 50% speed-up in the parser,
188
+ // and a smaller speed-up in the code-gen.
189
+ //
190
+ //
191
+ // Token matching is done with the `$` function, which either takes
192
+ // a terminal string or regexp, or a non-terminal function to call.
193
+ // It also takes care of moving all the indices forwards.
194
+ //
195
+ //
196
+ less.Parser = function Parser(env) {
197
+ var input, // LeSS input string
198
+ i, // current index in `input`
199
+ j, // current chunk
200
+ temp, // temporarily holds a chunk's state, for backtracking
201
+ memo, // temporarily holds `i`, when backtracking
202
+ furthest, // furthest index the parser has gone to
203
+ chunks, // chunkified input
204
+ current, // index of current chunk, in `input`
205
+ parser;
206
+
207
+ var that = this;
208
+
209
+ // This function is called after all files
210
+ // have been imported through `@import`.
211
+ var finish = function () {};
212
+
213
+ var imports = this.imports = {
214
+ paths: env && env.paths || [], // Search paths, when importing
215
+ queue: [], // Files which haven't been imported yet
216
+ files: {}, // Holds the imported parse trees
217
+ contents: {}, // Holds the imported file contents
218
+ mime: env && env.mime, // MIME type of .less files
219
+ error: null, // Error in parsing/evaluating an import
220
+ push: function (path, callback) {
221
+ var that = this;
222
+ this.queue.push(path);
223
+
224
+ //
225
+ // Import a file asynchronously
226
+ //
227
+ less.Parser.importer(path, this.paths, function (e, root, contents) {
228
+ that.queue.splice(that.queue.indexOf(path), 1); // Remove the path from the queue
229
+ that.files[path] = root; // Store the root
230
+ that.contents[path] = contents;
231
+
232
+ if (e && !that.error) { that.error = e }
233
+ callback(e, root);
234
+
235
+ if (that.queue.length === 0) { finish() } // Call `finish` if we're done importing
236
+ }, env);
237
+ }
238
+ };
239
+
240
+ function save() { temp = chunks[j], memo = i, current = i }
241
+ function restore() { chunks[j] = temp, i = memo, current = i }
242
+
243
+ function sync() {
244
+ if (i > current) {
245
+ chunks[j] = chunks[j].slice(i - current);
246
+ current = i;
247
+ }
248
+ }
249
+ //
250
+ // Parse from a token, regexp or string, and move forward if match
251
+ //
252
+ function $(tok) {
253
+ var match, args, length, c, index, endIndex, k, mem;
254
+
255
+ //
256
+ // Non-terminal
257
+ //
258
+ if (tok instanceof Function) {
259
+ return tok.call(parser.parsers);
260
+ //
261
+ // Terminal
262
+ //
263
+ // Either match a single character in the input,
264
+ // or match a regexp in the current chunk (chunk[j]).
265
+ //
266
+ } else if (typeof(tok) === 'string') {
267
+ match = input.charAt(i) === tok ? tok : null;
268
+ length = 1;
269
+ sync ();
270
+ } else {
271
+ sync ();
272
+
273
+ if (match = tok.exec(chunks[j])) {
274
+ length = match[0].length;
275
+ } else {
276
+ return null;
277
+ }
278
+ }
279
+
280
+ // The match is confirmed, add the match length to `i`,
281
+ // and consume any extra white-space characters (' ' || '\n')
282
+ // which come after that. The reason for this is that LeSS's
283
+ // grammar is mostly white-space insensitive.
284
+ //
285
+ if (match) {
286
+ mem = i += length;
287
+ endIndex = i + chunks[j].length - length;
288
+
289
+ while (i < endIndex) {
290
+ c = input.charCodeAt(i);
291
+ if (! (c === 32 || c === 10 || c === 9)) { break }
292
+ i++;
293
+ }
294
+ chunks[j] = chunks[j].slice(length + (i - mem));
295
+ current = i;
296
+
297
+ if (chunks[j].length === 0 && j < chunks.length - 1) { j++ }
298
+
299
+ if(typeof(match) === 'string') {
300
+ return match;
301
+ } else {
302
+ return match.length === 1 ? match[0] : match;
303
+ }
304
+ }
305
+ }
306
+
307
+ function expect(arg, msg) {
308
+ var result = $(arg);
309
+ if (! result) {
310
+ error(msg || (typeof(arg) === 'string' ? "expected '" + arg + "' got '" + input.charAt(i) + "'"
311
+ : "unexpected token"));
312
+ } else {
313
+ return result;
314
+ }
315
+ }
316
+
317
+ function error(msg, type) {
318
+ throw { index: i, type: type || 'Syntax', message: msg };
319
+ }
320
+
321
+ // Same as $(), but don't change the state of the parser,
322
+ // just return the match.
323
+ function peek(tok) {
324
+ if (typeof(tok) === 'string') {
325
+ return input.charAt(i) === tok;
326
+ } else {
327
+ if (tok.test(chunks[j])) {
328
+ return true;
329
+ } else {
330
+ return false;
331
+ }
332
+ }
333
+ }
334
+
335
+ function basename(pathname) {
336
+ if (less.mode === 'node') {
337
+ return require('path').basename(pathname);
338
+ } else {
339
+ return pathname.match(/[^\/]+$/)[0];
340
+ }
341
+ }
342
+
343
+ function getInput(e, env) {
344
+ if (e.filename && env.filename && (e.filename !== env.filename)) {
345
+ return parser.imports.contents[basename(e.filename)];
346
+ } else {
347
+ return input;
348
+ }
349
+ }
350
+
351
+ function getLocation(index, input) {
352
+ for (var n = index, column = -1;
353
+ n >= 0 && input.charAt(n) !== '\n';
354
+ n--) { column++ }
355
+
356
+ return { line: typeof(index) === 'number' ? (input.slice(0, index).match(/\n/g) || "").length : null,
357
+ column: column };
358
+ }
359
+
360
+ function LessError(e, env) {
361
+ var input = getInput(e, env),
362
+ loc = getLocation(e.index, input),
363
+ line = loc.line,
364
+ col = loc.column,
365
+ lines = input.split('\n');
366
+
367
+ this.type = e.type || 'Syntax';
368
+ this.message = e.message;
369
+ this.filename = e.filename || env.filename;
370
+ this.index = e.index;
371
+ this.line = typeof(line) === 'number' ? line + 1 : null;
372
+ this.callLine = e.call && (getLocation(e.call, input).line + 1);
373
+ this.callExtract = lines[getLocation(e.call, input).line];
374
+ this.stack = e.stack;
375
+ this.column = col;
376
+ this.extract = [
377
+ lines[line - 1],
378
+ lines[line],
379
+ lines[line + 1]
380
+ ];
381
+ }
382
+
383
+ this.env = env = env || {};
384
+
385
+ // The optimization level dictates the thoroughness of the parser,
386
+ // the lower the number, the less nodes it will create in the tree.
387
+ // This could matter for debugging, or if you want to access
388
+ // the individual nodes in the tree.
389
+ this.optimization = ('optimization' in this.env) ? this.env.optimization : 1;
390
+
391
+ this.env.filename = this.env.filename || null;
392
+
393
+ //
394
+ // The Parser
395
+ //
396
+ return parser = {
397
+
398
+ imports: imports,
399
+ //
400
+ // Parse an input string into an abstract syntax tree,
401
+ // call `callback` when done.
402
+ //
403
+ parse: function (str, callback) {
404
+ var root, start, end, zone, line, lines, buff = [], c, error = null;
405
+
406
+ i = j = current = furthest = 0;
407
+ input = str.replace(/\r\n/g, '\n');
408
+
409
+ // Split the input into chunks.
410
+ chunks = (function (chunks) {
411
+ var j = 0,
412
+ skip = /[^"'`\{\}\/\(\)\\]+/g,
413
+ comment = /\/\*(?:[^*]|\*+[^\/*])*\*+\/|\/\/.*/g,
414
+ string = /"((?:[^"\\\r\n]|\\.)*)"|'((?:[^'\\\r\n]|\\.)*)'|`((?:[^`\\\r\n]|\\.)*)`/g,
415
+ level = 0,
416
+ match,
417
+ chunk = chunks[0],
418
+ inParam;
419
+
420
+ for (var i = 0, c, cc; i < input.length; i++) {
421
+ skip.lastIndex = i;
422
+ if (match = skip.exec(input)) {
423
+ if (match.index === i) {
424
+ i += match[0].length;
425
+ chunk.push(match[0]);
426
+ }
427
+ }
428
+ c = input.charAt(i);
429
+ comment.lastIndex = string.lastIndex = i;
430
+
431
+ if (match = string.exec(input)) {
432
+ if (match.index === i) {
433
+ i += match[0].length;
434
+ chunk.push(match[0]);
435
+ c = input.charAt(i);
436
+ }
437
+ }
438
+
439
+ if (!inParam && c === '/') {
440
+ cc = input.charAt(i + 1);
441
+ if (cc === '/' || cc === '*') {
442
+ if (match = comment.exec(input)) {
443
+ if (match.index === i) {
444
+ i += match[0].length;
445
+ chunk.push(match[0]);
446
+ c = input.charAt(i);
447
+ }
448
+ }
449
+ }
450
+ }
451
+
452
+ switch (c) {
453
+ case '{': if (! inParam) { level ++; chunk.push(c); break }
454
+ case '}': if (! inParam) { level --; chunk.push(c); chunks[++j] = chunk = []; break }
455
+ case '(': if (! inParam) { inParam = true; chunk.push(c); break }
456
+ case ')': if ( inParam) { inParam = false; chunk.push(c); break }
457
+ default: chunk.push(c);
458
+ }
459
+ }
460
+ if (level > 0) {
461
+ error = new(LessError)({
462
+ index: i,
463
+ type: 'Parse',
464
+ message: "missing closing `}`",
465
+ filename: env.filename
466
+ }, env);
467
+ }
468
+
469
+ return chunks.map(function (c) { return c.join('') });;
470
+ })([[]]);
471
+
472
+ if (error) {
473
+ return callback(error);
474
+ }
475
+
476
+ // Start with the primary rule.
477
+ // The whole syntax tree is held under a Ruleset node,
478
+ // with the `root` property set to true, so no `{}` are
479
+ // output. The callback is called when the input is parsed.
480
+ try {
481
+ root = new(tree.Ruleset)([], $(this.parsers.primary));
482
+ root.root = true;
483
+ } catch (e) {
484
+ return callback(new(LessError)(e, env));
485
+ }
486
+
487
+ root.toCSS = (function (evaluate) {
488
+ var line, lines, column;
489
+
490
+ return function (options, variables) {
491
+ var frames = [], importError;
492
+
493
+ options = options || {};
494
+ //
495
+ // Allows setting variables with a hash, so:
496
+ //
497
+ // `{ color: new(tree.Color)('#f01') }` will become:
498
+ //
499
+ // new(tree.Rule)('@color',
500
+ // new(tree.Value)([
501
+ // new(tree.Expression)([
502
+ // new(tree.Color)('#f01')
503
+ // ])
504
+ // ])
505
+ // )
506
+ //
507
+ if (typeof(variables) === 'object' && !Array.isArray(variables)) {
508
+ variables = Object.keys(variables).map(function (k) {
509
+ var value = variables[k];
510
+
511
+ if (! (value instanceof tree.Value)) {
512
+ if (! (value instanceof tree.Expression)) {
513
+ value = new(tree.Expression)([value]);
514
+ }
515
+ value = new(tree.Value)([value]);
516
+ }
517
+ return new(tree.Rule)('@' + k, value, false, 0);
518
+ });
519
+ frames = [new(tree.Ruleset)(null, variables)];
520
+ }
521
+
522
+ try {
523
+ var css = evaluate.call(this, { frames: frames })
524
+ .toCSS([], { compress: options.compress || false });
525
+ } catch (e) {
526
+ throw new(LessError)(e, env);
527
+ }
528
+
529
+ if ((importError = parser.imports.error)) { // Check if there was an error during importing
530
+ if (importError instanceof LessError) throw importError;
531
+ else throw new(LessError)(importError, env);
532
+ }
533
+
534
+ if (options.yuicompress && less.mode === 'node') {
535
+ return require('./cssmin').compressor.cssmin(css);
536
+ } else if (options.compress) {
537
+ return css.replace(/(\s)+/g, "$1");
538
+ } else {
539
+ return css;
540
+ }
541
+ };
542
+ })(root.eval);
543
+
544
+ // If `i` is smaller than the `input.length - 1`,
545
+ // it means the parser wasn't able to parse the whole
546
+ // string, so we've got a parsing error.
547
+ //
548
+ // We try to extract a \n delimited string,
549
+ // showing the line where the parse error occured.
550
+ // We split it up into two parts (the part which parsed,
551
+ // and the part which didn't), so we can color them differently.
552
+ if (i < input.length - 1) {
553
+ i = furthest;
554
+ lines = input.split('\n');
555
+ line = (input.slice(0, i).match(/\n/g) || "").length + 1;
556
+
557
+ for (var n = i, column = -1; n >= 0 && input.charAt(n) !== '\n'; n--) { column++ }
558
+
559
+ error = {
560
+ type: "Parse",
561
+ message: "Syntax Error on line " + line,
562
+ index: i,
563
+ filename: env.filename,
564
+ line: line,
565
+ column: column,
566
+ extract: [
567
+ lines[line - 2],
568
+ lines[line - 1],
569
+ lines[line]
570
+ ]
571
+ };
572
+ }
573
+
574
+ if (this.imports.queue.length > 0) {
575
+ finish = function () { callback(error, root) };
576
+ } else {
577
+ callback(error, root);
578
+ }
579
+ },
580
+
581
+ //
582
+ // Here in, the parsing rules/functions
583
+ //
584
+ // The basic structure of the syntax tree generated is as follows:
585
+ //
586
+ // Ruleset -> Rule -> Value -> Expression -> Entity
587
+ //
588
+ // Here's some LESS code:
589
+ //
590
+ // .class {
591
+ // color: #fff;
592
+ // border: 1px solid #000;
593
+ // width: @w + 4px;
594
+ // > .child {...}
595
+ // }
596
+ //
597
+ // And here's what the parse tree might look like:
598
+ //
599
+ // Ruleset (Selector '.class', [
600
+ // Rule ("color", Value ([Expression [Color #fff]]))
601
+ // Rule ("border", Value ([Expression [Dimension 1px][Keyword "solid"][Color #000]]))
602
+ // Rule ("width", Value ([Expression [Operation "+" [Variable "@w"][Dimension 4px]]]))
603
+ // Ruleset (Selector [Element '>', '.child'], [...])
604
+ // ])
605
+ //
606
+ // In general, most rules will try to parse a token with the `$()` function, and if the return
607
+ // value is truly, will return a new node, of the relevant type. Sometimes, we need to check
608
+ // first, before parsing, that's when we use `peek()`.
609
+ //
610
+ parsers: {
611
+ //
612
+ // The `primary` rule is the *entry* and *exit* point of the parser.
613
+ // The rules here can appear at any level of the parse tree.
614
+ //
615
+ // The recursive nature of the grammar is an interplay between the `block`
616
+ // rule, which represents `{ ... }`, the `ruleset` rule, and this `primary` rule,
617
+ // as represented by this simplified grammar:
618
+ //
619
+ // primary → (ruleset | rule)+
620
+ // ruleset → selector+ block
621
+ // block → '{' primary '}'
622
+ //
623
+ // Only at one point is the primary rule not called from the
624
+ // block rule: at the root level.
625
+ //
626
+ primary: function () {
627
+ var node, root = [];
628
+
629
+ while ((node = $(this.mixin.definition) || $(this.rule) || $(this.ruleset) ||
630
+ $(this.mixin.call) || $(this.comment) || $(this.directive))
631
+ || $(/^[\s\n]+/)) {
632
+ node && root.push(node);
633
+ }
634
+ return root;
635
+ },
636
+
637
+ // We create a Comment node for CSS comments `/* */`,
638
+ // but keep the LeSS comments `//` silent, by just skipping
639
+ // over them.
640
+ comment: function () {
641
+ var comment;
642
+
643
+ if (input.charAt(i) !== '/') return;
644
+
645
+ if (input.charAt(i + 1) === '/') {
646
+ return new(tree.Comment)($(/^\/\/.*/), true);
647
+ } else if (comment = $(/^\/\*(?:[^*]|\*+[^\/*])*\*+\/\n?/)) {
648
+ return new(tree.Comment)(comment);
649
+ }
650
+ },
651
+
652
+ //
653
+ // Entities are tokens which can be found inside an Expression
654
+ //
655
+ entities: {
656
+ //
657
+ // A string, which supports escaping " and '
658
+ //
659
+ // "milky way" 'he\'s the one!'
660
+ //
661
+ quoted: function () {
662
+ var str, j = i, e;
663
+
664
+ if (input.charAt(j) === '~') { j++, e = true } // Escaped strings
665
+ if (input.charAt(j) !== '"' && input.charAt(j) !== "'") return;
666
+
667
+ e && $('~');
668
+
669
+ if (str = $(/^"((?:[^"\\\r\n]|\\.)*)"|'((?:[^'\\\r\n]|\\.)*)'/)) {
670
+ return new(tree.Quoted)(str[0], str[1] || str[2], e);
671
+ }
672
+ },
673
+
674
+ //
675
+ // A catch-all word, such as:
676
+ //
677
+ // black border-collapse
678
+ //
679
+ keyword: function () {
680
+ var k;
681
+
682
+ if (k = $(/^[_A-Za-z-][_A-Za-z0-9-]*/)) {
683
+ if (tree.colors.hasOwnProperty(k)) {
684
+ // detect named color
685
+ return new(tree.Color)(tree.colors[k].slice(1));
686
+ } else {
687
+ return new(tree.Keyword)(k);
688
+ }
689
+ }
690
+ },
691
+
692
+ //
693
+ // A function call
694
+ //
695
+ // rgb(255, 0, 255)
696
+ //
697
+ // We also try to catch IE's `alpha()`, but let the `alpha` parser
698
+ // deal with the details.
699
+ //
700
+ // The arguments are parsed with the `entities.arguments` parser.
701
+ //
702
+ call: function () {
703
+ var name, args, index = i;
704
+
705
+ if (! (name = /^([\w-]+|%|progid:[\w\.]+)\(/.exec(chunks[j]))) return;
706
+
707
+ name = name[1].toLowerCase();
708
+
709
+ if (name === 'url') { return null }
710
+ else { i += name.length }
711
+
712
+ if (name === 'alpha') { return $(this.alpha) }
713
+
714
+ $('('); // Parse the '(' and consume whitespace.
715
+
716
+ args = $(this.entities.arguments);
717
+
718
+ if (! $(')')) return;
719
+
720
+ if (name) { return new(tree.Call)(name, args, index, env.filename) }
721
+ },
722
+ arguments: function () {
723
+ var args = [], arg;
724
+
725
+ while (arg = $(this.entities.assignment) || $(this.expression)) {
726
+ args.push(arg);
727
+ if (! $(',')) { break }
728
+ }
729
+ return args;
730
+ },
731
+ literal: function () {
732
+ return $(this.entities.dimension) ||
733
+ $(this.entities.color) ||
734
+ $(this.entities.quoted);
735
+ },
736
+
737
+ // Assignments are argument entities for calls.
738
+ // They are present in ie filter properties as shown below.
739
+ //
740
+ // filter: progid:DXImageTransform.Microsoft.Alpha( *opacity=50* )
741
+ //
742
+
743
+ assignment: function () {
744
+ var key, value;
745
+ if ((key = $(/^\w+(?=\s?=)/i)) && $('=') && (value = $(this.entity))) {
746
+ return new(tree.Assignment)(key, value);
747
+ }
748
+ },
749
+
750
+ //
751
+ // Parse url() tokens
752
+ //
753
+ // We use a specific rule for urls, because they don't really behave like
754
+ // standard function calls. The difference is that the argument doesn't have
755
+ // to be enclosed within a string, so it can't be parsed as an Expression.
756
+ //
757
+ url: function () {
758
+ var value;
759
+
760
+ if (input.charAt(i) !== 'u' || !$(/^url\(/)) return;
761
+ value = $(this.entities.quoted) || $(this.entities.variable) ||
762
+ $(this.entities.dataURI) || $(/^[-\w%@$\/.&=:;#+?~]+/) || "";
763
+
764
+ expect(')');
765
+
766
+ return new(tree.URL)((value.value || value.data || value instanceof tree.Variable)
767
+ ? value : new(tree.Anonymous)(value), imports.paths);
768
+ },
769
+
770
+ dataURI: function () {
771
+ var obj;
772
+
773
+ if ($(/^data:/)) {
774
+ obj = {};
775
+ obj.mime = $(/^[^\/]+\/[^,;)]+/) || '';
776
+ obj.charset = $(/^;\s*charset=[^,;)]+/) || '';
777
+ obj.base64 = $(/^;\s*base64/) || '';
778
+ obj.data = $(/^,\s*[^)]+/);
779
+
780
+ if (obj.data) { return obj }
781
+ }
782
+ },
783
+
784
+ //
785
+ // A Variable entity, such as `@fink`, in
786
+ //
787
+ // width: @fink + 2px
788
+ //
789
+ // We use a different parser for variable definitions,
790
+ // see `parsers.variable`.
791
+ //
792
+ variable: function () {
793
+ var name, index = i;
794
+
795
+ if (input.charAt(i) === '@' && (name = $(/^@@?[\w-]+/))) {
796
+ return new(tree.Variable)(name, index, env.filename);
797
+ }
798
+ },
799
+
800
+ //
801
+ // A Hexadecimal color
802
+ //
803
+ // #4F3C2F
804
+ //
805
+ // `rgb` and `hsl` colors are parsed through the `entities.call` parser.
806
+ //
807
+ color: function () {
808
+ var rgb;
809
+
810
+ if (input.charAt(i) === '#' && (rgb = $(/^#([a-fA-F0-9]{6}|[a-fA-F0-9]{3})/))) {
811
+ return new(tree.Color)(rgb[1]);
812
+ }
813
+ },
814
+
815
+ //
816
+ // A Dimension, that is, a number and a unit
817
+ //
818
+ // 0.5em 95%
819
+ //
820
+ dimension: function () {
821
+ var value, c = input.charCodeAt(i);
822
+ if ((c > 57 || c < 45) || c === 47) return;
823
+
824
+ if (value = $(/^(-?\d*\.?\d+)(px|%|em|rem|pc|ex|in|deg|s|ms|pt|cm|mm|rad|grad|turn)?/)) {
825
+ return new(tree.Dimension)(value[1], value[2]);
826
+ }
827
+ },
828
+
829
+ //
830
+ // JavaScript code to be evaluated
831
+ //
832
+ // `window.location.href`
833
+ //
834
+ javascript: function () {
835
+ var str, j = i, e;
836
+
837
+ if (input.charAt(j) === '~') { j++, e = true } // Escaped strings
838
+ if (input.charAt(j) !== '`') { return }
839
+
840
+ e && $('~');
841
+
842
+ if (str = $(/^`([^`]*)`/)) {
843
+ return new(tree.JavaScript)(str[1], i, e);
844
+ }
845
+ }
846
+ },
847
+
848
+ //
849
+ // The variable part of a variable definition. Used in the `rule` parser
850
+ //
851
+ // @fink:
852
+ //
853
+ variable: function () {
854
+ var name;
855
+
856
+ if (input.charAt(i) === '@' && (name = $(/^(@[\w-]+)\s*:/))) { return name[1] }
857
+ },
858
+
859
+ //
860
+ // A font size/line-height shorthand
861
+ //
862
+ // small/12px
863
+ //
864
+ // We need to peek first, or we'll match on keywords and dimensions
865
+ //
866
+ shorthand: function () {
867
+ var a, b;
868
+
869
+ if (! peek(/^[@\w.%-]+\/[@\w.-]+/)) return;
870
+
871
+ if ((a = $(this.entity)) && $('/') && (b = $(this.entity))) {
872
+ return new(tree.Shorthand)(a, b);
873
+ }
874
+ },
875
+
876
+ //
877
+ // Mixins
878
+ //
879
+ mixin: {
880
+ //
881
+ // A Mixin call, with an optional argument list
882
+ //
883
+ // #mixins > .square(#fff);
884
+ // .rounded(4px, black);
885
+ // .button;
886
+ //
887
+ // The `while` loop is there because mixins can be
888
+ // namespaced, but we only support the child and descendant
889
+ // selector for now.
890
+ //
891
+ call: function () {
892
+ var elements = [], e, c, args, index = i, s = input.charAt(i), important = false;
893
+
894
+ if (s !== '.' && s !== '#') { return }
895
+
896
+ while (e = $(/^[#.](?:[\w-]|\\(?:[a-fA-F0-9]{1,6} ?|[^a-fA-F0-9]))+/)) {
897
+ elements.push(new(tree.Element)(c, e, i));
898
+ c = $('>');
899
+ }
900
+ $('(') && (args = $(this.entities.arguments)) && $(')');
901
+
902
+ if ($(this.important)) {
903
+ important = true;
904
+ }
905
+
906
+ if (elements.length > 0 && ($(';') || peek('}'))) {
907
+ return new(tree.mixin.Call)(elements, args || [], index, env.filename, important);
908
+ }
909
+ },
910
+
911
+ //
912
+ // A Mixin definition, with a list of parameters
913
+ //
914
+ // .rounded (@radius: 2px, @color) {
915
+ // ...
916
+ // }
917
+ //
918
+ // Until we have a finer grained state-machine, we have to
919
+ // do a look-ahead, to make sure we don't have a mixin call.
920
+ // See the `rule` function for more information.
921
+ //
922
+ // We start by matching `.rounded (`, and then proceed on to
923
+ // the argument list, which has optional default values.
924
+ // We store the parameters in `params`, with a `value` key,
925
+ // if there is a value, such as in the case of `@radius`.
926
+ //
927
+ // Once we've got our params list, and a closing `)`, we parse
928
+ // the `{...}` block.
929
+ //
930
+ definition: function () {
931
+ var name, params = [], match, ruleset, param, value, cond, variadic = false;
932
+ if ((input.charAt(i) !== '.' && input.charAt(i) !== '#') ||
933
+ peek(/^[^{]*(;|})/)) return;
934
+
935
+ save();
936
+
937
+ if (match = $(/^([#.](?:[\w-]|\\(?:[a-fA-F0-9]{1,6} ?|[^a-fA-F0-9]))+)\s*\(/)) {
938
+ name = match[1];
939
+
940
+ do {
941
+ if (input.charAt(i) === '.' && $(/^\.{3}/)) {
942
+ variadic = true;
943
+ break;
944
+ } else if (param = $(this.entities.variable) || $(this.entities.literal)
945
+ || $(this.entities.keyword)) {
946
+ // Variable
947
+ if (param instanceof tree.Variable) {
948
+ if ($(':')) {
949
+ value = expect(this.expression, 'expected expression');
950
+ params.push({ name: param.name, value: value });
951
+ } else if ($(/^\.{3}/)) {
952
+ params.push({ name: param.name, variadic: true });
953
+ variadic = true;
954
+ break;
955
+ } else {
956
+ params.push({ name: param.name });
957
+ }
958
+ } else {
959
+ params.push({ value: param });
960
+ }
961
+ } else {
962
+ break;
963
+ }
964
+ } while ($(','))
965
+
966
+ expect(')');
967
+
968
+ if ($(/^when/)) { // Guard
969
+ cond = expect(this.conditions, 'expected condition');
970
+ }
971
+
972
+ ruleset = $(this.block);
973
+
974
+ if (ruleset) {
975
+ return new(tree.mixin.Definition)(name, params, ruleset, cond, variadic);
976
+ } else {
977
+ restore();
978
+ }
979
+ }
980
+ }
981
+ },
982
+
983
+ //
984
+ // Entities are the smallest recognized token,
985
+ // and can be found inside a rule's value.
986
+ //
987
+ entity: function () {
988
+ return $(this.entities.literal) || $(this.entities.variable) || $(this.entities.url) ||
989
+ $(this.entities.call) || $(this.entities.keyword) || $(this.entities.javascript) ||
990
+ $(this.comment);
991
+ },
992
+
993
+ //
994
+ // A Rule terminator. Note that we use `peek()` to check for '}',
995
+ // because the `block` rule will be expecting it, but we still need to make sure
996
+ // it's there, if ';' was ommitted.
997
+ //
998
+ end: function () {
999
+ return $(';') || peek('}');
1000
+ },
1001
+
1002
+ //
1003
+ // IE's alpha function
1004
+ //
1005
+ // alpha(opacity=88)
1006
+ //
1007
+ alpha: function () {
1008
+ var value;
1009
+
1010
+ if (! $(/^\(opacity=/i)) return;
1011
+ if (value = $(/^\d+/) || $(this.entities.variable)) {
1012
+ expect(')');
1013
+ return new(tree.Alpha)(value);
1014
+ }
1015
+ },
1016
+
1017
+ //
1018
+ // A Selector Element
1019
+ //
1020
+ // div
1021
+ // + h1
1022
+ // #socks
1023
+ // input[type="text"]
1024
+ //
1025
+ // Elements are the building blocks for Selectors,
1026
+ // they are made out of a `Combinator` (see combinator rule),
1027
+ // and an element name, such as a tag a class, or `*`.
1028
+ //
1029
+ element: function () {
1030
+ var e, t, c, v;
1031
+
1032
+ c = $(this.combinator);
1033
+ e = $(/^(?:\d+\.\d+|\d+)%/) || $(/^(?:[.#]?|:*)(?:[\w-]|\\(?:[a-fA-F0-9]{1,6} ?|[^a-fA-F0-9]))+/) ||
1034
+ $('*') || $(this.attribute) || $(/^\([^)@]+\)/);
1035
+
1036
+ if (! e) {
1037
+ $('(') && (v = $(this.entities.variable)) && $(')') && (e = new(tree.Paren)(v));
1038
+ }
1039
+
1040
+ if (e) { return new(tree.Element)(c, e, i) }
1041
+
1042
+ if (c.value && c.value.charAt(0) === '&') {
1043
+ return new(tree.Element)(c, null, i);
1044
+ }
1045
+ },
1046
+
1047
+ //
1048
+ // Combinators combine elements together, in a Selector.
1049
+ //
1050
+ // Because our parser isn't white-space sensitive, special care
1051
+ // has to be taken, when parsing the descendant combinator, ` `,
1052
+ // as it's an empty space. We have to check the previous character
1053
+ // in the input, to see if it's a ` ` character. More info on how
1054
+ // we deal with this in *combinator.js*.
1055
+ //
1056
+ combinator: function () {
1057
+ var match, c = input.charAt(i);
1058
+
1059
+ if (c === '>' || c === '+' || c === '~') {
1060
+ i++;
1061
+ while (input.charAt(i) === ' ') { i++ }
1062
+ return new(tree.Combinator)(c);
1063
+ } else if (c === '&') {
1064
+ match = '&';
1065
+ i++;
1066
+ if(input.charAt(i) === ' ') {
1067
+ match = '& ';
1068
+ }
1069
+ while (input.charAt(i) === ' ') { i++ }
1070
+ return new(tree.Combinator)(match);
1071
+ } else if (input.charAt(i - 1) === ' ') {
1072
+ return new(tree.Combinator)(" ");
1073
+ } else {
1074
+ return new(tree.Combinator)(null);
1075
+ }
1076
+ },
1077
+
1078
+ //
1079
+ // A CSS Selector
1080
+ //
1081
+ // .class > div + h1
1082
+ // li a:hover
1083
+ //
1084
+ // Selectors are made out of one or more Elements, see above.
1085
+ //
1086
+ selector: function () {
1087
+ var sel, e, elements = [], c, match;
1088
+
1089
+ if ($('(')) {
1090
+ sel = $(this.entity);
1091
+ expect(')');
1092
+ return new(tree.Selector)([new(tree.Element)('', sel, i)]);
1093
+ }
1094
+
1095
+ while (e = $(this.element)) {
1096
+ c = input.charAt(i);
1097
+ elements.push(e)
1098
+ if (c === '{' || c === '}' || c === ';' || c === ',') { break }
1099
+ }
1100
+
1101
+ if (elements.length > 0) { return new(tree.Selector)(elements) }
1102
+ },
1103
+ tag: function () {
1104
+ return $(/^[a-zA-Z][a-zA-Z-]*[0-9]?/) || $('*');
1105
+ },
1106
+ attribute: function () {
1107
+ var attr = '', key, val, op;
1108
+
1109
+ if (! $('[')) return;
1110
+
1111
+ if (key = $(/^[a-zA-Z-]+/) || $(this.entities.quoted)) {
1112
+ if ((op = $(/^[|~*$^]?=/)) &&
1113
+ (val = $(this.entities.quoted) || $(/^[\w-]+/))) {
1114
+ attr = [key, op, val.toCSS ? val.toCSS() : val].join('');
1115
+ } else { attr = key }
1116
+ }
1117
+
1118
+ if (! $(']')) return;
1119
+
1120
+ if (attr) { return "[" + attr + "]" }
1121
+ },
1122
+
1123
+ //
1124
+ // The `block` rule is used by `ruleset` and `mixin.definition`.
1125
+ // It's a wrapper around the `primary` rule, with added `{}`.
1126
+ //
1127
+ block: function () {
1128
+ var content;
1129
+
1130
+ if ($('{') && (content = $(this.primary)) && $('}')) {
1131
+ return content;
1132
+ }
1133
+ },
1134
+
1135
+ //
1136
+ // div, .class, body > p {...}
1137
+ //
1138
+ ruleset: function () {
1139
+ var selectors = [], s, rules, match;
1140
+ save();
1141
+
1142
+ while (s = $(this.selector)) {
1143
+ selectors.push(s);
1144
+ $(this.comment);
1145
+ if (! $(',')) { break }
1146
+ $(this.comment);
1147
+ }
1148
+
1149
+ if (selectors.length > 0 && (rules = $(this.block))) {
1150
+ return new(tree.Ruleset)(selectors, rules, env.strictImports);
1151
+ } else {
1152
+ // Backtrack
1153
+ furthest = i;
1154
+ restore();
1155
+ }
1156
+ },
1157
+ rule: function () {
1158
+ var name, value, c = input.charAt(i), important, match;
1159
+ save();
1160
+
1161
+ if (c === '.' || c === '#' || c === '&') { return }
1162
+
1163
+ if (name = $(this.variable) || $(this.property)) {
1164
+ if ((name.charAt(0) != '@') && (match = /^([^@+\/'"*`(;{}-]*);/.exec(chunks[j]))) {
1165
+ i += match[0].length - 1;
1166
+ value = new(tree.Anonymous)(match[1]);
1167
+ } else if (name === "font") {
1168
+ value = $(this.font);
1169
+ } else {
1170
+ value = $(this.value);
1171
+ }
1172
+ important = $(this.important);
1173
+
1174
+ if (value && $(this.end)) {
1175
+ return new(tree.Rule)(name, value, important, memo);
1176
+ } else {
1177
+ furthest = i;
1178
+ restore();
1179
+ }
1180
+ }
1181
+ },
1182
+
1183
+ //
1184
+ // An @import directive
1185
+ //
1186
+ // @import "lib";
1187
+ //
1188
+ // Depending on our environemnt, importing is done differently:
1189
+ // In the browser, it's an XHR request, in Node, it would be a
1190
+ // file-system operation. The function used for importing is
1191
+ // stored in `import`, which we pass to the Import constructor.
1192
+ //
1193
+ "import": function () {
1194
+ var path, features, index = i;
1195
+ if ($(/^@import\s+/) &&
1196
+ (path = $(this.entities.quoted) || $(this.entities.url))) {
1197
+ features = $(this.mediaFeatures);
1198
+ if ($(';')) {
1199
+ return new(tree.Import)(path, imports, features, index);
1200
+ }
1201
+ }
1202
+ },
1203
+
1204
+ mediaFeature: function () {
1205
+ var e, p, nodes = [];
1206
+
1207
+ do {
1208
+ if (e = $(this.entities.keyword)) {
1209
+ nodes.push(e);
1210
+ } else if ($('(')) {
1211
+ p = $(this.property);
1212
+ e = $(this.entity);
1213
+ if ($(')')) {
1214
+ if (p && e) {
1215
+ nodes.push(new(tree.Paren)(new(tree.Rule)(p, e, null, i, true)));
1216
+ } else if (e) {
1217
+ nodes.push(new(tree.Paren)(e));
1218
+ } else {
1219
+ return null;
1220
+ }
1221
+ } else { return null }
1222
+ }
1223
+ } while (e);
1224
+
1225
+ if (nodes.length > 0) {
1226
+ return new(tree.Expression)(nodes);
1227
+ }
1228
+ },
1229
+
1230
+ mediaFeatures: function () {
1231
+ var e, features = [];
1232
+
1233
+ do {
1234
+ if (e = $(this.mediaFeature)) {
1235
+ features.push(e);
1236
+ if (! $(',')) { break }
1237
+ } else if (e = $(this.entities.variable)) {
1238
+ features.push(e);
1239
+ if (! $(',')) { break }
1240
+ }
1241
+ } while (e);
1242
+
1243
+ return features.length > 0 ? features : null;
1244
+ },
1245
+
1246
+ media: function () {
1247
+ var features, rules;
1248
+
1249
+ if ($(/^@media/)) {
1250
+ features = $(this.mediaFeatures);
1251
+
1252
+ if (rules = $(this.block)) {
1253
+ return new(tree.Media)(rules, features);
1254
+ }
1255
+ }
1256
+ },
1257
+
1258
+ //
1259
+ // A CSS Directive
1260
+ //
1261
+ // @charset "utf-8";
1262
+ //
1263
+ directive: function () {
1264
+ var name, value, rules, types, e, nodes;
1265
+
1266
+ if (input.charAt(i) !== '@') return;
1267
+
1268
+ if (value = $(this['import']) || $(this.media)) {
1269
+ return value;
1270
+ } else if (name = $(/^@page|@keyframes/) || $(/^@(?:-webkit-|-moz-|-o-|-ms-)[a-z0-9-]+/)) {
1271
+ types = ($(/^[^{]+/) || '').trim();
1272
+ if (rules = $(this.block)) {
1273
+ return new(tree.Directive)(name + " " + types, rules);
1274
+ }
1275
+ } else if (name = $(/^@[-a-z]+/)) {
1276
+ if (name === '@font-face') {
1277
+ if (rules = $(this.block)) {
1278
+ return new(tree.Directive)(name, rules);
1279
+ }
1280
+ } else if ((value = $(this.entity)) && $(';')) {
1281
+ return new(tree.Directive)(name, value);
1282
+ }
1283
+ }
1284
+ },
1285
+ font: function () {
1286
+ var value = [], expression = [], weight, shorthand, font, e;
1287
+
1288
+ while (e = $(this.shorthand) || $(this.entity)) {
1289
+ expression.push(e);
1290
+ }
1291
+ value.push(new(tree.Expression)(expression));
1292
+
1293
+ if ($(',')) {
1294
+ while (e = $(this.expression)) {
1295
+ value.push(e);
1296
+ if (! $(',')) { break }
1297
+ }
1298
+ }
1299
+ return new(tree.Value)(value);
1300
+ },
1301
+
1302
+ //
1303
+ // A Value is a comma-delimited list of Expressions
1304
+ //
1305
+ // font-family: Baskerville, Georgia, serif;
1306
+ //
1307
+ // In a Rule, a Value represents everything after the `:`,
1308
+ // and before the `;`.
1309
+ //
1310
+ value: function () {
1311
+ var e, expressions = [], important;
1312
+
1313
+ while (e = $(this.expression)) {
1314
+ expressions.push(e);
1315
+ if (! $(',')) { break }
1316
+ }
1317
+
1318
+ if (expressions.length > 0) {
1319
+ return new(tree.Value)(expressions);
1320
+ }
1321
+ },
1322
+ important: function () {
1323
+ if (input.charAt(i) === '!') {
1324
+ return $(/^! *important/);
1325
+ }
1326
+ },
1327
+ sub: function () {
1328
+ var e;
1329
+
1330
+ if ($('(') && (e = $(this.expression)) && $(')')) {
1331
+ return e;
1332
+ }
1333
+ },
1334
+ multiplication: function () {
1335
+ var m, a, op, operation;
1336
+ if (m = $(this.operand)) {
1337
+ while (!peek(/^\/\*/) && (op = ($('/') || $('*'))) && (a = $(this.operand))) {
1338
+ operation = new(tree.Operation)(op, [operation || m, a]);
1339
+ }
1340
+ return operation || m;
1341
+ }
1342
+ },
1343
+ addition: function () {
1344
+ var m, a, op, operation;
1345
+ if (m = $(this.multiplication)) {
1346
+ while ((op = $(/^[-+]\s+/) || (input.charAt(i - 1) != ' ' && ($('+') || $('-')))) &&
1347
+ (a = $(this.multiplication))) {
1348
+ operation = new(tree.Operation)(op, [operation || m, a]);
1349
+ }
1350
+ return operation || m;
1351
+ }
1352
+ },
1353
+ conditions: function () {
1354
+ var a, b, index = i, condition;
1355
+
1356
+ if (a = $(this.condition)) {
1357
+ while ($(',') && (b = $(this.condition))) {
1358
+ condition = new(tree.Condition)('or', condition || a, b, index);
1359
+ }
1360
+ return condition || a;
1361
+ }
1362
+ },
1363
+ condition: function () {
1364
+ var a, b, c, op, index = i, negate = false;
1365
+
1366
+ if ($(/^not/)) { negate = true }
1367
+ expect('(');
1368
+ if (a = $(this.addition) || $(this.entities.keyword) || $(this.entities.quoted)) {
1369
+ if (op = $(/^(?:>=|=<|[<=>])/)) {
1370
+ if (b = $(this.addition) || $(this.entities.keyword) || $(this.entities.quoted)) {
1371
+ c = new(tree.Condition)(op, a, b, index, negate);
1372
+ } else {
1373
+ error('expected expression');
1374
+ }
1375
+ } else {
1376
+ c = new(tree.Condition)('=', a, new(tree.Keyword)('true'), index, negate);
1377
+ }
1378
+ expect(')');
1379
+ return $(/^and/) ? new(tree.Condition)('and', c, $(this.condition)) : c;
1380
+ }
1381
+ },
1382
+
1383
+ //
1384
+ // An operand is anything that can be part of an operation,
1385
+ // such as a Color, or a Variable
1386
+ //
1387
+ operand: function () {
1388
+ var negate, p = input.charAt(i + 1);
1389
+
1390
+ if (input.charAt(i) === '-' && (p === '@' || p === '(')) { negate = $('-') }
1391
+ var o = $(this.sub) || $(this.entities.dimension) ||
1392
+ $(this.entities.color) || $(this.entities.variable) ||
1393
+ $(this.entities.call);
1394
+ return negate ? new(tree.Operation)('*', [new(tree.Dimension)(-1), o])
1395
+ : o;
1396
+ },
1397
+
1398
+ //
1399
+ // Expressions either represent mathematical operations,
1400
+ // or white-space delimited Entities.
1401
+ //
1402
+ // 1px solid black
1403
+ // @var * 2
1404
+ //
1405
+ expression: function () {
1406
+ var e, delim, entities = [], d;
1407
+
1408
+ while (e = $(this.addition) || $(this.entity)) {
1409
+ entities.push(e);
1410
+ }
1411
+ if (entities.length > 0) {
1412
+ return new(tree.Expression)(entities);
1413
+ }
1414
+ },
1415
+ property: function () {
1416
+ var name;
1417
+
1418
+ if (name = $(/^(\*?-?[-a-z_0-9]+)\s*:/)) {
1419
+ return name[1];
1420
+ }
1421
+ }
1422
+ }
1423
+ };
1424
+ };
1425
+
1426
+ if (less.mode === 'browser' || less.mode === 'rhino') {
1427
+ //
1428
+ // Used by `@import` directives
1429
+ //
1430
+ less.Parser.importer = function (path, paths, callback, env) {
1431
+ if (!/^([a-z]+:)?\//.test(path) && paths.length > 0) {
1432
+ path = paths[0] + path;
1433
+ }
1434
+ // We pass `true` as 3rd argument, to force the reload of the import.
1435
+ // This is so we can get the syntax tree as opposed to just the CSS output,
1436
+ // as we need this to evaluate the current stylesheet.
1437
+ loadStyleSheet({ href: path, title: path, type: env.mime }, function (e) {
1438
+ if (e && typeof(env.errback) === "function") {
1439
+ env.errback.call(null, path, paths, callback, env);
1440
+ } else {
1441
+ callback.apply(null, arguments);
1442
+ }
1443
+ }, true);
1444
+ };
1445
+ }
1446
+
1447
+ (function (tree) {
1448
+
1449
+ tree.functions = {
1450
+ rgb: function (r, g, b) {
1451
+ return this.rgba(r, g, b, 1.0);
1452
+ },
1453
+ rgba: function (r, g, b, a) {
1454
+ var rgb = [r, g, b].map(function (c) { return number(c) }),
1455
+ a = number(a);
1456
+ return new(tree.Color)(rgb, a);
1457
+ },
1458
+ hsl: function (h, s, l) {
1459
+ return this.hsla(h, s, l, 1.0);
1460
+ },
1461
+ hsla: function (h, s, l, a) {
1462
+ h = (number(h) % 360) / 360;
1463
+ s = number(s); l = number(l); a = number(a);
1464
+
1465
+ var m2 = l <= 0.5 ? l * (s + 1) : l + s - l * s;
1466
+ var m1 = l * 2 - m2;
1467
+
1468
+ return this.rgba(hue(h + 1/3) * 255,
1469
+ hue(h) * 255,
1470
+ hue(h - 1/3) * 255,
1471
+ a);
1472
+
1473
+ function hue(h) {
1474
+ h = h < 0 ? h + 1 : (h > 1 ? h - 1 : h);
1475
+ if (h * 6 < 1) return m1 + (m2 - m1) * h * 6;
1476
+ else if (h * 2 < 1) return m2;
1477
+ else if (h * 3 < 2) return m1 + (m2 - m1) * (2/3 - h) * 6;
1478
+ else return m1;
1479
+ }
1480
+ },
1481
+ hue: function (color) {
1482
+ return new(tree.Dimension)(Math.round(color.toHSL().h));
1483
+ },
1484
+ saturation: function (color) {
1485
+ return new(tree.Dimension)(Math.round(color.toHSL().s * 100), '%');
1486
+ },
1487
+ lightness: function (color) {
1488
+ return new(tree.Dimension)(Math.round(color.toHSL().l * 100), '%');
1489
+ },
1490
+ alpha: function (color) {
1491
+ return new(tree.Dimension)(color.toHSL().a);
1492
+ },
1493
+ saturate: function (color, amount) {
1494
+ var hsl = color.toHSL();
1495
+
1496
+ hsl.s += amount.value / 100;
1497
+ hsl.s = clamp(hsl.s);
1498
+ return hsla(hsl);
1499
+ },
1500
+ desaturate: function (color, amount) {
1501
+ var hsl = color.toHSL();
1502
+
1503
+ hsl.s -= amount.value / 100;
1504
+ hsl.s = clamp(hsl.s);
1505
+ return hsla(hsl);
1506
+ },
1507
+ lighten: function (color, amount) {
1508
+ var hsl = color.toHSL();
1509
+
1510
+ hsl.l += amount.value / 100;
1511
+ hsl.l = clamp(hsl.l);
1512
+ return hsla(hsl);
1513
+ },
1514
+ darken: function (color, amount) {
1515
+ var hsl = color.toHSL();
1516
+
1517
+ hsl.l -= amount.value / 100;
1518
+ hsl.l = clamp(hsl.l);
1519
+ return hsla(hsl);
1520
+ },
1521
+ fadein: function (color, amount) {
1522
+ var hsl = color.toHSL();
1523
+
1524
+ hsl.a += amount.value / 100;
1525
+ hsl.a = clamp(hsl.a);
1526
+ return hsla(hsl);
1527
+ },
1528
+ fadeout: function (color, amount) {
1529
+ var hsl = color.toHSL();
1530
+
1531
+ hsl.a -= amount.value / 100;
1532
+ hsl.a = clamp(hsl.a);
1533
+ return hsla(hsl);
1534
+ },
1535
+ fade: function (color, amount) {
1536
+ var hsl = color.toHSL();
1537
+
1538
+ hsl.a = amount.value / 100;
1539
+ hsl.a = clamp(hsl.a);
1540
+ return hsla(hsl);
1541
+ },
1542
+ spin: function (color, amount) {
1543
+ var hsl = color.toHSL();
1544
+ var hue = (hsl.h + amount.value) % 360;
1545
+
1546
+ hsl.h = hue < 0 ? 360 + hue : hue;
1547
+
1548
+ return hsla(hsl);
1549
+ },
1550
+ //
1551
+ // Copyright (c) 2006-2009 Hampton Catlin, Nathan Weizenbaum, and Chris Eppstein
1552
+ // http://sass-lang.com
1553
+ //
1554
+ mix: function (color1, color2, weight) {
1555
+ var p = weight.value / 100.0;
1556
+ var w = p * 2 - 1;
1557
+ var a = color1.toHSL().a - color2.toHSL().a;
1558
+
1559
+ var w1 = (((w * a == -1) ? w : (w + a) / (1 + w * a)) + 1) / 2.0;
1560
+ var w2 = 1 - w1;
1561
+
1562
+ var rgb = [color1.rgb[0] * w1 + color2.rgb[0] * w2,
1563
+ color1.rgb[1] * w1 + color2.rgb[1] * w2,
1564
+ color1.rgb[2] * w1 + color2.rgb[2] * w2];
1565
+
1566
+ var alpha = color1.alpha * p + color2.alpha * (1 - p);
1567
+
1568
+ return new(tree.Color)(rgb, alpha);
1569
+ },
1570
+ greyscale: function (color) {
1571
+ return this.desaturate(color, new(tree.Dimension)(100));
1572
+ },
1573
+ e: function (str) {
1574
+ return new(tree.Anonymous)(str instanceof tree.JavaScript ? str.evaluated : str);
1575
+ },
1576
+ escape: function (str) {
1577
+ return new(tree.Anonymous)(encodeURI(str.value).replace(/=/g, "%3D").replace(/:/g, "%3A").replace(/#/g, "%23").replace(/;/g, "%3B").replace(/\(/g, "%28").replace(/\)/g, "%29"));
1578
+ },
1579
+ '%': function (quoted /* arg, arg, ...*/) {
1580
+ var args = Array.prototype.slice.call(arguments, 1),
1581
+ str = quoted.value;
1582
+
1583
+ for (var i = 0; i < args.length; i++) {
1584
+ str = str.replace(/%[sda]/i, function(token) {
1585
+ var value = token.match(/s/i) ? args[i].value : args[i].toCSS();
1586
+ return token.match(/[A-Z]$/) ? encodeURIComponent(value) : value;
1587
+ });
1588
+ }
1589
+ str = str.replace(/%%/g, '%');
1590
+ return new(tree.Quoted)('"' + str + '"', str);
1591
+ },
1592
+ round: function (n) {
1593
+ return this._math('round', n);
1594
+ },
1595
+ ceil: function (n) {
1596
+ return this._math('ceil', n);
1597
+ },
1598
+ floor: function (n) {
1599
+ return this._math('floor', n);
1600
+ },
1601
+ _math: function (fn, n) {
1602
+ if (n instanceof tree.Dimension) {
1603
+ return new(tree.Dimension)(Math[fn](number(n)), n.unit);
1604
+ } else if (typeof(n) === 'number') {
1605
+ return Math[fn](n);
1606
+ } else {
1607
+ throw { type: "Argument", message: "argument must be a number" };
1608
+ }
1609
+ },
1610
+ argb: function (color) {
1611
+ return new(tree.Anonymous)(color.toARGB());
1612
+
1613
+ },
1614
+ percentage: function (n) {
1615
+ return new(tree.Dimension)(n.value * 100, '%');
1616
+ },
1617
+ color: function (n) {
1618
+ if (n instanceof tree.Quoted) {
1619
+ return new(tree.Color)(n.value.slice(1));
1620
+ } else {
1621
+ throw { type: "Argument", message: "argument must be a string" };
1622
+ }
1623
+ },
1624
+ iscolor: function (n) {
1625
+ return this._isa(n, tree.Color);
1626
+ },
1627
+ isnumber: function (n) {
1628
+ return this._isa(n, tree.Dimension);
1629
+ },
1630
+ isstring: function (n) {
1631
+ return this._isa(n, tree.Quoted);
1632
+ },
1633
+ iskeyword: function (n) {
1634
+ return this._isa(n, tree.Keyword);
1635
+ },
1636
+ isurl: function (n) {
1637
+ return this._isa(n, tree.URL);
1638
+ },
1639
+ ispixel: function (n) {
1640
+ return (n instanceof tree.Dimension) && n.unit === 'px' ? tree.True : tree.False;
1641
+ },
1642
+ ispercentage: function (n) {
1643
+ return (n instanceof tree.Dimension) && n.unit === '%' ? tree.True : tree.False;
1644
+ },
1645
+ isem: function (n) {
1646
+ return (n instanceof tree.Dimension) && n.unit === 'em' ? tree.True : tree.False;
1647
+ },
1648
+ _isa: function (n, Type) {
1649
+ return (n instanceof Type) ? tree.True : tree.False;
1650
+ }
1651
+ };
1652
+
1653
+ function hsla(hsla) {
1654
+ return tree.functions.hsla(hsla.h, hsla.s, hsla.l, hsla.a);
1655
+ }
1656
+
1657
+ function number(n) {
1658
+ if (n instanceof tree.Dimension) {
1659
+ return parseFloat(n.unit == '%' ? n.value / 100 : n.value);
1660
+ } else if (typeof(n) === 'number') {
1661
+ return n;
1662
+ } else {
1663
+ throw {
1664
+ error: "RuntimeError",
1665
+ message: "color functions take numbers as parameters"
1666
+ };
1667
+ }
1668
+ }
1669
+
1670
+ function clamp(val) {
1671
+ return Math.min(1, Math.max(0, val));
1672
+ }
1673
+
1674
+ })(require('./tree'));
1675
+ (function (tree) {
1676
+ tree.colors = {
1677
+ 'aliceblue':'#f0f8ff',
1678
+ 'antiquewhite':'#faebd7',
1679
+ 'aqua':'#00ffff',
1680
+ 'aquamarine':'#7fffd4',
1681
+ 'azure':'#f0ffff',
1682
+ 'beige':'#f5f5dc',
1683
+ 'bisque':'#ffe4c4',
1684
+ 'black':'#000000',
1685
+ 'blanchedalmond':'#ffebcd',
1686
+ 'blue':'#0000ff',
1687
+ 'blueviolet':'#8a2be2',
1688
+ 'brown':'#a52a2a',
1689
+ 'burlywood':'#deb887',
1690
+ 'cadetblue':'#5f9ea0',
1691
+ 'chartreuse':'#7fff00',
1692
+ 'chocolate':'#d2691e',
1693
+ 'coral':'#ff7f50',
1694
+ 'cornflowerblue':'#6495ed',
1695
+ 'cornsilk':'#fff8dc',
1696
+ 'crimson':'#dc143c',
1697
+ 'cyan':'#00ffff',
1698
+ 'darkblue':'#00008b',
1699
+ 'darkcyan':'#008b8b',
1700
+ 'darkgoldenrod':'#b8860b',
1701
+ 'darkgray':'#a9a9a9',
1702
+ 'darkgrey':'#a9a9a9',
1703
+ 'darkgreen':'#006400',
1704
+ 'darkkhaki':'#bdb76b',
1705
+ 'darkmagenta':'#8b008b',
1706
+ 'darkolivegreen':'#556b2f',
1707
+ 'darkorange':'#ff8c00',
1708
+ 'darkorchid':'#9932cc',
1709
+ 'darkred':'#8b0000',
1710
+ 'darksalmon':'#e9967a',
1711
+ 'darkseagreen':'#8fbc8f',
1712
+ 'darkslateblue':'#483d8b',
1713
+ 'darkslategray':'#2f4f4f',
1714
+ 'darkslategrey':'#2f4f4f',
1715
+ 'darkturquoise':'#00ced1',
1716
+ 'darkviolet':'#9400d3',
1717
+ 'deeppink':'#ff1493',
1718
+ 'deepskyblue':'#00bfff',
1719
+ 'dimgray':'#696969',
1720
+ 'dimgrey':'#696969',
1721
+ 'dodgerblue':'#1e90ff',
1722
+ 'firebrick':'#b22222',
1723
+ 'floralwhite':'#fffaf0',
1724
+ 'forestgreen':'#228b22',
1725
+ 'fuchsia':'#ff00ff',
1726
+ 'gainsboro':'#dcdcdc',
1727
+ 'ghostwhite':'#f8f8ff',
1728
+ 'gold':'#ffd700',
1729
+ 'goldenrod':'#daa520',
1730
+ 'gray':'#808080',
1731
+ 'grey':'#808080',
1732
+ 'green':'#008000',
1733
+ 'greenyellow':'#adff2f',
1734
+ 'honeydew':'#f0fff0',
1735
+ 'hotpink':'#ff69b4',
1736
+ 'indianred':'#cd5c5c',
1737
+ 'indigo':'#4b0082',
1738
+ 'ivory':'#fffff0',
1739
+ 'khaki':'#f0e68c',
1740
+ 'lavender':'#e6e6fa',
1741
+ 'lavenderblush':'#fff0f5',
1742
+ 'lawngreen':'#7cfc00',
1743
+ 'lemonchiffon':'#fffacd',
1744
+ 'lightblue':'#add8e6',
1745
+ 'lightcoral':'#f08080',
1746
+ 'lightcyan':'#e0ffff',
1747
+ 'lightgoldenrodyellow':'#fafad2',
1748
+ 'lightgray':'#d3d3d3',
1749
+ 'lightgrey':'#d3d3d3',
1750
+ 'lightgreen':'#90ee90',
1751
+ 'lightpink':'#ffb6c1',
1752
+ 'lightsalmon':'#ffa07a',
1753
+ 'lightseagreen':'#20b2aa',
1754
+ 'lightskyblue':'#87cefa',
1755
+ 'lightslategray':'#778899',
1756
+ 'lightslategrey':'#778899',
1757
+ 'lightsteelblue':'#b0c4de',
1758
+ 'lightyellow':'#ffffe0',
1759
+ 'lime':'#00ff00',
1760
+ 'limegreen':'#32cd32',
1761
+ 'linen':'#faf0e6',
1762
+ 'magenta':'#ff00ff',
1763
+ 'maroon':'#800000',
1764
+ 'mediumaquamarine':'#66cdaa',
1765
+ 'mediumblue':'#0000cd',
1766
+ 'mediumorchid':'#ba55d3',
1767
+ 'mediumpurple':'#9370d8',
1768
+ 'mediumseagreen':'#3cb371',
1769
+ 'mediumslateblue':'#7b68ee',
1770
+ 'mediumspringgreen':'#00fa9a',
1771
+ 'mediumturquoise':'#48d1cc',
1772
+ 'mediumvioletred':'#c71585',
1773
+ 'midnightblue':'#191970',
1774
+ 'mintcream':'#f5fffa',
1775
+ 'mistyrose':'#ffe4e1',
1776
+ 'moccasin':'#ffe4b5',
1777
+ 'navajowhite':'#ffdead',
1778
+ 'navy':'#000080',
1779
+ 'oldlace':'#fdf5e6',
1780
+ 'olive':'#808000',
1781
+ 'olivedrab':'#6b8e23',
1782
+ 'orange':'#ffa500',
1783
+ 'orangered':'#ff4500',
1784
+ 'orchid':'#da70d6',
1785
+ 'palegoldenrod':'#eee8aa',
1786
+ 'palegreen':'#98fb98',
1787
+ 'paleturquoise':'#afeeee',
1788
+ 'palevioletred':'#d87093',
1789
+ 'papayawhip':'#ffefd5',
1790
+ 'peachpuff':'#ffdab9',
1791
+ 'peru':'#cd853f',
1792
+ 'pink':'#ffc0cb',
1793
+ 'plum':'#dda0dd',
1794
+ 'powderblue':'#b0e0e6',
1795
+ 'purple':'#800080',
1796
+ 'red':'#ff0000',
1797
+ 'rosybrown':'#bc8f8f',
1798
+ 'royalblue':'#4169e1',
1799
+ 'saddlebrown':'#8b4513',
1800
+ 'salmon':'#fa8072',
1801
+ 'sandybrown':'#f4a460',
1802
+ 'seagreen':'#2e8b57',
1803
+ 'seashell':'#fff5ee',
1804
+ 'sienna':'#a0522d',
1805
+ 'silver':'#c0c0c0',
1806
+ 'skyblue':'#87ceeb',
1807
+ 'slateblue':'#6a5acd',
1808
+ 'slategray':'#708090',
1809
+ 'slategrey':'#708090',
1810
+ 'snow':'#fffafa',
1811
+ 'springgreen':'#00ff7f',
1812
+ 'steelblue':'#4682b4',
1813
+ 'tan':'#d2b48c',
1814
+ 'teal':'#008080',
1815
+ 'thistle':'#d8bfd8',
1816
+ 'tomato':'#ff6347',
1817
+ 'turquoise':'#40e0d0',
1818
+ 'violet':'#ee82ee',
1819
+ 'wheat':'#f5deb3',
1820
+ 'white':'#ffffff',
1821
+ 'whitesmoke':'#f5f5f5',
1822
+ 'yellow':'#ffff00',
1823
+ 'yellowgreen':'#9acd32'
1824
+ };
1825
+ })(require('./tree'));
1826
+ (function (tree) {
1827
+
1828
+ tree.Alpha = function (val) {
1829
+ this.value = val;
1830
+ };
1831
+ tree.Alpha.prototype = {
1832
+ toCSS: function () {
1833
+ return "alpha(opacity=" +
1834
+ (this.value.toCSS ? this.value.toCSS() : this.value) + ")";
1835
+ },
1836
+ eval: function (env) {
1837
+ if (this.value.eval) { this.value = this.value.eval(env) }
1838
+ return this;
1839
+ }
1840
+ };
1841
+
1842
+ })(require('../tree'));
1843
+ (function (tree) {
1844
+
1845
+ tree.Anonymous = function (string) {
1846
+ this.value = string.value || string;
1847
+ };
1848
+ tree.Anonymous.prototype = {
1849
+ toCSS: function () {
1850
+ return this.value;
1851
+ },
1852
+ eval: function () { return this }
1853
+ };
1854
+
1855
+ })(require('../tree'));
1856
+ (function (tree) {
1857
+
1858
+ tree.Assignment = function (key, val) {
1859
+ this.key = key;
1860
+ this.value = val;
1861
+ };
1862
+ tree.Assignment.prototype = {
1863
+ toCSS: function () {
1864
+ return this.key + '=' + (this.value.toCSS ? this.value.toCSS() : this.value);
1865
+ },
1866
+ eval: function (env) {
1867
+ if (this.value.eval) { this.value = this.value.eval(env) }
1868
+ return this;
1869
+ }
1870
+ };
1871
+
1872
+ })(require('../tree'));(function (tree) {
1873
+
1874
+ //
1875
+ // A function call node.
1876
+ //
1877
+ tree.Call = function (name, args, index, filename) {
1878
+ this.name = name;
1879
+ this.args = args;
1880
+ this.index = index;
1881
+ this.filename = filename;
1882
+ };
1883
+ tree.Call.prototype = {
1884
+ //
1885
+ // When evaluating a function call,
1886
+ // we either find the function in `tree.functions` [1],
1887
+ // in which case we call it, passing the evaluated arguments,
1888
+ // or we simply print it out as it appeared originally [2].
1889
+ //
1890
+ // The *functions.js* file contains the built-in functions.
1891
+ //
1892
+ // The reason why we evaluate the arguments, is in the case where
1893
+ // we try to pass a variable to a function, like: `saturate(@color)`.
1894
+ // The function should receive the value, not the variable.
1895
+ //
1896
+ eval: function (env) {
1897
+ var args = this.args.map(function (a) { return a.eval(env) });
1898
+
1899
+ if (this.name in tree.functions) { // 1.
1900
+ try {
1901
+ return tree.functions[this.name].apply(tree.functions, args);
1902
+ } catch (e) {
1903
+ throw { type: e.type || "Runtime",
1904
+ message: "error evaluating function `" + this.name + "`" +
1905
+ (e.message ? ': ' + e.message : ''),
1906
+ index: this.index, filename: this.filename };
1907
+ }
1908
+ } else { // 2.
1909
+ return new(tree.Anonymous)(this.name +
1910
+ "(" + args.map(function (a) { return a.toCSS() }).join(', ') + ")");
1911
+ }
1912
+ },
1913
+
1914
+ toCSS: function (env) {
1915
+ return this.eval(env).toCSS();
1916
+ }
1917
+ };
1918
+
1919
+ })(require('../tree'));
1920
+ (function (tree) {
1921
+ //
1922
+ // RGB Colors - #ff0014, #eee
1923
+ //
1924
+ tree.Color = function (rgb, a) {
1925
+ //
1926
+ // The end goal here, is to parse the arguments
1927
+ // into an integer triplet, such as `128, 255, 0`
1928
+ //
1929
+ // This facilitates operations and conversions.
1930
+ //
1931
+ if (Array.isArray(rgb)) {
1932
+ this.rgb = rgb;
1933
+ } else if (rgb.length == 6) {
1934
+ this.rgb = rgb.match(/.{2}/g).map(function (c) {
1935
+ return parseInt(c, 16);
1936
+ });
1937
+ } else {
1938
+ this.rgb = rgb.split('').map(function (c) {
1939
+ return parseInt(c + c, 16);
1940
+ });
1941
+ }
1942
+ this.alpha = typeof(a) === 'number' ? a : 1;
1943
+ };
1944
+ tree.Color.prototype = {
1945
+ eval: function () { return this },
1946
+
1947
+ //
1948
+ // If we have some transparency, the only way to represent it
1949
+ // is via `rgba`. Otherwise, we use the hex representation,
1950
+ // which has better compatibility with older browsers.
1951
+ // Values are capped between `0` and `255`, rounded and zero-padded.
1952
+ //
1953
+ toCSS: function () {
1954
+ if (this.alpha < 1.0) {
1955
+ return "rgba(" + this.rgb.map(function (c) {
1956
+ return Math.round(c);
1957
+ }).concat(this.alpha).join(', ') + ")";
1958
+ } else {
1959
+ return '#' + this.rgb.map(function (i) {
1960
+ i = Math.round(i);
1961
+ i = (i > 255 ? 255 : (i < 0 ? 0 : i)).toString(16);
1962
+ return i.length === 1 ? '0' + i : i;
1963
+ }).join('');
1964
+ }
1965
+ },
1966
+
1967
+ //
1968
+ // Operations have to be done per-channel, if not,
1969
+ // channels will spill onto each other. Once we have
1970
+ // our result, in the form of an integer triplet,
1971
+ // we create a new Color node to hold the result.
1972
+ //
1973
+ operate: function (op, other) {
1974
+ var result = [];
1975
+
1976
+ if (! (other instanceof tree.Color)) {
1977
+ other = other.toColor();
1978
+ }
1979
+
1980
+ for (var c = 0; c < 3; c++) {
1981
+ result[c] = tree.operate(op, this.rgb[c], other.rgb[c]);
1982
+ }
1983
+ return new(tree.Color)(result, this.alpha + other.alpha);
1984
+ },
1985
+
1986
+ toHSL: function () {
1987
+ var r = this.rgb[0] / 255,
1988
+ g = this.rgb[1] / 255,
1989
+ b = this.rgb[2] / 255,
1990
+ a = this.alpha;
1991
+
1992
+ var max = Math.max(r, g, b), min = Math.min(r, g, b);
1993
+ var h, s, l = (max + min) / 2, d = max - min;
1994
+
1995
+ if (max === min) {
1996
+ h = s = 0;
1997
+ } else {
1998
+ s = l > 0.5 ? d / (2 - max - min) : d / (max + min);
1999
+
2000
+ switch (max) {
2001
+ case r: h = (g - b) / d + (g < b ? 6 : 0); break;
2002
+ case g: h = (b - r) / d + 2; break;
2003
+ case b: h = (r - g) / d + 4; break;
2004
+ }
2005
+ h /= 6;
2006
+ }
2007
+ return { h: h * 360, s: s, l: l, a: a };
2008
+ },
2009
+ toARGB: function () {
2010
+ var argb = [Math.round(this.alpha * 255)].concat(this.rgb);
2011
+ return '#' + argb.map(function (i) {
2012
+ i = Math.round(i);
2013
+ i = (i > 255 ? 255 : (i < 0 ? 0 : i)).toString(16);
2014
+ return i.length === 1 ? '0' + i : i;
2015
+ }).join('');
2016
+ }
2017
+ };
2018
+
2019
+
2020
+ })(require('../tree'));
2021
+ (function (tree) {
2022
+
2023
+ tree.Comment = function (value, silent) {
2024
+ this.value = value;
2025
+ this.silent = !!silent;
2026
+ };
2027
+ tree.Comment.prototype = {
2028
+ toCSS: function (env) {
2029
+ return env.compress ? '' : this.value;
2030
+ },
2031
+ eval: function () { return this }
2032
+ };
2033
+
2034
+ })(require('../tree'));
2035
+ (function (tree) {
2036
+
2037
+ tree.Condition = function (op, l, r, i, negate) {
2038
+ this.op = op.trim();
2039
+ this.lvalue = l;
2040
+ this.rvalue = r;
2041
+ this.index = i;
2042
+ this.negate = negate;
2043
+ };
2044
+ tree.Condition.prototype.eval = function (env) {
2045
+ var a = this.lvalue.eval(env),
2046
+ b = this.rvalue.eval(env);
2047
+
2048
+ var i = this.index, result;
2049
+
2050
+ var result = (function (op) {
2051
+ switch (op) {
2052
+ case 'and':
2053
+ return a && b;
2054
+ case 'or':
2055
+ return a || b;
2056
+ default:
2057
+ if (a.compare) {
2058
+ result = a.compare(b);
2059
+ } else if (b.compare) {
2060
+ result = b.compare(a);
2061
+ } else {
2062
+ throw { type: "Type",
2063
+ message: "Unable to perform comparison",
2064
+ index: i };
2065
+ }
2066
+ switch (result) {
2067
+ case -1: return op === '<' || op === '=<';
2068
+ case 0: return op === '=' || op === '>=' || op === '=<';
2069
+ case 1: return op === '>' || op === '>=';
2070
+ }
2071
+ }
2072
+ })(this.op);
2073
+ return this.negate ? !result : result;
2074
+ };
2075
+
2076
+ })(require('../tree'));
2077
+ (function (tree) {
2078
+
2079
+ //
2080
+ // A number with a unit
2081
+ //
2082
+ tree.Dimension = function (value, unit) {
2083
+ this.value = parseFloat(value);
2084
+ this.unit = unit || null;
2085
+ };
2086
+
2087
+ tree.Dimension.prototype = {
2088
+ eval: function () { return this },
2089
+ toColor: function () {
2090
+ return new(tree.Color)([this.value, this.value, this.value]);
2091
+ },
2092
+ toCSS: function () {
2093
+ var css = this.value + this.unit;
2094
+ return css;
2095
+ },
2096
+
2097
+ // In an operation between two Dimensions,
2098
+ // we default to the first Dimension's unit,
2099
+ // so `1px + 2em` will yield `3px`.
2100
+ // In the future, we could implement some unit
2101
+ // conversions such that `100cm + 10mm` would yield
2102
+ // `101cm`.
2103
+ operate: function (op, other) {
2104
+ return new(tree.Dimension)
2105
+ (tree.operate(op, this.value, other.value),
2106
+ this.unit || other.unit);
2107
+ },
2108
+
2109
+ // TODO: Perform unit conversion before comparing
2110
+ compare: function (other) {
2111
+ if (other instanceof tree.Dimension) {
2112
+ if (other.value > this.value) {
2113
+ return -1;
2114
+ } else if (other.value < this.value) {
2115
+ return 1;
2116
+ } else {
2117
+ return 0;
2118
+ }
2119
+ } else {
2120
+ return -1;
2121
+ }
2122
+ }
2123
+ };
2124
+
2125
+ })(require('../tree'));
2126
+ (function (tree) {
2127
+
2128
+ tree.Directive = function (name, value, features) {
2129
+ this.name = name;
2130
+
2131
+ if (Array.isArray(value)) {
2132
+ this.ruleset = new(tree.Ruleset)([], value);
2133
+ this.ruleset.allowImports = true;
2134
+ } else {
2135
+ this.value = value;
2136
+ }
2137
+ };
2138
+ tree.Directive.prototype = {
2139
+ toCSS: function (ctx, env) {
2140
+ if (this.ruleset) {
2141
+ this.ruleset.root = true;
2142
+ return this.name + (env.compress ? '{' : ' {\n ') +
2143
+ this.ruleset.toCSS(ctx, env).trim().replace(/\n/g, '\n ') +
2144
+ (env.compress ? '}': '\n}\n');
2145
+ } else {
2146
+ return this.name + ' ' + this.value.toCSS() + ';\n';
2147
+ }
2148
+ },
2149
+ eval: function (env) {
2150
+ env.frames.unshift(this);
2151
+ this.ruleset = this.ruleset && this.ruleset.eval(env);
2152
+ env.frames.shift();
2153
+ return this;
2154
+ },
2155
+ variable: function (name) { return tree.Ruleset.prototype.variable.call(this.ruleset, name) },
2156
+ find: function () { return tree.Ruleset.prototype.find.apply(this.ruleset, arguments) },
2157
+ rulesets: function () { return tree.Ruleset.prototype.rulesets.apply(this.ruleset) }
2158
+ };
2159
+
2160
+ })(require('../tree'));
2161
+ (function (tree) {
2162
+
2163
+ tree.Element = function (combinator, value, index) {
2164
+ this.combinator = combinator instanceof tree.Combinator ?
2165
+ combinator : new(tree.Combinator)(combinator);
2166
+
2167
+ if (typeof(value) === 'string') {
2168
+ this.value = value.trim();
2169
+ } else if (value) {
2170
+ this.value = value;
2171
+ } else {
2172
+ this.value = "";
2173
+ }
2174
+ this.index = index;
2175
+ };
2176
+ tree.Element.prototype.eval = function (env) {
2177
+ return new(tree.Element)(this.combinator,
2178
+ this.value.eval ? this.value.eval(env) : this.value,
2179
+ this.index);
2180
+ };
2181
+ tree.Element.prototype.toCSS = function (env) {
2182
+ return this.combinator.toCSS(env || {}) + (this.value.toCSS ? this.value.toCSS(env) : this.value);
2183
+ };
2184
+
2185
+ tree.Combinator = function (value) {
2186
+ if (value === ' ') {
2187
+ this.value = ' ';
2188
+ } else if (value === '& ') {
2189
+ this.value = '& ';
2190
+ } else {
2191
+ this.value = value ? value.trim() : "";
2192
+ }
2193
+ };
2194
+ tree.Combinator.prototype.toCSS = function (env) {
2195
+ return {
2196
+ '' : '',
2197
+ ' ' : ' ',
2198
+ '&' : '',
2199
+ '& ' : ' ',
2200
+ ':' : ' :',
2201
+ '+' : env.compress ? '+' : ' + ',
2202
+ '~' : env.compress ? '~' : ' ~ ',
2203
+ '>' : env.compress ? '>' : ' > '
2204
+ }[this.value];
2205
+ };
2206
+
2207
+ })(require('../tree'));
2208
+ (function (tree) {
2209
+
2210
+ tree.Expression = function (value) { this.value = value };
2211
+ tree.Expression.prototype = {
2212
+ eval: function (env) {
2213
+ if (this.value.length > 1) {
2214
+ return new(tree.Expression)(this.value.map(function (e) {
2215
+ return e.eval(env);
2216
+ }));
2217
+ } else if (this.value.length === 1) {
2218
+ return this.value[0].eval(env);
2219
+ } else {
2220
+ return this;
2221
+ }
2222
+ },
2223
+ toCSS: function (env) {
2224
+ return this.value.map(function (e) {
2225
+ return e.toCSS ? e.toCSS(env) : '';
2226
+ }).join(' ');
2227
+ }
2228
+ };
2229
+
2230
+ })(require('../tree'));
2231
+ (function (tree) {
2232
+ //
2233
+ // CSS @import node
2234
+ //
2235
+ // The general strategy here is that we don't want to wait
2236
+ // for the parsing to be completed, before we start importing
2237
+ // the file. That's because in the context of a browser,
2238
+ // most of the time will be spent waiting for the server to respond.
2239
+ //
2240
+ // On creation, we push the import path to our import queue, though
2241
+ // `import,push`, we also pass it a callback, which it'll call once
2242
+ // the file has been fetched, and parsed.
2243
+ //
2244
+ tree.Import = function (path, imports, features, index) {
2245
+ var that = this;
2246
+
2247
+ this.index = index;
2248
+ this._path = path;
2249
+ this.features = features && new(tree.Value)(features);
2250
+
2251
+ // The '.less' extension is optional
2252
+ if (path instanceof tree.Quoted) {
2253
+ this.path = /\.(le?|c)ss(\?.*)?$/.test(path.value) ? path.value : path.value + '.less';
2254
+ } else {
2255
+ this.path = path.value.value || path.value;
2256
+ }
2257
+
2258
+ this.css = /css(\?.*)?$/.test(this.path);
2259
+
2260
+ // Only pre-compile .less files
2261
+ if (! this.css) {
2262
+ imports.push(this.path, function (e, root) {
2263
+ if (e) { e.index = index }
2264
+ that.root = root || new(tree.Ruleset)([], []);
2265
+ });
2266
+ }
2267
+ };
2268
+
2269
+ //
2270
+ // The actual import node doesn't return anything, when converted to CSS.
2271
+ // The reason is that it's used at the evaluation stage, so that the rules
2272
+ // it imports can be treated like any other rules.
2273
+ //
2274
+ // In `eval`, we make sure all Import nodes get evaluated, recursively, so
2275
+ // we end up with a flat structure, which can easily be imported in the parent
2276
+ // ruleset.
2277
+ //
2278
+ tree.Import.prototype = {
2279
+ toCSS: function (env) {
2280
+ var features = this.features ? ' ' + this.features.toCSS(env) : '';
2281
+
2282
+ if (this.css) {
2283
+ return "@import " + this._path.toCSS() + features + ';\n';
2284
+ } else {
2285
+ return "";
2286
+ }
2287
+ },
2288
+ eval: function (env) {
2289
+ var ruleset, features = this.features && this.features.eval(env);
2290
+
2291
+ if (this.css) {
2292
+ return this;
2293
+ } else {
2294
+ ruleset = new(tree.Ruleset)([], this.root.rules.slice(0));
2295
+
2296
+ for (var i = 0; i < ruleset.rules.length; i++) {
2297
+ if (ruleset.rules[i] instanceof tree.Import) {
2298
+ Array.prototype
2299
+ .splice
2300
+ .apply(ruleset.rules,
2301
+ [i, 1].concat(ruleset.rules[i].eval(env)));
2302
+ }
2303
+ }
2304
+ return this.features ? new(tree.Media)(ruleset.rules, this.features.value) : ruleset.rules;
2305
+ }
2306
+ }
2307
+ };
2308
+
2309
+ })(require('../tree'));
2310
+ (function (tree) {
2311
+
2312
+ tree.JavaScript = function (string, index, escaped) {
2313
+ this.escaped = escaped;
2314
+ this.expression = string;
2315
+ this.index = index;
2316
+ };
2317
+ tree.JavaScript.prototype = {
2318
+ eval: function (env) {
2319
+ var result,
2320
+ that = this,
2321
+ context = {};
2322
+
2323
+ var expression = this.expression.replace(/@\{([\w-]+)\}/g, function (_, name) {
2324
+ return tree.jsify(new(tree.Variable)('@' + name, that.index).eval(env));
2325
+ });
2326
+
2327
+ try {
2328
+ expression = new(Function)('return (' + expression + ')');
2329
+ } catch (e) {
2330
+ throw { message: "JavaScript evaluation error: `" + expression + "`" ,
2331
+ index: this.index };
2332
+ }
2333
+
2334
+ for (var k in env.frames[0].variables()) {
2335
+ context[k.slice(1)] = {
2336
+ value: env.frames[0].variables()[k].value,
2337
+ toJS: function () {
2338
+ return this.value.eval(env).toCSS();
2339
+ }
2340
+ };
2341
+ }
2342
+
2343
+ try {
2344
+ result = expression.call(context);
2345
+ } catch (e) {
2346
+ throw { message: "JavaScript evaluation error: '" + e.name + ': ' + e.message + "'" ,
2347
+ index: this.index };
2348
+ }
2349
+ if (typeof(result) === 'string') {
2350
+ return new(tree.Quoted)('"' + result + '"', result, this.escaped, this.index);
2351
+ } else if (Array.isArray(result)) {
2352
+ return new(tree.Anonymous)(result.join(', '));
2353
+ } else {
2354
+ return new(tree.Anonymous)(result);
2355
+ }
2356
+ }
2357
+ };
2358
+
2359
+ })(require('../tree'));
2360
+
2361
+ (function (tree) {
2362
+
2363
+ tree.Keyword = function (value) { this.value = value };
2364
+ tree.Keyword.prototype = {
2365
+ eval: function () { return this },
2366
+ toCSS: function () { return this.value },
2367
+ compare: function (other) {
2368
+ if (other instanceof tree.Keyword) {
2369
+ return other.value === this.value ? 0 : 1;
2370
+ } else {
2371
+ return -1;
2372
+ }
2373
+ }
2374
+ };
2375
+
2376
+ tree.True = new(tree.Keyword)('true');
2377
+ tree.False = new(tree.Keyword)('false');
2378
+
2379
+ })(require('../tree'));
2380
+ (function (tree) {
2381
+
2382
+ tree.Media = function (value, features) {
2383
+ var el = new(tree.Element)('&', null, 0),
2384
+ selectors = [new(tree.Selector)([el])];
2385
+
2386
+ this.features = new(tree.Value)(features);
2387
+ this.ruleset = new(tree.Ruleset)(selectors, value);
2388
+ this.ruleset.allowImports = true;
2389
+ };
2390
+ tree.Media.prototype = {
2391
+ toCSS: function (ctx, env) {
2392
+ var features = this.features.toCSS(env);
2393
+
2394
+ this.ruleset.root = (ctx.length === 0 || ctx[0].multiMedia);
2395
+ return '@media ' + features + (env.compress ? '{' : ' {\n ') +
2396
+ this.ruleset.toCSS(ctx, env).trim().replace(/\n/g, '\n ') +
2397
+ (env.compress ? '}': '\n}\n');
2398
+ },
2399
+ eval: function (env) {
2400
+ if (!env.mediaBlocks) {
2401
+ env.mediaBlocks = [];
2402
+ env.mediaPath = [];
2403
+ }
2404
+
2405
+ var blockIndex = env.mediaBlocks.length;
2406
+ env.mediaPath.push(this);
2407
+ env.mediaBlocks.push(this);
2408
+
2409
+ var media = new(tree.Media)([], []);
2410
+ media.features = this.features.eval(env);
2411
+
2412
+ env.frames.unshift(this.ruleset);
2413
+ media.ruleset = this.ruleset.eval(env);
2414
+ env.frames.shift();
2415
+
2416
+ env.mediaBlocks[blockIndex] = media;
2417
+ env.mediaPath.pop();
2418
+
2419
+ return env.mediaPath.length === 0 ? media.evalTop(env) :
2420
+ media.evalNested(env)
2421
+ },
2422
+ variable: function (name) { return tree.Ruleset.prototype.variable.call(this.ruleset, name) },
2423
+ find: function () { return tree.Ruleset.prototype.find.apply(this.ruleset, arguments) },
2424
+ rulesets: function () { return tree.Ruleset.prototype.rulesets.apply(this.ruleset) },
2425
+
2426
+ evalTop: function (env) {
2427
+ var result = this;
2428
+
2429
+ // Render all dependent Media blocks.
2430
+ if (env.mediaBlocks.length > 1) {
2431
+ var el = new(tree.Element)('&', null, 0);
2432
+ var selectors = [new(tree.Selector)([el])];
2433
+ result = new(tree.Ruleset)(selectors, env.mediaBlocks);
2434
+ result.multiMedia = true;
2435
+ }
2436
+
2437
+ delete env.mediaBlocks;
2438
+ delete env.mediaPath;
2439
+
2440
+ return result;
2441
+ },
2442
+ evalNested: function (env) {
2443
+ var i, value,
2444
+ path = env.mediaPath.concat([this]);
2445
+
2446
+ // Extract the media-query conditions separated with `,` (OR).
2447
+ for (i = 0; i < path.length; i++) {
2448
+ value = path[i].features instanceof tree.Value ?
2449
+ path[i].features.value : path[i].features;
2450
+ path[i] = Array.isArray(value) ? value : [value];
2451
+ }
2452
+
2453
+ // Trace all permutations to generate the resulting media-query.
2454
+ //
2455
+ // (a, b and c) with nested (d, e) ->
2456
+ // a and d
2457
+ // a and e
2458
+ // b and c and d
2459
+ // b and c and e
2460
+ this.features = new(tree.Value)(this.permute(path).map(function (path) {
2461
+ path = path.map(function (fragment) {
2462
+ return fragment.toCSS ? fragment : new(tree.Anonymous)(fragment);
2463
+ });
2464
+
2465
+ for(i = path.length - 1; i > 0; i--) {
2466
+ path.splice(i, 0, new(tree.Anonymous)("and"));
2467
+ }
2468
+
2469
+ return new(tree.Expression)(path);
2470
+ }));
2471
+
2472
+ // Fake a tree-node that doesn't output anything.
2473
+ return new(tree.Ruleset)([], []);
2474
+ },
2475
+ permute: function (arr) {
2476
+ if (arr.length === 0) {
2477
+ return [];
2478
+ } else if (arr.length === 1) {
2479
+ return arr[0];
2480
+ } else {
2481
+ var result = [];
2482
+ var rest = this.permute(arr.slice(1));
2483
+ for (var i = 0; i < rest.length; i++) {
2484
+ for (var j = 0; j < arr[0].length; j++) {
2485
+ result.push([arr[0][j]].concat(rest[i]));
2486
+ }
2487
+ }
2488
+ return result;
2489
+ }
2490
+ }
2491
+ };
2492
+
2493
+ })(require('../tree'));
2494
+ (function (tree) {
2495
+
2496
+ tree.mixin = {};
2497
+ tree.mixin.Call = function (elements, args, index, filename, important) {
2498
+ this.selector = new(tree.Selector)(elements);
2499
+ this.arguments = args;
2500
+ this.index = index;
2501
+ this.filename = filename;
2502
+ this.important = important;
2503
+ };
2504
+ tree.mixin.Call.prototype = {
2505
+ eval: function (env) {
2506
+ var mixins, args, rules = [], match = false;
2507
+
2508
+ for (var i = 0; i < env.frames.length; i++) {
2509
+ if ((mixins = env.frames[i].find(this.selector)).length > 0) {
2510
+ args = this.arguments && this.arguments.map(function (a) { return a.eval(env) });
2511
+ for (var m = 0; m < mixins.length; m++) {
2512
+ if (mixins[m].match(args, env)) {
2513
+ try {
2514
+ Array.prototype.push.apply(
2515
+ rules, mixins[m].eval(env, this.arguments, this.important).rules);
2516
+ match = true;
2517
+ } catch (e) {
2518
+ throw { message: e.message, index: this.index, filename: this.filename, stack: e.stack };
2519
+ }
2520
+ }
2521
+ }
2522
+ if (match) {
2523
+ return rules;
2524
+ } else {
2525
+ throw { type: 'Runtime',
2526
+ message: 'No matching definition was found for `' +
2527
+ this.selector.toCSS().trim() + '(' +
2528
+ this.arguments.map(function (a) {
2529
+ return a.toCSS();
2530
+ }).join(', ') + ")`",
2531
+ index: this.index, filename: this.filename };
2532
+ }
2533
+ }
2534
+ }
2535
+ throw { type: 'Name',
2536
+ message: this.selector.toCSS().trim() + " is undefined",
2537
+ index: this.index, filename: this.filename };
2538
+ }
2539
+ };
2540
+
2541
+ tree.mixin.Definition = function (name, params, rules, condition, variadic) {
2542
+ this.name = name;
2543
+ this.selectors = [new(tree.Selector)([new(tree.Element)(null, name)])];
2544
+ this.params = params;
2545
+ this.condition = condition;
2546
+ this.variadic = variadic;
2547
+ this.arity = params.length;
2548
+ this.rules = rules;
2549
+ this._lookups = {};
2550
+ this.required = params.reduce(function (count, p) {
2551
+ if (!p.name || (p.name && !p.value)) { return count + 1 }
2552
+ else { return count }
2553
+ }, 0);
2554
+ this.parent = tree.Ruleset.prototype;
2555
+ this.frames = [];
2556
+ };
2557
+ tree.mixin.Definition.prototype = {
2558
+ toCSS: function () { return "" },
2559
+ variable: function (name) { return this.parent.variable.call(this, name) },
2560
+ variables: function () { return this.parent.variables.call(this) },
2561
+ find: function () { return this.parent.find.apply(this, arguments) },
2562
+ rulesets: function () { return this.parent.rulesets.apply(this) },
2563
+
2564
+ evalParams: function (env, args) {
2565
+ var frame = new(tree.Ruleset)(null, []), varargs;
2566
+
2567
+ for (var i = 0, val, name; i < this.params.length; i++) {
2568
+ if (name = this.params[i].name) {
2569
+ if (this.params[i].variadic && args) {
2570
+ varargs = [];
2571
+ for (var j = i; j < args.length; j++) {
2572
+ varargs.push(args[j].eval(env));
2573
+ }
2574
+ frame.rules.unshift(new(tree.Rule)(name, new(tree.Expression)(varargs).eval(env)));
2575
+ } else if (val = (args && args[i]) || this.params[i].value) {
2576
+ frame.rules.unshift(new(tree.Rule)(name, val.eval(env)));
2577
+ } else {
2578
+ throw { type: 'Runtime', message: "wrong number of arguments for " + this.name +
2579
+ ' (' + args.length + ' for ' + this.arity + ')' };
2580
+ }
2581
+ }
2582
+ }
2583
+ return frame;
2584
+ },
2585
+ eval: function (env, args, important) {
2586
+ var frame = this.evalParams(env, args), context, _arguments = [], rules, start;
2587
+
2588
+ for (var i = 0; i < Math.max(this.params.length, args && args.length); i++) {
2589
+ _arguments.push(args[i] || this.params[i].value);
2590
+ }
2591
+ frame.rules.unshift(new(tree.Rule)('@arguments', new(tree.Expression)(_arguments).eval(env)));
2592
+
2593
+ rules = important ?
2594
+ this.rules.map(function (r) {
2595
+ return new(tree.Rule)(r.name, r.value, '!important', r.index);
2596
+ }) : this.rules.slice(0);
2597
+
2598
+ return new(tree.Ruleset)(null, rules).eval({
2599
+ frames: [this, frame].concat(this.frames, env.frames)
2600
+ });
2601
+ },
2602
+ match: function (args, env) {
2603
+ var argsLength = (args && args.length) || 0, len, frame;
2604
+
2605
+ if (! this.variadic) {
2606
+ if (argsLength < this.required) { return false }
2607
+ if (argsLength > this.params.length) { return false }
2608
+ if ((this.required > 0) && (argsLength > this.params.length)) { return false }
2609
+ }
2610
+
2611
+ if (this.condition && !this.condition.eval({
2612
+ frames: [this.evalParams(env, args)].concat(env.frames)
2613
+ })) { return false }
2614
+
2615
+ len = Math.min(argsLength, this.arity);
2616
+
2617
+ for (var i = 0; i < len; i++) {
2618
+ if (!this.params[i].name) {
2619
+ if (args[i].eval(env).toCSS() != this.params[i].value.eval(env).toCSS()) {
2620
+ return false;
2621
+ }
2622
+ }
2623
+ }
2624
+ return true;
2625
+ }
2626
+ };
2627
+
2628
+ })(require('../tree'));
2629
+ (function (tree) {
2630
+
2631
+ tree.Operation = function (op, operands) {
2632
+ this.op = op.trim();
2633
+ this.operands = operands;
2634
+ };
2635
+ tree.Operation.prototype.eval = function (env) {
2636
+ var a = this.operands[0].eval(env),
2637
+ b = this.operands[1].eval(env),
2638
+ temp;
2639
+
2640
+ if (a instanceof tree.Dimension && b instanceof tree.Color) {
2641
+ if (this.op === '*' || this.op === '+') {
2642
+ temp = b, b = a, a = temp;
2643
+ } else {
2644
+ throw { name: "OperationError",
2645
+ message: "Can't substract or divide a color from a number" };
2646
+ }
2647
+ }
2648
+ return a.operate(this.op, b);
2649
+ };
2650
+
2651
+ tree.operate = function (op, a, b) {
2652
+ switch (op) {
2653
+ case '+': return a + b;
2654
+ case '-': return a - b;
2655
+ case '*': return a * b;
2656
+ case '/': return a / b;
2657
+ }
2658
+ };
2659
+
2660
+ })(require('../tree'));
2661
+
2662
+ (function (tree) {
2663
+
2664
+ tree.Paren = function (node) {
2665
+ this.value = node;
2666
+ };
2667
+ tree.Paren.prototype = {
2668
+ toCSS: function (env) {
2669
+ return '(' + this.value.toCSS(env) + ')';
2670
+ },
2671
+ eval: function (env) {
2672
+ return new(tree.Paren)(this.value.eval(env));
2673
+ }
2674
+ };
2675
+
2676
+ })(require('../tree'));
2677
+ (function (tree) {
2678
+
2679
+ tree.Quoted = function (str, content, escaped, i) {
2680
+ this.escaped = escaped;
2681
+ this.value = content || '';
2682
+ this.quote = str.charAt(0);
2683
+ this.index = i;
2684
+ };
2685
+ tree.Quoted.prototype = {
2686
+ toCSS: function () {
2687
+ if (this.escaped) {
2688
+ return this.value;
2689
+ } else {
2690
+ return this.quote + this.value + this.quote;
2691
+ }
2692
+ },
2693
+ eval: function (env) {
2694
+ var that = this;
2695
+ var value = this.value.replace(/`([^`]+)`/g, function (_, exp) {
2696
+ return new(tree.JavaScript)(exp, that.index, true).eval(env).value;
2697
+ }).replace(/@\{([\w-]+)\}/g, function (_, name) {
2698
+ var v = new(tree.Variable)('@' + name, that.index).eval(env);
2699
+ return ('value' in v) ? v.value : v.toCSS();
2700
+ });
2701
+ return new(tree.Quoted)(this.quote + value + this.quote, value, this.escaped, this.index);
2702
+ }
2703
+ };
2704
+
2705
+ })(require('../tree'));
2706
+ (function (tree) {
2707
+
2708
+ tree.Rule = function (name, value, important, index, inline) {
2709
+ this.name = name;
2710
+ this.value = (value instanceof tree.Value) ? value : new(tree.Value)([value]);
2711
+ this.important = important ? ' ' + important.trim() : '';
2712
+ this.index = index;
2713
+ this.inline = inline || false;
2714
+
2715
+ if (name.charAt(0) === '@') {
2716
+ this.variable = true;
2717
+ } else { this.variable = false }
2718
+ };
2719
+ tree.Rule.prototype.toCSS = function (env) {
2720
+ if (this.variable) { return "" }
2721
+ else {
2722
+ return this.name + (env.compress ? ':' : ': ') +
2723
+ this.value.toCSS(env) +
2724
+ this.important + (this.inline ? "" : ";");
2725
+ }
2726
+ };
2727
+
2728
+ tree.Rule.prototype.eval = function (context) {
2729
+ return new(tree.Rule)(this.name,
2730
+ this.value.eval(context),
2731
+ this.important,
2732
+ this.index, this.inline);
2733
+ };
2734
+
2735
+ tree.Shorthand = function (a, b) {
2736
+ this.a = a;
2737
+ this.b = b;
2738
+ };
2739
+
2740
+ tree.Shorthand.prototype = {
2741
+ toCSS: function (env) {
2742
+ return this.a.toCSS(env) + "/" + this.b.toCSS(env);
2743
+ },
2744
+ eval: function () { return this }
2745
+ };
2746
+
2747
+ })(require('../tree'));
2748
+ (function (tree) {
2749
+
2750
+ tree.Ruleset = function (selectors, rules, strictImports) {
2751
+ this.selectors = selectors;
2752
+ this.rules = rules;
2753
+ this._lookups = {};
2754
+ this.strictImports = strictImports;
2755
+ };
2756
+ tree.Ruleset.prototype = {
2757
+ eval: function (env) {
2758
+ var selectors = this.selectors && this.selectors.map(function (s) { return s.eval(env) });
2759
+ var ruleset = new(tree.Ruleset)(selectors, this.rules.slice(0), this.strictImports);
2760
+
2761
+ ruleset.root = this.root;
2762
+ ruleset.allowImports = this.allowImports;
2763
+
2764
+ // push the current ruleset to the frames stack
2765
+ env.frames.unshift(ruleset);
2766
+
2767
+ // Evaluate imports
2768
+ if (ruleset.root || ruleset.allowImports || !ruleset.strictImports) {
2769
+ for (var i = 0; i < ruleset.rules.length; i++) {
2770
+ if (ruleset.rules[i] instanceof tree.Import) {
2771
+ Array.prototype.splice
2772
+ .apply(ruleset.rules, [i, 1].concat(ruleset.rules[i].eval(env)));
2773
+ }
2774
+ }
2775
+ }
2776
+
2777
+ // Store the frames around mixin definitions,
2778
+ // so they can be evaluated like closures when the time comes.
2779
+ for (var i = 0; i < ruleset.rules.length; i++) {
2780
+ if (ruleset.rules[i] instanceof tree.mixin.Definition) {
2781
+ ruleset.rules[i].frames = env.frames.slice(0);
2782
+ }
2783
+ }
2784
+
2785
+ // Evaluate mixin calls.
2786
+ for (var i = 0; i < ruleset.rules.length; i++) {
2787
+ if (ruleset.rules[i] instanceof tree.mixin.Call) {
2788
+ Array.prototype.splice
2789
+ .apply(ruleset.rules, [i, 1].concat(ruleset.rules[i].eval(env)));
2790
+ }
2791
+ }
2792
+
2793
+ // Evaluate everything else
2794
+ for (var i = 0, rule; i < ruleset.rules.length; i++) {
2795
+ rule = ruleset.rules[i];
2796
+
2797
+ if (! (rule instanceof tree.mixin.Definition)) {
2798
+ ruleset.rules[i] = rule.eval ? rule.eval(env) : rule;
2799
+ }
2800
+ }
2801
+
2802
+ // Pop the stack
2803
+ env.frames.shift();
2804
+
2805
+ return ruleset;
2806
+ },
2807
+ match: function (args) {
2808
+ return !args || args.length === 0;
2809
+ },
2810
+ variables: function () {
2811
+ if (this._variables) { return this._variables }
2812
+ else {
2813
+ return this._variables = this.rules.reduce(function (hash, r) {
2814
+ if (r instanceof tree.Rule && r.variable === true) {
2815
+ hash[r.name] = r;
2816
+ }
2817
+ return hash;
2818
+ }, {});
2819
+ }
2820
+ },
2821
+ variable: function (name) {
2822
+ return this.variables()[name];
2823
+ },
2824
+ rulesets: function () {
2825
+ if (this._rulesets) { return this._rulesets }
2826
+ else {
2827
+ return this._rulesets = this.rules.filter(function (r) {
2828
+ return (r instanceof tree.Ruleset) || (r instanceof tree.mixin.Definition);
2829
+ });
2830
+ }
2831
+ },
2832
+ find: function (selector, self) {
2833
+ self = self || this;
2834
+ var rules = [], rule, match,
2835
+ key = selector.toCSS();
2836
+
2837
+ if (key in this._lookups) { return this._lookups[key] }
2838
+
2839
+ this.rulesets().forEach(function (rule) {
2840
+ if (rule !== self) {
2841
+ for (var j = 0; j < rule.selectors.length; j++) {
2842
+ if (match = selector.match(rule.selectors[j])) {
2843
+ if (selector.elements.length > rule.selectors[j].elements.length) {
2844
+ Array.prototype.push.apply(rules, rule.find(
2845
+ new(tree.Selector)(selector.elements.slice(1)), self));
2846
+ } else {
2847
+ rules.push(rule);
2848
+ }
2849
+ break;
2850
+ }
2851
+ }
2852
+ }
2853
+ });
2854
+ return this._lookups[key] = rules;
2855
+ },
2856
+ //
2857
+ // Entry point for code generation
2858
+ //
2859
+ // `context` holds an array of arrays.
2860
+ //
2861
+ toCSS: function (context, env) {
2862
+ var css = [], // The CSS output
2863
+ rules = [], // node.Rule instances
2864
+ rulesets = [], // node.Ruleset instances
2865
+ paths = [], // Current selectors
2866
+ selector, // The fully rendered selector
2867
+ rule;
2868
+
2869
+ if (! this.root) {
2870
+ if (context.length === 0) {
2871
+ paths = this.selectors.map(function (s) { return [s] });
2872
+ } else {
2873
+ this.joinSelectors(paths, context, this.selectors);
2874
+ }
2875
+ }
2876
+
2877
+ // Compile rules and rulesets
2878
+ for (var i = 0; i < this.rules.length; i++) {
2879
+ rule = this.rules[i];
2880
+
2881
+ if (rule.rules || (rule instanceof tree.Directive) || (rule instanceof tree.Media)) {
2882
+ rulesets.push(rule.toCSS(paths, env));
2883
+ } else if (rule instanceof tree.Comment) {
2884
+ if (!rule.silent) {
2885
+ if (this.root) {
2886
+ rulesets.push(rule.toCSS(env));
2887
+ } else {
2888
+ rules.push(rule.toCSS(env));
2889
+ }
2890
+ }
2891
+ } else {
2892
+ if (rule.toCSS && !rule.variable) {
2893
+ rules.push(rule.toCSS(env));
2894
+ } else if (rule.value && !rule.variable) {
2895
+ rules.push(rule.value.toString());
2896
+ }
2897
+ }
2898
+ }
2899
+
2900
+ rulesets = rulesets.join('');
2901
+
2902
+ // If this is the root node, we don't render
2903
+ // a selector, or {}.
2904
+ // Otherwise, only output if this ruleset has rules.
2905
+ if (this.root) {
2906
+ css.push(rules.join(env.compress ? '' : '\n'));
2907
+ } else {
2908
+ if (rules.length > 0) {
2909
+ selector = paths.map(function (p) {
2910
+ return p.map(function (s) {
2911
+ return s.toCSS(env);
2912
+ }).join('').trim();
2913
+ }).join( env.compress ? ',' : ',\n');
2914
+
2915
+ css.push(selector,
2916
+ (env.compress ? '{' : ' {\n ') +
2917
+ rules.join(env.compress ? '' : '\n ') +
2918
+ (env.compress ? '}' : '\n}\n'));
2919
+ }
2920
+ }
2921
+ css.push(rulesets);
2922
+
2923
+ return css.join('') + (env.compress ? '\n' : '');
2924
+ },
2925
+
2926
+ joinSelectors: function (paths, context, selectors) {
2927
+ for (var s = 0; s < selectors.length; s++) {
2928
+ this.joinSelector(paths, context, selectors[s]);
2929
+ }
2930
+ },
2931
+
2932
+ joinSelector: function (paths, context, selector) {
2933
+ var before = [], after = [], beforeElements = [],
2934
+ afterElements = [], hasParentSelector = false, el;
2935
+
2936
+ for (var i = 0; i < selector.elements.length; i++) {
2937
+ el = selector.elements[i];
2938
+ if (el.combinator.value.charAt(0) === '&') {
2939
+ hasParentSelector = true;
2940
+ }
2941
+ if (hasParentSelector) afterElements.push(el);
2942
+ else beforeElements.push(el);
2943
+ }
2944
+
2945
+ if (! hasParentSelector) {
2946
+ afterElements = beforeElements;
2947
+ beforeElements = [];
2948
+ }
2949
+
2950
+ if (beforeElements.length > 0) {
2951
+ before.push(new(tree.Selector)(beforeElements));
2952
+ }
2953
+
2954
+ if (afterElements.length > 0) {
2955
+ after.push(new(tree.Selector)(afterElements));
2956
+ }
2957
+
2958
+ for (var c = 0; c < context.length; c++) {
2959
+ paths.push(before.concat(context[c]).concat(after));
2960
+ }
2961
+ }
2962
+ };
2963
+ })(require('../tree'));
2964
+ (function (tree) {
2965
+
2966
+ tree.Selector = function (elements) {
2967
+ this.elements = elements;
2968
+ if (this.elements[0].combinator.value === "") {
2969
+ this.elements[0].combinator.value = ' ';
2970
+ }
2971
+ };
2972
+ tree.Selector.prototype.match = function (other) {
2973
+ var len = this.elements.length,
2974
+ olen = other.elements.length,
2975
+ max = Math.min(len, olen);
2976
+
2977
+ if (len < olen) {
2978
+ return false;
2979
+ } else {
2980
+ for (var i = 0; i < max; i++) {
2981
+ if (this.elements[i].value !== other.elements[i].value) {
2982
+ return false;
2983
+ }
2984
+ }
2985
+ }
2986
+ return true;
2987
+ };
2988
+ tree.Selector.prototype.eval = function (env) {
2989
+ return new(tree.Selector)(this.elements.map(function (e) {
2990
+ return e.eval(env);
2991
+ }));
2992
+ };
2993
+ tree.Selector.prototype.toCSS = function (env) {
2994
+ if (this._css) { return this._css }
2995
+
2996
+ return this._css = this.elements.map(function (e) {
2997
+ if (typeof(e) === 'string') {
2998
+ return ' ' + e.trim();
2999
+ } else {
3000
+ return e.toCSS(env);
3001
+ }
3002
+ }).join('');
3003
+ };
3004
+
3005
+ })(require('../tree'));
3006
+ (function (tree) {
3007
+
3008
+ tree.URL = function (val, paths) {
3009
+ if (val.data) {
3010
+ this.attrs = val;
3011
+ } else {
3012
+ // Add the base path if the URL is relative and we are in the browser
3013
+ if (typeof(window) !== 'undefined' && !/^(?:https?:\/\/|file:\/\/|data:|\/)/.test(val.value) && paths.length > 0) {
3014
+ val.value = paths[0] + (val.value.charAt(0) === '/' ? val.value.slice(1) : val.value);
3015
+ }
3016
+ this.value = val;
3017
+ this.paths = paths;
3018
+ }
3019
+ };
3020
+ tree.URL.prototype = {
3021
+ toCSS: function () {
3022
+ return "url(" + (this.attrs ? 'data:' + this.attrs.mime + this.attrs.charset + this.attrs.base64 + this.attrs.data
3023
+ : this.value.toCSS()) + ")";
3024
+ },
3025
+ eval: function (ctx) {
3026
+ return this.attrs ? this : new(tree.URL)(this.value.eval(ctx), this.paths);
3027
+ }
3028
+ };
3029
+
3030
+ })(require('../tree'));
3031
+ (function (tree) {
3032
+
3033
+ tree.Value = function (value) {
3034
+ this.value = value;
3035
+ this.is = 'value';
3036
+ };
3037
+ tree.Value.prototype = {
3038
+ eval: function (env) {
3039
+ if (this.value.length === 1) {
3040
+ return this.value[0].eval(env);
3041
+ } else {
3042
+ return new(tree.Value)(this.value.map(function (v) {
3043
+ return v.eval(env);
3044
+ }));
3045
+ }
3046
+ },
3047
+ toCSS: function (env) {
3048
+ return this.value.map(function (e) {
3049
+ return e.toCSS(env);
3050
+ }).join(env.compress ? ',' : ', ');
3051
+ }
3052
+ };
3053
+
3054
+ })(require('../tree'));
3055
+ (function (tree) {
3056
+
3057
+ tree.Variable = function (name, index, file) { this.name = name, this.index = index, this.file = file };
3058
+ tree.Variable.prototype = {
3059
+ eval: function (env) {
3060
+ var variable, v, name = this.name;
3061
+
3062
+ if (name.indexOf('@@') == 0) {
3063
+ name = '@' + new(tree.Variable)(name.slice(1)).eval(env).value;
3064
+ }
3065
+
3066
+ if (variable = tree.find(env.frames, function (frame) {
3067
+ if (v = frame.variable(name)) {
3068
+ return v.value.eval(env);
3069
+ }
3070
+ })) { return variable }
3071
+ else {
3072
+ throw { type: 'Name',
3073
+ message: "variable " + name + " is undefined",
3074
+ filename: this.file,
3075
+ index: this.index };
3076
+ }
3077
+ }
3078
+ };
3079
+
3080
+ })(require('../tree'));
3081
+ (function (tree) {
3082
+
3083
+ tree.find = function (obj, fun) {
3084
+ for (var i = 0, r; i < obj.length; i++) {
3085
+ if (r = fun.call(obj, obj[i])) { return r }
3086
+ }
3087
+ return null;
3088
+ };
3089
+ tree.jsify = function (obj) {
3090
+ if (Array.isArray(obj.value) && (obj.value.length > 1)) {
3091
+ return '[' + obj.value.map(function (v) { return v.toCSS(false) }).join(', ') + ']';
3092
+ } else {
3093
+ return obj.toCSS(false);
3094
+ }
3095
+ };
3096
+
3097
+ })(require('./tree'));
3098
+ //
3099
+ // browser.js - client-side engine
3100
+ //
3101
+
3102
+ var isFileProtocol = (location.protocol === 'file:' ||
3103
+ location.protocol === 'chrome:' ||
3104
+ location.protocol === 'chrome-extension:' ||
3105
+ location.protocol === 'resource:');
3106
+
3107
+ less.env = less.env || (location.hostname == '127.0.0.1' ||
3108
+ location.hostname == '0.0.0.0' ||
3109
+ location.hostname == 'localhost' ||
3110
+ location.port.length > 0 ||
3111
+ isFileProtocol ? 'development'
3112
+ : 'production');
3113
+
3114
+ // Load styles asynchronously (default: false)
3115
+ //
3116
+ // This is set to `false` by default, so that the body
3117
+ // doesn't start loading before the stylesheets are parsed.
3118
+ // Setting this to `true` can result in flickering.
3119
+ //
3120
+ less.async = false;
3121
+
3122
+ // Interval between watch polls
3123
+ less.poll = less.poll || (isFileProtocol ? 1000 : 1500);
3124
+
3125
+ //
3126
+ // Watch mode
3127
+ //
3128
+ less.watch = function () { return this.watchMode = true };
3129
+ less.unwatch = function () { return this.watchMode = false };
3130
+
3131
+ if (less.env === 'development') {
3132
+ less.optimization = 0;
3133
+
3134
+ if (/!watch/.test(location.hash)) {
3135
+ less.watch();
3136
+ }
3137
+ less.watchTimer = setInterval(function () {
3138
+ if (less.watchMode) {
3139
+ loadStyleSheets(function (e, root, _, sheet, env) {
3140
+ if (root) {
3141
+ createCSS(root.toCSS(), sheet, env.lastModified);
3142
+ }
3143
+ });
3144
+ }
3145
+ }, less.poll);
3146
+ } else {
3147
+ less.optimization = 3;
3148
+ }
3149
+
3150
+ var cache;
3151
+
3152
+ try {
3153
+ cache = (typeof(window.localStorage) === 'undefined') ? null : window.localStorage;
3154
+ } catch (_) {
3155
+ cache = null;
3156
+ }
3157
+
3158
+ //
3159
+ // Get all <link> tags with the 'rel' attribute set to "stylesheet/less"
3160
+ //
3161
+ var links = document.getElementsByTagName('link');
3162
+ var typePattern = /^text\/(x-)?less$/;
3163
+
3164
+ less.sheets = [];
3165
+
3166
+ for (var i = 0; i < links.length; i++) {
3167
+ if (links[i].rel === 'stylesheet/less' || (links[i].rel.match(/stylesheet/) &&
3168
+ (links[i].type.match(typePattern)))) {
3169
+ less.sheets.push(links[i]);
3170
+ }
3171
+ }
3172
+
3173
+
3174
+ less.refresh = function (reload) {
3175
+ var startTime, endTime;
3176
+ startTime = endTime = new(Date);
3177
+
3178
+ loadStyleSheets(function (e, root, _, sheet, env) {
3179
+ if (env.local) {
3180
+ log("loading " + sheet.href + " from cache.");
3181
+ } else {
3182
+ log("parsed " + sheet.href + " successfully.");
3183
+ createCSS(root.toCSS(), sheet, env.lastModified);
3184
+ }
3185
+ log("css for " + sheet.href + " generated in " + (new(Date) - endTime) + 'ms');
3186
+ (env.remaining === 0) && log("css generated in " + (new(Date) - startTime) + 'ms');
3187
+ endTime = new(Date);
3188
+ }, reload);
3189
+
3190
+ loadStyles();
3191
+ };
3192
+ less.refreshStyles = loadStyles;
3193
+
3194
+ less.refresh(less.env === 'development');
3195
+
3196
+ function loadStyles() {
3197
+ var styles = document.getElementsByTagName('style');
3198
+ for (var i = 0; i < styles.length; i++) {
3199
+ if (styles[i].type.match(typePattern)) {
3200
+ new(less.Parser)().parse(styles[i].innerHTML || '', function (e, tree) {
3201
+ var css = tree.toCSS();
3202
+ var style = styles[i];
3203
+ style.type = 'text/css';
3204
+ if (style.styleSheet) {
3205
+ style.styleSheet.cssText = css;
3206
+ } else {
3207
+ style.innerHTML = css;
3208
+ }
3209
+ });
3210
+ }
3211
+ }
3212
+ }
3213
+
3214
+ function loadStyleSheets(callback, reload) {
3215
+ for (var i = 0; i < less.sheets.length; i++) {
3216
+ loadStyleSheet(less.sheets[i], callback, reload, less.sheets.length - (i + 1));
3217
+ }
3218
+ }
3219
+
3220
+ function loadStyleSheet(sheet, callback, reload, remaining) {
3221
+ var url = window.location.href.replace(/[#?].*$/, '');
3222
+ var href = sheet.href.replace(/\?.*$/, '');
3223
+ var css = cache && cache.getItem(href);
3224
+ var timestamp = cache && cache.getItem(href + ':timestamp');
3225
+ var styles = { css: css, timestamp: timestamp };
3226
+
3227
+ // Stylesheets in IE don't always return the full path
3228
+ if (! /^(https?|file):/.test(href)) {
3229
+ if (href.charAt(0) == "/") {
3230
+ href = window.location.protocol + "//" + window.location.host + href;
3231
+ } else {
3232
+ href = url.slice(0, url.lastIndexOf('/') + 1) + href;
3233
+ }
3234
+ }
3235
+ var filename = href.match(/([^\/]+)$/)[1];
3236
+
3237
+ xhr(sheet.href, sheet.type, function (data, lastModified) {
3238
+ if (!reload && styles && lastModified &&
3239
+ (new(Date)(lastModified).valueOf() ===
3240
+ new(Date)(styles.timestamp).valueOf())) {
3241
+ // Use local copy
3242
+ createCSS(styles.css, sheet);
3243
+ callback(null, null, data, sheet, { local: true, remaining: remaining });
3244
+ } else {
3245
+ // Use remote copy (re-parse)
3246
+ try {
3247
+ new(less.Parser)({
3248
+ optimization: less.optimization,
3249
+ paths: [href.replace(/[\w\.-]+$/, '')],
3250
+ mime: sheet.type,
3251
+ filename: filename
3252
+ }).parse(data, function (e, root) {
3253
+ if (e) { return error(e, href) }
3254
+ try {
3255
+ callback(e, root, data, sheet, { local: false, lastModified: lastModified, remaining: remaining });
3256
+ removeNode(document.getElementById('less-error-message:' + extractId(href)));
3257
+ } catch (e) {
3258
+ error(e, href);
3259
+ }
3260
+ });
3261
+ } catch (e) {
3262
+ error(e, href);
3263
+ }
3264
+ }
3265
+ }, function (status, url) {
3266
+ throw new(Error)("Couldn't load " + url + " (" + status + ")");
3267
+ });
3268
+ }
3269
+
3270
+ function extractId(href) {
3271
+ return href.replace(/^[a-z]+:\/\/?[^\/]+/, '' ) // Remove protocol & domain
3272
+ .replace(/^\//, '' ) // Remove root /
3273
+ .replace(/\?.*$/, '' ) // Remove query
3274
+ .replace(/\.[^\.\/]+$/, '' ) // Remove file extension
3275
+ .replace(/[^\.\w-]+/g, '-') // Replace illegal characters
3276
+ .replace(/\./g, ':'); // Replace dots with colons(for valid id)
3277
+ }
3278
+
3279
+ function createCSS(styles, sheet, lastModified) {
3280
+ var css;
3281
+
3282
+ // Strip the query-string
3283
+ var href = sheet.href ? sheet.href.replace(/\?.*$/, '') : '';
3284
+
3285
+ // If there is no title set, use the filename, minus the extension
3286
+ var id = 'less:' + (sheet.title || extractId(href));
3287
+
3288
+ // If the stylesheet doesn't exist, create a new node
3289
+ if ((css = document.getElementById(id)) === null) {
3290
+ css = document.createElement('style');
3291
+ css.type = 'text/css';
3292
+ css.media = sheet.media || 'screen';
3293
+ css.id = id;
3294
+ document.getElementsByTagName('head')[0].appendChild(css);
3295
+ }
3296
+
3297
+ if (css.styleSheet) { // IE
3298
+ try {
3299
+ css.styleSheet.cssText = styles;
3300
+ } catch (e) {
3301
+ throw new(Error)("Couldn't reassign styleSheet.cssText.");
3302
+ }
3303
+ } else {
3304
+ (function (node) {
3305
+ if (css.childNodes.length > 0) {
3306
+ if (css.firstChild.nodeValue !== node.nodeValue) {
3307
+ css.replaceChild(node, css.firstChild);
3308
+ }
3309
+ } else {
3310
+ css.appendChild(node);
3311
+ }
3312
+ })(document.createTextNode(styles));
3313
+ }
3314
+
3315
+ // Don't update the local store if the file wasn't modified
3316
+ if (lastModified && cache) {
3317
+ log('saving ' + href + ' to cache.');
3318
+ cache.setItem(href, styles);
3319
+ cache.setItem(href + ':timestamp', lastModified);
3320
+ }
3321
+ }
3322
+
3323
+ function xhr(url, type, callback, errback) {
3324
+ var xhr = getXMLHttpRequest();
3325
+ var async = isFileProtocol ? false : less.async;
3326
+
3327
+ if (typeof(xhr.overrideMimeType) === 'function') {
3328
+ xhr.overrideMimeType('text/css');
3329
+ }
3330
+ xhr.open('GET', url, async);
3331
+ xhr.setRequestHeader('Accept', type || 'text/x-less, text/css; q=0.9, */*; q=0.5');
3332
+ xhr.send(null);
3333
+
3334
+ if (isFileProtocol) {
3335
+ if (xhr.status === 0 || (xhr.status >= 200 && xhr.status < 300)) {
3336
+ callback(xhr.responseText);
3337
+ } else {
3338
+ errback(xhr.status, url);
3339
+ }
3340
+ } else if (async) {
3341
+ xhr.onreadystatechange = function () {
3342
+ if (xhr.readyState == 4) {
3343
+ handleResponse(xhr, callback, errback);
3344
+ }
3345
+ };
3346
+ } else {
3347
+ handleResponse(xhr, callback, errback);
3348
+ }
3349
+
3350
+ function handleResponse(xhr, callback, errback) {
3351
+ if (xhr.status >= 200 && xhr.status < 300) {
3352
+ callback(xhr.responseText,
3353
+ xhr.getResponseHeader("Last-Modified"));
3354
+ } else if (typeof(errback) === 'function') {
3355
+ errback(xhr.status, url);
3356
+ }
3357
+ }
3358
+ }
3359
+
3360
+ function getXMLHttpRequest() {
3361
+ if (window.XMLHttpRequest) {
3362
+ return new(XMLHttpRequest);
3363
+ } else {
3364
+ try {
3365
+ return new(ActiveXObject)("MSXML2.XMLHTTP.3.0");
3366
+ } catch (e) {
3367
+ log("browser doesn't support AJAX.");
3368
+ return null;
3369
+ }
3370
+ }
3371
+ }
3372
+
3373
+ function removeNode(node) {
3374
+ return node && node.parentNode.removeChild(node);
3375
+ }
3376
+
3377
+ function log(str) {
3378
+ if (less.env == 'development' && typeof(console) !== "undefined") { console.log('less: ' + str) }
3379
+ }
3380
+
3381
+ function error(e, href) {
3382
+ var id = 'less-error-message:' + extractId(href);
3383
+ var template = '<li><label>{line}</label><pre class="{class}">{content}</pre></li>';
3384
+ var elem = document.createElement('div'), timer, content, error = [];
3385
+ var filename = e.filename || href;
3386
+
3387
+ elem.id = id;
3388
+ elem.className = "less-error-message";
3389
+
3390
+ content = '<h3>' + (e.message || 'There is an error in your .less file') +
3391
+ '</h3>' + '<p>in <a href="' + filename + '">' + filename + "</a> ";
3392
+
3393
+ var errorline = function (e, i, classname) {
3394
+ if (e.extract[i]) {
3395
+ error.push(template.replace(/\{line\}/, parseInt(e.line) + (i - 1))
3396
+ .replace(/\{class\}/, classname)
3397
+ .replace(/\{content\}/, e.extract[i]));
3398
+ }
3399
+ };
3400
+
3401
+ if (e.stack) {
3402
+ content += '<br/>' + e.stack.split('\n').slice(1).join('<br/>');
3403
+ } else if (e.extract) {
3404
+ errorline(e, 0, '');
3405
+ errorline(e, 1, 'line');
3406
+ errorline(e, 2, '');
3407
+ content += 'on line ' + e.line + ', column ' + (e.column + 1) + ':</p>' +
3408
+ '<ul>' + error.join('') + '</ul>';
3409
+ }
3410
+ elem.innerHTML = content;
3411
+
3412
+ // CSS for error messages
3413
+ createCSS([
3414
+ '.less-error-message ul, .less-error-message li {',
3415
+ 'list-style-type: none;',
3416
+ 'margin-right: 15px;',
3417
+ 'padding: 4px 0;',
3418
+ 'margin: 0;',
3419
+ '}',
3420
+ '.less-error-message label {',
3421
+ 'font-size: 12px;',
3422
+ 'margin-right: 15px;',
3423
+ 'padding: 4px 0;',
3424
+ 'color: #cc7777;',
3425
+ '}',
3426
+ '.less-error-message pre {',
3427
+ 'color: #dd6666;',
3428
+ 'padding: 4px 0;',
3429
+ 'margin: 0;',
3430
+ 'display: inline-block;',
3431
+ '}',
3432
+ '.less-error-message pre.line {',
3433
+ 'color: #ff0000;',
3434
+ '}',
3435
+ '.less-error-message h3 {',
3436
+ 'font-size: 20px;',
3437
+ 'font-weight: bold;',
3438
+ 'padding: 15px 0 5px 0;',
3439
+ 'margin: 0;',
3440
+ '}',
3441
+ '.less-error-message a {',
3442
+ 'color: #10a',
3443
+ '}',
3444
+ '.less-error-message .error {',
3445
+ 'color: red;',
3446
+ 'font-weight: bold;',
3447
+ 'padding-bottom: 2px;',
3448
+ 'border-bottom: 1px dashed red;',
3449
+ '}'
3450
+ ].join('\n'), { title: 'error-message' });
3451
+
3452
+ elem.style.cssText = [
3453
+ "font-family: Arial, sans-serif",
3454
+ "border: 1px solid #e00",
3455
+ "background-color: #eee",
3456
+ "border-radius: 5px",
3457
+ "-webkit-border-radius: 5px",
3458
+ "-moz-border-radius: 5px",
3459
+ "color: #e00",
3460
+ "padding: 15px",
3461
+ "margin-bottom: 15px"
3462
+ ].join(';');
3463
+
3464
+ if (less.env == 'development') {
3465
+ timer = setInterval(function () {
3466
+ if (document.body) {
3467
+ if (document.getElementById(id)) {
3468
+ document.body.replaceChild(elem, document.getElementById(id));
3469
+ } else {
3470
+ document.body.insertBefore(elem, document.body.firstChild);
3471
+ }
3472
+ clearInterval(timer);
3473
+ }
3474
+ }, 10);
3475
+ }
3476
+ }
3477
+
3478
+ })(window);
libraries/less/dist/less-1.3.0.min.js ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ //
2
+ // LESS - Leaner CSS v1.3.0
3
+ // http://lesscss.org
4
+ //
5
+ // Copyright (c) 2009-2011, Alexis Sellier
6
+ // Licensed under the Apache 2.0 License.
7
+ //
8
+ (function(a,b){function c(b){return a.less[b.split("/")[1]]}function l(){var a=document.getElementsByTagName("style");for(var b=0;b<a.length;b++)a[b].type.match(j)&&(new d.Parser).parse(a[b].innerHTML||"",function(c,d){var e=d.toCSS(),f=a[b];f.type="text/css",f.styleSheet?f.styleSheet.cssText=e:f.innerHTML=e})}function m(a,b){for(var c=0;c<d.sheets.length;c++)n(d.sheets[c],a,b,d.sheets.length-(c+1))}function n(b,c,e,f){var h=a.location.href.replace(/[#?].*$/,""),i=b.href.replace(/\?.*$/,""),j=g&&g.getItem(i),k=g&&g.getItem(i+":timestamp"),l={css:j,timestamp:k};/^(https?|file):/.test(i)||(i.charAt(0)=="/"?i=a.location.protocol+"//"+a.location.host+i:i=h.slice(0,h.lastIndexOf("/")+1)+i);var m=i.match(/([^\/]+)$/)[1];q(b.href,b.type,function(a,g){if(!e&&l&&g&&(new Date(g)).valueOf()===(new Date(l.timestamp)).valueOf())p(l.css,b),c(null,null,a,b,{local:!0,remaining:f});else try{(new d.Parser({optimization:d.optimization,paths:[i.replace(/[\w\.-]+$/,"")],mime:b.type,filename:m})).parse(a,function(d,e){if(d)return u(d,i);try{c(d,e,a,b,{local:!1,lastModified:g,remaining:f}),s(document.getElementById("less-error-message:"+o(i)))}catch(d){u(d,i)}})}catch(h){u(h,i)}},function(a,b){throw new Error("Couldn't load "+b+" ("+a+")")})}function o(a){return a.replace(/^[a-z]+:\/\/?[^\/]+/,"").replace(/^\//,"").replace(/\?.*$/,"").replace(/\.[^\.\/]+$/,"").replace(/[^\.\w-]+/g,"-").replace(/\./g,":")}function p(a,b,c){var d,e=b.href?b.href.replace(/\?.*$/,""):"",f="less:"+(b.title||o(e));(d=document.getElementById(f))===null&&(d=document.createElement("style"),d.type="text/css",d.media=b.media||"screen",d.id=f,document.getElementsByTagName("head")[0].appendChild(d));if(d.styleSheet)try{d.styleSheet.cssText=a}catch(h){throw new Error("Couldn't reassign styleSheet.cssText.")}else(function(a){d.childNodes.length>0?d.firstChild.nodeValue!==a.nodeValue&&d.replaceChild(a,d.firstChild):d.appendChild(a)})(document.createTextNode(a));c&&g&&(t("saving "+e+" to cache."),g.setItem(e,a),g.setItem(e+":timestamp",c))}function q(a,b,c,e){function i(b,c,d){b.status>=200&&b.status<300?c(b.responseText,b.getResponseHeader("Last-Modified")):typeof d=="function"&&d(b.status,a)}var g=r(),h=f?!1:d.async;typeof g.overrideMimeType=="function"&&g.overrideMimeType("text/css"),g.open("GET",a,h),g.setRequestHeader("Accept",b||"text/x-less, text/css; q=0.9, */*; q=0.5"),g.send(null),f?g.status===0||g.status>=200&&g.status<300?c(g.responseText):e(g.status,a):h?g.onreadystatechange=function(){g.readyState==4&&i(g,c,e)}:i(g,c,e)}function r(){if(a.XMLHttpRequest)return new XMLHttpRequest;try{return new ActiveXObject("MSXML2.XMLHTTP.3.0")}catch(b){return t("browser doesn't support AJAX."),null}}function s(a){return a&&a.parentNode.removeChild(a)}function t(a){d.env=="development"&&typeof console!="undefined"&&console.log("less: "+a)}function u(a,b){var c="less-error-message:"+o(b),e='<li><label>{line}</label><pre class="{class}">{content}</pre></li>',f=document.createElement("div"),g,h,i=[],j=a.filename||b;f.id=c,f.className="less-error-message",h="<h3>"+(a.message||"There is an error in your .less file")+"</h3>"+'<p>in <a href="'+j+'">'+j+"</a> ";var k=function(a,b,c){a.extract[b]&&i.push(e.replace(/\{line\}/,parseInt(a.line)+(b-1)).replace(/\{class\}/,c).replace(/\{content\}/,a.extract[b]))};a.stack?h+="<br/>"+a.stack.split("\n").slice(1).join("<br/>"):a.extract&&(k(a,0,""),k(a,1,"line"),k(a,2,""),h+="on line "+a.line+", column "+(a.column+1)+":</p>"+"<ul>"+i.join("")+"</ul>"),f.innerHTML=h,p([".less-error-message ul, .less-error-message li {","list-style-type: none;","margin-right: 15px;","padding: 4px 0;","margin: 0;","}",".less-error-message label {","font-size: 12px;","margin-right: 15px;","padding: 4px 0;","color: #cc7777;","}",".less-error-message pre {","color: #dd6666;","padding: 4px 0;","margin: 0;","display: inline-block;","}",".less-error-message pre.line {","color: #ff0000;","}",".less-error-message h3 {","font-size: 20px;","font-weight: bold;","padding: 15px 0 5px 0;","margin: 0;","}",".less-error-message a {","color: #10a","}",".less-error-message .error {","color: red;","font-weight: bold;","padding-bottom: 2px;","border-bottom: 1px dashed red;","}"].join("\n"),{title:"error-message"}),f.style.cssText=["font-family: Arial, sans-serif","border: 1px solid #e00","background-color: #eee","border-radius: 5px","-webkit-border-radius: 5px","-moz-border-radius: 5px","color: #e00","padding: 15px","margin-bottom: 15px"].join(";"),d.env=="development"&&(g=setInterval(function(){document.body&&(document.getElementById(c)?document.body.replaceChild(f,document.getElementById(c)):document.body.insertBefore(f,document.body.firstChild),clearInterval(g))},10))}typeof define=="function"&&define.amd&&define("less",[],function(){return d}),Array.isArray||(Array.isArray=function(a){return Object.prototype.toString.call(a)==="[object Array]"||a instanceof Array}),Array.prototype.forEach||(Array.prototype.forEach=function(a,b){var c=this.length>>>0;for(var d=0;d<c;d++)d in this&&a.call(b,this[d],d,this)}),Array.prototype.map||(Array.prototype.map=function(a){var b=this.length>>>0,c=new Array(b),d=arguments[1];for(var e=0;e<b;e++)e in this&&(c[e]=a.call(d,this[e],e,this));return c}),Array.prototype.filter||(Array.prototype.filter=function(a){var b=[],c=arguments[1];for(var d=0;d<this.length;d++)a.call(c,this[d])&&b.push(this[d]);return b}),Array.prototype.reduce||(Array.prototype.reduce=function(a){var b=this.length>>>0,c=0;if(b===0&&arguments.length===1)throw new TypeError;if(arguments.length>=2)var d=arguments[1];else do{if(c in this){d=this[c++];break}if(++c>=b)throw new TypeError}while(!0);for(;c<b;c++)c in this&&(d=a.call(null,d,this[c],c,this));return d}),Array.prototype.indexOf||(Array.prototype.indexOf=function(a){var b=this.length,c=arguments[1]||0;if(!b)return-1;if(c>=b)return-1;c<0&&(c+=b);for(;c<b;c++){if(!Object.prototype.hasOwnProperty.call(this,c))continue;if(a===this[c])return c}return-1}),Object.keys||(Object.keys=function(a){var b=[];for(var c in a)Object.prototype.hasOwnProperty.call(a,c)&&b.push(c);return b}),String.prototype.trim||(String.prototype.trim=function(){return String(this).replace(/^\s\s*/,"").replace(/\s\s*$/,"")});var d,e;typeof environment=="object"&&{}.toString.call(environment)==="[object Environment]"?(typeof a=="undefined"?d={}:d=a.less={},e=d.tree={},d.mode="rhino"):typeof a=="undefined"?(d=exports,e=c("./tree"),d.mode="node"):(typeof a.less=="undefined"&&(a.less={}),d=a.less,e=a.less.tree={},d.mode="browser"),d.Parser=function v(a){function q(){h=k[g],i=f,l=f}function r(){k[g]=h,f=i,l=f}function s(){f>l&&(k[g]=k[g].slice(f-l),l=f)}function t(a){var c,d,e,h,i,j,n,o;if(a instanceof Function)return a.call(m.parsers);if(typeof a=="string")c=b.charAt(f)===a?a:null,e=1,s();else{s();if(c=a.exec(k[g]))e=c[0].length;else return null}if(c){o=f+=e,j=f+k[g].length-e;while(f<j){h=b.charCodeAt(f);if(h!==32&&h!==10&&h!==9)break;f++}return k[g]=k[g].slice(e+(f-o)),l=f,k[g].length===0&&g<k.length-1&&g++,typeof c=="string"?c:c.length===1?c[0]:c}}function u(a,c){var d=t(a);if(!d)v(c||(typeof a=="string"?"expected '"+a+"' got '"+b.charAt(f)+"'":"unexpected token"));else return d}function v(a,b){throw{index:f,type:b||"Syntax",message:a}}function w(a){return typeof a=="string"?b.charAt(f)===a:a.test(k[g])?!0:!1}function x(a){return d.mode==="node"?c("path").basename(a):a.match(/[^\/]+$/)[0]}function y(a,c){return a.filename&&c.filename&&a.filename!==c.filename?m.imports.contents[x(a.filename)]:b}function z(a,b){for(var c=a,d=-1;c>=0&&b.charAt(c)!=="\n";c--)d++;return{line:typeof a=="number"?(b.slice(0,a).match(/\n/g)||"").length:null,column:d}}function A(a,b){var c=y(a,b),d=z(a.index,c),e=d.line,f=d.column,g=c.split("\n");this.type=a.type||"Syntax",this.message=a.message,this.filename=a.filename||b.filename,this.index=a.index,this.line=typeof e=="number"?e+1:null,this.callLine=a.call&&z(a.call,c).line+1,this.callExtract=g[z(a.call,c).line],this.stack=a.stack,this.column=f,this.extract=[g[e-1],g[e],g[e+1]]}var b,f,g,h,i,j,k,l,m,n=this,o=function(){},p=this.imports={paths:a&&a.paths||[],queue:[],files:{},contents:{},mime:a&&a.mime,error:null,push:function(b,c){var e=this;this.queue.push(b),d.Parser.importer(b,this.paths,function(a,d,f){e.queue.splice(e.queue.indexOf(b),1),e.files[b]=d,e.contents[b]=f,a&&!e.error&&(e.error=a),c(a,d),e.queue.length===0&&o()},a)}};return this.env=a=a||{},this.optimization="optimization"in this.env?this.env.optimization:1,this.env.filename=this.env.filename||null,m={imports:p,parse:function(h,i){var n,p,q,r,s,u,v=[],w,x=null;f=g=l=j=0,b=h.replace(/\r\n/g,"\n"),k=function(c){var d=0,e=/[^"'`\{\}\/\(\)\\]+/g,f=/\/\*(?:[^*]|\*+[^\/*])*\*+\/|\/\/.*/g,g=/"((?:[^"\\\r\n]|\\.)*)"|'((?:[^'\\\r\n]|\\.)*)'|`((?:[^`\\\r\n]|\\.)*)`/g,h=0,i,j=c[0],k;for(var l=0,m,n;l<b.length;l++){e.lastIndex=l,(i=e.exec(b))&&i.index===l&&(l+=i[0].length,j.push(i[0])),m=b.charAt(l),f.lastIndex=g.lastIndex=l,(i=g.exec(b))&&i.index===l&&(l+=i[0].length,j.push(i[0]),m=b.charAt(l)),!k&&m==="/"&&(n=b.charAt(l+1),(n==="/"||n==="*")&&(i=f.exec(b))&&i.index===l&&(l+=i[0].length,j.push(i[0]),m=b.charAt(l)));switch(m){case"{":if(!k){h++,j.push(m);break};case"}":if(!k){h--,j.push(m),c[++d]=j=[];break};case"(":if(!k){k=!0,j.push(m);break};case")":if(k){k=!1,j.push(m);break};default:j.push(m)}}return h>0&&(x=new A({index:l,type:"Parse",message:"missing closing `}`",filename:a.filename},a)),c.map(function(a){return a.join("")})}([[]]);if(x)return i(x);try{n=new e.Ruleset([],t(this.parsers.primary)),n.root=!0}catch(y){return i(new A(y,a))}n.toCSS=function(b){var f,g,h;return function(f,g){var h=[],i;f=f||{},typeof g=="object"&&!Array.isArray(g)&&(g=Object.keys(g).map(function(a){var b=g[a];return b instanceof e.Value||(b instanceof e.Expression||(b=new e.Expression([b])),b=new e.Value([b])),new e.Rule("@"+a,b,!1,0)}),h=[new e.Ruleset(null,g)]);try{var j=b.call(this,{frames:h}).toCSS([],{compress:f.compress||!1})}catch(k){throw new A(k,a)}if(i=m.imports.error)throw i instanceof A?i:new A(i,a);return f.yuicompress&&d.mode==="node"?c("./cssmin").compressor.cssmin(j):f.compress?j.replace(/(\s)+/g,"$1"):j}}(n.eval);if(f<b.length-1){f=j,u=b.split("\n"),s=(b.slice(0,f).match(/\n/g)||"").length+1;for(var z=f,B=-1;z>=0&&b.charAt(z)!=="\n";z--)B++;x={type:"Parse",message:"Syntax Error on line "+s,index:f,filename:a.filename,line:s,column:B,extract:[u[s-2],u[s-1],u[s]]}}this.imports.queue.length>0?o=function(){i(x,n)}:i(x,n)},parsers:{primary:function(){var a,b=[];while((a=t(this.mixin.definition)||t(this.rule)||t(this.ruleset)||t(this.mixin.call)||t(this.comment)||t(this.directive))||t(/^[\s\n]+/))a&&b.push(a);return b},comment:function(){var a;if(b.charAt(f)!=="/")return;if(b.charAt(f+1)==="/")return new e.Comment(t(/^\/\/.*/),!0);if(a=t(/^\/\*(?:[^*]|\*+[^\/*])*\*+\/\n?/))return new e.Comment(a)},entities:{quoted:function(){var a,c=f,d;b.charAt(c)==="~"&&(c++,d=!0);if(b.charAt(c)!=='"'&&b.charAt(c)!=="'")return;d&&t("~");if(a=t(/^"((?:[^"\\\r\n]|\\.)*)"|'((?:[^'\\\r\n]|\\.)*)'/))return new e.Quoted(a[0],a[1]||a[2],d)},keyword:function(){var a;if(a=t(/^[_A-Za-z-][_A-Za-z0-9-]*/))return e.colors.hasOwnProperty(a)?new e.Color(e.colors[a].slice(1)):new e.Keyword(a)},call:function(){var b,c,d=f;if(!(b=/^([\w-]+|%|progid:[\w\.]+)\(/.exec(k[g])))return;b=b[1].toLowerCase();if(b==="url")return null;f+=b.length;if(b==="alpha")return t(this.alpha);t("("),c=t(this.entities.arguments);if(!t(")"))return;if(b)return new e.Call(b,c,d,a.filename)},arguments:function(){var a=[],b;while(b=t(this.entities.assignment)||t(this.expression)){a.push(b);if(!t(","))break}return a},literal:function(){return t(this.entities.dimension)||t(this.entities.color)||t(this.entities.quoted)},assignment:function(){var a,b;if((a=t(/^\w+(?=\s?=)/i))&&t("=")&&(b=t(this.entity)))return new e.Assignment(a,b)},url:function(){var a;if(b.charAt(f)!=="u"||!t(/^url\(/))return;return a=t(this.entities.quoted)||t(this.entities.variable)||t(this.entities.dataURI)||t(/^[-\w%@$\/.&=:;#+?~]+/)||"",u(")"),new e.URL(a.value||a.data||a instanceof e.Variable?a:new e.Anonymous(a),p.paths)},dataURI:function(){var a;if(t(/^data:/)){a={},a.mime=t(/^[^\/]+\/[^,;)]+/)||"",a.charset=t(/^;\s*charset=[^,;)]+/)||"",a.base64=t(/^;\s*base64/)||"",a.data=t(/^,\s*[^)]+/);if(a.data)return a}},variable:function(){var c,d=f;if(b.charAt(f)==="@"&&(c=t(/^@@?[\w-]+/)))return new e.Variable(c,d,a.filename)},color:function(){var a;if(b.charAt(f)==="#"&&(a=t(/^#([a-fA-F0-9]{6}|[a-fA-F0-9]{3})/)))return new e.Color(a[1])},dimension:function(){var a,c=b.charCodeAt(f);if(c>57||c<45||c===47)return;if(a=t(/^(-?\d*\.?\d+)(px|%|em|rem|pc|ex|in|deg|s|ms|pt|cm|mm|rad|grad|turn)?/))return new e.Dimension(a[1],a[2])},javascript:function(){var a,c=f,d;b.charAt(c)==="~"&&(c++,d=!0);if(b.charAt(c)!=="`")return;d&&t("~");if(a=t(/^`([^`]*)`/))return new e.JavaScript(a[1],f,d)}},variable:function(){var a;if(b.charAt(f)==="@"&&(a=t(/^(@[\w-]+)\s*:/)))return a[1]},shorthand:function(){var a,b;if(!w(/^[@\w.%-]+\/[@\w.-]+/))return;if((a=t(this.entity))&&t("/")&&(b=t(this.entity)))return new e.Shorthand(a,b)},mixin:{call:function(){var c=[],d,g,h,i=f,j=b.charAt(f),k=!1;if(j!=="."&&j!=="#")return;while(d=t(/^[#.](?:[\w-]|\\(?:[a-fA-F0-9]{1,6} ?|[^a-fA-F0-9]))+/))c.push(new e.Element(g,d,f)),g=t(">");t("(")&&(h=t(this.entities.arguments))&&t(")"),t(this.important)&&(k=!0);if(c.length>0&&(t(";")||w("}")))return new e.mixin.Call(c,h||[],i,a.filename,k)},definition:function(){var a,c=[],d,g,h,i,j,k=!1;if(b.charAt(f)!=="."&&b.charAt(f)!=="#"||w(/^[^{]*(;|})/))return;q();if(d=t(/^([#.](?:[\w-]|\\(?:[a-fA-F0-9]{1,6} ?|[^a-fA-F0-9]))+)\s*\(/)){a=d[1];do{if(b.charAt(f)==="."&&t(/^\.{3}/)){k=!0;break}if(!(h=t(this.entities.variable)||t(this.entities.literal)||t(this.entities.keyword)))break;if(h instanceof e.Variable)if(t(":"))i=u(this.expression,"expected expression"),c.push({name:h.name,value:i});else{if(t(/^\.{3}/)){c.push({name:h.name,variadic:!0}),k=!0;break}c.push({name:h.name})}else c.push({value:h})}while(t(","));u(")"),t(/^when/)&&(j=u(this.conditions,"expected condition")),g=t(this.block);if(g)return new e.mixin.Definition(a,c,g,j,k);r()}}},entity:function(){return t(this.entities.literal)||t(this.entities.variable)||t(this.entities.url)||t(this.entities.call)||t(this.entities.keyword)||t(this.entities.javascript)||t(this.comment)},end:function(){return t(";")||w("}")},alpha:function(){var a;if(!t(/^\(opacity=/i))return;if(a=t(/^\d+/)||t(this.entities.variable))return u(")"),new e.Alpha(a)},element:function(){var a,b,c,d;c=t(this.combinator),a=t(/^(?:\d+\.\d+|\d+)%/)||t(/^(?:[.#]?|:*)(?:[\w-]|\\(?:[a-fA-F0-9]{1,6} ?|[^a-fA-F0-9]))+/)||t("*")||t(this.attribute)||t(/^\([^)@]+\)/),a||t("(")&&(d=t(this.entities.variable))&&t(")")&&(a=new e.Paren(d));if(a)return new e.Element(c,a,f);if(c.value&&c.value.charAt(0)==="&")return new e.Element(c,null,f)},combinator:function(){var a,c=b.charAt(f);if(c===">"||c==="+"||c==="~"){f++;while(b.charAt(f)===" ")f++;return new e.Combinator(c)}if(c==="&"){a="&",f++,b.charAt(f)===" "&&(a="& ");while(b.charAt(f)===" ")f++;return new e.Combinator(a)}return b.charAt(f-1)===" "?new e.Combinator(" "):new e.Combinator(null)},selector:function(){var a,c,d=[],g,h;if(t("("))return a=t(this.entity),u(")"),new e.Selector([new e.Element("",a,f)]);while(c=t(this.element)){g=b.charAt(f),d.push(c);if(g==="{"||g==="}"||g===";"||g===",")break}if(d.length>0)return new e.Selector(d)},tag:function(){return t(/^[a-zA-Z][a-zA-Z-]*[0-9]?/)||t("*")},attribute:function(){var a="",b,c,d;if(!t("["))return;if(b=t(/^[a-zA-Z-]+/)||t(this.entities.quoted))(d=t(/^[|~*$^]?=/))&&(c=t(this.entities.quoted)||t(/^[\w-]+/))?a=[b,d,c.toCSS?c.toCSS():c].join(""):a=b;if(!t("]"))return;if(a)return"["+a+"]"},block:function(){var a;if(t("{")&&(a=t(this.primary))&&t("}"))return a},ruleset:function(){var b=[],c,d,g;q();while(c=t(this.selector)){b.push(c),t(this.comment);if(!t(","))break;t(this.comment)}if(b.length>0&&(d=t(this.block)))return new e.Ruleset(b,d,a.strictImports);j=f,r()},rule:function(){var a,c,d=b.charAt(f),h,l;q();if(d==="."||d==="#"||d==="&")return;if(a=t(this.variable)||t(this.property)){a.charAt(0)!="@"&&(l=/^([^@+\/'"*`(;{}-]*);/.exec(k[g]))?(f+=l[0].length-1,c=new e.Anonymous(l[1])):a==="font"?c=t(this.font):c=t(this.value),h=t(this.important);if(c&&t(this.end))return new e.Rule(a,c,h,i);j=f,r()}},"import":function(){var a,b,c=f;if(t(/^@import\s+/)&&(a=t(this.entities.quoted)||t(this.entities.url))){b=t(this.mediaFeatures);if(t(";"))return new e.Import(a,p,b,c)}},mediaFeature:function(){var a,b,c=[];do if(a=t(this.entities.keyword))c.push(a);else if(t("(")){b=t(this.property),a=t(this.entity);if(!t(")"))return null;if(b&&a)c.push(new e.Paren(new e.Rule(b,a,null,f,!0)));else if(a)c.push(new e.Paren(a));else return null}while(a);if(c.length>0)return new e.Expression(c)},mediaFeatures:function(){var a,b=[];do if(a=t(this.mediaFeature)){b.push(a);if(!t(","))break}else if(a=t(this.entities.variable)){b.push(a);if(!t(","))break}while(a);return b.length>0?b:null},media:function(){var a,b;if(t(/^@media/)){a=t(this.mediaFeatures);if(b=t(this.block))return new e.Media(b,a)}},directive:function(){var a,c,d,g,h,i;if(b.charAt(f)!=="@")return;if(c=t(this["import"])||t(this.media))return c;if(a=t(/^@page|@keyframes/)||t(/^@(?:-webkit-|-moz-|-o-|-ms-)[a-z0-9-]+/)){g=(t(/^[^{]+/)||"").trim();if(d=t(this.block))return new e.Directive(a+" "+g,d)}else if(a=t(/^@[-a-z]+/))if(a==="@font-face"){if(d=t(this.block))return new e.Directive(a,d)}else if((c=t(this.entity))&&t(";"))return new e.Directive(a,c)},font:function(){var a=[],b=[],c,d,f,g;while(g=t(this.shorthand)||t(this.entity))b.push(g);a.push(new e.Expression(b));if(t(","))while(g=t(this.expression)){a.push(g);if(!t(","))break}return new e.Value(a)},value:function(){var a,b=[],c;while(a=t(this.expression)){b.push(a);if(!t(","))break}if(b.length>0)return new e.Value(b)},important:function(){if(b.charAt(f)==="!")return t(/^! *important/)},sub:function(){var a;if(t("(")&&(a=t(this.expression))&&t(")"))return a},multiplication:function(){var a,b,c,d;if(a=t(this.operand)){while(!w(/^\/\*/)&&(c=t("/")||t("*"))&&(b=t(this.operand)))d=new e.Operation(c,[d||a,b]);return d||a}},addition:function(){var a,c,d,g;if(a=t(this.multiplication)){while((d=t(/^[-+]\s+/)||b.charAt(f-1)!=" "&&(t("+")||t("-")))&&(c=t(this.multiplication)))g=new e.Operation(d,[g||a,c]);return g||a}},conditions:function(){var a,b,c=f,d;if(a=t(this.condition)){while(t(",")&&(b=t(this.condition)))d=new e.Condition("or",d||a,b,c);return d||a}},condition:function(){var a,b,c,d,g=f,h=!1;t(/^not/)&&(h=!0),u("(");if(a=t(this.addition)||t(this.entities.keyword)||t(this.entities.quoted))return(d=t(/^(?:>=|=<|[<=>])/))?(b=t(this.addition)||t(this.entities.keyword)||t(this.entities.quoted))?c=new e.Condition(d,a,b,g,h):v("expected expression"):c=new e.Condition("=",a,new e.Keyword("true"),g,h),u(")"),t(/^and/)?new e.Condition("and",c,t(this.condition)):c},operand:function(){var a,c=b.charAt(f+1);b.charAt(f)==="-"&&(c==="@"||c==="(")&&(a=t("-"));var d=t(this.sub)||t(this.entities.dimension)||t(this.entities.color)||t(this.entities.variable)||t(this.entities.call);return a?new e.Operation("*",[new e.Dimension(-1),d]):d},expression:function(){var a,b,c=[],d;while(a=t(this.addition)||t(this.entity))c.push(a);if(c.length>0)return new e.Expression(c)},property:function(){var a;if(a=t(/^(\*?-?[-a-z_0-9]+)\s*:/))return a[1]}}}};if(d.mode==="browser"||d.mode==="rhino")d.Parser.importer=function(a,b,c,d){!/^([a-z]+:)?\//.test(a)&&b.length>0&&(a=b[0]+a),n({href:a,title:a,type:d.mime},function(e){e&&typeof d.errback=="function"?d.errback.call(null,a,b,c,d):c.apply(null,arguments)},!0)};(function(a){function b(b){return a.functions.hsla(b.h,b.s,b.l,b.a)}function c(b){if(b instanceof a.Dimension)return parseFloat(b.unit=="%"?b.value/100:b.value);if(typeof b=="number")return b;throw{error:"RuntimeError",message:"color functions take numbers as parameters"}}function d(a){return Math.min(1,Math.max(0,a))}a.functions={rgb:function(a,b,c){return this.rgba(a,b,c,1)},rgba:function(b,d,e,f){var g=[b,d,e].map(function(a){return c(a)}),f=c(f);return new a.Color(g,f)},hsl:function(a,b,c){return this.hsla(a,b,c,1)},hsla:function(a,b,d,e){function h(a){return a=a<0?a+1:a>1?a-1:a,a*6<1?g+(f-g)*a*6:a*2<1?f:a*3<2?g+(f-g)*(2/3-a)*6:g}a=c(a)%360/360,b=c(b),d=c(d),e=c(e);var f=d<=.5?d*(b+1):d+b-d*b,g=d*2-f;return this.rgba(h(a+1/3)*255,h(a)*255,h(a-1/3)*255,e)},hue:function(b){return new a.Dimension(Math.round(b.toHSL().h))},saturation:function(b){return new a.Dimension(Math.round(b.toHSL().s*100),"%")},lightness:function(b){return new a.Dimension(Math.round(b.toHSL().l*100),"%")},alpha:function(b){return new a.Dimension(b.toHSL().a)},saturate:function(a,c){var e=a.toHSL();return e.s+=c.value/100,e.s=d(e.s),b(e)},desaturate:function(a,c){var e=a.toHSL();return e.s-=c.value/100,e.s=d(e.s),b(e)},lighten:function(a,c){var e=a.toHSL();return e.l+=c.value/100,e.l=d(e.l),b(e)},darken:function(a,c){var e=a.toHSL();return e.l-=c.value/100,e.l=d(e.l),b(e)},fadein:function(a,c){var e=a.toHSL();return e.a+=c.value/100,e.a=d(e.a),b(e)},fadeout:function(a,c){var e=a.toHSL();return e.a-=c.value/100,e.a=d(e.a),b(e)},fade:function(a,c){var e=a.toHSL();return e.a=c.value/100,e.a=d(e.a),b(e)},spin:function(a,c){var d=a.toHSL(),e=(d.h+c.value)%360;return d.h=e<0?360+e:e,b(d)},mix:function(b,c,d){var e=d.value/100,f=e*2-1,g=b.toHSL().a-c.toHSL().a,h=((f*g==-1?f:(f+g)/(1+f*g))+1)/2,i=1-h,j=[b.rgb[0]*h+c.rgb[0]*i,b.rgb[1]*h+c.rgb[1]*i,b.rgb[2]*h+c.rgb[2]*i],k=b.alpha*e+c.alpha*(1-e);return new a.Color(j,k)},greyscale:function(b){return this.desaturate(b,new a.Dimension(100))},e:function(b){return new a.Anonymous(b instanceof a.JavaScript?b.evaluated:b)},escape:function(b){return new a.Anonymous(encodeURI(b.value).replace(/=/g,"%3D").replace(/:/g,"%3A").replace(/#/g,"%23").replace(/;/g,"%3B").replace(/\(/g,"%28").replace(/\)/g,"%29"))},"%":function(b){var c=Array.prototype.slice.call(arguments,1),d=b.value;for(var e=0;e<c.length;e++)d=d.replace(/%[sda]/i,function(a){var b=a.match(/s/i)?c[e].value:c[e].toCSS();return a.match(/[A-Z]$/)?encodeURIComponent(b):b});return d=d.replace(/%%/g,"%"),new a.Quoted('"'+d+'"',d)},round:function(a){return this._math("round",a)},ceil:function(a){return this._math("ceil",a)},floor:function(a){return this._math("floor",a)},_math:function(b,d){if(d instanceof a.Dimension)return new a.Dimension(Math[b](c(d)),d.unit);if(typeof d=="number")return Math[b](d);throw{type:"Argument",message:"argument must be a number"}},argb:function(b){return new a.Anonymous(b.toARGB())},percentage:function(b){return new a.Dimension(b.value*100,"%")},color:function(b){if(b instanceof a.Quoted)return new a.Color(b.value.slice(1));throw{type:"Argument",message:"argument must be a string"}},iscolor:function(b){return this._isa(b,a.Color)},isnumber:function(b){return this._isa(b,a.Dimension)},isstring:function(b){return this._isa(b,a.Quoted)},iskeyword:function(b){return this._isa(b,a.Keyword)},isurl:function(b){return this._isa(b,a.URL)},ispixel:function(b){return b instanceof a.Dimension&&b.unit==="px"?a.True:a.False},ispercentage:function(b){return b instanceof a.Dimension&&b.unit==="%"?a.True:a.False},isem:function(b){return b instanceof a.Dimension&&b.unit==="em"?a.True:a.False},_isa:function(b,c){return b instanceof c?a.True:a.False}}})(c("./tree")),function(a){a.colors={aliceblue:"#f0f8ff",antiquewhite:"#faebd7",aqua:"#00ffff",aquamarine:"#7fffd4",azure:"#f0ffff",beige:"#f5f5dc",bisque:"#ffe4c4",black:"#000000",blanchedalmond:"#ffebcd",blue:"#0000ff",blueviolet:"#8a2be2",brown:"#a52a2a",burlywood:"#deb887",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",cornflowerblue:"#6495ed",cornsilk:"#fff8dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkgray:"#a9a9a9",darkgrey:"#a9a9a9",darkgreen:"#006400",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",dodgerblue:"#1e90ff",firebrick:"#b22222",floralwhite:"#fffaf0",forestgreen:"#228b22",fuchsia:"#ff00ff",gainsboro:"#dcdcdc",ghostwhite:"#f8f8ff",gold:"#ffd700",goldenrod:"#daa520",gray:"#808080",grey:"#808080",green:"#008000",greenyellow:"#adff2f",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",lightgray:"#d3d3d3",lightgrey:"#d3d3d3",lightgreen:"#90ee90",lightpink:"#ffb6c1",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",lightskyblue:"#87cefa",lightslategray:"#778899",lightslategrey:"#778899",lightsteelblue:"#b0c4de",lightyellow:"#ffffe0",lime:"#00ff00",limegreen:"#32cd32",linen:"#faf0e6",magenta:"#ff00ff",maroon:"#800000",mediumaquamarine:"#66cdaa",mediumblue:"#0000cd",mediumorchid:"#ba55d3",mediumpurple:"#9370d8",mediumseagreen:"#3cb371",mediumslateblue:"#7b68ee",mediumspringgreen:"#00fa9a",mediumturquoise:"#48d1cc",mediumvioletred:"#c71585",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:"#d87093",papayawhip:"#ffefd5",peachpuff:"#ffdab9",peru:"#cd853f",pink:"#ffc0cb",plum:"#dda0dd",powderblue:"#b0e0e6",purple:"#800080",red:"#ff0000",rosybrown:"#bc8f8f",royalblue:"#4169e1",saddlebrown:"#8b4513",salmon:"#fa8072",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:"#ffffff",whitesmoke:"#f5f5f5",yellow:"#ffff00",yellowgreen:"#9acd32"}}(c("./tree")),function(a){a.Alpha=function(a){this.value=a},a.Alpha.prototype={toCSS:function(){return"alpha(opacity="+(this.value.toCSS?this.value.toCSS():this.value)+")"},eval:function(a){return this.value.eval&&(this.value=this.value.eval(a)),this}}}(c("../tree")),function(a){a.Anonymous=function(a){this.value=a.value||a},a.Anonymous.prototype={toCSS:function(){return this.value},eval:function(){return this}}}(c("../tree")),function(a){a.Assignment=function(a,b){this.key=a,this.value=b},a.Assignment.prototype={toCSS:function(){return this.key+"="+(this.value.toCSS?this.value.toCSS():this.value)},eval:function(a){return this.value.eval&&(this.value=this.value.eval(a)),this}}}(c("../tree")),function(a){a.Call=function(a,b,c,d){this.name=a,this.args=b,this.index=c,this.filename=d},a.Call.prototype={eval:function(b){var c=this.args.map(function(a){return a.eval(b)});if(!(this.name in a.functions))return new a.Anonymous(this.name+"("+c.map(function(a){return a.toCSS()}).join(", ")+")");try{return a.functions[this.name].apply(a.functions,c)}catch(d){throw{type:d.type||"Runtime",message:"error evaluating function `"+this.name+"`"+(d.message?": "+d.message:""),index:this.index,filename:this.filename}}},toCSS:function(a){return this.eval(a).toCSS()}}}(c("../tree")),function(a){a.Color=function(a,b){Array.isArray(a)?this.rgb=a:a.length==6?this.rgb=a.match(/.{2}/g).map(function(a){return parseInt(a,16)}):this.rgb=a.split("").map(function(a){return parseInt(a+a,16)}),this.alpha=typeof b=="number"?b:1},a.Color.prototype={eval:function(){return this},toCSS:function(){return this.alpha<1?"rgba("+this.rgb.map(function(a){return Math.round(a)}).concat(this.alpha).join(", ")+")":"#"+this.rgb.map(function(a){return a=Math.round(a),a=(a>255?255:a<0?0:a).toString(16),a.length===1?"0"+a:a}).join("")},operate:function(b,c){var d=[];c instanceof a.Color||(c=c.toColor());for(var e=0;e<3;e++)d[e]=a.operate(b,this.rgb[e],c.rgb[e]);return new a.Color(d,this.alpha+c.alpha)},toHSL:function(){var a=this.rgb[0]/255,b=this.rgb[1]/255,c=this.rgb[2]/255,d=this.alpha,e=Math.max(a,b,c),f=Math.min(a,b,c),g,h,i=(e+f)/2,j=e-f;if(e===f)g=h=0;else{h=i>.5?j/(2-e-f):j/(e+f);switch(e){case a:g=(b-c)/j+(b<c?6:0);break;case b:g=(c-a)/j+2;break;case c:g=(a-b)/j+4}g/=6}return{h:g*360,s:h,l:i,a:d}},toARGB:function(){var a=[Math.round(this.alpha*255)].concat(this.rgb);return"#"+a.map(function(a){return a=Math.round(a),a=(a>255?255:a<0?0:a).toString(16),a.length===1?"0"+a:a}).join("")}}}(c("../tree")),function(a){a.Comment=function(a,b){this.value=a,this.silent=!!b},a.Comment.prototype={toCSS:function(a){return a.compress?"":this.value},eval:function(){return this}}}(c("../tree")),function(a){a.Condition=function(a,b,c,d,e){this.op=a.trim(),this.lvalue=b,this.rvalue=c,this.index=d,this.negate=e},a.Condition.prototype.eval=function(a){var b=this.lvalue.eval(a),c=this.rvalue.eval(a),d=this.index,e,e=function(a){switch(a){case"and":return b&&c;case"or":return b||c;default:if(b.compare)e=b.compare(c);else if(c.compare)e=c.compare(b);else throw{type:"Type",message:"Unable to perform comparison",index:d};switch(e){case-1:return a==="<"||a==="=<";case 0:return a==="="||a===">="||a==="=<";case 1:return a===">"||a===">="}}}(this.op);return this.negate?!e:e}}(c("../tree")),function(a){a.Dimension=function(a,b){this.value=parseFloat(a),this.unit=b||null},a.Dimension.prototype={eval:function(){return this},toColor:function(){return new a.Color([this.value,this.value,this.value])},toCSS:function(){var a=this.value+this.unit;return a},operate:function(b,c){return new a.Dimension(a.operate(b,this.value,c.value),this.unit||c.unit)},compare:function(b){return b instanceof a.Dimension?b.value>this.value?-1:b.value<this.value?1:0:-1}}}(c("../tree")),function(a){a.Directive=function(b,c,d){this.name=b,Array.isArray(c)?(this.ruleset=new a.Ruleset([],c),this.ruleset.allowImports=!0):this.value=c},a.Directive.prototype={toCSS:function(a,b){return this.ruleset?(this.ruleset.root=!0,this.name+(b.compress?"{":" {\n ")+this.ruleset.toCSS(a,b).trim().replace(/\n/g,"\n ")+(b.compress?"}":"\n}\n")):this.name+" "+this.value.toCSS()+";\n"},eval:function(a){return a.frames.unshift(this),this.ruleset=this.ruleset&&this.ruleset.eval(a),a.frames.shift(),this},variable:function(b){return a.Ruleset.prototype.variable.call(this.ruleset,b)},find:function(){return a.Ruleset.prototype.find.apply(this.ruleset,arguments)},rulesets:function(){return a.Ruleset.prototype.rulesets.apply(this.ruleset)}}}(c("../tree")),function(a){a.Element=function(b,c,d){this.combinator=b instanceof a.Combinator?b:new a.Combinator(b),typeof c=="string"?this.value=c.trim():c?this.value=c:this.value="",this.index=d},a.Element.prototype.eval=function(b){return new a.Element(this.combinator,this.value.eval?this.value.eval(b):this.value,this.index)},a.Element.prototype.toCSS=function(a){return this.combinator.toCSS(a||{})+(this.value.toCSS?this.value.toCSS(a):this.value)},a.Combinator=function(a){a===" "?this.value=" ":a==="& "?this.value="& ":this.value=a?a.trim():""},a.Combinator.prototype.toCSS=function(a){return{"":""," ":" ","&":"","& ":" ",":":" :","+":a.compress?"+":" + ","~":a.compress?"~":" ~ ",">":a.compress?">":" > "}[this.value]}}(c("../tree")),function(a){a.Expression=function(a){this.value=a},a.Expression.prototype={eval:function(b){return this.value.length>1?new a.Expression(this.value.map(function(a){return a.eval(b)})):this.value.length===1?this.value[0].eval(b):this},toCSS:function(a){return this.value.map(function(b){return b.toCSS?b.toCSS(a):""}).join(" ")}}}(c("../tree")),function(a){a.Import=function(b,c,d,e){var f=this;this.index=e,this._path=b,this.features=d&&new a.Value(d),b instanceof a.Quoted?this.path=/\.(le?|c)ss(\?.*)?$/.test(b.value)?b.value:b.value+".less":this.path=b.value.value||b.value,this.css=/css(\?.*)?$/.test(this.path),this.css||c.push(this.path,function(b,c){b&&(b.index=e),f.root=c||new a.Ruleset([],[])})},a.Import.prototype={toCSS:function(a){var b=this.features?" "+this.features.toCSS(a):"";return this.css?"@import "+this._path.toCSS()+b+";\n":""},eval:function(b){var c,d=this.features&&this.features.eval(b);if(this.css)return this;c=new a.Ruleset([],this.root.rules.slice(0));for(var e=0;e<c.rules.length;e++)c.rules[e]instanceof a.Import&&Array.prototype
9
+ .splice.apply(c.rules,[e,1].concat(c.rules[e].eval(b)));return this.features?new a.Media(c.rules,this.features.value):c.rules}}}(c("../tree")),function(a){a.JavaScript=function(a,b,c){this.escaped=c,this.expression=a,this.index=b},a.JavaScript.prototype={eval:function(b){var c,d=this,e={},f=this.expression.replace(/@\{([\w-]+)\}/g,function(c,e){return a.jsify((new a.Variable("@"+e,d.index)).eval(b))});try{f=new Function("return ("+f+")")}catch(g){throw{message:"JavaScript evaluation error: `"+f+"`",index:this.index}}for(var h in b.frames[0].variables())e[h.slice(1)]={value:b.frames[0].variables()[h].value,toJS:function(){return this.value.eval(b).toCSS()}};try{c=f.call(e)}catch(g){throw{message:"JavaScript evaluation error: '"+g.name+": "+g.message+"'",index:this.index}}return typeof c=="string"?new a.Quoted('"'+c+'"',c,this.escaped,this.index):Array.isArray(c)?new a.Anonymous(c.join(", ")):new a.Anonymous(c)}}}(c("../tree")),function(a){a.Keyword=function(a){this.value=a},a.Keyword.prototype={eval:function(){return this},toCSS:function(){return this.value},compare:function(b){return b instanceof a.Keyword?b.value===this.value?0:1:-1}},a.True=new a.Keyword("true"),a.False=new a.Keyword("false")}(c("../tree")),function(a){a.Media=function(b,c){var d=new a.Element("&",null,0),e=[new a.Selector([d])];this.features=new a.Value(c),this.ruleset=new a.Ruleset(e,b),this.ruleset.allowImports=!0},a.Media.prototype={toCSS:function(a,b){var c=this.features.toCSS(b);return this.ruleset.root=a.length===0||a[0].multiMedia,"@media "+c+(b.compress?"{":" {\n ")+this.ruleset.toCSS(a,b).trim().replace(/\n/g,"\n ")+(b.compress?"}":"\n}\n")},eval:function(b){b.mediaBlocks||(b.mediaBlocks=[],b.mediaPath=[]);var c=b.mediaBlocks.length;b.mediaPath.push(this),b.mediaBlocks.push(this);var d=new a.Media([],[]);return d.features=this.features.eval(b),b.frames.unshift(this.ruleset),d.ruleset=this.ruleset.eval(b),b.frames.shift(),b.mediaBlocks[c]=d,b.mediaPath.pop(),b.mediaPath.length===0?d.evalTop(b):d.evalNested(b)},variable:function(b){return a.Ruleset.prototype.variable.call(this.ruleset,b)},find:function(){return a.Ruleset.prototype.find.apply(this.ruleset,arguments)},rulesets:function(){return a.Ruleset.prototype.rulesets.apply(this.ruleset)},evalTop:function(b){var c=this;if(b.mediaBlocks.length>1){var d=new a.Element("&",null,0),e=[new a.Selector([d])];c=new a.Ruleset(e,b.mediaBlocks),c.multiMedia=!0}return delete b.mediaBlocks,delete b.mediaPath,c},evalNested:function(b){var c,d,e=b.mediaPath.concat([this]);for(c=0;c<e.length;c++)d=e[c].features instanceof a.Value?e[c].features.value:e[c].features,e[c]=Array.isArray(d)?d:[d];return this.features=new a.Value(this.permute(e).map(function(b){b=b.map(function(b){return b.toCSS?b:new a.Anonymous(b)});for(c=b.length-1;c>0;c--)b.splice(c,0,new a.Anonymous("and"));return new a.Expression(b)})),new a.Ruleset([],[])},permute:function(a){if(a.length===0)return[];if(a.length===1)return a[0];var b=[],c=this.permute(a.slice(1));for(var d=0;d<c.length;d++)for(var e=0;e<a[0].length;e++)b.push([a[0][e]].concat(c[d]));return b}}}(c("../tree")),function(a){a.mixin={},a.mixin.Call=function(b,c,d,e,f){this.selector=new a.Selector(b),this.arguments=c,this.index=d,this.filename=e,this.important=f},a.mixin.Call.prototype={eval:function(a){var b,c,d=[],e=!1;for(var f=0;f<a.frames.length;f++)if((b=a.frames[f].find(this.selector)).length>0){c=this.arguments&&this.arguments.map(function(b){return b.eval(a)});for(var g=0;g<b.length;g++)if(b[g].match(c,a))try{Array.prototype.push.apply(d,b[g].eval(a,this.arguments,this.important).rules),e=!0}catch(h){throw{message:h.message,index:this.index,filename:this.filename,stack:h.stack}}if(e)return d;throw{type:"Runtime",message:"No matching definition was found for `"+this.selector.toCSS().trim()+"("+this.arguments.map(function(a){return a.toCSS()}).join(", ")+")`",index:this.index,filename:this.filename}}throw{type:"Name",message:this.selector.toCSS().trim()+" is undefined",index:this.index,filename:this.filename}}},a.mixin.Definition=function(b,c,d,e,f){this.name=b,this.selectors=[new a.Selector([new a.Element(null,b)])],this.params=c,this.condition=e,this.variadic=f,this.arity=c.length,this.rules=d,this._lookups={},this.required=c.reduce(function(a,b){return!b.name||b.name&&!b.value?a+1:a},0),this.parent=a.Ruleset.prototype,this.frames=[]},a.mixin.Definition.prototype={toCSS:function(){return""},variable:function(a){return this.parent.variable.call(this,a)},variables:function(){return this.parent.variables.call(this)},find:function(){return this.parent.find.apply(this,arguments)},rulesets:function(){return this.parent.rulesets.apply(this)},evalParams:function(b,c){var d=new a.Ruleset(null,[]),e;for(var f=0,g,h;f<this.params.length;f++)if(h=this.params[f].name)if(this.params[f].variadic&&c){e=[];for(var i=f;i<c.length;i++)e.push(c[i].eval(b));d.rules.unshift(new a.Rule(h,(new a.Expression(e)).eval(b)))}else if(g=c&&c[f]||this.params[f].value)d.rules.unshift(new a.Rule(h,g.eval(b)));else throw{type:"Runtime",message:"wrong number of arguments for "+this.name+" ("+c.length+" for "+this.arity+")"};return d},eval:function(b,c,d){var e=this.evalParams(b,c),f,g=[],h,i;for(var j=0;j<Math.max(this.params.length,c&&c.length);j++)g.push(c[j]||this.params[j].value);return e.rules.unshift(new a.Rule("@arguments",(new a.Expression(g)).eval(b))),h=d?this.rules.map(function(b){return new a.Rule(b.name,b.value,"!important",b.index)}):this.rules.slice(0),(new a.Ruleset(null,h)).eval({frames:[this,e].concat(this.frames,b.frames)})},match:function(a,b){var c=a&&a.length||0,d,e;if(!this.variadic){if(c<this.required)return!1;if(c>this.params.length)return!1;if(this.required>0&&c>this.params.length)return!1}if(this.condition&&!this.condition.eval({frames:[this.evalParams(b,a)].concat(b.frames)}))return!1;d=Math.min(c,this.arity);for(var f=0;f<d;f++)if(!this.params[f].name&&a[f].eval(b).toCSS()!=this.params[f].value.eval(b).toCSS())return!1;return!0}}}(c("../tree")),function(a){a.Operation=function(a,b){this.op=a.trim(),this.operands=b},a.Operation.prototype.eval=function(b){var c=this.operands[0].eval(b),d=this.operands[1].eval(b),e;if(c instanceof a.Dimension&&d instanceof a.Color)if(this.op==="*"||this.op==="+")e=d,d=c,c=e;else throw{name:"OperationError",message:"Can't substract or divide a color from a number"};return c.operate(this.op,d)},a.operate=function(a,b,c){switch(a){case"+":return b+c;case"-":return b-c;case"*":return b*c;case"/":return b/c}}}(c("../tree")),function(a){a.Paren=function(a){this.value=a},a.Paren.prototype={toCSS:function(a){return"("+this.value.toCSS(a)+")"},eval:function(b){return new a.Paren(this.value.eval(b))}}}(c("../tree")),function(a){a.Quoted=function(a,b,c,d){this.escaped=c,this.value=b||"",this.quote=a.charAt(0),this.index=d},a.Quoted.prototype={toCSS:function(){return this.escaped?this.value:this.quote+this.value+this.quote},eval:function(b){var c=this,d=this.value.replace(/`([^`]+)`/g,function(d,e){return(new a.JavaScript(e,c.index,!0)).eval(b).value}).replace(/@\{([\w-]+)\}/g,function(d,e){var f=(new a.Variable("@"+e,c.index)).eval(b);return"value"in f?f.value:f.toCSS()});return new a.Quoted(this.quote+d+this.quote,d,this.escaped,this.index)}}}(c("../tree")),function(a){a.Rule=function(b,c,d,e,f){this.name=b,this.value=c instanceof a.Value?c:new a.Value([c]),this.important=d?" "+d.trim():"",this.index=e,this.inline=f||!1,b.charAt(0)==="@"?this.variable=!0:this.variable=!1},a.Rule.prototype.toCSS=function(a){return this.variable?"":this.name+(a.compress?":":": ")+this.value.toCSS(a)+this.important+(this.inline?"":";")},a.Rule.prototype.eval=function(b){return new a.Rule(this.name,this.value.eval(b),this.important,this.index,this.inline)},a.Shorthand=function(a,b){this.a=a,this.b=b},a.Shorthand.prototype={toCSS:function(a){return this.a.toCSS(a)+"/"+this.b.toCSS(a)},eval:function(){return this}}}(c("../tree")),function(a){a.Ruleset=function(a,b,c){this.selectors=a,this.rules=b,this._lookups={},this.strictImports=c},a.Ruleset.prototype={eval:function(b){var c=this.selectors&&this.selectors.map(function(a){return a.eval(b)}),d=new a.Ruleset(c,this.rules.slice(0),this.strictImports);d.root=this.root,d.allowImports=this.allowImports,b.frames.unshift(d);if(d.root||d.allowImports||!d.strictImports)for(var e=0;e<d.rules.length;e++)d.rules[e]instanceof a.Import&&Array.prototype.splice.apply(d.rules,[e,1].concat(d.rules[e].eval(b)));for(var e=0;e<d.rules.length;e++)d.rules[e]instanceof a.mixin.Definition&&(d.rules[e].frames=b.frames.slice(0));for(var e=0;e<d.rules.length;e++)d.rules[e]instanceof a.mixin.Call&&Array.prototype.splice.apply(d.rules,[e,1].concat(d.rules[e].eval(b)));for(var e=0,f;e<d.rules.length;e++)f=d.rules[e],f instanceof a.mixin.Definition||(d.rules[e]=f.eval?f.eval(b):f);return b.frames.shift(),d},match:function(a){return!a||a.length===0},variables:function(){return this._variables?this._variables:this._variables=this.rules.reduce(function(b,c){return c instanceof a.Rule&&c.variable===!0&&(b[c.name]=c),b},{})},variable:function(a){return this.variables()[a]},rulesets:function(){return this._rulesets?this._rulesets:this._rulesets=this.rules.filter(function(b){return b instanceof a.Ruleset||b instanceof a.mixin.Definition})},find:function(b,c){c=c||this;var d=[],e,f,g=b.toCSS();return g in this._lookups?this._lookups[g]:(this.rulesets().forEach(function(e){if(e!==c)for(var g=0;g<e.selectors.length;g++)if(f=b.match(e.selectors[g])){b.elements.length>e.selectors[g].elements.length?Array.prototype.push.apply(d,e.find(new a.Selector(b.elements.slice(1)),c)):d.push(e);break}}),this._lookups[g]=d)},toCSS:function(b,c){var d=[],e=[],f=[],g=[],h,i;this.root||(b.length===0?g=this.selectors.map(function(a){return[a]}):this.joinSelectors(g,b,this.selectors));for(var j=0;j<this.rules.length;j++)i=this.rules[j],i.rules||i instanceof a.Directive||i instanceof a.Media?f.push(i.toCSS(g,c)):i instanceof a.Comment?i.silent||(this.root?f.push(i.toCSS(c)):e.push(i.toCSS(c))):i.toCSS&&!i.variable?e.push(i.toCSS(c)):i.value&&!i.variable&&e.push(i.value.toString());return f=f.join(""),this.root?d.push(e.join(c.compress?"":"\n")):e.length>0&&(h=g.map(function(a){return a.map(function(a){return a.toCSS(c)}).join("").trim()}).join(c.compress?",":",\n"),d.push(h,(c.compress?"{":" {\n ")+e.join(c.compress?"":"\n ")+(c.compress?"}":"\n}\n"))),d.push(f),d.join("")+(c.compress?"\n":"")},joinSelectors:function(a,b,c){for(var d=0;d<c.length;d++)this.joinSelector(a,b,c[d])},joinSelector:function(b,c,d){var e=[],f=[],g=[],h=[],i=!1,j;for(var k=0;k<d.elements.length;k++)j=d.elements[k],j.combinator.value.charAt(0)==="&"&&(i=!0),i?h.push(j):g.push(j);i||(h=g,g=[]),g.length>0&&e.push(new a.Selector(g)),h.length>0&&f.push(new a.Selector(h));for(var l=0;l<c.length;l++)b.push(e.concat(c[l]).concat(f))}}}(c("../tree")),function(a){a.Selector=function(a){this.elements=a,this.elements[0].combinator.value===""&&(this.elements[0].combinator.value=" ")},a.Selector.prototype.match=function(a){var b=this.elements.length,c=a.elements.length,d=Math.min(b,c);if(b<c)return!1;for(var e=0;e<d;e++)if(this.elements[e].value!==a.elements[e].value)return!1;return!0},a.Selector.prototype.eval=function(b){return new a.Selector(this.elements.map(function(a){return a.eval(b)}))},a.Selector.prototype.toCSS=function(a){return this._css?this._css:this._css=this.elements.map(function(b){return typeof b=="string"?" "+b.trim():b.toCSS(a)}).join("")}}(c("../tree")),function(b){b.URL=function(b,c){b.data?this.attrs=b:(typeof a!="undefined"&&!/^(?:https?:\/\/|file:\/\/|data:|\/)/.test(b.value)&&c.length>0&&(b.value=c[0]+(b.value.charAt(0)==="/"?b.value.slice(1):b.value)),this.value=b,this.paths=c)},b.URL.prototype={toCSS:function(){return"url("+(this.attrs?"data:"+this.attrs.mime+this.attrs.charset+this.attrs.base64+this.attrs.data:this.value.toCSS())+")"},eval:function(a){return this.attrs?this:new b.URL(this.value.eval(a),this.paths)}}}(c("../tree")),function(a){a.Value=function(a){this.value=a,this.is="value"},a.Value.prototype={eval:function(b){return this.value.length===1?this.value[0].eval(b):new a.Value(this.value.map(function(a){return a.eval(b)}))},toCSS:function(a){return this.value.map(function(b){return b.toCSS(a)}).join(a.compress?",":", ")}}}(c("../tree")),function(a){a.Variable=function(a,b,c){this.name=a,this.index=b,this.file=c},a.Variable.prototype={eval:function(b){var c,d,e=this.name;e.indexOf("@@")==0&&(e="@"+(new a.Variable(e.slice(1))).eval(b).value);if(c=a.find(b.frames,function(a){if(d=a.variable(e))return d.value.eval(b)}))return c;throw{type:"Name",message:"variable "+e+" is undefined",filename:this.file,index:this.index}}}}(c("../tree")),function(a){a.find=function(a,b){for(var c=0,d;c<a.length;c++)if(d=b.call(a,a[c]))return d;return null},a.jsify=function(a){return Array.isArray(a.value)&&a.value.length>1?"["+a.value.map(function(a){return a.toCSS(!1)}).join(", ")+"]":a.toCSS(!1)}}(c("./tree"));var f=location.protocol==="file:"||location.protocol==="chrome:"||location.protocol==="chrome-extension:"||location.protocol==="resource:";d.env=d.env||(location.hostname=="127.0.0.1"||location.hostname=="0.0.0.0"||location.hostname=="localhost"||location.port.length>0||f?"development":"production"),d.async=!1,d.poll=d.poll||(f?1e3:1500),d.watch=function(){return this.watchMode=!0},d.unwatch=function(){return this.watchMode=!1},d.env==="development"?(d.optimization=0,/!watch/.test(location.hash)&&d.watch(),d.watchTimer=setInterval(function(){d.watchMode&&m(function(a,b,c,d,e){b&&p(b.toCSS(),d,e.lastModified)})},d.poll)):d.optimization=3;var g;try{g=typeof a.localStorage=="undefined"?null:a.localStorage}catch(h){g=null}var i=document.getElementsByTagName("link"),j=/^text\/(x-)?less$/;d.sheets=[];for(var k=0;k<i.length;k++)(i[k].rel==="stylesheet/less"||i[k].rel.match(/stylesheet/)&&i[k].type.match(j))&&d.sheets.push(i[k]);d.refresh=function(a){var b,c;b=c=new Date,m(function(a,d,e,f,g){g.local?t("loading "+f.href+" from cache."):(t("parsed "+f.href+" successfully."),p(d.toCSS(),f,g.lastModified)),t("css for "+f.href+" generated in "+(new Date-c)+"ms"),g.remaining===0&&t("css generated in "+(new Date-b)+"ms"),c=new Date},a),l()},d.refreshStyles=l,d.refresh(d.env==="development")})(window);
license.txt CHANGED
@@ -1,281 +1,674 @@
1
- GNU GENERAL PUBLIC LICENSE
2
- Version 2, June 1991
3
-
4
- Copyright (C) 1989, 1991 Free Software Foundation, Inc.
5
- 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
6
 
 
7
  Everyone is permitted to copy and distribute verbatim copies
8
  of this license document, but changing it is not allowed.
9
 
10
- Preamble
 
 
 
11
 
12
- The licenses for most software are designed to take away your
13
- freedom to share and change it. By contrast, the GNU General Public
14
- License is intended to guarantee your freedom to share and change free
15
- software--to make sure the software is free for all its users. This
16
- General Public License applies to most of the Free Software
17
- Foundation's software and to any other program whose authors commit to
18
- using it. (Some other Free Software Foundation software is covered by
19
- the GNU Library General Public License instead.) You can apply it to
20
  your programs, too.
21
 
22
  When we speak of free software, we are referring to freedom, not
23
  price. Our General Public Licenses are designed to make sure that you
24
  have the freedom to distribute copies of free software (and charge for
25
- this service if you wish), that you receive source code or can get it
26
- if you want it, that you can change the software or use pieces of it
27
- in new free programs; and that you know you can do these things.
28
 
29
- To protect your rights, we need to make restrictions that forbid
30
- anyone to deny you these rights or to ask you to surrender the rights.
31
- These restrictions translate to certain responsibilities for you if you
32
- distribute copies of the software, or if you modify it.
33
 
34
  For example, if you distribute copies of such a program, whether
35
- gratis or for a fee, you must give the recipients all the rights that
36
- you have. You must make sure that they, too, receive or can get the
37
- source code. And you must show them these terms so they know their
38
- rights.
39
-
40
- We protect your rights with two steps: (1) copyright the software, and
41
- (2) offer you this license which gives you legal permission to copy,
42
- distribute and/or modify the software.
43
-
44
- Also, for each author's protection and ours, we want to make certain
45
- that everyone understands that there is no warranty for this free
46
- software. If the software is modified by someone else and passed on, we
47
- want its recipients to know that what they have is not the original, so
48
- that any problems introduced by others will not reflect on the original
49
- authors' reputations.
50
-
51
- Finally, any free program is threatened constantly by software
52
- patents. We wish to avoid the danger that redistributors of a free
53
- program will individually obtain patent licenses, in effect making the
54
- program proprietary. To prevent this, we have made it clear that any
55
- patent must be licensed for everyone's free use or not licensed at all.
 
 
 
 
 
 
 
 
 
 
 
56
 
57
  The precise terms and conditions for copying, distribution and
58
  modification follow.
59
 
60
- GNU GENERAL PUBLIC LICENSE
61
- TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
62
-
63
- 0. This License applies to any program or other work which contains
64
- a notice placed by the copyright holder saying it may be distributed
65
- under the terms of this General Public License. The "Program", below,
66
- refers to any such program or work, and a "work based on the Program"
67
- means either the Program or any derivative work under copyright law:
68
- that is to say, a work containing the Program or a portion of it,
69
- either verbatim or with modifications and/or translated into another
70
- language. (Hereinafter, translation is included without limitation in
71
- the term "modification".) Each licensee is addressed as "you".
72
-
73
- Activities other than copying, distribution and modification are not
74
- covered by this License; they are outside its scope. The act of
75
- running the Program is not restricted, and the output from the Program
76
- is covered only if its contents constitute a work based on the
77
- Program (independent of having been made by running the Program).
78
- Whether that is true depends on what the Program does.
79
-
80
- 1. You may copy and distribute verbatim copies of the Program's
81
- source code as you receive it, in any medium, provided that you
82
- conspicuously and appropriately publish on each copy an appropriate
83
- copyright notice and disclaimer of warranty; keep intact all the
84
- notices that refer to this License and to the absence of any warranty;
85
- and give any other recipients of the Program a copy of this License
86
- along with the Program.
87
-
88
- You may charge a fee for the physical act of transferring a copy, and
89
- you may at your option offer warranty protection in exchange for a fee.
90
-
91
- 2. You may modify your copy or copies of the Program or any portion
92
- of it, thus forming a work based on the Program, and copy and
93
- distribute such modifications or work under the terms of Section 1
94
- above, provided that you also meet all of these conditions:
95
-
96
- a) You must cause the modified files to carry prominent notices
97
- stating that you changed the files and the date of any change.
98
-
99
- b) You must cause any work that you distribute or publish, that in
100
- whole or in part contains or is derived from the Program or any
101
- part thereof, to be licensed as a whole at no charge to all third
102
- parties under the terms of this License.
103
-
104
- c) If the modified program normally reads commands interactively
105
- when run, you must cause it, when started running for such
106
- interactive use in the most ordinary way, to print or display an
107
- announcement including an appropriate copyright notice and a
108
- notice that there is no warranty (or else, saying that you provide
109
- a warranty) and that users may redistribute the program under
110
- these conditions, and telling the user how to view a copy of this
111
- License. (Exception: if the Program itself is interactive but
112
- does not normally print such an announcement, your work based on
113
- the Program is not required to print an announcement.)
114
-
115
- These requirements apply to the modified work as a whole. If
116
- identifiable sections of that work are not derived from the Program,
117
- and can be reasonably considered independent and separate works in
118
- themselves, then this License, and its terms, do not apply to those
119
- sections when you distribute them as separate works. But when you
120
- distribute the same sections as part of a whole which is a work based
121
- on the Program, the distribution of the whole must be on the terms of
122
- this License, whose permissions for other licensees extend to the
123
- entire whole, and thus to each and every part regardless of who wrote it.
124
- Thus, it is not the intent of this section to claim rights or contest
125
- your rights to work written entirely by you; rather, the intent is to
126
- exercise the right to control the distribution of derivative or
127
- collective works based on the Program.
128
-
129
- In addition, mere aggregation of another work not based on the Program
130
- with the Program (or with a work based on the Program) on a volume of
131
- a storage or distribution medium does not bring the other work under
132
- the scope of this License.
133
-
134
- 3. You may copy and distribute the Program (or a work based on it,
135
- under Section 2) in object code or executable form under the terms of
136
- Sections 1 and 2 above provided that you also do one of the following:
137
-
138
- a) Accompany it with the complete corresponding machine-readable
139
- source code, which must be distributed under the terms of Sections
140
- 1 and 2 above on a medium customarily used for software interchange; or,
141
-
142
- b) Accompany it with a written offer, valid for at least three
143
- years, to give any third party, for a charge no more than your
144
- cost of physically performing source distribution, a complete
145
- machine-readable copy of the corresponding source code, to be
146
- distributed under the terms of Sections 1 and 2 above on a medium
147
- customarily used for software interchange; or,
148
-
149
- c) Accompany it with the information you received as to the offer
150
- to distribute corresponding source code. (This alternative is
151
- allowed only for noncommercial distribution and only if you
152
- received the program in object code or executable form with such
153
- an offer, in accord with Subsection b above.)
154
-
155
- The source code for a work means the preferred form of the work for
156
- making modifications to it. For an executable work, complete source
157
- code means all the source code for all modules it contains, plus any
158
- associated interface definition files, plus the scripts used to
159
- control compilation and installation of the executable. However, as a
160
- special exception, the source code distributed need not include
161
- anything that is normally distributed (in either source or binary
162
- form) with the major components (compiler, kernel, and so on) of the
163
- operating system on which the executable runs, unless that component
164
- itself accompanies the executable.
165
-
166
- If distribution of executable or object code is made by offering
167
- access to copy from a designated place, then offering equivalent
168
- access to copy the source code from the same place counts as
169
- distribution of the source code, even though third parties are not
170
- compelled to copy the source along with the object code.
171
-
172
- 4. You may not copy, modify, sublicense, or distribute the Program
173
- except as expressly provided under this License. Any attempt
174
- otherwise to copy, modify, sublicense or distribute the Program is
175
- void, and will automatically terminate your rights under this License.
176
- However, parties who have received copies, or rights, from you under
177
- this License will not have their licenses terminated so long as such
178
- parties remain in full compliance.
179
-
180
- 5. You are not required to accept this License, since you have not
181
- signed it. However, nothing else grants you permission to modify or
182
- distribute the Program or its derivative works. These actions are
183
- prohibited by law if you do not accept this License. Therefore, by
184
- modifying or distributing the Program (or any work based on the
185
- Program), you indicate your acceptance of this License to do so, and
186
- all its terms and conditions for copying, distributing or modifying
187
- the Program or works based on it.
188
-
189
- 6. Each time you redistribute the Program (or any work based on the
190
- Program), the recipient automatically receives a license from the
191
- original licensor to copy, distribute or modify the Program subject to
192
- these terms and conditions. You may not impose any further
193
- restrictions on the recipients' exercise of the rights granted herein.
194
- You are not responsible for enforcing compliance by third parties to
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
195
  this License.
196
 
197
- 7. If, as a consequence of a court judgment or allegation of patent
198
- infringement or for any other reason (not limited to patent issues),
199
- conditions are imposed on you (whether by court order, agreement or
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
200
  otherwise) that contradict the conditions of this License, they do not
201
- excuse you from the conditions of this License. If you cannot
202
- distribute so as to satisfy simultaneously your obligations under this
203
- License and any other pertinent obligations, then as a consequence you
204
- may not distribute the Program at all. For example, if a patent
205
- license would not permit royalty-free redistribution of the Program by
206
- all those who receive copies directly or indirectly through you, then
207
- the only way you could satisfy both it and this License would be to
208
- refrain entirely from distribution of the Program.
209
-
210
- If any portion of this section is held invalid or unenforceable under
211
- any particular circumstance, the balance of the section is intended to
212
- apply and the section as a whole is intended to apply in other
213
- circumstances.
214
-
215
- It is not the purpose of this section to induce you to infringe any
216
- patents or other property right claims or to contest validity of any
217
- such claims; this section has the sole purpose of protecting the
218
- integrity of the free software distribution system, which is
219
- implemented by public license practices. Many people have made
220
- generous contributions to the wide range of software distributed
221
- through that system in reliance on consistent application of that
222
- system; it is up to the author/donor to decide if he or she is willing
223
- to distribute software through any other system and a licensee cannot
224
- impose that choice.
225
-
226
- This section is intended to make thoroughly clear what is believed to
227
- be a consequence of the rest of this License.
228
-
229
- 8. If the distribution and/or use of the Program is restricted in
230
- certain countries either by patents or by copyrighted interfaces, the
231
- original copyright holder who places the Program under this License
232
- may add an explicit geographical distribution limitation excluding
233
- those countries, so that distribution is permitted only in or among
234
- countries not thus excluded. In such case, this License incorporates
235
- the limitation as if written in the body of this License.
236
-
237
- 9. The Free Software Foundation may publish revised and/or new versions
238
- of the General Public License from time to time. Such new versions will
239
  be similar in spirit to the present version, but may differ in detail to
240
  address new problems or concerns.
241
 
242
- Each version is given a distinguishing version number. If the Program
243
- specifies a version number of this License which applies to it and "any
244
- later version", you have the option of following the terms and conditions
245
- either of that version or of any later version published by the Free
246
- Software Foundation. If the Program does not specify a version number of
247
- this License, you may choose any version ever published by the Free Software
248
- Foundation.
249
-
250
- 10. If you wish to incorporate parts of the Program into other free
251
- programs whose distribution conditions are different, write to the author
252
- to ask for permission. For software which is copyrighted by the Free
253
- Software Foundation, write to the Free Software Foundation; we sometimes
254
- make exceptions for this. Our decision will be guided by the two goals
255
- of preserving the free status of all derivatives of our free software and
256
- of promoting the sharing and reuse of software generally.
257
-
258
- NO WARRANTY
259
-
260
- 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
261
- FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
262
- OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
263
- PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
264
- OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
265
- MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
266
- TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
267
- PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
268
- REPAIR OR CORRECTION.
269
-
270
- 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
271
- WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
272
- REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
273
- INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
274
- OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
275
- TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
276
- YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
277
- PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
278
- POSSIBILITY OF SUCH DAMAGES.
279
-
280
- END OF TERMS AND CONDITIONS
281
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ GNU GENERAL PUBLIC LICENSE
2
+ Version 3, 29 June 2007
 
 
 
3
 
4
+ Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
5
  Everyone is permitted to copy and distribute verbatim copies
6
  of this license document, but changing it is not allowed.
7
 
8
+ Preamble
9
+
10
+ The GNU General Public License is a free, copyleft license for
11
+ software and other kinds of works.
12
 
13
+ The licenses for most software and other practical works are designed
14
+ to take away your freedom to share and change the works. By contrast,
15
+ the GNU General Public License is intended to guarantee your freedom to
16
+ share and change all versions of a program--to make sure it remains free
17
+ software for all its users. We, the Free Software Foundation, use the
18
+ GNU General Public License for most of our software; it applies also to
19
+ any other work released this way by its authors. You can apply it to
 
20
  your programs, too.
21
 
22
  When we speak of free software, we are referring to freedom, not
23
  price. Our General Public Licenses are designed to make sure that you
24
  have the freedom to distribute copies of free software (and charge for
25
+ them if you wish), that you receive source code or can get it if you
26
+ want it, that you can change the software or use pieces of it in new
27
+ free programs, and that you know you can do these things.
28
 
29
+ To protect your rights, we need to prevent others from denying you
30
+ these rights or asking you to surrender the rights. Therefore, you have
31
+ certain responsibilities if you distribute copies of the software, or if
32
+ you modify it: responsibilities to respect the freedom of others.
33
 
34
  For example, if you distribute copies of such a program, whether
35
+ gratis or for a fee, you must pass on to the recipients the same
36
+ freedoms that you received. You must make sure that they, too, receive
37
+ or can get the source code. And you must show them these terms so they
38
+ know their rights.
39
+
40
+ Developers that use the GNU GPL protect your rights with two steps:
41
+ (1) assert copyright on the software, and (2) offer you this License
42
+ giving you legal permission to copy, distribute and/or modify it.
43
+
44
+ For the developers' and authors' protection, the GPL clearly explains
45
+ that there is no warranty for this free software. For both users' and
46
+ authors' sake, the GPL requires that modified versions be marked as
47
+ changed, so that their problems will not be attributed erroneously to
48
+ authors of previous versions.
49
+
50
+ Some devices are designed to deny users access to install or run
51
+ modified versions of the software inside them, although the manufacturer
52
+ can do so. This is fundamentally incompatible with the aim of
53
+ protecting users' freedom to change the software. The systematic
54
+ pattern of such abuse occurs in the area of products for individuals to
55
+ use, which is precisely where it is most unacceptable. Therefore, we
56
+ have designed this version of the GPL to prohibit the practice for those
57
+ products. If such problems arise substantially in other domains, we
58
+ stand ready to extend this provision to those domains in future versions
59
+ of the GPL, as needed to protect the freedom of users.
60
+
61
+ Finally, every program is threatened constantly by software patents.
62
+ States should not allow patents to restrict development and use of
63
+ software on general-purpose computers, but in those that do, we wish to
64
+ avoid the special danger that patents applied to a free program could
65
+ make it effectively proprietary. To prevent this, the GPL assures that
66
+ patents cannot be used to render the program non-free.
67
 
68
  The precise terms and conditions for copying, distribution and
69
  modification follow.
70
 
71
+ TERMS AND CONDITIONS
72
+
73
+ 0. Definitions.
74
+
75
+ "This License" refers to version 3 of the GNU General Public License.
76
+
77
+ "Copyright" also means copyright-like laws that apply to other kinds of
78
+ works, such as semiconductor masks.
79
+
80
+ "The Program" refers to any copyrightable work licensed under this
81
+ License. Each licensee is addressed as "you". "Licensees" and
82
+ "recipients" may be individuals or organizations.
83
+
84
+ To "modify" a work means to copy from or adapt all or part of the work
85
+ in a fashion requiring copyright permission, other than the making of an
86
+ exact copy. The resulting work is called a "modified version" of the
87
+ earlier work or a work "based on" the earlier work.
88
+
89
+ A "covered work" means either the unmodified Program or a work based
90
+ on the Program.
91
+
92
+ To "propagate" a work means to do anything with it that, without
93
+ permission, would make you directly or secondarily liable for
94
+ infringement under applicable copyright law, except executing it on a
95
+ computer or modifying a private copy. Propagation includes copying,
96
+ distribution (with or without modification), making available to the
97
+ public, and in some countries other activities as well.
98
+
99
+ To "convey" a work means any kind of propagation that enables other
100
+ parties to make or receive copies. Mere interaction with a user through
101
+ a computer network, with no transfer of a copy, is not conveying.
102
+
103
+ An interactive user interface displays "Appropriate Legal Notices"
104
+ to the extent that it includes a convenient and prominently visible
105
+ feature that (1) displays an appropriate copyright notice, and (2)
106
+ tells the user that there is no warranty for the work (except to the
107
+ extent that warranties are provided), that licensees may convey the
108
+ work under this License, and how to view a copy of this License. If
109
+ the interface presents a list of user commands or options, such as a
110
+ menu, a prominent item in the list meets this criterion.
111
+
112
+ 1. Source Code.
113
+
114
+ The "source code" for a work means the preferred form of the work
115
+ for making modifications to it. "Object code" means any non-source
116
+ form of a work.
117
+
118
+ A "Standard Interface" means an interface that either is an official
119
+ standard defined by a recognized standards body, or, in the case of
120
+ interfaces specified for a particular programming language, one that
121
+ is widely used among developers working in that language.
122
+
123
+ The "System Libraries" of an executable work include anything, other
124
+ than the work as a whole, that (a) is included in the normal form of
125
+ packaging a Major Component, but which is not part of that Major
126
+ Component, and (b) serves only to enable use of the work with that
127
+ Major Component, or to implement a Standard Interface for which an
128
+ implementation is available to the public in source code form. A
129
+ "Major Component", in this context, means a major essential component
130
+ (kernel, window system, and so on) of the specific operating system
131
+ (if any) on which the executable work runs, or a compiler used to
132
+ produce the work, or an object code interpreter used to run it.
133
+
134
+ The "Corresponding Source" for a work in object code form means all
135
+ the source code needed to generate, install, and (for an executable
136
+ work) run the object code and to modify the work, including scripts to
137
+ control those activities. However, it does not include the work's
138
+ System Libraries, or general-purpose tools or generally available free
139
+ programs which are used unmodified in performing those activities but
140
+ which are not part of the work. For example, Corresponding Source
141
+ includes interface definition files associated with source files for
142
+ the work, and the source code for shared libraries and dynamically
143
+ linked subprograms that the work is specifically designed to require,
144
+ such as by intimate data communication or control flow between those
145
+ subprograms and other parts of the work.
146
+
147
+ The Corresponding Source need not include anything that users
148
+ can regenerate automatically from other parts of the Corresponding
149
+ Source.
150
+
151
+ The Corresponding Source for a work in source code form is that
152
+ same work.
153
+
154
+ 2. Basic Permissions.
155
+
156
+ All rights granted under this License are granted for the term of
157
+ copyright on the Program, and are irrevocable provided the stated
158
+ conditions are met. This License explicitly affirms your unlimited
159
+ permission to run the unmodified Program. The output from running a
160
+ covered work is covered by this License only if the output, given its
161
+ content, constitutes a covered work. This License acknowledges your
162
+ rights of fair use or other equivalent, as provided by copyright law.
163
+
164
+ You may make, run and propagate covered works that you do not
165
+ convey, without conditions so long as your license otherwise remains
166
+ in force. You may convey covered works to others for the sole purpose
167
+ of having them make modifications exclusively for you, or provide you
168
+ with facilities for running those works, provided that you comply with
169
+ the terms of this License in conveying all material for which you do
170
+ not control copyright. Those thus making or running the covered works
171
+ for you must do so exclusively on your behalf, under your direction
172
+ and control, on terms that prohibit them from making any copies of
173
+ your copyrighted material outside their relationship with you.
174
+
175
+ Conveying under any other circumstances is permitted solely under
176
+ the conditions stated below. Sublicensing is not allowed; section 10
177
+ makes it unnecessary.
178
+
179
+ 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
180
+
181
+ No covered work shall be deemed part of an effective technological
182
+ measure under any applicable law fulfilling obligations under article
183
+ 11 of the WIPO copyright treaty adopted on 20 December 1996, or
184
+ similar laws prohibiting or restricting circumvention of such
185
+ measures.
186
+
187
+ When you convey a covered work, you waive any legal power to forbid
188
+ circumvention of technological measures to the extent such circumvention
189
+ is effected by exercising rights under this License with respect to
190
+ the covered work, and you disclaim any intention to limit operation or
191
+ modification of the work as a means of enforcing, against the work's
192
+ users, your or third parties' legal rights to forbid circumvention of
193
+ technological measures.
194
+
195
+ 4. Conveying Verbatim Copies.
196
+
197
+ You may convey verbatim copies of the Program's source code as you
198
+ receive it, in any medium, provided that you conspicuously and
199
+ appropriately publish on each copy an appropriate copyright notice;
200
+ keep intact all notices stating that this License and any
201
+ non-permissive terms added in accord with section 7 apply to the code;
202
+ keep intact all notices of the absence of any warranty; and give all
203
+ recipients a copy of this License along with the Program.
204
+
205
+ You may charge any price or no price for each copy that you convey,
206
+ and you may offer support or warranty protection for a fee.
207
+
208
+ 5. Conveying Modified Source Versions.
209
+
210
+ You may convey a work based on the Program, or the modifications to
211
+ produce it from the Program, in the form of source code under the
212
+ terms of section 4, provided that you also meet all of these conditions:
213
+
214
+ a) The work must carry prominent notices stating that you modified
215
+ it, and giving a relevant date.
216
+
217
+ b) The work must carry prominent notices stating that it is
218
+ released under this License and any conditions added under section
219
+ 7. This requirement modifies the requirement in section 4 to
220
+ "keep intact all notices".
221
+
222
+ c) You must license the entire work, as a whole, under this
223
+ License to anyone who comes into possession of a copy. This
224
+ License will therefore apply, along with any applicable section 7
225
+ additional terms, to the whole of the work, and all its parts,
226
+ regardless of how they are packaged. This License gives no
227
+ permission to license the work in any other way, but it does not
228
+ invalidate such permission if you have separately received it.
229
+
230
+ d) If the work has interactive user interfaces, each must display
231
+ Appropriate Legal Notices; however, if the Program has interactive
232
+ interfaces that do not display Appropriate Legal Notices, your
233
+ work need not make them do so.
234
+
235
+ A compilation of a covered work with other separate and independent
236
+ works, which are not by their nature extensions of the covered work,
237
+ and which are not combined with it such as to form a larger program,
238
+ in or on a volume of a storage or distribution medium, is called an
239
+ "aggregate" if the compilation and its resulting copyright are not
240
+ used to limit the access or legal rights of the compilation's users
241
+ beyond what the individual works permit. Inclusion of a covered work
242
+ in an aggregate does not cause this License to apply to the other
243
+ parts of the aggregate.
244
+
245
+ 6. Conveying Non-Source Forms.
246
+
247
+ You may convey a covered work in object code form under the terms
248
+ of sections 4 and 5, provided that you also convey the
249
+ machine-readable Corresponding Source under the terms of this License,
250
+ in one of these ways:
251
+
252
+ a) Convey the object code in, or embodied in, a physical product
253
+ (including a physical distribution medium), accompanied by the
254
+ Corresponding Source fixed on a durable physical medium
255
+ customarily used for software interchange.
256
+
257
+ b) Convey the object code in, or embodied in, a physical product
258
+ (including a physical distribution medium), accompanied by a
259
+ written offer, valid for at least three years and valid for as
260
+ long as you offer spare parts or customer support for that product
261
+ model, to give anyone who possesses the object code either (1) a
262
+ copy of the Corresponding Source for all the software in the
263
+ product that is covered by this License, on a durable physical
264
+ medium customarily used for software interchange, for a price no
265
+ more than your reasonable cost of physically performing this
266
+ conveying of source, or (2) access to copy the
267
+ Corresponding Source from a network server at no charge.
268
+
269
+ c) Convey individual copies of the object code with a copy of the
270
+ written offer to provide the Corresponding Source. This
271
+ alternative is allowed only occasionally and noncommercially, and
272
+ only if you received the object code with such an offer, in accord
273
+ with subsection 6b.
274
+
275
+ d) Convey the object code by offering access from a designated
276
+ place (gratis or for a charge), and offer equivalent access to the
277
+ Corresponding Source in the same way through the same place at no
278
+ further charge. You need not require recipients to copy the
279
+ Corresponding Source along with the object code. If the place to
280
+ copy the object code is a network server, the Corresponding Source
281
+ may be on a different server (operated by you or a third party)
282
+ that supports equivalent copying facilities, provided you maintain
283
+ clear directions next to the object code saying where to find the
284
+ Corresponding Source. Regardless of what server hosts the
285
+ Corresponding Source, you remain obligated to ensure that it is
286
+ available for as long as needed to satisfy these requirements.
287
+
288
+ e) Convey the object code using peer-to-peer transmission, provided
289
+ you inform other peers where the object code and Corresponding
290
+ Source of the work are being offered to the general public at no
291
+ charge under subsection 6d.
292
+
293
+ A separable portion of the object code, whose source code is excluded
294
+ from the Corresponding Source as a System Library, need not be
295
+ included in conveying the object code work.
296
+
297
+ A "User Product" is either (1) a "consumer product", which means any
298
+ tangible personal property which is normally used for personal, family,
299
+ or household purposes, or (2) anything designed or sold for incorporation
300
+ into a dwelling. In determining whether a product is a consumer product,
301
+ doubtful cases shall be resolved in favor of coverage. For a particular
302
+ product received by a particular user, "normally used" refers to a
303
+ typical or common use of that class of product, regardless of the status
304
+ of the particular user or of the way in which the particular user
305
+ actually uses, or expects or is expected to use, the product. A product
306
+ is a consumer product regardless of whether the product has substantial
307
+ commercial, industrial or non-consumer uses, unless such uses represent
308
+ the only significant mode of use of the product.
309
+
310
+ "Installation Information" for a User Product means any methods,
311
+ procedures, authorization keys, or other information required to install
312
+ and execute modified versions of a covered work in that User Product from
313
+ a modified version of its Corresponding Source. The information must
314
+ suffice to ensure that the continued functioning of the modified object
315
+ code is in no case prevented or interfered with solely because
316
+ modification has been made.
317
+
318
+ If you convey an object code work under this section in, or with, or
319
+ specifically for use in, a User Product, and the conveying occurs as
320
+ part of a transaction in which the right of possession and use of the
321
+ User Product is transferred to the recipient in perpetuity or for a
322
+ fixed term (regardless of how the transaction is characterized), the
323
+ Corresponding Source conveyed under this section must be accompanied
324
+ by the Installation Information. But this requirement does not apply
325
+ if neither you nor any third party retains the ability to install
326
+ modified object code on the User Product (for example, the work has
327
+ been installed in ROM).
328
+
329
+ The requirement to provide Installation Information does not include a
330
+ requirement to continue to provide support service, warranty, or updates
331
+ for a work that has been modified or installed by the recipient, or for
332
+ the User Product in which it has been modified or installed. Access to a
333
+ network may be denied when the modification itself materially and
334
+ adversely affects the operation of the network or violates the rules and
335
+ protocols for communication across the network.
336
+
337
+ Corresponding Source conveyed, and Installation Information provided,
338
+ in accord with this section must be in a format that is publicly
339
+ documented (and with an implementation available to the public in
340
+ source code form), and must require no special password or key for
341
+ unpacking, reading or copying.
342
+
343
+ 7. Additional Terms.
344
+
345
+ "Additional permissions" are terms that supplement the terms of this
346
+ License by making exceptions from one or more of its conditions.
347
+ Additional permissions that are applicable to the entire Program shall
348
+ be treated as though they were included in this License, to the extent
349
+ that they are valid under applicable law. If additional permissions
350
+ apply only to part of the Program, that part may be used separately
351
+ under those permissions, but the entire Program remains governed by
352
+ this License without regard to the additional permissions.
353
+
354
+ When you convey a copy of a covered work, you may at your option
355
+ remove any additional permissions from that copy, or from any part of
356
+ it. (Additional permissions may be written to require their own
357
+ removal in certain cases when you modify the work.) You may place
358
+ additional permissions on material, added by you to a covered work,
359
+ for which you have or can give appropriate copyright permission.
360
+
361
+ Notwithstanding any other provision of this License, for material you
362
+ add to a covered work, you may (if authorized by the copyright holders of
363
+ that material) supplement the terms of this License with terms:
364
+
365
+ a) Disclaiming warranty or limiting liability differently from the
366
+ terms of sections 15 and 16 of this License; or
367
+
368
+ b) Requiring preservation of specified reasonable legal notices or
369
+ author attributions in that material or in the Appropriate Legal
370
+ Notices displayed by works containing it; or
371
+
372
+ c) Prohibiting misrepresentation of the origin of that material, or
373
+ requiring that modified versions of such material be marked in
374
+ reasonable ways as different from the original version; or
375
+
376
+ d) Limiting the use for publicity purposes of names of licensors or
377
+ authors of the material; or
378
+
379
+ e) Declining to grant rights under trademark law for use of some
380
+ trade names, trademarks, or service marks; or
381
+
382
+ f) Requiring indemnification of licensors and authors of that
383
+ material by anyone who conveys the material (or modified versions of
384
+ it) with contractual assumptions of liability to the recipient, for
385
+ any liability that these contractual assumptions directly impose on
386
+ those licensors and authors.
387
+
388
+ All other non-permissive additional terms are considered "further
389
+ restrictions" within the meaning of section 10. If the Program as you
390
+ received it, or any part of it, contains a notice stating that it is
391
+ governed by this License along with a term that is a further
392
+ restriction, you may remove that term. If a license document contains
393
+ a further restriction but permits relicensing or conveying under this
394
+ License, you may add to a covered work material governed by the terms
395
+ of that license document, provided that the further restriction does
396
+ not survive such relicensing or conveying.
397
+
398
+ If you add terms to a covered work in accord with this section, you
399
+ must place, in the relevant source files, a statement of the
400
+ additional terms that apply to those files, or a notice indicating
401
+ where to find the applicable terms.
402
+
403
+ Additional terms, permissive or non-permissive, may be stated in the
404
+ form of a separately written license, or stated as exceptions;
405
+ the above requirements apply either way.
406
+
407
+ 8. Termination.
408
+
409
+ You may not propagate or modify a covered work except as expressly
410
+ provided under this License. Any attempt otherwise to propagate or
411
+ modify it is void, and will automatically terminate your rights under
412
+ this License (including any patent licenses granted under the third
413
+ paragraph of section 11).
414
+
415
+ However, if you cease all violation of this License, then your
416
+ license from a particular copyright holder is reinstated (a)
417
+ provisionally, unless and until the copyright holder explicitly and
418
+ finally terminates your license, and (b) permanently, if the copyright
419
+ holder fails to notify you of the violation by some reasonable means
420
+ prior to 60 days after the cessation.
421
+
422
+ Moreover, your license from a particular copyright holder is
423
+ reinstated permanently if the copyright holder notifies you of the
424
+ violation by some reasonable means, this is the first time you have
425
+ received notice of violation of this License (for any work) from that
426
+ copyright holder, and you cure the violation prior to 30 days after
427
+ your receipt of the notice.
428
+
429
+ Termination of your rights under this section does not terminate the
430
+ licenses of parties who have received copies or rights from you under
431
+ this License. If your rights have been terminated and not permanently
432
+ reinstated, you do not qualify to receive new licenses for the same
433
+ material under section 10.
434
+
435
+ 9. Acceptance Not Required for Having Copies.
436
+
437
+ You are not required to accept this License in order to receive or
438
+ run a copy of the Program. Ancillary propagation of a covered work
439
+ occurring solely as a consequence of using peer-to-peer transmission
440
+ to receive a copy likewise does not require acceptance. However,
441
+ nothing other than this License grants you permission to propagate or
442
+ modify any covered work. These actions infringe copyright if you do
443
+ not accept this License. Therefore, by modifying or propagating a
444
+ covered work, you indicate your acceptance of this License to do so.
445
+
446
+ 10. Automatic Licensing of Downstream Recipients.
447
+
448
+ Each time you convey a covered work, the recipient automatically
449
+ receives a license from the original licensors, to run, modify and
450
+ propagate that work, subject to this License. You are not responsible
451
+ for enforcing compliance by third parties with this License.
452
+
453
+ An "entity transaction" is a transaction transferring control of an
454
+ organization, or substantially all assets of one, or subdividing an
455
+ organization, or merging organizations. If propagation of a covered
456
+ work results from an entity transaction, each party to that
457
+ transaction who receives a copy of the work also receives whatever
458
+ licenses to the work the party's predecessor in interest had or could
459
+ give under the previous paragraph, plus a right to possession of the
460
+ Corresponding Source of the work from the predecessor in interest, if
461
+ the predecessor has it or can get it with reasonable efforts.
462
+
463
+ You may not impose any further restrictions on the exercise of the
464
+ rights granted or affirmed under this License. For example, you may
465
+ not impose a license fee, royalty, or other charge for exercise of
466
+ rights granted under this License, and you may not initiate litigation
467
+ (including a cross-claim or counterclaim in a lawsuit) alleging that
468
+ any patent claim is infringed by making, using, selling, offering for
469
+ sale, or importing the Program or any portion of it.
470
+
471
+ 11. Patents.
472
+
473
+ A "contributor" is a copyright holder who authorizes use under this
474
+ License of the Program or a work on which the Program is based. The
475
+ work thus licensed is called the contributor's "contributor version".
476
+
477
+ A contributor's "essential patent claims" are all patent claims
478
+ owned or controlled by the contributor, whether already acquired or
479
+ hereafter acquired, that would be infringed by some manner, permitted
480
+ by this License, of making, using, or selling its contributor version,
481
+ but do not include claims that would be infringed only as a
482
+ consequence of further modification of the contributor version. For
483
+ purposes of this definition, "control" includes the right to grant
484
+ patent sublicenses in a manner consistent with the requirements of
485
  this License.
486
 
487
+ Each contributor grants you a non-exclusive, worldwide, royalty-free
488
+ patent license under the contributor's essential patent claims, to
489
+ make, use, sell, offer for sale, import and otherwise run, modify and
490
+ propagate the contents of its contributor version.
491
+
492
+ In the following three paragraphs, a "patent license" is any express
493
+ agreement or commitment, however denominated, not to enforce a patent
494
+ (such as an express permission to practice a patent or covenant not to
495
+ sue for patent infringement). To "grant" such a patent license to a
496
+ party means to make such an agreement or commitment not to enforce a
497
+ patent against the party.
498
+
499
+ If you convey a covered work, knowingly relying on a patent license,
500
+ and the Corresponding Source of the work is not available for anyone
501
+ to copy, free of charge and under the terms of this License, through a
502
+ publicly available network server or other readily accessible means,
503
+ then you must either (1) cause the Corresponding Source to be so
504
+ available, or (2) arrange to deprive yourself of the benefit of the
505
+ patent license for this particular work, or (3) arrange, in a manner
506
+ consistent with the requirements of this License, to extend the patent
507
+ license to downstream recipients. "Knowingly relying" means you have
508
+ actual knowledge that, but for the patent license, your conveying the
509
+ covered work in a country, or your recipient's use of the covered work
510
+ in a country, would infringe one or more identifiable patents in that
511
+ country that you have reason to believe are valid.
512
+
513
+ If, pursuant to or in connection with a single transaction or
514
+ arrangement, you convey, or propagate by procuring conveyance of, a
515
+ covered work, and grant a patent license to some of the parties
516
+ receiving the covered work authorizing them to use, propagate, modify
517
+ or convey a specific copy of the covered work, then the patent license
518
+ you grant is automatically extended to all recipients of the covered
519
+ work and works based on it.
520
+
521
+ A patent license is "discriminatory" if it does not include within
522
+ the scope of its coverage, prohibits the exercise of, or is
523
+ conditioned on the non-exercise of one or more of the rights that are
524
+ specifically granted under this License. You may not convey a covered
525
+ work if you are a party to an arrangement with a third party that is
526
+ in the business of distributing software, under which you make payment
527
+ to the third party based on the extent of your activity of conveying
528
+ the work, and under which the third party grants, to any of the
529
+ parties who would receive the covered work from you, a discriminatory
530
+ patent license (a) in connection with copies of the covered work
531
+ conveyed by you (or copies made from those copies), or (b) primarily
532
+ for and in connection with specific products or compilations that
533
+ contain the covered work, unless you entered into that arrangement,
534
+ or that patent license was granted, prior to 28 March 2007.
535
+
536
+ Nothing in this License shall be construed as excluding or limiting
537
+ any implied license or other defenses to infringement that may
538
+ otherwise be available to you under applicable patent law.
539
+
540
+ 12. No Surrender of Others' Freedom.
541
+
542
+ If conditions are imposed on you (whether by court order, agreement or
543
  otherwise) that contradict the conditions of this License, they do not
544
+ excuse you from the conditions of this License. If you cannot convey a
545
+ covered work so as to satisfy simultaneously your obligations under this
546
+ License and any other pertinent obligations, then as a consequence you may
547
+ not convey it at all. For example, if you agree to terms that obligate you
548
+ to collect a royalty for further conveying from those to whom you convey
549
+ the Program, the only way you could satisfy both those terms and this
550
+ License would be to refrain entirely from conveying the Program.
551
+
552
+ 13. Use with the GNU Affero General Public License.
553
+
554
+ Notwithstanding any other provision of this License, you have
555
+ permission to link or combine any covered work with a work licensed
556
+ under version 3 of the GNU Affero General Public License into a single
557
+ combined work, and to convey the resulting work. The terms of this
558
+ License will continue to apply to the part which is the covered work,
559
+ but the special requirements of the GNU Affero General Public License,
560
+ section 13, concerning interaction through a network will apply to the
561
+ combination as such.
562
+
563
+ 14. Revised Versions of this License.
564
+
565
+ The Free Software Foundation may publish revised and/or new versions of
566
+ the GNU General Public License from time to time. Such new versions will
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
567
  be similar in spirit to the present version, but may differ in detail to
568
  address new problems or concerns.
569
 
570
+ Each version is given a distinguishing version number. If the
571
+ Program specifies that a certain numbered version of the GNU General
572
+ Public License "or any later version" applies to it, you have the
573
+ option of following the terms and conditions either of that numbered
574
+ version or of any later version published by the Free Software
575
+ Foundation. If the Program does not specify a version number of the
576
+ GNU General Public License, you may choose any version ever published
577
+ by the Free Software Foundation.
578
+
579
+ If the Program specifies that a proxy can decide which future
580
+ versions of the GNU General Public License can be used, that proxy's
581
+ public statement of acceptance of a version permanently authorizes you
582
+ to choose that version for the Program.
583
+
584
+ Later license versions may give you additional or different
585
+ permissions. However, no additional obligations are imposed on any
586
+ author or copyright holder as a result of your choosing to follow a
587
+ later version.
588
+
589
+ 15. Disclaimer of Warranty.
590
+
591
+ THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
592
+ APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
593
+ HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
594
+ OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
595
+ THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
596
+ PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
597
+ IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
598
+ ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
599
+
600
+ 16. Limitation of Liability.
601
+
602
+ IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
603
+ WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
604
+ THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
605
+ GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
606
+ USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
607
+ DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
608
+ PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
609
+ EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
610
+ SUCH DAMAGES.
611
+
612
+ 17. Interpretation of Sections 15 and 16.
613
+
614
+ If the disclaimer of warranty and limitation of liability provided
615
+ above cannot be given local legal effect according to their terms,
616
+ reviewing courts shall apply local law that most closely approximates
617
+ an absolute waiver of all civil liability in connection with the
618
+ Program, unless a warranty or assumption of liability accompanies a
619
+ copy of the Program in return for a fee.
620
+
621
+ END OF TERMS AND CONDITIONS
622
+
623
+ How to Apply These Terms to Your New Programs
624
+
625
+ If you develop a new program, and you want it to be of the greatest
626
+ possible use to the public, the best way to achieve this is to make it
627
+ free software which everyone can redistribute and change under these terms.
628
+
629
+ To do so, attach the following notices to the program. It is safest
630
+ to attach them to the start of each source file to most effectively
631
+ state the exclusion of warranty; and each file should have at least
632
+ the "copyright" line and a pointer to where the full notice is found.
633
+
634
+ <one line to give the program's name and a brief idea of what it does.>
635
+ Copyright (C) <year> <name of author>
636
+
637
+ This program is free software: you can redistribute it and/or modify
638
+ it under the terms of the GNU General Public License as published by
639
+ the Free Software Foundation, either version 3 of the License, or
640
+ (at your option) any later version.
641
+
642
+ This program is distributed in the hope that it will be useful,
643
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
644
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
645
+ GNU General Public License for more details.
646
+
647
+ You should have received a copy of the GNU General Public License
648
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
649
+
650
+ Also add information on how to contact you by electronic and paper mail.
651
+
652
+ If the program does terminal interaction, make it output a short
653
+ notice like this when it starts in an interactive mode:
654
+
655
+ <program> Copyright (C) <year> <name of author>
656
+ This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
657
+ This is free software, and you are welcome to redistribute it
658
+ under certain conditions; type `show c' for details.
659
+
660
+ The hypothetical commands `show w' and `show c' should show the appropriate
661
+ parts of the General Public License. Of course, your program's commands
662
+ might be different; for a GUI interface, you would use an "about box".
663
+
664
+ You should also get your employer (if you work as a programmer) or school,
665
+ if any, to sign a "copyright disclaimer" for the program, if necessary.
666
+ For more information on this, and how to apply and follow the GNU GPL, see
667
+ <http://www.gnu.org/licenses/>.
668
+
669
+ The GNU General Public License does not permit incorporating your program
670
+ into proprietary programs. If your program is a subroutine library, you
671
+ may consider it more useful to permit linking proprietary applications with
672
+ the library. If this is what you want to do, use the GNU Lesser General
673
+ Public License instead of this License. But first, please read
674
+ <http://www.gnu.org/philosophy/why-not-lgpl.html>.
scripts-n-styles.php CHANGED
@@ -5,8 +5,8 @@ Plugin URI: http://www.unfocus.com/projects/scripts-n-styles/
5
  Description: Allows WordPress admin users the ability to add custom CSS and JavaScript directly to individual Post, Pages or custom post types.
6
  Author: unFocus Projects
7
  Author URI: http://www.unfocus.com/
8
- Version: 3.0.3
9
- License: GPLv2 or later
10
  Text Domain: scripts-n-styles
11
  Network: true
12
  */
@@ -15,7 +15,7 @@ Network: true
15
 
16
  This program is free software; you can redistribute it and/or
17
  modify it under the terms of the GNU General Public License
18
- as published by the Free Software Foundation; either version 2
19
  of the License, or (at your option) any later version.
20
 
21
  This program is distributed in the hope that it will be useful,
@@ -26,6 +26,8 @@ Network: true
26
  You should have received a copy of the GNU General Public License
27
  along with this program; if not, write to the Free Software
28
  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 
 
29
  */
30
 
31
  /**
@@ -47,7 +49,7 @@ Network: true
47
  * @link http://www.unfocus.com/projects/scripts-n-styles/ Plugin URI
48
  * @author unFocus Projects
49
  * @link http://www.unfocus.com/ Author URI
50
- * @version 3.0.3
51
  * @license http://opensource.org/licenses/gpl-license.php GNU Public License
52
  * @copyright Copyright (c) 2010 - 2012, Kenneth Newman
53
  *
@@ -69,17 +71,17 @@ Network: true
69
 
70
  class Scripts_n_Styles
71
  {
72
- /**#@+
73
- * @static
74
- */
75
- const VERSION = '3.0.3';
76
  static $file = __FILE__;
77
- /**#@-*/
78
 
79
- /**
80
  * Initializing method. Checks if is_admin() and registers action hooks for admin if true. Sets filters and actions for Theme side functions.
81
- * @static
82
- */
83
  static function init() {
84
  if ( is_admin() && ! ( defined('DISALLOW_UNFILTERED_HTML') && DISALLOW_UNFILTERED_HTML ) ) {
85
  /* NOTE: Setting the DISALLOW_UNFILTERED_HTML constant to
@@ -98,11 +100,33 @@ class Scripts_n_Styles
98
  add_action( 'wp_enqueue_scripts', array( __CLASS__, 'enqueue_scripts' ), 11 );
99
  add_action( 'wp_head', array( __CLASS__, 'scripts_in_head' ), 11 );
100
  add_action( 'wp_footer', array( __CLASS__, 'scripts' ), 11 );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
101
  }
102
 
103
  /**
104
  * Utility Method
105
- */
106
  static function get_wp_registered() {
107
  return array(
108
  // Starting with the list of Scripts registered by default on the Theme side (index page of twentyten).
@@ -167,18 +191,23 @@ class Scripts_n_Styles
167
  );
168
  }
169
 
170
- /**
171
  * Theme Action: 'wp_head()'
172
  * Outputs the globally and individually set Styles in the Theme's head element.
173
- */
174
  static function styles() {
175
  // Global
176
  $options = get_option( 'SnS_options' );
177
  if ( ! empty( $options ) && ! empty( $options[ 'styles' ] ) ) {
178
- ?><style type="text/css"><?php
179
  echo $options[ 'styles' ];
180
  ?></style><?php
181
  }
 
 
 
 
 
182
 
183
  if ( ! is_singular() ) return;
184
  // Individual
@@ -186,21 +215,21 @@ class Scripts_n_Styles
186
  $SnS = get_post_meta( $post->ID, '_SnS', true );
187
  $styles = isset( $SnS['styles'] ) ? $SnS[ 'styles' ]: array();
188
  if ( ! empty( $styles ) && ! empty( $styles[ 'styles' ] ) ) {
189
- ?><style type="text/css"><?php
190
  echo $styles[ 'styles' ];
191
  ?></style><?php
192
  }
193
  }
194
 
195
- /**
196
  * Theme Action: 'wp_footer()'
197
  * Outputs the globally and individually set Scripts at the end of the Theme's body element.
198
- */
199
  static function scripts() {
200
  // Global
201
  $options = get_option( 'SnS_options' );
202
  if ( ! empty( $options ) && ! empty( $options[ 'scripts' ] ) ) {
203
- ?><script type="text/javascript"><?php
204
  echo $options[ 'scripts' ];
205
  ?></script><?php
206
  }
@@ -211,21 +240,21 @@ class Scripts_n_Styles
211
  $SnS = get_post_meta( $post->ID, '_SnS', true );
212
  $scripts = isset( $SnS['scripts'] ) ? $SnS[ 'scripts' ]: array();
213
  if ( ! empty( $scripts ) && ! empty( $scripts[ 'scripts' ] ) ) {
214
- ?><script type="text/javascript"><?php
215
  echo $scripts[ 'scripts' ];
216
  ?></script><?php
217
  }
218
  }
219
 
220
- /**
221
  * Theme Action: 'wp_head()'
222
  * Outputs the globally and individually set Scripts in the Theme's head element.
223
- */
224
  static function scripts_in_head() {
225
  // Global
226
  $options = get_option( 'SnS_options' );
227
  if ( ! empty( $options ) && ! empty( $options[ 'scripts_in_head' ] ) ) {
228
- ?><script type="text/javascript"><?php
229
  echo $options[ 'scripts_in_head' ];
230
  ?></script><?php
231
  }
@@ -236,19 +265,19 @@ class Scripts_n_Styles
236
  $SnS = get_post_meta( $post->ID, '_SnS', true );
237
  $scripts = isset( $SnS['scripts'] ) ? $SnS[ 'scripts' ]: array();
238
  if ( ! empty( $scripts ) && ! empty( $scripts[ 'scripts_in_head' ] ) ) {
239
- ?><script type="text/javascript"><?php
240
  echo $scripts[ 'scripts_in_head' ];
241
  ?></script><?php
242
  }
243
  }
244
 
245
- /**
246
  * Theme Filter: 'body_class()'
247
  * Adds classes to the Theme's body tag.
248
  * @uses self::get_styles()
249
  * @param array $classes
250
  * @return array $classes
251
- */
252
  static function body_classes( $classes ) {
253
  if ( ! is_singular() || is_admin() ) return $classes;
254
 
@@ -261,12 +290,12 @@ class Scripts_n_Styles
261
  return $classes;
262
  }
263
 
264
- /**
265
  * Theme Filter: 'post_class()'
266
  * Adds classes to the Theme's post container.
267
  * @param array $classes
268
  * @return array $classes
269
- */
270
  static function post_classes( $classes ) {
271
  if ( ! is_singular() || is_admin() ) return $classes;
272
 
@@ -280,10 +309,10 @@ class Scripts_n_Styles
280
  return $classes;
281
  }
282
 
283
- /**
284
  * Theme Action: 'wp_enqueue_scripts'
285
  * Enqueues chosen Scripts.
286
- */
287
  static function enqueue_scripts() {
288
  // Global
289
  $options = get_option( 'SnS_options' );
@@ -307,9 +336,9 @@ class Scripts_n_Styles
307
  }
308
  }
309
 
310
- /**
311
  * Utility Method: Compares VERSION to stored 'version' value.
312
- */
313
  static function upgrade_check() {
314
  $options = get_option( 'SnS_options' );
315
  if ( ! isset( $options[ 'version' ] ) || version_compare( self::VERSION, $options[ 'version' ], '>' ) ) {
5
  Description: Allows WordPress admin users the ability to add custom CSS and JavaScript directly to individual Post, Pages or custom post types.
6
  Author: unFocus Projects
7
  Author URI: http://www.unfocus.com/
8
+ Version: 3.1
9
+ License: GPLv3 or later
10
  Text Domain: scripts-n-styles
11
  Network: true
12
  */
15
 
16
  This program is free software; you can redistribute it and/or
17
  modify it under the terms of the GNU General Public License
18
+ as published by the Free Software Foundation; either version 3
19
  of the License, or (at your option) any later version.
20
 
21
  This program is distributed in the hope that it will be useful,
26
  You should have received a copy of the GNU General Public License
27
  along with this program; if not, write to the Free Software
28
  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
29
+
30
+ This file incorporates work covered by other licenses and permissions.
31
  */
32
 
33
  /**
49
  * @link http://www.unfocus.com/projects/scripts-n-styles/ Plugin URI
50
  * @author unFocus Projects
51
  * @link http://www.unfocus.com/ Author URI
52
+ * @version 3.1
53
  * @license http://opensource.org/licenses/gpl-license.php GNU Public License
54
  * @copyright Copyright (c) 2010 - 2012, Kenneth Newman
55
  *
71
 
72
  class Scripts_n_Styles
73
  {
74
+ /**#@+
75
+ * @static
76
+ */
77
+ const VERSION = '3.1';
78
  static $file = __FILE__;
79
+ /**#@-*/
80
 
81
+ /**
82
  * Initializing method. Checks if is_admin() and registers action hooks for admin if true. Sets filters and actions for Theme side functions.
83
+ * @static
84
+ */
85
  static function init() {
86
  if ( is_admin() && ! ( defined('DISALLOW_UNFILTERED_HTML') && DISALLOW_UNFILTERED_HTML ) ) {
87
  /* NOTE: Setting the DISALLOW_UNFILTERED_HTML constant to
100
  add_action( 'wp_enqueue_scripts', array( __CLASS__, 'enqueue_scripts' ), 11 );
101
  add_action( 'wp_head', array( __CLASS__, 'scripts_in_head' ), 11 );
102
  add_action( 'wp_footer', array( __CLASS__, 'scripts' ), 11 );
103
+
104
+ add_shortcode( 'sns_shortcode', array( __CLASS__, 'shortcode' ) );
105
+ }
106
+
107
+ function shortcode( $atts, $content = null, $tag ) {
108
+ global $post;
109
+
110
+ if ( isset( $post->ID ) ) $id = $post->ID;
111
+ else $id = get_the_ID();
112
+ if ( ! $id ) return '<pre>There was an error.</pre>';
113
+
114
+ extract( shortcode_atts( array( 'name' => 0, ), $atts ) );
115
+ $output = '';
116
+
117
+ $SnS = get_post_meta( $post->ID, '_SnS', true );
118
+ $shortcodes = isset( $SnS['shortcodes'] ) ? $SnS[ 'shortcodes' ]: array();
119
+ if ( isset( $shortcodes[ $name ] ) )
120
+ $output .= $shortcodes[ $name ];
121
+ if ( isset( $content ) && empty( $output ) ) $output = $content;
122
+ $output = do_shortcode( $output );
123
+
124
+ return $output;
125
  }
126
 
127
  /**
128
  * Utility Method
129
+ */
130
  static function get_wp_registered() {
131
  return array(
132
  // Starting with the list of Scripts registered by default on the Theme side (index page of twentyten).
191
  );
192
  }
193
 
194
+ /**
195
  * Theme Action: 'wp_head()'
196
  * Outputs the globally and individually set Styles in the Theme's head element.
197
+ */
198
  static function styles() {
199
  // Global
200
  $options = get_option( 'SnS_options' );
201
  if ( ! empty( $options ) && ! empty( $options[ 'styles' ] ) ) {
202
+ ?><style type="text/css" id="sns_global_styles"><?php
203
  echo $options[ 'styles' ];
204
  ?></style><?php
205
  }
206
+ if ( ! empty( $options ) && ! empty( $options[ 'compiled' ] ) ) {
207
+ ?><style type="text/css" id="sns_global_less_compiled"><?php
208
+ echo $options[ 'compiled' ];
209
+ ?></style><?php
210
+ }
211
 
212
  if ( ! is_singular() ) return;
213
  // Individual
215
  $SnS = get_post_meta( $post->ID, '_SnS', true );
216
  $styles = isset( $SnS['styles'] ) ? $SnS[ 'styles' ]: array();
217
  if ( ! empty( $styles ) && ! empty( $styles[ 'styles' ] ) ) {
218
+ ?><style type="text/css" id="sns_styles"><?php
219
  echo $styles[ 'styles' ];
220
  ?></style><?php
221
  }
222
  }
223
 
224
+ /**
225
  * Theme Action: 'wp_footer()'
226
  * Outputs the globally and individually set Scripts at the end of the Theme's body element.
227
+ */
228
  static function scripts() {
229
  // Global
230
  $options = get_option( 'SnS_options' );
231
  if ( ! empty( $options ) && ! empty( $options[ 'scripts' ] ) ) {
232
+ ?><script type="text/javascript" id="sns_global_scripts"><?php
233
  echo $options[ 'scripts' ];
234
  ?></script><?php
235
  }
240
  $SnS = get_post_meta( $post->ID, '_SnS', true );
241
  $scripts = isset( $SnS['scripts'] ) ? $SnS[ 'scripts' ]: array();
242
  if ( ! empty( $scripts ) && ! empty( $scripts[ 'scripts' ] ) ) {
243
+ ?><script type="text/javascript" id="sns_scripts"><?php
244
  echo $scripts[ 'scripts' ];
245
  ?></script><?php
246
  }
247
  }
248
 
249
+ /**
250
  * Theme Action: 'wp_head()'
251
  * Outputs the globally and individually set Scripts in the Theme's head element.
252
+ */
253
  static function scripts_in_head() {
254
  // Global
255
  $options = get_option( 'SnS_options' );
256
  if ( ! empty( $options ) && ! empty( $options[ 'scripts_in_head' ] ) ) {
257
+ ?><script type="text/javascript" id="sns_global_scripts_in_head"><?php
258
  echo $options[ 'scripts_in_head' ];
259
  ?></script><?php
260
  }
265
  $SnS = get_post_meta( $post->ID, '_SnS', true );
266
  $scripts = isset( $SnS['scripts'] ) ? $SnS[ 'scripts' ]: array();
267
  if ( ! empty( $scripts ) && ! empty( $scripts[ 'scripts_in_head' ] ) ) {
268
+ ?><script type="text/javascript" id="sns_scripts_in_head"><?php
269
  echo $scripts[ 'scripts_in_head' ];
270
  ?></script><?php
271
  }
272
  }
273
 
274
+ /**
275
  * Theme Filter: 'body_class()'
276
  * Adds classes to the Theme's body tag.
277
  * @uses self::get_styles()
278
  * @param array $classes
279
  * @return array $classes
280
+ */
281
  static function body_classes( $classes ) {
282
  if ( ! is_singular() || is_admin() ) return $classes;
283
 
290
  return $classes;
291
  }
292
 
293
+ /**
294
  * Theme Filter: 'post_class()'
295
  * Adds classes to the Theme's post container.
296
  * @param array $classes
297
  * @return array $classes
298
+ */
299
  static function post_classes( $classes ) {
300
  if ( ! is_singular() || is_admin() ) return $classes;
301
 
309
  return $classes;
310
  }
311
 
312
+ /**
313
  * Theme Action: 'wp_enqueue_scripts'
314
  * Enqueues chosen Scripts.
315
+ */
316
  static function enqueue_scripts() {
317
  // Global
318
  $options = get_option( 'SnS_options' );
336
  }
337
  }
338
 
339
+ /**
340
  * Utility Method: Compares VERSION to stored 'version' value.
341
+ */
342
  static function upgrade_check() {
343
  $options = get_option( 'SnS_options' );
344
  if ( ! isset( $options[ 'version' ] ) || version_compare( self::VERSION, $options[ 'version' ], '>' ) ) {