puffer_pages 0.0.14 → 0.0.15

Sign up to get free protection for your applications and to get access to all the features.
Files changed (107) hide show
  1. data/Gemfile +11 -7
  2. data/Gemfile.lock +130 -114
  3. data/Guardfile +20 -0
  4. data/README.md +3 -3
  5. data/VERSION +1 -1
  6. data/app/assets/javascripts/puffer/codemirror-base.js +1 -0
  7. data/app/assets/javascripts/puffer/codemirror-parser.js +1 -0
  8. data/app/assets/javascripts/puffer/codemirror.js +1 -0
  9. data/{spec/dummy/public/puffer/javascripts → app/assets/javascripts/puffer}/puffer_pages.js +11 -0
  10. data/{lib/generators/puffer_pages/install/templates/puffer/javascripts → app/assets/javascripts/puffer}/right-dialog.js +0 -0
  11. data/{lib/generators/puffer_pages/install/templates/puffer/javascripts → app/assets/javascripts/puffer}/right-tabs.js +0 -0
  12. data/app/assets/stylesheets/codemirror.css +135 -0
  13. data/app/assets/stylesheets/puffer_pages.css +12 -0
  14. data/{lib/generators/puffer_pages/install/templates/puffer → app/assets}/stylesheets/puffer_tree.css +0 -0
  15. data/{lib/generators/puffer_pages/install/templates/controllers → app/controllers/admin}/layouts_controller.rb +0 -0
  16. data/{lib/generators/puffer_pages/install/templates/controllers → app/controllers/admin}/pages_controller.rb +0 -0
  17. data/{lib/generators/puffer_pages/install/templates/controllers → app/controllers/admin}/snippets_controller.rb +0 -0
  18. data/app/controllers/pages_controller.rb +2 -2
  19. data/app/controllers/puffer_pages/layouts_controller.rb +2 -2
  20. data/app/controllers/puffer_pages/pages_controller.rb +1 -2
  21. data/app/controllers/puffer_pages/snippets_controller.rb +2 -2
  22. data/app/helpers/puffer_pages_helper.rb +1 -1
  23. data/app/models/layout.rb +1 -5
  24. data/app/models/page.rb +1 -105
  25. data/app/models/page_part.rb +1 -20
  26. data/app/models/puffer_pages/layout.rb +8 -0
  27. data/app/models/puffer_pages/page.rb +107 -0
  28. data/app/models/puffer_pages/page_part.rb +23 -0
  29. data/app/models/puffer_pages/snippet.rb +6 -0
  30. data/app/models/snippet.rb +1 -3
  31. data/app/views/{puffer_tree → puffer/tree_base}/_record.html.erb +0 -0
  32. data/app/views/{puffer_tree → puffer/tree_base}/toggle.js.erb +0 -0
  33. data/app/views/{puffer_tree → puffer/tree_base}/tree.html.erb +0 -0
  34. data/app/views/puffer_pages/{_page_part_builder.html.erb → pages/_page_part_builder.html.erb} +1 -1
  35. data/app/views/puffer_pages/{_page_parts.html.erb → pages/_page_parts.html.erb} +0 -0
  36. data/app/views/puffer_pages/{_tree_page.html.erb → pages/_tree_page.html.erb} +0 -0
  37. data/config/locales/en.yml +3 -1
  38. data/{lib/generators/puffer_pages/install/templates → db}/migrate/20090422092419_create_pages.rb +0 -0
  39. data/{lib/generators/puffer_pages/install/templates → db}/migrate/20090504132337_create_page_parts.rb +0 -0
  40. data/{lib/generators/puffer_pages/install/templates → db}/migrate/20090506102004_create_layouts.rb +0 -0
  41. data/{lib/generators/puffer_pages/install/templates → db}/migrate/20090510121824_create_snippets.rb +0 -0
  42. data/lib/puffer/inputs/page_parts.rb +0 -1
  43. data/lib/puffer/inputs/page_parts_body.rb +0 -1
  44. data/lib/puffer/tree_base.rb +1 -2
  45. data/lib/puffer_pages/engine.rb +0 -4
  46. data/lib/puffer_pages/liquid/file_system.rb +7 -3
  47. data/lib/puffer_pages/liquid/page_drop.rb +13 -6
  48. data/lib/puffer_pages.rb +0 -5
  49. data/puffer_pages.gemspec +63 -107
  50. data/spec/dummy/Rakefile +1 -1
  51. data/spec/dummy/app/assets/images/rails.png +0 -0
  52. data/spec/dummy/app/assets/javascripts/application.js +9 -0
  53. data/spec/dummy/app/assets/stylesheets/application.css +7 -0
  54. data/spec/dummy/app/controllers/puffer/dashboard_controller.rb +1 -1
  55. data/spec/dummy/app/controllers/puffer/sessions_controller.rb +1 -1
  56. data/spec/dummy/app/views/layouts/application.html.erb +3 -3
  57. data/spec/dummy/config/application.rb +4 -8
  58. data/spec/dummy/config/application.rb.orig +43 -0
  59. data/spec/dummy/config/boot.rb +5 -7
  60. data/spec/dummy/config/boot.rb.orig +6 -0
  61. data/spec/dummy/config/environments/development.rb +4 -3
  62. data/spec/dummy/config/environments/pg_test.rb +5 -1
  63. data/spec/dummy/config/environments/production.rb +14 -12
  64. data/spec/dummy/config/environments/test.rb +5 -1
  65. data/spec/dummy/config/initializers/secret_token.rb +1 -1
  66. data/spec/dummy/config/initializers/session_store.rb +1 -1
  67. data/spec/dummy/config/initializers/wrap_parameters.rb +12 -0
  68. data/spec/dummy/config/locales/en.yml +1 -1
  69. data/spec/dummy/config/routes.rb +3 -1
  70. data/spec/dummy/config/routes.rb.orig +58 -0
  71. data/spec/dummy/db/seeds.rb +7 -0
  72. data/spec/dummy/public/robots.txt +5 -0
  73. data/spec/fabricators/pages_fabricator.rb +1 -0
  74. data/spec/lib/core_spec.rb +1 -1
  75. data/spec/lib/drops_spec.rb +13 -8
  76. data/spec/models/page_spec.rb +4 -3
  77. data/spec/spec_helper.rb +14 -1
  78. metadata +200 -288
  79. data/autotest/discover.rb +0 -2
  80. data/lib/generators/puffer_pages/install/USAGE +0 -6
  81. data/lib/generators/puffer_pages/install/install_generator.rb +0 -24
  82. data/lib/generators/puffer_pages/install/templates/puffer/javascripts/puffer_pages.js +0 -35
  83. data/lib/generators/puffer_pages/install/templates/puffer/stylesheets/puffer_pages.css +0 -4
  84. data/lib/generators/puffer_pages/install/templates/puffer_pages.rb +0 -16
  85. data/spec/dummy/app/controllers/admin/layouts_controller.rb +0 -3
  86. data/spec/dummy/app/controllers/admin/pages_controller.rb +0 -3
  87. data/spec/dummy/app/controllers/admin/snippets_controller.rb +0 -3
  88. data/spec/dummy/config/initializers/puffer.rb +0 -12
  89. data/spec/dummy/config/initializers/puffer_pages.rb +0 -16
  90. data/spec/dummy/public/javascripts/application.js +0 -2
  91. data/spec/dummy/public/javascripts/controls.js +0 -965
  92. data/spec/dummy/public/javascripts/dragdrop.js +0 -974
  93. data/spec/dummy/public/javascripts/effects.js +0 -1123
  94. data/spec/dummy/public/javascripts/prototype.js +0 -6001
  95. data/spec/dummy/public/javascripts/rails.js +0 -175
  96. data/spec/dummy/public/puffer/javascripts/puffer.js +0 -10
  97. data/spec/dummy/public/puffer/javascripts/rails.js +0 -57
  98. data/spec/dummy/public/puffer/javascripts/right-autocompleter.js +0 -621
  99. data/spec/dummy/public/puffer/javascripts/right-calendar.js +0 -1461
  100. data/spec/dummy/public/puffer/javascripts/right-dialog.js +0 -764
  101. data/spec/dummy/public/puffer/javascripts/right-tabs.js +0 -1144
  102. data/spec/dummy/public/puffer/javascripts/right.js +0 -5892
  103. data/spec/dummy/public/puffer/stylesheets/puffer.css +0 -469
  104. data/spec/dummy/public/puffer/stylesheets/puffer_pages.css +0 -4
  105. data/spec/dummy/public/puffer/stylesheets/puffer_tree.css +0 -64
  106. data/spec/dummy/public/puffer/stylesheets/reset.css +0 -60
  107. data/spec/dummy/public/stylesheets/.gitkeep +0 -0
data/Gemfile CHANGED
@@ -1,21 +1,25 @@
1
1
  source "http://rubygems.org"
2
2
 
3
- gem 'rails'
3
+ gem 'rails', '>= 3.1.0.rc4'
4
+ gem 'puffer', :git => 'git://github.com/puffer/puffer.git'
4
5
  gem 'liquid', :git => 'git://github.com/puffer/liquid.git'
5
- gem 'nested_set', :git => 'git://github.com/pyromaniac/nested_set.git'
6
- gem 'puffer', '>= 0.0.17'
6
+ gem 'nested_set'
7
7
 
8
8
  group :development, :test, :pg_test do
9
- gem "capybara", ">= 0.4.0"
10
9
  gem "sqlite3-ruby", :require => "sqlite3"
11
10
  gem "pg"
12
11
  gem "mysql"
13
12
 
14
13
  gem "rspec-rails"
15
- gem "autotest"
14
+ gem "capybara", ">= 0.4.0"
15
+ gem 'database_cleaner'
16
+
17
+ gem 'guard'
18
+ gem 'libnotify'
19
+ gem 'guard-rspec'
20
+
16
21
  gem 'forgery'
17
- gem 'fabrication', '0.9.2'
22
+ gem 'fabrication'
18
23
  gem "jeweler"
19
- gem "mongrel"
20
24
  end
21
25
 
data/Gemfile.lock CHANGED
@@ -1,168 +1,184 @@
1
1
  GIT
2
2
  remote: git://github.com/puffer/liquid.git
3
- revision: 18ddffc9c4be25dadf9ec55dc5664a454ae3d072
3
+ revision: 3885290fefa0e6f92cfd812455a7cbd8eee9871b
4
4
  specs:
5
5
  liquid (2.2.2)
6
6
 
7
7
  GIT
8
- remote: git://github.com/pyromaniac/nested_set.git
9
- revision: 32c0d948cfccdb81324bc127daa3c5077d89be22
8
+ remote: git://github.com/puffer/puffer.git
9
+ revision: 64792e0691ee4c9031028eaac84dbb15a5db9e17
10
10
  specs:
11
- nested_set (1.6.4)
12
- activerecord (>= 3.0.0)
13
- railties (>= 3.0.0)
11
+ puffer (0.0.20)
12
+ apotomo
13
+ kaminari
14
+ rails (>= 3.1.0.rc4)
14
15
 
15
16
  GEM
16
17
  remote: http://rubygems.org/
17
18
  specs:
18
- ZenTest (4.5.0)
19
- abstract (1.0.0)
20
- actionmailer (3.0.5)
21
- actionpack (= 3.0.5)
22
- mail (~> 2.2.15)
23
- actionpack (3.0.5)
24
- activemodel (= 3.0.5)
25
- activesupport (= 3.0.5)
26
- builder (~> 2.1.2)
27
- erubis (~> 2.6.6)
28
- i18n (~> 0.4)
29
- rack (~> 1.2.1)
30
- rack-mount (~> 0.6.13)
31
- rack-test (~> 0.5.7)
32
- tzinfo (~> 0.3.23)
33
- activemodel (3.0.5)
34
- activesupport (= 3.0.5)
35
- builder (~> 2.1.2)
36
- i18n (~> 0.4)
37
- activerecord (3.0.5)
38
- activemodel (= 3.0.5)
39
- activesupport (= 3.0.5)
40
- arel (~> 2.0.2)
41
- tzinfo (~> 0.3.23)
42
- activeresource (3.0.5)
43
- activemodel (= 3.0.5)
44
- activesupport (= 3.0.5)
45
- activesupport (3.0.5)
46
- arel (2.0.9)
47
- autotest (4.4.6)
48
- ZenTest (>= 4.4.1)
49
- builder (2.1.2)
50
- capybara (0.4.1.2)
51
- celerity (>= 0.7.9)
52
- culerity (>= 0.2.4)
19
+ actionmailer (3.1.0.rc5)
20
+ actionpack (= 3.1.0.rc5)
21
+ mail (~> 2.3.0)
22
+ actionpack (3.1.0.rc5)
23
+ activemodel (= 3.1.0.rc5)
24
+ activesupport (= 3.1.0.rc5)
25
+ builder (~> 3.0.0)
26
+ erubis (~> 2.7.0)
27
+ i18n (~> 0.6)
28
+ rack (~> 1.3.1)
29
+ rack-cache (~> 1.0.2)
30
+ rack-mount (~> 0.8.1)
31
+ rack-test (~> 0.6.0)
32
+ sprockets (~> 2.0.0.beta.12)
33
+ activemodel (3.1.0.rc5)
34
+ activesupport (= 3.1.0.rc5)
35
+ bcrypt-ruby (~> 2.1.4)
36
+ builder (~> 3.0.0)
37
+ i18n (~> 0.6)
38
+ activerecord (3.1.0.rc5)
39
+ activemodel (= 3.1.0.rc5)
40
+ activesupport (= 3.1.0.rc5)
41
+ arel (~> 2.1.4)
42
+ tzinfo (~> 0.3.29)
43
+ activeresource (3.1.0.rc5)
44
+ activemodel (= 3.1.0.rc5)
45
+ activesupport (= 3.1.0.rc5)
46
+ activesupport (3.1.0.rc5)
47
+ multi_json (~> 1.0)
48
+ apotomo (1.1.2)
49
+ cells (>= 3.5.6)
50
+ hooks (~> 0.1.3)
51
+ onfire (~> 0.2.0)
52
+ arel (2.1.4)
53
+ bcrypt-ruby (2.1.4)
54
+ builder (3.0.0)
55
+ capybara (1.0.0)
53
56
  mime-types (>= 1.16)
54
57
  nokogiri (>= 1.3.3)
55
58
  rack (>= 1.0.0)
56
59
  rack-test (>= 0.5.4)
57
- selenium-webdriver (>= 0.0.27)
58
- xpath (~> 0.1.3)
59
- celerity (0.8.8)
60
- cells (3.4.4)
61
- cgi_multipart_eof_fix (2.5.0)
62
- childprocess (0.1.7)
63
- ffi (~> 0.6.3)
64
- culerity (0.2.15)
65
- daemons (1.1.0)
60
+ selenium-webdriver (~> 0.2.0)
61
+ xpath (~> 0.1.4)
62
+ cells (3.6.4)
63
+ actionpack (~> 3.0)
64
+ railties (~> 3.0)
65
+ childprocess (0.2.0)
66
+ ffi (~> 1.0.6)
67
+ database_cleaner (0.6.7)
66
68
  diff-lcs (1.1.2)
67
- erubis (2.6.6)
68
- abstract (>= 1.0.0)
69
- fabrication (0.9.2)
70
- fastthread (1.0.7)
71
- ffi (0.6.3)
72
- rake (>= 0.8.7)
73
- forgery (0.3.7)
69
+ erubis (2.7.0)
70
+ fabrication (1.0.1)
71
+ ffi (1.0.9)
72
+ forgery (0.3.12)
74
73
  nokogiri (~> 1.4)
75
- gem_plugin (0.2.3)
76
74
  git (1.2.5)
77
- i18n (0.5.0)
78
- jeweler (1.5.2)
79
- bundler (~> 1.0.0)
75
+ guard (0.5.1)
76
+ thor (~> 0.14.6)
77
+ guard-rspec (0.4.0)
78
+ guard (>= 0.4.0)
79
+ hike (1.2.0)
80
+ hooks (0.1.4)
81
+ i18n (0.6.0)
82
+ jeweler (1.6.4)
83
+ bundler (~> 1.0)
80
84
  git (>= 1.2.5)
81
85
  rake
82
- json_pure (1.5.1)
83
- mail (2.2.15)
84
- activesupport (>= 2.3.6)
86
+ json_pure (1.5.3)
87
+ kaminari (0.12.4)
88
+ rails (>= 3.0.0)
89
+ libnotify (0.5.7)
90
+ mail (2.3.0)
85
91
  i18n (>= 0.4.0)
86
92
  mime-types (~> 1.16)
87
93
  treetop (~> 1.4.8)
88
94
  mime-types (1.16)
89
- mongrel (1.1.5)
90
- cgi_multipart_eof_fix (>= 2.4)
91
- daemons (>= 1.0.3)
92
- fastthread (>= 1.0.1)
93
- gem_plugin (>= 0.2.3)
95
+ multi_json (1.0.3)
94
96
  mysql (2.8.1)
95
- nokogiri (1.4.4)
96
- pg (0.10.1)
97
- polyglot (0.3.1)
98
- puffer (0.0.19)
99
- cells (~> 3.4.4)
100
- rails (~> 3.0.4)
101
- will_paginate (~> 3.0.pre2)
102
- rack (1.2.1)
103
- rack-mount (0.6.13)
97
+ nested_set (1.6.7)
98
+ activerecord (>= 3.0.0)
99
+ railties (>= 3.0.0)
100
+ nokogiri (1.5.0)
101
+ onfire (0.2.0)
102
+ pg (0.11.0)
103
+ polyglot (0.3.2)
104
+ rack (1.3.2)
105
+ rack-cache (1.0.2)
106
+ rack (>= 0.4)
107
+ rack-mount (0.8.1)
104
108
  rack (>= 1.0.0)
105
- rack-test (0.5.7)
109
+ rack-ssl (1.3.2)
110
+ rack
111
+ rack-test (0.6.1)
106
112
  rack (>= 1.0)
107
- rails (3.0.5)
108
- actionmailer (= 3.0.5)
109
- actionpack (= 3.0.5)
110
- activerecord (= 3.0.5)
111
- activeresource (= 3.0.5)
112
- activesupport (= 3.0.5)
113
+ rails (3.1.0.rc5)
114
+ actionmailer (= 3.1.0.rc5)
115
+ actionpack (= 3.1.0.rc5)
116
+ activerecord (= 3.1.0.rc5)
117
+ activeresource (= 3.1.0.rc5)
118
+ activesupport (= 3.1.0.rc5)
113
119
  bundler (~> 1.0)
114
- railties (= 3.0.5)
115
- railties (3.0.5)
116
- actionpack (= 3.0.5)
117
- activesupport (= 3.0.5)
120
+ railties (= 3.1.0.rc5)
121
+ railties (3.1.0.rc5)
122
+ actionpack (= 3.1.0.rc5)
123
+ activesupport (= 3.1.0.rc5)
124
+ rack-ssl (~> 1.3.2)
118
125
  rake (>= 0.8.7)
119
- thor (~> 0.14.4)
120
- rake (0.8.7)
121
- rspec (2.5.0)
122
- rspec-core (~> 2.5.0)
123
- rspec-expectations (~> 2.5.0)
124
- rspec-mocks (~> 2.5.0)
125
- rspec-core (2.5.1)
126
- rspec-expectations (2.5.0)
126
+ rdoc (~> 3.4)
127
+ thor (~> 0.14.6)
128
+ rake (0.9.2)
129
+ rdoc (3.8)
130
+ rspec (2.6.0)
131
+ rspec-core (~> 2.6.0)
132
+ rspec-expectations (~> 2.6.0)
133
+ rspec-mocks (~> 2.6.0)
134
+ rspec-core (2.6.4)
135
+ rspec-expectations (2.6.0)
127
136
  diff-lcs (~> 1.1.2)
128
- rspec-mocks (2.5.0)
129
- rspec-rails (2.5.0)
137
+ rspec-mocks (2.6.0)
138
+ rspec-rails (2.6.1)
130
139
  actionpack (~> 3.0)
131
140
  activesupport (~> 3.0)
132
141
  railties (~> 3.0)
133
- rspec (~> 2.5.0)
142
+ rspec (~> 2.6.0)
134
143
  rubyzip (0.9.4)
135
- selenium-webdriver (0.1.3)
136
- childprocess (~> 0.1.5)
137
- ffi (~> 0.6.3)
144
+ selenium-webdriver (0.2.2)
145
+ childprocess (>= 0.1.9)
146
+ ffi (>= 1.0.7)
138
147
  json_pure
139
148
  rubyzip
140
- sqlite3 (1.3.3)
149
+ sprockets (2.0.0.beta.12)
150
+ hike (~> 1.2)
151
+ rack (~> 1.0)
152
+ tilt (!= 1.3.0, ~> 1.1)
153
+ sqlite3 (1.3.4)
141
154
  sqlite3-ruby (1.3.3)
142
155
  sqlite3 (>= 1.3.3)
143
156
  thor (0.14.6)
144
- treetop (1.4.9)
157
+ tilt (1.3.2)
158
+ treetop (1.4.10)
159
+ polyglot
145
160
  polyglot (>= 0.3.1)
146
- tzinfo (0.3.24)
147
- will_paginate (3.0.pre2)
148
- xpath (0.1.3)
161
+ tzinfo (0.3.29)
162
+ xpath (0.1.4)
149
163
  nokogiri (~> 1.3)
150
164
 
151
165
  PLATFORMS
152
166
  ruby
153
167
 
154
168
  DEPENDENCIES
155
- autotest
156
169
  capybara (>= 0.4.0)
157
- fabrication (= 0.9.2)
170
+ database_cleaner
171
+ fabrication
158
172
  forgery
173
+ guard
174
+ guard-rspec
159
175
  jeweler
176
+ libnotify
160
177
  liquid!
161
- mongrel
162
178
  mysql
163
- nested_set!
179
+ nested_set
164
180
  pg
165
- puffer (>= 0.0.17)
166
- rails
181
+ puffer!
182
+ rails (>= 3.1.0.rc4)
167
183
  rspec-rails
168
184
  sqlite3-ruby
data/Guardfile ADDED
@@ -0,0 +1,20 @@
1
+ # A sample Guardfile
2
+ # More info at https://github.com/guard/guard#readme
3
+
4
+ guard 'rspec', :version => 2 do
5
+ watch(%r{^spec/.+_spec\.rb$})
6
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
7
+ watch('spec/spec_helper.rb') { "spec" }
8
+
9
+ # Rails example
10
+ watch(%r{^spec/.+_spec\.rb$})
11
+ watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
12
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
13
+ watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb"] }
14
+ watch(%r{^spec/support/(.+)\.rb$}) { "spec" }
15
+ watch('spec/spec_helper.rb') { "spec" }
16
+ watch('config/routes.rb') { "spec/routing" }
17
+ watch('app/controllers/application_controller.rb') { "spec/controllers" }
18
+ # Capybara request specs
19
+ watch(%r{^app/views/(.+)/.*\.(erb|haml)$}) { |m| "spec/requests/#{m[1]}_spec.rb" }
20
+ end
data/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
  <pre>gem 'liquid', :git => 'git://github.com/puffer/liquid.git'</pre>
3
3
  I hope, it's temporarly
4
4
 
5
- # Puffer_pages is lightweight rails 3 CMS
5
+ # Puffer_pages is lightweight rails 3.1 CMS
6
6
 
7
7
  Interface of pages based on [puffer](https://github.com/puffer/puffer)
8
8
 
@@ -22,11 +22,11 @@ Or in Gemfile:
22
22
  Did you install [puffer](https://github.com/puffer/puffer) properly?
23
23
 
24
24
  Next step is:
25
- <pre>rails g puffer_pages:install</pre>
25
+ <pre>rake puffer_pages_engine:install:migrations</pre>
26
26
  This will install puffer_pages config file in your initializers, some css/js, controllers and migrations
27
27
  <pre>rake db:migrate</pre>
28
28
 
29
- To start working with admin interface, you need to have some routes like:
29
+ To start working with admin interface, you need to add some routes like:
30
30
  <pre>
31
31
  namespace :admin do
32
32
  resources :pages
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.14
1
+ 0.0.15
@@ -0,0 +1 @@
1
+ function tokenizer(a,b){function c(a){return a!="\n"&&/^[\s\u00a0]*$/.test(a)}var d={state:b,take:function(b){typeof b=="string"&&(b={style:b,type:b}),b.content=(b.content||"")+a.get(),/\n$/.test(b.content)||a.nextWhile(c),b.value=b.content+a.get();return b},next:function(){if(!a.more())throw StopIteration;var b;if(a.equals("\n")){a.next();return this.take("whitespace")}if(a.applies(c))b="whitespace";else while(!b)b=this.state(a,function(a){d.state=a});return this.take(b)}};return d}function asEditorLines(a){var b=makeWhiteSpace(indentUnit);return map(a.replace(/\t/g,b).replace(/\u00a0/g," ").replace(/\r\n?/g,"\n").split("\n"),fixSpaces)}function alwaysZero(){return 0}function makePartSpan(a){var b=a;a.nodeType==3?b=a.nodeValue:a=document.createTextNode(b);var c=document.createElement("span");c.isPart=!0,c.appendChild(a),c.currentText=b;return c}function cleanText(a){return a.replace(/\u00a0/g," ").replace(/\u200b/g,"")}function fixSpaces(a){a.charAt(0)==" "&&(a=nbsp+a.slice(1));return a.replace(/\t/g,function(){return makeWhiteSpace(indentUnit)}).replace(/[ \u00a0]{2,}/g,function(a){return makeWhiteSpace(a.length)})}function makeWhiteSpace(a){var b=[],c=!0;for(;a>0;a--)b.push(c||a==1?nbsp:" "),c^=!0;return b.join("")}function UndoHistory(a,b,c,d){this.container=a,this.maxDepth=b,this.commitDelay=c,this.editor=d;var e={text:"",from:null,to:null};this.first=e,this.last=e,this.firstTouched=!1,this.history=[],this.redoHistory=[],this.touched=[],this.lostundo=0}function isSpan(a){var b=a.nodeName;return b=="SPAN"||b=="span"}function isBR(a){var b=a.nodeName;return b=="BR"||b=="br"}function nodeTop(a){var b=0;while(a.offsetParent)b+=a.offsetTop,a=a.offsetParent;return b}function nodeText(a){return a.textContent||a.innerText||a.nodeValue||""}function addEventHandler(a,b,c,d){function e(a){c(normalizeEvent(a||window.event))}if(typeof a.addEventListener=="function"){a.addEventListener(b,e,!1);if(d)return function(){a.removeEventListener(b,e,!1)}}else{a.attachEvent("on"+b,e);if(d)return function(){a.detachEvent("on"+b,e)}}}function normalizeEvent(a){a.stopPropagation||(a.stopPropagation=function(){this.cancelBubble=!0},a.preventDefault=function(){this.returnValue=!1}),a.stop||(a.stop=function(){this.stopPropagation(),this.preventDefault()}),a.type=="keypress"&&(a.code=a.charCode==null?a.keyCode:a.charCode,a.character=String.fromCharCode(a.code));return a}function isAncestor(a,b){while(b=b.parentNode)if(a==b)return!0;return!1}function clearElement(a){while(a.firstChild)a.removeChild(a.firstChild)}function removeElement(a){a.parentNode&&a.parentNode.removeChild(a)}function insertAfter(a,b){var c=b.parentNode;c.insertBefore(a,b.nextSibling);return a}function removeClass(a,b){a.className=a.className.replace(new RegExp(" "+b+"\\b","g"),"");return a}function hasClass(a,b){var c=a.className;return c&&(new RegExp("(^| )"+b+"($| )")).test(c)}function matcher(a){return function(b){return a.test(b)}}function map(a,b){var c=[];forEach(a,function(a){c.push(b(a))});return c}function forEach(a,b){if(a.next)try{for(;;)b(a.next())}catch(c){if(c!=StopIteration)throw c}else for(var d=0;d<a.length;d++)b(a[d])}function method(a,b){return function(){a[b].apply(a,arguments)}}var StopIteration={toString:function(){return"StopIteration"}},nbsp=" ",matching={"{":"}","[":"]","(":")","}":"{","]":"[",")":"("},stringStream=function(a){function e(){while(c==b.length){d+=b,b="",c=0;try{b=a.next()}catch(e){if(e!=StopIteration)throw e;return!1}}return!0}var b="",c=0,d="";return{peek:function(){if(!e())return null;return b.charAt(c)},next:function(){if(!e())throw d.length>0?"End of stringstream reached without emptying buffer ('"+d+"').":StopIteration;return b.charAt(c++)},get:function(){var a=d;d="",c>0&&(a+=b.slice(0,c),b=b.slice(c),c=0);return a},push:function(a){b=b.slice(0,c)+a+b.slice(c)},lookAhead:function(e,f,g,h){function i(a){return h?a.toLowerCase():a}e=i(e);var j=!1,k=d,l=c;g&&this.nextWhileMatches(/[\s\u00a0]/);for(;;){var m=c+e.length,n=b.length-c;if(m<=b.length){j=e==i(b.slice(c,m)),c=m;break}if(e.slice(0,n)!=i(b.slice(c)))break;d+=b,b="";try{b=a.next()}catch(o){if(o!=StopIteration)throw o;break}c=0,e=e.slice(n)}if(!j||!f)b=d.slice(k.length)+b,c=l,d=k;return j},lookAheadRegex:function(d,e){if(d.source.charAt(0)!="^")throw new Error("Regexps passed to lookAheadRegex must start with ^");while(b.indexOf("\n",c)==-1)try{b+=a.next()}catch(f){if(f!=StopIteration)throw f;break}var g=b.slice(c).match(d);g&&e&&(c+=g[0].length);return g},more:function(){return this.peek()!==null},applies:function(a){var b=this.peek();return b!==null&&a(b)},nextWhile:function(a){var b;while((b=this.peek())!==null&&a(b))this.next()},matches:function(a){var b=this.peek();return b!==null&&a.test(b)},nextWhileMatches:function(a){var b;while((b=this.peek())!==null&&a.test(b))this.next()},equals:function(a){return a===this.peek()},endOfLine:function(){var a=this.peek();return a==null||a=="\n"}}},select={};(function(){function e(a){var b=a.nextSibling;if(b){while(b.firstChild)b=b.firstChild;return b.nodeType==3||isBR(b)?b:e(b)}var c=a.parentNode;while(c&&!c.nextSibling)c=c.parentNode;return c&&e(c)}function b(b,c){while(!b.previousSibling&&b.parentNode!=c)b=b.parentNode;return a(b.previousSibling,c)}function a(a,b){while(a&&a.parentNode!=b)a=a.parentNode;return a}select.ie_selection=document.selection&&document.selection.createRangeCollection;var c="    ";select.scrollToNode=function(a,b){if(!!a){var c=a,d=document.body,e=document.documentElement,f=!c.nextSibling||!c.nextSibling.nextSibling||!c.nextSibling.nextSibling.nextSibling,g=0;while(c&&!c.offsetTop)g++,c=c.previousSibling;g==0&&(f=!1);if(webkit&&c&&c.offsetTop==5&&c.offsetLeft==5)return;var h=g*(c?c.offsetHeight:0),i=0,j=a?a.offsetWidth:0,k=c;while(k&&k.offsetParent)h+=k.offsetTop,isBR(k)||(i+=k.offsetLeft),k=k.offsetParent;var l=d.scrollLeft||e.scrollLeft||0,m=d.scrollTop||e.scrollTop||0,n=!1,o=window.innerWidth||e.clientWidth||0;if(b||j<o){if(b){var p=select.offsetInNode(a),q=nodeText(a).length;q&&(i+=j*(p/q))}var r=i-l;if(r<0||r>o)l=i,n=!0}var s=h-m;if(s<0||f||s>(window.innerHeight||e.clientHeight||0)-50)m=f?1e6:h,n=!0;n&&window.scrollTo(l,m)}},select.scrollToCursor=function(a){select.scrollToNode(select.selectionTopNode(a,!0)||a.firstChild,!0)};var d=null;select.snapshotChanged=function(){d&&(d.changed=!0)},select.snapshotReplaceNode=function(a,b,c,f){function g(g){a==g.node?(d.changed=!0,c&&g.offset>c?g.offset-=c:(g.node=b,g.offset+=f||0)):select.ie_selection&&g.offset==0&&g.node==e(a)&&(d.changed=!0)}!d||(g(d.start),g(d.end))},select.snapshotMove=function(a,b,c,e,f){function g(g){a==g.node&&(!f||g.offset==0)&&(d.changed=!0,g.node=b,e?g.offset=Math.max(0,g.offset+c):g.offset=c)}!d||(g(d.start),g(d.end))};if(select.ie_selection){function f(){var a=document.selection;if(!a)return null;return a.createRange?a.createRange():a.createTextRange()}function g(a){function d(a){while(a&&a.firstChild)a=a.firstChild;return{node:a,offset:0}}function c(a){var b=null;while(!b&&a)b=a.nextSibling,a=a.parentNode;return d(b)}var b=f();b.collapse(a);var e=b.parentElement();if(!isAncestor(document.body,e))return null;if(!e.firstChild)return d(e);var g=b.duplicate();g.moveToElementText(e),g.collapse(!0);for(var h=e.firstChild;h;h=h.nextSibling){if(h.nodeType==3){var i=h.nodeValue.length;g.move("character",i)}else g.moveToElementText(h),g.collapse(!1);var j=b.compareEndPoints("StartToStart",g);if(j==0)return c(h);if(j==1)continue;if(h.nodeType!=3)return d(h);g.setEndPoint("StartToEnd",b);return{node:h,offset:i-g.text.length}}return c(e)}select.markSelection=function(){d=null;var a=document.selection;if(!!a){var b=g(!0),c=g(!1);if(!b||!c)return;d={start:b,end:c,changed:!1}}},select.selectMarked=function(){function a(a){var b=document.body.createTextRange(),c=a.node;if(!c)b.moveToElementText(document.body),b.collapse(!1);else if(c.nodeType==3){b.moveToElementText(c.parentNode);var d=a.offset;while(c.previousSibling)c=c.previousSibling,d+=(c.innerText||"").length;b.move("character",d)}else b.moveToElementText(c),b.collapse(!0);return b}if(!!d&&!!d.changed){var b=a(d.start),c=a(d.end);b.setEndPoint("StartToEnd",c),b.select()}},select.offsetInNode=function(a){var b=f();if(!b)return 0;var c=b.duplicate();try{c.moveToElementText(a)}catch(d){return 0}b.setEndPoint("StartToStart",c);return b.text.length},select.selectionTopNode=function(b,c){function h(a,b){if(b.nodeType==3){var c=0,d=b.previousSibling;while(d&&d.nodeType==3)c+=d.nodeValue.length,d=d.previousSibling;if(d){try{a.moveToElementText(d)}catch(e){return!1}a.collapse(!1)}else a.moveToElementText(b.parentNode);c&&a.move("character",c)}else try{a.moveToElementText(b)}catch(e){return!1}return!0}var d=f();if(!d)return!1;var e=d.duplicate();d.collapse(c);var g=d.parentElement();if(g&&isAncestor(b,g)){e.moveToElementText(g);if(d.compareEndPoints("StartToStart",e)==1)return a(g,b)}var c=0,i=b.childNodes.length-1;while(c<i){var j=Math.ceil((i+c)/2),k=b.childNodes[j];if(!k)return!1;if(!h(e,k))return!1;d.compareEndPoints("StartToStart",e)==1?c=j:i=j-1}if(c==0){var l=f(),m=l.duplicate();try{m.moveToElementText(b)}catch(n){return null}if(l.compareEndPoints("StartToStart",m)==0)return null}return b.childNodes[c]||null},select.focusAfterNode=function(a,b){var c=document.body.createTextRange();c.moveToElementText(a||b),c.collapse(!a),c.select()},select.somethingSelected=function(){var a=f();return a&&a.text!=""};function h(a){var b=f();b&&(b.pasteHTML(a),b.collapse(!1),b.select())}select.insertNewlineAtCursor=function(){h("<br>")},select.insertTabAtCursor=function(){h(c)},select.cursorPos=function(a,b){var c=f();if(!c)return null;var d=select.selectionTopNode(a,b);while(d&&!isBR(d))d=d.previousSibling;var e=c.duplicate();c.collapse(b);if(d)e.moveToElementText(d),e.collapse(!1);else{try{e.moveToElementText(a)}catch(g){return null}e.collapse(!0)}c.setEndPoint("StartToStart",e);return{node:d,offset:c.text.length}},select.setCursorPos=function(a,b,c){function d(b){var c=document.body.createTextRange();b.node?(c.moveToElementText(b.node),c.collapse(!1)):(c.moveToElementText(a),c.collapse(!0)),c.move("character",b.offset);return c}var e=d(b);c&&c!=b&&e.setEndPoint("EndToEnd",d(c)),e.select()},select.getBookmark=function(a){var b=select.cursorPos(a,!0),c=select.cursorPos(a,!1);if(b&&c)return{from:b,to:c}},select.setBookmark=function(a,b){!b||select.setCursorPos(a,b.from,b.to)}}else{function i(a,b){while(a.nodeType!=3&&!isBR(a)){var c=a.childNodes[b]||a.nextSibling;b=0;while(!c&&a.parentNode)a=a.parentNode,c=a.nextSibling;a=c;if(!c)break}return{node:a,offset:b}}select.markSelection=function(){var a=window.getSelection();if(!a||a.rangeCount==0)return d=null;var b=a.getRangeAt(0);d={start:i(b.startContainer,b.startOffset),end:i(b.endContainer,b.endOffset),changed:!1}},select.selectMarked=function(){function e(a,b){a.node?a.offset==0?c["set"+b+"Before"](a.node):c["set"+b](a.node,a.offset):c.setStartAfter(document.body.lastChild||document.body)}function b(){if(a.start.node==a.end.node&&a.start.offset==a.end.offset){var b=window.getSelection();if(!b||b.rangeCount==0)return!0;var c=b.getRangeAt(0),d=i(c.startContainer,c.startOffset);return a.start.node!=d.node||a.start.offset!=d.offset}}var a=d;if(!!a&&!!(a.changed||webkit&&b())){var c=document.createRange();e(a.end,"End"),e(a.start,"Start"),j(c)}};function j(a){var b=window.getSelection();!b||(b.removeAllRanges(),b.addRange(a))}function k(){var a=window.getSelection();return!a||a.rangeCount==0?!1:a.getRangeAt(0)}select.selectionTopNode=function(c,d){var e=k();if(!e)return!1;var f=d?e.startContainer:e.endContainer,g=d?e.startOffset:e.endOffset;window.opera&&!d&&e.endContainer==c&&e.endOffset==e.startOffset+1&&c.childNodes[e.startOffset]&&isBR(c.childNodes[e.startOffset])&&g--;return f.nodeType==3?g>0?a(f,c):b(f,c):f.nodeName.toUpperCase()=="HTML"?g==1?null:c.lastChild:f==c?g==0?null:f.childNodes[g-1]:g==f.childNodes.length?a(f,c):g==0?b(f,c):a(f.childNodes[g-1],c)},select.focusAfterNode=function(a,b){var c=document.createRange();c.setStartBefore(b.firstChild||b),a&&!a.firstChild?c.setEndAfter(a):a?c.setEnd(a,a.childNodes.length):c.setEndBefore(b.firstChild||b),c.collapse(!1),j(c)},select.somethingSelected=function(){var a=k();return a&&!a.collapsed},select.offsetInNode=function(a){var b=k();if(!b)return 0;b=b.cloneRange(),b.setStartBefore(a);return b.toString().length},select.insertNodeAtCursor=function(a){var b=k();if(!!b){b.deleteContents(),b.insertNode(a),webkitLastLineHack(document.body);if(window.opera&&isBR(a)&&isSpan(a.parentNode)){var c=a.nextSibling,d=a.parentNode,e=d.parentNode;e.insertBefore(a,d.nextSibling);var f="";for(;c&&c.nodeType==3;c=c.nextSibling)f+=c.nodeValue,removeElement(c);e.insertBefore(makePartSpan(f,document),a.nextSibling)}b=document.createRange(),b.selectNode(a),b.collapse(!1),j(b)}},select.insertNewlineAtCursor=function(){select.insertNodeAtCursor(document.createElement("BR"))},select.insertTabAtCursor=function(){select.insertNodeAtCursor(document.createTextNode(c))},select.cursorPos=function(a,b){var c=k();if(!!c){var d=select.selectionTopNode(a,b);while(d&&!isBR(d))d=d.previousSibling;c=c.cloneRange(),c.collapse(b),d?c.setStartAfter(d):c.setStartBefore(a);var e=c.toString();return{node:d,offset:e.length}}},select.setCursorPos=function(a,b,c){function e(b,c,e){function g(a){a.nodeType==3?f.push(a):forEach(a.childNodes,g)}if(c==0&&b&&!b.nextSibling){d["set"+e+"After"](b);return!0}b?b=b.nextSibling:b=a.firstChild;if(!!b){if(c==0){d["set"+e+"Before"](b);return!0}var f=[];for(;;){while(b&&!f.length)g(b),b=b.nextSibling;var h=f.shift();if(!h)return!1;var i=h.nodeValue.length;if(i>=c){d["set"+e](h,c);return!0}c-=i}}}var d=document.createRange();c=c||b,e(c.node,c.offset,"End")&&e(b.node,b.offset,"Start")&&j(d)}}})(),UndoHistory.prototype={scheduleCommit:function(){var a=this;parent.clearTimeout(this.commitTimeout),this.commitTimeout=parent.setTimeout(function(){a.tryCommit()},this.commitDelay)},touch:function(a){this.setTouched(a),this.scheduleCommit()},undo:function(){this.commit();if(this.history.length){var a=this.history.pop();this.redoHistory.push(this.updateTo(a,"applyChain")),this.notifyEnvironment();return this.chainNode(a)}},redo:function(){this.commit();if(this.redoHistory.length){var a=this.redoHistory.pop();this.addUndoLevel(this.updateTo(a,"applyChain")),this.notifyEnvironment();return this.chainNode(a)}},clear:function(){this.history=[],this.redoHistory=[],this.lostundo=0},historySize:function(){return{undo:this.history.length,redo:this.redoHistory.length,lostundo:this.lostundo}},push:function(a,b,c){var d=[];for(var e=0;e<c.length;e++){var f=e==c.length-1?b:document.createElement("br");d.push({from:a,to:f,text:cleanText(c[e])}),a=f}this.pushChains([d],a==null&&b==null),this.notifyEnvironment()},pushChains:function(a,b){this.commit(b),this.addUndoLevel(this.updateTo(a,"applyChain")),this.redoHistory=[]},chainNode:function(a){for(var b=0;b<a.length;b++){var c=a[b][0],d=c&&(c.from||c.to);if(d)return d}},reset:function(){this.history=[],this.redoHistory=[],this.lostundo=0},textAfter:function(a){return this.after(a).text},nodeAfter:function(a){return this.after(a).to},nodeBefore:function(a){return this.before(a).from},tryCommit:function(){!window||!window.parent||!window.UndoHistory||(this.editor.highlightDirty()?this.commit(!0):this.scheduleCommit())},commit:function(a){parent.clearTimeout(this.commitTimeout),a||this.editor.highlightDirty(!0);var b=this.touchedChains(),c=this;b.length&&(this.addUndoLevel(this.updateTo(b,"linkChain")),this.redoHistory=[],this.notifyEnvironment())},updateTo:function(a,b){var c=[],d=[];for(var e=0;e<a.length;e++)c.push(this.shadowChain(a[e])),d.push(this[b](a[e]));b=="applyChain"&&this.notifyDirty(d);return c},notifyDirty:function(a){forEach(a,method(this.editor,"addDirtyNode")),this.editor.scheduleHighlight()},notifyEnvironment:function(){this.onChange&&this.onChange(this.editor),window.frameElement&&window.frameElement.CodeMirror.updateNumbers&&window.frameElement.CodeMirror.updateNumbers()},linkChain:function(a){for(var b=0;b<a.length;b++){var c=a[b];c.from?c.from.historyAfter=c:this.first=c,c.to?c.to.historyBefore=c:this.last=c}},after:function(a){return a?a.historyAfter:this.first},before:function(a){return a?a.historyBefore:this.last},setTouched:function(a){a?a.historyTouched||(this.touched.push(a),a.historyTouched=!0):this.firstTouched=!0},addUndoLevel:function(a){this.history.push(a),this.history.length>this.maxDepth&&(this.history.shift(),this.lostundo+=1)},touchedChains:function(){function g(a,b){var c=b+"Sibling",d=a[c];while(d&&!isBR(d))d=d[c];return d}function e(b){var c=[];for(var d=b?b.nextSibling:a.container.firstChild;d&&(!isBR(d)||d.hackBR);d=d.nextSibling)!d.hackBR&&d.currentText&&c.push(d.currentText);return{from:b,to:d,text:cleanText(c.join(""))}}function d(a,c){a?a.historyTemp=c:b=c}function c(a){return a?a.historyTemp:b}var a=this,b=null,f=[];a.firstTouched&&a.touched.push(null),forEach(a.touched,function(b){if(!b||b.parentNode==a.container&&!b.hackBR){b?b.historyTouched=!1:a.firstTouched=!1;var c=e(b),g=a.after(b);if(!g||g.text!=c.text||g.to!=c.to)f.push(c),d(b,c)}});var h=[];a.touched=[],forEach(f,function(b){if(!!c(b.from)){var f=[],i=b.from,j=!0;for(;;){var k=c(i);if(!k){if(j)break;k=e(i)}f.unshift(k),d(i,null);if(!i)break;j=a.after(i),i=g(i,"previous")}i=b.to,j=a.before(b.from);for(;;){if(!i)break;var k=c(i);if(!k){if(j)break;k=e(i)}f.push(k),d(i,null),j=a.before(i),i=g(i,"next")}h.push(f)}});return h},shadowChain:function(a){var b=[],c=this.after(a[0].from),d=a[a.length-1].to;for(;;){b.push(c);var e=c.to;if(!e||e==d)break;c=e.historyAfter||this.before(d)}return b},applyChain:function(a){function d(a,b){var d=a?a.nextSibling:c.container.firstChild;while(d!=b){var e=d.nextSibling;removeElement(d),d=e}}var b=select.cursorPos(this.container,!1),c=this,e=a[0].from,f=a[a.length-1].to;d(e,f);for(var g=0;g<a.length;g++){var h=a[g];g>0&&c.container.insertBefore(h.from,f);var i=makePartSpan(fixSpaces(h.text));c.container.insertBefore(i,f);if(b&&b.node==h.from){var j=0,k=this.after(h.from);if(k&&g==a.length-1){for(var l=0;l<b.offset&&h.text.charAt(l)==k.text.charAt(l);l++);b.offset>l&&(j=h.text.length-k.text.length)}select.setCursorPos(this.container,{node:h.from,offset:Math.max(0,b.offset+j)})}else b&&g==a.length-1&&b.node&&b.node.parentNode!=this.container&&select.setCursorPos(this.container,{node:h.from,offset:h.text.length})}this.linkChain(a);return e}};var internetExplorer=document.selection&&window.ActiveXObject&&/MSIE/.test(navigator.userAgent),webkit=/AppleWebKit/.test(navigator.userAgent),safari=/Apple Computer, Inc/.test(navigator.vendor),gecko=navigator.userAgent.match(/gecko\/(\d{8})/i);gecko&&(gecko=Number(gecko[1]));var mac=/Mac/.test(navigator.platform),brokenOpera=window.opera&&/Version\/10.[56]/.test(navigator.userAgent),slowWebkit=/AppleWebKit\/533/.test(navigator.userAgent),webkitLastLineHack=webkit?function(a){var b=a.lastChild;if(!b||!b.hackBR){var c=document.createElement("br");c.hackBR=!0,a.appendChild(c)}}:function(){},Editor=function(){function j(a){return a>=16&&a<=18||a>=33&&a<=40}function i(a){this.options=a,window.indentUnit=a.indentUnit;var b=this.container=document.body;this.history=new UndoHistory(b,a.undoDepth,a.undoDelay,this);var c=this;if(!i.Parser)throw"No parser loaded.";a.parserConfig&&i.Parser.configure&&i.Parser.configure(a.parserConfig),!a.readOnly&&!internetExplorer&&select.setCursorPos(b,{node:null,offset:0}),this.dirty=[],this.importCode(a.content||""),this.history.onChange=a.onChange;if(!a.readOnly){a.continuousScanning!==!1&&(this.scanner=this.documentScanner(a.passTime),this.delayScanning());function d(){document.body.contentEditable!=undefined&&internetExplorer?document.body.contentEditable="true":document.designMode="on",internetExplorer&&a.height!="dynamic"&&(document.body.style.minHeight=window.frameElement.clientHeight-2*document.body.offsetTop-5+"px"),document.documentElement.style.borderWidth="0",a.textWrapping||(b.style.whiteSpace="nowrap")}try{d()}catch(e){var f=addEventHandler(document,"focus",function(){f(),d()},!0)}addEventHandler(document,"keydown",method(this,"keyDown")),addEventHandler(document,"keypress",method(this,"keyPress")),addEventHandler(document,"keyup",method(this,"keyUp"));function g(){c.cursorActivity(!1)}addEventHandler(internetExplorer?document.body:window,"mouseup",g),addEventHandler(document.body,"cut",g),gecko&&addEventHandler(window,"pagehide",function(){c.unloaded=!0}),addEventHandler(document.body,"paste",function(a){g();var b=null;try{var d=a.clipboardData||window.clipboardData;d&&(b=d.getData("Text"))}catch(e){}b!==null&&(a.stop(),c.replaceSelection(b),select.scrollToCursor(c.container))}),this.options.autoMatchParens&&addEventHandler(document.body,"click",method(this,"scheduleParenHighlight"))}else a.textWrapping||(b.style.whiteSpace="nowrap")}function h(a,b,c,d){function e(b){var c=cleanText(a.history.textAfter(b));return d?c.toLowerCase():c}this.editor=a,this.history=a.history,this.history.commit(),this.valid=!!b,this.atOccurrence=!1,d==undefined&&(d=typeof b=="string"&&b==b.toLowerCase());var f={node:null,offset:0},g=this;if(c&&typeof c=="object"&&typeof c.character=="number"){a.checkLine(c.line);var h={node:c.line,offset:c.character};this.pos={from:h,to:h}}else c?this.pos={from:select.cursorPos(a.container,!0)||f,to:select.cursorPos(a.container,!1)||f}:this.pos={from:f,to:f};if(typeof b!="string")this.matches=function(a,c,d){if(a){var f=e(c).slice(0,d),h=f.match(b),i=0;while(h){var j=f.indexOf(h[0]);i+=j,f=f.slice(j+1);var k=f.match(b);if(k)h=k;else break}}else var f=e(c).slice(d),h=f.match(b),i=h&&d+f.indexOf(h[0]);if(h){g.currentMatch=h;return{from:{node:c,offset:i},to:{node:c,offset:i+h[0].length}}}};else{d&&(b=b.toLowerCase());var i=b.split("\n");this.matches=i.length==1?function(a,c,d){var f=e(c),g=b.length,h;if(a?d>=g&&(h=f.lastIndexOf(b,d-g))!=-1:(h=f.indexOf(b,d))!=-1)return{from:{node:c,offset:h},to:{node:c,offset:h+g}}}:function(a,b,c){var d=a?i.length-1:0,f=i[d],g=e(b),h=a?g.indexOf(f)+f.length:g.lastIndexOf(f);if(!(a?h>=c||h!=f.length:h<=c||h!=g.length-f.length)){var j=b;for(;;){if(a&&!j)return;j=a?this.history.nodeBefore(j):this.history.nodeAfter(j);if(!a&&!j)return;g=e(j),f=i[a?--d:++d];if(d>0&&d<i.length-1){if(g!=f)return;continue}var k=a?g.lastIndexOf(f):g.indexOf(f)+f.length;if(a?k!=g.length-f.length:k!=f.length)return;return{from:{node:a?j:b,offset:a?k:h},to:{node:a?b:j,offset:a?h:k}}}}}}}function g(){return(new Date).getTime()}function f(a,b){a?isBR(a)&&(a=a.nextSibling):a=b.firstChild;while(a&&!isBR(a))a=a.nextSibling;return a}function e(a){while(a&&!isBR(a))a=a.previousSibling;return a}function d(a){return isBR(a)?1:a.currentText.length}function c(a){function j(){if(!a)throw StopIteration;var b=a;a=b.nextSibling;if(i(b)){c.push(b),f=!1;return b.currentText}if(isBR(b)){f&&window.opera&&b.parentNode.insertBefore(makePartSpan(""),b),c.push(b),f=!0;return"\n"}var g=!b.nextSibling;e=d(b),removeElement(b);return h(b,g)}function i(a){if(a.isPart&&a.childNodes.length==1&&a.firstChild.nodeType==3){var b=a.firstChild.nodeValue;a.dirty=a.dirty||b!=a.currentText,a.currentText=b;return!/[\n\t\r]/.test(a.currentText)}return!1}function h(a,c){var d=b(a,c);for(var e=0;e<d.length;e++)d[e]=g(d[e]);return d.join("")}function g(a){var b="\n";a.nodeType==3?(select.snapshotChanged(),a=makePartSpan(a),b=a.currentText,f=!1):(f&&window.opera&&e(makePartSpan("")),f=!0),a.dirty=!0,c.push(a),e(a);return b}function d(a){var b=a.parentNode,c=a.nextSibling;return function(a){b.insertBefore(a,c)}}var c=[],e=null,f=!0;return{next:j,nodes:c}}function b(b,c){function f(b,g){if(b.nodeType==3){var h=b.nodeValue=fixSpaces(b.nodeValue.replace(/[\r\u200b]/g,"").replace(/\n/g," "));h.length&&(e=!1),d.push(b)}else if(isBR(b)&&b.childNodes.length==0)e=!0,d.push(b);else{for(var i=b.firstChild;i;i=i.nextSibling)f(i);!e&&a.hasOwnProperty(b.nodeName.toUpperCase())&&(e=!0,(!c||!g)&&d.push(document.createElement("br")))}}var d=[],e=!0;f(b,!0);return d}var a={P:!0,DIV:!0,LI:!0};h.prototype={findNext:function(){return this.find(!1)},findPrevious:function(){return this.find(!0)},find:function(a){function f(){var a={node:d,offset:e};b.pos={from:a,to:a},b.atOccurrence=!1;return!1}if(!this.valid)return!1;var b=this,c=a?this.pos.from:this.pos.to,d=c.node,e=c.offset;d&&!d.parentNode&&(d=null,e=0);for(;;){if(this.pos=this.matches(a,d,e)){this.atOccurrence=!0;return!0}if(a){if(!d)return f();d=this.history.nodeBefore(d),e=this.history.textAfter(d).length}else{var g=this.history.nodeAfter(d);if(!g){e=this.history.textAfter(d).length;return f()}d=g,e=0}}},select:function(){this.atOccurrence&&(select.setCursorPos(this.editor.container,this.pos.from,this.pos.to),select.scrollToCursor(this.editor.container))},replace:function(a){if(this.atOccurrence){var b=this.currentMatch;b&&(a=a.replace(/\\(\d)/,function(a,c){return b[c]}));var c=this.editor.replaceRange(this.pos.from,this.pos.to,a);this.pos.to=c,this.atOccurrence=!1}},position:function(){if(this.atOccurrence)return{line:this.pos.from.node,character:this.pos.from.offset}}},i.prototype={importCode:function(a){var b=asEditorLines(a),c=1e3;if(!this.options.incrementalLoading||b.length<c)this.history.push(null,null,b),this.history.reset();else{var d=0,e=this;function f(){var a=b.slice(d,d+c);a.push(""),e.history.push(e.history.nodeBefore(null),null,a),e.history.reset(),d+=c,d<b.length&&parent.setTimeout(f,1e3)}f()}},getCode:function(){if(!this.container.firstChild)return"";var a=[];select.markSelection(),forEach(c(this.container.firstChild),method(a,"push")),select.selectMarked(),webkit&&this.container.lastChild.hackBR&&a.pop(),webkitLastLineHack(this.container);return cleanText(a.join(""))},checkLine:function(a){if(a===!1||a!=null&&a.parentNode!=this.container&&!a.hackBR)throw parent.CodeMirror.InvalidLineHandle},cursorPosition:function(a){a==null&&(a=!0);var b=select.cursorPos(this.container,a);return b?{line:b.node,character:b.offset}:{line:null,character:0}},firstLine:function(){return null},lastLine:function(){var a=this.container.lastChild;a&&(a=e(a)),a&&a.hackBR&&(a=e(a.previousSibling));return a},nextLine:function(a){this.checkLine(a);var b=f(a,this.container);return!b||b.hackBR?!1:b},prevLine:function(a){this.checkLine(a);if(a==null)return!1;return e(a.previousSibling)},visibleLineCount:function(){var a=this.container.firstChild;while(a&&isBR(a))a=a.nextSibling;if(!a)return!1;var b=window.innerHeight||document.documentElement.clientHeight||document.body.clientHeight;return Math.floor(b/a.offsetHeight)},selectLines:function(a,b,c,d){this.checkLine(a);var e={node:a,offset:b},f=null;d!==undefined&&(this.checkLine(c),f={node:c,offset:d}),select.setCursorPos(this.container,e,f),select.scrollToCursor(this.container)},lineContent:function(a){var b=[];for(a=a?a.nextSibling:this.container.firstChild;a&&!isBR(a);a=a.nextSibling)b.push(nodeText(a));return cleanText(b.join(""))},setLineContent:function(a,b){this.history.commit(),this.replaceRange({node:a,offset:0},{node:a,offset:this.history.textAfter(a).length},b),this.addDirtyNode(a),this.scheduleHighlight()},removeLine:function(a){var b=a?a.nextSibling:this.container.firstChild;while(b){var c=b.nextSibling;removeElement(b);if(isBR(b))break;b=c}this.addDirtyNode(a),this.scheduleHighlight()},insertIntoLine:function(a,b,c){var d=null;if(b=="end")d=f(a,this.container);else for(var e=a?a.nextSibling:this.container.firstChild;e;e=e.nextSibling){if(b==0){d=e;break}var g=nodeText(e);if(g.length>b){d=e.nextSibling,c=g.slice(0,b)+c+g.slice(b),removeElement(e);break}b-=g.length}var h=asEditorLines(c);for(var i=0;i<h.length;i++)i>0&&this.container.insertBefore(document.createElement("BR"),d),this.container.insertBefore(makePartSpan(h[i]),d);this.addDirtyNode(a),this.scheduleHighlight()},selectedText:function(){var a=this.history;a.commit();var b=select.cursorPos(this.container,!0),c=select.cursorPos(this.container,!1);if(!b||!c)return"";if(b.node==c.node)return a.textAfter(b.node).slice(b.offset,c.offset);var d=[a.textAfter(b.node).slice(b.offset)];for(var e=a.nodeAfter(b.node);e!=c.node;e=a.nodeAfter(e))d.push(a.textAfter(e));d.push(a.textAfter(c.node).slice(0,c.offset));return cleanText(d.join("\n"))},replaceSelection:function(a){this.history.commit();var b=select.cursorPos(this.container,!0),c=select.cursorPos(this.container,!1);!!b&&!!c&&(c=this.replaceRange(b,c,a),select.setCursorPos(this.container,c),webkitLastLineHack(this.container))},cursorCoords:function(a,b){function h(a,b){var c=document.createElement("SPAN");c.appendChild(document.createTextNode(a));try{return b(c)}finally{c.parentNode&&c.parentNode.removeChild(c)}}function g(a,c){var d=-(document.body.scrollTop||document.documentElement.scrollTop||0),e=-(document.body.scrollLeft||document.documentElement.scrollLeft||0)+c;forEach([a,b?null:window.frameElement],function(a){while(a)e+=a.offsetLeft,d+=a.offsetTop,a=a.offsetParent});return{x:e,y:d,yBot:d+a.offsetHeight}}var c=select.cursorPos(this.container,a);if(!c)return null;var d=c.offset,e=c.node,f=this;while(d){e=e?e.nextSibling:this.container.firstChild;var i=nodeText(e);if(d<i.length)return h(i.substr(0,d),function(a){a.style.position="absolute",a.style.visibility="hidden",a.className=e.className,f.container.appendChild(a);return g(e,a.offsetWidth)});d-=i.length}return e&&isSpan(e)?g(e,e.offsetWidth):e&&e.nextSibling&&isSpan(e.nextSibling)?g(e.nextSibling,0):h("​",function(a){e?e.parentNode.insertBefore(a,e.nextSibling):f.container.insertBefore(a,f.container.firstChild);return g(a,0)})},reroutePasteEvent:function(){if(!(this.capturingPaste||window.opera||gecko&&gecko>=20101026)){this.capturingPaste=!0;var a=window.frameElement.CodeMirror.textareaHack,b=this.cursorCoords(!0,!0);a.style.top=b.y+"px";if(internetExplorer){var c=select.getBookmark(this.container);c&&(this.selectionSnapshot=c)}parent.focus(),a.value="",a.focus();var d=this;parent.setTimeout(function(){d.capturingPaste=!1,window.focus(),d.selectionSnapshot&&window.select.setBookmark(d.container,d.selectionSnapshot);var b=a.value;b&&(d.replaceSelection(b),select.scrollToCursor(d.container))},10)}},replaceRange:function(a,b,c){var d=asEditorLines(c);d[0]=this.history.textAfter(a.node).slice(0,a.offset)+d[0];var e=d[d.length-1];d[d.length-1]=e+this.history.textAfter(b.node).slice(b.offset);var f=this.history.nodeAfter(b.node);this.history.push(a.node,f,d);return{node:this.history.nodeBefore(f),offset:e.length}},getSearchCursor:function(a,b,c){return new h(this,a,b,c)},reindent:function(){this.container.firstChild&&this.indentRegion(null,this.container.lastChild)},reindentSelection:function(a){if(!select.somethingSelected())this.indentAtCursor(a);else{var b=select.selectionTopNode(this.container,!0),c=select.selectionTopNode(this.container,!1);if(b===!1||c===!1)return;this.indentRegion(b,c,a,!0)}},grabKeys:function(a,b){this.frozen=a,this.keyFilter=b},ungrabKeys:function(){this.frozen="leave"},setParser:function(a,b){i.Parser=window[a],b=b||this.options.parserConfig,b&&i.Parser.configure&&i.Parser.configure(b),this.container.firstChild&&(forEach(this.container.childNodes,function(a){a.nodeType!=3&&(a.dirty=!0)}),this.addDirtyNode(this.firstChild),this.scheduleHighlight())},keyDown:function(a){this.frozen=="leave"&&(this.frozen=null,this.keyFilter=null);if(this.frozen&&(!this.keyFilter||this.keyFilter(a.keyCode,a)))a.stop(),this.frozen(a);else{var b=a.keyCode;this.delayScanning(),this.options.autoMatchParens&&this.scheduleParenHighlight();if(b==13){if(a.ctrlKey&&!a.altKey)this.reparseBuffer();else{select.insertNewlineAtCursor();var c=this.options.enterMode;c!="flat"&&this.indentAtCursor(c=="keep"?"keep":undefined),select.scrollToCursor(this.container)}a.stop()}else if(b==9&&this.options.tabMode!="default"&&!a.ctrlKey)this.handleTab(!a.shiftKey),a.stop();else if(b==32&&a.shiftKey&&this.options.tabMode=="default")this.handleTab(!0),a.stop();else if(b==36&&!a.shiftKey&&!a.ctrlKey)this.home()&&a.stop();else if(b==35&&!a.shiftKey&&!a.ctrlKey)this.end()&&a.stop();else if(b==33&&!a.shiftKey&&!a.ctrlKey&&!gecko)this.pageUp()&&a.stop();else if(b==34&&!a.shiftKey&&!a.ctrlKey&&!gecko)this.pageDown()&&a.stop();else if((b==219||b==221)&&a.ctrlKey&&!a.altKey)this.highlightParens(a.shiftKey,!0),a.stop();else if(a.metaKey&&!a.shiftKey&&(b==37||b==39)){var d=select.selectionTopNode(this.container);if(d===!1||!this.container.firstChild)return;if(b==37)select.focusAfterNode(e(d),this.container);else{var g=f(d,this.container);select.focusAfterNode(g?g.previousSibling:this.container.lastChild,this.container)}a.stop()}else(a.ctrlKey||a.metaKey)&&!a.altKey&&(a.shiftKey&&b==90||b==89?(select.scrollToNode(this.history.redo()),a.stop()):b==90||safari&&b==8?(select.scrollToNode(this.history.undo()),a.stop()):b==83&&this.options.saveFunction?(this.options.saveFunction(),a.stop()):b==86&&!mac&&this.reroutePasteEvent())}},keyPress:function(a){var b=this.options.electricChars&&i.Parser.electricChars,c=this;if(this.frozen&&(!this.keyFilter||this.keyFilter(a.keyCode||a.code,a))||a.code==13||a.code==9&&this.options.tabMode!="default"||a.code==32&&a.shiftKey&&this.options.tabMode=="default")a.stop();else if(mac&&(a.ctrlKey||a.metaKey)&&a.character=="v")this.reroutePasteEvent();else if(b&&b.indexOf(a.character)!=-1)parent.setTimeout(function(){c.indentAtCursor(null)},0);else if(brokenOpera){if(a.code==8){var d=select.selectionTopNode(this.container),c=this,e=d?d.nextSibling:this.container.firstChild;d!==!1&&e&&isBR(e)&&parent.setTimeout(function(){select.selectionTopNode(c.container)==e&&select.focusAfterNode(e.previousSibling,c.container)},20)}else if(a.code==46){var d=select.selectionTopNode(this.container),c=this;d&&isBR(d)&&parent.setTimeout(function(){select.selectionTopNode(c.container)!=d&&select.focusAfterNode(d,c.container)},20)}}else if(slowWebkit){var d=select.selectionTopNode(this.container),e=d?d.nextSibling:this.container.firstChild;if(d&&e&&isBR(e)&&!isBR(d)){var f=document.createTextNode("​");this.container.insertBefore(f,e),parent.setTimeout(function(){f.nodeValue=="​"?removeElement(f):f.nodeValue=f.nodeValue.replace("​","")},20)}}webkit&&!this.options.textWrapping&&setTimeout(function(){var a=select.selectionTopNode(c.container,!0);a&&a.nodeType==3&&a.previousSibling&&isBR(a.previousSibling)&&a.nextSibling&&isBR(a.nextSibling)&&a.parentNode.replaceChild(document.createElement("BR"),a.previousSibling)},50)},keyUp:function(a){this.cursorActivity(j(a.keyCode))},indentLineAfter:function(a,b){function c(a){var b=a?a.nextSibling:d.container.firstChild;if(!b||!hasClass(b,"whitespace"))return null;return b}var d=this,f=c(a),g=0,h=f?f.currentText.length:0,j=f?f.nextSibling:a?a.nextSibling:this.container.firstChild;if(b=="keep"){if(a){var k=c(e(a.previousSibling));k&&(g=k.currentText.length)}}else{var l=a&&j&&j.currentText?j.currentText:"";b!=null&&this.options.tabMode!="indent"?g=b?h+indentUnit:Math.max(0,h-indentUnit):a?g=a.indentation(l,h,b,j):i.Parser.firstIndentation&&(g=i.Parser.firstIndentation(l,h,b,j))}var m=g-h;m<0?g==0?(j&&select.snapshotMove(f.firstChild,j.firstChild||j,0),removeElement(f),f=null):(select.snapshotMove(f.firstChild,f.firstChild,m,!0),f.currentText=makeWhiteSpace(g),f.firstChild.nodeValue=f.currentText):m>0?f?(f.currentText=makeWhiteSpace(g),f.firstChild.nodeValue=f.currentText,select.snapshotMove(f.firstChild,f.firstChild,m,!0)):(f=makePartSpan(makeWhiteSpace(g)),f.className="whitespace",a?insertAfter(f,a):this.container.insertBefore(f,this.container.firstChild),select.snapshotMove(j&&(j.firstChild||j),f.firstChild,g,!1,!0)):f&&select.snapshotMove(f.firstChild,f.firstChild,g,!1),m!=0&&this.addDirtyNode(a)},highlightAtCursor:function(){var a=select.selectionTopNode(this.container,!0),b=select.selectionTopNode(this.container,!1);if(a===!1||b===!1)return!1;select.markSelection();if(this.highlight(a,f(b,this.container),!0,20)===!1)return!1;select.selectMarked();return!0},handleTab:function(a){this.options.tabMode=="spaces"&&!select.somethingSelected()?select.insertTabAtCursor():this.reindentSelection(a)},home:function(){var a=select.selectionTopNode(this.container,!0),b=a;if(a===!1||!(!a||a.isPart||isBR(a))||!this.container.firstChild)return!1;while(a&&!isBR(a))a=a.previousSibling;var c=a?a.nextSibling:this.container.firstChild;c&&c!=b&&c.isPart&&hasClass(c,"whitespace")?select.focusAfterNode(c,this.container):select.focusAfterNode(a,this.container),select.scrollToCursor(this.container);return!0},end:function(){var a=select.selectionTopNode(this.container,!0);if(a===!1)return!1;a=f(a,this.container);if(!a)return!1;select.focusAfterNode(a.previousSibling,this.container),select.scrollToCursor(this.container);return!0},pageUp:function(){var a=this.cursorPosition().line,b=this.visibleLineCount();if(a===!1||b===!1)return!1;b-=2;for(var c=0;c<b;c++){a=this.prevLine(a);if(a===!1)break}if(c==0)return!1;select.setCursorPos(this.container,{node:a,offset:0}),select.scrollToCursor(this.container);return!0},pageDown:function(){var a=this.cursorPosition().line,b=this.visibleLineCount();if(a===!1||b===!1)return!1;b-=2;for(var c=0;c<b;c++){var d=this.nextLine(a);if(d===!1)break;a=d}if(c==0)return!1;select.setCursorPos(this.container,{node:a,offset:0}),select.scrollToCursor(this.container);return!0},scheduleParenHighlight:function(){this.parenEvent&&parent.clearTimeout(this.parenEvent);var a=this;this.parenEvent=parent.setTimeout(function(){a.highlightParens()},300)},highlightParens:function(a,b){function o(){var a=[],b,c=!0;for(var d=k;d;d=m?d.nextSibling:d.previousSibling)if(d.className==l&&isSpan(d)&&(b=h(d))){i(b)==m?a.push(b):a.length?a.pop()!=matching[b]&&(c=!1):c=!1;if(!a.length)break}else if(d.dirty||!isSpan(d)&&!isBR(d))return{node:d,status:"dirty"};return{node:d,status:d&&c}}function i(a){return/[\(\[\{]/.test(a)}function h(a){if(a.currentText){var b=a.currentText.match(/^[\s\u00a0]*([\(\)\[\]{}])[\s\u00a0]*$/);return b&&b[1]}}function g(a){!a||(d&&!d.call?removeClass(removeClass(a,d[0]),d[1]):c.options.unmarkParen?c.options.unmarkParen(a):(a.style.fontWeight="",a.style.color=""))}function e(a,b){!a||(d?d.call?d(a,b):a.className+=" "+d[b?0:1]:(a.style.fontWeight="bold",a.style.color=b?"#8F8":"#F88"))}var c=this,d=this.options.markParen;typeof d=="string"&&(d=[d,d]),!b&&c.highlighted&&(g(c.highlighted[0]),g(c.highlighted[1]));if(!(!window||!window.parent||!window.select)){this.parenEvent&&parent.clearTimeout(this.parenEvent),this.parenEvent=null;var j,k=select.selectionTopNode(this.container,!0);if(!k||!this.highlightAtCursor())return;k=select.selectionTopNode(this.container,!0);if(!k||!((j=h(k))||(k=k.nextSibling)&&(j=h(k))))return;var l=k.className,m=i(j),n=matching[j];for(;;){var p=o();if(p.status=="dirty"){this.highlight(p.node,f(p.node)),p.node.dirty=!1;continue}e(k,p.status),e(p.node,p.status),b?parent.setTimeout(function(){g(k),g(p.node)},500):c.highlighted=[k,p.node],a&&p.node&&select.focusAfterNode(p.node.previousSibling,this.container);break}}},indentAtCursor:function(a){if(!!this.container.firstChild){if(!this.highlightAtCursor())return;var b=select.selectionTopNode(this.container,!1);if(b===!1)return;select.markSelection(),this.indentLineAfter(e(b),a),select.selectMarked()}},indentRegion:function(a,b,c,d){var g=a=e(a),h=a&&e(a.previousSibling);isBR(b)||(b=f(b,this.container)),this.addDirtyNode(a);do{var i=f(g,this.container);g&&this.highlight(h,i,!0),this.indentLineAfter(g,c),h=g,g=i}while(g!=b);d&&select.setCursorPos(this.container,{node:a,offset:0},{node:b,offset:0})},cursorActivity:function(a){this.unloaded&&(window.document.designMode="off",window.document.designMode="on",this.unloaded=!1);if(internetExplorer){this.container.createTextRange().execCommand("unlink"),clearTimeout(this.saveSelectionSnapshot);var b=this;this.saveSelectionSnapshot=setTimeout(function(){var a=select.getBookmark(b.container);a&&(b.selectionSnapshot=a)},200)}var c=this.options.onCursorActivity;if(!a||c){var d=select.selectionTopNode(this.container,!1);if(d===!1||!this.container.firstChild)return;d=d||this.container.firstChild,c&&c(d),a||(this.scheduleHighlight(),this.addDirtyNode(d))}},reparseBuffer:function(){forEach(this.container.childNodes,function(a){a.dirty=!0}),this.container.firstChild&&this.addDirtyNode(this.container.firstChild)},addDirtyNode:function(a){a=a||this.container.firstChild;if(!!a){for(var b=0;b<this.dirty.length;b++)if(this.dirty[b]==a)return;a.nodeType!=3&&(a.dirty=!0),this.dirty.push(a)}},allClean:function(){return!this.dirty.length},scheduleHighlight:function(){var a=this;parent.clearTimeout(this.highlightTimeout),this.highlightTimeout=parent.setTimeout(function(){a.highlightDirty()},this.options.passDelay)},getDirtyNode:function(){while(this.dirty.length>0){var a=this.dirty.pop();try{while(a&&a.parentNode!=this.container)a=a.parentNode;if(a&&(a.dirty||a.nodeType==3))return a}catch(b){}}return null},highlightDirty:function(a){if(!window||!window.parent||!window.select)return!1;this.options.readOnly||select.markSelection();var b,c=a?null:g()+this.options.passTime;while((g()<c||a)&&(b=this.getDirtyNode())){var d=this.highlight(b,c);d&&d.node&&d.dirty&&this.addDirtyNode(d.node.nextSibling)}this.options.readOnly||select.selectMarked(),b&&this.scheduleHighlight();return this.dirty.length==0},documentScanner:function(a){var b=this,c=null;return function(){if(!(!window||!window.parent||!window.select)){c&&c.parentNode!=b.container&&(c=null),select.markSelection();var d=b.highlight(c,g()+a,!0);select.selectMarked();var e=d?d.node&&d.node.nextSibling:null;c=c==e?null:e,b.delayScanning()}}},delayScanning:function(){this.scanner&&(parent.clearTimeout(this.documentScan),this.documentScan=parent.setTimeout(this.scanner,this.options.continuousScanning))},highlight:function(a,b,d,e){function s(a){return(a.previousSibling==null||isBR(a.previousSibling))&&(a.nextSibling==null||isBR(a.nextSibling))}function o(a){if(a){var b=a.oldNextSibling;(u||b===undefined||a.nextSibling!=b)&&h.history.touch(a),a.oldNextSibling=a.nextSibling}else{var b=h.container.oldFirstChild;(u||b===undefined||h.container.firstChild!=b)&&h.history.touch(null),h.container.oldFirstChild=h.container.firstChild}}function n(a){var b=makePartSpan(a.value);b.className=a.style;return b}function m(a,b){a.currentText=a.currentText.substring(b),a.reduced=!0}function l(a,b){return!b.reduced&&b.currentText==a.value&&b.className==a.style}var f=this.container,h=this,j=this.options.activeTokens,k=typeof b=="number"?b:null;if(!f.firstChild)return!1;while(a&&(!a.parserFromHere||a.dirty)){if(e!=null&&isBR(a)&&--e<0)return!1;a=a.previousSibling}if(a&&!a.nextSibling)return!1;var p=c(a?a.nextSibling:f.firstChild),q=stringStream(p),r=a?a.parserFromHere(q):i.Parser.make(q),t={current:null,get:function(){this.current||(this.current=p.nodes.shift());return this.current},next:function(){this.current=null},remove:function(){f.removeChild(this.get()),this.current=null},getNonEmpty:function(){var a=this.get();while(a&&isSpan(a)&&a.currentText=="")if(window.opera&&s(a))this.next(),a=this.get();else{var b=a;this.remove(),a=this.get(),select.snapshotMove(b.firstChild,a&&(a.firstChild||a),0)}return a}},u=!1,v=!0,w=0;forEach(r,function(c){var e=t.getNonEmpty();if(c.value=="\n"){if(!isBR(e))throw"Parser out of sync. Expected BR.";if(e.dirty||!e.indentation)u=!0;o(a),a=e,e.parserFromHere=r.copy(),e.indentation=c.indentation||alwaysZero,e.dirty=!1;if(k==null&&e==b)throw StopIteration;if(k!=null&&g()>=k||!u&&!v&&w>1&&!d)throw StopIteration;v=u,u=!1,w=0,t.next()}else{if(!isSpan(e))throw"Parser out of sync. Expected SPAN.";e.dirty&&(u=!0),w++;if(l(c,e))j&&e.dirty&&j(e,c,h),e.dirty=!1,t.next();else{u=!0;var i=n(c);f.insertBefore(i,e),j&&j(i,c,h);var p=c.value.length,q=0;while(p>0){e=t.get();var s=e.currentText.length;select.snapshotReplaceNode(e.firstChild,i.firstChild,p,q),s>p?(m(e,p),p=0):(p-=s,q+=s,t.remove())}}}}),o(a),webkitLastLineHack(this.container);return{node:t.getNonEmpty(),dirty:u}}};return i}();addEventHandler(window,"load",function(){var a=window.frameElement.CodeMirror,b=a.editor=new Editor(a.options);parent.setTimeout(method(a,"init"),0)})
@@ -0,0 +1 @@
1
+ var tokenizeJavaScript=function(){function g(f,g,h,i){function p(b){var c=a(h,b);i(c?b:null);return{type:"string",style:"js-string"}}function o(){h.nextWhileMatches(c);return{type:"operator",style:"js-operator"}}function n(a){var b="/*",c=a=="*";for(;;){if(h.endOfLine())break;var d=h.next();if(d=="/"&&c){b=null;break}c=d=="*"}i(b);return{type:"comment",style:"js-comment"}}function m(){a(h,"/"),h.nextWhileMatches(/[gimy]/);return{type:"regexp",style:"js-string"}}function l(){h.nextWhileMatches(e);var a=h.get(),c=b.hasOwnProperty(a)&&b.propertyIsEnumerable(a)&&b[a];return c?{type:c.type,style:c.style,content:a}:{type:"variable",style:"js-variable",content:a}}function k(){h.nextWhileMatches(/[0-9]/),h.equals(".")&&(h.next(),h.nextWhileMatches(/[0-9]/));if(h.equals("e")||h.equals("E"))h.next(),h.equals("-")&&h.next(),h.nextWhileMatches(/[0-9]/);return{type:"number",style:"js-atom"}}function j(){h.next(),h.nextWhileMatches(d);return{type:"number",style:"js-atom"}}if(f=='"'||f=="'")return p(f);var q=h.next();if(f=="/*")return n(q);if(q=='"'||q=="'")return p(q);if(/[\[\]{}\(\),;\:\.]/.test(q))return{type:q,style:"js-punctuation"};if(q=="0"&&(h.equals("x")||h.equals("X")))return j();if(/[0-9]/.test(q))return k();if(q=="/"){if(h.equals("*")){h.next();return n(q)}if(h.equals("/")){a(h,null);return{type:"comment",style:"js-comment"}}return g?m():o()}return c.test(q)?o():l()}function f(a,b){return function(c,d){var e=a,h=g(a,b,c,function(a){e=a}),i=h.type=="operator"||h.type=="keyword c"||h.type.match(/^[\[{}\(,;:]$/);(i!=b||e!=a)&&d(f(e,i));return h}}function a(a,b){var c=!1;while(!a.endOfLine()){var d=a.next();if(d==b&&!c)return!1;c=!c&&d=="\\"}return c}var b=function(){function a(a,b){return{type:a,style:"js-"+b}}var b=a("keyword a","keyword"),c=a("keyword b","keyword"),d=a("keyword c","keyword"),e=a("operator","keyword"),f=a("atom","atom");return{"if":b,"while":b,"with":b,"else":c,"do":c,"try":c,"finally":c,"return":d,"break":d,"continue":d,"new":d,"delete":d,"throw":d,"in":e,"typeof":e,"instanceof":e,"var":a("var","keyword"),"function":a("function","keyword"),"catch":a("catch","keyword"),"for":a("for","keyword"),"switch":a("switch","keyword"),"case":a("case","keyword"),"default":a("default","keyword"),"true":f,"false":f,"null":f,"undefined":f,NaN:f,Infinity:f}}(),c=/[+\-*&%=<>!?|]/,d=/[0-9A-Fa-f]/,e=/[\w\$_]/;return function(a,b){return tokenizer(a,b||f(!1,!0))}}(),JSParser=Editor.Parser=function(){function e(e,f){function T(a,b){a=="variable"&&(x(b),s())}function S(a,b){a=="variable"?(x(b),s(S)):a=="("&&s(v,K(T,")"),E,w)}function R(a){a==")"?t():s(F)}function Q(a,b){a==";"?s(R):b=="in"?s(F):s(F,B(";"),R)}function P(a,b){b=="in"?s(F):s(G,Q)}function O(a){a=="var"?s(M,Q):a==";"?t(Q):a=="variable"?s(P):t(Q)}function N(a,b){b=="="?s(F,N):a==","&&s(M)}function M(a,b){a=="variable"?(x(b),s(N)):s()}function L(a){a=="}"?s():t(E,L)}function K(a,b){function c(d){d==","?s(a,c):d==b?s():s(B(b))}return function(d){d==b?s():t(a,c)}}function J(b){b=="variable"&&u("js-property"),a.hasOwnProperty(b)&&s(B(":"),F)}function I(a){a=="variable"&&(u("js-property"),s())}function H(a){a==":"?s(A,E):t(G,B(";"),A)}function G(a,b){a=="operator"&&/\+\+|--/.test(b)?s(G):a=="operator"?s(F):a==";"?t():a=="("?s(z(")"),K(F,")"),A,G):a=="."?s(I,G):a=="["&&s(z("]"),F,B("]"),A,G)}function F(b){a.hasOwnProperty(b)?s(G):b=="function"?s(S):b=="keyword c"?s(F):b=="("?s(z(")"),F,B(")"),A,G):b=="operator"?s(F):b=="["?s(z("]"),K(F,"]"),A,G):b=="{"?s(z("}"),K(J,"}"),A,G):s()}function E(a){a=="var"?s(z("vardef"),M,B(";"),A):a=="keyword a"?s(z("form"),F,E,A):a=="keyword b"?s(z("form"),E,A):a=="{"?s(z("}"),L,A):a==";"?s():a=="function"?s(S):a=="for"?s(z("form"),B("("),z(")"),O,B(")"),A,E,A):a=="variable"?s(z("stat"),H):a=="switch"?s(z("form"),F,z("}","switch"),B("{"),L,A,A):a=="case"?s(F,B(":")):a=="default"?s(B(":")):a=="catch"?s(z("form"),v,B("("),T,B(")"),E,A,w):t(z("stat"),F,B(";"),A)}function D(a){return t(F,D)}function C(a){return t(E,C)}function B(a){return function(b){b==a?s():a==";"?t():s(arguments.callee)}}function A(){j.type==")"&&(l=j.indented),j=j.prev}function z(a,b){var d=function(){j=new c(l,k,a,null,j,b)};d.lex=!0;return d}function y(a){var b=i;while(b){if(b.vars[a])return!0;b=b.prev}return!1}function x(a){i&&(u("js-variabledef"),i.vars[a]=!0)}function w(){i=i.prev}function v(){i={prev:i,vars:{"this":!0,arguments:!0}}}function u(a){n=a}function t(){r(arguments),m=!1}function s(){r(arguments),m=!0}function r(a){for(var b=a.length-1;b>=0;b--)h.push(a[b])}function q(){var a=i,b=j,c=h.concat([]),d=g.state;return function(e){i=a,j=b,h=c.concat([]),k=l=0,g=tokenizeJavaScript(e,d);return o}}function p(){while(h[h.length-1].lex)h.pop()();var a=g.next();a.type=="whitespace"&&k==0&&(l=a.value.length),k+=a.value.length,a.content=="\n"&&(l=k=0,"align"in j||(j.align=!1),a.indentation=d(j));if(a.type=="whitespace"||a.type=="comment")return a;"align"in j||(j.align=!0);for(;;){m=n=!1,h.pop()(a.type,a.content);if(m){n?a.style=n:a.type=="variable"&&y(a.content)&&(a.style="js-localvariable");return a}}}var g=tokenizeJavaScript(e),h=[b?D:C],i=null,j=new c((f||0)-indentUnit,0,"block",!1),k=0,l=0,m,n,o={next:p,copy:q};A.lex=!0;return o}function d(a){return function(b){var c=b&&b.charAt(0),d=a.type,e=c==d;return d=="vardef"?a.indented+4:d=="form"&&c=="{"?a.indented:d=="stat"||d=="form"?a.indented+indentUnit:a.info=="switch"&&!e?a.indented+(/^(?:case|default)\b/.test(b)?indentUnit:2*indentUnit):a.align?a.column-(e?1:0):a.indented+(e?0:indentUnit)}}function c(a,b,c,d,e,f){this.indented=a,this.column=b,this.type=c,d!=null&&(this.align=d),this.prev=e,this.info=f}var a={atom:!0,number:!0,variable:!0,string:!0,regexp:!0},b=!1;return{make:e,electricChars:"{}:",configure:function(a){a.json!=null&&(b=a.json)}}}(),XMLParser=Editor.Parser=function(){function f(a){function C(a){a=="xml-attribute"?n(C):o()}function B(a,b){b=="="?n(C):b==">"||b=="/>"?o(z):o()}function A(a){a=="xml-name"?(f.style="xml-attname",n(B,A)):o()}function z(a){return function(b,d){d=="/>"||d==">"&&c.autoSelfClosers.hasOwnProperty(j)?n():d==">"?(r(j,a),n()):(p(),n(arguments.callee))}}function y(a,b){a=="xml-name"&&(f.style="xml-tagname",k&&b.toLowerCase()==k.name?s():p()),n()}function x(a,b){a=="xml-name"?(j=b.toLowerCase(),f.style="xml-tagname",n()):(j=null,o())}function w(a,b){b=="<"?n(x,A,z(h==1)):b=="</"?n(y,q(">")):a=="xml-cdata"?((!k||k.name!="!cdata")&&r("!cdata"),/\]\]>$/.test(b)&&s(),n()):v.hasOwnProperty(a)?n():(p(),n())}function u(){return o(w,u)}function t(a){return function(b,c){var e=a;if(e&&e.noIndent)return c;if(d&&/<!\[CDATA\[/.test(b))return 0;e&&/^<\//.test(b)&&(e=e.prev);while(e&&!e.startOfLine)e=e.prev;return e?e.indent+indentUnit:0}}function s(){k=k.prev}function r(a,b){var d=c.doNotIndent.hasOwnProperty(a)||k&&k.noIndent;k={prev:k,name:a,indent:i,startOfLine:b,noIndent:d}}function q(a){return function(b,c){c==a?n():(p(),n(arguments.callee))}}function p(){f.style+=" xml-error"}function o(){m(arguments),l=!1}function n(){m(arguments),l=!0}function m(a){for(var b=a.length-1;b>=0;b--)g.push(a[b])}var b=e(a),f,g=[u],h=0,i=0,j=null,k=null,l,v={"xml-text":!0,"xml-entity":!0,"xml-comment":!0,"xml-processing":!0,"xml-doctype":!0};return{indentation:function(){return i},next:function(){f=b.next(),f.style=="whitespace"&&h==0?i=f.value.length:h++,f.content=="\n"&&(i=h=0,f.indentation=t(k));if(f.style=="whitespace"||f.type=="xml-comment")return f;for(;;){l=!1,g.pop()(f.style,f.content);if(l)return f}},copy:function(){var a=g.concat([]),c=b.state,d=k,f=this;return function(j){g=a.concat([]),h=i=0,k=d,b=e(j,c);return f}}}}var a={autoSelfClosers:{br:!0,img:!0,hr:!0,link:!0,input:!0,meta:!0,col:!0,frame:!0,base:!0,area:!0},doNotIndent:{pre:!0,"!cdata":!0}},b={autoSelfClosers:{},doNotIndent:{"!cdata":!0}},c=a,d=!1,e=function(){function d(b,c){return function(d,e){while(!d.endOfLine()){if(d.lookAhead(c,!0)){e(a);break}d.next()}return b}}function c(a){return function(c,d){while(!c.endOfLine())if(c.next()==a){d(b);break}return"xml-attribute"}}function b(b,d){var e=b.next();if(e==">"){d(a);return"xml-punctuation"}if(/[?\/]/.test(e)&&b.equals(">")){b.next(),d(a);return"xml-punctuation"}if(e=="=")return"xml-punctuation";if(/[\'\"]/.test(e)){d(c(e));return null}b.nextWhileMatches(/[^\s\u00a0=<>\"\'\/?]/);return"xml-name"}function a(a,c){var e=a.next();if(e=="<"){if(a.equals("!")){a.next();if(a.equals("[")){if(a.lookAhead("[CDATA[",!0)){c(d("xml-cdata","]]>"));return null}return"xml-text"}if(a.lookAhead("--",!0)){c(d("xml-comment","-->"));return null}if(a.lookAhead("DOCTYPE",!0)){a.nextWhileMatches(/[\w\._\-]/),c(d("xml-doctype",">"));return"xml-doctype"}return"xml-text"}if(a.equals("?")){a.next(),a.nextWhileMatches(/[\w\._\-]/),c(d("xml-processing","?>"));return"xml-processing"}a.equals("/")&&a.next(),c(b);return"xml-punctuation"}if(e=="&"){while(!a.endOfLine())if(a.next()==";")break;return"xml-entity"}a.nextWhileMatches(/[^&<\n]/);return"xml-text"}return function(b,c){return tokenizer(b,c||a)}}();return{make:f,electricChars:"/",configure:function(e){e.useHTMLKludges!=null&&(c=e.useHTMLKludges?a:b),e.alignCDATA&&(d=e.alignCDATA)}}}(),CSSParser=Editor.Parser=function(){function c(c,d){d=d||0;var e=a(c),f=!1,g=!1,h=!1,i={next:function(){var a=e.next(),c=a.style,i=a.content;c=="css-hash"&&(c=a.style=g?"css-colorcode":"css-identifier"),c=="css-identifier"&&(g?a.style="css-value":!f&&!h&&(a.style="css-selector")),i=="\n"&&(a.indentation=b(f,g,d)),i=="{"&&h=="@media"?h=!1:i=="{"?f=!0:i=="}"?f=g=h=!1:i==";"?g=h=!1:f&&c!="css-comment"&&c!="whitespace"?g=!0:!f&&c=="css-at"&&(h=i);return a},copy:function(){var b=f,c=g,d=e.state;return function(h){e=a(h,d),f=b,g=c;return i}}};return i}function b(a,b,c){return function(d){return!a||/^\}/.test(d)?c:b?c+indentUnit*2:c+indentUnit}}var a=function(){function d(b){return function(c,d){var e=!1;while(!c.endOfLine()){var f=c.next();if(f==b&&!e)break;e=!e&&f=="\\"}e||d(a);return"css-string"}}function c(b,c){var d=0;while(!b.endOfLine()){var e=b.next();if(d>=2&&e==">"){c(a);break}d=e=="-"?d+1:0}return"css-comment"}function b(b,c){var d=!1;while(!b.endOfLine()){var e=b.next();if(d&&e=="/"){c(a);break}d=e=="*"}return"css-comment"}function a(a,e){var f=a.next();if(f=="@"){a.nextWhileMatches(/\w/);return"css-at"}if(f=="/"&&a.equals("*")){e(b);return null}if(f=="<"&&a.equals("!")){e(c);return null}if(f=="=")return"css-compare";if(!a.equals("=")||f!="~"&&f!="|"){if(f=='"'||f=="'"){e(d(f));return null}if(f=="#"){a.nextWhileMatches(/\w/);return"css-hash"}if(f=="!"){a.nextWhileMatches(/[ \t]/),a.nextWhileMatches(/\w/);return"css-important"}if(/\d/.test(f)){a.nextWhileMatches(/[\w.%]/);return"css-unit"}if(/[,.+>*\/]/.test(f))return"css-select-op";if(/[;{}:\[\]]/.test(f))return"css-punctuation";a.nextWhileMatches(/[\w\\\-_]/);return"css-identifier"}a.next();return"css-compare"}return function(b,c){return tokenizer(b,c||a)}}();return{make:c,electricChars:"}"}}(),HTMLMixedParser=Editor.Parser=function(){function c(c){function j(){var a=d.copy(),b=e&&e.copy(),h=g.next,i=f;return function(j){c=j,d=a(j),e=b&&b(j),g.next=h,f=i;return g}}function i(a,b){var f=d.indentation();e=a.make(c,f+indentUnit);return function(){if(c.lookAhead(b,!1,!1,!0)){e=null,g.next=h;return h()}var a=e.next(),d=a.value.lastIndexOf("<"),i=Math.min(a.value.length-d,b.length);d!=-1&&a.value.slice(d,d+i).toLowerCase()==b.slice(0,i)&&c.lookAhead(b.slice(i),!1,!1,!0)&&(c.push(a.value.slice(d)),a.value=a.value.slice(0,d));if(a.indentation){var j=a.indentation;a.indentation=function(a){return a=="</"?f:j(a)}}return a}}function h(){var b=d.next();if(b.content=="<")f=!0;else if(b.style=="xml-tagname"&&f===!0)f=b.content.toLowerCase();else if(b.content==">"){if(a[f]){var c=window[a[f]];g.next=i(c,"</"+f)}f=!1}return b}b();var d=XMLParser.make(c),e=null,f=!1,g={next:h,copy:j};return g}function b(){var b=["XMLParser"];for(var c in a)b.push(a[c]);for(var d in b)if(!window[b[d]])throw new Error(b[d]+" parser must be loaded for HTML mixed mode to work.");XMLParser.configure({useHTMLKludges:!0})}var a={script:"JSParser",style:"CSSParser"};return{make:c,electricChars:"{}/:",configure:function(b){b.triggers&&(a=b.triggers)}}}()
@@ -0,0 +1 @@
1
+ var CodeMirrorConfig=window.CodeMirrorConfig||{},CodeMirror=function(){function g(b,g){this.options=g=g||{},a(g,CodeMirrorConfig),g.dumbTabs?g.tabMode="spaces":g.normalTab&&(g.tabMode="default"),g.cursorActivity&&(g.onCursorActivity=g.cursorActivity);var h=this.frame=c("iframe");g.iframeClass&&(h.className=g.iframeClass),h.frameBorder=0,h.style.border="0",h.style.width="100%",h.style.height="100%",h.style.display="block";var i=this.wrapping=c("div");i.style.position="relative",i.className="CodeMirror-wrapping",i.style.width=g.width,i.style.height=g.height=="dynamic"?g.minHeight+"px":g.height;var j=this.textareaHack=c("textarea");i.appendChild(j),j.style.position="absolute",j.style.left="-10000px",j.style.width="10px",j.tabIndex=1e5,h.CodeMirror=this,g.domain&&f?(this.html=e(g),h.src="javascript:(function(){document.open();"+(g.domain?'document.domain="'+g.domain+'";':"")+"document.write(window.frameElement.CodeMirror.html);document.close();})()"):h.src="javascript:;",b.appendChild?b.appendChild(i):b(i),i.appendChild(h),g.lineNumbers&&(this.lineNumbers=d(i,g.firstLineNumber)),this.win=h.contentWindow;if(!g.domain||!f)this.win.document.open(),this.win.document.write(e(g)),this.win.document.close()}function e(a){typeof a.parserfile=="string"&&(a.parserfile=[a.parserfile]),typeof a.basefiles=="string"&&(a.basefiles=[a.basefiles]),typeof a.stylesheet=="string"&&(a.stylesheet=[a.stylesheet]);var c=' spellcheck="'+(a.disableSpellcheck?"false":"true")+'"',d=['<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html'+c+"><head>"];d.push('<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7"/>');var e=a.noScriptCaching?"?nocache="+(new Date).getTime().toString(16):"";b(a.stylesheet,function(a){d.push('<link rel="stylesheet" type="text/css" href="'+a+e+'"/>')}),b(a.basefiles.concat(a.parserfile),function(b){/^https?:/.test(b)||(b=a.path+b),d.push('<script type="text/javascript" src="'+b+e+'"><'+"/script>")}),d.push('</head><body style="border-width: 0;" class="editbox"'+c+"></body></html>");return d.join("")}function d(a,b){var d=c("div"),e=c("div");d.style.position="absolute",d.style.height="100%";if(d.style.setExpression)try{d.style.setExpression("height","this.previousSibling.offsetHeight + 'px'")}catch(f){}d.style.top="0px",d.style.left="0px",d.style.overflow="hidden",a.appendChild(d),e.className="CodeMirror-line-numbers",d.appendChild(e),e.innerHTML="<div>"+b+"</div>";return d}function c(a){return document.createElementNS&&document.documentElement.namespaceURI!==null?document.createElementNS("http://www.w3.org/1999/xhtml",a):document.createElement(a)}function b(a,b){for(var c=0;c<a.length;c++)b(a[c])}function a(a,b){for(var c in b)a.hasOwnProperty(c)||(a[c]=b[c])}a(CodeMirrorConfig,{stylesheet:[],path:"",parserfile:[],basefiles:["util.js","stringstream.js","select.js","undo.js","editor.js","tokenize.js"],iframeClass:null,passDelay:200,passTime:50,lineNumberDelay:200,lineNumberTime:50,continuousScanning:!1,saveFunction:null,onLoad:null,onChange:null,undoDepth:50,undoDelay:800,disableSpellcheck:!0,textWrapping:!0,readOnly:!1,width:"",height:"300px",minHeight:100,autoMatchParens:!1,markParen:null,unmarkParen:null,parserConfig:null,tabMode:"indent",enterMode:"indent",electricChars:!0,reindentOnLoad:!1,activeTokens:null,onCursorActivity:null,lineNumbers:!1,firstLineNumber:1,onLineNumberClick:null,indentUnit:2,domain:null,noScriptCaching:!1,incrementalLoading:!1});var f=document.selection&&window.ActiveXObject&&/MSIE/.test(navigator.userAgent);g.prototype={init:function(){this.options.initCallback&&this.options.initCallback(this),this.options.onLoad&&this.options.onLoad(this),this.options.lineNumbers&&this.activateLineNumbers(),this.options.reindentOnLoad&&this.reindent(),this.options.height=="dynamic"&&this.setDynamicHeight()},getCode:function(){return this.editor.getCode()},setCode:function(a){this.editor.importCode(a)},selection:function(){this.focusIfIE();return this.editor.selectedText()},reindent:function(){this.editor.reindent()},reindentSelection:function(){this.focusIfIE(),this.editor.reindentSelection(null)},focusIfIE:function(){this.win.select.ie_selection&&document.activeElement!=this.frame&&this.focus()},focus:function(){this.win.focus(),this.editor.selectionSnapshot&&this.win.select.setBookmark(this.win.document.body,this.editor.selectionSnapshot)},replaceSelection:function(a){this.focus(),this.editor.replaceSelection(a);return!0},replaceChars:function(a,b,c){this.editor.replaceChars(a,b,c)},getSearchCursor:function(a,b,c){return this.editor.getSearchCursor(a,b,c)},undo:function(){this.editor.history.undo()},redo:function(){this.editor.history.redo()},historySize:function(){return this.editor.history.historySize()},clearHistory:function(){this.editor.history.clear()},grabKeys:function(a,b){this.editor.grabKeys(a,b)},ungrabKeys:function(){this.editor.ungrabKeys()},setParser:function(a,b){this.editor.setParser(a,b)},setSpellcheck:function(a){this.win.document.body.spellcheck=a},setStylesheet:function(a){typeof a=="string"&&(a=[a]);var b={},c={},d=this.win.document.getElementsByTagName("link");for(var e=0,f;f=d[e];e++)if(f.rel.indexOf("stylesheet")!==-1)for(var g=0;g<a.length;g++){var h=a[g];f.href.substring(f.href.length-h.length)===h&&(b[f.href]=!0,c[h]=!0)}for(var e=0,f;f=d[e];e++)f.rel.indexOf("stylesheet")!==-1&&(f.disabled=!(f.href in b));for(var g=0;g<a.length;g++){var h=a[g];if(!(h in c)){var f=this.win.document.createElement("link");f.rel="stylesheet",f.type="text/css",f.href=h,this.win.document.getElementsByTagName("head")[0].appendChild(f)}}},setTextWrapping:function(a){a!=this.options.textWrapping&&(this.win.document.body.style.whiteSpace=a?"":"nowrap",this.options.textWrapping=a,this.lineNumbers&&(this.setLineNumbers(!1),this.setLineNumbers(!0)))},setIndentUnit:function(a){this.win.indentUnit=a},setUndoDepth:function(a){this.editor.history.maxDepth=a},setTabMode:function(a){this.options.tabMode=a},setEnterMode:function(a){this.options.enterMode=a},setLineNumbers:function(a){a&&!this.lineNumbers?(this.lineNumbers=d(this.wrapping,this.options.firstLineNumber),this.activateLineNumbers()):!a&&this.lineNumbers&&(this.wrapping.removeChild(this.lineNumbers),this.wrapping.style.paddingLeft="",this.lineNumbers=null)},cursorPosition:function(a){this.focusIfIE();return this.editor.cursorPosition(a)},firstLine:function(){return this.editor.firstLine()},lastLine:function(){return this.editor.lastLine()},nextLine:function(a){return this.editor.nextLine(a)},prevLine:function(a){return this.editor.prevLine(a)},lineContent:function(a){return this.editor.lineContent(a)},setLineContent:function(a,b){this.editor.setLineContent(a,b)},removeLine:function(a){this.editor.removeLine(a)},insertIntoLine:function(a,b,c){this.editor.insertIntoLine(a,b,c)},selectLines:function(a,b,c,d){this.win.focus(),this.editor.selectLines(a,b,c,d)},nthLine:function(a){var b=this.firstLine();for(;a>1&&b!==!1;a--)b=this.nextLine(b);return b},lineNumber:function(a){var b=0;while(a!==!1)b++,a=this.prevLine(a);return b},jumpToLine:function(a){typeof a=="number"&&(a=this.nthLine(a)),this.selectLines(a,0),this.win.focus()},currentLine:function(){return this.lineNumber(this.cursorLine())},cursorLine:function(){return this.cursorPosition().line},cursorCoords:function(a){return this.editor.cursorCoords(a)},activateLineNumbers:function(){function p(){function t(){s&&clearTimeout(s),h.editor.allClean()?r():s=setTimeout(t,200)}function r(b){k(),n(b),a=e.firstChild,d=g.firstChild,i=0,f=h.options.firstLineNumber,q()}function q(){if(!!g.parentNode&&g.parentNode==h.lineNumbers){var c=(new Date).getTime()+h.options.lineNumberTime;while(a){o(f++,a.previousSibling);for(;a&&!b.isBR(a);a=a.nextSibling){var e=a.offsetTop+a.offsetHeight;while(g.offsetHeight&&e-3>i){var j=i;o("&nbsp;");if(i<=j)break}}a&&(a=a.nextSibling);if((new Date).getTime()>c){p(),s=setTimeout(q,h.options.lineNumberDelay);return}}while(d)o(f++);p(),k()}}function p(){for(var a=0;a<j.length;a+=2)j[a].innerHTML=j[a+1];j=[]}function o(a,b){d||(d=g.appendChild(c("div"))),m&&m(d,b,a),j.push(d),j.push(a),i=d.offsetHeight+d.offsetTop,d=d.nextSibling}var a,d,f,i,j=[],m=h.options.styleNumbers;r(!0);var s=null;h.updateNumbers=t;var u=b.addEventHandler(b,"scroll",k,!0),v=b.addEventHandler(b,"resize",t,!0);l=function(){s&&clearTimeout(s),h.updateNumbers==t&&(h.updateNumbers=null),u(),v()}}function o(){function a(){n(!0),k()}h.updateNumbers=a;var c=b.addEventHandler(b,"scroll",k,!0),d=b.addEventHandler(b,"resize",a,!0);l=function(){c(),d(),h.updateNumbers==a&&(h.updateNumbers=null)},a()}function n(b){var d=g.firstChild.offsetHeight;if(d!=0){var f=50+Math.max(e.offsetHeight,Math.max(a.offsetHeight,e.scrollHeight||0)),i=Math.ceil(f/d);for(var j=g.childNodes.length;j<=i;j++){var k=c("div");k.appendChild(document.createTextNode(b?String(j+h.options.firstLineNumber):" ")),g.appendChild(k)}}}function k(){f.scrollTop=e.scrollTop||d.documentElement.scrollTop||0}function j(){if(a.offsetWidth!=0){for(var c=a;c.parentNode;c=c.parentNode);if(!f.parentNode||c!=document||!b.Editor){try{l()}catch(d){}clearInterval(m);return}f.offsetWidth!=i&&(i=f.offsetWidth,a.parentNode.style.paddingLeft=i+"px")}}var a=this.frame,b=a.contentWindow,d=b.document,e=d.body,f=this.lineNumbers,g=f.firstChild,h=this,i=null;f.onclick=function(a){var b=h.options.onLineNumberClick;if(b){var c=(a||window.event).target||(a||window.event).srcElement,d=c==f?NaN:Number(c.innerHTML);isNaN(d)||b(d,c)}};var l=function(){};j();var m=setInterval(j,500);(this.options.textWrapping||this.options.styleNumbers?p:o)()},setDynamicHeight:function(){function h(){var b=0,f=d.lastChild,h;while(f&&c.isBR(f))f.hackBR||b++,f=f.previousSibling;f?(e=f.offsetHeight,h=f.offsetTop+(1+b)*e):e&&(h=b*e),h&&(a.wrapping.style.height=Math.max(g+h,a.options.minHeight)+"px")}var a=this,b=a.options.onCursorActivity,c=a.win,d=c.document.body,e=null,f=null,g=2*a.frame.offsetTop;d.style.overflowY="hidden",c.document.documentElement.style.overflowY="hidden",this.frame.scrolling="no",setTimeout(h,300),a.options.onCursorActivity=function(a){b&&b(a),clearTimeout(f),f=setTimeout(h,100)}}},g.InvalidLineHandle={toString:function(){return"CodeMirror.InvalidLineHandle"}},g.replace=function(a){typeof a=="string"&&(a=document.getElementById(a));return function(b){a.parentNode.replaceChild(b,a)}},g.fromTextArea=function(a,b){function f(b){a.nextSibling?a.parentNode.insertBefore(b,a.nextSibling):a.parentNode.appendChild(b)}function c(){a.value=h.getCode()}typeof a=="string"&&(a=document.getElementById(a)),b=b||{},a.style.width&&b.width==null&&(b.width=a.style.width),a.style.height&&b.height==null&&(b.height=a.style.height),b.content==null&&(b.content=a.value);if(a.form){typeof a.form.addEventListener=="function"?a.form.addEventListener("submit",c,!1):a.form.attachEvent("onsubmit",c);if(typeof a.form.submit=="function"){var d=a.form.submit;function e(){c(),a.form.submit=d,a.form.submit(),a.form.submit=e}a.form.submit=e}}a.style.display="none";var h=new g(f,b);h.save=c,h.toTextArea=function(){c(),a.parentNode.removeChild(h.wrapping),a.style.display="",a.form&&(typeof a.form.submit=="function"&&(a.form.submit=d),typeof a.form.removeEventListener=="function"?a.form.removeEventListener("submit",c,!1):a.form.detachEvent("onsubmit",c))};return h},g.isProbablySupported=function(){var a;return window.opera?Number(window.opera.version())>=9.52:/Apple Computer, Inc/.test(navigator.vendor)&&(a=navigator.userAgent.match(/Version\/(\d+(?:\.\d+)?)\./))?Number(a[1])>=3:document.selection&&window.ActiveXObject&&(a=navigator.userAgent.match(/MSIE (\d+(?:\.\d*)?)\b/))?Number(a[1])>=6:(a=navigator.userAgent.match(/gecko\/(\d{8})/i))?Number(a[1])>=20050901:(a=navigator.userAgent.match(/AppleWebKit\/(\d+)/))?Number(a[1])>=525:null};return g}()
@@ -33,3 +33,14 @@ var page_part_tab_add = function(event) {
33
33
  this.hide();
34
34
  }).show();
35
35
  }
36
+
37
+ $(document).onReady(function() {
38
+ $$('textarea[codemirror]').each(function(textarea) {
39
+ CodeMirror.fromTextArea(textarea._, {
40
+ basefiles: "/puffer/javascripts/codemirror-base.js",
41
+ parserfile: "/puffer/javascripts/codemirror-parser.js",
42
+ stylesheet: "/puffer/stylesheets/codemirror.css",
43
+ tabMode: 'shift'
44
+ });
45
+ });
46
+ });