lucy_cms 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (245) hide show
  1. data/Gemfile +19 -0
  2. data/Gemfile.lock +88 -0
  3. data/LICENSE +24 -0
  4. data/README.md +161 -0
  5. data/Rakefile +26 -0
  6. data/VERSION +1 -0
  7. data/app/controllers/application_controller.rb +5 -0
  8. data/app/controllers/cms_admin/base_controller.rb +43 -0
  9. data/app/controllers/cms_admin/layouts_controller.rb +66 -0
  10. data/app/controllers/cms_admin/pages_controller.rb +111 -0
  11. data/app/controllers/cms_admin/sessions_controller.rb +25 -0
  12. data/app/controllers/cms_admin/sites_controller.rb +69 -0
  13. data/app/controllers/cms_admin/snippets_controller.rb +62 -0
  14. data/app/controllers/cms_admin/upload_dirs_controller.rb +79 -0
  15. data/app/controllers/cms_admin/users_controller.rb +129 -0
  16. data/app/controllers/cms_content_controller.rb +51 -0
  17. data/app/models/cms_block.rb +28 -0
  18. data/app/models/cms_layout.rb +118 -0
  19. data/app/models/cms_page.rb +163 -0
  20. data/app/models/cms_site.rb +38 -0
  21. data/app/models/cms_snippet.rb +70 -0
  22. data/app/models/cms_upload.rb +19 -0
  23. data/app/models/cms_upload_dir.rb +11 -0
  24. data/app/models/cms_user.rb +93 -0
  25. data/app/views/cms_admin/layouts/_form.html.erb +10 -0
  26. data/app/views/cms_admin/layouts/_index_branch.html.erb +24 -0
  27. data/app/views/cms_admin/layouts/edit.html.erb +6 -0
  28. data/app/views/cms_admin/layouts/index.html.erb +6 -0
  29. data/app/views/cms_admin/layouts/new.html.erb +6 -0
  30. data/app/views/cms_admin/pages/_form.html.erb +37 -0
  31. data/app/views/cms_admin/pages/_form_blocks.html.erb +7 -0
  32. data/app/views/cms_admin/pages/_index_branch.html.erb +40 -0
  33. data/app/views/cms_admin/pages/edit.html.erb +5 -0
  34. data/app/views/cms_admin/pages/form_blocks.js.erb +2 -0
  35. data/app/views/cms_admin/pages/index.html.erb +6 -0
  36. data/app/views/cms_admin/pages/new.html.erb +5 -0
  37. data/app/views/cms_admin/pages/toggle_branch.js.erb +11 -0
  38. data/app/views/cms_admin/sessions/new.html.erb +12 -0
  39. data/app/views/cms_admin/sites/_form.html.erb +16 -0
  40. data/app/views/cms_admin/sites/edit.html.erb +6 -0
  41. data/app/views/cms_admin/sites/new.html.erb +6 -0
  42. data/app/views/cms_admin/sites/setup.html.erb +16 -0
  43. data/app/views/cms_admin/snippets/_form.html.erb +4 -0
  44. data/app/views/cms_admin/snippets/edit.html.erb +6 -0
  45. data/app/views/cms_admin/snippets/index.html.erb +23 -0
  46. data/app/views/cms_admin/snippets/new.html.erb +6 -0
  47. data/app/views/cms_admin/upload_dirs/_file.html.erb +15 -0
  48. data/app/views/cms_admin/upload_dirs/_form.html.erb +2 -0
  49. data/app/views/cms_admin/upload_dirs/conflict.html.erb +12 -0
  50. data/app/views/cms_admin/upload_dirs/index.html.erb +23 -0
  51. data/app/views/cms_admin/upload_dirs/new.html.erb +6 -0
  52. data/app/views/cms_admin/upload_dirs/show.html.erb +26 -0
  53. data/app/views/cms_admin/upload_dirs/uploads_destroy.js.erb +3 -0
  54. data/app/views/cms_admin/users/_form.html.erb +9 -0
  55. data/app/views/cms_admin/users/_index_branch.html.erb +16 -0
  56. data/app/views/cms_admin/users/change_password.html.erb +14 -0
  57. data/app/views/cms_admin/users/edit.html.erb +17 -0
  58. data/app/views/cms_admin/users/index.html.erb +6 -0
  59. data/app/views/cms_admin/users/new.html.erb +14 -0
  60. data/app/views/layouts/cms_admin.html.erb +52 -0
  61. data/config/application.rb +48 -0
  62. data/config/boot.rb +13 -0
  63. data/config/database.yml +22 -0
  64. data/config/environment.rb +5 -0
  65. data/config/environments/development.rb +22 -0
  66. data/config/environments/production.rb +49 -0
  67. data/config/environments/test.rb +35 -0
  68. data/config/initializers/LucyCMS.rb +37 -0
  69. data/config/initializers/mime_types.rb +5 -0
  70. data/config/locales/en.yml +5 -0
  71. data/config/routes.rb +45 -0
  72. data/config.ru +4 -0
  73. data/db/cms_seeds/example.local/layouts/default.yml +8 -0
  74. data/db/cms_seeds/example.local/layouts/nested.yml +6 -0
  75. data/db/cms_seeds/example.local/pages/child/subchild.yml +14 -0
  76. data/db/cms_seeds/example.local/pages/child.yml +10 -0
  77. data/db/cms_seeds/example.local/pages/index.yml +11 -0
  78. data/db/cms_seeds/example.local/snippets/example.yml +4 -0
  79. data/db/migrate/01_create_cms.rb +114 -0
  80. data/db/seeds.rb +7 -0
  81. data/lib/LucyCMS/acts_as_tree.rb +102 -0
  82. data/lib/LucyCMS/cms_tag/field_datetime.rb +26 -0
  83. data/lib/LucyCMS/cms_tag/field_integer.rb +26 -0
  84. data/lib/LucyCMS/cms_tag/field_string.rb +26 -0
  85. data/lib/LucyCMS/cms_tag/field_text.rb +26 -0
  86. data/lib/LucyCMS/cms_tag/helper.rb +20 -0
  87. data/lib/LucyCMS/cms_tag/page_datetime.rb +22 -0
  88. data/lib/LucyCMS/cms_tag/page_integer.rb +22 -0
  89. data/lib/LucyCMS/cms_tag/page_rich_text.rb +22 -0
  90. data/lib/LucyCMS/cms_tag/page_string.rb +22 -0
  91. data/lib/LucyCMS/cms_tag/page_text.rb +22 -0
  92. data/lib/LucyCMS/cms_tag/partial.rb +21 -0
  93. data/lib/LucyCMS/cms_tag/snippet.rb +22 -0
  94. data/lib/LucyCMS/cms_tag.rb +119 -0
  95. data/lib/LucyCMS/configuration.rb +36 -0
  96. data/lib/LucyCMS/controller_methods.rb +42 -0
  97. data/lib/LucyCMS/engine.rb +12 -0
  98. data/lib/LucyCMS/form_builder.rb +129 -0
  99. data/lib/LucyCMS/rails_extensions.rb +22 -0
  100. data/lib/LucyCMS/site_form_builder.rb +129 -0
  101. data/lib/LucyCMS/view_hooks.rb +30 -0
  102. data/lib/LucyCMS/view_methods.rb +68 -0
  103. data/lib/LucyCMS.rb +40 -0
  104. data/lib/generators/README +17 -0
  105. data/lib/generators/cms_generator.rb +44 -0
  106. data/lib/tasks/LucyCMS.rake +283 -0
  107. data/lucy_cms.gemspec +100 -0
  108. data/public/404.html +26 -0
  109. data/public/422.html +26 -0
  110. data/public/500.html +26 -0
  111. data/public/favicon.ico +0 -0
  112. data/public/images/LucyCMS/arrow_bottom.gif +0 -0
  113. data/public/images/LucyCMS/arrow_right.gif +0 -0
  114. data/public/images/LucyCMS/icon_folder.png +0 -0
  115. data/public/images/LucyCMS/icon_layout.gif +0 -0
  116. data/public/images/LucyCMS/icon_move.gif +0 -0
  117. data/public/images/LucyCMS/icon_regular.gif +0 -0
  118. data/public/images/LucyCMS/icon_snippet.gif +0 -0
  119. data/public/images/LucyCMS/icon_upload.png +0 -0
  120. data/public/images/LucyCMS/icon_user.jpg +0 -0
  121. data/public/javascripts/LucyCMS/cms.js +204 -0
  122. data/public/javascripts/LucyCMS/codemirror/codemirror.css +102 -0
  123. data/public/javascripts/LucyCMS/codemirror/codemirror.js +23 -0
  124. data/public/javascripts/LucyCMS/codemirror/codemirror_base.js +88 -0
  125. data/public/javascripts/LucyCMS/codemirror/parse_css.js +4 -0
  126. data/public/javascripts/LucyCMS/codemirror/parse_html_mixed.js +3 -0
  127. data/public/javascripts/LucyCMS/codemirror/parse_js.js +12 -0
  128. data/public/javascripts/LucyCMS/codemirror/parse_xml.js +7 -0
  129. data/public/javascripts/LucyCMS/jquery-ui/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
  130. data/public/javascripts/LucyCMS/jquery-ui/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
  131. data/public/javascripts/LucyCMS/jquery-ui/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
  132. data/public/javascripts/LucyCMS/jquery-ui/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
  133. data/public/javascripts/LucyCMS/jquery-ui/images/ui-bg_glass_75_dadada_1x400.png +0 -0
  134. data/public/javascripts/LucyCMS/jquery-ui/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
  135. data/public/javascripts/LucyCMS/jquery-ui/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
  136. data/public/javascripts/LucyCMS/jquery-ui/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
  137. data/public/javascripts/LucyCMS/jquery-ui/images/ui-icons_222222_256x240.png +0 -0
  138. data/public/javascripts/LucyCMS/jquery-ui/images/ui-icons_2e83ff_256x240.png +0 -0
  139. data/public/javascripts/LucyCMS/jquery-ui/images/ui-icons_454545_256x240.png +0 -0
  140. data/public/javascripts/LucyCMS/jquery-ui/images/ui-icons_888888_256x240.png +0 -0
  141. data/public/javascripts/LucyCMS/jquery-ui/images/ui-icons_cd0a0a_256x240.png +0 -0
  142. data/public/javascripts/LucyCMS/jquery-ui/jquery-ui.css +362 -0
  143. data/public/javascripts/LucyCMS/jquery-ui/jquery-ui.js +190 -0
  144. data/public/javascripts/LucyCMS/jquery.js +154 -0
  145. data/public/javascripts/LucyCMS/plupload/plupload.full.min.js +1 -0
  146. data/public/javascripts/LucyCMS/plupload/plupload.html5.min.js +1 -0
  147. data/public/javascripts/LucyCMS/plupload/plupload.min.js +1 -0
  148. data/public/javascripts/LucyCMS/rails.js +132 -0
  149. data/public/javascripts/LucyCMS/tiny_mce/jquery.tinymce.js +1 -0
  150. data/public/javascripts/LucyCMS/tiny_mce/langs/en.js +170 -0
  151. data/public/javascripts/LucyCMS/tiny_mce/themes/advanced/about.htm +54 -0
  152. data/public/javascripts/LucyCMS/tiny_mce/themes/advanced/anchor.htm +26 -0
  153. data/public/javascripts/LucyCMS/tiny_mce/themes/advanced/charmap.htm +52 -0
  154. data/public/javascripts/LucyCMS/tiny_mce/themes/advanced/color_picker.htm +73 -0
  155. data/public/javascripts/LucyCMS/tiny_mce/themes/advanced/editor_template.js +1 -0
  156. data/public/javascripts/LucyCMS/tiny_mce/themes/advanced/image.htm +80 -0
  157. data/public/javascripts/LucyCMS/tiny_mce/themes/advanced/img/colorpicker.jpg +0 -0
  158. data/public/javascripts/LucyCMS/tiny_mce/themes/advanced/img/icons.gif +0 -0
  159. data/public/javascripts/LucyCMS/tiny_mce/themes/advanced/js/about.js +72 -0
  160. data/public/javascripts/LucyCMS/tiny_mce/themes/advanced/js/anchor.js +37 -0
  161. data/public/javascripts/LucyCMS/tiny_mce/themes/advanced/js/charmap.js +335 -0
  162. data/public/javascripts/LucyCMS/tiny_mce/themes/advanced/js/color_picker.js +253 -0
  163. data/public/javascripts/LucyCMS/tiny_mce/themes/advanced/js/image.js +245 -0
  164. data/public/javascripts/LucyCMS/tiny_mce/themes/advanced/js/link.js +156 -0
  165. data/public/javascripts/LucyCMS/tiny_mce/themes/advanced/js/source_editor.js +56 -0
  166. data/public/javascripts/LucyCMS/tiny_mce/themes/advanced/langs/en.js +62 -0
  167. data/public/javascripts/LucyCMS/tiny_mce/themes/advanced/langs/en_dlg.js +51 -0
  168. data/public/javascripts/LucyCMS/tiny_mce/themes/advanced/link.htm +58 -0
  169. data/public/javascripts/LucyCMS/tiny_mce/themes/advanced/skins/default/content.css +36 -0
  170. data/public/javascripts/LucyCMS/tiny_mce/themes/advanced/skins/default/dialog.css +117 -0
  171. data/public/javascripts/LucyCMS/tiny_mce/themes/advanced/skins/default/img/buttons.png +0 -0
  172. data/public/javascripts/LucyCMS/tiny_mce/themes/advanced/skins/default/img/items.gif +0 -0
  173. data/public/javascripts/LucyCMS/tiny_mce/themes/advanced/skins/default/img/menu_arrow.gif +0 -0
  174. data/public/javascripts/LucyCMS/tiny_mce/themes/advanced/skins/default/img/menu_check.gif +0 -0
  175. data/public/javascripts/LucyCMS/tiny_mce/themes/advanced/skins/default/img/progress.gif +0 -0
  176. data/public/javascripts/LucyCMS/tiny_mce/themes/advanced/skins/default/img/tabs.gif +0 -0
  177. data/public/javascripts/LucyCMS/tiny_mce/themes/advanced/skins/default/ui.css +213 -0
  178. data/public/javascripts/LucyCMS/tiny_mce/themes/advanced/source_editor.htm +25 -0
  179. data/public/javascripts/LucyCMS/tiny_mce/tiny_mce.js +1 -0
  180. data/public/javascripts/LucyCMS/tiny_mce/tiny_mce_popup.js +5 -0
  181. data/public/robots.txt +5 -0
  182. data/public/stylesheets/LucyCMS/content.css +196 -0
  183. data/public/stylesheets/LucyCMS/form.css +125 -0
  184. data/public/stylesheets/LucyCMS/reset.css +1 -0
  185. data/public/stylesheets/LucyCMS/site_form.css +82 -0
  186. data/public/stylesheets/LucyCMS/structure.css +125 -0
  187. data/public/stylesheets/LucyCMS/typography.css +25 -0
  188. data/script/rails +6 -0
  189. data/test/cms_seeds/test.host/layouts/broken.yml +1 -0
  190. data/test/cms_seeds/test.host/layouts/default.yml +3 -0
  191. data/test/cms_seeds/test.host/layouts/nested.yml +4 -0
  192. data/test/cms_seeds/test.host/pages/broken.yml +1 -0
  193. data/test/cms_seeds/test.host/pages/child/subchild.yml +10 -0
  194. data/test/cms_seeds/test.host/pages/child.yml +10 -0
  195. data/test/cms_seeds/test.host/pages/index.yml +10 -0
  196. data/test/cms_seeds/test.host/snippets/broken.yml +1 -0
  197. data/test/cms_seeds/test.host/snippets/default.yml +3 -0
  198. data/test/fixtures/cms_blocks.yml +12 -0
  199. data/test/fixtures/cms_layouts.yml +36 -0
  200. data/test/fixtures/cms_pages.yml +39 -0
  201. data/test/fixtures/cms_sites.yml +3 -0
  202. data/test/fixtures/cms_snippets.yml +5 -0
  203. data/test/fixtures/cms_upload_dirs.yml +9 -0
  204. data/test/fixtures/cms_uploads.yml +4 -0
  205. data/test/fixtures/cms_users.yml +11 -0
  206. data/test/fixtures/files/invalid_file.gif +9 -0
  207. data/test/fixtures/files/valid_image.jpg +0 -0
  208. data/test/fixtures/views/_nav_hook.html.erb +1 -0
  209. data/test/fixtures/views/_nav_hook_2.html.erb +1 -0
  210. data/test/functional/cms_admin/layouts_controller_test.rb +103 -0
  211. data/test/functional/cms_admin/pages_controller_test.rb +334 -0
  212. data/test/functional/cms_admin/sites_controller_test.rb +99 -0
  213. data/test/functional/cms_admin/snippets_controller_test.rb +102 -0
  214. data/test/functional/cms_admin/uploads_controller_test.rb +26 -0
  215. data/test/functional/cms_content_controller_test.rb +134 -0
  216. data/test/integration/rake_tasks_test.rb +65 -0
  217. data/test/integration/render_cms_seed_test.rb +34 -0
  218. data/test/integration/render_cms_test.rb +81 -0
  219. data/test/integration/sites_test.rb +63 -0
  220. data/test/integration/view_hooks_test.rb +33 -0
  221. data/test/test_helper.rb +86 -0
  222. data/test/unit/cms_block_test.rb +43 -0
  223. data/test/unit/cms_configuration_test.rb +17 -0
  224. data/test/unit/cms_layout_test.rb +146 -0
  225. data/test/unit/cms_page_test.rb +257 -0
  226. data/test/unit/cms_site_test.rb +41 -0
  227. data/test/unit/cms_snippet_test.rb +77 -0
  228. data/test/unit/cms_tag_test.rb +206 -0
  229. data/test/unit/cms_tags/field_datetime_test.rb +34 -0
  230. data/test/unit/cms_tags/field_integer_test.rb +33 -0
  231. data/test/unit/cms_tags/field_string_test.rb +34 -0
  232. data/test/unit/cms_tags/field_text_test.rb +32 -0
  233. data/test/unit/cms_tags/helper_test.rb +38 -0
  234. data/test/unit/cms_tags/page_datetime_test.rb +34 -0
  235. data/test/unit/cms_tags/page_integer_test.rb +33 -0
  236. data/test/unit/cms_tags/page_rich_text.rb +33 -0
  237. data/test/unit/cms_tags/page_string_test.rb +33 -0
  238. data/test/unit/cms_tags/page_text_test.rb +34 -0
  239. data/test/unit/cms_tags/partial_test.rb +44 -0
  240. data/test/unit/cms_tags/snippet_test.rb +33 -0
  241. data/test/unit/cms_upload_dir_test.rb +8 -0
  242. data/test/unit/cms_upload_test.rb +26 -0
  243. data/test/unit/cms_user_test.rb +8 -0
  244. data/test/unit/view_methods_test.rb +21 -0
  245. metadata +488 -0
@@ -0,0 +1,204 @@
1
+ $.CMS = function(){
2
+ var current_path = window.location.pathname;
3
+ var admin_path_prefix = current_path.split('/')[1]
4
+ var current_id = current_path.split('/')[3]
5
+ $(function(){
6
+
7
+ $.CMS.slugify();
8
+ $.CMS.tree_methods();
9
+ $.CMS.load_page_blocks();
10
+ $.CMS.enable_rich_text();
11
+ $.CMS.enable_codemirror();
12
+ $.CMS.enable_date_picker();
13
+ $.CMS.enable_desc_toggle();
14
+ $.CMS.enable_sortable_list();
15
+ if($('form.new_cms_page, form.edit_cms_page').get(0)) $.CMS.enable_page_save_form();
16
+ if($('#page_save').get(0)) $.CMS.enable_page_save_widget();
17
+ if($('#uploader_button').get(0)) $.CMS.enable_uploader();
18
+ });
19
+
20
+ return {
21
+
22
+ enable_sortable_list: function(){
23
+ $('ul.sortable, ul.sortable ul').sortable({
24
+ handle: 'div.dragger',
25
+ axis: 'y',
26
+ update: function(){
27
+ $.post(current_path + '/reorder', '_method=put&'+$(this).sortable('serialize'));
28
+ }
29
+ })
30
+ },
31
+
32
+ slugify: function(){
33
+ $('input#slugify').bind('keyup.cms', function() {
34
+ $('input#slug').val( slugify( $(this).val() ) );
35
+ });
36
+
37
+ function slugify(str){
38
+ str = str.replace(/^\s+|\s+$/g, '');
39
+ var from = "ÀÁÄÂÈÉËÊÌÍÏÎÒÓÖÔÙÚÜÛàáäâèéëêìíïîòóöôùúüûÑñÇç·/_,:;";
40
+ var to = "aaaaeeeeiiiioooouuuuaaaaeeeeiiiioooouuuunncc------";
41
+ for (var i=0, l=from.length ; i<l ; i++) {
42
+ str = str.replace(new RegExp(from[i], "g"), to[i]);
43
+ }
44
+ str = str.replace(/[^a-zA-Z0-9 -]/g, '').replace(/\s+/g, '-').toLowerCase();
45
+ return str;
46
+ }
47
+ },
48
+
49
+ // Load Page Blocks on layout change
50
+ load_page_blocks: function(){
51
+ $('select#cms_page_cms_layout_id').bind('change.cms', function() {
52
+ $.ajax({
53
+ url: ['/' + admin_path_prefix, 'pages', $(this).attr('data-page-id'), 'form_blocks'].join('/'),
54
+ data: ({
55
+ layout_id: $(this).val()
56
+ }),
57
+ complete: function(){
58
+ $.CMS.enable_rich_text();
59
+ $.CMS.enable_date_picker();
60
+ }
61
+ })
62
+ });
63
+ },
64
+
65
+ enable_rich_text: function(){
66
+ $('textarea.rich_text').tinymce({
67
+ theme : "advanced",
68
+ plugins: "",
69
+ theme_advanced_buttons1 : "formatselect,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,bullist,numlist,|,link,unlink,anchor,image,|,code",
70
+ theme_advanced_buttons2 : "",
71
+ theme_advanced_buttons3 : "",
72
+ theme_advanced_buttons4 : "",
73
+ theme_advanced_toolbar_location : "top",
74
+ theme_advanced_toolbar_align : "left",
75
+ theme_advanced_statusbar_location : "bottom",
76
+ theme_advanced_resizing : true,
77
+ theme_advanced_resize_horizontal : false
78
+ });
79
+ },
80
+
81
+ enable_codemirror: function(){
82
+ $('textarea.code').each(function(i, element){
83
+ CodeMirror.fromTextArea(element, {
84
+ basefiles: [
85
+ "/javascripts/LucyCMS/codemirror/codemirror_base.js",
86
+ "/javascripts/LucyCMS/codemirror/parse_xml.js",
87
+ "/javascripts/LucyCMS/codemirror/parse_css.js",
88
+ "/javascripts/LucyCMS/codemirror/parse_js.js",
89
+ "/javascripts/LucyCMS/codemirror/parse_html_mixed.js"
90
+ ],
91
+ stylesheet: "/javascripts/LucyCMS/codemirror/codemirror.css"
92
+ });
93
+ });
94
+
95
+ $('textarea.code_css').each(function(i, element){
96
+ CodeMirror.fromTextArea(element, {
97
+ basefiles: [
98
+ "/javascripts/LucyCMS/codemirror/codemirror_base.js",
99
+ "/javascripts/LucyCMS/codemirror/parse_css.js"
100
+ ],
101
+ stylesheet: "/javascripts/LucyCMS/codemirror/codemirror.css"
102
+ });
103
+ });
104
+
105
+ $('textarea.code_js').each(function(i, element){
106
+ CodeMirror.fromTextArea(element, {
107
+ basefiles: [
108
+ "/javascripts/LucyCMS/codemirror/codemirror_base.js",
109
+ "/javascripts/LucyCMS/codemirror/parse_js.js"
110
+ ],
111
+ stylesheet: "/javascripts/LucyCMS/codemirror/codemirror.css"
112
+ });
113
+ });
114
+ },
115
+
116
+ enable_date_picker: function(){
117
+ $('input[type=datetime]').datepicker();
118
+ },
119
+
120
+ enable_desc_toggle: function(){
121
+ $('.form_element .desc .desc_toggle').click(function(){
122
+ $(this).toggle();
123
+ $(this).siblings('.desc_content').toggle();
124
+ })
125
+ },
126
+
127
+ tree_methods: function(){
128
+ $('a.tree_toggle').bind('click.cms', function() {
129
+ $(this).siblings('ul').toggle();
130
+ $(this).toggleClass('closed');
131
+ // object_id are set in the helper (check cms_helper.rb)
132
+ $.ajax({url: [current_path, object_id, 'toggle'].join('/')});
133
+ });
134
+
135
+ $('ul.sortable').each(function(){
136
+ $(this).sortable({
137
+ handle: 'div.dragger',
138
+ axis: 'y',
139
+ update: function() {
140
+ $.post(current_path + '/reorder', '_method=put&'+$(this).sortable('serialize'));
141
+ }
142
+ })
143
+ });
144
+ },
145
+
146
+ enable_page_save_widget : function(){
147
+ $('#page_save input').attr('checked', $('input#cms_page_is_published').is(':checked'));
148
+ $('#page_save a').html($('input#cms_page_submit').val());
149
+
150
+ $('#page_save a').bind('click', function(){
151
+ $('input#cms_page_is_published').attr('checked', $(this).is(':checked'));
152
+ })
153
+ $('input#cms_page_is_published').bind('click', function(){
154
+ $('#page_save a').attr('checked', $(this).is(':checked'));
155
+ })
156
+ $('#page_save a').bind('click', function(){
157
+ $('input#cms_page_submit').click();
158
+ })
159
+ },
160
+
161
+ enable_page_save_form : function(){
162
+ $('input[name=commit]').click(function() {
163
+ $(this).parents('form').attr('target', '');
164
+ });
165
+ $('input[name=preview]').click(function() {
166
+ $(this).parents('form').attr('target', '_blank');
167
+ });
168
+ },
169
+
170
+ enable_uploader : function(){
171
+ auth_token = $("meta[name=csrf-token]").attr('content');
172
+ var uploader = new plupload.Uploader({
173
+ container: 'file_uploads',
174
+ browse_button: 'uploader_button',
175
+ runtimes: 'html5',
176
+ unique_names: true,
177
+ multipart: true,
178
+ multipart_params: { authenticity_token: auth_token, format: 'js' },
179
+ url: '/' + admin_path_prefix + '/upload_dirs/' + current_id + '/uploads'
180
+ });
181
+ uploader.init();
182
+ uploader.bind('FilesAdded', function(up, files) {
183
+ $.each(files, function(i, file){
184
+ $('#uploaded_files').prepend(
185
+ '<li id="cms_upload_' + file.id + '">' +
186
+ '<div class="item">' +
187
+ '<div class="icon"></div>' +
188
+ '<div class="label">' + file.name + ' (Uploading, Please Wait...)</div>' +
189
+ '</div>' +
190
+ '</li>'
191
+ );
192
+ });
193
+ uploader.start();
194
+ });
195
+ uploader.bind('Error', function(up, err) {
196
+ alert('File Upload failed')
197
+ });
198
+ uploader.bind('FileUploaded', function(up, file, response){
199
+ $('#cms_upload_' + file.id).replaceWith(response.response);
200
+ });
201
+ }
202
+
203
+ }
204
+ }();
@@ -0,0 +1,102 @@
1
+ html {
2
+ cursor: text;
3
+ }
4
+ .editbox {
5
+ margin: .4em;
6
+ padding: 0;
7
+ font: 13px 'Courier New', Courier, monospace;
8
+ color: #000;
9
+ }
10
+ .editbox p {
11
+ margin: 0;
12
+ }
13
+
14
+ span.xml-tagname {
15
+ color: #A0B;
16
+ }
17
+ span.xml-attribute {
18
+ color: #281;
19
+ }
20
+ span.xml-punctuation {
21
+ color: black;
22
+ }
23
+ span.xml-attname {
24
+ color: #00F;
25
+ }
26
+ span.xml-comment {
27
+ color: #A70;
28
+ }
29
+ span.xml-cdata {
30
+ color: #48A;
31
+ }
32
+ span.xml-processing {
33
+ color: #999;
34
+ }
35
+ span.xml-entity {
36
+ color: #A22;
37
+ }
38
+ span.xml-error {
39
+ color: #F00 !important;
40
+ }
41
+ span.xml-text {
42
+ color: black;
43
+ }
44
+
45
+ span.css-at {
46
+ color: #708;
47
+ }
48
+ span.css-unit {
49
+ color: #281;
50
+ }
51
+ span.css-value {
52
+ color: #708;
53
+ }
54
+ span.css-identifier {
55
+ color: black;
56
+ }
57
+ span.css-selector {
58
+ color: #11B;
59
+ }
60
+ span.css-important {
61
+ color: #00F;
62
+ }
63
+ span.css-colorcode {
64
+ color: #299;
65
+ }
66
+ span.css-comment {
67
+ color: #A70;
68
+ }
69
+ span.css-string {
70
+ color: #A22;
71
+ }
72
+
73
+ span.js-punctuation {
74
+ color: #666666;
75
+ }
76
+ span.js-operator {
77
+ color: #666666;
78
+ }
79
+ span.js-keyword {
80
+ color: #770088;
81
+ }
82
+ span.js-atom {
83
+ color: #228811;
84
+ }
85
+ span.js-variable {
86
+ color: black;
87
+ }
88
+ span.js-variabledef {
89
+ color: #0000FF;
90
+ }
91
+ span.js-localvariable {
92
+ color: #004499;
93
+ }
94
+ span.js-property {
95
+ color: black;
96
+ }
97
+ span.js-comment {
98
+ color: #AA7700;
99
+ }
100
+ span.js-string {
101
+ color: #AA2222;
102
+ }
@@ -0,0 +1,23 @@
1
+ var CodeMirrorConfig=window.CodeMirrorConfig||{},CodeMirror=function(){function D(a,b){for(var c in b)a.hasOwnProperty(c)||(a[c]=b[c])}function E(a,b){for(var c=0;c<a.length;c++)b(a[c])}function s(a){return document.createElementNS&&document.documentElement.namespaceURI!==null?document.createElementNS("http://www.w3.org/1999/xhtml",a):document.createElement(a)}function F(a,b){var c=s("div"),d=s("div");c.style.position="absolute";c.style.height="100%";if(c.style.setExpression)try{c.style.setExpression("height",
2
+ "this.previousSibling.offsetHeight + 'px'")}catch(h){}c.style.top="0px";c.style.left="0px";c.style.overflow="hidden";a.appendChild(c);d.className="CodeMirror-line-numbers";c.appendChild(d);d.innerHTML="<div>"+b+"</div>";return c}function G(a){if(typeof a.parserfile=="string")a.parserfile=[a.parserfile];if(typeof a.basefiles=="string")a.basefiles=[a.basefiles];if(typeof a.stylesheet=="string")a.stylesheet=[a.stylesheet];var b=['<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html><head>'];
3
+ b.push('<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7"/>');var c=a.noScriptCaching?"?nocache="+(new Date).getTime().toString(16):"";E(a.stylesheet,function(d){b.push('<link rel="stylesheet" type="text/css" href="'+d+c+'"/>')});E(a.basefiles.concat(a.parserfile),function(d){/^https?:/.test(d)||(d=a.path+d);b.push('<script type="text/javascript" src="'+d+c+'"><\/script>')});b.push('</head><body style="border-width: 0;" class="editbox" spellcheck="'+(a.disableSpellcheck?"false":"true")+'"></body></html>');
4
+ return b.join("")}function t(a,b){this.options=b=b||{};D(b,CodeMirrorConfig);if(b.dumbTabs)b.tabMode="spaces";else if(b.normalTab)b.tabMode="default";if(b.cursorActivity)b.onCursorActivity=b.cursorActivity;var c=this.frame=s("iframe");if(b.iframeClass)c.className=b.iframeClass;c.frameBorder=0;c.style.border="0";c.style.width="100%";c.style.height="100%";c.style.display="block";var d=this.wrapping=s("div");d.style.position="relative";d.className="CodeMirror-wrapping";d.style.width=b.width;d.style.height=
5
+ b.height=="dynamic"?b.minHeight+"px":b.height;var h=this.textareaHack=s("textarea");d.appendChild(h);h.style.position="absolute";h.style.left="-10000px";h.style.width="10px";h.tabIndex=1E5;c.CodeMirror=this;if(b.domain&&H){this.html=G(b);c.src="javascript:(function(){document.open();"+(b.domain?'document.domain="'+b.domain+'";':"")+"document.write(window.frameElement.CodeMirror.html);document.close();})()"}else c.src="javascript:;";a.appendChild?a.appendChild(d):a(d);d.appendChild(c);if(b.lineNumbers)this.lineNumbers=
6
+ F(d,b.firstLineNumber);this.win=c.contentWindow;if(!b.domain||!H){this.win.document.open();this.win.document.write(G(b));this.win.document.close()}}D(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:false,saveFunction:null,onLoad:null,onChange:null,undoDepth:50,undoDelay:800,disableSpellcheck:true,textWrapping:true,
7
+ readOnly:false,width:"",height:"300px",minHeight:100,autoMatchParens:false,markParen:null,unmarkParen:null,parserConfig:null,tabMode:"indent",enterMode:"indent",electricChars:true,reindentOnLoad:false,activeTokens:null,onCursorActivity:null,lineNumbers:false,firstLineNumber:1,onLineNumberClick:null,indentUnit:2,domain:null,noScriptCaching:false,incrementalLoading:false});var H=document.selection&&window.ActiveXObject&&/MSIE/.test(navigator.userAgent);t.prototype={init:function(){this.options.initCallback&&
8
+ 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)},
9
+ 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 true},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()},
10
+ 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){if(typeof a==="string")a=[a];for(var b={},c={},d=this.win.document.getElementsByTagName("link"),h=0,
11
+ e;e=d[h];h++)if(e.rel.indexOf("stylesheet")!==-1)for(var f=0;f<a.length;f++){var n=a[f];if(e.href.substring(e.href.length-n.length)===n){b[e.href]=true;c[n]=true}}for(h=0;e=d[h];h++)if(e.rel.indexOf("stylesheet")!==-1)e.disabled=!(e.href in b);for(f=0;f<a.length;f++){n=a[f];if(!(n in c)){e=this.win.document.createElement("link");e.rel="stylesheet";e.type="text/css";e.href=n;this.win.document.getElementsByTagName("head")[0].appendChild(e)}}},setTextWrapping:function(a){if(a!=this.options.textWrapping){this.win.document.body.style.whiteSpace=
12
+ a?"":"nowrap";this.options.textWrapping=a;if(this.lineNumbers){this.setLineNumbers(false);this.setLineNumbers(true)}}},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){if(a&&!this.lineNumbers){this.lineNumbers=F(this.wrapping,this.options.firstLineNumber);this.activateLineNumbers()}else if(!a&&this.lineNumbers){this.wrapping.removeChild(this.lineNumbers);
13
+ 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)},
14
+ 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){for(var b=this.firstLine();a>1&&b!==false;a--)b=this.nextLine(b);return b},lineNumber:function(a){for(var b=0;a!==false;){b++;a=this.prevLine(a)}return b},jumpToLine:function(a){if(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},
15
+ cursorCoords:function(a){return this.editor.cursorCoords(a)},activateLineNumbers:function(){function a(){if(e.offsetWidth!=0){for(var g=e;g.parentNode;g=g.parentNode);if(!i.parentNode||g!=document||!f.Editor){try{z()}catch(k){}clearInterval(J)}else if(i.offsetWidth!=A){A=i.offsetWidth;e.parentNode.style.paddingLeft=A+"px"}}}function b(){i.scrollTop=q.scrollTop||n.documentElement.scrollTop||0}function c(g){var k=l.firstChild.offsetHeight;if(k!=0){k=Math.ceil((50+Math.max(q.offsetHeight,Math.max(e.offsetHeight,
16
+ q.scrollHeight||0)))/k);for(var o=l.childNodes.length;o<=k;o++){var w=s("div");w.appendChild(document.createTextNode(g?String(o+j.options.firstLineNumber):"\u00a0"));l.appendChild(w)}}}function d(){function g(){c(true);b()}j.updateNumbers=g;var k=f.addEventHandler(f,"scroll",b,true),o=f.addEventHandler(f,"resize",g,true);z=function(){k();o();if(j.updateNumbers==g)j.updateNumbers=null};g()}function h(){function g(p,B){r||(r=l.appendChild(s("div")));I&&I(r,B,p);u.push(r);u.push(p);x=r.offsetHeight+
17
+ r.offsetTop;r=r.nextSibling}function k(){for(var p=0;p<u.length;p+=2)u[p].innerHTML=u[p+1];u=[]}function o(){if(!(!l.parentNode||l.parentNode!=j.lineNumbers)){for(var p=(new Date).getTime()+j.options.lineNumberTime;m;){for(g(C++,m.previousSibling);m&&!f.isBR(m);m=m.nextSibling)for(var B=m.offsetTop+m.offsetHeight;l.offsetHeight&&B-3>x;){var K=x;g("&nbsp;");if(x<=K)break}if(m)m=m.nextSibling;if((new Date).getTime()>p){k();v=setTimeout(o,j.options.lineNumberDelay);return}}for(;r;)g(C++);k();b()}}function w(p){b();
18
+ c(p);m=q.firstChild;r=l.firstChild;x=0;C=j.options.firstLineNumber;o()}function y(){v&&clearTimeout(v);if(j.editor.allClean())w();else v=setTimeout(y,200)}var m,r,C,x,u=[],I=j.options.styleNumbers;w(true);var v=null;j.updateNumbers=y;var L=f.addEventHandler(f,"scroll",b,true),M=f.addEventHandler(f,"resize",y,true);z=function(){v&&clearTimeout(v);if(j.updateNumbers==y)j.updateNumbers=null;L();M()}}var e=this.frame,f=e.contentWindow,n=f.document,q=n.body,i=this.lineNumbers,l=i.firstChild,j=this,A=null;
19
+ i.onclick=function(g){var k=j.options.onLineNumberClick;if(k){g=(g||window.event).target||(g||window.event).srcElement;var o=g==i?NaN:Number(g.innerHTML);isNaN(o)||k(o,g)}};var z=function(){};a();var J=setInterval(a,500);(this.options.textWrapping||this.options.styleNumbers?h:d)()},setDynamicHeight:function(){function a(){for(var q=0,i=h.lastChild,l;i&&d.isBR(i);){i.hackBR||q++;i=i.previousSibling}if(i){e=i.offsetHeight;l=i.offsetTop+(1+q)*e}else if(e)l=q*e;if(l)b.wrapping.style.height=Math.max(n+
20
+ l,b.options.minHeight)+"px"}var b=this,c=b.options.onCursorActivity,d=b.win,h=d.document.body,e=null,f=null,n=2*b.frame.offsetTop;h.style.overflowY="hidden";d.document.documentElement.style.overflowY="hidden";this.frame.scrolling="no";setTimeout(a,300);b.options.onCursorActivity=function(q){c&&c(q);clearTimeout(f);f=setTimeout(a,100)}}};t.InvalidLineHandle={toString:function(){return"CodeMirror.InvalidLineHandle"}};t.replace=function(a){if(typeof a=="string")a=document.getElementById(a);return function(b){a.parentNode.replaceChild(b,
21
+ a)}};t.fromTextArea=function(a,b){function c(){a.value=e.getCode()}if(typeof a=="string")a=document.getElementById(a);b=b||{};if(a.style.width&&b.width==null)b.width=a.style.width;if(a.style.height&&b.height==null)b.height=a.style.height;if(b.content==null)b.content=a.value;if(a.form){typeof a.form.addEventListener=="function"?a.form.addEventListener("submit",c,false):a.form.attachEvent("onsubmit",c);var d=a.form.submit,h=function(){c();a.form.submit=d;a.form.submit();a.form.submit=h};a.form.submit=
22
+ h}a.style.display="none";var e=new t(function(f){a.nextSibling?a.parentNode.insertBefore(f,a.nextSibling):a.parentNode.appendChild(f)},b);e.save=c;e.toTextArea=function(){c();a.parentNode.removeChild(e.wrapping);a.style.display="";if(a.form){a.form.submit=d;typeof a.form.removeEventListener=="function"?a.form.removeEventListener("submit",c,false):a.form.detachEvent("onsubmit",c)}};return e};t.isProbablySupported=function(){var a;return window.opera?Number(window.opera.version())>=9.52:/Apple Computer, Inc/.test(navigator.vendor)&&
23
+ (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 t}();
@@ -0,0 +1,88 @@
1
+ function method(f,l){return function(){f[l].apply(f,arguments)}}var StopIteration={toString:function(){return"StopIteration"}};function forEach(f,l){if(f.next)try{for(;;)l(f.next())}catch(k){if(k!=StopIteration)throw k;}else for(var m=0;m<f.length;m++)l(f[m])}function map(f,l){var k=[];forEach(f,function(m){k.push(l(m))});return k}function matcher(f){return function(l){return f.test(l)}}function hasClass(f,l){var k=f.className;return k&&RegExp("(^| )"+l+"($| )").test(k)}
2
+ function removeClass(f,l){f.className=f.className.replace(RegExp(" "+l+"\\b","g"),"");return f}function insertAfter(f,l){l.parentNode.insertBefore(f,l.nextSibling);return f}function removeElement(f){f.parentNode&&f.parentNode.removeChild(f)}function clearElement(f){for(;f.firstChild;)f.removeChild(f.firstChild)}function isAncestor(f,l){for(;l=l.parentNode;)if(f==l)return true;return false}var nbsp="\u00a0",matching={"{":"}","[":"]","(":")","}":"{","]":"[",")":"("};
3
+ function normalizeEvent(f){if(!f.stopPropagation){f.stopPropagation=function(){this.cancelBubble=true};f.preventDefault=function(){this.returnValue=false}}if(!f.stop)f.stop=function(){this.stopPropagation();this.preventDefault()};if(f.type=="keypress"){f.code=f.charCode==null?f.keyCode:f.charCode;f.character=String.fromCharCode(f.code)}return f}
4
+ function addEventHandler(f,l,k,m){function q(p){k(normalizeEvent(p||window.event))}if(typeof f.addEventListener=="function"){f.addEventListener(l,q,false);if(m)return function(){f.removeEventListener(l,q,false)}}else{f.attachEvent("on"+l,q);if(m)return function(){f.detachEvent("on"+l,q)}}}function nodeText(f){return f.textContent||f.innerText||f.nodeValue||""}function nodeTop(f){for(var l=0;f.offsetParent;){l+=f.offsetTop;f=f.offsetParent}return l}
5
+ function isBR(f){f=f.nodeName;return f=="BR"||f=="br"}function isSpan(f){f=f.nodeName;return f=="SPAN"||f=="span"};var stringStream=function(f){function l(){for(;m==k.length;){q+=k;k="";m=0;try{k=f.next()}catch(p){if(p!=StopIteration)throw p;else return false}}return true}var k="",m=0,q="";return{peek:function(){if(!l())return null;return k.charAt(m)},next:function(){if(!l())if(q.length>0)throw"End of stringstream reached without emptying buffer ('"+q+"').";else throw StopIteration;return k.charAt(m++)},get:function(){var p=q;q="";if(m>0){p+=k.slice(0,m);k=k.slice(m);m=0}return p},push:function(p){k=k.slice(0,
6
+ m)+p+k.slice(m)},lookAhead:function(p,w,a,d){function g(i){return d?i.toLowerCase():i}p=g(p);var b=false,c=q,e=m;for(a&&this.nextWhileMatches(/[\s\u00a0]/);;){a=m+p.length;var h=k.length-m;if(a<=k.length){b=p==g(k.slice(m,a));m=a;break}else if(p.slice(0,h)==g(k.slice(m))){q+=k;k="";try{k=f.next()}catch(j){if(j!=StopIteration)throw j;break}m=0;p=p.slice(h)}else break}if(!(b&&w)){k=q.slice(c.length)+k;m=e;q=c}return b},lookAheadRegex:function(p,w){if(p.source.charAt(0)!="^")throw Error("Regexps passed to lookAheadRegex must start with ^");
7
+ for(;k.indexOf("\n",m)==-1;)try{k+=f.next()}catch(a){if(a!=StopIteration)throw a;break}var d=k.slice(m).match(p);if(d&&w)m+=d[0].length;return d},more:function(){return this.peek()!==null},applies:function(p){var w=this.peek();return w!==null&&p(w)},nextWhile:function(p){for(var w;(w=this.peek())!==null&&p(w);)this.next()},matches:function(p){var w=this.peek();return w!==null&&p.test(w)},nextWhileMatches:function(p){for(var w;(w=this.peek())!==null&&p.test(w);)this.next()},equals:function(p){return p===
8
+ this.peek()},endOfLine:function(){var p=this.peek();return p==null||p=="\n"}}};var select={};
9
+ (function(){function f(b,c){for(;b&&b.parentNode!=c;)b=b.parentNode;return b}function l(b,c){for(;!b.previousSibling&&b.parentNode!=c;)b=b.parentNode;return f(b.previousSibling,c)}function k(b){var c=b.nextSibling;if(c){for(;c.firstChild;)c=c.firstChild;return c.nodeType==3||isBR(c)?c:k(c)}else{for(b=b.parentNode;b&&!b.nextSibling;)b=b.parentNode;return b&&k(b)}}select.ie_selection=document.selection&&document.selection.createRangeCollection;select.scrollToNode=function(b,c){if(b){for(var e=b,h=document.body,
10
+ j=document.documentElement,i=!e.nextSibling||!e.nextSibling.nextSibling||!e.nextSibling.nextSibling.nextSibling,n=0;e&&!e.offsetTop;){n++;e=e.previousSibling}if(n==0)i=false;if(!(webkit&&e&&e.offsetTop==5&&e.offsetLeft==5)){n=n*(e?e.offsetHeight:0);var r=0,t=b?b.offsetWidth:0;for(e=e;e&&e.offsetParent;){n+=e.offsetTop;isBR(e)||(r+=e.offsetLeft);e=e.offsetParent}e=h.scrollLeft||j.scrollLeft||0;h=h.scrollTop||j.scrollTop||0;var o=false,u=window.innerWidth||j.clientWidth||0;if(c||t<u){if(c){var x=select.offsetInNode(b),
11
+ s=nodeText(b).length;if(s)r+=t*(x/s)}t=r-e;if(t<0||t>u){e=r;o=true}}r=n-h;if(r<0||i||r>(window.innerHeight||j.clientHeight||0)-50){h=i?1E6:n;o=true}o&&window.scrollTo(e,h)}}};select.scrollToCursor=function(b){select.scrollToNode(select.selectionTopNode(b,true)||b.firstChild,true)};var m=null;select.snapshotChanged=function(){if(m)m.changed=true};select.snapshotReplaceNode=function(b,c,e,h){function j(i){if(b==i.node){m.changed=true;if(e&&i.offset>e)i.offset-=e;else{i.node=c;i.offset+=h||0}}else if(select.ie_selection&&
12
+ i.offset==0&&i.node==k(b))m.changed=true}if(m){j(m.start);j(m.end)}};select.snapshotMove=function(b,c,e,h,j){function i(n){if(b==n.node&&(!j||n.offset==0)){m.changed=true;n.node=c;n.offset=h?Math.max(0,n.offset+e):e}}if(m){i(m.start);i(m.end)}};if(select.ie_selection){var q=function(){var b=document.selection;return b&&(b.createRange||b.createTextRange)()},p=function(b){function c(t){for(var o=null;!o&&t;){o=t.nextSibling;t=t.parentNode}return e(o)}function e(t){for(;t&&t.firstChild;)t=t.firstChild;
13
+ return{node:t,offset:0}}var h=q();h.collapse(b);b=h.parentElement();if(!isAncestor(document.body,b))return null;if(!b.firstChild)return e(b);var j=h.duplicate();j.moveToElementText(b);j.collapse(true);for(var i=b.firstChild;i;i=i.nextSibling){if(i.nodeType==3){var n=i.nodeValue.length;j.move("character",n)}else{j.moveToElementText(i);j.collapse(false)}var r=h.compareEndPoints("StartToStart",j);if(r==0)return c(i);if(r!=1){if(i.nodeType!=3)return e(i);j.setEndPoint("StartToEnd",h);return{node:i,offset:n-
14
+ j.text.length}}}return c(b)};select.markSelection=function(){m=null;if(document.selection){var b=p(true),c=p(false);if(b&&c)m={start:b,end:c,changed:false}}};select.selectMarked=function(){function b(h){var j=document.body.createTextRange(),i=h.node;if(i)if(i.nodeType==3){j.moveToElementText(i.parentNode);for(h=h.offset;i.previousSibling;){i=i.previousSibling;h+=(i.innerText||"").length}j.move("character",h)}else{j.moveToElementText(i);j.collapse(true)}else{j.moveToElementText(document.body);j.collapse(false)}return j}
15
+ if(m&&m.changed){var c=b(m.start),e=b(m.end);c.setEndPoint("StartToEnd",e);c.select()}};select.offsetInNode=function(b){var c=q();if(!c)return 0;var e=c.duplicate();try{e.moveToElementText(b)}catch(h){return 0}c.setEndPoint("StartToStart",e);return c.text.length};select.selectionTopNode=function(b,c){function e(o,u){if(u.nodeType==3){for(var x=0,s=u.previousSibling;s&&s.nodeType==3;){x+=s.nodeValue.length;s=s.previousSibling}if(s){try{o.moveToElementText(s)}catch(v){return false}o.collapse(false)}else o.moveToElementText(u.parentNode);
16
+ x&&o.move("character",x)}else try{o.moveToElementText(u)}catch(y){return false}return true}var h=q();if(!h)return false;var j=h.duplicate();h.collapse(c);var i=h.parentElement();if(i&&isAncestor(b,i)){j.moveToElementText(i);if(h.compareEndPoints("StartToStart",j)==1)return f(i,b)}c=0;for(i=b.childNodes.length-1;c<i;){var n=Math.ceil((i+c)/2),r=b.childNodes[n];if(!r)return false;if(!e(j,r))return false;if(h.compareEndPoints("StartToStart",j)==1)c=n;else i=n-1}if(c==0){h=q();j=h.duplicate();try{j.moveToElementText(b)}catch(t){return null}if(h.compareEndPoints("StartToStart",
17
+ j)==0)return null}return b.childNodes[c]||null};select.focusAfterNode=function(b,c){var e=document.body.createTextRange();e.moveToElementText(b||c);e.collapse(!b);e.select()};select.somethingSelected=function(){var b=q();return b&&b.text!=""};var w=function(b){var c=q();if(c){c.pasteHTML(b);c.collapse(false);c.select()}};select.insertNewlineAtCursor=function(){w("<br>")};select.insertTabAtCursor=function(){w("\u00a0\u00a0\u00a0\u00a0")};select.cursorPos=function(b,c){var e=q();if(!e)return null;for(var h=
18
+ select.selectionTopNode(b,c);h&&!isBR(h);)h=h.previousSibling;var j=e.duplicate();e.collapse(c);if(h){j.moveToElementText(h);j.collapse(false)}else{try{j.moveToElementText(b)}catch(i){return null}j.collapse(true)}e.setEndPoint("StartToStart",j);return{node:h,offset:e.text.length}};select.setCursorPos=function(b,c,e){function h(i){var n=document.body.createTextRange();if(i.node){n.moveToElementText(i.node);n.collapse(false)}else{n.moveToElementText(b);n.collapse(true)}n.move("character",i.offset);
19
+ return n}var j=h(c);e&&e!=c&&j.setEndPoint("EndToEnd",h(e));j.select()};select.getBookmark=function(b){var c=select.cursorPos(b,true);b=select.cursorPos(b,false);if(c&&b)return{from:c,to:b}};select.setBookmark=function(b,c){c&&select.setCursorPos(b,c.from,c.to)}}else{var a=function(b,c){for(;b.nodeType!=3&&!isBR(b);){var e=b.childNodes[c]||b.nextSibling;for(c=0;!e&&b.parentNode;){b=b.parentNode;e=b.nextSibling}b=e;if(!e)break}return{node:b,offset:c}};select.markSelection=function(){var b=window.getSelection();
20
+ if(!b||b.rangeCount==0)return m=null;b=b.getRangeAt(0);m={start:a(b.startContainer,b.startOffset),end:a(b.endContainer,b.endOffset),changed:false}};select.selectMarked=function(){function b(){if(e.start.node==e.end.node&&e.start.offset==e.end.offset){var j=window.getSelection();if(!j||j.rangeCount==0)return true;j=j.getRangeAt(0);j=a(j.startContainer,j.startOffset);return e.start.node!=j.node||e.start.offset!=j.offset}}function c(j,i){if(j.node)j.offset==0?h["set"+i+"Before"](j.node):h["set"+i](j.node,
21
+ j.offset);else h.setStartAfter(document.body.lastChild||document.body)}var e=m;if(e&&(e.changed||webkit&&b())){var h=document.createRange();c(e.end,"End");c(e.start,"Start");d(h)}};var d=function(b){var c=window.getSelection();if(c){c.removeAllRanges();c.addRange(b)}},g=function(){var b=window.getSelection();return!b||b.rangeCount==0?false:b.getRangeAt(0)};select.selectionTopNode=function(b,c){var e=g();if(!e)return false;var h=c?e.startContainer:e.endContainer,j=c?e.startOffset:e.endOffset;window.opera&&
22
+ !c&&e.endContainer==b&&e.endOffset==e.startOffset+1&&b.childNodes[e.startOffset]&&isBR(b.childNodes[e.startOffset])&&j--;return h.nodeType==3?j>0?f(h,b):l(h,b):h.nodeName.toUpperCase()=="HTML"?j==1?null:b.lastChild:h==b?j==0?null:h.childNodes[j-1]:j==h.childNodes.length?f(h,b):j==0?l(h,b):f(h.childNodes[j-1],b)};select.focusAfterNode=function(b,c){var e=document.createRange();e.setStartBefore(c.firstChild||c);if(b&&!b.firstChild)e.setEndAfter(b);else b?e.setEnd(b,b.childNodes.length):e.setEndBefore(c.firstChild||
23
+ c);e.collapse(false);d(e)};select.somethingSelected=function(){var b=g();return b&&!b.collapsed};select.offsetInNode=function(b){var c=g();if(!c)return 0;c=c.cloneRange();c.setStartBefore(b);return c.toString().length};select.insertNodeAtCursor=function(b){var c=g();if(c){c.deleteContents();c.insertNode(b);webkitLastLineHack(document.body);if(window.opera&&isBR(b)&&isSpan(b.parentNode)){c=b.nextSibling;var e=b.parentNode,h=e.parentNode;h.insertBefore(b,e.nextSibling);for(e="";c&&c.nodeType==3;c=c.nextSibling){e+=
24
+ c.nodeValue;removeElement(c)}h.insertBefore(makePartSpan(e,document),b.nextSibling)}c=document.createRange();c.selectNode(b);c.collapse(false);d(c)}};select.insertNewlineAtCursor=function(){select.insertNodeAtCursor(document.createElement("BR"))};select.insertTabAtCursor=function(){select.insertNodeAtCursor(document.createTextNode("\u00a0\u00a0\u00a0\u00a0"))};select.cursorPos=function(b,c){var e=g();if(e){for(var h=select.selectionTopNode(b,c);h&&!isBR(h);)h=h.previousSibling;e=e.cloneRange();e.collapse(c);
25
+ h?e.setStartAfter(h):e.setStartBefore(b);e=e.toString();return{node:h,offset:e.length}}};select.setCursorPos=function(b,c,e){function h(i,n,r){function t(s){s.nodeType==3?o.push(s):forEach(s.childNodes,t)}if(n==0&&i&&!i.nextSibling){j["set"+r+"After"](i);return true}if(i=i?i.nextSibling:b.firstChild){if(n==0){j["set"+r+"Before"](i);return true}for(var o=[];;){for(;i&&!o.length;){t(i);i=i.nextSibling}var u=o.shift();if(!u)return false;var x=u.nodeValue.length;if(x>=n){j["set"+r](u,n);return true}n-=
26
+ x}}}var j=document.createRange();e=e||c;h(e.node,e.offset,"End")&&h(c.node,c.offset,"Start")&&d(j)}}})();function UndoHistory(f,l,k,m){this.container=f;this.maxDepth=l;this.commitDelay=k;this.editor=m;this.last=this.first=f={text:"",from:null,to:null};this.firstTouched=false;this.history=[];this.redoHistory=[];this.touched=[];this.lostundo=0}
27
+ UndoHistory.prototype={scheduleCommit:function(){var f=this;parent.clearTimeout(this.commitTimeout);this.commitTimeout=parent.setTimeout(function(){f.tryCommit()},this.commitDelay)},touch:function(f){this.setTouched(f);this.scheduleCommit()},undo:function(){this.commit();if(this.history.length){var f=this.history.pop();this.redoHistory.push(this.updateTo(f,"applyChain"));this.notifyEnvironment();return this.chainNode(f)}},redo:function(){this.commit();if(this.redoHistory.length){var f=this.redoHistory.pop();
28
+ this.addUndoLevel(this.updateTo(f,"applyChain"));this.notifyEnvironment();return this.chainNode(f)}},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(f,l,k){for(var m=[],q=0;q<k.length;q++){var p=q==k.length-1?l:document.createElement("br");m.push({from:f,to:p,text:cleanText(k[q])});f=p}this.pushChains([m],f==null&&l==null);this.notifyEnvironment()},pushChains:function(f,
29
+ l){this.commit(l);this.addUndoLevel(this.updateTo(f,"applyChain"));this.redoHistory=[]},chainNode:function(f){for(var l=0;l<f.length;l++){var k=f[l][0];if(k=k&&(k.from||k.to))return k}},reset:function(){this.history=[];this.redoHistory=[];this.lostundo=0},textAfter:function(f){return this.after(f).text},nodeAfter:function(f){return this.after(f).to},nodeBefore:function(f){return this.before(f).from},tryCommit:function(){!window||!window.parent||!window.UndoHistory||(this.editor.highlightDirty()?this.commit(true):
30
+ this.scheduleCommit())},commit:function(f){parent.clearTimeout(this.commitTimeout);f||this.editor.highlightDirty(true);f=this.touchedChains();if(f.length){this.addUndoLevel(this.updateTo(f,"linkChain"));this.redoHistory=[];this.notifyEnvironment()}},updateTo:function(f,l){for(var k=[],m=[],q=0;q<f.length;q++){k.push(this.shadowChain(f[q]));m.push(this[l](f[q]))}l=="applyChain"&&this.notifyDirty(m);return k},notifyDirty:function(f){forEach(f,method(this.editor,"addDirtyNode"));this.editor.scheduleHighlight()},
31
+ notifyEnvironment:function(){this.onChange&&this.onChange(this.editor);window.frameElement&&window.frameElement.CodeMirror.updateNumbers&&window.frameElement.CodeMirror.updateNumbers()},linkChain:function(f){for(var l=0;l<f.length;l++){var k=f[l];if(k.from)k.from.historyAfter=k;else this.first=k;if(k.to)k.to.historyBefore=k;else this.last=k}},after:function(f){return f?f.historyAfter:this.first},before:function(f){return f?f.historyBefore:this.last},setTouched:function(f){if(f){if(!f.historyTouched){this.touched.push(f);
32
+ f.historyTouched=true}}else this.firstTouched=true},addUndoLevel:function(f){this.history.push(f);if(this.history.length>this.maxDepth){this.history.shift();lostundo+=1}},touchedChains:function(){function f(a,d){if(a)a.historyTemp=d;else q=d}function l(a){for(var d=[],g=a?a.nextSibling:m.container.firstChild;g&&(!isBR(g)||g.hackBR);g=g.nextSibling)!g.hackBR&&g.currentText&&d.push(g.currentText);return{from:a,to:g,text:cleanText(d.join(""))}}function k(a,d){for(var g=d+"Sibling",b=a[g];b&&!isBR(b);)b=
33
+ b[g];return b}var m=this,q=null,p=[];m.firstTouched&&m.touched.push(null);forEach(m.touched,function(a){if(!(a&&(a.parentNode!=m.container||a.hackBR))){if(a)a.historyTouched=false;else m.firstTouched=false;var d=l(a),g=m.after(a);if(!g||g.text!=d.text||g.to!=d.to){p.push(d);f(a,d)}}});var w=[];m.touched=[];forEach(p,function(a){if(a.from?a.from.historyTemp:q){for(var d=[],g=a.from,b=true;;){var c=g?g.historyTemp:q;if(!c)if(b)break;else c=l(g);d.unshift(c);f(g,null);if(!g)break;b=m.after(g);g=k(g,
34
+ "previous")}g=a.to;for(b=m.before(a.from);;){if(!g)break;c=g?g.historyTemp:q;if(!c)if(b)break;else c=l(g);d.push(c);f(g,null);b=m.before(g);g=k(g,"next")}w.push(d)}});return w},shadowChain:function(f){var l=[],k=this.after(f[0].from);for(f=f[f.length-1].to;;){l.push(k);k=k.to;if(!k||k==f)break;else k=k.historyAfter||this.before(f)}return l},applyChain:function(f){var l=select.cursorPos(this.container,false),k=this,m=f[0].from,q=f[f.length-1].to;(function(b,c){for(var e=b?b.nextSibling:k.container.firstChild;e!=
35
+ c;){var h=e.nextSibling;removeElement(e);e=h}})(m,q);for(var p=0;p<f.length;p++){var w=f[p];p>0&&k.container.insertBefore(w.from,q);var a=makePartSpan(fixSpaces(w.text));k.container.insertBefore(a,q);if(l&&l.node==w.from){a=0;var d=this.after(w.from);if(d&&p==f.length-1){for(var g=0;g<l.offset&&w.text.charAt(g)==d.text.charAt(g);g++);if(l.offset>g)a=w.text.length-d.text.length}select.setCursorPos(this.container,{node:w.from,offset:Math.max(0,l.offset+a)})}else l&&p==f.length-1&&l.node&&l.node.parentNode!=
36
+ this.container&&select.setCursorPos(this.container,{node:w.from,offset:w.text.length})}this.linkChain(f);return m}};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);if(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);
37
+ function makeWhiteSpace(f){for(var l=[],k=true;f>0;f--){l.push(k||f==1?nbsp:" ");k^=true}return l.join("")}function fixSpaces(f){if(f.charAt(0)==" ")f=nbsp+f.slice(1);return f.replace(/\t/g,function(){return makeWhiteSpace(indentUnit)}).replace(/[ \u00a0]{2,}/g,function(l){return makeWhiteSpace(l.length)})}function cleanText(f){return f.replace(/\u00a0/g," ").replace(/\u200b/g,"")}
38
+ function makePartSpan(f){var l=f;if(f.nodeType==3)l=f.nodeValue;else f=document.createTextNode(l);var k=document.createElement("span");k.isPart=true;k.appendChild(f);k.currentText=l;return k}function alwaysZero(){return 0}var webkitLastLineHack=webkit?function(f){var l=f.lastChild;if(!l||!l.hackBR){l=document.createElement("br");l.hackBR=true;f.appendChild(l)}}:function(){};
39
+ function asEditorLines(f){var l=makeWhiteSpace(indentUnit);return map(f.replace(/\t/g,l).replace(/\u00a0/g," ").replace(/\r\n?/g,"\n").split("\n"),fixSpaces)}
40
+ var Editor=function(){function f(a,d){function g(e,h){if(e.nodeType==3){if((e.nodeValue=fixSpaces(e.nodeValue.replace(/[\r\u200b]/g,"").replace(/\n/g," "))).length)c=false;b.push(e)}else if(isBR(e)&&e.childNodes.length==0){c=true;b.push(e)}else{for(var j=e.firstChild;j;j=j.nextSibling)g(j);if(!c&&w.hasOwnProperty(e.nodeName.toUpperCase())){c=true;if(!d||!h)b.push(document.createElement("br"))}}}var b=[],c=true;g(a,true);return b}function l(a){function d(e){var h=e.parentNode,j=e.nextSibling;return function(i){h.insertBefore(i,
41
+ j)}}var g=[],b=null,c=true;return{next:function(){if(!a)throw StopIteration;var e=a;a=e.nextSibling;var h;if(e.isPart&&e.childNodes.length==1&&e.firstChild.nodeType==3){h=e.firstChild.nodeValue;e.dirty=e.dirty||h!=e.currentText;e.currentText=h;h=!/[\n\t\r]/.test(e.currentText)}else h=false;if(h){g.push(e);c=false;return e.currentText}else if(isBR(e)){c&&window.opera&&e.parentNode.insertBefore(makePartSpan(""),e);g.push(e);c=true;return"\n"}else{h=!e.nextSibling;b=d(e);removeElement(e);e=f(e,h);for(h=
42
+ 0;h<e.length;h++){var j=e,i=h,n=e[h],r="\n";if(n.nodeType==3){select.snapshotChanged();n=makePartSpan(n);r=n.currentText;c=false}else{c&&window.opera&&b(makePartSpan(""));c=true}n.dirty=true;g.push(n);b(n);j[i]=r}return e.join("")}},nodes:g}}function k(a){for(;a&&!isBR(a);)a=a.previousSibling;return a}function m(a,d){if(a){if(isBR(a))a=a.nextSibling}else a=d.firstChild;for(;a&&!isBR(a);)a=a.nextSibling;return a}function q(a,d,g,b){function c(i){i=cleanText(a.history.textAfter(i));return b?i.toLowerCase():
43
+ i}this.editor=a;this.history=a.history;this.history.commit();this.valid=!!d;this.atOccurrence=false;if(b==undefined)b=typeof d=="string"&&d==d.toLowerCase();var e={node:null,offset:0},h=this;if(g&&typeof g=="object"&&typeof g.character=="number"){a.checkLine(g.line);g={node:g.line,offset:g.character};this.pos={from:g,to:g}}else this.pos=g?{from:select.cursorPos(a.container,true)||e,to:select.cursorPos(a.container,false)||e}:{from:e,to:e};if(typeof d!="string")this.matches=function(i,n,r){if(i){i=
44
+ c(n).slice(0,r);var t=i.match(d);for(r=0;t;){var o=i.indexOf(t[0]);r+=o;i=i.slice(o+1);if(o=i.match(d))t=o;else break}}else{i=c(n).slice(r);r=(t=i.match(d))&&r+i.indexOf(t[0])}if(t){h.currentMatch=t;return{from:{node:n,offset:r},to:{node:n,offset:r+t[0].length}}}};else{if(b)d=d.toLowerCase();var j=d.split("\n");this.matches=j.length==1?function(i,n,r){var t=c(n),o=d.length,u;if(i?r>=o&&(u=t.lastIndexOf(d,r-o))!=-1:(u=t.indexOf(d,r))!=-1)return{from:{node:n,offset:u},to:{node:n,offset:u+o}}}:function(i,
45
+ n,r){var t=i?j.length-1:0,o=j[t],u=c(n),x=i?u.indexOf(o)+o.length:u.lastIndexOf(o);if(!(i?x>=r||x!=o.length:x<=r||x!=u.length-o.length))for(r=n;;){if(i&&!r)break;r=i?this.history.nodeBefore(r):this.history.nodeAfter(r);if(!i&&!r)break;u=c(r);o=j[i?--t:++t];if(t>0&&t<j.length-1)if(u!=o)break;else continue;t=i?u.lastIndexOf(o):u.indexOf(o)+o.length;if(i?t!=u.length-o.length:t!=o.length)break;return{from:{node:i?r:n,offset:i?t:x},to:{node:i?n:r,offset:i?x:t}}}}}}function p(a){this.options=a;window.indentUnit=
46
+ a.indentUnit;var d=this.container=document.body;this.history=new UndoHistory(d,a.undoDepth,a.undoDelay,this);var g=this;if(!p.Parser)throw"No parser loaded.";a.parserConfig&&p.Parser.configure&&p.Parser.configure(a.parserConfig);!a.readOnly&&!internetExplorer&&select.setCursorPos(d,{node:null,offset:0});this.dirty=[];this.importCode(a.content||"");this.history.onChange=a.onChange;if(a.readOnly){if(!a.textWrapping)d.style.whiteSpace="nowrap"}else{if(a.continuousScanning!==false){this.scanner=this.documentScanner(a.passTime);
47
+ this.delayScanning()}var b=function(){if(document.body.contentEditable!=undefined&&internetExplorer)document.body.contentEditable="true";else document.designMode="on";if(internetExplorer&&a.height!="dynamic")document.body.style.minHeight=window.frameElement.clientHeight-2*document.body.offsetTop-5+"px";document.documentElement.style.borderWidth="0";if(!a.textWrapping)d.style.whiteSpace="nowrap"};try{b()}catch(c){var e=addEventHandler(document,"focus",function(){e();b()},true)}addEventHandler(document,
48
+ "keydown",method(this,"keyDown"));addEventHandler(document,"keypress",method(this,"keyPress"));addEventHandler(document,"keyup",method(this,"keyUp"));var h=function(){g.cursorActivity(false)};addEventHandler(internetExplorer?document.body:window,"mouseup",h);addEventHandler(document.body,"cut",h);gecko&&addEventHandler(window,"pagehide",function(){g.unloaded=true});addEventHandler(document.body,"paste",function(j){h();var i=null;try{var n=j.clipboardData||window.clipboardData;if(n)i=n.getData("Text")}catch(r){}if(i!==
49
+ null){j.stop();g.replaceSelection(i);select.scrollToCursor(g.container)}});this.options.autoMatchParens&&addEventHandler(document.body,"click",method(this,"scheduleParenHighlight"))}}var w={P:true,DIV:true,LI:true};q.prototype={findNext:function(){return this.find(false)},findPrevious:function(){return this.find(true)},find:function(a){function d(){var h={node:c,offset:e};g.pos={from:h,to:h};return g.atOccurrence=false}if(!this.valid)return false;var g=this,b=a?this.pos.from:this.pos.to,c=b.node,
50
+ e=b.offset;if(c&&!c.parentNode){c=null;e=0}for(;;){if(this.pos=this.matches(a,c,e))return this.atOccurrence=true;if(a){if(!c)return d();c=this.history.nodeBefore(c);e=this.history.textAfter(c).length}else{b=this.history.nodeAfter(c);if(!b){e=this.history.textAfter(c).length;return d()}c=b;e=0}}},select:function(){if(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 d=
51
+ this.currentMatch;if(d)a=a.replace(/\\(\d)/,function(g,b){return d[b]});this.pos.to=this.editor.replaceRange(this.pos.from,this.pos.to,a);this.atOccurrence=false}},position:function(){if(this.atOccurrence)return{line:this.pos.from.node,character:this.pos.from.offset}}};p.prototype={importCode:function(a){var d=asEditorLines(a);if(!this.options.incrementalLoading||d.length<1E3){this.history.push(null,null,d);this.history.reset()}else{var g=0,b=this,c=function(){var e=d.slice(g,g+1E3);e.push("");b.history.push(b.history.nodeBefore(null),
52
+ null,e);b.history.reset();g+=1E3;g<d.length&&parent.setTimeout(c,1E3)};c()}},getCode:function(){if(!this.container.firstChild)return"";var a=[];select.markSelection();forEach(l(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===false||!(a==null||a.parentNode==this.container||a.hackBR))throw parent.CodeMirror.InvalidLineHandle;},cursorPosition:function(a){if(a==
53
+ null)a=true;return(a=select.cursorPos(this.container,a))?{line:a.node,character:a.offset}:{line:null,character:0}},firstLine:function(){return null},lastLine:function(){var a=this.container.lastChild;if(a)a=k(a);if(a&&a.hackBR)a=k(a.previousSibling);return a},nextLine:function(a){this.checkLine(a);a=m(a,this.container);return!a||a.hackBR?false:a},prevLine:function(a){this.checkLine(a);if(a==null)return false;return k(a.previousSibling)},visibleLineCount:function(){for(var a=this.container.firstChild;a&&
54
+ isBR(a);)a=a.nextSibling;if(!a)return false;return Math.floor((window.innerHeight||document.documentElement.clientHeight||document.body.clientHeight)/a.offsetHeight)},selectLines:function(a,d,g,b){this.checkLine(a);a={node:a,offset:d};d=null;if(b!==undefined){this.checkLine(g);d={node:g,offset:b}}select.setCursorPos(this.container,a,d);select.scrollToCursor(this.container)},lineContent:function(a){var d=[];for(a=a?a.nextSibling:this.container.firstChild;a&&!isBR(a);a=a.nextSibling)d.push(nodeText(a));
55
+ return cleanText(d.join(""))},setLineContent:function(a,d){this.history.commit();this.replaceRange({node:a,offset:0},{node:a,offset:this.history.textAfter(a).length},d);this.addDirtyNode(a);this.scheduleHighlight()},removeLine:function(a){for(var d=a?a.nextSibling:this.container.firstChild;d;){var g=d.nextSibling;removeElement(d);if(isBR(d))break;d=g}this.addDirtyNode(a);this.scheduleHighlight()},insertIntoLine:function(a,d,g){var b=null;if(d=="end")b=m(a,this.container);else for(var c=a?a.nextSibling:
56
+ this.container.firstChild;c;c=c.nextSibling){if(d==0){b=c;break}var e=nodeText(c);if(e.length>d){b=c.nextSibling;g=e.slice(0,d)+g+e.slice(d);removeElement(c);break}d-=e.length}d=asEditorLines(g);for(g=0;g<d.length;g++){g>0&&this.container.insertBefore(document.createElement("BR"),b);this.container.insertBefore(makePartSpan(d[g]),b)}this.addDirtyNode(a);this.scheduleHighlight()},selectedText:function(){var a=this.history;a.commit();var d=select.cursorPos(this.container,true),g=select.cursorPos(this.container,
57
+ false);if(!d||!g)return"";if(d.node==g.node)return a.textAfter(d.node).slice(d.offset,g.offset);var b=[a.textAfter(d.node).slice(d.offset)];for(d=a.nodeAfter(d.node);d!=g.node;d=a.nodeAfter(d))b.push(a.textAfter(d));b.push(a.textAfter(g.node).slice(0,g.offset));return cleanText(b.join("\n"))},replaceSelection:function(a){this.history.commit();var d=select.cursorPos(this.container,true),g=select.cursorPos(this.container,false);if(d&&g){g=this.replaceRange(d,g,a);select.setCursorPos(this.container,
58
+ g);webkitLastLineHack(this.container)}},cursorCoords:function(a,d){function g(i,n){var r=-(document.body.scrollTop||document.documentElement.scrollTop||0),t=-(document.body.scrollLeft||document.documentElement.scrollLeft||0)+n;forEach([i,d?null:window.frameElement],function(o){for(;o;){t+=o.offsetLeft;r+=o.offsetTop;o=o.offsetParent}});return{x:t,y:r,yBot:r+i.offsetHeight}}function b(i,n){var r=document.createElement("SPAN");r.appendChild(document.createTextNode(i));try{return n(r)}finally{r.parentNode&&
59
+ r.parentNode.removeChild(r)}}var c=select.cursorPos(this.container,a);if(!c)return null;for(var e=c.offset,h=c.node,j=this;e;){h=h?h.nextSibling:this.container.firstChild;c=nodeText(h);if(e<c.length)return b(c.substr(0,e),function(i){i.style.position="absolute";i.style.visibility="hidden";i.className=h.className;j.container.appendChild(i);return g(h,i.offsetWidth)});e-=c.length}return h&&isSpan(h)?g(h,h.offsetWidth):h&&h.nextSibling&&isSpan(h.nextSibling)?g(h.nextSibling,0):b("\u200b",function(i){h?
60
+ h.parentNode.insertBefore(i,h.nextSibling):j.container.insertBefore(i,j.container.firstChild);return g(i,0)})},reroutePasteEvent:function(){if(!(this.capturingPaste||window.opera||gecko&&gecko>=20101026)){this.capturingPaste=true;var a=window.frameElement.CodeMirror.textareaHack,d=this.cursorCoords(true,true);a.style.top=d.y+"px";if(internetExplorer)if(d=select.getBookmark(this.container))this.selectionSnapshot=d;parent.focus();a.value="";a.focus();var g=this;parent.setTimeout(function(){g.capturingPaste=
61
+ false;window.focus();g.selectionSnapshot&&window.select.setBookmark(g.container,g.selectionSnapshot);var b=a.value;if(b){g.replaceSelection(b);select.scrollToCursor(g.container)}},10)}},replaceRange:function(a,d,g){g=asEditorLines(g);g[0]=this.history.textAfter(a.node).slice(0,a.offset)+g[0];var b=g[g.length-1];g[g.length-1]=b+this.history.textAfter(d.node).slice(d.offset);d=this.history.nodeAfter(d.node);this.history.push(a.node,d,g);return{node:this.history.nodeBefore(d),offset:b.length}},getSearchCursor:function(a,
62
+ d,g){return new q(this,a,d,g)},reindent:function(){this.container.firstChild&&this.indentRegion(null,this.container.lastChild)},reindentSelection:function(a){if(select.somethingSelected()){var d=select.selectionTopNode(this.container,true),g=select.selectionTopNode(this.container,false);d===false||g===false||this.indentRegion(d,g,a)}else this.indentAtCursor(a)},grabKeys:function(a,d){this.frozen=a;this.keyFilter=d},ungrabKeys:function(){this.frozen="leave"},setParser:function(a,d){p.Parser=window[a];
63
+ (d=d||this.options.parserConfig)&&p.Parser.configure&&p.Parser.configure(d);if(this.container.firstChild){forEach(this.container.childNodes,function(g){if(g.nodeType!=3)g.dirty=true});this.addDirtyNode(this.firstChild);this.scheduleHighlight()}},keyDown:function(a){if(this.frozen=="leave")this.keyFilter=this.frozen=null;if(this.frozen&&(!this.keyFilter||this.keyFilter(a.keyCode,a))){a.stop();this.frozen(a)}else{var d=a.keyCode;this.delayScanning();this.options.autoMatchParens&&this.scheduleParenHighlight();
64
+ if(d==13){if(a.ctrlKey&&!a.altKey)this.reparseBuffer();else{select.insertNewlineAtCursor();d=this.options.enterMode;if(d!="flat")this.indentAtCursor(d=="keep"?"keep":undefined);select.scrollToCursor(this.container)}a.stop()}else if(d==9&&this.options.tabMode!="default"&&!a.ctrlKey){this.handleTab(!a.shiftKey);a.stop()}else if(d==32&&a.shiftKey&&this.options.tabMode=="default"){this.handleTab(true);a.stop()}else if(d==36&&!a.shiftKey&&!a.ctrlKey)this.home()&&a.stop();else if(d==35&&!a.shiftKey&&!a.ctrlKey)this.end()&&
65
+ a.stop();else if(d==33&&!a.shiftKey&&!a.ctrlKey&&!gecko)this.pageUp()&&a.stop();else if(d==34&&!a.shiftKey&&!a.ctrlKey&&!gecko)this.pageDown()&&a.stop();else if((d==219||d==221)&&a.ctrlKey&&!a.altKey){this.highlightParens(a.shiftKey,true);a.stop()}else if(a.metaKey&&!a.shiftKey&&(d==37||d==39)){var g=select.selectionTopNode(this.container);if(!(g===false||!this.container.firstChild)){if(d==37)select.focusAfterNode(k(g),this.container);else{d=m(g,this.container);select.focusAfterNode(d?d.previousSibling:
66
+ this.container.lastChild,this.container)}a.stop()}}else if((a.ctrlKey||a.metaKey)&&!a.altKey)if(a.shiftKey&&d==90||d==89){select.scrollToNode(this.history.redo());a.stop()}else if(d==90||safari&&d==8){select.scrollToNode(this.history.undo());a.stop()}else if(d==83&&this.options.saveFunction){this.options.saveFunction();a.stop()}else d==86&&!mac&&this.reroutePasteEvent()}},keyPress:function(a){var d=this.options.electricChars&&p.Parser.electricChars,g=this;if(this.frozen&&(!this.keyFilter||this.keyFilter(a.keyCode||
67
+ 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(d&&d.indexOf(a.character)!=-1)parent.setTimeout(function(){g.indentAtCursor(null)},0);else if(brokenOpera)if(a.code==8){var b=select.selectionTopNode(this.container);g=this;var c=b?b.nextSibling:this.container.firstChild;b!==false&&c&&isBR(c)&&parent.setTimeout(function(){select.selectionTopNode(g.container)==
68
+ c&&select.focusAfterNode(c.previousSibling,g.container)},20)}else{if(a.code==46){b=select.selectionTopNode(this.container);g=this;b&&isBR(b)&&parent.setTimeout(function(){select.selectionTopNode(g.container)!=b&&select.focusAfterNode(b,g.container)},20)}}else if(slowWebkit){c=(b=select.selectionTopNode(this.container))?b.nextSibling:this.container.firstChild;if(b&&c&&isBR(c)&&!isBR(b)){var e=document.createTextNode("\u200b");this.container.insertBefore(e,c);parent.setTimeout(function(){if(e.nodeValue==
69
+ "\u200b")removeElement(e);else e.nodeValue=e.nodeValue.replace("\u200b","")},20)}}webkit&&!this.options.textWrapping&&setTimeout(function(){var h=select.selectionTopNode(g.container,true);h&&h.nodeType==3&&h.previousSibling&&isBR(h.previousSibling)&&h.nextSibling&&isBR(h.nextSibling)&&h.parentNode.replaceChild(document.createElement("BR"),h.previousSibling)},50)},keyUp:function(a){this.cursorActivity(a.keyCode>=16&&a.keyCode<=18||a.keyCode>=33&&a.keyCode<=40)},indentLineAfter:function(a,d){function g(n){n=
70
+ n?n.nextSibling:b.container.firstChild;if(!n||!hasClass(n,"whitespace"))return null;return n}var b=this,c=g(a),e=0,h=c?c.currentText.length:0,j=c?c.nextSibling:a?a.nextSibling:this.container.firstChild;if(d=="keep"){if(a){var i=g(k(a.previousSibling));if(i)e=i.currentText.length}}else{i=a&&j&&j.currentText?j.currentText:"";if(d!=null&&this.options.tabMode=="shift")e=d?h+indentUnit:Math.max(0,h-indentUnit);else if(a)e=a.indentation(i,h,d,j);else if(p.Parser.firstIndentation)e=p.Parser.firstIndentation(i,
71
+ h,d,j)}h=e-h;if(h<0)if(e==0){if(j)select.snapshotMove(c.firstChild,j.firstChild||j,0);removeElement(c);c=null}else{select.snapshotMove(c.firstChild,c.firstChild,h,true);c.currentText=makeWhiteSpace(e);c.firstChild.nodeValue=c.currentText}else if(h>0)if(c){c.currentText=makeWhiteSpace(e);c.firstChild.nodeValue=c.currentText;select.snapshotMove(c.firstChild,c.firstChild,h,true)}else{c=makePartSpan(makeWhiteSpace(e));c.className="whitespace";a?insertAfter(c,a):this.container.insertBefore(c,this.container.firstChild);
72
+ select.snapshotMove(j&&(j.firstChild||j),c.firstChild,e,false,true)}else c&&select.snapshotMove(c.firstChild,c.firstChild,e,false);h!=0&&this.addDirtyNode(a)},highlightAtCursor:function(){var a=select.selectionTopNode(this.container,true),d=select.selectionTopNode(this.container,false);if(a===false||d===false)return false;select.markSelection();if(this.highlight(a,m(d,this.container),true,20)===false)return false;select.selectMarked();return true},handleTab:function(a){this.options.tabMode=="spaces"?
73
+ select.insertTabAtCursor():this.reindentSelection(a)},home:function(){var a=select.selectionTopNode(this.container,true),d=a;if(a===false||!(!a||a.isPart||isBR(a))||!this.container.firstChild)return false;for(;a&&!isBR(a);)a=a.previousSibling;var g=a?a.nextSibling:this.container.firstChild;g&&g!=d&&g.isPart&&hasClass(g,"whitespace")?select.focusAfterNode(g,this.container):select.focusAfterNode(a,this.container);select.scrollToCursor(this.container);return true},end:function(){var a=select.selectionTopNode(this.container,
74
+ true);if(a===false)return false;a=m(a,this.container);if(!a)return false;select.focusAfterNode(a.previousSibling,this.container);select.scrollToCursor(this.container);return true},pageUp:function(){var a=this.cursorPosition().line,d=this.visibleLineCount();if(a===false||d===false)return false;d-=2;for(var g=0;g<d;g++){a=this.prevLine(a);if(a===false)break}if(g==0)return false;select.setCursorPos(this.container,{node:a,offset:0});select.scrollToCursor(this.container);return true},pageDown:function(){var a=
75
+ this.cursorPosition().line,d=this.visibleLineCount();if(a===false||d===false)return false;d-=2;for(var g=0;g<d;g++){var b=this.nextLine(a);if(b===false)break;a=b}if(g==0)return false;select.setCursorPos(this.container,{node:a,offset:0});select.scrollToCursor(this.container);return true},scheduleParenHighlight:function(){this.parenEvent&&parent.clearTimeout(this.parenEvent);var a=this;this.parenEvent=parent.setTimeout(function(){a.highlightParens()},300)},highlightParens:function(a,d){function g(u,
76
+ x){if(u)if(j)if(j.call)j(u,x);else u.className+=" "+j[x?0:1];else{u.style.fontWeight="bold";u.style.color=x?"#8F8":"#F88"}}function b(u){if(u)if(j&&!j.call)removeClass(removeClass(u,j[0]),j[1]);else if(h.options.unmarkParen)h.options.unmarkParen(u);else{u.style.fontWeight="";u.style.color=""}}function c(u){if(u.currentText)return(u=u.currentText.match(/^[\s\u00a0]*([\(\)\[\]{}])[\s\u00a0]*$/))&&u[1]}function e(){for(var u=[],x,s=true,v=n;v;v=t?v.nextSibling:v.previousSibling)if(v.className==r&&isSpan(v)&&
77
+ (x=c(v))){if(/[\(\[\{]/.test(x)==t)u.push(x);else if(u.length){if(u.pop()!=matching[x])s=false}else s=false;if(!u.length)break}else if(v.dirty||!isSpan(v)&&!isBR(v))return{node:v,status:"dirty"};return{node:v,status:v&&s}}var h=this,j=this.options.markParen;if(typeof j=="string")j=[j,j];if(!d&&h.highlighted){b(h.highlighted[0]);b(h.highlighted[1])}if(!(!window||!window.parent||!window.select)){this.parenEvent&&parent.clearTimeout(this.parenEvent);this.parenEvent=null;var i,n=select.selectionTopNode(this.container,
78
+ true);if(n&&this.highlightAtCursor())if((n=select.selectionTopNode(this.container,true))&&((i=c(n))||(n=n.nextSibling)&&(i=c(n))))for(var r=n.className,t=/[\(\[\{]/.test(i);;){var o=e();if(o.status=="dirty"){this.highlight(o.node,m(o.node));o.node.dirty=false}else{g(n,o.status);g(o.node,o.status);if(d)parent.setTimeout(function(){b(n);b(o.node)},500);else h.highlighted=[n,o.node];a&&o.node&&select.focusAfterNode(o.node.previousSibling,this.container);break}}}},indentAtCursor:function(a){if(this.container.firstChild)if(this.highlightAtCursor()){var d=
79
+ select.selectionTopNode(this.container,false);if(d!==false){select.markSelection();this.indentLineAfter(k(d),a);select.selectMarked()}}},indentRegion:function(a,d,g){var b=a=k(a),c=a&&k(a.previousSibling);isBR(d)||(d=m(d,this.container));this.addDirtyNode(a);do{var e=m(b,this.container);b&&this.highlight(c,e,true);this.indentLineAfter(b,g);c=b;b=e}while(b!=d);select.setCursorPos(this.container,{node:a,offset:0},{node:d,offset:0})},cursorActivity:function(a){if(this.unloaded){window.document.designMode=
80
+ "off";window.document.designMode="on";this.unloaded=false}if(internetExplorer){this.container.createTextRange().execCommand("unlink");clearTimeout(this.saveSelectionSnapshot);var d=this;this.saveSelectionSnapshot=setTimeout(function(){var c=select.getBookmark(d.container);if(c)d.selectionSnapshot=c},200)}var g=this.options.onCursorActivity;if(!a||g){var b=select.selectionTopNode(this.container,false);if(!(b===false||!this.container.firstChild)){b=b||this.container.firstChild;g&&g(b);if(!a){this.scheduleHighlight();
81
+ this.addDirtyNode(b)}}}},reparseBuffer:function(){forEach(this.container.childNodes,function(a){a.dirty=true});this.container.firstChild&&this.addDirtyNode(this.container.firstChild)},addDirtyNode:function(a){if(a=a||this.container.firstChild){for(var d=0;d<this.dirty.length;d++)if(this.dirty[d]==a)return;if(a.nodeType!=3)a.dirty=true;this.dirty.push(a)}},allClean:function(){return!this.dirty.length},scheduleHighlight:function(){var a=this;parent.clearTimeout(this.highlightTimeout);this.highlightTimeout=
82
+ parent.setTimeout(function(){a.highlightDirty()},this.options.passDelay)},getDirtyNode:function(){for(;this.dirty.length>0;){var a=this.dirty.pop();try{for(;a&&a.parentNode!=this.container;)a=a.parentNode;if(a&&(a.dirty||a.nodeType==3))return a}catch(d){}}return null},highlightDirty:function(a){if(!window||!window.parent||!window.select)return false;this.options.readOnly||select.markSelection();for(var d,g=a?null:(new Date).getTime()+this.options.passTime;((new Date).getTime()<g||a)&&(d=this.getDirtyNode());){var b=
83
+ this.highlight(d,g);b&&b.node&&b.dirty&&this.addDirtyNode(b.node.nextSibling)}this.options.readOnly||select.selectMarked();d&&this.scheduleHighlight();return this.dirty.length==0},documentScanner:function(a){var d=this,g=null;return function(){if(!(!window||!window.parent||!window.select)){if(g&&g.parentNode!=d.container)g=null;select.markSelection();var b=d.highlight(g,(new Date).getTime()+a,true);select.selectMarked();b=b?b.node&&b.node.nextSibling:null;g=g==b?null:b;d.delayScanning()}}},delayScanning:function(){if(this.scanner){parent.clearTimeout(this.documentScan);
84
+ this.documentScan=parent.setTimeout(this.scanner,this.options.continuousScanning)}},highlight:function(a,d,g,b){function c(s){if(s){var v=s.oldNextSibling;if(o||v===undefined||s.nextSibling!=v)h.history.touch(s);s.oldNextSibling=s.nextSibling}else{v=h.container.oldFirstChild;if(o||v===undefined||h.container.firstChild!=v)h.history.touch(null);h.container.oldFirstChild=h.container.firstChild}}var e=this.container,h=this,j=this.options.activeTokens,i=typeof d=="number"?d:null;if(!e.firstChild)return false;
85
+ for(;a&&(!a.parserFromHere||a.dirty);){if(b!=null&&isBR(a)&&--b<0)return false;a=a.previousSibling}if(a&&!a.nextSibling)return false;var n=l(a?a.nextSibling:e.firstChild);b=stringStream(n);var r=a?a.parserFromHere(b):p.Parser.make(b),t={current:null,get:function(){if(!this.current)this.current=n.nodes.shift();return this.current},next:function(){this.current=null},remove:function(){e.removeChild(this.get());this.current=null},getNonEmpty:function(){for(var s=this.get();s&&isSpan(s)&&s.currentText==
86
+ "";)if(window.opera&&(s.previousSibling==null||isBR(s.previousSibling))&&(s.nextSibling==null||isBR(s.nextSibling))){this.next();s=this.get()}else{var v=s;this.remove();s=this.get();select.snapshotMove(v.firstChild,s&&(s.firstChild||s),0)}return s}},o=false,u=true,x=0;forEach(r,function(s){var v=t.getNonEmpty();if(s.value=="\n"){if(!isBR(v))throw"Parser out of sync. Expected BR.";if(v.dirty||!v.indentation)o=true;c(a);a=v;v.parserFromHere=r.copy();v.indentation=s.indentation||alwaysZero;v.dirty=false;
87
+ if(i==null&&v==d)throw StopIteration;if(i!=null&&(new Date).getTime()>=i||!o&&!u&&x>1&&!g)throw StopIteration;u=o;o=false;x=0;t.next()}else{if(!isSpan(v))throw"Parser out of sync. Expected SPAN.";if(v.dirty)o=true;x++;if(!v.reduced&&v.currentText==s.value&&v.className==s.style){j&&v.dirty&&j(v,s,h);v.dirty=false;t.next()}else{o=true;var y=makePartSpan(s.value);y.className=s.style;e.insertBefore(y,v);j&&j(y,s,h);s=s.value.length;for(var A=0;s>0;){v=t.get();var z=v.currentText.length;select.snapshotReplaceNode(v.firstChild,
88
+ y.firstChild,s,A);if(z>s){v=v;v.currentText=v.currentText.substring(s);v.reduced=true;s=0}else{s-=z;A+=z;t.remove()}}}}});c(a);webkitLastLineHack(this.container);return{node:t.getNonEmpty(),dirty:o}}};return p}();addEventHandler(window,"load",function(){var f=window.frameElement.CodeMirror;f.editor=new Editor(f.options);parent.setTimeout(method(f,"init"),0)});function tokenizer(f,l){function k(q){return q!="\n"&&/^[\s\u00a0]*$/.test(q)}var m={state:l,take:function(q){if(typeof q=="string")q={style:q,type:q};q.content=(q.content||"")+f.get();/\n$/.test(q.content)||f.nextWhile(k);q.value=q.content+f.get();return q},next:function(){if(!f.more())throw StopIteration;var q;if(f.equals("\n")){f.next();return this.take("whitespace")}if(f.applies(k))q="whitespace";else for(;!q;)q=this.state(f,function(p){m.state=p});return this.take(q)}};return m};
@@ -0,0 +1,4 @@
1
+ var CSSParser=Editor.Parser=function(){function l(h,j,g){return function(e){return!h||/^\}/.test(e)?g:j?g+indentUnit*2:g+indentUnit}}var k=function(){function h(a,d){var b=a.next();if(b=="@"){a.nextWhileMatches(/\w/);return"css-at"}else if(b=="/"&&a.equals("*")){d(j);return null}else if(b=="<"&&a.equals("!")){d(g);return null}else if(b=="=")return"css-compare";else if(a.equals("=")&&(b=="~"||b=="|")){a.next();return"css-compare"}else if(b=='"'||b=="'"){d(e(b));return null}else if(b=="#"){a.nextWhileMatches(/\w/);
2
+ return"css-hash"}else if(b=="!"){a.nextWhileMatches(/[ \t]/);a.nextWhileMatches(/\w/);return"css-important"}else if(/\d/.test(b)){a.nextWhileMatches(/[\w.%]/);return"css-unit"}else if(/[,.+>*\/]/.test(b))return"css-select-op";else if(/[;{}:\[\]]/.test(b))return"css-punctuation";else{a.nextWhileMatches(/[\w\\\-_]/);return"css-identifier"}}function j(a,d){for(var b=false;!a.endOfLine();){var c=a.next();if(b&&c=="/"){d(h);break}b=c=="*"}return"css-comment"}function g(a,d){for(var b=0;!a.endOfLine();){var c=
3
+ a.next();if(b>=2&&c==">"){d(h);break}b=c=="-"?b+1:0}return"css-comment"}function e(a){return function(d,b){for(var c=false;!d.endOfLine();){var f=d.next();if(f==a&&!c)break;c=!c&&f=="\\"}c||b(h);return"css-string"}}return function(a,d){return tokenizer(a,d||h)}}();return{make:function(h,j){j=j||0;var g=k(h),e=false,a=false,d=false,b={next:function(){var c=g.next(),f=c.style,i=c.content;if(f=="css-hash")f=c.style=a?"css-colorcode":"css-identifier";if(f=="css-identifier")if(a)c.style="css-value";else if(!e&&
4
+ !d)c.style="css-selector";if(i=="\n")c.indentation=l(e,a,j);if(i=="{"&&d=="@media")d=false;else if(i=="{")e=true;else if(i=="}")e=a=d=false;else if(i==";")a=d=false;else if(e&&f!="css-comment"&&f!="whitespace")a=true;else if(!e&&f=="css-at")d=i;return c},copy:function(){var c=e,f=a,i=g.state;return function(m){g=k(m,i);e=c;a=f;return b}}};return b},electricChars:"}"}}();
@@ -0,0 +1,3 @@
1
+ var HTMLMixedParser=Editor.Parser=function(){function p(){var a=["XMLParser"],g;for(g in j)a.push(j[g]);for(var k in a)if(!window[a[k]])throw Error(a[k]+" parser must be loaded for HTML mixed mode to work.");XMLParser.configure({useHTMLKludges:true})}var j={script:"JSParser",style:"CSSParser"};return{make:function(a){function g(){var d=l.next();if(d.content=="<")e=true;else if(d.style=="xml-tagname"&&e===true)e=d.content.toLowerCase();else if(d.content==">"){if(j[e])h.next=k(window[j[e]],"</"+e);
2
+ e=false}return d}function k(d,f){var m=l.indentation();i=d.make(a,m+indentUnit);return function(){if(a.lookAhead(f,false,false,true)){i=null;h.next=g;return g()}var b=i.next(),c=b.value.lastIndexOf("<"),n=Math.min(b.value.length-c,f.length);if(c!=-1&&b.value.slice(c,c+n).toLowerCase()==f.slice(0,n)&&a.lookAhead(f.slice(n),false,false,true)){a.push(b.value.slice(c));b.value=b.value.slice(0,c)}if(b.indentation){var q=b.indentation;b.indentation=function(o){return o=="</"?m:q(o)}}return b}}p();var l=
3
+ XMLParser.make(a),i=null,e=false,h={next:g,copy:function(){var d=l.copy(),f=i&&i.copy(),m=h.next,b=e;return function(c){a=c;l=d(c);i=f&&f(c);h.next=m;e=b;return h}}};return h},electricChars:"{}/:",configure:function(a){if(a.triggers)j=a.triggers}}}();
@@ -0,0 +1,12 @@
1
+ var tokenizeJavaScript=function(){function w(a,f){for(var c=false;!a.endOfLine();){var k=a.next();if(k==f&&!c)return false;c=!c&&k=="\\"}return c}function C(a,f){return function(c,k){var o=a,e=D(a,f,c,function(h){o=h}),g=e.type=="operator"||e.type=="keyword c"||e.type.match(/^[\[{}\(,;:]$/);if(g!=f||o!=a)k(C(o,g));return e}}function D(a,f,c,k){function o(){c.nextWhileMatches(r);var m=c.get(),l=x.hasOwnProperty(m)&&x.propertyIsEnumerable(m)&&x[m];return l?{type:l.type,style:l.style,content:m}:{type:"variable",
2
+ style:"js-variable",content:m}}function e(m){var l="/*";for(m=m=="*";;){if(c.endOfLine())break;var i=c.next();if(i=="/"&&m){l=null;break}m=i=="*"}k(l);return{type:"comment",style:"js-comment"}}function g(){c.nextWhileMatches(j);return{type:"operator",style:"js-operator"}}function h(m){var l=w(c,m);k(l?m:null);return{type:"string",style:"js-string"}}if(a=='"'||a=="'")return h(a);var n=c.next();if(a=="/*")return e(n);else if(n=='"'||n=="'")return h(n);else if(/[\[\]{}\(\),;\:\.]/.test(n))return{type:n,
3
+ style:"js-punctuation"};else if(n=="0"&&(c.equals("x")||c.equals("X"))){c.next();c.nextWhileMatches(s);return{type:"number",style:"js-atom"}}else if(/[0-9]/.test(n)){c.nextWhileMatches(/[0-9]/);if(c.equals(".")){c.next();c.nextWhileMatches(/[0-9]/)}if(c.equals("e")||c.equals("E")){c.next();c.equals("-")&&c.next();c.nextWhileMatches(/[0-9]/)}return{type:"number",style:"js-atom"}}else if(n=="/")if(c.equals("*")){c.next();return e(n)}else if(c.equals("/")){w(c,null);return{type:"comment",style:"js-comment"}}else{if(f){w(c,
4
+ "/");c.nextWhileMatches(/[gimy]/);a={type:"regexp",style:"js-string"}}else a=g();return a}else return j.test(n)?g():o()}var x=function(){function a(g,h){return{type:g,style:"js-"+h}}var f=a("keyword a","keyword"),c=a("keyword b","keyword"),k=a("keyword c","keyword"),o=a("operator","keyword"),e=a("atom","atom");return{"if":f,"while":f,"with":f,"else":c,"do":c,"try":c,"finally":c,"return":k,"break":k,"continue":k,"new":k,"delete":k,"throw":k,"in":o,"typeof":o,"instanceof":o,"var":a("var","keyword"),
5
+ "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":e,"false":e,"null":e,undefined:e,NaN:e,Infinity:e}}(),j=/[+\-*&%=<>!?|]/,s=/[0-9A-Fa-f]/,r=/[\w\$_]/;return function(a,f){return tokenizer(a,f||C(false,true))}}();var JSParser=Editor.Parser=function(){function w(j,s,r,a,f,c){this.indented=j;this.column=s;this.type=r;if(a!=null)this.align=a;this.prev=f;this.info=c}function C(j){return function(s){var r=s&&s.charAt(0),a=j.type,f=r==a;return a=="vardef"?j.indented+4:a=="form"&&r=="{"?j.indented:a=="stat"||a=="form"?j.indented+indentUnit:j.info=="switch"&&!f?j.indented+(/^(?:case|default)\b/.test(s)?indentUnit:2*indentUnit):j.align?j.column-(f?1:0):j.indented+(f?0:indentUnit)}}var D={atom:true,number:true,variable:true,
6
+ string:true,regexp:true},x=false;return{make:function(j,s){function r(b){for(var d=b.length-1;d>=0;d--)u.push(b[d])}function a(){r(arguments);E=true}function f(){r(arguments);E=false}function c(){t={prev:t,vars:{"this":true,arguments:true}}}function k(){t=t.prev}function o(b){if(t){y="js-variabledef";t.vars[b]=true}}function e(b,d){var v=function(){p=new w(A,B,b,null,p,d)};v.lex=true;return v}function g(){if(p.type==")")A=p.indented;p=p.prev}function h(b){return function(d){if(d==b)a();else b==";"?
7
+ f():a(arguments.callee)}}function n(){return f(l,n)}function m(){return f(i,m)}function l(b){if(b=="var")a(e("vardef"),H,h(";"),g);else if(b=="keyword a")a(e("form"),i,l,g);else if(b=="keyword b")a(e("form"),l,g);else if(b=="{")a(e("}"),I,g);else if(b==";")a();else if(b=="function")a(J);else if(b=="for")a(e("form"),h("("),e(")"),P,h(")"),g,l,g);else if(b=="variable")a(e("stat"),Q);else if(b=="switch")a(e("form"),i,e("}","switch"),h("{"),I,g,g);else if(b=="case")a(i,h(":"));else if(b=="default")a(h(":"));
8
+ else b=="catch"?a(e("form"),c,h("("),L,h(")"),l,g,k):f(e("stat"),i,h(";"),g)}function i(b){if(D.hasOwnProperty(b))a(q);else if(b=="function")a(J);else if(b=="keyword c")a(i);else if(b=="(")a(e(")"),i,h(")"),g,q);else if(b=="operator")a(i);else if(b=="[")a(e("]"),F(i,"]"),g,q);else b=="{"?a(e("}"),F(R,"}"),g,q):a()}function q(b,d){if(b=="operator"&&/\+\+|--/.test(d))a(q);else if(b=="operator")a(i);else if(b==";")f();else if(b=="(")a(e(")"),F(i,")"),g,q);else if(b==".")a(S,q);else b=="["&&a(e("]"),
9
+ i,h("]"),g,q)}function Q(b){b==":"?a(g,l):f(q,h(";"),g)}function S(b){if(b=="variable"){y="js-property";a()}}function R(b){if(b=="variable")y="js-property";D.hasOwnProperty(b)&&a(h(":"),i)}function F(b,d){function v(z){if(z==",")a(b,v);else z==d?a():a(h(d))}return function(z){z==d?a():f(b,v)}}function I(b){b=="}"?a():f(l,I)}function H(b,d){if(b=="variable"){o(d);a(M)}else a()}function M(b,d){if(d=="=")a(i,M);else b==","&&a(H)}function P(b){if(b=="var")a(H,G);else if(b==";")f(G);else b=="variable"?
10
+ a(T):f(G)}function T(b,d){d=="in"?a(i):a(q,G)}function G(b,d){if(b==";")a(N);else d=="in"?a(i):a(i,h(";"),N)}function N(b){b==")"?f():a(i)}function J(b,d){if(b=="variable"){o(d);a(J)}else b=="("&&a(c,F(L,")"),l,k)}function L(b,d){if(b=="variable"){o(d);a()}}var K=tokenizeJavaScript(j),u=[x?m:n],t=null,p=new w((s||0)-indentUnit,0,"block",false),B=0,A=0,E,y,O={next:function(){for(;u[u.length-1].lex;)u.pop()();var b=K.next();if(b.type=="whitespace"&&B==0)A=b.value.length;B+=b.value.length;if(b.content==
11
+ "\n"){A=B=0;if(!("align"in p))p.align=false;b.indentation=C(p)}if(b.type=="whitespace"||b.type=="comment")return b;if(!("align"in p))p.align=true;for(;;){E=y=false;u.pop()(b.type,b.content);if(E){if(y)b.style=y;else{var d;if(d=b.type=="variable")a:{for(d=t;d;){if(d.vars[b.content]){d=true;break a}d=d.prev}d=false}if(d)b.style="js-localvariable"}return b}}},copy:function(){var b=t,d=p,v=u.concat([]),z=K.state;return function(U){t=b;p=d;u=v.concat([]);B=A=0;K=tokenizeJavaScript(U,z);return O}}};g.lex=
12
+ true;return O},electricChars:"{}:",configure:function(j){if(j.json!=null)x=j.json}}}();
@@ -0,0 +1,7 @@
1
+ var XMLParser=Editor.Parser=function(){var v={autoSelfClosers:{br:true,img:true,hr:true,link:true,input:true,meta:true,col:true,frame:true,base:true,area:true},doNotIndent:{pre:true,"!cdata":true}},C={autoSelfClosers:{},doNotIndent:{"!cdata":true}},s=v,w=false,x=function(){function j(a,d){var e=a.next();if(e=="<")if(a.equals("!")){a.next();if(a.equals("["))if(a.lookAhead("[CDATA[",true)){d(k("xml-cdata","]]\>"));return null}else return"xml-text";else if(a.lookAhead("--",true)){d(k("xml-comment","--\>"));
2
+ return null}else if(a.lookAhead("DOCTYPE",true)){a.nextWhileMatches(/[\w\._\-]/);d(k("xml-doctype",">"));return"xml-doctype"}else return"xml-text"}else if(a.equals("?")){a.next();a.nextWhileMatches(/[\w\._\-]/);d(k("xml-processing","?>"));return"xml-processing"}else{a.equals("/")&&a.next();d(m);return"xml-punctuation"}else if(e=="&"){for(;!a.endOfLine();)if(a.next()==";")break;return"xml-entity"}else{a.nextWhileMatches(/[^&<\n]/);return"xml-text"}}function m(a,d){var e=a.next();if(e==">"){d(j);return"xml-punctuation"}else if(/[?\/]/.test(e)&&
3
+ a.equals(">")){a.next();d(j);return"xml-punctuation"}else if(e=="=")return"xml-punctuation";else if(/[\'\"]/.test(e)){d(f(e));return null}else{a.nextWhileMatches(/[^\s\u00a0=<>\"\'\/?]/);return"xml-name"}}function f(a){return function(d,e){for(;!d.endOfLine();)if(d.next()==a){e(m);break}return"xml-attribute"}}function k(a,d){return function(e,t){for(;!e.endOfLine();){if(e.lookAhead(d,true)){t(j);break}e.next()}return a}}return function(a,d){return tokenizer(a,d||j)}}();return{make:function(j){function m(b){for(var c=
4
+ b.length-1;c>=0;c--)p.push(b[c])}function f(){m(arguments);q=true}function k(){m(arguments);q=false}function a(){g.style+=" xml-error"}function d(b){return function(c,l){if(l==b)f();else{a();f(arguments.callee)}}}function e(b,c){var l=s.doNotIndent.hasOwnProperty(b)||h&&h.noIndent;h={prev:h,name:b,indent:n,startOfLine:c,noIndent:l}}function t(b){return function(c,l){var i=b;if(i&&i.noIndent)return l;if(w&&/<!\[CDATA\[/.test(c))return 0;if(i&&/^<\//.test(c))i=i.prev;for(;i&&!i.startOfLine;)i=i.prev;
5
+ return i?i.indent+indentUnit:0}}function y(){return k(D,y)}function D(b,c){if(c=="<")f(E,z,A(o==1));else if(c=="</")f(F,d(">"));else{if(b=="xml-cdata"){if(!h||h.name!="!cdata")e("!cdata");if(/\]\]>$/.test(c))h=h.prev}else G.hasOwnProperty(b)||a();f()}}function E(b,c){if(b=="xml-name"){r=c.toLowerCase();g.style="xml-tagname";f()}else{r=null;k()}}function F(b,c){if(b=="xml-name"){g.style="xml-tagname";if(h&&c.toLowerCase()==h.name)h=h.prev;else a()}f()}function A(b){return function(c,l){if(l=="/>"||
6
+ l==">"&&s.autoSelfClosers.hasOwnProperty(r))f();else if(l==">"){e(r,b);f()}else{a();f(arguments.callee)}}}function z(b){if(b=="xml-name"){g.style="xml-attname";f(H,z)}else k()}function H(b,c){if(c=="=")f(B);else c==">"||c=="/>"?k(A):k()}function B(b){b=="xml-attribute"?f(B):k()}var u=x(j),g,p=[y],o=0,n=0,r=null,h=null,q,G={"xml-text":true,"xml-entity":true,"xml-comment":true,"xml-processing":true,"xml-doctype":true};return{indentation:function(){return n},next:function(){g=u.next();if(g.style=="whitespace"&&
7
+ o==0)n=g.value.length;else o++;if(g.content=="\n"){n=o=0;g.indentation=t(h)}if(g.style=="whitespace"||g.type=="xml-comment")return g;for(;;){q=false;p.pop()(g.style,g.content);if(q)return g}},copy:function(){var b=p.concat([]),c=u.state,l=h,i=this;return function(I){p=b.concat([]);o=n=0;h=l;u=x(I,c);return i}}}},electricChars:"/",configure:function(j){if(j.useHTMLKludges!=null)s=j.useHTMLKludges?v:C;if(j.alignCDATA)w=j.alignCDATA}}}();