locomotive_cms 0.0.4.beta5 → 0.0.4.beta7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (206) hide show
  1. data/Gemfile +12 -10
  2. data/app/controllers/admin/api_contents_controller.rb +10 -1
  3. data/app/controllers/admin/base_controller.rb +2 -2
  4. data/app/controllers/admin/cross_domain_sessions_controller.rb +7 -4
  5. data/app/controllers/admin/current_sites_controller.rb +2 -0
  6. data/app/controllers/admin/imports_controller.rb +8 -27
  7. data/app/controllers/admin/installation_controller.rb +79 -0
  8. data/app/controllers/admin/passwords_controller.rb +2 -2
  9. data/app/controllers/admin/sessions_controller.rb +2 -2
  10. data/app/controllers/admin/sites_controller.rb +2 -0
  11. data/app/controllers/application_controller.rb +1 -1
  12. data/app/helpers/admin/assets_helper.rb +0 -6
  13. data/app/helpers/admin/{login_helper.rb → box_helper.rb} +7 -3
  14. data/app/helpers/admin/custom_fields_helper.rb +2 -2
  15. data/app/models/asset_collection.rb +10 -0
  16. data/app/models/content_instance.rb +19 -0
  17. data/app/models/content_type.rb +20 -2
  18. data/app/models/extensions/page/tree.rb +4 -6
  19. data/app/models/site.rb +11 -3
  20. data/app/uploaders/theme_asset_uploader.rb +1 -1
  21. data/app/views/admin/asset_collections/edit.html.haml +2 -2
  22. data/app/views/admin/asset_collections/new.html.haml +1 -1
  23. data/app/views/admin/assets/_form.html.haml +2 -2
  24. data/app/views/admin/content_types/_form.html.haml +2 -2
  25. data/app/views/admin/content_types/new.html.haml +1 -1
  26. data/app/views/admin/contents/_form.html.haml +2 -2
  27. data/app/views/admin/contents/index.html.haml +1 -1
  28. data/app/views/admin/cross_domain_sessions/new.html.haml +1 -1
  29. data/app/views/admin/current_sites/_form.html.haml +3 -3
  30. data/app/views/admin/current_sites/edit.html.haml +1 -1
  31. data/app/views/admin/errors/no_page.html.haml +1 -0
  32. data/app/views/admin/errors/no_site.html.haml +1 -0
  33. data/app/views/admin/imports/new.html.haml +11 -0
  34. data/app/views/admin/imports/show.html.haml +1 -1
  35. data/app/views/admin/installation/step_1.html.haml +24 -0
  36. data/app/views/admin/installation/step_2.html.haml +26 -0
  37. data/app/views/admin/installation/step_3.html.haml +23 -0
  38. data/app/views/{layouts/admin → admin/layouts}/application.html.haml +0 -0
  39. data/app/views/admin/layouts/box.html.haml +21 -0
  40. data/app/views/admin/layouts/error.html.haml +1 -0
  41. data/app/views/admin/my_accounts/edit.html.haml +1 -1
  42. data/app/views/admin/pages/_form.html.haml +2 -3
  43. data/app/views/admin/pages/index.html.haml +1 -1
  44. data/app/views/admin/passwords/edit.html.haml +2 -2
  45. data/app/views/admin/passwords/new.html.haml +2 -2
  46. data/app/views/admin/sessions/new.html.haml +2 -2
  47. data/app/views/admin/shared/_head.html.haml +4 -5
  48. data/app/views/admin/sites/_form.html.haml +3 -3
  49. data/app/views/admin/snippets/_form.html.haml +2 -2
  50. data/app/views/admin/theme_assets/_form.html.haml +2 -2
  51. data/app/views/admin/theme_assets/index.html.haml +1 -1
  52. data/config/application.rb +1 -3
  53. data/config/assets.yml +94 -0
  54. data/config/environments/development.rb +0 -5
  55. data/config/environments/production.rb +1 -3
  56. data/config/environments/test.rb +1 -5
  57. data/config/initializers/carrierwave.rb +17 -0
  58. data/config/initializers/locomotive.rb +12 -0
  59. data/config/locales/admin_ui_en.yml +33 -1
  60. data/config/locales/admin_ui_fr.yml +34 -1
  61. data/config/locales/flash.en.yml +1 -0
  62. data/config/locales/flash.fr.yml +1 -0
  63. data/config/mongoid.yml +2 -2
  64. data/config/routes.rb +6 -1
  65. data/lib/generators/locomotive/install/install_generator.rb +18 -10
  66. data/lib/generators/locomotive/install/templates/README +23 -13
  67. data/lib/generators/locomotive/install/templates/locomotive.rb +13 -1
  68. data/lib/locomotive/carrierwave.rb +1 -0
  69. data/lib/locomotive/configuration.rb +3 -1
  70. data/lib/locomotive/custom_fields.rb +0 -1
  71. data/lib/locomotive/engine.rb +12 -9
  72. data/lib/locomotive/import/asset_collections.rb +40 -8
  73. data/lib/locomotive/import/assets.rb +20 -12
  74. data/lib/locomotive/import/base.rb +46 -0
  75. data/lib/locomotive/import/content_types.rb +51 -15
  76. data/lib/locomotive/import/job.rb +59 -15
  77. data/lib/locomotive/import/logger.rb +13 -0
  78. data/lib/locomotive/import/pages.rb +64 -25
  79. data/lib/locomotive/import/site.rb +3 -5
  80. data/lib/locomotive/import/snippets.rb +6 -8
  81. data/lib/locomotive/import.rb +2 -0
  82. data/lib/locomotive/liquid/drops/asset_collections.rb +4 -4
  83. data/lib/locomotive/liquid/drops/contents.rb +21 -16
  84. data/lib/locomotive/liquid/filters/html.rb +9 -6
  85. data/lib/locomotive/liquid/tags/nav.rb +18 -5
  86. data/lib/locomotive/liquid/tags/paginate.rb +3 -3
  87. data/lib/locomotive/misc_form_builder.rb +2 -7
  88. data/lib/locomotive/render.rb +9 -3
  89. data/lib/locomotive/routing/site_dispatcher.rb +8 -6
  90. data/lib/locomotive/version.rb +1 -1
  91. data/public/images/admin/box/buttons/right_bg.png +0 -0
  92. data/public/javascripts/admin/aloha/VERSION.txt +1 -1
  93. data/public/javascripts/admin/aloha/aloha-nodeps.js +140 -101
  94. data/public/javascripts/admin/aloha/aloha.js +193 -105
  95. data/public/javascripts/admin/aloha/css/aloha.css +65 -4
  96. data/public/javascripts/admin/aloha/deps/prettyPhoto/resources/css/prettyPhoto.css +2 -2
  97. data/public/javascripts/admin/aloha/i18n/de.dict +2 -0
  98. data/public/javascripts/admin/aloha/i18n/en.dict +2 -0
  99. data/public/javascripts/admin/aloha/i18n/pl.dict +5 -0
  100. data/public/javascripts/admin/aloha/images/base.png +0 -0
  101. data/public/javascripts/admin/aloha/images/base_big.png +0 -0
  102. data/public/javascripts/admin/aloha/images/base_multi.png +0 -0
  103. data/public/javascripts/admin/aloha/images/fade_in.png +0 -0
  104. data/public/javascripts/admin/aloha/images/fade_out.png +0 -0
  105. data/public/javascripts/admin/aloha/images/gentics_logo.png +0 -0
  106. data/public/javascripts/admin/aloha/images/grabhandle.png +0 -0
  107. data/public/javascripts/admin/aloha/images/maximize.png +0 -0
  108. data/public/javascripts/admin/aloha/images/pin.png +0 -0
  109. data/public/javascripts/admin/aloha/images/removeformat.png +0 -0
  110. data/public/javascripts/admin/aloha/plugins/com.example.aloha.plugins.Product/examples/triSports.css +86 -0
  111. data/public/javascripts/admin/aloha/plugins/com.example.aloha.plugins.Product/examples/triSports.html +44 -0
  112. data/public/javascripts/admin/aloha/plugins/com.example.aloha.plugins.Product/i18n/de.dict +4 -0
  113. data/public/javascripts/admin/aloha/plugins/com.example.aloha.plugins.Product/i18n/en.dict +4 -0
  114. data/public/javascripts/admin/aloha/plugins/com.example.aloha.plugins.Product/i18n/fr.dict +4 -0
  115. data/public/javascripts/admin/aloha/plugins/com.example.aloha.plugins.Product/plugin.js +1 -0
  116. data/public/javascripts/admin/aloha/plugins/com.example.aloha.plugins.Product/product.js +1 -0
  117. data/public/javascripts/admin/aloha/plugins/com.example.aloha.plugins.Product/resources/2xu-wetsuit.jpg +0 -0
  118. data/public/javascripts/admin/aloha/plugins/com.example.aloha.plugins.Product/resources/asics-noosa.jpg +0 -0
  119. data/public/javascripts/admin/aloha/plugins/com.example.aloha.plugins.Product/resources/fivefingers-kso.jpg +0 -0
  120. data/public/javascripts/admin/aloha/plugins/com.example.aloha.plugins.Product/resources/kuota-kueen-k.jpg +0 -0
  121. data/public/javascripts/admin/aloha/plugins/com.example.aloha.plugins.Product/resources/mizuno-wave-musha2.jpg +0 -0
  122. data/public/javascripts/admin/aloha/plugins/com.example.aloha.plugins.Product/resources/product.css +69 -0
  123. data/public/javascripts/admin/aloha/plugins/com.example.aloha.plugins.Product/resources/product_button.gif +0 -0
  124. data/public/javascripts/admin/aloha/plugins/com.example.aloha.plugins.Product/resources/simplon-mrt.jpg +0 -0
  125. data/public/javascripts/admin/aloha/plugins/com.example.aloha.plugins.Product/resources/trek-fuel-ex.jpg +0 -0
  126. data/public/javascripts/admin/aloha/plugins/com.example.aloha.plugins.Product/resources/trisports.jpg +0 -0
  127. data/public/javascripts/admin/aloha/plugins/com.example.aloha.plugins.Product/resources/zoggs-predator.jpg +0 -0
  128. data/public/javascripts/admin/aloha/plugins/{com.example.aloha.DummySave → com.example.aloha.plugins.Save}/i18n/de.dict +0 -0
  129. data/public/javascripts/admin/aloha/plugins/{com.example.aloha.DummySave → com.example.aloha.plugins.Save}/i18n/en.dict +0 -0
  130. data/public/javascripts/admin/aloha/plugins/{com.example.aloha.DummySave → com.example.aloha.plugins.Save}/i18n/fi.dict +0 -0
  131. data/public/javascripts/admin/aloha/plugins/{com.example.aloha.DummySave → com.example.aloha.plugins.Save}/i18n/fr.dict +0 -0
  132. data/public/javascripts/admin/aloha/plugins/{com.example.aloha.DummySave → com.example.aloha.plugins.Save}/i18n/it.dict +0 -0
  133. data/public/javascripts/admin/aloha/plugins/{com.example.aloha.DummySave → com.example.aloha.plugins.Save}/plugin.js +0 -0
  134. data/public/javascripts/admin/aloha/plugins/com.gentics.aloha.plugins.Abbr/examples/AlohaAbbr.css +48 -0
  135. data/public/javascripts/admin/aloha/plugins/com.gentics.aloha.plugins.Abbr/examples/AlohaAbbr.html +69 -0
  136. data/public/javascripts/admin/aloha/plugins/com.gentics.aloha.plugins.Abbr/i18n/de.dict +4 -0
  137. data/public/javascripts/admin/aloha/plugins/com.gentics.aloha.plugins.Abbr/i18n/en.dict +4 -0
  138. data/public/javascripts/admin/aloha/plugins/com.gentics.aloha.plugins.Abbr/plugin.js +7 -0
  139. data/public/javascripts/admin/aloha/plugins/com.gentics.aloha.plugins.Format/i18n/pl.dict +30 -0
  140. data/public/javascripts/admin/aloha/plugins/com.gentics.aloha.plugins.Format/plugin.js +1 -1
  141. data/public/javascripts/admin/aloha/plugins/com.gentics.aloha.plugins.HighlightEditables/plugin.js +1 -1
  142. data/public/javascripts/admin/aloha/plugins/com.gentics.aloha.plugins.Link/LinkList.js +7 -0
  143. data/public/javascripts/admin/aloha/plugins/com.gentics.aloha.plugins.Link/delicious.js +7 -0
  144. data/public/javascripts/admin/aloha/plugins/com.gentics.aloha.plugins.Link/i18n/pl.dict +4 -0
  145. data/public/javascripts/admin/aloha/plugins/com.gentics.aloha.plugins.Link/plugin.js +1 -1
  146. data/public/javascripts/admin/aloha/plugins/com.gentics.aloha.plugins.LinkChecker/css/LinkChecker.css +14 -0
  147. data/public/javascripts/admin/aloha/plugins/com.gentics.aloha.plugins.LinkChecker/examples/AlohaLinkChecker.css +49 -0
  148. data/public/javascripts/admin/aloha/plugins/com.gentics.aloha.plugins.LinkChecker/examples/AlohaLinkChecker.html +82 -0
  149. data/public/javascripts/admin/aloha/plugins/com.gentics.aloha.plugins.LinkChecker/i18n/en.dict +27 -0
  150. data/public/javascripts/admin/aloha/plugins/com.gentics.aloha.plugins.LinkChecker/plugin.js +7 -0
  151. data/public/javascripts/admin/aloha/plugins/com.gentics.aloha.plugins.LinkChecker/proxy.php +235 -0
  152. data/public/javascripts/admin/aloha/plugins/com.gentics.aloha.plugins.List/plugin.js +1 -1
  153. data/public/javascripts/admin/aloha/plugins/com.gentics.aloha.plugins.Paste/plugin.js +7 -0
  154. data/public/javascripts/admin/aloha/plugins/com.gentics.aloha.plugins.Paste/wordpastehandler.js +7 -0
  155. data/public/javascripts/admin/aloha/plugins/com.gentics.aloha.plugins.TOC/i18n/de.dict +1 -0
  156. data/public/javascripts/admin/aloha/plugins/com.gentics.aloha.plugins.TOC/i18n/en.dict +1 -0
  157. data/public/javascripts/admin/aloha/plugins/com.gentics.aloha.plugins.TOC/plugin.js +1 -1
  158. data/public/javascripts/admin/aloha/plugins/com.gentics.aloha.plugins.Table/i18n/de.dict +2 -0
  159. data/public/javascripts/admin/aloha/plugins/com.gentics.aloha.plugins.Table/i18n/en.dict +2 -0
  160. data/public/javascripts/admin/aloha/plugins/com.gentics.aloha.plugins.Table/i18n/pl.dict +12 -0
  161. data/public/javascripts/admin/aloha/plugins/com.gentics.aloha.plugins.Table/plugin.js +1 -1
  162. data/public/javascripts/admin/aloha/plugins/com.gentics.aloha.plugins.Table/resources/table.css +28 -110
  163. data/public/javascripts/admin/aloha/plugins/com.gentics.aloha.plugins.Table/resources/wai_green.png +0 -0
  164. data/public/javascripts/admin/aloha/plugins/com.gentics.aloha.plugins.Table/resources/wai_red.png +0 -0
  165. data/public/javascripts/admin/asset_collections.js +11 -7
  166. data/public/javascripts/admin/contents.js +3 -1
  167. data/public/javascripts/admin/site.js +9 -3
  168. data/public/javascripts/admin/snippets.js +1 -1
  169. data/public/stylesheets/admin/box.css +5 -0
  170. data/public/stylesheets/admin/formtastic_changes.css +5 -1
  171. data/public/stylesheets/admin/inline_editor.css +22 -5
  172. data/public/stylesheets/admin/installation.css +50 -0
  173. data/public/stylesheets/admin/layout.css +9 -0
  174. metadata +176 -127
  175. data/app/controllers/home_controller.rb +0 -7
  176. data/app/views/admin/snippets/index.html.haml +0 -15
  177. data/app/views/home/show.html.haml +0 -4
  178. data/app/views/layouts/admin/box.html.haml +0 -19
  179. data/app/views/layouts/application.html.haml +0 -7
  180. data/lib/generators/locomotive/copy_assets/copy_assets_generator.rb +0 -14
  181. data/public/javascripts/admin/aloha/plugins/com.example.aloha.DummyDC/i18n/de.dict +0 -2
  182. data/public/javascripts/admin/aloha/plugins/com.example.aloha.DummyDC/i18n/en.dict +0 -2
  183. data/public/javascripts/admin/aloha/plugins/com.example.aloha.DummyDC/i18n/eo.dict +0 -2
  184. data/public/javascripts/admin/aloha/plugins/com.example.aloha.DummyDC/i18n/fi.dict +0 -2
  185. data/public/javascripts/admin/aloha/plugins/com.example.aloha.DummyDC/i18n/fr.dict +0 -2
  186. data/public/javascripts/admin/aloha/plugins/com.example.aloha.DummyDC/i18n/it.dict +0 -2
  187. data/public/javascripts/admin/aloha/plugins/com.example.aloha.DummyDC/plugin.js +0 -7
  188. data/public/javascripts/admin/aloha/plugins/com.gentics.aloha.plugins.GCN/i18n/de.dict +0 -20
  189. data/public/javascripts/admin/aloha/plugins/com.gentics.aloha.plugins.GCN/i18n/en.dict +0 -20
  190. data/public/javascripts/admin/aloha/plugins/com.gentics.aloha.plugins.GCN/i18n/eo.dict +0 -16
  191. data/public/javascripts/admin/aloha/plugins/com.gentics.aloha.plugins.GCN/i18n/fi.dict +0 -20
  192. data/public/javascripts/admin/aloha/plugins/com.gentics.aloha.plugins.GCN/i18n/fr.dict +0 -16
  193. data/public/javascripts/admin/aloha/plugins/com.gentics.aloha.plugins.GCN/i18n/it.dict +0 -20
  194. data/public/javascripts/admin/aloha/plugins/com.gentics.aloha.plugins.GCN/plugin.js +0 -7
  195. data/public/javascripts/admin/aloha/plugins/com.gentics.aloha.plugins.Link/css/jquery.autocomplete.css +0 -48
  196. data/public/javascripts/admin/aloha/plugins/com.gentics.aloha.plugins.Link/deps/jquery.autocomplete.js +0 -1
  197. data/public/javascripts/admin/aloha/plugins/com.gentics.aloha.plugins.Link/ressource.js +0 -7
  198. data/public/javascripts/admin/aloha/plugins/com.gentics.aloha.plugins.Link/ressourcedummy.js +0 -7
  199. data/public/javascripts/admin/aloha/plugins/com.gentics.aloha.plugins.Link/ressourceregistry.js +0 -7
  200. data/public/javascripts/admin/aloha/plugins/eu.iksproject.plugins.Loader/plugin.js +0 -1
  201. data/public/javascripts/admin/aloha/plugins/eu.iksproject.plugins.Person/i18n/en.dict +0 -2
  202. data/public/javascripts/admin/aloha/plugins/eu.iksproject.plugins.Person/i18n/fi.dict +0 -2
  203. data/public/javascripts/admin/aloha/plugins/eu.iksproject.plugins.Person/i18n/fr.dict +0 -2
  204. data/public/javascripts/admin/aloha/plugins/eu.iksproject.plugins.Person/person.css +0 -3
  205. data/public/javascripts/admin/aloha/plugins/eu.iksproject.plugins.Person/plugin.js +0 -1
  206. data/public/javascripts/admin/aloha/plugins/simpletable/plugin.js.deactivated +0 -2330
@@ -1,153 +1,192 @@
1
1
  /*
2
- * Aloha Editor
3
- * Author & Copyright (c) 2010 Gentics Software GmbH
4
- * aloha-sales@gentics.com
5
- * Licensed unter the terms of http://www.aloha-editor.com/license.html
2
+ * This file is part of Aloha Editor
3
+ * Author & Copyright (c) 2010 Gentics Software GmbH, aloha@gentics.com
4
+ * Licensed unter the terms of http://www.aloha-editor.com/license.html
6
5
  */
7
- jQuery.fn.between=function(content,offset){if(this[0].nodeType!==3){if(offset>this.children().size()){offset=this.children().size()}if(offset<=0){this.prepend(content)}else{this.children().eq(offset-1).after(content)}}else{if(offset<=0){this.before(content)}else{if(offset>=this[0].length){this.after(content)}else{var fullText=this[0].data;this[0].data=fullText.substring(0,offset);this.after(fullText.substring(offset,fullText.length));this.after(content)}}}};
6
+ jQuery.fn.between=function(content,offset){if(this[0].nodeType!==3){if(offset>this.children().size()){offset=this.children().size()}if(offset<=0){this.prepend(content)}else{this.children().eq(offset-1).after(content)}}else{if(offset<=0){this.before(content)}else{if(offset>=this[0].length){this.after(content)}else{var fullText=this[0].data;this[0].data=fullText.substring(0,offset);this.after(fullText.substring(offset,fullText.length));this.after(content)}}}};jQuery.fn.removeCss=function(cssName){return this.each(function(){var oldstyle=jQuery(this).attr("style");var style=jQuery.grep(jQuery(this).attr("style").split(";"),function(curStyleAttr){var curStyleAttrName=curStyleAttr.split(":");if(curStyleAttrName[0]){if(curStyleAttrName[0].toUpperCase().trim().indexOf(cssName.toUpperCase())==-1){return curStyleAttr}}}).join(";").trim();jQuery(this).removeAttr("style");if(style.trim()){jQuery(this).attr("style",style)}return jQuery(this)})};jQuery.fn.contentEditable=function(b){var ce="contenteditable";if(jQuery.browser.msie&&parseInt(jQuery.browser.version)==7){ce="contentEditable"}if(b==undefined){return jQuery(this).attr(ce)}else{if(b===""){jQuery(this).removeAttr(ce)}else{if(b&&b!=="false"){b="true"}else{b="false"}jQuery(this).attr(ce,b)}}};
8
7
  /*
9
- * Aloha Editor
10
- * Author & Copyright (c) 2010 Gentics Software GmbH
11
- * aloha-sales@gentics.com
12
- * Licensed unter the terms of http://www.aloha-editor.com/license.html
8
+ * This file is part of Aloha Editor
9
+ * Author & Copyright (c) 2010 Gentics Software GmbH, aloha@gentics.com
10
+ * Licensed unter the terms of http://www.aloha-editor.com/license.html
13
11
  */
14
- if(typeof GENTICS=="undefined"||!GENTICS){var GENTICS={}}if(typeof GENTICS.Utils=="undefined"||!GENTICS){GENTICS.Utils={}}GENTICS.Utils.applyProperties=function(target,properties){var name;for(name in properties){if(properties.hasOwnProperty(name)){target[name]=properties[name]}}};
12
+ if(typeof GENTICS=="undefined"||!GENTICS){var GENTICS={}}if(typeof GENTICS.Utils=="undefined"||!GENTICS){GENTICS.Utils={}}GENTICS.Utils.applyProperties=function(target,properties){var name;for(name in properties){if(properties.hasOwnProperty(name)){target[name]=properties[name]}}};GENTICS.Utils.uniqeString4=function(){return(((1+Math.random())*65536)|0).toString(16).substring(1)};GENTICS.Utils.guid=function(){var S4=GENTICS.Utils.uniqeString4;return(S4()+S4()+"-"+S4()+"-"+S4()+"-"+S4()+"-"+S4()+S4()+S4())};
15
13
  /*
16
- * Aloha Editor
17
- * Author & Copyright (c) 2010 Gentics Software GmbH
18
- * aloha-sales@gentics.com
19
- * Licensed unter the terms of http://www.aloha-editor.com/license.html
14
+ * This file is part of Aloha Editor
15
+ * Author & Copyright (c) 2010 Gentics Software GmbH, aloha@gentics.com
16
+ * Licensed unter the terms of http://www.aloha-editor.com/license.html
20
17
  */
21
18
  if(typeof GENTICS=="undefined"||!GENTICS){var GENTICS={}}if(typeof GENTICS.Utils=="undefined"||!GENTICS){GENTICS.Utils={}}GENTICS.Utils.RangeObject=function(param){this.startContainer;this.startOffset;this.endContainer;this.endOffset;this.startParents=[];this.endParents=[];this.rangeTree=[];if(typeof param==="object"){if(param.startContainer!==undefined){this.startContainer=param.startContainer}if(param.startOffset!==undefined){this.startOffset=param.startOffset}if(param.endContainer!==undefined){this.endContainer=param.endContainer}if(param.endOffset!==undefined){this.endOffset=param.endOffset}}else{if(param===true){this.initializeFromUserSelection()}}};GENTICS.Utils.RangeObject.prototype.log=function(message,obj){if(GENTICS&&GENTICS.Aloha&&GENTICS.Aloha.Log){GENTICS.Aloha.Log.debug(this,message);return false}if(console){console.log(message);if(obj){console.log(obj)}}};GENTICS.Utils.RangeObject.prototype.isCollapsed=function(){return(!this.endContainer||(this.startContainer===this.endContainer&&this.startOffset===this.endOffset))};GENTICS.Utils.RangeObject.prototype.getCommonAncestorContainer=function(){if(this.commonAncestorContainer){return this.commonAncestorContainer}this.updateCommonAncestorContainer();return this.commonAncestorContainer};GENTICS.Utils.RangeObject.prototype.getContainerParents=function(limit,fromEnd){var container=fromEnd?this.endContainer:this.startContainer;var parentStore=fromEnd?this.endParents:this.startParents;if(!container){return false}if(typeof limit=="undefined"){limit=jQuery("body")}if(!parentStore[limit.get(0)]){var parents;if(container.nodeType==3){parents=jQuery(container).parents()}else{parents=jQuery(container).parents();for(var i=parents.length;i>0;--i){parents[i]=parents[i-1]}parents[0]=container}var limitIndex=parents.index(limit);if(limitIndex>=0){parents=parents.slice(0,limitIndex)}parentStore[limit.get(0)]=parents}return parentStore[limit.get(0)]};GENTICS.Utils.RangeObject.prototype.getStartContainerParents=function(limit){return this.getContainerParents(limit,false)};GENTICS.Utils.RangeObject.prototype.getEndContainerParents=function(limit){return this.getContainerParents(limit,true)};GENTICS.Utils.RangeObject.prototype.updateCommonAncestorContainer=function(commonAncestorContainer){var parentsStartContainer=this.getStartContainerParents();var parentsEndContainer=this.getEndContainerParents();if(!commonAncestorContainer){if(!(parentsStartContainer.length>0&&parentsEndContainer.length>0)){GENTICS.Utils.RangeObject.prototype.log("could not find commonAncestorContainer");return false}for(var i=0;i<parentsStartContainer.length;i++){if(parentsEndContainer.index(parentsStartContainer[i])!=-1){this.commonAncestorContainer=parentsStartContainer[i];break}}}else{this.commonAncestorContainer=commonAncestorContainer}GENTICS.Utils.RangeObject.prototype.log(commonAncestorContainer?"commonAncestorContainer was set successfully":"commonAncestorContainer was calculated successfully");return true};GENTICS.Utils.RangeObject.prototype.getCollapsedIERange=function(container,offset){var ieRange=document.body.createTextRange();var left=this.searchElementToLeft(container,offset);if(left.element){var tmpRange=document.body.createTextRange();tmpRange.moveToElementText(left.element);ieRange.setEndPoint("StartToEnd",tmpRange);if(left.characters!=0){ieRange.moveStart("character",left.characters)}else{ieRange.moveStart("character",1);ieRange.moveStart("character",-1)}}else{var right=this.searchElementToRight(container,offset);if(false&&right.element){var tmpRange=document.body.createTextRange();tmpRange.moveToElementText(right.element);ieRange.setEndPoint("StartToStart",tmpRange);if(right.characters!=0){ieRange.moveStart("character",-right.characters)}else{ieRange.moveStart("character",-1);ieRange.moveStart("character",1)}}else{var parent=container.nodeType==3?container.parentNode:container;var tmpRange=document.body.createTextRange();tmpRange.moveToElementText(parent);ieRange.setEndPoint("StartToStart",tmpRange);if(left.characters!=0){ieRange.moveStart("character",left.characters)}}}ieRange.collapse();return ieRange};GENTICS.Utils.RangeObject.prototype.select=document.createRange===undefined?function(){if(GENTICS.Aloha.Log.isDebugEnabled()){GENTICS.Aloha.Log.debug(this,"Set selection to current range (IE version)")}if(this.startContainer.nodeType==3&&GENTICS.Utils.Dom.isBlockLevelElement(this.startContainer.nextSibling)){jQuery(this.startContainer).after("<br/>");if(this.endContainer===this.startContainer.parentNode&&GENTICS.Utils.Dom.getIndexInParent(this.startContainer)<this.endOffset){this.endOffset++}}var ieRange=document.body.createTextRange();var startRange=this.getCollapsedIERange(this.startContainer,this.startOffset);ieRange.setEndPoint("StartToStart",startRange);if(this.isCollapsed()){ieRange.collapse()}else{var endRange=this.getCollapsedIERange(this.endContainer,this.endOffset);ieRange.setEndPoint("EndToStart",endRange)}ieRange.select()}:function(){if(GENTICS.Aloha.Log.isDebugEnabled()){GENTICS.Aloha.Log.debug(this,"Set selection to current range (non IE version)")}var range=document.createRange();range.setStart(this.startContainer,this.startOffset);range.setEnd(this.endContainer,this.endOffset);window.getSelection().removeAllRanges();window.getSelection().addRange(range)};GENTICS.Utils.RangeObject.prototype.searchElementToLeft=function(container,offset){var checkElement=undefined;var characters=0;if(container.nodeType==3){characters=offset;checkElement=container.previousSibling}else{if(offset>0){checkElement=container.childNodes[offset-1]}}while(checkElement&&checkElement.nodeType==3){characters+=checkElement.data.length;checkElement=checkElement.previousSibling}return{element:checkElement,characters:characters}};GENTICS.Utils.RangeObject.prototype.searchElementToRight=function(container,offset){var checkElement=undefined;var characters=0;if(container.nodeType==3){characters=container.data.length-offset;checkElement=container.nextSibling}else{if(offset<container.childNodes.length){checkElement=container.childNodes[offset]}}while(checkElement&&checkElement.nodeType==3){characters+=checkElement.data.length;checkElement=checkElement.nextSibling}return{element:checkElement,characters:characters}};GENTICS.Utils.RangeObject.prototype.update=function(event){GENTICS.Utils.RangeObject.prototype.log("==========");GENTICS.Utils.RangeObject.prototype.log("now updating rangeObject");this.initializeFromUserSelection(event);this.updateCommonAncestorContainer()};GENTICS.Utils.RangeObject.prototype.initializeFromUserSelection=function(event){var selection=window.getSelection();if(!selection){return false}var browserRange=selection.getRangeAt(0);if(!browserRange){return false}this.startContainer=browserRange.startContainer;this.endContainer=browserRange.endContainer;this.startOffset=browserRange.startOffset;this.endOffset=browserRange.endOffset;this.correctRange();return};GENTICS.Utils.RangeObject.prototype.correctRange=function(){this.clearCaches();if(this.isCollapsed()){if(this.startContainer.nodeType==1){if(this.startOffset>0&&this.startContainer.childNodes[this.startOffset-1].nodeType==3){this.startContainer=this.startContainer.childNodes[this.startOffset-1];this.startOffset=this.startContainer.data.length;this.endContainer=this.startContainer;this.endOffset=this.startOffset;return}if(this.startOffset>0&&this.startContainer.childNodes[this.startOffset-1].nodeType==1){var adjacentTextNode=GENTICS.Utils.Dom.searchAdjacentTextNode(this.startContainer,this.startOffset,true);if(adjacentTextNode){this.startContainer=this.endContainer=adjacentTextNode;this.startOffset=this.endOffset=adjacentTextNode.data.length;return}adjacentTextNode=GENTICS.Utils.Dom.searchAdjacentTextNode(this.startContainer,this.startOffset,false);if(adjacentTextNode){this.startContainer=this.endContainer=adjacentTextNode;this.startOffset=this.endOffset=0;return}}if(this.startOffset<this.startContainer.childNodes.length&&this.startContainer.childNodes[this.startOffset].nodeType==3){this.startContainer=this.startContainer.childNodes[this.startOffset];this.startOffset=0;this.endContainer=this.startContainer;this.endOffset=0;return}}if(this.startContainer.nodeType==3&&this.startOffset==0){var adjacentTextNode=GENTICS.Utils.Dom.searchAdjacentTextNode(this.startContainer.parentNode,GENTICS.Utils.Dom.getIndexInParent(this.startContainer),true);if(adjacentTextNode){this.startContainer=this.endContainer=adjacentTextNode;this.startOffset=this.endOffset=adjacentTextNode.data.length}}}else{if(this.startContainer.nodeType==1){if(this.startOffset<this.startContainer.childNodes.length&&this.startContainer.childNodes[this.startOffset].nodeType==3){this.startContainer=this.startContainer.childNodes[this.startOffset];this.startOffset=0}else{if(this.startOffset<this.startContainer.childNodes.length&&this.startContainer.childNodes[this.startOffset].nodeType==1){var textNode=false;var checkedElement=this.startContainer.childNodes[this.startOffset];while(textNode===false&&checkedElement.childNodes&&checkedElement.childNodes.length>0){checkedElement=checkedElement.childNodes[0];if(checkedElement.nodeType==3){textNode=checkedElement}}if(textNode!==false){this.startContainer=textNode;this.startOffset=0}}}}if(this.startContainer.nodeType==3&&this.startOffset==this.startContainer.data.length){var adjacentTextNode=GENTICS.Utils.Dom.searchAdjacentTextNode(this.startContainer.parentNode,GENTICS.Utils.Dom.getIndexInParent(this.startContainer)+1,false);if(adjacentTextNode){this.startContainer=adjacentTextNode;this.startOffset=0}}if(this.endContainer.nodeType==3&&this.endOffset==0){if(this.endContainer.previousSibling&&this.endContainer.previousSibling.nodeType==3){this.endContainer=this.endContainer.previousSibling;this.endOffset=this.endContainer.data.length}else{if(this.endContainer.previousSibling&&this.endContainer.previousSibling.nodeType==1&&this.endContainer.parentNode){var parentNode=this.endContainer.parentNode;for(var offset=0;offset<parentNode.childNodes.length;++offset){if(parentNode.childNodes[offset]==this.endContainer){this.endOffset=offset;break}}this.endContainer=parentNode}}}if(this.endContainer.nodeType==1&&this.endOffset==0){if(this.endContainer.previousSibling){if(this.endContainer.previousSibling.nodeType==3){this.endContainer=this.endContainer.previousSibling;this.endOffset=this.endContainer.data.length}else{if(this.endContainer.previousSibling.nodeType==1&&this.endContainer.previousSibling.childNodes&&this.endContainer.previousSibling.childNodes.length>0){this.endContainer=this.endContainer.previousSibling;this.endOffset=this.endContainer.childNodes.length}}}}if(this.endContainer.nodeType==1){if(this.endOffset>0&&this.endContainer.childNodes[this.endOffset-1].nodeType==3){this.endContainer=this.endContainer.childNodes[this.endOffset-1];this.endOffset=this.endContainer.data.length}else{if(this.endOffset>0&&this.endContainer.childNodes[this.endOffset-1].nodeType==1){var textNode=false;var checkedElement=this.endContainer.childNodes[this.endOffset-1];while(textNode===false&&checkedElement.childNodes&&checkedElement.childNodes.length>0){checkedElement=checkedElement.childNodes[checkedElement.childNodes.length-1];if(checkedElement.nodeType==3){textNode=checkedElement}}if(textNode!==false){this.endContainer=textNode;this.endOffset=this.endContainer.data.length}}}}}};GENTICS.Utils.RangeObject.prototype.clearCaches=function(){this.rangeTree=[];this.startParents=[];this.endParents=[];this.commonAncestorContainer=undefined};GENTICS.Utils.RangeObject.prototype.getRangeTree=function(root){if(typeof root=="undefined"){root=this.getCommonAncestorContainer()}if(this.rangeTree[root]){return this.rangeTree[root]}this.inselection=false;this.rangeTree[root]=this.recursiveGetRangeTree(root);return this.rangeTree[root]};GENTICS.Utils.RangeObject.prototype.recursiveGetRangeTree=function(currentObject){var jQueryCurrentObject=jQuery(currentObject);var childCount=0;var that=this;var currentElements=new Array();jQueryCurrentObject.contents().each(function(index){var type="none";var startOffset=false;var endOffset=false;var collapsedFound=false;if(that.isCollapsed()&&currentObject===that.startContainer&&that.startOffset==index){currentElements[childCount]=new GENTICS.Utils.RangeTree();currentElements[childCount].type="collapsed";currentElements[childCount].domobj=undefined;that.inselection=false;collapsedFound=true;childCount++}if(!that.inselection&&!collapsedFound){switch(this.nodeType){case 3:if(this===that.startContainer){that.inselection=true;type=that.startOffset>0?"partial":"full";startOffset=that.startOffset;endOffset=this.length}break;case 1:if(this===that.startContainer&&that.startOffset==0){that.inselection=true;type="full"}if(currentObject===that.startContainer&&that.startOffset==index){that.inselection=true;type="full"}break}}if(that.inselection&&!collapsedFound){if(type=="none"){type="full"}switch(this.nodeType){case 3:if(this===that.endContainer){that.inselection=false;if(that.endOffset<this.length){type="partial"}if(startOffset===false){startOffset=0}endOffset=that.endOffset}break;case 1:if(this===that.endContainer&&that.endOffset==0){that.inselection=false}break}if(currentObject===that.endContainer&&that.endOffset<=index){that.inselection=false;type="none"}}currentElements[childCount]=new GENTICS.Utils.RangeTree();currentElements[childCount].domobj=this;currentElements[childCount].type=type;if(type=="partial"){currentElements[childCount].startOffset=startOffset;currentElements[childCount].endOffset=endOffset}currentElements[childCount].children=that.recursiveGetRangeTree(this);if(currentElements[childCount].children.length>0){var noneFound=false;var partialFound=false;var fullFound=false;for(var i=0;i<currentElements[childCount].children.length;++i){switch(currentElements[childCount].children[i].type){case"none":noneFound=true;break;case"full":fullFound=true;break;case"partial":partialFound=true;break}}if(partialFound||(fullFound&&noneFound)){currentElements[childCount].type="partial"}else{if(fullFound&&!partialFound&&!noneFound){currentElements[childCount].type="full"}}}childCount++});if(this.isCollapsed()&&currentObject===this.startContainer&&this.startOffset==currentObject.childNodes.length){currentElements[childCount]=new GENTICS.Utils.RangeTree();currentElements[childCount].type="collapsed";currentElements[childCount].domobj=undefined}return currentElements};GENTICS.Utils.RangeObject.prototype.findMarkup=function(comparator,limit,atEnd){var parents=this.getContainerParents(limit,atEnd);var returnValue=false;jQuery.each(parents,function(index,domObj){if(comparator.apply(domObj)){returnValue=domObj;return false}});return returnValue};GENTICS.Utils.RangeTree=function(){this.domobj=new Object();this.type;this.children=new Array()};
22
19
  /*
23
- * Aloha Editor
24
- * Author & Copyright (c) 2010 Gentics Software GmbH
25
- * aloha-sales@gentics.com
26
- * Licensed unter the terms of http://www.aloha-editor.com/license.html
20
+ * This file is part of Aloha Editor
21
+ * Author & Copyright (c) 2010 Gentics Software GmbH, aloha@gentics.com
22
+ * Licensed unter the terms of http://www.aloha-editor.com/license.html
27
23
  */
28
24
  if(typeof GENTICS=="undefined"||!GENTICS){var GENTICS={}}if(typeof GENTICS.Utils=="undefined"||!GENTICS){GENTICS.Utils={}}GENTICS.Utils.Position={};GENTICS.Utils.Position.w=jQuery(window);GENTICS.Utils.Position.Scroll={top:0,left:0,isScrolling:false};GENTICS.Utils.Position.Mouse={x:0,y:0,oldX:0,oldY:0,isMoving:false,triggeredMouseStop:true};GENTICS.Utils.Position.mouseStopCallbacks=new Array();GENTICS.Utils.Position.mouseMoveCallbacks=new Array();GENTICS.Utils.Position.update=function(){var st=this.w.scrollTop();var sl=this.w.scrollLeft();if(this.Scroll.isScrolling){if(this.Scroll.top==st&&this.Scroll.left==sl){this.Scroll.isScrolling=false}}else{if(this.Scroll.top!=st||this.Scroll.left!=sl){this.Scroll.isScrolling=true}}this.Scroll.top=st;this.Scroll.left=sl;if(this.Mouse.x==this.Mouse.oldX&&this.Mouse.y==this.Mouse.oldY){this.Mouse.isMoving=false;if(!this.Mouse.triggeredMouseStop){this.Mouse.triggeredMouseStop=true;for(var i=0;i<this.mouseStopCallbacks.length;i++){this.mouseStopCallbacks[i].call()}}}else{this.Mouse.isMoving=true;this.Mouse.triggeredMouseStop=false;for(var i=0;i<this.mouseMoveCallbacks.length;i++){this.mouseMoveCallbacks[i].call()}}this.Mouse.oldX=this.Mouse.x;this.Mouse.oldY=this.Mouse.y};GENTICS.Utils.Position.addMouseStopCallback=function(callback){this.mouseStopCallbacks.push(callback);return(this.mouseStopCallbacks.length-1)};GENTICS.Utils.Position.addMouseMoveCallback=function(callback){this.mouseMoveCallbacks.push(callback);return(this.mouseMoveCallbacks.length-1)};setInterval("GENTICS.Utils.Position.update()",500);jQuery("html").mousemove(function(e){GENTICS.Utils.Position.Mouse.x=e.pageX;GENTICS.Utils.Position.Mouse.y=e.pageY});
29
25
  /*
30
- * Aloha Editor
31
- * Author & Copyright (c) 2010 Gentics Software GmbH
32
- * aloha-sales@gentics.com
33
- * Licensed unter the terms of http://www.aloha-editor.com/license.html
26
+ * This file is part of Aloha Editor
27
+ * Author & Copyright (c) 2010 Gentics Software GmbH, aloha@gentics.com
28
+ * Licensed unter the terms of http://www.aloha-editor.com/license.html
29
+ */
30
+ if(typeof GENTICS=="undefined"||!GENTICS){var GENTICS={}}if(typeof GENTICS.Utils=="undefined"||!GENTICS.Utils){GENTICS.Utils={}}if(typeof GENTICS.Utils.Dom=="undefined"||!GENTICS.Utils.Dom){GENTICS.Utils.Dom=function(){}}GENTICS.Utils.Dom.prototype.mergeableTags=["a","b","code","del","em","i","ins","strong","sub","sup","#text"];GENTICS.Utils.Dom.prototype.nonWordBoundaryTags=["a","b","code","del","em","i","ins","span","strong","sub","sup","#text"];GENTICS.Utils.Dom.prototype.nonEmptyTags=["br"];GENTICS.Utils.Dom.prototype.tags={flow:["a","abbr","address","area","article","aside","audio","b","bdo","blockquote","br","button","canvas","cite","code","command","datalist","del","details","dfn","div","dl","em","embed","fieldset","figure","footer","form","h1","h2","h3","h4","h5","h6","header","hgroup","hr","i","iframe","img","input","ins","kbd","keygen","label","map","mark","math","menu","meter","nav","noscript","object","ol","output","p","pre","progress","q","ruby","samp","script","section","select","small","span","strong","style","sub","sup","svg","table","textarea","time","ul","var","video","wbr","#text"],phrasing:["a","abbr","area","audio","b","bdo","br","button","canvas","cite","code","command","datalist","del","dfn","em","embed","i","iframe","img","input","ins","kbd","keygen","label","map","mark","math","meter","noscript","object","output","progress","q","ruby","samp","script","select","small","span","strong","sub","sup","svg","textarea","time","var","video","wbr","#text"]};GENTICS.Utils.Dom.prototype.children={a:"phrasing",abbr:"phrasing",address:"flow",area:"empty",article:"flow",aside:"flow",audio:"source",b:"phrasing",base:"empty",bdo:"phrasing",blockquote:"flow",body:"flow",br:"empty",button:"phrasing",canvas:"phrasing",caption:"flow",cite:"phrasing",code:"phrasing",col:"empty",colgroup:"col",command:"empty",datalist:["phrasing","option"],dd:"flow",del:"phrasing",div:"flow",details:["summary","flow"],dfn:"flow",div:"flow",dl:["dt","dd"],dt:"phrasing",em:"phrasing",embed:"empty",fieldset:["legend","flow"],figcaption:"flow",figure:["figcaption","flow"],footer:"flow",form:"flow",h1:"phrasing",h2:"phrasing",h3:"phrasing",h4:"phrasing",h5:"phrasing",h6:"phrasing",header:"flow",hgroup:["h1","h2","h3","h4","h5","h6"],hr:"empty",i:"phrasing",iframe:"#text",img:"empty",input:"empty",ins:"phrasing",kbd:"phrasing",keygen:"empty",label:"phrasing",legend:"phrasing",li:"flow",link:"empty",map:"area",mark:"phrasing",menu:["li","flow"],meta:"empty",meter:"phrasing",nav:"flow",noscript:"phrasing",object:"param",ol:"li",optgroup:"option",option:"#text",output:"phrasing",p:"phrasing",param:"empty",pre:"phrasing",progress:"phrasing",q:"phrasing",rp:"phrasing",rt:"phrasing",ruby:["phrasing","rt","rp"],s:"phrasing",samp:"pharsing",script:"#script",section:"flow",select:["option","optgroup"],small:"phrasing",source:"empty",span:"phrasing",strong:"phrasing",style:"phrasing",sub:"phrasing",summary:"phrasing",sup:"phrasing",table:["caption","colgroup","thead","tbody","tfoot","tr"],tbody:"tr",td:"flow",textarea:"#text",tfoot:"tr",th:"phrasing",thead:"tr",time:"phrasing",title:"#text",tr:["th","td"],track:"empty",ul:"li","var":"phrasing",video:"source",wbr:"empty"};GENTICS.Utils.Dom.prototype.blockLevelElements=["p","h1","h2","h3","h4","h5","h6","blockquote","div","pre"];GENTICS.Utils.Dom.prototype.listElements=["li","ol","ul"];GENTICS.Utils.Dom.prototype.split=function(range,limit,atEnd){var splitElement=jQuery(range.startContainer);var splitPosition=range.startOffset;if(atEnd){splitElement=jQuery(range.endContainer);splitPosition=range.endOffset}if(limit.length<1){limit=jQuery(document.body)}var updateRange=(!range.isCollapsed()&&!atEnd);var path;var parents=splitElement.parents().get();parents.unshift(splitElement.get(0));jQuery.each(parents,function(index,element){var isLimit=limit.filter(function(){return this==element}).length;if(isLimit){if(index>0){path=parents.slice(0,index)}return false}});if(!path){return true}path=path.reverse();var newDom;var insertElement;for(var i=0;i<path.length;i++){var element=path[i];if(i===path.length-1){var secondPart;if(element.nodeType===3){secondPart=document.createTextNode(element.data.substring(splitPosition,element.data.length));element.data=element.data.substring(0,splitPosition)}else{var newElement=jQuery(element).clone(false).empty();var children=jQuery(element).contents();secondPart=newElement.append(children.slice(splitPosition,children.length)).get(0)}if(updateRange&&range.endContainer===element){range.endContainer=secondPart;range.endOffset-=splitPosition;range.clearCaches()}if(insertElement){insertElement.prepend(secondPart)}else{jQuery(element).after(secondPart)}}else{var newElement=jQuery(element).clone(false).empty();if(!newDom){newDom=newElement;insertElement=newElement}else{insertElement.prepend(newElement);insertElement=newElement}var next;while(next=path[i+1].nextSibling){insertElement.append(next)}if(updateRange&&range.endContainer===element){range.endContainer=newElement.get(0);var prev=path[i+1];var offset=0;while(prev=prev.previousSibling){offset++}range.endOffset-=offset;range.clearCaches()}}}jQuery(path[0]).after(newDom);return jQuery([path[0],newDom?newDom.get(0):secondPart])};GENTICS.Utils.Dom.prototype.allowsNesting=function(outerDOMObject,innerDOMObject){if(!outerDOMObject||!outerDOMObject.nodeName||!innerDOMObject||!innerDOMObject.nodeName){return false}var outerNodeName=outerDOMObject.nodeName.toLowerCase();var innerNodeName=innerDOMObject.nodeName.toLowerCase();if(!this.children[outerNodeName]){return false}if(this.children[outerNodeName]==innerNodeName){return true}if(jQuery.isArray(this.children[outerNodeName])&&jQuery.inArray(innerNodeName,this.children[outerNodeName])>=0){return true}if(jQuery.isArray(this.tags[this.children[outerNodeName]])&&jQuery.inArray(innerNodeName,this.tags[this.children[outerNodeName]])>=0){return true}return false};GENTICS.Utils.Dom.prototype.addMarkup=function(rangeObject,markup,nesting){if(rangeObject.startContainer.nodeType==3&&rangeObject.startOffset>0&&rangeObject.startOffset<rangeObject.startContainer.data.length){this.split(rangeObject,jQuery(rangeObject.startContainer).parent(),false)}if(rangeObject.endContainer.nodeType==3&&rangeObject.endOffset>0&&rangeObject.endOffset<rangeObject.endContainer.data.length){this.split(rangeObject,jQuery(rangeObject.endContainer).parent(),true)}var rangeTree=rangeObject.getRangeTree();this.recursiveAddMarkup(rangeTree,markup,rangeObject,nesting);this.doCleanup({merge:true,removeempty:true},rangeObject)};GENTICS.Utils.Dom.prototype.recursiveAddMarkup=function(rangeTree,markup,rangeObject,nesting){for(var i=0;i<rangeTree.length;++i){if(rangeTree[i].type=="full"&&this.allowsNesting(markup.get(0),rangeTree[i].domobj)){if((nesting||rangeTree[i].domobj.nodeName!=markup.get(0).nodeName)&&(rangeTree[i].domobj.nodeType!=3||jQuery.trim(rangeTree[i].domobj.data).length!=0)){jQuery(rangeTree[i].domobj).wrap(markup);if(!nesting&&rangeTree[i].domobj.nodeType!=3){var innerRange=new GENTICS.Utils.RangeObject();innerRange.startContainer=innerRange.endContainer=rangeTree[i].domobj.parentNode;innerRange.startOffset=0;innerRange.endOffset=innerRange.endContainer.childNodes.length;this.removeMarkup(innerRange,markup,jQuery(rangeTree[i].domobj.parentNode))}}}else{if(false){}else{if(nesting||rangeTree[i].domobj.nodeName!=markup.get(0).nodeName){if(rangeTree[i].children&&rangeTree[i].children.length>0){this.recursiveAddMarkup(rangeTree[i].children,markup)}}}}}};GENTICS.Utils.Dom.prototype.findHighestElement=function(start,nodeName,limit){var testObject=start;nodeName=nodeName.toLowerCase();var isLimit=limit?function(){return limit.filter(function(){return testObject==this}).length}:function(){return false};var highestObject=undefined;while(!isLimit()&&testObject){if(testObject.nodeName.toLowerCase()==nodeName){highestObject=testObject}testObject=testObject.parentNode}return highestObject};GENTICS.Utils.Dom.prototype.removeMarkup=function(rangeObject,markup,limit){var nodeName=markup.get(0).nodeName;var startSplitLimit=this.findHighestElement(rangeObject.startContainer,nodeName,limit);var endSplitLimit=this.findHighestElement(rangeObject.endContainer,nodeName,limit);var didSplit=false;if(startSplitLimit){this.split(rangeObject,jQuery(startSplitLimit).parent(),false);didSplit=true}if(endSplitLimit){this.split(rangeObject,jQuery(endSplitLimit).parent(),true);didSplit=true}if(didSplit){rangeObject.correctRange()}var highestObject=this.findHighestElement(rangeObject.getCommonAncestorContainer(),nodeName,limit);var root=highestObject?highestObject.parentNode:undefined;var rangeTree=rangeObject.getRangeTree(root);this.recursiveRemoveMarkup(rangeTree,markup);this.doCleanup({merge:true,removeempty:true},rangeObject,root)};GENTICS.Utils.Dom.prototype.recursiveRemoveMarkup=function(rangeTree,markup){for(var i=0;i<rangeTree.length;++i){if(rangeTree[i].type=="full"&&rangeTree[i].domobj.nodeName==markup.get(0).nodeName){var content=jQuery(rangeTree[i].domobj).contents();if(content.length>0){content.first().unwrap()}else{jQuery(rangeTree[i].domobj).remove()}}if(rangeTree[i].children){this.recursiveRemoveMarkup(rangeTree[i].children,markup)}}};GENTICS.Utils.Dom.prototype.doCleanup=function(cleanup,rangeObject,start){var that=this;if(typeof cleanup=="undefined"){cleanup={merge:true,removeempty:true}}if(typeof start=="undefined"){if(rangeObject){start=rangeObject.getCommonAncestorContainer()}}var prevNode=false;var modifiedRange=false;var startObject=jQuery(start);startObject.contents().each(function(index){switch(this.nodeType){case 1:if(prevNode&&prevNode.nodeName==this.nodeName){if(rangeObject.startContainer===startObject&&rangeObject.startOffset>index){rangeObject.startOffset-=1;modifiedRange=true}if(rangeObject.endContainer===startObject&&rangeObject.endOffset>index){rangeObject.endOffset-=1;modifiedRange=true}jQuery(prevNode).append(jQuery(this).contents());modifiedRange|=that.doCleanup(cleanup,rangeObject,prevNode);jQuery(this).remove()}else{modifiedRange|=that.doCleanup(cleanup,rangeObject,this);var removed=false;if(cleanup.removeempty){if(GENTICS.Utils.Dom.isBlockLevelElement(this)&&this.childNodes.length==0){jQuery(this).remove();removed=true}if(jQuery.inArray(this.nodeName.toLowerCase(),that.mergeableTags)>=0&&jQuery(this).text().length==0&&this.childNodes.length==0){jQuery(this).remove();removed=true}}if(!removed){if(jQuery.inArray(this.nodeName.toLowerCase(),that.mergeableTags)>=0){prevNode=this}else{prevNode=false}}}break;case 3:if(prevNode&&prevNode.nodeType==3&&cleanup.merge){if(rangeObject.startContainer===this){rangeObject.startContainer=prevNode;rangeObject.startOffset+=prevNode.length;modifiedRange=true}if(rangeObject.endContainer===this){rangeObject.endContainer=prevNode;rangeObject.endOffset+=prevNode.length;modifiedRange=true}if(rangeObject.startContainer===startObject&&rangeObject.startOffset>index){rangeObject.startOffset-=1;modifiedRange=true}if(rangeObject.endContainer===startObject&&rangeObject.endOffset>index){rangeObject.endOffset-=1;modifiedRange=true}prevNode.data+=this.data;jQuery(this).remove()}else{prevNode=this}break}});if(cleanup.removeempty&&GENTICS.Utils.Dom.isBlockLevelElement(start)&&(!start.childNodes||start.childNodes.length==0)){if(rangeObject.startContainer==start){rangeObject.startContainer=start.parentNode;rangeObject.startOffset=GENTICS.Utils.Dom.getIndexInParent(start)}if(rangeObject.endContainer==start){rangeObject.endContainer=start.parentNode;rangeObject.endOffset=GENTICS.Utils.Dom.getIndexInParent(start)}startObject.remove();modifiedRange=true}if(modifiedRange){rangeObject.clearCaches()}return modifiedRange};GENTICS.Utils.Dom.prototype.getIndexInParent=function(node){if(!node){return false}var index=0;var check=node.previousSibling;while(check){index++;check=check.previousSibling}return index};GENTICS.Utils.Dom.prototype.isBlockLevelElement=function(node){if(!node){return false}if(node.nodeType==1&&jQuery.inArray(node.nodeName.toLowerCase(),this.blockLevelElements)>=0){return true}else{return false}};GENTICS.Utils.Dom.prototype.isLineBreakElement=function(node){if(!node){return false}return node.nodeType==1&&node.nodeName.toLowerCase()=="br"};GENTICS.Utils.Dom.prototype.isListElement=function(node){if(!node){return false}return node.nodeType==1&&jQuery.inArray(node.nodeName.toLowerCase(),this.listElements)>=0};GENTICS.Utils.Dom.prototype.isSplitObject=function(el){if(el.nodeType===1){switch(el.nodeName.toLowerCase()){case"p":case"h1":case"h2":case"h3":case"h4":case"h5":case"h6":case"li":return true}}return false};GENTICS.Utils.Dom.prototype.searchAdjacentTextNode=function(parent,index,searchleft,stopat){if(!parent||parent.nodeType!=1||index<0||index>parent.childNodes.length){return false}if(typeof stopat=="undefined"){stopat={blocklevel:true,list:true,linebreak:true}}if(stopat.blocklevel=="undefined"){stopal.blocklevel=true}if(stopat.list=="undefined"){stopal.list=true}if(stopat.linebreak=="undefined"){stopal.linebreak=true}if(typeof searchleft=="undefined"){searchleft=true}var nextNode=undefined;var currentParent=parent;if(searchleft&&index>0){nextNode=parent.childNodes[index-1]}if(!searchleft&&index<parent.childNodes.length){nextNode=parent.childNodes[index]}while(typeof currentParent!="undefined"){if(!nextNode){if(stopat.blocklevel&&this.isBlockLevelElement(currentParent)){return false}else{if(stopat.list&&this.isListElement(currentParent)){return false}else{nextNode=searchleft?currentParent.previousSibling:currentParent.nextSibling;currentParent=currentParent.parentNode}}}else{if(nextNode.nodeType==3&&jQuery.trim(nextNode.data).length>0){return nextNode}else{if(stopat.blocklevel&&this.isBlockLevelElement(nextNode)){return false}else{if(stopat.linebreak&&this.isLineBreakElement(nextNode)){return false}else{if(stopat.list&&this.isListElement(nextNode)){return false}else{if(nextNode.nodeType==3){nextNode=searchleft?nextNode.previousSibling:nextNode.nextSibling}else{currentParent=nextNode;nextNode=searchleft?nextNode.lastChild:nextNode.firstChild}}}}}}}};GENTICS.Utils.Dom.prototype.insertIntoDOM=function(object,range,limit,atEnd){var parentElements=range.getContainerParents(limit,atEnd);var that=this;var newParent;if(!limit){limit=jQuery(document.body)}if(parentElements.length==0){newParent=limit.get(0)}else{jQuery.each(parentElements,function(index,parent){if(that.allowsNesting(parent,object.get(0))){newParent=parent;return false}})}if(typeof newParent=="undefined"&&limit.length>0){newParent=limit.get(0)}if(typeof newParent!="undefined"){var splitParts=this.split(range,jQuery(newParent),atEnd);if(splitParts===true){var container=range.startContainer;var offset=range.startOffset;if(atEnd){container=range.endContainer;offset=range.endOffset}if(offset==0){var contents=jQuery(container).contents();if(contents.length>0){contents.eq(0).before(object)}else{jQuery(container).append(object)}return true}else{jQuery(container).contents().eq(offset-1).after(object);return true}}else{if(splitParts){splitParts.eq(0).after(object);return true}else{return false}}}else{return false}};GENTICS.Utils.Dom.prototype.removeFromDOM=function(object,range,preserveContent){if(preserveContent){var indexInParent=this.getIndexInParent(object);var numChildren=jQuery(object).contents().length;var parent=object.parentNode;if(range.startContainer==parent&&range.startOffset>indexInParent){range.startOffset+=numChildren-1}else{if(range.startContainer==object){range.startContainer=parent;range.startOffset=indexInParent+range.startOffset}}if(range.endContainer==parent&&range.endOffset>indexInParent){range.endOffset+=numChildren-1}else{if(range.endContainer==object){range.endContainer=parent;range.endOffset=indexInParent+range.endOffset}}jQuery(object).contents().unwrap();this.doCleanup({merge:true},range,parent)}else{}};GENTICS.Utils.Dom.prototype.extendToWord=function(range,fromBoundaries){var leftBoundary=this.searchWordBoundary(range.startContainer,range.startOffset,true);var rightBoundary=this.searchWordBoundary(range.endContainer,range.endOffset,false);if(!fromBoundaries){if(range.startContainer==leftBoundary.container&&range.startOffset==leftBoundary.offset){return}if(range.endContainer==rightBoundary.container&&range.endOffset==rightBoundary.offset){return}}range.startContainer=leftBoundary.container;range.startOffset=leftBoundary.offset;range.endContainer=rightBoundary.container;range.endOffset=rightBoundary.offset;range.correctRange();range.clearCaches()};GENTICS.Utils.Dom.prototype.isWordBoundaryElement=function(object){if(!object||!object.nodeName){return false}return jQuery.inArray(object.nodeName.toLowerCase(),this.nonWordBoundaryTags)==-1};GENTICS.Utils.Dom.prototype.searchWordBoundary=function(container,offset,searchleft){if(typeof searchleft=="undefined"){searchleft=true}var boundaryFound=false;while(!boundaryFound){if(container.nodeType==3){if(!searchleft){var wordBoundaryPos=container.data.substring(offset).search(/\W/);if(wordBoundaryPos!=-1){offset=offset+wordBoundaryPos;boundaryFound=true}else{offset=this.getIndexInParent(container)+1;container=container.parentNode}}else{var wordBoundaryPos=container.data.substring(0,offset).search(/\W/);var tempWordBoundaryPos=wordBoundaryPos;while(tempWordBoundaryPos!=-1){wordBoundaryPos=tempWordBoundaryPos;tempWordBoundaryPos=container.data.substring(wordBoundaryPos+1,offset).search(/\W/);if(tempWordBoundaryPos!=-1){tempWordBoundaryPos=tempWordBoundaryPos+wordBoundaryPos+1}}if(wordBoundaryPos!=-1){offset=wordBoundaryPos+1;boundaryFound=true}else{offset=this.getIndexInParent(container);container=container.parentNode}}}else{if(container.nodeType==1){if(!searchleft){if(offset<container.childNodes.length){if(this.isWordBoundaryElement(container.childNodes[offset])){boundaryFound=true}else{container=container.childNodes[offset];offset=0}}else{if(this.isWordBoundaryElement(container)){boundaryFound=true}else{offset=this.getIndexInParent(container)+1;container=container.parentNode}}}else{if(offset>0){if(this.isWordBoundaryElement(container.childNodes[offset-1])){boundaryFound=true}else{container=container.childNodes[offset-1];offset=container.nodeType==3?container.data.length:container.childNodes.length}}else{if(this.isWordBoundaryElement(container)){boundaryFound=true}else{offset=this.getIndexInParent(container);container=container.parentNode}}}}}}if(container.nodeType!=3){var textNode=this.searchAdjacentTextNode(container,offset,!searchleft);if(textNode){container=textNode;offset=searchleft?0:container.data.length}}return{container:container,offset:offset}};GENTICS.Utils.Dom.prototype.isEmpty=function(domObject){if(!domObject){return true}if(jQuery.inArray(domObject.nodeName.toLowerCase(),this.nonEmptyTags)!=-1){return false}if(domObject.nodeType==3){return domObject.data.search(/\S/)==-1}for(var i=0;i<domObject.childNodes.length;++i){if(!this.isEmpty(domObject.childNodes[i])){return false}}return true};GENTICS.Utils.Dom.prototype.setCursorAfter=function(domObject){var newRange=new GENTICS.Utils.RangeObject();newRange.startContainer=newRange.endContainer=domObject.parentNode;newRange.startOffset=newRange.endOffset=this.getIndexInParent(domObject);newRange.select()};GENTICS.Utils.Dom.prototype.setCursorInto=function(domObject){var newRange=new GENTICS.Utils.RangeObject();newRange.startContainer=newRange.endContainer=domObject;newRange.startOffset=newRange.endOffset=0;newRange.select()};GENTICS.Utils.Dom=new GENTICS.Utils.Dom();
31
+ /*
32
+ * Aloha Editor is free software: you can redistribute it and/or modify
33
+ * it under the terms of the GNU Affero General Public License as published by
34
+ * the Free Software Foundation, either version 3 of the License, or
35
+ * (at your option) any later version.*
36
+
37
+ * Aloha Editor is distributed in the hope that it will be useful,
38
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
39
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
40
+ * GNU Affero General Public License for more details.
41
+
42
+ * You should have received a copy of the GNU Affero General Public License
43
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
34
44
  */
35
- if(typeof GENTICS=="undefined"||!GENTICS){var GENTICS={}}if(typeof GENTICS.Utils=="undefined"||!GENTICS.Utils){GENTICS.Utils={}}if(typeof GENTICS.Utils.Dom=="undefined"||!GENTICS.Utils.Dom){GENTICS.Utils.Dom=function(){}}GENTICS.Utils.Dom.prototype.mergeableTags=["a","b","span","code","del","em","i","ins","strong","sub","sup","#text"];GENTICS.Utils.Dom.prototype.nonWordBoundaryTags=["a","b","span","code","del","em","i","ins","span","strong","sub","sup","#text"];GENTICS.Utils.Dom.prototype.nonEmptyTags=["br"];GENTICS.Utils.Dom.prototype.tags={flow:["a","abbr","address","area","article","aside","audio","b","bdo","blockquote","br","button","canvas","cite","code","command","datalist","del","details","dfn","div","dl","em","embed","fieldset","figure","footer","form","h1","h2","h3","h4","h5","h6","header","hgroup","hr","i","iframe","img","input","ins","kbd","keygen","label","map","mark","math","menu","meter","nav","noscript","object","ol","output","p","pre","progress","q","ruby","samp","script","section","select","small","span","strong","style","sub","sup","svg","table","textarea","time","ul","var","video","wbr","#text"],phrasing:["a","abbr","area","audio","b","bdo","br","button","canvas","cite","code","command","datalist","del","dfn","em","embed","i","iframe","img","input","ins","kbd","keygen","label","map","mark","math","meter","noscript","object","output","progress","q","ruby","samp","script","select","small","span","strong","sub","sup","svg","textarea","time","var","video","wbr","#text"]};GENTICS.Utils.Dom.prototype.children={a:"phrasing",b:"phrasing",blockquote:"flow",br:"empty",caption:"flow",cite:"phrasing",code:"phrasing",col:"empty",colgroup:"col",del:"phrasing",div:"flow",h1:"phrasing",h2:"phrasing",h3:"phrasing",h4:"phrasing",h5:"phrasing",h6:"phrasing",hr:"empty",i:"phrasing",img:"empty",ins:"phrasing",li:"flow",ol:"li",p:"phrasing",pre:"phrasing",small:"phrasing",span:"phrasing",strong:"phrasing",sub:"phrasing",sup:"phrasing",table:["caption","colgroup","thead","tbody","tfoot","tr"],tbody:"tr",td:"flow",tfoot:"tr",th:"phrasing",thead:"tr",tr:["th","td"],ul:"li"};GENTICS.Utils.Dom.prototype.blockLevelElements=["p","h1","h2","h3","h4","h5","h6","blockquote","div","pre"];GENTICS.Utils.Dom.prototype.listElements=["li","ol","ul"];GENTICS.Utils.Dom.prototype.split=function(range,limit,atEnd){var splitElement=jQuery(range.startContainer);var splitPosition=range.startOffset;if(atEnd){splitElement=jQuery(range.endContainer);splitPosition=range.endOffset}if(limit.length<1){limit=jQuery(document.body)}var updateRange=(!range.isCollapsed()&&!atEnd);var path;var parents=splitElement.parents().get();parents.unshift(splitElement.get(0));jQuery.each(parents,function(index,element){var isLimit=limit.filter(function(){return this==element}).length;if(isLimit){if(index>0){path=parents.slice(0,index)}return false}});if(!path){return}path=path.reverse();var newDom;var insertElement;for(var i=0;i<path.length;i++){var element=path[i];if(i===path.length-1){var secondPart;if(element.nodeType===3){secondPart=document.createTextNode(element.data.substring(splitPosition,element.data.length));element.data=element.data.substring(0,splitPosition)}else{var newElement=jQuery(element).clone(false).empty();var children=jQuery(element).contents();secondPart=newElement.append(children.slice(splitPosition,children.length)).get(0)}if(updateRange&&range.endContainer===element){range.endContainer=secondPart;range.endOffset-=splitPosition;range.clearCaches()}if(insertElement){insertElement.prepend(secondPart)}else{jQuery(element).after(secondPart)}}else{var newElement=jQuery(element).clone(false).empty();if(!newDom){newDom=newElement;insertElement=newElement}else{insertElement.prepend(newElement);insertElement=newElement}var next;while(next=path[i+1].nextSibling){insertElement.append(next)}if(updateRange&&range.endContainer===element){range.endContainer=newElement.get(0);var prev=path[i+1];var offset=0;while(prev=prev.previousSibling){offset++}range.endOffset-=offset;range.clearCaches()}}}jQuery(path[0]).after(newDom);return jQuery([path[0],newDom?newDom.get(0):secondPart])};GENTICS.Utils.Dom.prototype.allowsNesting=function(outerDOMObject,innerDOMObject){if(!outerDOMObject||!outerDOMObject.nodeName||!innerDOMObject||!innerDOMObject.nodeName){return false}var outerNodeName=outerDOMObject.nodeName.toLowerCase();var innerNodeName=innerDOMObject.nodeName.toLowerCase();if(!this.children[outerNodeName]){return false}if(this.children[outerNodeName]==innerNodeName){return true}if(jQuery.isArray(this.children[outerNodeName])&&jQuery.inArray(innerNodeName,this.children[outerNodeName])>=0){return true}if(jQuery.isArray(this.tags[this.children[outerNodeName]])&&jQuery.inArray(innerNodeName,this.tags[this.children[outerNodeName]])>=0){return true}return false};GENTICS.Utils.Dom.prototype.addMarkup=function(rangeObject,markup,nesting){if(rangeObject.startContainer.nodeType==3&&rangeObject.startOffset>0&&rangeObject.startOffset<rangeObject.startContainer.data.length){this.split(rangeObject,jQuery(rangeObject.startContainer).parent(),false)}if(rangeObject.endContainer.nodeType==3&&rangeObject.endOffset>0&&rangeObject.endOffset<rangeObject.endContainer.data.length){this.split(rangeObject,jQuery(rangeObject.endContainer).parent(),true)}var rangeTree=rangeObject.getRangeTree();this.recursiveAddMarkup(rangeTree,markup,rangeObject,nesting);this.doCleanup({merge:true,removeempty:true},rangeObject)};GENTICS.Utils.Dom.prototype.recursiveAddMarkup=function(rangeTree,markup,rangeObject,nesting){for(var i=0;i<rangeTree.length;++i){if(rangeTree[i].type=="full"&&this.allowsNesting(markup.get(0),rangeTree[i].domobj)){if((nesting||rangeTree[i].domobj.nodeName!=markup.get(0).nodeName)&&(rangeTree[i].domobj.nodeType!=3||jQuery.trim(rangeTree[i].domobj.data).length!=0)){jQuery(rangeTree[i].domobj).wrap(markup);if(!nesting&&rangeTree[i].domobj.nodeType!=3){var innerRange=new GENTICS.Utils.RangeObject();innerRange.startContainer=innerRange.endContainer=rangeTree[i].domobj.parentNode;innerRange.startOffset=0;innerRange.endOffset=innerRange.endContainer.childNodes.length;this.removeMarkup(innerRange,markup,jQuery(rangeTree[i].domobj.parentNode))}}}else{if(false){}else{if(nesting||rangeTree[i].domobj.nodeName!=markup.get(0).nodeName){if(rangeTree[i].children&&rangeTree[i].children.length>0){this.recursiveAddMarkup(rangeTree[i].children,markup)}}}}}};GENTICS.Utils.Dom.prototype.findHighestElement=function(start,nodeName,limit){var testObject=start;nodeName=nodeName.toLowerCase();var isLimit=limit?function(){return limit.filter(function(){return testObject==this}).length}:function(){return false};var highestObject=undefined;while(!isLimit()&&testObject){if(testObject.nodeName.toLowerCase()==nodeName){highestObject=testObject}testObject=testObject.parentNode}return highestObject};GENTICS.Utils.Dom.prototype.removeMarkup=function(rangeObject,markup,limit){var nodeName=markup.get(0).nodeName;var startSplitLimit=this.findHighestElement(rangeObject.startContainer,nodeName,limit);var endSplitLimit=this.findHighestElement(rangeObject.endContainer,nodeName,limit);var didSplit=false;if(startSplitLimit){this.split(rangeObject,jQuery(startSplitLimit).parent(),false);didSplit=true}if(endSplitLimit){this.split(rangeObject,jQuery(endSplitLimit).parent(),true);didSplit=true}if(didSplit){rangeObject.correctRange()}var highestObject=this.findHighestElement(rangeObject.getCommonAncestorContainer(),nodeName,limit);var root=highestObject?highestObject.parentNode:undefined;var rangeTree=rangeObject.getRangeTree(root);this.recursiveRemoveMarkup(rangeTree,markup);this.doCleanup({merge:true,removeempty:true},rangeObject,root)};GENTICS.Utils.Dom.prototype.recursiveRemoveMarkup=function(rangeTree,markup){for(var i=0;i<rangeTree.length;++i){if(rangeTree[i].type=="full"&&rangeTree[i].domobj.nodeName==markup.get(0).nodeName){var content=jQuery(rangeTree[i].domobj).contents();if(content.length>0){content.first().unwrap()}else{jQuery(rangeTree[i].domobj).remove()}}if(rangeTree[i].children){this.recursiveRemoveMarkup(rangeTree[i].children,markup)}}};GENTICS.Utils.Dom.prototype.doCleanup=function(cleanup,rangeObject,start){var that=this;if(typeof cleanup=="undefined"){cleanup={merge:true,removeempty:true}}if(typeof start=="undefined"){if(rangeObject){start=rangeObject.getCommonAncestorContainer()}}var prevNode=false;var modifiedRange=false;var startObject=jQuery(start);startObject.contents().each(function(index){switch(this.nodeType){case 1:if(prevNode&&prevNode.nodeName==this.nodeName){if(rangeObject.startContainer===startObject&&rangeObject.startOffset>index){rangeObject.startOffset-=1;modifiedRange=true}if(rangeObject.endContainer===startObject&&rangeObject.endOffset>index){rangeObject.endOffset-=1;modifiedRange=true}jQuery(prevNode).append(jQuery(this).contents());modifiedRange|=that.doCleanup(cleanup,rangeObject,prevNode);jQuery(this).remove()}else{modifiedRange|=that.doCleanup(cleanup,rangeObject,this);var removed=false;if(cleanup.removeempty){if(GENTICS.Utils.Dom.isBlockLevelElement(this)&&this.childNodes.length==0){jQuery(this).remove();removed=true}if(jQuery.inArray(this.nodeName.toLowerCase(),that.mergeableTags)>=0&&jQuery(this).text().length==0){jQuery(this).remove();removed=true}}if(!removed){if(jQuery.inArray(this.nodeName.toLowerCase(),that.mergeableTags)>=0){prevNode=this}else{prevNode=false}}}break;case 3:if(prevNode&&prevNode.nodeType==3&&cleanup.merge){if(rangeObject.startContainer===this){rangeObject.startContainer=prevNode;rangeObject.startOffset+=prevNode.length;modifiedRange=true}if(rangeObject.endContainer===this){rangeObject.endContainer=prevNode;rangeObject.endOffset+=prevNode.length;modifiedRange=true}if(rangeObject.startContainer===startObject&&rangeObject.startOffset>index){rangeObject.startOffset-=1;modifiedRange=true}if(rangeObject.endContainer===startObject&&rangeObject.endOffset>index){rangeObject.endOffset-=1;modifiedRange=true}prevNode.data+=this.data;jQuery(this).remove()}else{prevNode=this}break}});if(cleanup.removeempty&&GENTICS.Utils.Dom.isBlockLevelElement(start)&&(!start.childNodes||start.childNodes.length==0)){if(rangeObject.startContainer==start){rangeObject.startContainer=start.parentNode;rangeObject.startOffset=GENTICS.Utils.Dom.getIndexInParent(start)}if(rangeObject.endContainer==start){rangeObject.endContainer=start.parentNode;rangeObject.endOffset=GENTICS.Utils.Dom.getIndexInParent(start)}startObject.remove();modifiedRange=true}if(modifiedRange){rangeObject.clearCaches()}return modifiedRange};GENTICS.Utils.Dom.prototype.getIndexInParent=function(node){if(!node){return false}var index=0;var check=node.previousSibling;while(check){index++;check=check.previousSibling}return index};GENTICS.Utils.Dom.prototype.isBlockLevelElement=function(node){if(!node){return false}if(node.nodeType==1&&jQuery.inArray(node.nodeName.toLowerCase(),this.blockLevelElements)>=0){return true}else{return false}};GENTICS.Utils.Dom.prototype.isLineBreakElement=function(node){if(!node){return false}return node.nodeType==1&&node.nodeName.toLowerCase()=="br"};GENTICS.Utils.Dom.prototype.isListElement=function(node){if(!node){return false}return node.nodeType==1&&jQuery.inArray(node.nodeName.toLowerCase(),this.listElements)>=0};GENTICS.Utils.Dom.prototype.isSplitObject=function(el){if(el.nodeType===1){switch(el.nodeName.toLowerCase()){case"p":case"h1":case"h2":case"h3":case"h4":case"h5":case"h6":case"li":return true}}return false};GENTICS.Utils.Dom.prototype.searchAdjacentTextNode=function(parent,index,searchleft,stopat){if(!parent||parent.nodeType!=1||index<0||index>parent.childNodes.length){return false}if(typeof stopat=="undefined"){stopat={blocklevel:true,list:true,linebreak:true}}if(stopat.blocklevel=="undefined"){stopal.blocklevel=true}if(stopat.list=="undefined"){stopal.list=true}if(stopat.linebreak=="undefined"){stopal.linebreak=true}if(typeof searchleft=="undefined"){searchleft=true}var nextNode=undefined;var currentParent=parent;if(searchleft&&index>0){nextNode=parent.childNodes[index-1]}if(!searchleft&&index<parent.childNodes.length){nextNode=parent.childNodes[index]}while(typeof currentParent!="undefined"){if(!nextNode){if(stopat.blocklevel&&this.isBlockLevelElement(currentParent)){return false}else{if(stopat.list&&this.isListElement(currentParent)){return false}else{nextNode=searchleft?currentParent.previousSibling:currentParent.nextSibling;currentParent=currentParent.parentNode}}}else{if(nextNode.nodeType==3&&jQuery.trim(nextNode.data).length>0){return nextNode}else{if(stopat.blocklevel&&this.isBlockLevelElement(nextNode)){return false}else{if(stopat.linebreak&&this.isLineBreakElement(nextNode)){return false}else{if(stopat.list&&this.isListElement(nextNode)){return false}else{if(nextNode.nodeType==3){nextNode=searchleft?nextNode.previousSibling:nextNode.nextSibling}else{currentParent=nextNode;nextNode=searchleft?nextNode.lastChild:nextNode.firstChild}}}}}}}};GENTICS.Utils.Dom.prototype.insertIntoDOM=function(object,range,limit,atEnd){var parentElements=range.getContainerParents(limit,atEnd);var that=this;var newParent;if(!limit){limit=jQuery(document.body)}if(parentElements.length==0){newParent=limit.get(0)}else{jQuery.each(parentElements,function(index,parent){if(that.allowsNesting(parent,object.get(0))){newParent=parent;return false}})}if(typeof newParent=="undefined"&&limit.length>0){newParent=limit.get(0)}if(typeof newParent!="undefined"){var splitParts=this.split(range,jQuery(newParent),atEnd);if(splitParts){splitParts.eq(0).after(object);return true}else{return false}}else{return false}};GENTICS.Utils.Dom.prototype.removeFromDOM=function(object,range,preserveContent){if(preserveContent){var indexInParent=this.getIndexInParent(object);var numChildren=jQuery(object).contents().length;var parent=object.parentNode;if(range.startContainer==parent&&range.startOffset>indexInParent){range.startOffset+=numChildren-1}else{if(range.startContainer==object){range.startContainer=parent;range.startOffset=indexInParent+range.startOffset}}if(range.endContainer==parent&&range.endOffset>indexInParent){range.endOffset+=numChildren-1}else{if(range.endContainer==object){range.endContainer=parent;range.endOffset=indexInParent+range.endOffset}}jQuery(object).contents().unwrap();this.doCleanup({merge:true},range,parent)}else{}};GENTICS.Utils.Dom.prototype.extendToWord=function(range,fromBoundaries){var leftBoundary=this.searchWordBoundary(range.startContainer,range.startOffset,true);var rightBoundary=this.searchWordBoundary(range.endContainer,range.endOffset,false);if(!fromBoundaries){if(range.startContainer==leftBoundary.container&&range.startOffset==leftBoundary.offset){return}if(range.endContainer==rightBoundary.container&&range.endOffset==rightBoundary.offset){return}}range.startContainer=leftBoundary.container;range.startOffset=leftBoundary.offset;range.endContainer=rightBoundary.container;range.endOffset=rightBoundary.offset;range.correctRange();range.clearCaches()};GENTICS.Utils.Dom.prototype.isWordBoundaryElement=function(object){if(!object||!object.nodeName){return false}return jQuery.inArray(object.nodeName.toLowerCase(),this.nonWordBoundaryTags)==-1};GENTICS.Utils.Dom.prototype.searchWordBoundary=function(container,offset,searchleft){if(typeof searchleft=="undefined"){searchleft=true}var boundaryFound=false;while(!boundaryFound){if(container.nodeType==3){if(!searchleft){var wordBoundaryPos=container.data.substring(offset).search(/\W/);if(wordBoundaryPos!=-1){offset=offset+wordBoundaryPos;boundaryFound=true}else{offset=this.getIndexInParent(container)+1;container=container.parentNode}}else{var wordBoundaryPos=container.data.substring(0,offset).search(/\W/);var tempWordBoundaryPos=wordBoundaryPos;while(tempWordBoundaryPos!=-1){wordBoundaryPos=tempWordBoundaryPos;tempWordBoundaryPos=container.data.substring(wordBoundaryPos+1,offset).search(/\W/);if(tempWordBoundaryPos!=-1){tempWordBoundaryPos=tempWordBoundaryPos+wordBoundaryPos+1}}if(wordBoundaryPos!=-1){offset=wordBoundaryPos+1;boundaryFound=true}else{offset=this.getIndexInParent(container);container=container.parentNode}}}else{if(container.nodeType==1){if(!searchleft){if(offset<container.childNodes.length){if(this.isWordBoundaryElement(container.childNodes[offset])){boundaryFound=true}else{container=container.childNodes[offset];offset=0}}else{if(this.isWordBoundaryElement(container)){boundaryFound=true}else{offset=this.getIndexInParent(container)+1;container=container.parentNode}}}else{if(offset>0){if(this.isWordBoundaryElement(container.childNodes[offset-1])){boundaryFound=true}else{container=container.childNodes[offset-1];offset=container.nodeType==3?container.data.length:container.childNodes.length}}else{if(this.isWordBoundaryElement(container)){boundaryFound=true}else{offset=this.getIndexInParent(container);container=container.parentNode}}}}}}if(container.nodeType!=3){var textNode=this.searchAdjacentTextNode(container,offset,!searchleft);if(textNode){container=textNode;offset=searchleft?0:container.data.length}}return{container:container,offset:offset}};GENTICS.Utils.Dom.prototype.isEmpty=function(domObject){if(!domObject){return true}if(jQuery.inArray(domObject.nodeName.toLowerCase(),this.nonEmptyTags)!=-1){return false}if(domObject.nodeType==3){return domObject.data.search(/\S/)==-1}for(var i=0;i<domObject.childNodes.length;++i){if(!this.isEmpty(domObject.childNodes[i])){return false}}return true};GENTICS.Utils.Dom=new GENTICS.Utils.Dom();
36
45
  /*
37
46
  * Aloha Editor
38
47
  * Author & Copyright (c) 2010 Gentics Software GmbH
39
48
  * aloha-sales@gentics.com
40
49
  * Licensed unter the terms of http://www.aloha-editor.com/license.html
41
50
  */
42
- if(typeof GENTICS=="undefined"||!GENTICS){
51
+ if(!Array.indexOf){Array.prototype.indexOf=function(obj){for(var i=0;i<this.length;i++){if(this[i]===obj){return i}}return -1};
43
52
  /*
44
- * The GENTICS global namespace object. If GENTICS is already defined, the
45
- * existing GENTICS object will not be overwritten so that defined
46
- * namespaces are preserved.
47
- */
48
- var GENTICS={}}GENTICS.Aloha=function(){};GENTICS.Aloha.setAutobase=function(){var scriptTags=document.getElementsByTagName("script");var path=scriptTags[scriptTags.length-1].src.split("?")[0];path=path.split("/");var substitute=1;if("core"===path[path.length-2]){substitute=2}GENTICS.Aloha.prototype.autobase=path.slice(0,substitute*-1).join("/")+"/"};GENTICS.Aloha.setAutobase();GENTICS.Aloha.prototype.version="nightly";GENTICS.Aloha.prototype.editables=new Array();GENTICS.Aloha.prototype.activeEditable=null;GENTICS.Aloha.prototype.ready=false;GENTICS.Aloha.prototype.dictionaries={};GENTICS.Aloha.prototype.settings={};GENTICS.Aloha.prototype.OSName="Unknown";GENTICS.Aloha.prototype.init=function(){var that=this;jQuery("html").mousedown(function(){if(that.activeEditable&&!that.isMessageVisible()){that.activeEditable.blur();that.FloatingMenu.setScope("GENTICS.Aloha.empty");that.activeEditable=null}});if(typeof this.settings.base=="undefined"||!this.settings.base){this.settings.base=GENTICS.Aloha.autobase;if(typeof GENTICS_Aloha_base!="undefined"){this.settings.base=GENTICS_Aloha_base}}this.Log.init();if(!(this.settings.errorhandling==false)){window.onerror=function(msg,url,linenumber){GENTICS.Aloha.Log.error(GENTICS.Aloha,"Error message: "+msg+"\nURL: "+url+"\nLine Number: "+linenumber);return true}}if(navigator.appVersion.indexOf("Win")!=-1){this.OSName="Win"}if(navigator.appVersion.indexOf("Mac")!=-1){this.OSName="Mac"}if(navigator.appVersion.indexOf("X11")!=-1){this.OSName="Unix"}if(navigator.appVersion.indexOf("Linux")!=-1){this.OSName="Linux"}this.initI18n();this.PluginRegistry.init();this.Ribbon.init();this.FloatingMenu.init();Ext.MessageBox.buttonText.yes=GENTICS.Aloha.i18n(this,"yes");Ext.MessageBox.buttonText.no=GENTICS.Aloha.i18n(this,"no");Ext.MessageBox.buttonText.cancel=GENTICS.Aloha.i18n(this,"cancel");this.ready=true;for(var i=0;i<this.editables.length;i++){this.editables[i].init()}};GENTICS.Aloha.prototype.activateEditable=function(editable){for(var i=0;i<this.editables.length;i++){if(this.editables[i]!=editable&&this.editables[i].isActive){var oldActive=this.editables[i];this.editables[i].blur()}}this.activeEditable=editable};GENTICS.Aloha.prototype.getActiveEditable=function(){return this.activeEditable};GENTICS.Aloha.prototype.deactivateEditable=function(){if(typeof this.activeEditable=="undefined"||this.activeEditable==null){return}this.activeEditable.blur();this.FloatingMenu.setScope("GENTICS.Aloha.empty");this.activeEditable=null};GENTICS.Aloha.prototype.log=function(level,component,message){GENTICS.Aloha.Log.log(level,component,message)};GENTICS.Aloha.prototype.identStr=function(object){if(object instanceof jQuery){object=object[0]}if(!(object instanceof HTMLElement)){GENTICS.Aloha.Log.warn(this,"{"+object.toString()+"} provided is not an HTML element");return object.toString()}var out=object.tagName.toLowerCase();if(object.id){return out+"#"+object.id}if(object.className){return out+"."+object.className}return out};GENTICS.Aloha.prototype.trim=function(str){str=str.replace(/^\s+/,"");for(var i=str.length-1;i>=0;i--){if(/\S/.test(str.charAt(i))){str=str.substring(0,i+1);break}}return str};GENTICS.Aloha.prototype.initI18n=function(){if(typeof this.settings.i18n=="undefined"||!this.settings.i18n){this.settings.i18n={}}if(typeof this.settings.i18n.available=="undefined"||!this.settings.i18n.available||!this.settings.i18n.available instanceof Array){this.settings.i18n.available=["en","de","fr","eo","fi","ru","it"]}if((typeof this.settings.i18n.current=="undefined"||!this.settings.i18n.current)&&typeof this.settings.i18n.acceptLanguage=="string"){var acceptLanguage=[];var preferredLanugage=this.settings.i18n.acceptLanguage.split(",");for(i=0;i<preferredLanugage.length;i++){var lang=preferredLanugage[i].split(";");if(typeof lang[1]=="undefined"||!lang[1]){lang[1]=1}else{lang[1]=parseFloat(lang[1].substring(2,lang[1].length))}acceptLanguage.push(lang)}acceptLanguage.sort(function(a,b){return b[1]-a[1]});for(i=0;i<acceptLanguage.length;i++){if(jQuery.inArray(acceptLanguage[i][0],this.settings.i18n.available)>=0){this.settings.i18n.current=acceptLanguage[i][0];break}}}if(typeof this.settings.i18n.current=="undefined"||!this.settings.i18n.current){this.settings.i18n.current=(navigator.language?navigator.language:navigator.userLanguage)}var actualLanguage=this.getLanguage(this.settings.i18n.current,this.settings.i18n.available);if(!actualLanguage){GENTICS.Aloha.Log.error(this,"Could not determine actual language.")}else{var fileUrl=this.settings.base+"i18n/"+actualLanguage+".dict";this.loadI18nFile(fileUrl,this)}};GENTICS.Aloha.prototype.getLanguage=function(language,availableLanguages){if(!availableLanguages instanceof Array){GENTICS.Aloha.Log.error(this,"Available languages must be an Array");return null}if(typeof language=="undefined"||!language){return availableLanguages[0]}for(var i=0;i<availableLanguages.length;++i){if(language==availableLanguages[i]){return language}}return availableLanguages[0]};GENTICS.Aloha.prototype.loadI18nFile=function(fileUrl,component){jQuery.ajax({async:false,datatype:"text",url:fileUrl,error:function(request,textStatus,error){GENTICS.Aloha.Log.error(component,"Error while getting dictionary file "+fileUrl+": server returned "+textStatus)},success:function(data,textStatus,request){if(GENTICS.Aloha.Log.isInfoEnabled()){GENTICS.Aloha.Log.info(component,"Loaded dictionary file "+fileUrl)}GENTICS.Aloha.parseI18nFile(data,component)}})};GENTICS.Aloha.prototype.parseI18nFile=function(data,component){data=data.replace(/\r/g,"");var entries=data.split("\n");var dictionary=new Object();for(var i=0;i<entries.length;++i){var entry=entries[i];var equal=entry.indexOf("=");if(equal>0){var key=GENTICS.Aloha.trim(entry.substring(0,equal));var value=GENTICS.Aloha.trim(entry.substring(equal+1,entry.length));value=value.replace(/\\n/g,"\n");value=value.replace(/\\\\/g,"\\");if(dictionary[key]){GENTICS.Aloha.Log.warn(component,"Found duplicate key "+key+" in dictionary file, ignoring")}else{dictionary[key]=value}}}this.dictionaries[component.toString()]=dictionary};GENTICS.Aloha.prototype.i18n=function(component,key,replacements){var value=null;if(this.dictionaries[component.toString()]){if(this.dictionaries[component.toString()][key]){value=this.dictionaries[component.toString()][key]}}if(!value&&component!=GENTICS.Aloha){if(this.dictionaries[GENTICS.Aloha.toString()]){if(this.dictionaries[GENTICS.Aloha.toString()][key]){value=this.dictionaries[GENTICS.Aloha.toString()][key]}}}if(!value){return"??? "+key+" ???"}else{if(typeof replacements!="undefined"&&replacements!=null){for(var i=0;i<replacements.length;++i){if(typeof replacements[i]!="undefined"&&replacements[i]!=null){var regEx=new RegExp("\\{"+(i)+"\\}","g");var safeArgument=replacements[i].toString().replace(/\{/g,"\\{");safeArgument=safeArgument.replace(/\}/g,"\\}");value=value.replace(regEx,safeArgument)}}}value=value.replace(/\{\d\}/g,"");value=value.replace(/\\\{/g,"{");value=value.replace(/\\\}/g,"}");return value}};GENTICS.Aloha.prototype.registerEditable=function(editable){this.editables.push(editable)};GENTICS.Aloha.prototype.unregisterEditable=function(editable){var id=this.editables.indexOf(editable);if(id!=-1){this.editables.splice(id,1)}};GENTICS.Aloha.prototype.showMessage=function(message){if(GENTICS.Aloha.FloatingMenu.obj){GENTICS.Aloha.FloatingMenu.obj.css("z-index",8900)}switch(message.type){case GENTICS.Aloha.Message.Type.ALERT:Ext.MessageBox.alert(message.title,message.text,message.callback);break;case GENTICS.Aloha.Message.Type.CONFIRM:Ext.MessageBox.confirm(message.title,message.text,message.callback);break;case GENTICS.Aloha.Message.Type.WAIT:Ext.MessageBox.wait(message.text,message.title);break;default:this.log("warn",this,"Unknown message type for message {"+message.toString()+"}");break}};GENTICS.Aloha.prototype.hideMessage=function(){Ext.MessageBox.hide()};GENTICS.Aloha.prototype.isMessageVisible=function(){return Ext.MessageBox.isVisible()};GENTICS.Aloha.prototype.toString=function(){return"GENTICS.Aloha"};GENTICS.Aloha.prototype.isModified=function(){for(var i in this.editables){if(this.editables[i].isModified){if(this.editables[i].isModified()){return true}}}return false};GENTICS.Aloha=new GENTICS.Aloha();if(!Array.indexOf){Array.prototype.indexOf=function(obj){for(var i=0;i<this.length;i++){if(this[i]===obj){return i}}return -1}}jQuery(document).ready(function(){if(Ext.isReady){GENTICS.Aloha.init()}else{Ext.onReady(function(){GENTICS.Aloha.init()})}});
53
+ * This file is part of Aloha Editor
54
+ * Author & Copyright (c) 2010 Gentics Software GmbH, aloha@gentics.com
55
+ * Licensed unter the terms of http://www.aloha-editor.com/license.html
56
+ */
57
+ }Ext.data.AlohaProxy=function(){var api={};api[Ext.data.Api.actions.read]=true;Ext.data.AlohaProxy.superclass.constructor.call(this,{api:api});this.params={queryString:null,objectTypeFilter:null,filter:null,inFolderId:null,orderBy:null,maxItems:null,skipCount:null,renditionFilter:null,repositoryId:null}};Ext.extend(Ext.data.AlohaProxy,Ext.data.DataProxy,{doRequest:function(action,rs,params,reader,cb,scope,arg){var p=this.params;jQuery.extend(p,params);try{GENTICS.Aloha.RepositoryManager.query(p,function(items){var result=reader.readRecords(items);cb.call(scope,result,arg,true)})}catch(e){this.fireEvent("loadexception",this,null,arg,e);this.fireEvent("exception",this,"response",action,arg,null,e);return false}},setObjectTypeFilter:function(otFilter){this.params.objectTypeFilter=otFilter},getObjectTypeFilter:function(){return this.params.objectTypeFilter},setParams:function(p){jQuery.extend(this.params,p)}});
49
58
  /*
50
- * Aloha Editor
51
- * Author & Copyright (c) 2010 Gentics Software GmbH
52
- * aloha-sales@gentics.com
53
- * Licensed unter the terms of http://www.aloha-editor.com/license.html
59
+ * This file is part of Aloha Editor
60
+ * Author & Copyright (c) 2010 Gentics Software GmbH, aloha@gentics.com
61
+ * Licensed unter the terms of http://www.aloha-editor.com/license.html
54
62
  */
55
- if(typeof GENTICS.Aloha.ui=="undefined"){GENTICS.Aloha.ui=function(){}}GENTICS.Aloha.ui.Button=function(properties){this.label;this.iconClass;this.icon;this.onclick;this.menu;this.toggle;this.pressed=false;this.visible=true;this.enabled=true;this.tooltip;this.extButton;GENTICS.Utils.applyProperties(this,properties);this.id=this.generateId()};GENTICS.Aloha.ui.Button.idCounter=0;GENTICS.Aloha.ui.Button.prototype.generateId=function(){GENTICS.Aloha.ui.Button.idCounter=GENTICS.Aloha.ui.Button.idCounter+1;return"GENTICS_Aloha_ui_Button_"+GENTICS.Aloha.ui.Button.idCounter};GENTICS.Aloha.ui.Button.prototype.setPressed=function(pressed){if(this.toggle){this.pressed=pressed;if(typeof this.extButton=="object"&&this.extButton.pressed!=pressed){this.extButton.toggle(this.pressed)}}};GENTICS.Aloha.ui.Button.prototype.isPressed=function(){if(this.toggle){return this.pressed}else{return false}};GENTICS.Aloha.ui.Button.prototype.show=function(){this.visible=true};GENTICS.Aloha.ui.Button.prototype.hide=function(){this.visible=false};GENTICS.Aloha.ui.Button.prototype.isVisible=function(){return this.visible};GENTICS.Aloha.ui.Button.prototype.enable=function(){this.enabled=true;if(typeof this.extButton=="object"){this.extButton.enable()}};GENTICS.Aloha.ui.Button.prototype.disable=function(){this.enabled=false;if(typeof this.extButton=="object"){this.extButton.disable()}};GENTICS.Aloha.ui.Button.prototype.isEnabled=function(){return this.enabled};GENTICS.Aloha.ui.Button.prototype.getExtMenu=function(){if(typeof this.menu==="object"){var menu=new Ext.menu.Menu();for(var i=0;i<this.menu.length;++i){var entry=this.menu[i];menu.addItem(new Ext.menu.Item(entry.getExtMenuConfigProperties()))}}return menu};GENTICS.Aloha.ui.Button.prototype.getExtMenuConfigProperties=function(){var that=this;var submenu=this.getExtMenu();return{text:this.label,icon:this.icon,iconCls:this.iconClass,handler:function(){if(typeof that.onclick=="function"){that.onclick()}},menu:submenu}};GENTICS.Aloha.ui.Button.prototype.getExtConfigProperties=function(){var that=this;var menu=this.getExtMenu();var buttonConfig={text:this.label,enableToggle:this.toggle,pressed:this.pressed,icon:this.icon,iconCls:this.iconClass,scale:this.size,rowspan:(this.size=="large"||this.size=="medium")?2:1,menu:menu,handler:function(element,event){if(typeof that.onclick==="function"){that.onclick.apply(that,[element,event])}that.pressed=!that.pressed},xtype:(menu&&typeof this.onclick=="function")?"splitbutton":"button",tooltipType:"qtip",tooltip:this.tooltip,id:this.id,arrowAlign:this.size=="large"||this.size=="small"?"right":"bottom"};return buttonConfig};Ext.ux.GENTICSMultiSplitButton=Ext.extend(Ext.Component,{autoEl:{cls:"GENTICS_multisplit-wrapper"},ulObj:null,panelButton:null,wrapper:null,panelOpened:false,onRender:function(){Ext.ux.GENTICSMultiSplitButton.superclass.onRender.apply(this,arguments);this.wrapper=jQuery(this.el.dom);var item;var html='<ul class="GENTICS_multisplit">';for(var i=0;i<this.items.length;i++){item=this.items[i];if(item.visible==undefined){item.visible=true}if(item.wide){continue}html+='<li><button xmlns:ext="http://www.extjs.com/" class="'+item.iconClass+'" ext:qtip="'+item.tooltip+'" gtxmultisplititem="'+i+'">&#160;</button></li>'}for(var i=0;i<this.items.length;i++){item=this.items[i];if(!item.wide){continue}html+='<li><button xmlns:ext="http://www.extjs.com/" class="GENTICS_multisplit-wide '+item.iconClass+'" ext:qtip="'+item.tooltip+'" gtxmultisplititem="'+i+'">'+item.text+"</button></li>"}html+="</ul>";var that=this;GENTICS.Aloha.FloatingMenu.extTabPanel.on("move",function(){that.closePanel()});GENTICS.Aloha.FloatingMenu.extTabPanel.on("tabchange",function(){that.closePanel()});this.ulObj=jQuery(this.el.createChild(html).dom);this.ulObj.click(function(event){that.onClick(event)});this.panelButton=jQuery(this.el.createChild('<button class="GENTICS_multisplit_toggle GENTICS_multisplit_toggle_open">&#160;</button>').dom);this.panelButton.click(function(){that.togglePanel()})},onClick:function(event){if(!event.target.attributes.gtxmultisplititem){return}var el=jQuery(event.target);this.closePanel();if(!el.hasClass("GENTICS_multisplit-wide")){this.setActiveDOMElement(el)}this.items[event.target.attributes.gtxmultisplititem.value].click()},setActiveItem:function(name){this.closePanel();if(this.activeItem==name){return}for(var i=0;i<this.items.length;i++){if(this.items[i].name==name){var button=jQuery(this.ulObj).find("[gtxmultisplititem="+i+"]");this.setActiveDOMElement(button);this.activeItem=name;return}}this.activeItem=null;this.setActiveDOMElement(null)},setActiveDOMElement:function(el){var ct=this;while(typeof ct!="undefined"){if(ct.hidden){this.activeDOMElement=el;return}ct=ct.ownerCt}jQuery(this.ulObj).find(".GENTICS_multisplit-activeitem").removeClass("GENTICS_multisplit-activeitem");if(el){el.addClass("GENTICS_multisplit-activeitem")}if(el==null||el.parent().is(":hidden")){return}if(el){this.ulObj.css("margin-top",0);var top=el.position().top;this.ulObj.css("margin-top",-top+6);this.ulObj.css("height",46+top-6)}this.activeDOMElement=undefined},togglePanel:function(){if(this.panelOpened){this.closePanel()}else{this.openPanel()}},openPanel:function(){if(this.panelOpened){return}this.ulObj.appendTo(jQuery(document.body));this.ulObj.addClass("GENTICS_multisplit-expanded");this.ulObj.mousedown(function(e){e.stopPropagation()});var o=this.wrapper.offset();this.ulObj.css("top",o.top-1);this.ulObj.css("left",o.left-1);this.ulObj.animate({height:this.ulObj.attr("scrollHeight")});this.panelButton.removeClass("GENTICS_multisplit_toggle_open");this.panelButton.addClass("GENTICS_multisplit_toggle_close");this.panelOpened=true},closePanel:function(){if(!this.panelOpened){return}this.ulObj.removeClass("GENTICS_multisplit-expanded");this.ulObj.appendTo(this.wrapper);this.panelButton.addClass("GENTICS_multisplit_toggle_open");this.panelButton.removeClass("GENTICS_multisplit_toggle_close");this.panelOpened=false},hideItem:function(name){for(var i=0;i<this.items.length;i++){if(this.items[i].name==name){this.items[i].visible=false;jQuery("#"+this.id+" [gtxmultisplititem="+i+"]").parent().hide();return}}},showItem:function(name){for(var i=0;i<this.items.length;i++){if(this.items[i].name==name){this.items[i].visible=true;jQuery("#"+this.id+" [gtxmultisplititem="+i+"]").parent().show();return}}}});Ext.reg("genticsmultisplitbutton",Ext.ux.GENTICSMultiSplitButton);GENTICS.Aloha.ui.MultiSplitButton=function(properties){this.items;GENTICS.Utils.applyProperties(this,properties);this.id=this.generateId()};GENTICS.Aloha.ui.MultiSplitButton.idCounter=0;GENTICS.Aloha.ui.MultiSplitButton.prototype.generateId=function(){GENTICS.Aloha.ui.MultiSplitButton.idCounter=GENTICS.Aloha.ui.MultiSplitButton.idCounter+1;return"GENTICS_Aloha_ui_MultiSplitButton_"+GENTICS.Aloha.ui.MultiSplitButton.idCounter};GENTICS.Aloha.ui.MultiSplitButton.prototype.getExtConfigProperties=function(){return{xtype:"genticsmultisplitbutton",items:this.items,id:this.id}};GENTICS.Aloha.ui.MultiSplitButton.prototype.setActiveItem=function(name){this.extButton.setActiveItem(name)};GENTICS.Aloha.ui.MultiSplitButton.prototype.isVisible=function(){for(var i=0;i<this.items.length;i++){if(this.items[i].visible){return true}}return false};GENTICS.Aloha.ui.MultiSplitButton.prototype.showItem=function(name){this.extButton.showItem(name)};GENTICS.Aloha.ui.MultiSplitButton.prototype.hideItem=function(name){this.extButton.hideItem(name)};(function(){if(typeof this.GENTICS_Aloha_autoloadcss=="undefined"||!(this.GENTICS_Aloha_autoloadcss==false)){var base=GENTICS.Aloha.autobase;if(typeof GENTICS_Aloha_base!="undefined"){base=GENTICS_Aloha_base}var header=document.getElementsByTagName("head")[0];header.appendChild(cssElement(base+"css/aloha.css?v="+GENTICS.Aloha.version));header.appendChild(cssElement(base+"deps/extjs/resources/css/ext-all.css?v="+GENTICS.Aloha.version));header.appendChild(cssElement(base+"deps/extjs/resources/css/xtheme-gray.css?v="+GENTICS.Aloha.version));header.appendChild(cssElement(base+"deps/prettyPhoto/resources/css/prettyPhoto.css?v="+GENTICS.Aloha.version));header.appendChild(cssElement(base+"plugins/com.gentics.aloha.plugins.Table/resources/table.css?v="+GENTICS.Aloha.version));header.appendChild(cssElement(base+"plugins/com.gentics.aloha.plugins.Link/css/jquery.autocomplete.css?v="+GENTICS.Aloha.version));header.appendChild(cssElement(base+"plugins/com.gentics.aloha.plugins.Link/css/Link.css?v="+GENTICS.Aloha.version));header.appendChild(cssElement(base+"plugins/com.gentics.aloha.plugins.HighlightEditables/css/HighlightEditables.css?v="+GENTICS.Aloha.version))}function cssElement(link){var csslink=document.createElement("link");csslink.setAttribute("rel","stylesheet");csslink.setAttribute("type","text/css");csslink.setAttribute("href",link);csslink.setAttribute("media","all");return csslink}})();
63
+ Ext.data.AlohaObjectReader=function(meta,recordType){meta={};Ext.applyIf(meta,{idProperty:"id",root:"items",totalProperty:"results",fields:["id","url","name","type","weight","repositoryId"]});Ext.data.JsonReader.superclass.constructor.call(this,meta,meta.fields)};Ext.extend(Ext.data.AlohaObjectReader,Ext.data.JsonReader,{});
56
64
  /*
57
- * Aloha Editor
58
- * Author & Copyright (c) 2010 Gentics Software GmbH
59
- * aloha-sales@gentics.com
60
- * Licensed unter the terms of http://www.aloha-editor.com/license.html
65
+ * This file is part of Aloha Editor
66
+ * Author & Copyright (c) 2010 Gentics Software GmbH, aloha@gentics.com
67
+ * Licensed unter the terms of http://www.aloha-editor.com/license.html
61
68
  */
62
- GENTICS.Aloha.Editable=function(obj){this.obj=obj;this.ready=false;GENTICS.Aloha.registerEditable(this);this.init()};GENTICS.Aloha.Editable.prototype.isActive=false;GENTICS.Aloha.Editable.prototype.originalContent=null;GENTICS.Aloha.Editable.prototype.range=undefined;GENTICS.Aloha.Editable.prototype.init=function(){var that=this;if(GENTICS.Aloha.ready){this.obj.addClass("GENTICS_editable");this.obj.attr("contenteditable",true);this.obj.mousedown(function(e){that.activate(e);e.stopPropagation()});this.obj.focus(function(e){that.activate(e)});this.obj.keydown(function(event){return GENTICS.Aloha.Markup.preProcessKeyStrokes(event)});this.obj.keyup(function(event){if(event.keyCode==27){GENTICS.Aloha.deactivateEditable();return false}});this.obj.GENTICS_contentEditableSelectionChange(function(event){GENTICS.Aloha.Selection.onChange(that.obj,event);return that.obj});GENTICS.Aloha.EventRegistry.trigger(new GENTICS.Aloha.Event("editableCreated",GENTICS.Aloha,[this]));this.setUnmodified();this.ready=true}};GENTICS.Aloha.Editable.prototype.destroy=function(){var that=this;this.blur();this.ready=false;this.obj.removeClass("GENTICS_editable");this.obj.removeAttr("contenteditable");this.obj.unbind("mousedown");this.obj.unbind("focus");this.obj.unbind("keydown");this.obj.unbind("keyup");GENTICS.Aloha.EventRegistry.trigger(new GENTICS.Aloha.Event("editableDestroyed",GENTICS.Aloha,[this]));GENTICS.Aloha.unregisterEditable(this)};GENTICS.Aloha.Editable.prototype.setUnmodified=function(){this.originalContent=this.getContents()};GENTICS.Aloha.Editable.prototype.isModified=function(){if(this.originalContent!=this.getContents()){return true}else{return false}};GENTICS.Aloha.Editable.prototype.toString=function(){return"GENTICS.Aloha.Editable"};GENTICS.Aloha.Editable.prototype.activate=function(e){if(this.isActive){return}var oldActive=GENTICS.Aloha.getActiveEditable();GENTICS.Aloha.activateEditable(this);if(document.selection&&document.selection.createRange){this.obj.mouseup()}this.isActive=true;GENTICS.Aloha.EventRegistry.trigger(new GENTICS.Aloha.Event("editableActivated",GENTICS.Aloha,{oldActive:oldActive,editable:this}));GENTICS.Aloha.EventRegistry.trigger(new GENTICS.Aloha.Event("editableActivated",this,{oldActive:GENTICS.Aloha.getActiveEditable()}))};GENTICS.Aloha.Editable.prototype.blur=function(){this.obj.blur();this.isActive=false;GENTICS.Aloha.EventRegistry.trigger(new GENTICS.Aloha.Event("editableDeactivated",GENTICS.Aloha,{editable:this}));GENTICS.Aloha.EventRegistry.trigger(new GENTICS.Aloha.Event("editableDeactivated",this))};GENTICS.Aloha.Editable.prototype.empty=function(str){if(null===str){return true}return(GENTICS.Aloha.trim(str)==""||str=="<br>")};GENTICS.Aloha.Editable.prototype.getContents=function(){var clonedObj=this.obj.clone(true);GENTICS.Aloha.PluginRegistry.makeClean(clonedObj);return clonedObj.html()};GENTICS.Aloha.Editable.prototype.getId=function(){return this.obj.attr("id")};
69
+ Ext.tree.AlohaTreeLoader=function(config){Ext.apply(this,config);Ext.tree.AlohaTreeLoader.superclass.constructor.call(this)};Ext.extend(Ext.tree.AlohaTreeLoader,Ext.tree.TreeLoader,{paramOrder:["node","id"],nodeParameter:"id",directFn:function(node,id,callback){var params={inFolderId:node.id,objectTypeFilter:this.objectTypeFilter,repositoryId:node.repositoryId};GENTICS.Aloha.RepositoryManager.getChildren(params,function(items){var response={};response={status:true,scope:this,argument:{callback:callback,node:node}};if(typeof callback=="function"){callback(items,response)}})},createNode:function(node){if(node.name){node.text=node.name}if(node.hasMoreItems){node.leaf=!node.hasMoreItems}if(node.objectType){node.cls=node.objectType}return Ext.tree.TreeLoader.prototype.createNode.call(this,node)},objectTypeFilter:null,setObjectTypeFilter:function(otFilter){this.objectTypeFilter=otFilter},getObjectTypeFilter:function(){return this.objectTypeFilter}});
63
70
  /*
64
- * Aloha Editor
65
- * Author & Copyright (c) 2010 Gentics Software GmbH
66
- * aloha-sales@gentics.com
67
- * Licensed unter the terms of http://www.aloha-editor.com/license.html
71
+ * This file is part of Aloha Editor
72
+ * Author & Copyright (c) 2010 Gentics Software GmbH, aloha@gentics.com
73
+ * Licensed unter the terms of http://www.aloha-editor.com/license.html
68
74
  */
69
- GENTICS.Aloha.Ribbon=function(){var that=this;this.toolbar=new Ext.Toolbar({height:30,cls:"GENTICS_ribbon ext-root"});this.toolbar.add(new Ext.Toolbar.Spacer({width:"5"}));this.icon=new Ext.Toolbar.Spacer();this.toolbar.add(this.icon);this.toolbar.add(new Ext.Toolbar.Fill());this.toolbar.add(new Ext.Toolbar.Separator());var fadeButton=new Ext.Button({iconCls:"GENTICS_fade_out",handler:function(button){var toolbar=jQuery(that.toolbar.getEl().dom);if(button.iconCls=="GENTICS_fade_out"){toolbar.css("marginLeft","34px");toolbar.animate({left:"-100%"});jQuery("body").animate({paddingTop:0});button.setIconClass("GENTICS_fade_in")}else{toolbar.css("marginLeft","0px");toolbar.animate({left:"0%"});jQuery("body").animate({paddingTop:30});button.setIconClass("GENTICS_fade_out")}that.toolbar.doLayout()}});this.toolbar.add(fadeButton);this.toolbar.add(new Ext.Toolbar.Spacer({width:"5"}))};GENTICS.Aloha.Ribbon.prototype.setIcon=function(iconClass){if(typeof this.icon.cls!="undefined"){this.icon.removeClass(this.icon.cls)}this.icon.addClass(iconClass)};GENTICS.Aloha.Ribbon.prototype.addButton=function(button){if(typeof button.menu==="object"){var menu=new Ext.menu.Menu();jQuery.each(button.menu,function(index,entry){menu.addItem(new Ext.menu.Item({text:entry.label,icon:entry.icon,iconCls:entry.iconClass,handler:function(){entry.onclick.apply(entry)}}))})}var buttonConfig={text:button.label,enableToggle:button.toggle,icon:button.icon,pressed:button.pressed,iconCls:button.iconClass,menu:menu,handler:function(){if(typeof button.onclick==="function"){button.onclick.apply(button)}button.pressed=!button.pressed}};var extButton;if(menu&&typeof button.onclick=="function"){extButton=new Ext.SplitButton(buttonConfig)}else{extButton=new Ext.Button(buttonConfig)}this.toolbar.insert(this.toolbar.items.getCount()-3,extButton)};GENTICS.Aloha.Ribbon.prototype.addSeparator=function(){this.toolbar.insert(this.toolbar.items.getCount()-3,new Ext.Toolbar.Separator())};GENTICS.Aloha.Ribbon.prototype.init=function(){this.toolbar.render(document.body,0);if(GENTICS.Aloha.settings.ribbon!==false){jQuery("body").css("paddingTop","30px !important");this.show()}};GENTICS.Aloha.Ribbon.prototype.hide=function(){jQuery(".GENTICS_ribbon").fadeOut()};GENTICS.Aloha.Ribbon.prototype.show=function(){jQuery(".GENTICS_ribbon").fadeIn()};GENTICS.Aloha.Ribbon=new GENTICS.Aloha.Ribbon();
75
+ if(typeof GENTICS=="undefined"||!GENTICS){var GENTICS={}}GENTICS.Aloha=function(){};GENTICS.Aloha.setAutobase=function(){var scriptTags=jQuery("script");var path=scriptTags[scriptTags.length-1].src.split("?")[0];path=path.split("/");var substitute=1;if("core"===path[path.length-2]){substitute=2}GENTICS.Aloha.prototype.autobase=path.slice(0,substitute*-1).join("/")+"/"};GENTICS.Aloha.setAutobase();GENTICS.Aloha.prototype.version="nightly";GENTICS.Aloha.prototype.editables=[];GENTICS.Aloha.prototype.activeEditable=null;GENTICS.Aloha.prototype.ready=false;GENTICS.Aloha.prototype.dictionaries={};GENTICS.Aloha.prototype.settings={};GENTICS.Aloha.prototype.OSName="Unknown";GENTICS.Aloha.prototype.readyCallbacks=[];GENTICS.Aloha.prototype.init=function(){if(jQuery.browser.webkit&&parseFloat(jQuery.browser.version)<532.5||jQuery.browser.mozilla&&parseFloat(jQuery.browser.version)<1.9||jQuery.browser.msie&&jQuery.browser.version<7||jQuery.browser.opera){alert("Sorry, your browser is not supported at the moment.");return}var that=this;jQuery("html").mousedown(function(){if(that.activeEditable&&!that.isMessageVisible()){that.activeEditable.blur();that.FloatingMenu.setScope("GENTICS.Aloha.empty");that.activeEditable=null}});if(typeof this.settings.base=="undefined"||!this.settings.base){this.settings.base=GENTICS.Aloha.autobase;if(typeof GENTICS_Aloha_base!="undefined"){this.settings.base=GENTICS_Aloha_base}}this.Log.init();if(!(this.settings.errorhandling==false)){window.onerror=function(msg,url,linenumber){GENTICS.Aloha.Log.error(GENTICS.Aloha,"Error message: "+msg+"\nURL: "+url+"\nLine Number: "+linenumber);return true}}if(navigator.appVersion.indexOf("Win")!=-1){this.OSName="Win"}if(navigator.appVersion.indexOf("Mac")!=-1){this.OSName="Mac"}if(navigator.appVersion.indexOf("X11")!=-1){this.OSName="Unix"}if(navigator.appVersion.indexOf("Linux")!=-1){this.OSName="Linux"}this.initI18n();this.PluginRegistry.init();this.RepositoryManager.init();this.Ribbon.init();this.FloatingMenu.init();Ext.MessageBox.buttonText.yes=GENTICS.Aloha.i18n(this,"yes");Ext.MessageBox.buttonText.no=GENTICS.Aloha.i18n(this,"no");Ext.MessageBox.buttonText.cancel=GENTICS.Aloha.i18n(this,"cancel");Ext.ux.AlohaAttributeField.prototype.listEmptyText=GENTICS.Aloha.i18n(GENTICS.Aloha,"repository.no_item_found");Ext.ux.AlohaAttributeField.prototype.loadingText=GENTICS.Aloha.i18n(GENTICS.Aloha,"repository.loading")+"...";this.ready=true;for(var i=0;i<this.editables.length;i++){if(!this.editables[i].ready){this.editables[i].init()}}GENTICS.Aloha.EventRegistry.trigger(new GENTICS.Aloha.Event("ready",GENTICS.Aloha,null))};GENTICS.Aloha.prototype.activateEditable=function(editable){for(var i=0;i<this.editables.length;i++){if(this.editables[i]!=editable&&this.editables[i].isActive){var oldActive=this.editables[i];this.editables[i].blur()}}this.activeEditable=editable};GENTICS.Aloha.prototype.getActiveEditable=function(){return this.activeEditable};GENTICS.Aloha.prototype.deactivateEditable=function(){if(typeof this.activeEditable=="undefined"||this.activeEditable==null){return}this.activeEditable.blur();this.FloatingMenu.setScope("GENTICS.Aloha.empty");this.activeEditable=null};GENTICS.Aloha.prototype.getEditableById=function(id){for(var i=0;i<GENTICS.Aloha.editables.length;i++){if(GENTICS.Aloha.editables[i].getId()==id){return GENTICS.Aloha.editables[i]}}return null};GENTICS.Aloha.prototype.log=function(level,component,message){GENTICS.Aloha.Log.log(level,component,message)};GENTICS.Aloha.prototype.identStr=function(object){if(object instanceof jQuery){object=object[0]}if(!(object instanceof HTMLElement)){GENTICS.Aloha.Log.warn(this,"{"+object.toString()+"} provided is not an HTML element");return object.toString()}var out=object.tagName.toLowerCase();if(object.id){return out+"#"+object.id}if(object.className){return out+"."+object.className}return out};GENTICS.Aloha.prototype.trim=function(str){str=str.replace(/^\s+/,"");for(var i=str.length-1;i>=0;i--){if(/\S/.test(str.charAt(i))){str=str.substring(0,i+1);break}}return str};GENTICS.Aloha.prototype.initI18n=function(){if(typeof this.settings.i18n=="undefined"||!this.settings.i18n){this.settings.i18n={}}if(typeof this.settings.i18n.available=="undefined"||!this.settings.i18n.available||!this.settings.i18n.available instanceof Array){this.settings.i18n.available=["en","de","fr","eo","fi","ru","it","pl"]}if((typeof this.settings.i18n.current=="undefined"||!this.settings.i18n.current)&&typeof this.settings.i18n.acceptLanguage=="string"){var acceptLanguage=[];var preferredLanugage=this.settings.i18n.acceptLanguage.split(",");for(i=0;i<preferredLanugage.length;i++){var lang=preferredLanugage[i].split(";");if(typeof lang[1]=="undefined"||!lang[1]){lang[1]=1}else{lang[1]=parseFloat(lang[1].substring(2,lang[1].length))}acceptLanguage.push(lang)}acceptLanguage.sort(function(a,b){return b[1]-a[1]});for(i=0;i<acceptLanguage.length;i++){if(jQuery.inArray(acceptLanguage[i][0],this.settings.i18n.available)>=0){this.settings.i18n.current=acceptLanguage[i][0];break}}}if(typeof this.settings.i18n.current=="undefined"||!this.settings.i18n.current){this.settings.i18n.current=(navigator.language?navigator.language:navigator.userLanguage)}var actualLanguage=this.getLanguage(this.settings.i18n.current,this.settings.i18n.available);if(!actualLanguage){GENTICS.Aloha.Log.error(this,"Could not determine actual language.")}else{var fileUrl=this.settings.base+"i18n/"+actualLanguage+".dict";this.loadI18nFile(fileUrl,this)}};GENTICS.Aloha.prototype.getLanguage=function(language,availableLanguages){if(!availableLanguages instanceof Array){GENTICS.Aloha.Log.error(this,"Available languages must be an Array");return null}if(typeof language=="undefined"||!language){return availableLanguages[0]}for(var i=0;i<availableLanguages.length;++i){if(language==availableLanguages[i]){return language}}return availableLanguages[0]};GENTICS.Aloha.prototype.loadI18nFile=function(fileUrl,component){jQuery.ajax({async:false,datatype:"text",url:fileUrl,error:function(request,textStatus,error){GENTICS.Aloha.Log.error(component,"Error while getting dictionary file "+fileUrl+": server returned "+textStatus)},success:function(data,textStatus,request){if(GENTICS.Aloha.Log.isInfoEnabled()){GENTICS.Aloha.Log.info(component,"Loaded dictionary file "+fileUrl)}GENTICS.Aloha.parseI18nFile(data,component)}})};GENTICS.Aloha.prototype.parseI18nFile=function(data,component){data=data.replace(/\r/g,"");var entries=data.split("\n");var dictionary={};for(var i=0;i<entries.length;++i){var entry=entries[i];var equal=entry.indexOf("=");if(equal>0){var key=GENTICS.Aloha.trim(entry.substring(0,equal));var value=GENTICS.Aloha.trim(entry.substring(equal+1,entry.length));value=value.replace(/\\n/g,"\n");value=value.replace(/\\\\/g,"\\");if(dictionary[key]){GENTICS.Aloha.Log.warn(component,"Found duplicate key "+key+" in dictionary file, ignoring")}else{dictionary[key]=value}}}this.dictionaries[component.toString()]=dictionary};GENTICS.Aloha.prototype.i18n=function(component,key,replacements){var value=null;if(this.dictionaries[component.toString()]){if(this.dictionaries[component.toString()][key]){value=this.dictionaries[component.toString()][key]}}if(!value&&component!=GENTICS.Aloha){if(this.dictionaries[GENTICS.Aloha.toString()]){if(this.dictionaries[GENTICS.Aloha.toString()][key]){value=this.dictionaries[GENTICS.Aloha.toString()][key]}}}if(!value){return"??? "+key+" ???"}else{if(typeof replacements!="undefined"&&replacements!=null){for(var i=0;i<replacements.length;++i){if(typeof replacements[i]!="undefined"&&replacements[i]!=null){var regEx=new RegExp("\\{"+(i)+"\\}","g");var safeArgument=replacements[i].toString().replace(/\{/g,"\\{");safeArgument=safeArgument.replace(/\}/g,"\\}");value=value.replace(regEx,safeArgument)}}}value=value.replace(/\{\d\}/g,"");value=value.replace(/\\\{/g,"{");value=value.replace(/\\\}/g,"}");return value}};GENTICS.Aloha.prototype.registerEditable=function(editable){this.editables.push(editable)};GENTICS.Aloha.prototype.unregisterEditable=function(editable){var id=this.editables.indexOf(editable);if(id!=-1){this.editables.splice(id,1)}};GENTICS.Aloha.prototype.showMessage=function(message){if(GENTICS.Aloha.FloatingMenu.obj){GENTICS.Aloha.FloatingMenu.obj.css("z-index",8900)}switch(message.type){case GENTICS.Aloha.Message.Type.ALERT:Ext.MessageBox.alert(message.title,message.text,message.callback);break;case GENTICS.Aloha.Message.Type.CONFIRM:Ext.MessageBox.confirm(message.title,message.text,message.callback);break;case GENTICS.Aloha.Message.Type.WAIT:Ext.MessageBox.wait(message.text,message.title);break;default:this.log("warn",this,"Unknown message type for message {"+message.toString()+"}");break}};GENTICS.Aloha.prototype.hideMessage=function(){Ext.MessageBox.hide()};GENTICS.Aloha.prototype.isMessageVisible=function(){return Ext.MessageBox.isVisible()};GENTICS.Aloha.prototype.toString=function(){return"GENTICS.Aloha"};GENTICS.Aloha.prototype.isModified=function(){for(var i in this.editables){if(this.editables[i].isModified){if(this.editables[i].isModified()){return true}}}return false};GENTICS.Aloha=new GENTICS.Aloha();jQuery.isAloha=true;jQuery(document).ready(function(){if(!jQuery.isAloha&&window.console&&console.error){console.error("Aloha ERROR: jQuery was included at least a second time after loading Aloha. This will cause serious problems. You must not load other versions of jQuery with Aloha.")}if(Ext.isReady){GENTICS.Aloha.init()}else{Ext.onReady(function(){GENTICS.Aloha.init()})}});
70
76
  /*
71
- * Aloha Editor
72
- * Author & Copyright (c) 2010 Gentics Software GmbH
73
- * aloha-sales@gentics.com
74
- * Licensed unter the terms of http://www.aloha-editor.com/license.html
77
+ * This file is part of Aloha Editor
78
+ * Author & Copyright (c) 2010 Gentics Software GmbH, aloha@gentics.com
79
+ * Licensed unter the terms of http://www.aloha-editor.com/license.html
80
+ */
81
+ if(typeof GENTICS.Aloha.ui=="undefined"){GENTICS.Aloha.ui=function(){}}GENTICS.Aloha.ui.Button=function(properties){this.init(properties)};GENTICS.Aloha.ui.Button.prototype.init=function(properties){this.label;this.iconClass;this.icon;this.onclick;this.menu;this.toggle;this.pressed=false;this.visible=true;this.enabled=true;this.tooltip;this.extButton;this.listenerQueue=[];GENTICS.Utils.applyProperties(this,properties);this.id=this.generateId()};GENTICS.Aloha.ui.Button.idCounter=0;GENTICS.Aloha.ui.Button.prototype.generateId=function(){GENTICS.Aloha.ui.Button.idCounter=GENTICS.Aloha.ui.Button.idCounter+1;return"GENTICS_Aloha_ui_Button_"+GENTICS.Aloha.ui.Button.idCounter};GENTICS.Aloha.ui.Button.prototype.setPressed=function(pressed){if(this.toggle){this.pressed=pressed;if(typeof this.extButton=="object"&&this.extButton.pressed!=pressed){this.extButton.toggle(this.pressed)}}};GENTICS.Aloha.ui.Button.prototype.isPressed=function(){if(this.toggle){return this.pressed}return false};GENTICS.Aloha.ui.Button.prototype.show=function(){this.visible=true};GENTICS.Aloha.ui.Button.prototype.hide=function(){this.visible=false};GENTICS.Aloha.ui.Button.prototype.isVisible=function(){return this.visible};GENTICS.Aloha.ui.Button.prototype.enable=function(){this.enabled=true;if(typeof this.extButton=="object"){this.extButton.enable()}};GENTICS.Aloha.ui.Button.prototype.disable=function(){this.enabled=false;if(typeof this.extButton=="object"){this.extButton.disable()}};GENTICS.Aloha.ui.Button.prototype.isEnabled=function(){return this.enabled};GENTICS.Aloha.ui.Button.prototype.getExtMenu=function(){if(typeof this.menu==="object"){var menu=new Ext.menu.Menu();for(var i=0;i<this.menu.length;++i){var entry=this.menu[i];menu.addItem(new Ext.menu.Item(entry.getExtMenuConfigProperties()))}}return menu};GENTICS.Aloha.ui.Button.prototype.getExtMenuConfigProperties=function(){var that=this;var submenu=this.getExtMenu();return{text:this.label,icon:this.icon,iconCls:this.iconClass,handler:function(){if(typeof that.onclick=="function"){that.onclick()}},menu:submenu}};GENTICS.Aloha.ui.Button.prototype.getExtConfigProperties=function(){var that=this;var menu=this.getExtMenu();var buttonConfig={text:this.label,enableToggle:this.toggle,pressed:this.pressed,icon:this.icon,iconCls:this.iconClass,scale:this.scale||this.size,width:this.width||undefined,rowspan:this.rowspan||((this.size=="large"||this.size=="medium")?2:1),menu:menu,handler:function(element,event){if(typeof that.onclick==="function"){that.onclick.apply(that,[element,event])}that.pressed=!that.pressed},xtype:(menu&&typeof this.onclick=="function")?"splitbutton":"button",tooltipType:"qtip",tooltip:this.tooltip,id:this.id,arrowAlign:this.arrowAlign||(this.size=="large"||this.size=="small"?"right":"bottom")};return buttonConfig};Ext.ux.GENTICSMultiSplitButton=Ext.extend(Ext.Component,{autoEl:{cls:"GENTICS_multisplit-wrapper"},ulObj:null,panelButton:null,wrapper:null,panelOpened:false,onRender:function(){Ext.ux.GENTICSMultiSplitButton.superclass.onRender.apply(this,arguments);this.wrapper=jQuery(this.el.dom);var item;var html='<ul class="GENTICS_multisplit">';for(var i=0;i<this.items.length;i++){item=this.items[i];if(typeof item.visible=="undefined"){item.visible=true}if(item.wide){continue}html+='<li><button xmlns:ext="http://www.extjs.com/" class="'+item.iconClass+'" ext:qtip="'+item.tooltip+'" gtxmultisplititem="'+i+'">&#160;</button></li>'}for(var i=0;i<this.items.length;i++){item=this.items[i];if(!item.wide){continue}html+='<li><button xmlns:ext="http://www.extjs.com/" class="GENTICS_multisplit-wide '+item.iconClass+'" ext:qtip="'+item.tooltip+'" gtxmultisplititem="'+i+'">'+item.text+"</button></li>"}html+="</ul>";var that=this;GENTICS.Aloha.FloatingMenu.extTabPanel.on("move",function(){that.closePanel()});GENTICS.Aloha.FloatingMenu.extTabPanel.on("tabchange",function(){that.closePanel()});this.ulObj=jQuery(this.el.createChild(html).dom).click(function(event){that.onClick(event)});this.panelButton=jQuery(this.el.createChild('<button class="GENTICS_multisplit_toggle GENTICS_multisplit_toggle_open">&#160;</button>').dom).click(function(){that.togglePanel()})},onClick:function(event){if(!event.target.attributes.gtxmultisplititem){return}var el=jQuery(event.target);this.closePanel();if(!el.hasClass("GENTICS_multisplit-wide")){this.setActiveDOMElement(el)}this.items[event.target.attributes.gtxmultisplititem.value].click()},setActiveItem:function(name){this.closePanel();if(this.activeItem==name){return}for(var i=0;i<this.items.length;i++){if(this.items[i].name==name){var button=jQuery(this.ulObj).find("[gtxmultisplititem="+i+"]");this.setActiveDOMElement(button);this.activeItem=name;return}}this.activeItem=null;this.setActiveDOMElement(null)},setActiveDOMElement:function(el){var ct=this;while(typeof ct!="undefined"){if(ct.hidden){this.activeDOMElement=el;return}ct=ct.ownerCt}jQuery(this.ulObj).find(".GENTICS_multisplit-activeitem").removeClass("GENTICS_multisplit-activeitem");if(el){el.addClass("GENTICS_multisplit-activeitem")}if(el==null||el.parent().is(":hidden")){return}if(el&&this.ulObj){this.ulObj.css("margin-top",0);var top=el.position().top;this.ulObj.css({"margin-top":-top+6,height:46+top-6})}this.activeDOMElement=undefined},togglePanel:function(){if(this.panelOpened){this.closePanel()}else{this.openPanel()}},openPanel:function(){if(this.panelOpened){return}this.ulObj.appendTo(jQuery("body"));this.ulObj.addClass("GENTICS_multisplit-expanded");this.ulObj.mousedown(function(e){e.stopPropagation()});var o=this.wrapper.offset();this.ulObj.css({top:o.top-1,left:o.left-1});this.ulObj.animate({height:this.ulObj.attr("scrollHeight")});this.panelButton.removeClass("GENTICS_multisplit_toggle_open");this.panelButton.addClass("GENTICS_multisplit_toggle_close");this.panelOpened=true},closePanel:function(){if(!this.panelOpened){return}this.ulObj.removeClass("GENTICS_multisplit-expanded");this.ulObj.appendTo(this.wrapper);this.panelButton.addClass("GENTICS_multisplit_toggle_open");this.panelButton.removeClass("GENTICS_multisplit_toggle_close");this.panelOpened=false},hideItem:function(name){for(var i=0;i<this.items.length;i++){if(this.items[i].name==name){this.items[i].visible=false;jQuery("#"+this.id+" [gtxmultisplititem="+i+"]").parent().hide();return}}},showItem:function(name){for(var i=0;i<this.items.length;i++){if(this.items[i].name==name){this.items[i].visible=true;jQuery("#"+this.id+" [gtxmultisplititem="+i+"]").parent().show();return}}}});Ext.reg("genticsmultisplitbutton",Ext.ux.GENTICSMultiSplitButton);GENTICS.Aloha.ui.MultiSplitButton=function(properties){this.items;GENTICS.Utils.applyProperties(this,properties);this.id=this.generateId()};GENTICS.Aloha.ui.MultiSplitButton.idCounter=0;GENTICS.Aloha.ui.MultiSplitButton.prototype.generateId=function(){GENTICS.Aloha.ui.MultiSplitButton.idCounter=GENTICS.Aloha.ui.MultiSplitButton.idCounter+1;return"GENTICS_Aloha_ui_MultiSplitButton_"+GENTICS.Aloha.ui.MultiSplitButton.idCounter};GENTICS.Aloha.ui.MultiSplitButton.prototype.getExtConfigProperties=function(){return{xtype:"genticsmultisplitbutton",items:this.items,id:this.id}};GENTICS.Aloha.ui.MultiSplitButton.prototype.setActiveItem=function(name){this.extButton.setActiveItem(name)};GENTICS.Aloha.ui.MultiSplitButton.prototype.isVisible=function(){for(var i=0;i<this.items.length;i++){if(this.items[i].visible){return true}}return false};GENTICS.Aloha.ui.MultiSplitButton.prototype.showItem=function(name){this.extButton.showItem(name)};GENTICS.Aloha.ui.MultiSplitButton.prototype.hideItem=function(name){this.extButton.hideItem(name)};
82
+ /*
83
+ * This file is part of Aloha Editor
84
+ * Author & Copyright (c) 2010 Gentics Software GmbH, aloha@gentics.com
85
+ * Licensed unter the terms of http://www.aloha-editor.com/license.html
86
+ */
87
+ Ext.ux.AlohaAttributeField=Ext.extend(Ext.form.ComboBox,{typeAhead:false,mode:"remote",triggerAction:"all",width:300,hideTrigger:true,minChars:3,valueField:"id",displayField:"url",enableKeyEvents:true,store:new Ext.data.Store({proxy:new Ext.data.AlohaProxy(),reader:new Ext.data.AlohaObjectReader()}),tpl:new Ext.XTemplate('<tpl for="."><div class="x-combo-list-item">',"<span><b>{name}</b><br />{url}</span>","</div></tpl>"),onSelect:function(item){this.setItem(item.data);if(typeof this.alohaButton.onSelect=="function"){this.alohaButton.onSelect.call(this.alohaButton,item.data)}this.collapse()},listeners:{beforequery:function(event){if(this.noQuery){event.cancel=true;return}if(this.store!=null&&this.store.proxy!=null){this.store.proxy.setParams({objectTypeFilter:this.getObjectTypeFilter(),queryString:event.query})}},afterrender:function(obj,event){var that=this;jQuery(this.wrap.dom.children[0]).blur(function(e){that.triggerBlur()})},keydown:function(obj,event){if(event.keyCode==13||event.keyCode==27){if(this.isExpanded()){this.ALOHAwasExpanded=true}else{this.ALOHAwasExpanded=false}}},keyup:function(obj,event){if((event.keyCode==13||event.keyCode==27)&&!this.ALOHAwasExpanded){setTimeout(function(){GENTICS.Aloha.activeEditable.obj[0].focus();GENTICS.Aloha.Selection.getRangeObject().select()},0)}var v=this.wrap.dom.children[0].value;this.setAttribute(this.targetAttribute,v)},focus:function(obj,event){var target=jQuery(this.getTargetObject());var s=target.css("background-color");if(target&&target.context.style&&target.context.style["background-color"]){target.attr("data-original-background-color",target.context.style["background-color"])}target.css("background-color","Highlight")},blur:function(obj,event){var target=jQuery(this.getTargetObject());if(target){if(color=target.attr("data-original-background-color")){jQuery(target).css("background-color",color)}else{jQuery(target).removeCss("background-color")}jQuery(target).removeAttr("data-original-background-color")}},expand:function(combo){if(this.noQuery){this.collapse()}}},setItem:function(item,displayField){this.resourceItem=item;if(item){displayField=(displayField)?displayField:this.displayField;var v=item[displayField];this.setValue(v);this.setAttribute(this.targetAttribute,v);GENTICS.Aloha.RepositoryManager.markObject(this.targetObject,item)}},getItem:function(){return this.resourceItem},setAttribute:function(attr,value,regex,reference){if(this.targetObject){var setAttr=true;if(typeof reference!="undefined"){var regxp=new RegExp(regex);if(!reference.match(regxp)){setAttr=false}}if(setAttr){jQuery(this.targetObject).attr(attr,value)}else{jQuery(this.targetObject).removeAttr(attr)}}},setTargetObject:function(obj,attr){this.targetObject=obj;this.targetAttribute=attr;if(this.targetObject&&this.targetAttribute){this.setValue(jQuery(this.targetObject).attr(this.targetAttribute))}else{this.setValue("")}},getTargetObject:function(){return this.targetObject},setObjectTypeFilter:function(otFilter){this.objectTypeFilter=otFilter},getObjectTypeFilter:function(){return this.objectTypeFilter},noQuery:true});Ext.reg("alohaattributefield",Ext.ux.AlohaAttributeField);GENTICS.Aloha.ui.AttributeField=function(properties){this.onSelect=null;this.listenerQueue=[];this.objectTypeFilter=null;this.tpl=null;this.displayField=null;this.init(properties)};GENTICS.Aloha.ui.AttributeField.prototype=new GENTICS.Aloha.ui.Button();GENTICS.Aloha.ui.AttributeField.prototype.getExtConfigProperties=function(){return{alohaButton:this,xtype:"alohaattributefield",rowspan:this.rowspan||undefined,width:this.width||undefined,id:this.id}};GENTICS.Aloha.ui.AttributeField.prototype.setTargetObject=function(obj,attr){if(this.extButton){this.extButton.setTargetObject(obj,attr)}};GENTICS.Aloha.ui.AttributeField.prototype.getTargetObject=function(){if(this.extButton){return this.extButton.getTargetObject()}else{return null}};GENTICS.Aloha.ui.AttributeField.prototype.focus=function(){if(this.extButton){this.extButton.focus();if(this.extButton.getValue().length>0){this.extButton.selectText(0,this.extButton.getValue().length)}}};GENTICS.Aloha.ui.AttributeField.prototype.addListener=function(eventName,handler,scope){if(this.extButton){this.extButton.addListener(eventName,handler,null)}else{listener={eventName:eventName,handler:handler,scope:scope,options:null};this.listenerQueue.push(listener)}};GENTICS.Aloha.ui.AttributeField.prototype.setAttribute=function(attr,value,regex,reference){if(this.extButton){this.extButton.setAttribute(attr,value,regex,reference)}};GENTICS.Aloha.ui.AttributeField.prototype.setObjectTypeFilter=function(objectTypeFilter){if(this.extButton){this.noQuery=false;this.extButton.setObjectType(objectTypeFilter)}else{if(!objectTypeFilter){objectTypeFilter="all"}this.objectTypeFilter=objectTypeFilter}};GENTICS.Aloha.ui.AttributeField.prototype.setItem=function(item,displayField){if(this.extButton){this.extButton.setItem(item,displayField)}};GENTICS.Aloha.ui.AttributeField.prototype.getItem=function(){if(this.extButton){return this.extButton.getItem()}return null};GENTICS.Aloha.ui.AttributeField.prototype.getValue=function(){if(this.extButton){return this.extButton.getValue()}return null};GENTICS.Aloha.ui.AttributeField.prototype.setValue=function(v){if(this.extButton){this.extButton.setValue(v)}};GENTICS.Aloha.ui.AttributeField.prototype.getQueryValue=function(){if(this.extButton){return this.extButton.wrap.dom.children[0].value}return null};GENTICS.Aloha.ui.AttributeField.prototype.setDisplayField=function(displayField){if(this.extButton){return this.extButton.displayField=displayField}else{return this.displayField=displayField}return null};GENTICS.Aloha.ui.AttributeField.prototype.setTemplate=function(tpl){if(this.extButton){return this.extButton.tpl='<tpl for="."><div class="x-combo-list-item">'+tpl+"</div></tpl>"}else{return this.tpl='<tpl for="."><div class="x-combo-list-item">'+tpl+"</div></tpl>"}return null};
88
+ /*
89
+ * This file is part of Aloha Editor
90
+ * Author & Copyright (c) 2010 Gentics Software GmbH, aloha@gentics.com
91
+ * Licensed unter the terms of http://www.aloha-editor.com/license.html
92
+ */
93
+ GENTICS.Aloha.ui.Browser=function(){this.onSelect=null;var that=this;this.grid=new Ext.grid.GridPanel({region:"center",autoScroll:true,store:new Ext.data.Store({proxy:new Ext.data.AlohaProxy(),reader:new Ext.data.AlohaObjectReader()}),columns:[{id:"name",header:"Name",width:100,sortable:true,dataIndex:"name"},{header:"URL",renderer:function(val){return val},width:300,sortable:true,dataIndex:"url"}],stripeRows:true,autoExpandColumn:"name",height:350,width:600,title:"Objectlist",stateful:true,stateId:"grid",selModel:new Ext.grid.RowSelectionModel({singleSelect:true}),listeners:{dblclick:function(e){that.onItemSelect()}}});this.grid.getSelectionModel().on({selectionchange:function(sm,n,node){var resourceItem=that.grid.getSelectionModel().getSelected();if(resourceItem){this.win.buttons[1].enable()}else{this.win.buttons[1].disable()}},scope:this});this.tree=new Ext.tree.TreePanel({region:"center",useArrows:true,autoScroll:true,animate:true,enableDD:true,containerScroll:true,border:false,loader:new Ext.tree.AlohaTreeLoader(),root:{nodeType:"async",text:"Aloha Repositories",draggable:false,id:"aloha"},rootVisible:false,listeners:{beforeload:function(node){this.loader.baseParams={node:node.attributes}}}});this.tree.getSelectionModel().on({selectionchange:function(sm,node){if(node){var resourceItem=node.attributes;that.grid.store.load({params:{inFolderId:resourceItem.id,objectTypeFilter:that.objectTypeFilter,repositoryId:resourceItem.repositoryId}})}},scope:this});this.nav=new Ext.Panel({title:"Navigation",region:"west",width:300,layout:"fit",collapsible:true,items:[this.tree]});this.win=new Ext.Window({title:"Resource Selector",layout:"border",width:800,height:300,closeAction:"hide",onEsc:function(){this.hide()},defaultButton:this.nav,plain:true,initHidden:true,items:[this.nav,this.grid],buttons:[{text:"Close",handler:function(){that.win.hide()}},{text:"Select",disabled:true,handler:function(){that.onItemSelect()}}],toFront:function(e){this.manager=this.manager||Ext.WindowMgr;this.manager.bringToFront(this);this.setZIndex(9999999999);return this}});this.onItemSelect=function(){var sm=this.grid.getSelectionModel();var sel=(sm)?sm.getSelected():null;var resourceItem=(sel)?sel.data:null;this.win.hide();if(typeof this.onSelect=="function"){this.onSelect.call(this,resourceItem)}}};GENTICS.Aloha.ui.Browser.prototype.setObjectTypeFilter=function(otf){this.objectTypeFilter=otf};GENTICS.Aloha.ui.Browser.prototype.getObjectTypeFilter=function(){return this.objectTypeFilter};GENTICS.Aloha.ui.Browser.prototype.show=function(){this.win.show();this.win.toFront(true);this.win.focus()};(function(){if(typeof this.GENTICS_Aloha_autoloadcss=="undefined"||!(this.GENTICS_Aloha_autoloadcss==false)){var base=GENTICS.Aloha.autobase;if(typeof GENTICS_Aloha_base!="undefined"){base=GENTICS_Aloha_base}var header=document.getElementsByTagName("head")[0];header.appendChild(cssElement(base+"css/aloha.css?v="+GENTICS.Aloha.version));header.appendChild(cssElement(base+"deps/extjs/resources/css/ext-all.css?v="+GENTICS.Aloha.version));header.appendChild(cssElement(base+"deps/extjs/resources/css/xtheme-gray.css?v="+GENTICS.Aloha.version));header.appendChild(cssElement(base+"deps/prettyPhoto/resources/css/prettyPhoto.css?v="+GENTICS.Aloha.version));header.appendChild(cssElement(base+"plugins/com.gentics.aloha.plugins.Table/resources/table.css?v="+GENTICS.Aloha.version));header.appendChild(cssElement(base+"plugins/com.gentics.aloha.plugins.Link/css/Link.css?v="+GENTICS.Aloha.version));header.appendChild(cssElement(base+"plugins/com.gentics.aloha.plugins.HighlightEditables/css/HighlightEditables.css?v="+GENTICS.Aloha.version));header.appendChild(cssElement(base+"plugins/com.gentics.aloha.plugins.LinkChecker/css/LinkChecker.css?v="+GENTICS.Aloha.version))}function cssElement(link){var csslink=document.createElement("link");csslink.setAttribute("rel","stylesheet");csslink.setAttribute("type","text/css");csslink.setAttribute("href",link);csslink.setAttribute("media","all");return csslink}})();
94
+ /*
95
+ * This file is part of Aloha Editor
96
+ * Author & Copyright (c) 2010 Gentics Software GmbH, aloha@gentics.com
97
+ * Licensed unter the terms of http://www.aloha-editor.com/license.html
98
+ */
99
+ GENTICS.Aloha.Editable=function(obj){if(!obj.attr("id")){obj.attr("id",GENTICS.Utils.guid())}this.obj=obj;this.ready=false;GENTICS.Aloha.registerEditable(this);this.init()};GENTICS.Aloha.Editable.prototype.isActive=false;GENTICS.Aloha.Editable.prototype.originalContent=null;GENTICS.Aloha.Editable.prototype.range=undefined;GENTICS.Aloha.Editable.prototype.check=function(){var obj=this.obj,el=obj.get(0),nodeName=el.nodeName.toLowerCase();var textElements=["a","abbr","address","article","aside","b","bdo","blockquote","cite","code","command","del","details","dfn","div","dl","em","footer","h1","h2","h3","h4","h5","h6","header","i","ins","menu","nav","p","pre","q","ruby","section","small","span","strong","sub","sup","var"];for(var i=0;i<textElements.length;i++){if(nodeName==textElements[i]){return true}}switch(nodeName){case"label":case"button":break;case"textarea":var div=jQuery("<div/>").insertAfter(obj);div.html(obj.val());obj.hide();var updateFunction=function(){var val=div.html();obj.val(val)};obj.parents("form:first").submit(updateFunction);this.obj=div;return true;default:break}return false};GENTICS.Aloha.Editable.prototype.init=function(){var that=this;if(!this.check(this.obj)){this.destroy();return}if(GENTICS.Aloha.ready){this.obj.addClass("GENTICS_editable");this.obj.attr("contentEditable",true);this.obj.mousedown(function(e){that.activate(e);e.stopPropagation()});this.obj.focus(function(e){that.activate(e)});this.obj.keydown(function(event){return GENTICS.Aloha.Markup.preProcessKeyStrokes(event)});this.obj.keyup(function(event){if(event.keyCode==27){GENTICS.Aloha.deactivateEditable();return false}});this.obj.GENTICS_contentEditableSelectionChange(function(event){GENTICS.Aloha.Selection.onChange(that.obj,event);return that.obj});GENTICS.Aloha.EventRegistry.trigger(new GENTICS.Aloha.Event("editableCreated",GENTICS.Aloha,[this]));this.setUnmodified();this.ready=true}};GENTICS.Aloha.Editable.prototype.destroy=function(){var that=this;this.blur();this.ready=false;this.obj.removeClass("GENTICS_editable");this.obj.removeAttr("contentEditable");this.obj.unbind("mousedown");this.obj.unbind("focus");this.obj.unbind("keydown");this.obj.unbind("keyup");GENTICS.Aloha.EventRegistry.trigger(new GENTICS.Aloha.Event("editableDestroyed",GENTICS.Aloha,[this]));GENTICS.Aloha.unregisterEditable(this)};GENTICS.Aloha.Editable.prototype.setUnmodified=function(){this.originalContent=this.getContents()};GENTICS.Aloha.Editable.prototype.isModified=function(){return this.originalContent!=this.getContents()};GENTICS.Aloha.Editable.prototype.toString=function(){return"GENTICS.Aloha.Editable"};GENTICS.Aloha.Editable.prototype.isDisabled=function(){return this.obj.attr("contentEditable")=="false"||!this.obj.attr("contentEditable")};GENTICS.Aloha.Editable.prototype.disable=function(){if(!this.isDisabled()){this.obj.attr("contentEditable","false")}};GENTICS.Aloha.Editable.prototype.enable=function(){if(this.isDisabled()){this.obj.attr("contentEditable","true")}};GENTICS.Aloha.Editable.prototype.activate=function(e){if(this.isActive||this.isDisabled()){return}var oldActive=GENTICS.Aloha.getActiveEditable();GENTICS.Aloha.activateEditable(this);if(document.selection&&document.selection.createRange){this.obj.mouseup()}this.isActive=true;GENTICS.Aloha.EventRegistry.trigger(new GENTICS.Aloha.Event("editableActivated",GENTICS.Aloha,{oldActive:oldActive,editable:this}));GENTICS.Aloha.EventRegistry.trigger(new GENTICS.Aloha.Event("editableActivated",this,{oldActive:GENTICS.Aloha.getActiveEditable()}))};GENTICS.Aloha.Editable.prototype.blur=function(){this.obj.blur();this.isActive=false;GENTICS.Aloha.EventRegistry.trigger(new GENTICS.Aloha.Event("editableDeactivated",GENTICS.Aloha,{editable:this}));GENTICS.Aloha.EventRegistry.trigger(new GENTICS.Aloha.Event("editableDeactivated",this))};GENTICS.Aloha.Editable.prototype.empty=function(str){return(null===str)||(GENTICS.Aloha.trim(str)==""||str=="<br>")};GENTICS.Aloha.Editable.prototype.getContents=function(){var clonedObj=this.obj.clone(true);GENTICS.Aloha.PluginRegistry.makeClean(clonedObj);return clonedObj.html()};GENTICS.Aloha.Editable.prototype.getId=function(){return this.obj.attr("id")};
100
+ /*
101
+ * This file is part of Aloha Editor
102
+ * Author & Copyright (c) 2010 Gentics Software GmbH, aloha@gentics.com
103
+ * Licensed unter the terms of http://www.aloha-editor.com/license.html
104
+ */
105
+ GENTICS.Aloha.Ribbon=function(){var that=this;this.visible=false;this.toolbar=new Ext.Toolbar({height:30,cls:"GENTICS_ribbon ext-root"});this.toolbar.add(new Ext.Toolbar.Spacer({width:"5"}));this.icon=new Ext.Toolbar.Spacer();this.toolbar.add(this.icon);this.toolbar.add(new Ext.Toolbar.Fill());this.toolbar.add(new Ext.Toolbar.Separator());var fadeButton=new Ext.Button({iconCls:"GENTICS_fade_out",handler:function(button){var toolbar=jQuery(that.toolbar.getEl().dom);if(button.iconCls=="GENTICS_fade_out"){toolbar.animate({left:"-100%",marginLeft:"34px"});jQuery("body").animate({paddingTop:0});button.setIconClass("GENTICS_fade_in")}else{toolbar.animate({left:"0%",marginLeft:0});jQuery("body").animate({paddingTop:30});button.setIconClass("GENTICS_fade_out")}that.toolbar.doLayout()}});this.toolbar.add(fadeButton);this.toolbar.add(new Ext.Toolbar.Spacer({width:"5"}))};GENTICS.Aloha.Ribbon.prototype.setIcon=function(iconClass){if(typeof this.icon.cls!="undefined"){this.icon.removeClass(this.icon.cls)}this.icon.addClass(iconClass)};GENTICS.Aloha.Ribbon.prototype.addButton=function(button){if(typeof button.menu==="object"){var menu=new Ext.menu.Menu();jQuery.each(button.menu,function(index,entry){menu.addItem(new Ext.menu.Item({text:entry.label,icon:entry.icon,iconCls:entry.iconClass,handler:function(){entry.onclick.apply(entry)}}))})}var buttonConfig={text:button.label,enableToggle:button.toggle,icon:button.icon,pressed:button.pressed,iconCls:button.iconClass,menu:menu,handler:function(){if(typeof button.onclick==="function"){button.onclick.apply(button)}button.pressed=!button.pressed}};var extButton;if(menu&&typeof button.onclick=="function"){extButton=new Ext.SplitButton(buttonConfig)}else{extButton=new Ext.Button(buttonConfig)}this.toolbar.insert(this.toolbar.items.getCount()-3,extButton)};GENTICS.Aloha.Ribbon.prototype.addSeparator=function(){this.toolbar.insert(this.toolbar.items.getCount()-3,new Ext.Toolbar.Separator())};GENTICS.Aloha.Ribbon.prototype.init=function(){this.toolbar.render(document.body,0);if(GENTICS.Aloha.settings.ribbon===true){jQuery("body").css("paddingTop","30px !important");this.show()}};GENTICS.Aloha.Ribbon.prototype.hide=function(){jQuery(".GENTICS_ribbon").fadeOut();this.visible=false};GENTICS.Aloha.Ribbon.prototype.show=function(){jQuery(".GENTICS_ribbon").fadeIn();this.visible=true};GENTICS.Aloha.Ribbon.prototype.isVisible=function(){return this.visible};GENTICS.Aloha.Ribbon=new GENTICS.Aloha.Ribbon();
106
+ /*
107
+ *
108
+ * This file is part of Aloha Editor
109
+ * Author & Copyright (c) 2010 Gentics Software GmbH, aloha@gentics.com
110
+ * Licensed unter the terms of http://www.aloha-editor.com/license.html
75
111
  */
76
112
  GENTICS.Aloha.Event=function(eventName,eventSource,properties){this.name=eventName;if(eventSource){this.source=eventSource}else{this.source=GENTICS.Aloha}this.properties=properties};GENTICS.Aloha.EventRegistry=function(){};GENTICS.Aloha.EventRegistry.prototype.subscribe=function(eventSource,eventName,handleMethod){jQuery(eventSource).bind(eventName,handleMethod)};GENTICS.Aloha.EventRegistry.prototype.trigger=function(event){jQuery(event.source).trigger(event.name,event.properties)};GENTICS.Aloha.EventRegistry=new GENTICS.Aloha.EventRegistry();
77
113
  /*
78
- * Aloha Editor
79
- * Author & Copyright (c) 2010 Gentics Software GmbH
80
- * aloha-sales@gentics.com
81
- * Licensed unter the terms of http://www.aloha-editor.com/license.html
114
+ * This file is part of Aloha Editor
115
+ * Author & Copyright (c) 2010 Gentics Software GmbH, aloha@gentics.com
116
+ * Licensed unter the terms of http://www.aloha-editor.com/license.html
82
117
  */
83
- GENTICS.Aloha.FloatingMenu={};GENTICS.Aloha.FloatingMenu.scopes={"GENTICS.Aloha.empty":{name:"GENTICS.Aloha.empty",extendedScopes:[],buttons:[]},"GENTICS.Aloha.global":{name:"GENTICS.Aloha.global",extendedScopes:["GENTICS.Aloha.empty"],buttons:[]},"GENTICS.Aloha.continuoustext":{name:"GENTICS.Aloha.continuoustext",extendedScopes:["GENTICS.Aloha.global"],buttons:[]}};GENTICS.Aloha.FloatingMenu.tabs=new Array();GENTICS.Aloha.FloatingMenu.tabMap={};GENTICS.Aloha.FloatingMenu.initialized=false;GENTICS.Aloha.FloatingMenu.allButtons=new Array();GENTICS.Aloha.FloatingMenu.top=100;GENTICS.Aloha.FloatingMenu.left=100;GENTICS.Aloha.FloatingMenu.pinned=false;GENTICS.Aloha.FloatingMenu.init=function(){this.currentScope="GENTICS.Aloha.global";var that=this;jQuery(window).unload(function(){if(that.pinned){jQuery.cookie("GENTICS.Aloha.FloatingMenu.pinned","true");jQuery.cookie("GENTICS.Aloha.FloatingMenu.top",that.obj.offset().top);jQuery.cookie("GENTICS.Aloha.FloatingMenu.left",that.obj.offset().left);if(GENTICS.Aloha.Log.isInfoEnabled()){GENTICS.Aloha.Log.info(this,"stored FloatingMenu pinned position {"+that.obj.offset().left+", "+that.obj.offset().top+"}")}}else{jQuery.cookie("GENTICS.Aloha.FloatingMenu.pinned",null);jQuery.cookie("GENTICS.Aloha.FloatingMenu.top",null);jQuery.cookie("GENTICS.Aloha.FloatingMenu.left",null)}if(that.userActivatedTab){jQuery.cookie("GENTICS.Aloha.FloatingMenu.activeTab",that.userActivatedTab)}}).resize(function(){var target=that.calcFloatTarget(GENTICS.Aloha.Selection.getRangeObject());if(target){that.floatTo(target)}});this.generateComponent();this.initialized=true};GENTICS.Aloha.FloatingMenu.obj=null;GENTICS.Aloha.FloatingMenu.shadow=null;GENTICS.Aloha.FloatingMenu.panelBody=null;GENTICS.Aloha.FloatingMenu.generateComponent=function(){var that=this;Ext.QuickTips.init();Ext.apply(Ext.QuickTips.getQuickTip(),{minWidth:10});if(this.extTabPanel){}this.extTabPanel=new Ext.TabPanel({activeTab:0,width:400,plain:false,draggable:{insertProxy:false,onDrag:function(e){var pel=this.proxy.getEl();this.x=pel.getLeft(true);this.y=pel.getTop(true);GENTICS.Aloha.FloatingMenu.shadow.hide()},endDrag:function(e){if(GENTICS.Aloha.FloatingMenu.pinned){var top=this.y-jQuery(document).scrollTop()}else{var top=this.y}that.left=this.x;that.top=top;this.panel.setPosition(this.x,top);GENTICS.Aloha.FloatingMenu.refreshShadow();GENTICS.Aloha.FloatingMenu.shadow.show()}},floating:true,defaults:{autoScroll:true},layoutOnTabChange:true,shadow:false,cls:"GENTICS_floatingmenu ext-root",listeners:{tabchange:{fn:function(tabPanel,tab){if(tab.title!=that.autoActivatedTab){if(GENTICS.Aloha.Log.isDebugEnabled()){GENTICS.Aloha.Log.debug(that,"User selected tab "+tab.title)}that.userActivatedTab=tab.title}else{if(GENTICS.Aloha.Log.isDebugEnabled()){GENTICS.Aloha.Log.debug(that,"Tab "+tab.title+" was activated automatically")}}that.autoActivatedTab=undefined;jQuery.each(that.allButtons,function(index,buttonInfo){if(typeof buttonInfo.button!="undefined"&&typeof buttonInfo.button.extButton!="undefined"&&typeof buttonInfo.button.extButton.setActiveDOMElement=="function"){if(typeof buttonInfo.button.extButton.activeDOMElement!="undefined"){buttonInfo.button.extButton.setActiveDOMElement(buttonInfo.button.extButton.activeDOMElement)}}});GENTICS.Aloha.FloatingMenu.shadow.show();GENTICS.Aloha.FloatingMenu.refreshShadow()}}},enableTabScroll:true});jQuery.each(this.tabs,function(index,tab){that.extTabPanel.add(tab.getExtComponent())});jQuery("body").append('<div id="GENTICS_floatingmenu_shadow" class="GENTICS_shadow">&#160;</div>');this.shadow=jQuery("#GENTICS_floatingmenu_shadow");var pinTab=this.extTabPanel.add({title:"&#160;"});this.extTabPanel.render(document.body);jQuery(pinTab.tabEl).addClass("GENTICS_floatingmenu_pin").html("&#160;").mousedown(function(e){that.togglePin();e.stopPropagation()});this.panelBody=jQuery(".GENTICS_floatingmenu .x-tab-panel-bwrap");this.doLayout();this.obj=jQuery(this.extTabPanel.getEl().dom);if(jQuery.cookie("GENTICS.Aloha.FloatingMenu.pinned")=="true"){this.togglePin();this.top=parseInt(jQuery.cookie("GENTICS.Aloha.FloatingMenu.top"));this.left=parseInt(jQuery.cookie("GENTICS.Aloha.FloatingMenu.left"));if(this.top<30){this.top=30}if(this.left<0){this.left=0}if(GENTICS.Aloha.Log.isInfoEnabled()){GENTICS.Aloha.Log.info(this,"restored FloatingMenu pinned position {"+this.left+", "+this.top+"}")}this.refreshShadow()}if(jQuery.cookie("GENTICS.Aloha.FloatingMenu.activeTab")){this.userActivatedTab=jQuery.cookie("GENTICS.Aloha.FloatingMenu.activeTab")}this.extTabPanel.setPosition(this.left,this.top);this.obj.mousedown(function(e){e.stopPropagation()});GENTICS.Aloha.EventRegistry.subscribe(GENTICS.Aloha,"selectionChanged",function(event,rangeObject){if(!that.pinned){var pos=that.calcFloatTarget(rangeObject);if(pos){that.floatTo(pos)}}})};GENTICS.Aloha.FloatingMenu.refreshShadow=function(){if(!this.panelBody){return}GENTICS.Aloha.FloatingMenu.shadow.css("top",this.top+24);GENTICS.Aloha.FloatingMenu.shadow.css("left",this.left);GENTICS.Aloha.FloatingMenu.shadow.width(this.panelBody.width());GENTICS.Aloha.FloatingMenu.shadow.height(this.panelBody.height())};GENTICS.Aloha.FloatingMenu.togglePin=function(){var el=jQuery(".GENTICS_floatingmenu_pin");if(this.pinned){el.removeClass("GENTICS_floatingmenu_pinned");this.top=this.obj.offset().top;this.obj.css("top",this.top);this.obj.css("position","absolute");this.shadow.css("position","absolute");this.refreshShadow();this.pinned=false}else{el.addClass("GENTICS_floatingmenu_pinned");this.top=this.obj.offset().top-jQuery(window).scrollTop();this.obj.css("top",this.top);this.obj.css("position","fixed");this.shadow.css("position","fixed");this.refreshShadow();this.pinned=true}};GENTICS.Aloha.FloatingMenu.createScope=function(scope,extendedScopes){if(typeof extendedScopes=="undefined"){extendedScopes=["GENTICS.Aloha.empty"]}else{if(typeof extendedScopes=="string"){extendedScopes=[extendedScopes]}}var scopeObject=this.scopes[scope];if(scopeObject){}else{this.scopes[scope]={name:scope,extendedScopes:extendedScopes,buttons:[]}}};GENTICS.Aloha.FloatingMenu.addButton=function(scope,button,tab,group){var scopeObject=this.scopes[scope];if(typeof scopeObject=="undefined"){}var buttonInfo={button:button,scopeVisible:false};this.allButtons.push(buttonInfo);scopeObject.buttons.push(buttonInfo);var tabObject=this.tabMap[tab];if(typeof tabObject=="undefined"){tabObject=new GENTICS.Aloha.FloatingMenu.Tab(tab);this.tabs.push(tabObject);this.tabMap[tab]=tabObject}var groupObject=tabObject.getGroup(group);groupObject.addButton(buttonInfo);if(this.initialized){this.generateComponent()}};GENTICS.Aloha.FloatingMenu.doLayout=function(){if(GENTICS.Aloha.Log.isDebugEnabled()){GENTICS.Aloha.Log.debug(this,"doLayout called for FloatingMenu, scope is "+this.currentScope)}var that=this;var firstVisibleTab=false;var activeExtTab=this.extTabPanel.getActiveTab();var activeTab=false;var floatingMenuVisible=false;var showUserActivatedTab=false;jQuery.each(this.tabs,function(index,tab){if(tab.extPanel==activeExtTab){activeTab=tab}var tabVisible=tab.visible;if(tab.doLayout()){floatingMenuVisible=true;if(!tabVisible){if(GENTICS.Aloha.Log.isDebugEnabled()){GENTICS.Aloha.Log.debug(that,"showing tab strip for tab "+tab.label)}that.extTabPanel.unhideTabStripItem(tab.extPanel)}if(firstVisibleTab==false){firstVisibleTab=tab}if(that.userActivatedTab==tab.extPanel.title&&tab.extPanel!=activeExtTab){showUserActivatedTab=tab}}else{if(tabVisible){if(GENTICS.Aloha.Log.isDebugEnabled()){GENTICS.Aloha.Log.debug(that,"hiding tab strip for tab "+tab.label)}that.extTabPanel.hideTabStripItem(tab.extPanel)}}});if(showUserActivatedTab){if(GENTICS.Aloha.Log.isDebugEnabled()){GENTICS.Aloha.Log.debug(this,"Setting active tab to "+showUserActivatedTab.label)}this.extTabPanel.setActiveTab(showUserActivatedTab.extPanel)}else{if(typeof activeTab=="object"&&typeof firstVisibleTab=="object"){if(!activeTab.visible){if(GENTICS.Aloha.Log.isDebugEnabled()){GENTICS.Aloha.Log.debug(this,"Setting active tab to "+firstVisibleTab.label)}this.autoActivatedTab=firstVisibleTab.extPanel.title;this.extTabPanel.setActiveTab(firstVisibleTab.extPanel)}}}if(floatingMenuVisible&&this.extTabPanel.hidden){this.extTabPanel.show();this.refreshShadow();this.shadow.show();this.extTabPanel.setPosition(this.left,this.top)}else{if(!floatingMenuVisible&&!this.extTabPanel.hidden){var pos=this.extTabPanel.getPosition(true);this.left=pos[0]<0?100:pos[0];this.top=pos[1]<0?100:pos[1];this.extTabPanel.hide();this.shadow.hide()}}this.extTabPanel.doLayout()};GENTICS.Aloha.FloatingMenu.setScope=function(scope){var scopeObject=this.scopes[scope];if(typeof scopeObject=="undefined"){}else{if(this.currentScope!=scope){this.currentScope=scope;jQuery.each(this.allButtons,function(index,buttonInfo){buttonInfo.scopeVisible=false});this.setButtonScopeVisibility(scopeObject);this.doLayout()}}};GENTICS.Aloha.FloatingMenu.setButtonScopeVisibility=function(scopeObject){var that=this;jQuery.each(scopeObject.buttons,function(index,buttonInfo){buttonInfo.scopeVisible=true});jQuery.each(scopeObject.extendedScopes,function(index,scopeName){var motherScopeObject=that.scopes[scopeName];if(typeof motherScopeObject=="object"){that.setButtonScopeVisibility(motherScopeObject)}})};GENTICS.Aloha.FloatingMenu.nextFloatTargetObj=function(obj,limitObj){if(!obj||obj==limitObj){return obj}switch(obj.nodeName.toLowerCase()){case"h1":case"h2":case"h3":case"h4":case"h5":case"h6":case"p":case"div":case"td":case"pre":case"ul":case"ol":return obj;break;default:return this.nextFloatTargetObj(obj.parentNode,limitObj);break}};GENTICS.Aloha.FloatingMenu.calcFloatTarget=function(range){if(!GENTICS.Aloha.activeEditable){return false}var targetObj=jQuery(this.nextFloatTargetObj(range.getCommonAncestorContainer(),range.limitObject));var scrollTop=GENTICS.Utils.Position.Scroll.top;var y=targetObj.offset().top-this.obj.height()-50;if(y<(scrollTop+30)){y=targetObj.offset().top+targetObj.height()+30}return{x:GENTICS.Aloha.activeEditable.obj.offset().left,y:y}};GENTICS.Aloha.FloatingMenu.floatTo=function(position){if(this.pinned){return}var that=this;if(!this.floatedTo||this.floatedTo.x!=position.x||this.floatedTo.y!=position.y){this.obj.animate({top:position.y,left:position.x},{queue:false,step:function(step,props){if(props.prop=="top"){that.top=props.now}else{if(props.prop=="left"){that.left=props.now}}that.refreshShadow()}});this.floatedTo=position}};GENTICS.Aloha.FloatingMenu.Tab=function(label){this.label=label;this.groups=new Array();this.groupMap={};this.visible=true};GENTICS.Aloha.FloatingMenu.Tab.prototype.getGroup=function(group){var groupObject=this.groupMap[group];if(typeof groupObject=="undefined"){groupObject=new GENTICS.Aloha.FloatingMenu.Group();this.groupMap[group]=groupObject;this.groups.push(groupObject)}return groupObject};GENTICS.Aloha.FloatingMenu.Tab.prototype.getExtComponent=function(){var that=this;if(typeof this.extPanel=="undefined"){this.extPanel=new Ext.Panel({tbar:[],title:this.label,style:"margin-top:0px",bodyStyle:"display:none",autoScroll:true});jQuery.each(this.groups,function(index,group){that.extPanel.getTopToolbar().add(group.getExtComponent())})}return this.extPanel};GENTICS.Aloha.FloatingMenu.Tab.prototype.doLayout=function(){var that=this;if(GENTICS.Aloha.Log.isDebugEnabled()){GENTICS.Aloha.Log.debug(this,"doLayout called for tab "+this.label)}this.visible=false;jQuery.each(this.groups,function(index,group){that.visible|=group.doLayout()});if(GENTICS.Aloha.Log.isDebugEnabled()){GENTICS.Aloha.Log.debug(this,"tab "+this.label+(this.visible?" is ":" is not ")+"visible now")}return this.visible};GENTICS.Aloha.FloatingMenu.Group=function(){this.buttons=new Array()};GENTICS.Aloha.FloatingMenu.Group.prototype.addButton=function(buttonInfo){this.buttons.push(buttonInfo)};GENTICS.Aloha.FloatingMenu.Group.prototype.getExtComponent=function(){var that=this;if(typeof this.extButtonGroup=="undefined"){var items=new Array();var buttonCount=0;jQuery.each(this.buttons,function(index,button){items.push(button.button.getExtConfigProperties());buttonCount+=button.button.size=="small"?1:2});this.extButtonGroup=new Ext.ButtonGroup({columns:Math.ceil(buttonCount/2),items:items});jQuery.each(this.buttons,function(index,buttonInfo){buttonInfo.button.extButton=that.extButtonGroup.findById(buttonInfo.button.id)})}return this.extButtonGroup};GENTICS.Aloha.FloatingMenu.Group.prototype.doLayout=function(){var groupVisible=false;var that=this;jQuery.each(this.buttons,function(index,button){var extButton=that.extButtonGroup.findById(button.button.id);var buttonVisible=button.button.isVisible()&&button.scopeVisible;if(buttonVisible&&extButton.hidden){extButton.show()}else{if(!buttonVisible&&!extButton.hidden){extButton.hide()}}groupVisible|=buttonVisible});if(groupVisible&&this.extButtonGroup.hidden){this.extButtonGroup.show()}else{if(!groupVisible&&!this.extButtonGroup.hidden){this.extButtonGroup.hide()}}return groupVisible};if(document.attachEvent&&document.selection){(function(){var DOMUtils={findChildPosition:function(node){for(var i=0;node=node.previousSibling;i++){continue}return i},isDataNode:function(node){return node&&node.nodeValue!==null&&node.data!==null},isAncestorOf:function(parent,node){return !DOMUtils.isDataNode(parent)&&(parent.contains(DOMUtils.isDataNode(node)?node.parentNode:node)||node.parentNode==parent)},isAncestorOrSelf:function(root,node){return DOMUtils.isAncestorOf(root,node)||root==node},findClosestAncestor:function(root,node){if(DOMUtils.isAncestorOf(root,node)){while(node&&node.parentNode!=root){node=node.parentNode}}return node},getNodeLength:function(node){return DOMUtils.isDataNode(node)?node.length:node.childNodes.length},splitDataNode:function(node,offset){if(!DOMUtils.isDataNode(node)){return false}var newNode=node.cloneNode(false);node.deleteData(offset,node.length);newNode.deleteData(0,offset);node.parentNode.insertBefore(newNode,node.nextSibling)}};var TextRangeUtils={convertToDOMRange:function(textRange,document){function adoptBoundary(domRange,textRange,bStart){var cursorNode=document.createElement("a"),cursor=textRange.duplicate();cursor.collapse(bStart);var parent=cursor.parentElement();do{parent.insertBefore(cursorNode,cursorNode.previousSibling);cursor.moveToElementText(cursorNode)}while(cursor.compareEndPoints(bStart?"StartToStart":"StartToEnd",textRange)>0&&cursorNode.previousSibling);if(cursor.compareEndPoints(bStart?"StartToStart":"StartToEnd",textRange)==-1&&cursorNode.nextSibling){cursor.setEndPoint(bStart?"EndToStart":"EndToEnd",textRange);domRange[bStart?"setStart":"setEnd"](cursorNode.nextSibling,cursor.text.length)}else{domRange[bStart?"setStartBefore":"setEndBefore"](cursorNode)}cursorNode.parentNode.removeChild(cursorNode)}var domRange=new DOMRange(document);adoptBoundary(domRange,textRange,true);adoptBoundary(domRange,textRange,false);return domRange},convertFromDOMRange:function(domRange){function adoptEndPoint(textRange,domRange,bStart){var container=domRange[bStart?"startContainer":"endContainer"];var offset=domRange[bStart?"startOffset":"endOffset"],textOffset=0;var anchorNode=DOMUtils.isDataNode(container)?container:container.childNodes[offset];var anchorParent=DOMUtils.isDataNode(container)?container.parentNode:container;if(container.nodeType==3||container.nodeType==4){textOffset=offset}var cursorNode=domRange._document.createElement("a");anchorParent.insertBefore(cursorNode,anchorNode);var cursor=domRange._document.body.createTextRange();cursor.moveToElementText(cursorNode);cursorNode.parentNode.removeChild(cursorNode);textRange.setEndPoint(bStart?"StartToStart":"EndToStart",cursor);textRange[bStart?"moveStart":"moveEnd"]("character",textOffset)}var textRange=domRange._document.body.createTextRange();adoptEndPoint(textRange,domRange,true);adoptEndPoint(textRange,domRange,false);return textRange}};function DOMRange(document){this._document=document;this.startContainer=this.endContainer=document.body;this.endOffset=DOMUtils.getNodeLength(document.body)}DOMRange.START_TO_START=0;DOMRange.START_TO_END=1;DOMRange.END_TO_END=2;DOMRange.END_TO_START=3;DOMRange.prototype={startContainer:null,startOffset:0,endContainer:null,endOffset:0,commonAncestorContainer:null,collapsed:false,_document:null,_refreshProperties:function(){this.collapsed=(this.startContainer==this.endContainer&&this.startOffset==this.endOffset);var node=this.startContainer;while(node&&node!=this.endContainer&&!DOMUtils.isAncestorOf(node,this.endContainer)){node=node.parentNode}this.commonAncestorContainer=node},setStart:function(container,offset){this.startContainer=container;this.startOffset=offset;this._refreshProperties()},setEnd:function(container,offset){this.endContainer=container;this.endOffset=offset;this._refreshProperties()},setStartBefore:function(refNode){this.setStart(refNode.parentNode,DOMUtils.findChildPosition(refNode))},setStartAfter:function(refNode){this.setStart(refNode.parentNode,DOMUtils.findChildPosition(refNode)+1)},setEndBefore:function(refNode){this.setEnd(refNode.parentNode,DOMUtils.findChildPosition(refNode))},setEndAfter:function(refNode){this.setEnd(refNode.parentNode,DOMUtils.findChildPosition(refNode)+1)},selectNode:function(refNode){this.setStartBefore(refNode);this.setEndAfter(refNode)},selectNodeContents:function(refNode){this.setStart(refNode,0);this.setEnd(refNode,DOMUtils.getNodeLength(refNode))},collapse:function(toStart){if(toStart){this.setEnd(this.startContainer,this.startOffset)}else{this.setStart(this.endContainer,this.endOffset)}},cloneContents:function(){return(function cloneSubtree(iterator){for(var node,frag=document.createDocumentFragment();node=iterator.next();){node=node.cloneNode(!iterator.hasPartialSubtree());if(iterator.hasPartialSubtree()){node.appendChild(cloneSubtree(iterator.getSubtreeIterator()))}frag.appendChild(node)}return frag})(new RangeIterator(this))},extractContents:function(){var range=this.cloneRange();if(this.startContainer!=this.commonAncestorContainer){this.setStartAfter(DOMUtils.findClosestAncestor(this.commonAncestorContainer,this.startContainer))}this.collapse(true);return(function extractSubtree(iterator){for(var node,frag=document.createDocumentFragment();node=iterator.next();){iterator.hasPartialSubtree()?node=node.cloneNode(false):iterator.remove();if(iterator.hasPartialSubtree()){node.appendChild(extractSubtree(iterator.getSubtreeIterator()))}frag.appendChild(node)}return frag})(new RangeIterator(range))},deleteContents:function(){var range=this.cloneRange();if(this.startContainer!=this.commonAncestorContainer){this.setStartAfter(DOMUtils.findClosestAncestor(this.commonAncestorContainer,this.startContainer))}this.collapse(true);(function deleteSubtree(iterator){while(iterator.next()){iterator.hasPartialSubtree()?deleteSubtree(iterator.getSubtreeIterator()):iterator.remove()}})(new RangeIterator(range))},insertNode:function(newNode){if(DOMUtils.isDataNode(this.startContainer)){DOMUtils.splitDataNode(this.startContainer,this.startOffset);this.startContainer.parentNode.insertBefore(newNode,this.startContainer.nextSibling)}else{this.startContainer.insertBefore(newNode,this.startContainer.childNodes[this.startOffset])}this.setStart(this.startContainer,this.startOffset)},surroundContents:function(newNode){var content=this.extractContents();this.insertNode(newNode);newNode.appendChild(content);this.selectNode(newNode)},compareBoundaryPoints:function(how,sourceRange){var containerA,offsetA,containerB,offsetB;switch(how){case DOMRange.START_TO_START:case DOMRange.START_TO_END:containerA=this.startContainer;offsetA=this.startOffset;break;case DOMRange.END_TO_END:case DOMRange.END_TO_START:containerA=this.endContainer;offsetA=this.endOffset;break}switch(how){case DOMRange.START_TO_START:case DOMRange.END_TO_START:containerB=sourceRange.startContainer;offsetB=sourceRange.startOffset;break;case DOMRange.START_TO_END:case DOMRange.END_TO_END:containerB=sourceRange.endContainer;offsetB=sourceRange.endOffset;break}return containerA.sourceIndex<containerB.sourceIndex?-1:containerA.sourceIndex==containerB.sourceIndex?offsetA<offsetB?-1:offsetA==offsetB?0:1:1},cloneRange:function(){var range=new DOMRange(this._document);range.setStart(this.startContainer,this.startOffset);range.setEnd(this.endContainer,this.endOffset);return range},detach:function(){},toString:function(){return TextRangeUtils.convertFromDOMRange(this).text},createContextualFragment:function(tagString){var content=(DOMUtils.isDataNode(this.startContainer)?this.startContainer.parentNode:this.startContainer).cloneNode(false);content.innerHTML=tagString;for(var fragment=this._document.createDocumentFragment();content.firstChild;){fragment.appendChild(content.firstChild)}return fragment}};function RangeIterator(range){this.range=range;if(range.collapsed){return}var root=range.commonAncestorContainer;this._next=range.startContainer==root&&!DOMUtils.isDataNode(range.startContainer)?range.startContainer.childNodes[range.startOffset]:DOMUtils.findClosestAncestor(root,range.startContainer);this._end=range.endContainer==root&&!DOMUtils.isDataNode(range.endContainer)?range.endContainer.childNodes[range.endOffset]:DOMUtils.findClosestAncestor(root,range.endContainer).nextSibling}RangeIterator.prototype={range:null,_current:null,_next:null,_end:null,hasNext:function(){return !!this._next},next:function(){var current=this._current=this._next;this._next=this._current&&this._current.nextSibling!=this._end?this._current.nextSibling:null;if(DOMUtils.isDataNode(this._current)){if(this.range.endContainer==this._current){(current=current.cloneNode(true)).deleteData(this.range.endOffset,current.length-this.range.endOffset)}if(this.range.startContainer==this._current){(current=current.cloneNode(true)).deleteData(0,this.range.startOffset)}}return current},remove:function(){if(DOMUtils.isDataNode(this._current)&&(this.range.startContainer==this._current||this.range.endContainer==this._current)){var start=this.range.startContainer==this._current?this.range.startOffset:0;var end=this.range.endContainer==this._current?this.range.endOffset:this._current.length;this._current.deleteData(start,end-start)}else{this._current.parentNode.removeChild(this._current)}},hasPartialSubtree:function(){return !DOMUtils.isDataNode(this._current)&&(DOMUtils.isAncestorOrSelf(this._current,this.range.startContainer)||DOMUtils.isAncestorOrSelf(this._current,this.range.endContainer))},getSubtreeIterator:function(){var subRange=new DOMRange(this.range._document);subRange.selectNodeContents(this._current);if(DOMUtils.isAncestorOrSelf(this._current,this.range.startContainer)){subRange.setStart(this.range.startContainer,this.range.startOffset)}if(DOMUtils.isAncestorOrSelf(this._current,this.range.endContainer)){subRange.setEnd(this.range.endContainer,this.range.endOffset)}return new RangeIterator(subRange)}};function DOMSelection(document){this._document=document;var selection=this;document.attachEvent("onselectionchange",function(){selection._selectionChangeHandler()})}DOMSelection.prototype={rangeCount:0,_document:null,_selectionChangeHandler:function(){this.rangeCount=this._selectionExists(this._document.selection.createRange())?1:0},_selectionExists:function(textRange){return textRange.compareEndPoints("StartToEnd",textRange)!=0||textRange.parentElement().isContentEditable},addRange:function(range){var selection=this._document.selection.createRange(),textRange=TextRangeUtils.convertFromDOMRange(range);if(!this._selectionExists(selection)){textRange.select()}else{if(textRange.compareEndPoints("StartToStart",selection)==-1){if(textRange.compareEndPoints("StartToEnd",selection)>-1&&textRange.compareEndPoints("EndToEnd",selection)==-1){selection.setEndPoint("StartToStart",textRange)}else{if(textRange.compareEndPoints("EndToStart",selection)<1&&textRange.compareEndPoints("EndToEnd",selection)>-1){selection.setEndPoint("EndToEnd",textRange)}}}selection.select()}},removeAllRanges:function(){this._document.selection.empty()},getRangeAt:function(index){var textRange=this._document.selection.createRange();if(this._selectionExists(textRange)){return TextRangeUtils.convertToDOMRange(textRange,this._document)}return null},toString:function(){return this._document.selection.createRange().text}};document.createRange=function(){return new DOMRange(document)};var selection=new DOMSelection(document);window.getSelection=function(){return selection}})();
118
+ GENTICS.Aloha.FloatingMenu={};GENTICS.Aloha.FloatingMenu.scopes={"GENTICS.Aloha.empty":{name:"GENTICS.Aloha.empty",extendedScopes:[],buttons:[]},"GENTICS.Aloha.global":{name:"GENTICS.Aloha.global",extendedScopes:["GENTICS.Aloha.empty"],buttons:[]},"GENTICS.Aloha.continuoustext":{name:"GENTICS.Aloha.continuoustext",extendedScopes:["GENTICS.Aloha.global"],buttons:[]}};GENTICS.Aloha.FloatingMenu.tabs=[];GENTICS.Aloha.FloatingMenu.tabMap={};GENTICS.Aloha.FloatingMenu.initialized=false;GENTICS.Aloha.FloatingMenu.allButtons=[];GENTICS.Aloha.FloatingMenu.top=100;GENTICS.Aloha.FloatingMenu.left=100;GENTICS.Aloha.FloatingMenu.pinned=false;GENTICS.Aloha.FloatingMenu.window=jQuery(window);GENTICS.Aloha.FloatingMenu.init=function(){this.currentScope="GENTICS.Aloha.global";var that=this;this.window.unload(function(){if(that.pinned){jQuery.cookie("GENTICS.Aloha.FloatingMenu.pinned","true");jQuery.cookie("GENTICS.Aloha.FloatingMenu.top",that.obj.offset().top);jQuery.cookie("GENTICS.Aloha.FloatingMenu.left",that.obj.offset().left);if(GENTICS.Aloha.Log.isInfoEnabled()){GENTICS.Aloha.Log.info(this,"stored FloatingMenu pinned position {"+that.obj.offset().left+", "+that.obj.offset().top+"}")}}else{jQuery.cookie("GENTICS.Aloha.FloatingMenu.pinned",null);jQuery.cookie("GENTICS.Aloha.FloatingMenu.top",null);jQuery.cookie("GENTICS.Aloha.FloatingMenu.left",null)}if(that.userActivatedTab){jQuery.cookie("GENTICS.Aloha.FloatingMenu.activeTab",that.userActivatedTab)}}).resize(function(){var target=that.calcFloatTarget(GENTICS.Aloha.Selection.getRangeObject());if(target){that.floatTo(target)}});this.generateComponent();this.initialized=true};GENTICS.Aloha.FloatingMenu.obj=null;GENTICS.Aloha.FloatingMenu.shadow=null;GENTICS.Aloha.FloatingMenu.panelBody=null;GENTICS.Aloha.FloatingMenu.generateComponent=function(){var that=this;Ext.QuickTips.init();Ext.apply(Ext.QuickTips.getQuickTip(),{minWidth:10});if(this.extTabPanel){}this.extTabPanel=new Ext.TabPanel({activeTab:0,width:400,plain:false,draggable:{insertProxy:false,onDrag:function(e){var pel=this.proxy.getEl();this.x=pel.getLeft(true);this.y=pel.getTop(true);GENTICS.Aloha.FloatingMenu.shadow.hide()},endDrag:function(e){if(GENTICS.Aloha.FloatingMenu.pinned){var top=this.y-jQuery(document).scrollTop()}else{var top=this.y}that.left=this.x;that.top=top;this.panel.setPosition(this.x,top);GENTICS.Aloha.FloatingMenu.refreshShadow();GENTICS.Aloha.FloatingMenu.shadow.show()}},floating:true,defaults:{autoScroll:true},layoutOnTabChange:true,shadow:false,cls:"GENTICS_floatingmenu ext-root",listeners:{tabchange:{fn:function(tabPanel,tab){if(tab.title!=that.autoActivatedTab){if(GENTICS.Aloha.Log.isDebugEnabled()){GENTICS.Aloha.Log.debug(that,"User selected tab "+tab.title)}that.userActivatedTab=tab.title}else{if(GENTICS.Aloha.Log.isDebugEnabled()){GENTICS.Aloha.Log.debug(that,"Tab "+tab.title+" was activated automatically")}}that.autoActivatedTab=undefined;jQuery.each(that.allButtons,function(index,buttonInfo){if(typeof buttonInfo.button!="undefined"&&typeof buttonInfo.button.extButton!="undefined"&&typeof buttonInfo.button.extButton.setActiveDOMElement=="function"){if(typeof buttonInfo.button.extButton.activeDOMElement!="undefined"){buttonInfo.button.extButton.setActiveDOMElement(buttonInfo.button.extButton.activeDOMElement)}}});GENTICS.Aloha.FloatingMenu.shadow.show();GENTICS.Aloha.FloatingMenu.refreshShadow()}}},enableTabScroll:true});jQuery.each(this.tabs,function(index,tab){that.extTabPanel.add(tab.getExtComponent())});jQuery("body").append('<div id="GENTICS_floatingmenu_shadow" class="GENTICS_shadow">&#160;</div>');this.shadow=jQuery("#GENTICS_floatingmenu_shadow");var pinTab=this.extTabPanel.add({title:"&#160;"});this.extTabPanel.render(document.body);jQuery(pinTab.tabEl).addClass("GENTICS_floatingmenu_pin").html("&#160;").mousedown(function(e){that.togglePin();e.stopPropagation()});this.panelBody=jQuery(".GENTICS_floatingmenu .x-tab-panel-bwrap");this.doLayout();this.obj=jQuery(this.extTabPanel.getEl().dom);if(jQuery.cookie("GENTICS.Aloha.FloatingMenu.pinned")=="true"){this.togglePin();this.top=parseInt(jQuery.cookie("GENTICS.Aloha.FloatingMenu.top"));this.left=parseInt(jQuery.cookie("GENTICS.Aloha.FloatingMenu.left"));if(this.top<30){this.top=30}if(this.left<0){this.left=0}if(GENTICS.Aloha.Log.isInfoEnabled()){GENTICS.Aloha.Log.info(this,"restored FloatingMenu pinned position {"+this.left+", "+this.top+"}")}this.refreshShadow()}if(jQuery.cookie("GENTICS.Aloha.FloatingMenu.activeTab")){this.userActivatedTab=jQuery.cookie("GENTICS.Aloha.FloatingMenu.activeTab")}this.extTabPanel.setPosition(this.left,this.top);this.obj.mousedown(function(e){e.stopPropagation()});GENTICS.Aloha.EventRegistry.subscribe(GENTICS.Aloha,"selectionChanged",function(event,rangeObject){if(!that.pinned){var pos=that.calcFloatTarget(rangeObject);if(pos){that.floatTo(pos)}}})};GENTICS.Aloha.FloatingMenu.refreshShadow=function(){if(this.panelBody){GENTICS.Aloha.FloatingMenu.shadow.css({top:this.top+24,left:this.left,width:this.panelBody.width()+"px",height:this.panelBody.height()+"px"})}};GENTICS.Aloha.FloatingMenu.togglePin=function(){var el=jQuery(".GENTICS_floatingmenu_pin");if(this.pinned){el.removeClass("GENTICS_floatingmenu_pinned");this.top=this.obj.offset().top;this.obj.css({top:this.top,position:"absolute"});this.shadow.css("position","absolute");this.refreshShadow();this.pinned=false}else{el.addClass("GENTICS_floatingmenu_pinned");this.top=this.obj.offset().top-this.window.scrollTop();this.obj.css({top:this.top,position:"fixed"});this.shadow.css("position","fixed");this.refreshShadow();this.pinned=true}};GENTICS.Aloha.FloatingMenu.createScope=function(scope,extendedScopes){if(typeof extendedScopes=="undefined"){extendedScopes=["GENTICS.Aloha.empty"]}else{if(typeof extendedScopes=="string"){extendedScopes=[extendedScopes]}}var scopeObject=this.scopes[scope];if(scopeObject){}else{this.scopes[scope]={name:scope,extendedScopes:extendedScopes,buttons:[]}}};GENTICS.Aloha.FloatingMenu.addButton=function(scope,button,tab,group){var scopeObject=this.scopes[scope];if(typeof scopeObject=="undefined"){}var buttonInfo={button:button,scopeVisible:false};this.allButtons.push(buttonInfo);scopeObject.buttons.push(buttonInfo);var tabObject=this.tabMap[tab];if(typeof tabObject=="undefined"){tabObject=new GENTICS.Aloha.FloatingMenu.Tab(tab);this.tabs.push(tabObject);this.tabMap[tab]=tabObject}var groupObject=tabObject.getGroup(group);groupObject.addButton(buttonInfo);if(this.initialized){this.generateComponent()}};GENTICS.Aloha.FloatingMenu.doLayout=function(){if(GENTICS.Aloha.Log.isDebugEnabled()){GENTICS.Aloha.Log.debug(this,"doLayout called for FloatingMenu, scope is "+this.currentScope)}var that=this;var firstVisibleTab=false;var activeExtTab=this.extTabPanel.getActiveTab();var activeTab=false;var floatingMenuVisible=false;var showUserActivatedTab=false;jQuery.each(this.tabs,function(index,tab){if(tab.extPanel==activeExtTab){activeTab=tab}var tabVisible=tab.visible;if(tab.doLayout()){floatingMenuVisible=true;if(!tabVisible){if(GENTICS.Aloha.Log.isDebugEnabled()){GENTICS.Aloha.Log.debug(that,"showing tab strip for tab "+tab.label)}that.extTabPanel.unhideTabStripItem(tab.extPanel)}if(firstVisibleTab==false){firstVisibleTab=tab}if(that.userActivatedTab==tab.extPanel.title&&tab.extPanel!=activeExtTab){showUserActivatedTab=tab}}else{if(tabVisible){if(GENTICS.Aloha.Log.isDebugEnabled()){GENTICS.Aloha.Log.debug(that,"hiding tab strip for tab "+tab.label)}that.extTabPanel.hideTabStripItem(tab.extPanel)}}});if(showUserActivatedTab){if(GENTICS.Aloha.Log.isDebugEnabled()){GENTICS.Aloha.Log.debug(this,"Setting active tab to "+showUserActivatedTab.label)}this.extTabPanel.setActiveTab(showUserActivatedTab.extPanel)}else{if(typeof activeTab=="object"&&typeof firstVisibleTab=="object"){if(!activeTab.visible){if(GENTICS.Aloha.Log.isDebugEnabled()){GENTICS.Aloha.Log.debug(this,"Setting active tab to "+firstVisibleTab.label)}this.autoActivatedTab=firstVisibleTab.extPanel.title;this.extTabPanel.setActiveTab(firstVisibleTab.extPanel)}}}if(floatingMenuVisible&&this.extTabPanel.hidden){this.extTabPanel.show();this.refreshShadow();this.shadow.show();this.extTabPanel.setPosition(this.left,this.top)}else{if(!floatingMenuVisible&&!this.extTabPanel.hidden){var pos=this.extTabPanel.getPosition(true);this.left=pos[0]<0?100:pos[0];this.top=pos[1]<0?100:pos[1];this.extTabPanel.hide();this.shadow.hide()}}this.extTabPanel.doLayout()};GENTICS.Aloha.FloatingMenu.setScope=function(scope){var scopeObject=this.scopes[scope];if(typeof scopeObject=="undefined"){}else{if(this.currentScope!=scope){this.currentScope=scope;jQuery.each(this.allButtons,function(index,buttonInfo){buttonInfo.scopeVisible=false});this.setButtonScopeVisibility(scopeObject);this.doLayout()}}};GENTICS.Aloha.FloatingMenu.setButtonScopeVisibility=function(scopeObject){var that=this;jQuery.each(scopeObject.buttons,function(index,buttonInfo){buttonInfo.scopeVisible=true});jQuery.each(scopeObject.extendedScopes,function(index,scopeName){var motherScopeObject=that.scopes[scopeName];if(typeof motherScopeObject=="object"){that.setButtonScopeVisibility(motherScopeObject)}})};GENTICS.Aloha.FloatingMenu.nextFloatTargetObj=function(obj,limitObj){if(!obj||obj==limitObj){return obj}switch(obj.nodeName.toLowerCase()){case"h1":case"h2":case"h3":case"h4":case"h5":case"h6":case"p":case"div":case"td":case"pre":case"ul":case"ol":return obj;break;default:return this.nextFloatTargetObj(obj.parentNode,limitObj);break}};GENTICS.Aloha.FloatingMenu.calcFloatTarget=function(range){if(!GENTICS.Aloha.activeEditable||typeof range.getCommonAncestorContainer=="undefined"){return false}for(var i=0;i<GENTICS.Aloha.editables.length;i++){if(GENTICS.Aloha.editables[i].obj.get(0)==range.limitObject&&GENTICS.Aloha.editables[i].isDisabled()){return false}}var targetObj=jQuery(this.nextFloatTargetObj(range.getCommonAncestorContainer(),range.limitObject));var scrollTop=GENTICS.Utils.Position.Scroll.top;var y=targetObj.offset().top-this.obj.height()-50;var ribbonOffset=0;if(GENTICS.Aloha.Ribbon&&GENTICS.Aloha.settings.ribbon===true){ribbonOffset=30}if(y<(scrollTop+ribbonOffset)){y=targetObj.offset().top+targetObj.height()+ribbonOffset}if(y>this.window.height()+this.window.scrollTop()){return false}return{x:GENTICS.Aloha.activeEditable.obj.offset().left,y:y}};GENTICS.Aloha.FloatingMenu.floatTo=function(position){if(this.pinned){return}var that=this;if(!this.floatedTo||this.floatedTo.x!=position.x||this.floatedTo.y!=position.y){this.obj.animate({top:position.y,left:position.x},{queue:false,step:function(step,props){if(props.prop=="top"){that.top=props.now}else{if(props.prop=="left"){that.left=props.now}}that.refreshShadow()}});this.floatedTo=position}};GENTICS.Aloha.FloatingMenu.Tab=function(label){this.label=label;this.groups=[];this.groupMap={};this.visible=true};GENTICS.Aloha.FloatingMenu.Tab.prototype.getGroup=function(group){var groupObject=this.groupMap[group];if(typeof groupObject=="undefined"){groupObject=new GENTICS.Aloha.FloatingMenu.Group();this.groupMap[group]=groupObject;this.groups.push(groupObject)}return groupObject};GENTICS.Aloha.FloatingMenu.Tab.prototype.getExtComponent=function(){var that=this;if(typeof this.extPanel=="undefined"){this.extPanel=new Ext.Panel({tbar:[],title:this.label,style:"margin-top:0px",bodyStyle:"display:none",autoScroll:true});jQuery.each(this.groups,function(index,group){that.extPanel.getTopToolbar().add(group.getExtComponent())})}return this.extPanel};GENTICS.Aloha.FloatingMenu.Tab.prototype.doLayout=function(){var that=this;if(GENTICS.Aloha.Log.isDebugEnabled()){GENTICS.Aloha.Log.debug(this,"doLayout called for tab "+this.label)}this.visible=false;jQuery.each(this.groups,function(index,group){that.visible|=group.doLayout()});if(GENTICS.Aloha.Log.isDebugEnabled()){GENTICS.Aloha.Log.debug(this,"tab "+this.label+(this.visible?" is ":" is not ")+"visible now")}return this.visible};GENTICS.Aloha.FloatingMenu.Group=function(){this.buttons=[]};GENTICS.Aloha.FloatingMenu.Group.prototype.addButton=function(buttonInfo){this.buttons.push(buttonInfo)};GENTICS.Aloha.FloatingMenu.Group.prototype.getExtComponent=function(){var that=this;if(typeof this.extButtonGroup=="undefined"){var items=[];var buttonCount=0;jQuery.each(this.buttons,function(index,button){items.push(button.button.getExtConfigProperties());buttonCount+=button.button.size=="small"?1:2});this.extButtonGroup=new Ext.ButtonGroup({columns:Math.ceil(buttonCount/2),items:items});jQuery.each(this.buttons,function(index,buttonInfo){buttonInfo.button.extButton=that.extButtonGroup.findById(buttonInfo.button.id);if(buttonInfo.button.listenerQueue&&buttonInfo.button.listenerQueue.length>0){while(l=buttonInfo.button.listenerQueue.shift()){buttonInfo.button.extButton.addListener(l.eventName,l.handler,l.scope,l.options)}}if(buttonInfo.button.extButton.setObjectTypeFilter){if(buttonInfo.button.objectTypeFilter){buttonInfo.button.extButton.noQuery=false}if(buttonInfo.button.objectTypeFilter=="all"){buttonInfo.button.objectTypeFilter=null}buttonInfo.button.extButton.setObjectTypeFilter(buttonInfo.button.objectTypeFilter);if(buttonInfo.button.displayField){buttonInfo.button.extButton.displayField=buttonInfo.button.displayField}if(buttonInfo.button.tpl){buttonInfo.button.extButton.tpl=buttonInfo.button.tpl}}})}return this.extButtonGroup};GENTICS.Aloha.FloatingMenu.Group.prototype.doLayout=function(){var groupVisible=false;var that=this;jQuery.each(this.buttons,function(index,button){var extButton=that.extButtonGroup.findById(button.button.id);var buttonVisible=button.button.isVisible()&&button.scopeVisible;if(buttonVisible&&extButton.hidden){extButton.show()}else{if(!buttonVisible&&!extButton.hidden){extButton.hide()}}groupVisible|=buttonVisible});if(groupVisible&&this.extButtonGroup.hidden){this.extButtonGroup.show()}else{if(!groupVisible&&!this.extButtonGroup.hidden){this.extButtonGroup.hide()}}return groupVisible};
84
119
  /*
85
- * Aloha Editor
86
- * Author & Copyright (c) 2010 Gentics Software GmbH
87
- * aloha-sales@gentics.com
88
- * Licensed unter the terms of http://www.aloha-editor.com/license.html
120
+ * This file is part of Aloha Editor
121
+ * Author & Copyright (c) 2010 Gentics Software GmbH, aloha@gentics.com
122
+ * Licensed unter the terms of http://www.aloha-editor.com/license.html
123
+ */
124
+ if(document.attachEvent&&document.selection){
125
+ /*
126
+ * DOM Ranges for Internet Explorer (m2)
127
+ *
128
+ * Copyright (c) 2009 Tim Cameron Ryan
129
+ * Released under the MIT/X License
130
+ * available at http://code.google.com/p/ierange/
131
+ */
132
+ (function(){var DOMUtils={findChildPosition:function(node){for(var i=0;node=node.previousSibling;i++){continue}return i},isDataNode:function(node){return node&&node.nodeValue!==null&&node.data!==null},isAncestorOf:function(parent,node){return !DOMUtils.isDataNode(parent)&&(parent.contains(DOMUtils.isDataNode(node)?node.parentNode:node)||node.parentNode==parent)},isAncestorOrSelf:function(root,node){return DOMUtils.isAncestorOf(root,node)||root==node},findClosestAncestor:function(root,node){if(DOMUtils.isAncestorOf(root,node)){while(node&&node.parentNode!=root){node=node.parentNode}}return node},getNodeLength:function(node){return DOMUtils.isDataNode(node)?node.length:node.childNodes.length},splitDataNode:function(node,offset){if(!DOMUtils.isDataNode(node)){return false}var newNode=node.cloneNode(false);node.deleteData(offset,node.length);newNode.deleteData(0,offset);node.parentNode.insertBefore(newNode,node.nextSibling)}};var TextRangeUtils={convertToDOMRange:function(textRange,document){function adoptBoundary(domRange,textRange,bStart){var cursorNode=document.createElement("a"),cursor=textRange.duplicate();cursor.collapse(bStart);var parent=cursor.parentElement();do{parent.insertBefore(cursorNode,cursorNode.previousSibling);cursor.moveToElementText(cursorNode)}while(cursor.compareEndPoints(bStart?"StartToStart":"StartToEnd",textRange)>0&&cursorNode.previousSibling);if(cursor.compareEndPoints(bStart?"StartToStart":"StartToEnd",textRange)==-1&&cursorNode.nextSibling){cursor.setEndPoint(bStart?"EndToStart":"EndToEnd",textRange);domRange[bStart?"setStart":"setEnd"](cursorNode.nextSibling,cursor.text.length)}else{domRange[bStart?"setStartBefore":"setEndBefore"](cursorNode)}cursorNode.parentNode.removeChild(cursorNode)}var domRange=new DOMRange(document);adoptBoundary(domRange,textRange,true);adoptBoundary(domRange,textRange,false);return domRange},convertFromDOMRange:function(domRange){function adoptEndPoint(textRange,domRange,bStart){var container=domRange[bStart?"startContainer":"endContainer"];var offset=domRange[bStart?"startOffset":"endOffset"],textOffset=0;var anchorNode=DOMUtils.isDataNode(container)?container:container.childNodes[offset];var anchorParent=DOMUtils.isDataNode(container)?container.parentNode:container;if(container.nodeType==3||container.nodeType==4){textOffset=offset}var cursorNode=domRange._document.createElement("a");anchorParent.insertBefore(cursorNode,anchorNode);var cursor=domRange._document.body.createTextRange();cursor.moveToElementText(cursorNode);cursorNode.parentNode.removeChild(cursorNode);textRange.setEndPoint(bStart?"StartToStart":"EndToStart",cursor);textRange[bStart?"moveStart":"moveEnd"]("character",textOffset)}var textRange=domRange._document.body.createTextRange();adoptEndPoint(textRange,domRange,true);adoptEndPoint(textRange,domRange,false);return textRange}};function DOMRange(document){this._document=document;this.startContainer=this.endContainer=document.body;this.endOffset=DOMUtils.getNodeLength(document.body)}DOMRange.START_TO_START=0;DOMRange.START_TO_END=1;DOMRange.END_TO_END=2;DOMRange.END_TO_START=3;DOMRange.prototype={startContainer:null,startOffset:0,endContainer:null,endOffset:0,commonAncestorContainer:null,collapsed:false,_document:null,_refreshProperties:function(){this.collapsed=(this.startContainer==this.endContainer&&this.startOffset==this.endOffset);var node=this.startContainer;while(node&&node!=this.endContainer&&!DOMUtils.isAncestorOf(node,this.endContainer)){node=node.parentNode}this.commonAncestorContainer=node},setStart:function(container,offset){this.startContainer=container;this.startOffset=offset;this._refreshProperties()},setEnd:function(container,offset){this.endContainer=container;this.endOffset=offset;this._refreshProperties()},setStartBefore:function(refNode){this.setStart(refNode.parentNode,DOMUtils.findChildPosition(refNode))},setStartAfter:function(refNode){this.setStart(refNode.parentNode,DOMUtils.findChildPosition(refNode)+1)},setEndBefore:function(refNode){this.setEnd(refNode.parentNode,DOMUtils.findChildPosition(refNode))},setEndAfter:function(refNode){this.setEnd(refNode.parentNode,DOMUtils.findChildPosition(refNode)+1)},selectNode:function(refNode){this.setStartBefore(refNode);this.setEndAfter(refNode)},selectNodeContents:function(refNode){this.setStart(refNode,0);this.setEnd(refNode,DOMUtils.getNodeLength(refNode))},collapse:function(toStart){if(toStart){this.setEnd(this.startContainer,this.startOffset)}else{this.setStart(this.endContainer,this.endOffset)}},cloneContents:function(){return(function cloneSubtree(iterator){for(var node,frag=document.createDocumentFragment();node=iterator.next();){node=node.cloneNode(!iterator.hasPartialSubtree());if(iterator.hasPartialSubtree()){node.appendChild(cloneSubtree(iterator.getSubtreeIterator()))}frag.appendChild(node)}return frag})(new RangeIterator(this))},extractContents:function(){var range=this.cloneRange();if(this.startContainer!=this.commonAncestorContainer){this.setStartAfter(DOMUtils.findClosestAncestor(this.commonAncestorContainer,this.startContainer))}this.collapse(true);return(function extractSubtree(iterator){for(var node,frag=document.createDocumentFragment();node=iterator.next();){iterator.hasPartialSubtree()?node=node.cloneNode(false):iterator.remove();if(iterator.hasPartialSubtree()){node.appendChild(extractSubtree(iterator.getSubtreeIterator()))}frag.appendChild(node)}return frag})(new RangeIterator(range))},deleteContents:function(){var range=this.cloneRange();if(this.startContainer!=this.commonAncestorContainer){this.setStartAfter(DOMUtils.findClosestAncestor(this.commonAncestorContainer,this.startContainer))}this.collapse(true);(function deleteSubtree(iterator){while(iterator.next()){iterator.hasPartialSubtree()?deleteSubtree(iterator.getSubtreeIterator()):iterator.remove()}})(new RangeIterator(range))},insertNode:function(newNode){if(DOMUtils.isDataNode(this.startContainer)){DOMUtils.splitDataNode(this.startContainer,this.startOffset);this.startContainer.parentNode.insertBefore(newNode,this.startContainer.nextSibling)}else{this.startContainer.insertBefore(newNode,this.startContainer.childNodes[this.startOffset])}this.setStart(this.startContainer,this.startOffset)},surroundContents:function(newNode){var content=this.extractContents();this.insertNode(newNode);newNode.appendChild(content);this.selectNode(newNode)},compareBoundaryPoints:function(how,sourceRange){var containerA,offsetA,containerB,offsetB;switch(how){case DOMRange.START_TO_START:case DOMRange.START_TO_END:containerA=this.startContainer;offsetA=this.startOffset;break;case DOMRange.END_TO_END:case DOMRange.END_TO_START:containerA=this.endContainer;offsetA=this.endOffset;break}switch(how){case DOMRange.START_TO_START:case DOMRange.END_TO_START:containerB=sourceRange.startContainer;offsetB=sourceRange.startOffset;break;case DOMRange.START_TO_END:case DOMRange.END_TO_END:containerB=sourceRange.endContainer;offsetB=sourceRange.endOffset;break}return containerA.sourceIndex<containerB.sourceIndex?-1:containerA.sourceIndex==containerB.sourceIndex?offsetA<offsetB?-1:offsetA==offsetB?0:1:1},cloneRange:function(){var range=new DOMRange(this._document);range.setStart(this.startContainer,this.startOffset);range.setEnd(this.endContainer,this.endOffset);return range},detach:function(){},toString:function(){return TextRangeUtils.convertFromDOMRange(this).text},createContextualFragment:function(tagString){var content=(DOMUtils.isDataNode(this.startContainer)?this.startContainer.parentNode:this.startContainer).cloneNode(false);content.innerHTML=tagString;for(var fragment=this._document.createDocumentFragment();content.firstChild;){fragment.appendChild(content.firstChild)}return fragment}};function RangeIterator(range){this.range=range;if(range.collapsed){return}var root=range.commonAncestorContainer;this._next=range.startContainer==root&&!DOMUtils.isDataNode(range.startContainer)?range.startContainer.childNodes[range.startOffset]:DOMUtils.findClosestAncestor(root,range.startContainer);this._end=range.endContainer==root&&!DOMUtils.isDataNode(range.endContainer)?range.endContainer.childNodes[range.endOffset]:DOMUtils.findClosestAncestor(root,range.endContainer).nextSibling}RangeIterator.prototype={range:null,_current:null,_next:null,_end:null,hasNext:function(){return !!this._next},next:function(){var current=this._current=this._next;this._next=this._current&&this._current.nextSibling!=this._end?this._current.nextSibling:null;if(DOMUtils.isDataNode(this._current)){if(this.range.endContainer==this._current){(current=current.cloneNode(true)).deleteData(this.range.endOffset,current.length-this.range.endOffset)}if(this.range.startContainer==this._current){(current=current.cloneNode(true)).deleteData(0,this.range.startOffset)}}return current},remove:function(){if(DOMUtils.isDataNode(this._current)&&(this.range.startContainer==this._current||this.range.endContainer==this._current)){var start=this.range.startContainer==this._current?this.range.startOffset:0;var end=this.range.endContainer==this._current?this.range.endOffset:this._current.length;this._current.deleteData(start,end-start)}else{this._current.parentNode.removeChild(this._current)}},hasPartialSubtree:function(){return !DOMUtils.isDataNode(this._current)&&(DOMUtils.isAncestorOrSelf(this._current,this.range.startContainer)||DOMUtils.isAncestorOrSelf(this._current,this.range.endContainer))},getSubtreeIterator:function(){var subRange=new DOMRange(this.range._document);subRange.selectNodeContents(this._current);if(DOMUtils.isAncestorOrSelf(this._current,this.range.startContainer)){subRange.setStart(this.range.startContainer,this.range.startOffset)}if(DOMUtils.isAncestorOrSelf(this._current,this.range.endContainer)){subRange.setEnd(this.range.endContainer,this.range.endOffset)}return new RangeIterator(subRange)}};function DOMSelection(document){this._document=document;var selection=this;document.attachEvent("onselectionchange",function(){selection._selectionChangeHandler()})}DOMSelection.prototype={rangeCount:0,_document:null,_selectionChangeHandler:function(){this.rangeCount=this._selectionExists(this._document.selection.createRange())?1:0},_selectionExists:function(textRange){return textRange.compareEndPoints("StartToEnd",textRange)!=0||textRange.parentElement().isContentEditable},addRange:function(range){var selection=this._document.selection.createRange(),textRange=TextRangeUtils.convertFromDOMRange(range);if(!this._selectionExists(selection)){textRange.select()}else{if(textRange.compareEndPoints("StartToStart",selection)==-1){if(textRange.compareEndPoints("StartToEnd",selection)>-1&&textRange.compareEndPoints("EndToEnd",selection)==-1){selection.setEndPoint("StartToStart",textRange)}else{if(textRange.compareEndPoints("EndToStart",selection)<1&&textRange.compareEndPoints("EndToEnd",selection)>-1){selection.setEndPoint("EndToEnd",textRange)}}}selection.select()}},removeAllRanges:function(){this._document.selection.empty()},getRangeAt:function(index){var textRange=this._document.selection.createRange();if(this._selectionExists(textRange)){return TextRangeUtils.convertToDOMRange(textRange,this._document)}return null},toString:function(){return this._document.selection.createRange().text}};document.createRange=function(){return new DOMRange(document)};var selection=new DOMSelection(document);window.getSelection=function(){return selection}})();
133
+ /*
134
+ * This file is part of Aloha Editor
135
+ * Author & Copyright (c) 2010 Gentics Software GmbH, aloha@gentics.com
136
+ * Licensed unter the terms of http://www.aloha-editor.com/license.html
89
137
  */
90
138
  }jQuery.fn.aloha=function(){return this.each(function(){new GENTICS.Aloha.Editable(jQuery(this))})};jQuery.fn.GENTICS_aloha=function(){return this.each(function(){new GENTICS.Aloha.Editable(jQuery(this))})};jQuery.fn.mahalo=function(){return this.each(function(){if(jQuery(this).hasClass("GENTICS_editable")){for(var i=0;i<GENTICS.Aloha.editables.length;i++){if(GENTICS.Aloha.editables[i].obj.get(0)===this){GENTICS.Aloha.editables[i].destroy()}}}})};jQuery.fn.GENTICS_mahalo=function(){return this.each(function(){var that=this})};jQuery.fn.GENTICS_contentEditableSelectionChange=function(callback){var that=this;this.keyup(function(event){var rangeObject=GENTICS.Aloha.Selection.getRangeObject();callback(event)});this.dblclick(function(event){callback(event)});this.mousedown(function(event){that.selectionStarted=true});jQuery(document).mouseup(function(event){GENTICS.Aloha.Selection.eventOriginalTarget=that;if(that.selectionStarted){callback(event)}GENTICS.Aloha.Selection.eventOriginalTarget=false;that.selectionStarted=false});return this};jQuery.fn.outerHTML=function(s){if(s){return this.before(s).remove()}else{return jQuery("<p>").append(this.eq(0).clone()).html()}};
91
139
  /*
92
- * Aloha Editor
93
- * Author & Copyright (c) 2010 Gentics Software GmbH
94
- * aloha-sales@gentics.com
95
- * Licensed unter the terms of http://www.aloha-editor.com/license.html
140
+ * This file is part of Aloha Editor
141
+ * Author & Copyright (c) 2010 Gentics Software GmbH, aloha@gentics.com
142
+ * Licensed unter the terms of http://www.aloha-editor.com/license.html
96
143
  */
97
- GENTICS.Aloha.Log=function(){};GENTICS.Aloha.Log.prototype.logHistory=null;GENTICS.Aloha.Log.prototype.highWaterMarkReached=false;GENTICS.Aloha.Log.prototype.init=function(){if(typeof GENTICS.Aloha.settings.logLevels=="undefined"||!GENTICS.Aloha.settings.logLevels){GENTICS.Aloha.settings.logLevels={error:true,warn:true}}if(typeof GENTICS.Aloha.settings.logHistory=="undefined"||!GENTICS.Aloha.settings.logHistory){GENTICS.Aloha.settings.logHistory={}}if(!GENTICS.Aloha.settings.logHistory.maxEntries){GENTICS.Aloha.settings.logHistory.maxEntries=100}if(!GENTICS.Aloha.settings.logHistory.highWaterMark){GENTICS.Aloha.settings.logHistory.highWaterMark=90}if(!GENTICS.Aloha.settings.logHistory.levels){GENTICS.Aloha.settings.logHistory.levels={error:true,warn:true}}this.flushLogHistory()};GENTICS.Aloha.Log.prototype.log=function(level,component,message){if(typeof level=="undefined"||!level){level="error"}level=level.toLowerCase();if(!GENTICS.Aloha.settings.logLevels[level]){return}this.addToLogHistory({level:level,component:component.toString(),message:message,date:new Date()});switch(level){case"error":if(window.console&&console.error){console.error(component.toString()+": "+message)}break;case"warn":if(window.console&&console.warn){console.warn(component.toString()+": "+message)}break;case"info":if(window.console&&console.info){console.info(component.toString()+": "+message)}break;case"debug":if(window.console&&console.log){console.log(component.toString()+" ["+level+"]: "+message)}break;default:if(window.console&&console.log){console.log(component.toString()+" ["+level+"]: "+message)}break}};GENTICS.Aloha.Log.prototype.error=function(component,message){this.log("error",component,message)};GENTICS.Aloha.Log.prototype.warn=function(component,message){this.log("warn",component,message)};GENTICS.Aloha.Log.prototype.info=function(component,message){this.log("info",component,message)};GENTICS.Aloha.Log.prototype.debug=function(component,message){this.log("debug",component,message)};GENTICS.Aloha.Log.prototype.isLogLevelEnabled=function(level){return GENTICS.Aloha.settings&&GENTICS.Aloha.settings.logLevels&&(GENTICS.Aloha.settings.logLevels[level]==true)};GENTICS.Aloha.Log.prototype.isErrorEnabled=function(){return this.isLogLevelEnabled("error")};GENTICS.Aloha.Log.prototype.isWarnEnabled=function(){return this.isLogLevelEnabled("warn")};GENTICS.Aloha.Log.prototype.isInfoEnabled=function(){return this.isLogLevelEnabled("info")};GENTICS.Aloha.Log.prototype.isDebugEnabled=function(){return this.isLogLevelEnabled("debug")};GENTICS.Aloha.Log.prototype.addToLogHistory=function(entry){if(GENTICS.Aloha.settings.logHistory.maxEntries<=0){return}if(!GENTICS.Aloha.settings.logHistory.levels[entry.level]){return}this.logHistory.push(entry);if(this.highWaterMarkReached==false){if(this.logHistory.length>=GENTICS.Aloha.settings.logHistory.maxEntries*GENTICS.Aloha.settings.logHistory.highWaterMark/100){GENTICS.Aloha.EventRegistry.trigger(new GENTICS.Aloha.Event("logFull",GENTICS.Aloha.Log));this.highWaterMarkReached=true}}while(this.logHistory.length>GENTICS.Aloha.settings.logHistory.maxEntries){this.logHistory.shift()}};GENTICS.Aloha.Log.prototype.getLogHistory=function(){return this.logHistory};GENTICS.Aloha.Log.prototype.flushLogHistory=function(){this.logHistory=new Array();this.highWaterMarkReached=false};GENTICS.Aloha.Log=new GENTICS.Aloha.Log();
144
+ GENTICS.Aloha.Log=function(){};GENTICS.Aloha.Log.prototype.logHistory=null;GENTICS.Aloha.Log.prototype.highWaterMarkReached=false;GENTICS.Aloha.Log.prototype.init=function(){if(typeof GENTICS.Aloha.settings.logLevels=="undefined"||!GENTICS.Aloha.settings.logLevels){GENTICS.Aloha.settings.logLevels={error:true,warn:true}}if(typeof GENTICS.Aloha.settings.logHistory=="undefined"||!GENTICS.Aloha.settings.logHistory){GENTICS.Aloha.settings.logHistory={}}if(!GENTICS.Aloha.settings.logHistory.maxEntries){GENTICS.Aloha.settings.logHistory.maxEntries=100}if(!GENTICS.Aloha.settings.logHistory.highWaterMark){GENTICS.Aloha.settings.logHistory.highWaterMark=90}if(!GENTICS.Aloha.settings.logHistory.levels){GENTICS.Aloha.settings.logHistory.levels={error:true,warn:true}}this.flushLogHistory()};GENTICS.Aloha.Log.prototype.log=function(level,component,message){if(typeof level=="undefined"||!level){level="error"}level=level.toLowerCase();if(!GENTICS.Aloha.settings.logLevels[level]){return}this.addToLogHistory({level:level,component:component.toString(),message:message,date:new Date()});switch(level){case"error":if(window.console&&console.error){console.error(component.toString()+": "+message)}break;case"warn":if(window.console&&console.warn){console.warn(component.toString()+": "+message)}break;case"info":if(window.console&&console.info){console.info(component.toString()+": "+message)}break;case"debug":if(window.console&&console.log){console.log(component.toString()+" ["+level+"]: "+message)}break;default:if(window.console&&console.log){console.log(component.toString()+" ["+level+"]: "+message)}break}};GENTICS.Aloha.Log.prototype.error=function(component,message){this.log("error",component,message)};GENTICS.Aloha.Log.prototype.warn=function(component,message){this.log("warn",component,message)};GENTICS.Aloha.Log.prototype.info=function(component,message){this.log("info",component,message)};GENTICS.Aloha.Log.prototype.debug=function(component,message){this.log("debug",component,message)};GENTICS.Aloha.Log.prototype.isLogLevelEnabled=function(level){return GENTICS.Aloha.settings&&GENTICS.Aloha.settings.logLevels&&(GENTICS.Aloha.settings.logLevels[level]==true)};GENTICS.Aloha.Log.prototype.isErrorEnabled=function(){return this.isLogLevelEnabled("error")};GENTICS.Aloha.Log.prototype.isWarnEnabled=function(){return this.isLogLevelEnabled("warn")};GENTICS.Aloha.Log.prototype.isInfoEnabled=function(){return this.isLogLevelEnabled("info")};GENTICS.Aloha.Log.prototype.isDebugEnabled=function(){return this.isLogLevelEnabled("debug")};GENTICS.Aloha.Log.prototype.addToLogHistory=function(entry){if(GENTICS.Aloha.settings.logHistory.maxEntries<=0||!GENTICS.Aloha.settings.logHistory.levels[entry.level]){return}this.logHistory.push(entry);if(this.highWaterMarkReached==false){if(this.logHistory.length>=GENTICS.Aloha.settings.logHistory.maxEntries*GENTICS.Aloha.settings.logHistory.highWaterMark/100){GENTICS.Aloha.EventRegistry.trigger(new GENTICS.Aloha.Event("logFull",GENTICS.Aloha.Log));this.highWaterMarkReached=true}}while(this.logHistory.length>GENTICS.Aloha.settings.logHistory.maxEntries){this.logHistory.shift()}};GENTICS.Aloha.Log.prototype.getLogHistory=function(){return this.logHistory};GENTICS.Aloha.Log.prototype.flushLogHistory=function(){this.logHistory=[];this.highWaterMarkReached=false};GENTICS.Aloha.Log=new GENTICS.Aloha.Log();
98
145
  /*
99
- * Aloha Editor
100
- * Author & Copyright (c) 2010 Gentics Software GmbH
101
- * aloha-sales@gentics.com
102
- * Licensed unter the terms of http://www.aloha-editor.com/license.html
146
+ * This file is part of Aloha Editor
147
+ * Author & Copyright (c) 2010 Gentics Software GmbH, aloha@gentics.com
148
+ * Licensed unter the terms of http://www.aloha-editor.com/license.html
103
149
  */
104
150
  GENTICS.Aloha.Markup=function(){};GENTICS.Aloha.Markup.prototype.keyHandlers={};GENTICS.Aloha.Markup.prototype.addKeyHandler=function(keyCode,handler){if(!this.keyHandlers[keyCode]){this.keyHandlers[keyCode]=[]}this.keyHandlers[keyCode].push(handler)};GENTICS.Aloha.Markup.prototype.insertBreak=function(){var range=GENTICS.Aloha.Selection.rangeObject;if(!range.isCollapsed()){this.removeSelectedMarkup()}var newBreak=jQuery("<br/>");GENTICS.Utils.Dom.insertIntoDOM(newBreak,range,GENTICS.Aloha.activeEditable.obj);var nextTextNode=GENTICS.Utils.Dom.searchAdjacentTextNode(newBreak.parent().get(0),GENTICS.Utils.Dom.getIndexInParent(newBreak.get(0))+1,false);if(nextTextNode){var nonWSIndex=nextTextNode.data.search(/\S/);if(nonWSIndex>0){nextTextNode.data=nextTextNode.data.substring(nonWSIndex)}}range.startContainer=range.endContainer=newBreak.get(0).parentNode;range.startOffset=range.endOffset=GENTICS.Utils.Dom.getIndexInParent(newBreak.get(0))+1;range.correctRange();range.clearCaches();range.select()};GENTICS.Aloha.Markup.prototype.preProcessKeyStrokes=function(event){if(event.type!="keydown"){return false}var rangeObject=GENTICS.Aloha.Selection.rangeObject;if(this.keyHandlers[event.keyCode]){var handlers=this.keyHandlers[event.keyCode];for(var i=0;i<handlers.length;++i){if(!handlers[i](event)){return false}}}switch(event.keyCode){case 13:if(event.shiftKey){GENTICS.Aloha.Log.debug(this,"... got a smoking Shift+Enter, Cowboy");if(!rangeObject.isCollapsed()){this.removeSelectedMarkup()}GENTICS.Aloha.Selection.updateSelection(false,true);this.processShiftEnter(rangeObject);return false}else{GENTICS.Aloha.Log.debug(this,"... got a lonely Enter, Mum");if(!rangeObject.isCollapsed()){this.removeSelectedMarkup()}GENTICS.Aloha.Selection.updateSelection(false,true);this.processEnter(rangeObject);return false}break}return true};GENTICS.Aloha.Markup.prototype.processShiftEnter=function(rangeObject){this.insertHTMLBreak(rangeObject.getSelectionTree(),rangeObject)};GENTICS.Aloha.Markup.prototype.processEnter=function(rangeObject){if(rangeObject.splitObject){if(jQuery.browser.msie&&GENTICS.Utils.Dom.isListElement(rangeObject.splitObject)){jQuery(rangeObject.splitObject).append(jQuery(document.createTextNode("")))}this.splitRangeObject(rangeObject)}else{this.insertHTMLBreak(rangeObject.getSelectionTree(),rangeObject)}};GENTICS.Aloha.Markup.prototype.insertHTMLCode=function(html){var rangeObject=GENTICS.Aloha.Selection.rangeObject;this.insertHTMLBreak(rangeObject.getSelectionTree(),rangeObject,jQuery(html))};GENTICS.Aloha.Markup.prototype.insertHTMLBreak=function(selectionTree,rangeObject,inBetweenMarkup){inBetweenMarkup=inBetweenMarkup?inBetweenMarkup:jQuery("<br />");for(var i=0;i<selectionTree.length;i++){var el=selectionTree[i];var jqEl=el.domobj?jQuery(el.domobj):undefined;if(el.selection!=="none"){if(el.selection=="collapsed"){if(i>0){var jqElBefore=jQuery(selectionTree[i-1].domobj);jqElBefore.after(inBetweenMarkup)}else{var jqElAfter=jQuery(selectionTree[1].domobj);jqElAfter.before(inBetweenMarkup)}rangeObject.startContainer=rangeObject.endContainer=inBetweenMarkup[0].parentNode;rangeObject.startOffset=rangeObject.endOffset=GENTICS.Utils.Dom.getIndexInParent(inBetweenMarkup[0])+1;rangeObject.correctRange()}else{if(el.domobj&&el.domobj.nodeType===3){if(el.domobj.nextSibling&&el.domobj.nextSibling.nodeType==1&&GENTICS.Aloha.Selection.replacingElements[el.domobj.nextSibling.nodeName.toLowerCase()]){jqEl.after("<br/>")}var checkObj=el.domobj;while(checkObj){if(checkObj.nextSibling){checkObj=false}else{checkObj=checkObj.parentNode;if(checkObj===rangeObject.limitObject){checkObj=false}if(GENTICS.Utils.Dom.isBlockLevelElement(checkObj)){break}}}if(checkObj){jQuery(checkObj).append("<br/>")}jqEl.between(inBetweenMarkup,el.startOffset);var offset=0;var tmpObject=inBetweenMarkup[0];while(tmpObject){tmpObject=tmpObject.previousSibling;offset++}rangeObject.startContainer=inBetweenMarkup[0].parentNode;rangeObject.endContainer=inBetweenMarkup[0].parentNode;rangeObject.startOffset=offset;rangeObject.endOffset=offset;rangeObject.correctRange()}else{if(el.domobj&&el.domobj.nodeType===1){if(jqEl.parent().find("br.GENTICS_ephemera").length===0){jQuery(rangeObject.limitObject).find("br.GENTICS_ephemera").remove();jQuery(rangeObject.commonAncestorContainer).append(this.getFillUpElement(rangeObject.splitObject))}jqEl.after(inBetweenMarkup);rangeObject.startContainer=rangeObject.commonAncestorContainer;rangeObject.endContainer=rangeObject.startContainer;rangeObject.startOffset=i+2;rangeObject.endOffset=i+2;rangeObject.update()}}}}}rangeObject.select()};GENTICS.Aloha.Markup.prototype.getSelectedText=function(){var rangeObject=GENTICS.Aloha.Selection.rangeObject;if(rangeObject.isCollapsed()){return false}return this.getFromSelectionTree(rangeObject.getSelectionTree(),true)};GENTICS.Aloha.Markup.prototype.getFromSelectionTree=function(selectionTree,astext){var text="";for(var i=0;i<selectionTree.length;i++){var el=selectionTree[i];if(el.selection=="partial"){if(el.domobj.nodeType==3){text+=el.domobj.data.substring(el.startOffset,el.endOffset)}else{if(el.domobj.nodeType==1&&el.children){if(astext){text+=this.getFromSelectionTree(el.children,astext)}else{var clone=jQuery(el.domobj).clone(false).empty();clone.html(this.getFromSelectionTree(el.children,astext));text+=clone.outerHTML()}}}}else{if(el.selection=="full"){if(el.domobj.nodeType==3){text+=jQuery(el.domobj).text()}else{if(el.domobj.nodeType==1&&el.children){text+=astext?jQuery(el.domobj).text():jQuery(el.domobj).outerHTML()}}}}}return text};GENTICS.Aloha.Markup.prototype.getSelectedMarkup=function(){var rangeObject=GENTICS.Aloha.Selection.rangeObject;if(rangeObject.isCollapsed()){return false}return this.getFromSelectionTree(rangeObject.getSelectionTree(),false)};GENTICS.Aloha.Markup.prototype.removeSelectedMarkup=function(){var rangeObject=GENTICS.Aloha.Selection.rangeObject;if(rangeObject.isCollapsed()){return}var newRange=new GENTICS.Aloha.Selection.SelectionRange();this.removeFromSelectionTree(rangeObject.getSelectionTree(),newRange);newRange.update();GENTICS.Utils.Dom.doCleanup({merge:true,removeempty:true},GENTICS.Aloha.Selection.rangeObject);GENTICS.Aloha.Selection.rangeObject=newRange;newRange.correctRange();newRange.update();newRange.select();GENTICS.Aloha.Selection.updateSelection()};GENTICS.Aloha.Markup.prototype.removeFromSelectionTree=function(selectionTree,newRange){var firstPartialElement=undefined;for(var i=0;i<selectionTree.length;i++){var el=selectionTree[i];if(el.selection=="partial"){if(el.domobj.nodeType==3){var newdata="";if(el.startOffset>0){newdata+=el.domobj.data.substring(0,el.startOffset)}if(el.endOffset<el.domobj.data.length){newdata+=el.domobj.data.substring(el.endOffset,el.domobj.data.length)}el.domobj.data=newdata;if(!newRange.startContainer){newRange.startContainer=newRange.endContainer=el.domobj;newRange.startOffset=newRange.endOffset=el.startOffset}}else{if(el.domobj.nodeType==1&&el.children){this.removeFromSelectionTree(el.children,newRange);if(firstPartialElement){if(firstPartialElement.nodeName==el.domobj.nodeName){jQuery(firstPartialElement).append(jQuery(el.domobj).contents());jQuery(el.domobj).remove()}}else{firstPartialElement=el.domobj}}}}else{if(el.selection=="full"){if(!newRange.startContainer){var adjacentTextNode=GENTICS.Utils.Dom.searchAdjacentTextNode(el.domobj.parentNode,GENTICS.Utils.Dom.getIndexInParent(el.domobj)+1,false,{blocklevel:false});if(adjacentTextNode){newRange.startContainer=newRange.endContainer=adjacentTextNode;newRange.startOffset=newRange.endOffset=0}else{newRange.startContainer=newRange.endContainer=el.domobj.parentNode;newRange.startOffset=newRange.endOffset=GENTICS.Utils.Dom.getIndexInParent(el.domobj)+1}}jQuery(el.domobj).remove()}}}};GENTICS.Aloha.Markup.prototype.splitRangeObject=function(rangeObject,markup){var splitObject=jQuery(rangeObject.splitObject);rangeObject.update(rangeObject.splitObject);var selectionTree=rangeObject.getSelectionTree();var followUpContainer=this.getSplitFollowUpContainer(rangeObject);this.splitRangeObjectHelper(selectionTree,rangeObject,followUpContainer);if(followUpContainer.hasClass("preparedForRemoval")){followUpContainer.removeClass("preparedForRemoval")}var insertAfterObject=this.getInsertAfterObject(rangeObject,followUpContainer);jQuery(followUpContainer).insertAfter(insertAfterObject);if(rangeObject.splitObject.nodeName.toLowerCase()==="li"&&!GENTICS.Aloha.Selection.standardTextLevelSemanticsComparator(rangeObject.splitObject,followUpContainer)){jQuery(rangeObject.splitObject).remove()}rangeObject.startContainer=followUpContainer.textNodes(true,true).first().get(0);if(!rangeObject.startContainer){rangeObject.startContainer=followUpContainer.textNodes(false).first().parent().get(0)}if(rangeObject.startContainer){rangeObject.endContainer=rangeObject.startContainer;rangeObject.startOffset=0;rangeObject.endOffset=0}else{rangeObject.startContainer=rangeObject.endContainer=followUpContainer.parent().get(0);rangeObject.startOffset=rangeObject.endOffset=GENTICS.Utils.Dom.getIndexInParent(followUpContainer.get(0))}rangeObject.update();rangeObject.select()};GENTICS.Aloha.Markup.prototype.getInsertAfterObject=function(rangeObject,followUpContainer){for(var i=0;i<rangeObject.markupEffectiveAtStart.length;i++){el=rangeObject.markupEffectiveAtStart[i];if(el===rangeObject.splitObject){var passedSplitObject=true}if(!passedSplitObject){continue}if(GENTICS.Aloha.Selection.canTag1WrapTag2(jQuery(el).parent()[0].nodeName,followUpContainer[0].nodeName)){return el}}return false};GENTICS.Aloha.Markup.prototype.getFillUpElement=function(splitObject){if(jQuery.browser.msie){return false}else{return jQuery('<br class="GENTICS_ephemera" />')}};GENTICS.Aloha.Markup.prototype.removeElementContentWhitespaceObj=function(domArray){var correction=0;var removeLater=[];for(var i=0;i<domArray.length;i++){var el=domArray[i];if(el.isElementContentWhitespace){removeLater[removeLater.length]=i}}for(var i=0;i<removeLater.length;i++){var removeIndex=removeLater[i];domArray.splice(removeIndex-correction,1);correction++}};GENTICS.Aloha.Markup.prototype.splitRangeObjectHelper=function(selectionTree,rangeObject,followUpContainer,inBetweenMarkup){if(!followUpContainer){GENTICS.Aloha.Log.warn(this,"no followUpContainer, no inBetweenMarkup, nothing to do...")}var fillUpElement=this.getFillUpElement(rangeObject.splitObject);var splitObject=jQuery(rangeObject.splitObject);var startMoving=false;if(selectionTree.length>0){var mirrorLevel=followUpContainer.contents();if(mirrorLevel.length!==selectionTree.length){this.removeElementContentWhitespaceObj(mirrorLevel)}for(var i=0;i<selectionTree.length;i++){var el=selectionTree[i];if((el.selection==="none"&&startMoving===false)||(el.domobj&&el.domobj.nodeType===3&&el===selectionTree[(selectionTree.length-1)]&&el.startOffset===el.domobj.data.length)){if(followUpContainer.textNodes().length>1){mirrorLevel.eq(i).remove()}else{if(GENTICS.Utils.Dom.isSplitObject(followUpContainer[0])){if(fillUpElement){followUpContainer.html(fillUpElement)}else{followUpContainer.empty()}}else{followUpContainer.empty();followUpContainer.addClass("preparedForRemoval")}}continue}else{if(el.selection!=="none"){if(el.domobj&&el.domobj.nodeType===3&&el.startOffset!==undefined){var completeText=el.domobj.data;if(el.startOffset>0){el.domobj.data=completeText.substr(0,el.startOffset)}else{if(selectionTree.length>1){jQuery(el.domobj).remove()}else{var parent=jQuery(el.domobj).parent();if(GENTICS.Utils.Dom.isSplitObject(parent[0])){if(fillUpElement){parent.html(fillUpElement)}else{parent.empty()}}else{parent.remove()}}}if(completeText.length-el.startOffset>0){mirrorLevel[i].data=completeText.substr(el.startOffset,completeText.length)}else{if(mirrorLevel.length>1){mirrorLevel.eq((i)).remove()}else{if(GENTICS.Utils.Dom.isBlockLevelElement(followUpContainer[0])){if(fillUpElement){followUpContainer.html(fillUpElement)}else{followUpContainer.empty()}}else{followUpContainer.empty();followUpContainer.addClass("preparedForRemoval")}}}}startMoving=true;if(el.children.length>0){this.splitRangeObjectHelper(el.children,rangeObject,mirrorLevel.eq(i),inBetweenMarkup)}}else{if(el.selection==="none"&&startMoving===true){jqObj=jQuery(el.domobj).remove()}}}}}else{GENTICS.Aloha.Log.error(this,"can not split splitObject due to an empty selection tree")}splitObject.find("br.GENTICS_ephemera:gt(0)").remove();followUpContainer.find("br.GENTICS_ephemera:gt(0)").remove();splitObject.find(".preparedForRemoval").remove();followUpContainer.find(".preparedForRemoval").remove();if(splitObject.contents().length===0&&GENTICS.Utils.Dom.isSplitObject(splitObject[0])&&fillUpElement){splitObject.html(fillUpElement)}if(followUpContainer.contents().length===0&&GENTICS.Utils.Dom.isSplitObject(followUpContainer[0])&&fillUpElement){followUpContainer.html(fillUpElement)}};GENTICS.Aloha.Markup.prototype.getSplitFollowUpContainer=function(rangeObject){var tagName=rangeObject.splitObject.nodeName.toLowerCase();switch(tagName){case"h1":case"h2":case"h3":case"h4":case"h5":case"h6":var lastObj=jQuery(rangeObject.splitObject).textNodes().last()[0];if(lastObj&&rangeObject.startContainer===lastObj&&rangeObject.startOffset===lastObj.length){var returnObj=jQuery("<p></p>");var inside=jQuery(rangeObject.splitObject).clone().contents();returnObj.append(inside);return returnObj}break;case"li":if(rangeObject.startContainer.nodeName.toLowerCase()==="br"&&jQuery(rangeObject.startContainer).hasClass("GENTICS_ephemera")){var returnObj=jQuery("<p></p>");var inside=jQuery(rangeObject.splitObject).clone().contents();returnObj.append(inside);return returnObj}if(!rangeObject.splitObject.nextSibling&&jQuery.trim(jQuery(rangeObject.splitObject).text()).length==0){var returnObj=jQuery("<p></p>");return returnObj}}return jQuery(rangeObject.splitObject).clone()};GENTICS.Aloha.Markup.prototype.transformDomObject=function(domobj,nodeName){var jqOldObj=jQuery(domobj);var jqNewObj=jQuery("<"+nodeName+"></"+nodeName+">");jqOldObj.contents().appendTo(jqNewObj);jqOldObj.replaceWith(jqNewObj);return jqNewObj};GENTICS.Aloha.Markup.prototype.toString=function(){return"GENTICS.Aloha.Markup"};GENTICS.Aloha.Markup=new GENTICS.Aloha.Markup();
105
151
  /*
106
- * Aloha Editor
107
- * Author & Copyright (c) 2010 Gentics Software GmbH
108
- * aloha-sales@gentics.com
109
- * Licensed unter the terms of http://www.aloha-editor.com/license.html
152
+ * This file is part of Aloha Editor
153
+ * Author & Copyright (c) 2010 Gentics Software GmbH, aloha@gentics.com
154
+ * Licensed unter the terms of http://www.aloha-editor.com/license.html
110
155
  */
111
- GENTICS.Aloha.Message=function(data){this.title=data.title;this.text=data.text;this.type=data.type;this.callback=data.callback};GENTICS.Aloha.Message.Type={CONFIRM:"confirm",ALERT:"alert",WAIT:"wait"};GENTICS.Aloha.Message.prototype.toString=function(){return this.type+": "+this.message};GENTICS.Aloha.MessageLine=function(){this.messages=new Array()};GENTICS.Aloha.MessageLine.prototype.add=function(message){this.messages[this.messages.length]=message;while(this.messages.length>4){this.messages.shift()}jQuery("#gtx_aloha_messageline").html("");for(var i=0;i<this.messages.length;i++){jQuery("#gtx_aloha_messageline").append((this.messages[i].toString()+"<br/>"))}};GENTICS.Aloha.MessageLine=new GENTICS.Aloha.MessageLine();
156
+ GENTICS.Aloha.Message=function(data){this.title=data.title;this.text=data.text;this.type=data.type;this.callback=data.callback};GENTICS.Aloha.Message.Type={CONFIRM:"confirm",ALERT:"alert",WAIT:"wait"};GENTICS.Aloha.Message.prototype.toString=function(){return this.type+": "+this.message};GENTICS.Aloha.MessageLine=function(){this.messages=[]};GENTICS.Aloha.MessageLine.prototype.add=function(message){this.messages[this.messages.length]=message;while(this.messages.length>4){this.messages.shift()}jQuery("#gtx_aloha_messageline").empty();for(var i=0;i<this.messages.length;i++){jQuery("#gtx_aloha_messageline").append((this.messages[i].toString()+"<br/>"))}};GENTICS.Aloha.MessageLine=new GENTICS.Aloha.MessageLine();
112
157
  /*
113
- * Aloha Editor
114
- * Author & Copyright (c) 2010 Gentics Software GmbH
115
- * aloha-sales@gentics.com
116
- * Licensed unter the terms of http://www.aloha-editor.com/license.html
158
+ * This file is part of Aloha Editor
159
+ * Author & Copyright (c) 2010 Gentics Software GmbH, aloha@gentics.com
160
+ * Licensed unter the terms of http://www.aloha-editor.com/license.html
117
161
  */
118
- GENTICS.Aloha.PluginRegistry=function(){this.plugins=new Array()};GENTICS.Aloha.PluginRegistry.prototype.register=function(plugin){if(plugin instanceof GENTICS.Aloha.Plugin){this.plugins.push(plugin)}};GENTICS.Aloha.PluginRegistry.prototype.init=function(){for(var i=0;i<this.plugins.length;i++){var plugin=this.plugins[i];if(GENTICS.Aloha.settings.plugins==undefined){GENTICS.Aloha.settings.plugins={}}plugin.settings=GENTICS.Aloha.settings.plugins[plugin.prefix];if(plugin.settings==undefined){plugin.settings={}}if(plugin.settings.enabled==undefined){plugin.settings.enabled=true}var actualLanguage=plugin.languages?GENTICS.Aloha.getLanguage(GENTICS.Aloha.settings.i18n.current,plugin.languages):null;if(!actualLanguage){GENTICS.Aloha.Log.warn(this,"Could not determine actual language, no languages available for plugin "+plugin)}else{var fileUrl=GENTICS.Aloha.settings.base+"plugins/"+plugin.basePath+"/i18n/"+actualLanguage+".dict";GENTICS.Aloha.loadI18nFile(fileUrl,plugin)}if(plugin.settings.enabled==true){this.plugins[i].init()}}};GENTICS.Aloha.PluginRegistry.prototype.makeClean=function(obj){for(var i=0;i<this.plugins.length;i++){var plugin=this.plugins[i];if(GENTICS.Aloha.Log.isDebugEnabled()){GENTICS.Aloha.Log.debug(this,"Passing contents of HTML Element with id { "+obj.attr("id")+" } for cleaning to plugin { "+plugin.prefix+" }")}plugin.makeClean(obj)}};GENTICS.Aloha.PluginRegistry=new GENTICS.Aloha.PluginRegistry();GENTICS.Aloha.PluginRegistry.toString=function(){return"com.gentics.aloha.PluginRegistry"};GENTICS.Aloha.Plugin=function(pluginPrefix,basePath){this.prefix=pluginPrefix;this.basePath=basePath?basePath:pluginPrefix;GENTICS.Aloha.PluginRegistry.register(this)};GENTICS.Aloha.Plugin.prototype.settings=null;GENTICS.Aloha.Plugin.prototype.init=function(){};GENTICS.Aloha.Plugin.prototype.getEditableConfig=function(obj){var config=[];var configSpecified=false;if(this.settings.editables){jQuery.each(this.settings.editables,function(selector,selectorConfig){if(obj.is(selector)){configSpecified=true;config=jQuery.merge(config,selectorConfig)}})}if(!configSpecified){if(this.settings.config=="undefined"||!this.settings.config){config=this.config}else{config=this.settings.config}}return config};GENTICS.Aloha.Plugin.prototype.makeClean=function(obj){};GENTICS.Aloha.Plugin.prototype.getUID=function(id){return this.prefix+"."+id};GENTICS.Aloha.Plugin.prototype.i18n=function(key,replacements){return GENTICS.Aloha.i18n(this,key,replacements)};GENTICS.Aloha.Plugin.prototype.toString=function(){return this.prefix};GENTICS.Aloha.Plugin.prototype.log=function(level,message){GENTICS.Aloha.Log.log(level,this,message)};
162
+ GENTICS.Aloha.PluginRegistry=function(){this.plugins=[]};GENTICS.Aloha.PluginRegistry.prototype.register=function(plugin){if(plugin instanceof GENTICS.Aloha.Plugin){this.plugins.push(plugin)}};GENTICS.Aloha.PluginRegistry.prototype.init=function(){for(var i=0;i<this.plugins.length;i++){var plugin=this.plugins[i];if(GENTICS.Aloha.settings.plugins==undefined){GENTICS.Aloha.settings.plugins={}}plugin.settings=GENTICS.Aloha.settings.plugins[plugin.prefix];if(plugin.settings==undefined){plugin.settings={}}if(plugin.settings.enabled==undefined){plugin.settings.enabled=true}var actualLanguage=plugin.languages?GENTICS.Aloha.getLanguage(GENTICS.Aloha.settings.i18n.current,plugin.languages):null;if(!actualLanguage){GENTICS.Aloha.Log.warn(this,"Could not determine actual language, no languages available for plugin "+plugin)}else{var fileUrl=GENTICS.Aloha.settings.base+"plugins/"+plugin.basePath+"/i18n/"+actualLanguage+".dict";GENTICS.Aloha.loadI18nFile(fileUrl,plugin)}if(plugin.settings.enabled==true){this.plugins[i].init()}}};GENTICS.Aloha.PluginRegistry.prototype.makeClean=function(obj){for(var i=0;i<this.plugins.length;i++){var plugin=this.plugins[i];if(GENTICS.Aloha.Log.isDebugEnabled()){GENTICS.Aloha.Log.debug(this,"Passing contents of HTML Element with id { "+obj.attr("id")+" } for cleaning to plugin { "+plugin.prefix+" }")}plugin.makeClean(obj)}};GENTICS.Aloha.PluginRegistry=new GENTICS.Aloha.PluginRegistry();GENTICS.Aloha.PluginRegistry.toString=function(){return"com.gentics.aloha.PluginRegistry"};GENTICS.Aloha.Plugin=function(pluginPrefix,basePath){this.prefix=pluginPrefix;this.basePath=basePath?basePath:pluginPrefix;GENTICS.Aloha.PluginRegistry.register(this)};GENTICS.Aloha.Plugin.prototype.settings=null;GENTICS.Aloha.Plugin.prototype.init=function(){};GENTICS.Aloha.Plugin.prototype.getEditableConfig=function(obj){var config=[];var configSpecified=false;if(this.settings.editables){jQuery.each(this.settings.editables,function(selector,selectorConfig){if(obj.is(selector)){configSpecified=true;config=jQuery.merge(config,selectorConfig)}})}if(!configSpecified){if(typeof this.settings.config=="undefined"||!this.settings.config){config=this.config}else{config=this.settings.config}}return config};GENTICS.Aloha.Plugin.prototype.makeClean=function(obj){};GENTICS.Aloha.Plugin.prototype.getUID=function(id){return this.prefix+"."+id};GENTICS.Aloha.Plugin.prototype.i18n=function(key,replacements){return GENTICS.Aloha.i18n(this,key,replacements)};GENTICS.Aloha.Plugin.prototype.toString=function(){return this.prefix};GENTICS.Aloha.Plugin.prototype.log=function(level,message){GENTICS.Aloha.Log.log(level,this,message)};
119
163
  /*
120
- * Aloha Editor
121
- * Author & Copyright (c) 2010 Gentics Software GmbH
122
- * aloha-sales@gentics.com
123
- * Licensed unter the terms of http://www.aloha-editor.com/license.html
164
+ * This file is part of Aloha Editor
165
+ * Author & Copyright (c) 2010 Gentics Software GmbH, aloha@gentics.com
166
+ * Licensed unter the terms of http://www.aloha-editor.com/license.html
124
167
  */
125
- jQuery.fn.zap=function(){return this.each(function(){jQuery(this.childNodes).insertBefore(this)}).remove()};jQuery.fn.textNodes=function(excludeBreaks,includeEmptyTextNodes){var ret=[];(function(el){if((el.nodeType==3&&jQuery.trim(el.data)!=""&&!includeEmptyTextNodes)||(el.nodeType==3&&includeEmptyTextNodes)||(el.nodeName=="BR"&&!excludeBreaks)){ret.push(el)}else{for(var i=0;i<el.childNodes.length;++i){arguments.callee(el.childNodes[i])}}})(this[0]);return jQuery(ret)};GENTICS.Aloha.Selection=function(){this.rangeObject=new Object();this.tagHierarchy={textNode:[],abbr:["textNode"],b:["textNode","b","i","em","sup","sub","br","span","img","a","del","ins","u","cite","q","code","abbr","strong"],pre:["textNode","b","i","em","sup","sub","br","span","img","a","del","ins","u","cite","q","code","abbr","code"],blockquote:["textNode","b","i","em","sup","sub","br","span","img","a","del","ins","u","cite","q","code","abbr","p","h1","h2","h3","h4","h5","h6"],ins:["textNode","b","i","em","sup","sub","br","span","img","a","u","p","h1","h2","h3","h4","h5","h6"],ul:["li"],ol:["li"],li:["textNode","b","i","em","sup","sub","br","span","img","ul","ol","h1","h2","h3","h4","h5","h6","del","ins","u"],tr:["td","th"],table:["tr"],div:["textNode","b","i","em","sup","sub","br","span","img","ul","ol","table","h1","h2","h3","h4","h5","h6","del","ins","u","p","div","pre","blockquote"],h1:["textNode","b","i","em","sup","sub","br","span","img","a","del","ins","u"]};this.tagHierarchy={textNode:this.tagHierarchy.textNode,abbr:this.tagHierarchy.abbr,br:this.tagHierarchy.textNode,img:this.tagHierarchy.textNode,b:this.tagHierarchy.b,strong:this.tagHierarchy.b,code:this.tagHierarchy.b,q:this.tagHierarchy.b,blockquote:this.tagHierarchy.blockquote,cite:this.tagHierarchy.b,i:this.tagHierarchy.b,em:this.tagHierarchy.b,sup:this.tagHierarchy.b,sub:this.tagHierarchy.b,span:this.tagHierarchy.b,del:this.tagHierarchy.del,ins:this.tagHierarchy.ins,u:this.tagHierarchy.b,p:this.tagHierarchy.b,pre:this.tagHierarchy.pre,a:this.tagHierarchy.b,ul:this.tagHierarchy.ul,ol:this.tagHierarchy.ol,li:this.tagHierarchy.li,td:this.tagHierarchy.li,div:this.tagHierarchy.div,h1:this.tagHierarchy.h1,h2:this.tagHierarchy.h1,h3:this.tagHierarchy.h1,h4:this.tagHierarchy.h1,h5:this.tagHierarchy.h1,h6:this.tagHierarchy.h1,table:this.tagHierarchy.table};this.replacingElements={h1:["p","h1","h2","h3","h4","h5","h6","pre"],blockquote:["blockquote"]};this.replacingElements={h1:this.replacingElements.h1,h2:this.replacingElements.h1,h3:this.replacingElements.h1,h4:this.replacingElements.h1,h5:this.replacingElements.h1,h6:this.replacingElements.h1,pre:this.replacingElements.h1,p:this.replacingElements.h1,blockquote:this.replacingElements.blockquote};this.allowedToStealElements={h1:["textNode"]};this.allowedToStealElements={h1:this.allowedToStealElements.h1,h2:this.allowedToStealElements.h1,h3:this.allowedToStealElements.h1,h4:this.allowedToStealElements.h1,h5:this.allowedToStealElements.h1,h6:this.allowedToStealElements.h1,p:this.tagHierarchy.b}};GENTICS.Aloha.Selection.prototype.SelectionTree=function(){this.domobj=new Object();this.selection;this.children=new Array()};GENTICS.Aloha.Selection.prototype.onChange=function(objectClicked,event){if(this.updateSelectionTimeout){window.clearTimeout(this.updateSelectionTimeout);this.updateSelectionTimeout=undefined}this.updateSelectionTimeout=window.setTimeout(function(){GENTICS.Aloha.Selection.updateSelection(event)},5)};GENTICS.Aloha.Selection.prototype.updateSelection=function(event){var rangeObject=this.rangeObject=new GENTICS.Aloha.Selection.SelectionRange(true);rangeObject.update();GENTICS.Aloha.FloatingMenu.setScope("GENTICS.Aloha.continuoustext");GENTICS.Aloha.EventRegistry.trigger(new GENTICS.Aloha.Event("selectionChanged",GENTICS.Aloha,[rangeObject,event]));return true};GENTICS.Aloha.Selection.prototype.getSelectionTree=function(rangeObject){if(!rangeObject){return this.rangeObject.getSelectionTree()}if(!rangeObject.commonAncestorContainer){GENTICS.Aloha.Log.error(this,"the rangeObject is missing the commonAncestorContainer");return false}this.inselection=false;if(GENTICS.Utils.Dom.doCleanup({mergetext:true},rangeObject)){this.rangeObject.update();this.rangeObject.select()}return this.recursiveGetSelectionTree(rangeObject,rangeObject.commonAncestorContainer)};GENTICS.Aloha.Selection.prototype.recursiveGetSelectionTree=function(rangeObject,currentObject){var jQueryCurrentObject=jQuery(currentObject);var childCount=0;var that=this;var currentElements=new Array();jQueryCurrentObject.contents().each(function(index){var selectionType="none";var startOffset=false;var endOffset=false;var collapsedFound=false;if(rangeObject.isCollapsed()&&currentObject===rangeObject.startContainer&&rangeObject.startOffset==index){currentElements[childCount]=new GENTICS.Aloha.Selection.SelectionTree();currentElements[childCount].selection="collapsed";currentElements[childCount].domobj=undefined;that.inselection=false;collapsedFound=true;childCount++}if(!that.inselection&&!collapsedFound){switch(this.nodeType){case 3:if(this===rangeObject.startContainer){that.inselection=true;selectionType=rangeObject.startOffset>0?"partial":"full";startOffset=rangeObject.startOffset;endOffset=this.length}break;case 1:if(this===rangeObject.startContainer&&rangeObject.startOffset==0){that.inselection=true;selectionType="full"}if(currentObject===rangeObject.startContainer&&rangeObject.startOffset==index){that.inselection=true;selectionType="full"}break}}if(that.inselection&&!collapsedFound){if(selectionType=="none"){selectionType="full"}switch(this.nodeType){case 3:if(this===rangeObject.endContainer){that.inselection=false;if(rangeObject.endOffset<this.length){selectionType="partial"}if(startOffset===false){startOffset=0}endOffset=rangeObject.endOffset}break;case 1:if(this===rangeObject.endContainer&&rangeObject.endOffset==0){that.inselection=false}break}if(currentObject===rangeObject.endContainer&&rangeObject.endOffset<=index){that.inselection=false;selectionType="none"}}currentElements[childCount]=new GENTICS.Aloha.Selection.SelectionTree();currentElements[childCount].domobj=this;currentElements[childCount].selection=selectionType;if(selectionType=="partial"){currentElements[childCount].startOffset=startOffset;currentElements[childCount].endOffset=endOffset}currentElements[childCount].children=that.recursiveGetSelectionTree(rangeObject,this);if(currentElements[childCount].children.length>0){var noneFound=false;var partialFound=false;var fullFound=false;for(var i=0;i<currentElements[childCount].children.length;++i){switch(currentElements[childCount].children[i].selection){case"none":noneFound=true;break;case"full":fullFound=true;break;case"partial":partialFound=true;break}}if(partialFound||(fullFound&&noneFound)){currentElements[childCount].selection="partial"}else{if(fullFound&&!partialFound&&!noneFound){currentElements[childCount].selection="full"}}}childCount++});if(rangeObject.isCollapsed()&&currentObject===rangeObject.startContainer&&rangeObject.startOffset==currentObject.childNodes.length){currentElements[childCount]=new GENTICS.Aloha.Selection.SelectionTree();currentElements[childCount].selection="collapsed";currentElements[childCount].domobj=undefined}return currentElements};GENTICS.Aloha.Selection.prototype.getRangeObject=function(){return this.rangeObject};GENTICS.Aloha.Selection.prototype.isRangeObjectWithinMarkup=function(rangeObject,startOrEnd,markupObject,tagComparator,limitObject){domObj=!startOrEnd?rangeObject.startContainer:rangeObject.endContainer;if(typeof tagComparator!=="undefined"&&typeof tagComparator!=="function"){GENTICS.Aloha.Log.error(this,"parameter tagComparator is not a function")}var that=this;if(typeof tagComparator==="undefined"){tagComparator=function(domobj,markupObject){return that.standardTextLevelSemanticsComparator(domobj,markupObject)}}var parents=jQuery(domObj).parents();var returnVal=false;var i=-1;var that=this;if(parents.length>0){parents.each(function(){if(this===limitObject){GENTICS.Aloha.Log.debug(that,"reached limit dom obj");return false}if(tagComparator(this,markupObject)){if(returnVal===false){returnVal=new Array()}GENTICS.Aloha.Log.debug(that,"reached object equal to markup");i++;returnVal[i]=this;return true}})}return returnVal};GENTICS.Aloha.Selection.prototype.standardSectionsAndGroupingContentComparator=function(domobj,markupObject){if(domobj.nodeType===1){if(markupObject[0].tagName&&GENTICS.Aloha.Selection.replacingElements[domobj.tagName.toLowerCase()]&&GENTICS.Aloha.Selection.replacingElements[domobj.tagName.toLowerCase()].indexOf(markupObject[0].tagName.toLowerCase())!=-1){return true}}else{GENTICS.Aloha.Log.debug(this,"only element nodes (nodeType == 1) can be compared")}return false};GENTICS.Aloha.Selection.prototype.standardTextLevelSemanticsComparator=function(domobj,markupObject){if(domobj.nodeType===1){if(domobj.tagName.toLowerCase()!=markupObject[0].tagName.toLowerCase()){return false}if(!this.standardAttributesComparator(domobj,markupObject)){return false}return true}else{GENTICS.Aloha.Log.debug(this,"only element nodes (nodeType == 1) can be compared")}return false};GENTICS.Aloha.Selection.prototype.standardAttributesComparator=function(domobj,markupObject){if(domobj.attributes&&domobj.attributes.length&&domobj.attributes.length>0){for(var i=0;i<domobj.attributes.length;i++){var attr=domobj.attributes[i];if(attr.nodeName.toLowerCase()=="class"&&attr.nodeValue.length>0){var classString=attr.nodeValue;var classes=classString.split(" ")}}}if(markupObject[0].attributes&&markupObject[0].attributes.length&&markupObject[0].attributes.length>0){for(var i=0;i<markupObject[0].attributes.length;i++){var attr=markupObject[0].attributes[i];if(attr.nodeName.toLowerCase()=="class"&&attr.nodeValue.length>0){var classString=attr.nodeValue;var classes2=classString.split(" ")}}}if(classes&&!classes2||classes2&&!classes){GENTICS.Aloha.Log.debug(this,"tag comparison for <"+domobj.tagName.toLowerCase()+"> failed because one element has classes and the other has not");return false}if(classes&&classes2&&classes.length!=classes.length){GENTICS.Aloha.Log.debug(this,"tag comparison for <"+domobj.tagName.toLowerCase()+"> failed because of a different amount of classes");return false}if(classes&&classes2&&classes.length==classes2.length&&classes.length!=0){for(var i=0;i<classes.length;i++){if(!markupObject.hasClass(classes[i])){GENTICS.Aloha.Log.debug(this,"tag comparison for <"+domobj.tagName.toLowerCase()+"> failed because of different classes");return false}}}return true};GENTICS.Aloha.Selection.prototype.changeMarkup=function(rangeObject,markupObject,tagComparator){var tagName=markupObject[0].tagName.toLowerCase();if(this.replacingElements[tagName]){var backupRangeObject=rangeObject;rangeObject=new this.SelectionRange(rangeObject);if(GENTICS.Aloha.activeEditable){var newCAC=GENTICS.Aloha.activeEditable.obj.get(0)}else{var newCAC=document.body}rangeObject.update(newCAC);markupObject.isReplacingElement=true}else{if(rangeObject.isCollapsed()){GENTICS.Aloha.Log.debug(this,"early returning from applying markup because nothing is currently selected");return false}}if(GENTICS.Aloha.activeEditable){var limitObject=GENTICS.Aloha.activeEditable.obj[0]}else{var limitObject=document.body}var relevantMarkupObjectsAtSelectionStart=this.isRangeObjectWithinMarkup(rangeObject,false,markupObject,tagComparator,limitObject);var relevantMarkupObjectsAtSelectionEnd=this.isRangeObjectWithinMarkup(rangeObject,true,markupObject,tagComparator,limitObject);if(!markupObject.isReplacingElement&&rangeObject.startOffset==0){var prevSibling;if(prevSibling=this.getTextNodeSibling(false,rangeObject.commonAncestorContainer.parentNode,rangeObject.startContainer)){var relevantMarkupObjectBeforeSelection=this.isRangeObjectWithinMarkup({startContainer:prevSibling,startOffset:0},false,markupObject,tagComparator,limitObject)}}if(!markupObject.isReplacingElement&&(rangeObject.endOffset==rangeObject.endContainer.length)){var nextSibling;if(nextSibling=this.getTextNodeSibling(true,rangeObject.commonAncestorContainer.parentNode,rangeObject.endContainer)){var relevantMarkupObjectAfterSelection=this.isRangeObjectWithinMarkup({startContainer:nextSibling,startOffset:0},false,markupObject,tagComparator,limitObject)}}if(!markupObject.isReplacingElement&&(relevantMarkupObjectsAtSelectionStart&&!relevantMarkupObjectsAtSelectionEnd)){GENTICS.Aloha.Log.info(this,"markup 2 non-markup");this.prepareForRemoval(rangeObject.getSelectionTree(),markupObject,tagComparator);jQuery(relevantMarkupObjectsAtSelectionStart).addClass("preparedForRemoval");this.insertCroppedMarkups(relevantMarkupObjectsAtSelectionStart,rangeObject,false,tagComparator)}else{if(!markupObject.isReplacingElement&&relevantMarkupObjectsAtSelectionStart&&relevantMarkupObjectsAtSelectionEnd){GENTICS.Aloha.Log.info(this,"markup 2 markup");this.prepareForRemoval(rangeObject.getSelectionTree(),markupObject,tagComparator);this.splitRelevantMarkupObject(relevantMarkupObjectsAtSelectionStart,relevantMarkupObjectsAtSelectionEnd,rangeObject,tagComparator)}else{if(!markupObject.isReplacingElement&&((!relevantMarkupObjectsAtSelectionStart&&relevantMarkupObjectsAtSelectionEnd)||relevantMarkupObjectAfterSelection||relevantMarkupObjectBeforeSelection)){GENTICS.Aloha.Log.info(this,"non-markup 2 markup OR with next2markup");if(relevantMarkupObjectBeforeSelection&&relevantMarkupObjectAfterSelection){var extendedRangeObject=new GENTICS.Aloha.Selection.SelectionRange(rangeObject);extendedRangeObject.startContainer=jQuery(relevantMarkupObjectBeforeSelection[relevantMarkupObjectBeforeSelection.length-1]).textNodes()[0];extendedRangeObject.startOffset=0;extendedRangeObject.endContainer=jQuery(relevantMarkupObjectAfterSelection[relevantMarkupObjectAfterSelection.length-1]).textNodes().last()[0];extendedRangeObject.endOffset=extendedRangeObject.endContainer.length;extendedRangeObject.update();this.applyMarkup(extendedRangeObject.getSelectionTree(),rangeObject,markupObject,tagComparator);GENTICS.Aloha.Log.info(this,"double extending previous markup(previous and after selection), actually wrapping it ...")}else{if(relevantMarkupObjectBeforeSelection&&!relevantMarkupObjectAfterSelection&&!relevantMarkupObjectsAtSelectionEnd){this.extendExistingMarkupWithSelection(relevantMarkupObjectBeforeSelection,rangeObject,false,tagComparator);GENTICS.Aloha.Log.info(this,"extending previous markup")}else{if(relevantMarkupObjectBeforeSelection&&!relevantMarkupObjectAfterSelection&&relevantMarkupObjectsAtSelectionEnd){var extendedRangeObject=new GENTICS.Aloha.Selection.SelectionRange(rangeObject);extendedRangeObject.startContainer=jQuery(relevantMarkupObjectBeforeSelection[relevantMarkupObjectBeforeSelection.length-1]).textNodes()[0];extendedRangeObject.startOffset=0;extendedRangeObject.endContainer=jQuery(relevantMarkupObjectsAtSelectionEnd[relevantMarkupObjectsAtSelectionEnd.length-1]).textNodes().last()[0];extendedRangeObject.endOffset=extendedRangeObject.endContainer.length;extendedRangeObject.update();this.applyMarkup(extendedRangeObject.getSelectionTree(),rangeObject,markupObject,tagComparator);GENTICS.Aloha.Log.info(this,"double extending previous markup(previous and relevant at the end), actually wrapping it ...")}else{if(!relevantMarkupObjectBeforeSelection&&relevantMarkupObjectAfterSelection){this.extendExistingMarkupWithSelection(relevantMarkupObjectAfterSelection,rangeObject,true,tagComparator);GENTICS.Aloha.Log.info(this,"extending following markup backwards")}else{this.extendExistingMarkupWithSelection(relevantMarkupObjectsAtSelectionEnd,rangeObject,true,tagComparator)}}}}}else{if(markupObject.isReplacingElement||(!relevantMarkupObjectsAtSelectionStart&&!relevantMarkupObjectsAtSelectionEnd&&!relevantMarkupObjectBeforeSelection&&!relevantMarkupObjectAfterSelection)){GENTICS.Aloha.Log.info(this,"non-markup 2 non-markup");this.applyMarkup(rangeObject.getSelectionTree(),rangeObject,markupObject,tagComparator,{setRangeObject2NewMarkup:true})}}}}jQuery(".preparedForRemoval").zap();rangeObject.update();if(markupObject.isReplacingElement){backupRangeObject.select()}else{rangeObject.select()}};GENTICS.Aloha.Selection.prototype.areMarkupObjectsAsLongAsRangeObject=function(relevantMarkupObjectsAtSelectionStart,relevantMarkupObjectsAtSelectionEnd,rangeObject){if(rangeObject.startOffset!==0){return false}for(var i=0;i<relevantMarkupObjectsAtSelectionStart.length;i++){var el=relevantMarkupObjectsAtSelectionStart[i];if(jQuery(el).textNodes().first()[0]!==rangeObject.startContainer){return false}}for(var i=0;i<relevantMarkupObjectsAtSelectionEnd.length;i++){var el=relevantMarkupObjectsAtSelectionEnd[i];if(jQuery(el).textNodes().last()[0]!==rangeObject.endContainer||jQuery(el).textNodes().last()[0].length!=rangeObject.endOffset){return false}}return true};GENTICS.Aloha.Selection.prototype.splitRelevantMarkupObject=function(relevantMarkupObjectsAtSelectionStart,relevantMarkupObjectsAtSelectionEnd,rangeObject,tagComparator){jQuery(relevantMarkupObjectsAtSelectionStart).addClass("preparedForRemoval");jQuery(relevantMarkupObjectsAtSelectionEnd).addClass("preparedForRemoval");if(this.areMarkupObjectsAsLongAsRangeObject(relevantMarkupObjectsAtSelectionStart,relevantMarkupObjectsAtSelectionEnd,rangeObject)){return true}var relevantMarkupObjectAtSelectionStartAndEnd=this.intersectRelevantMarkupObjects(relevantMarkupObjectsAtSelectionStart,relevantMarkupObjectsAtSelectionEnd);if(relevantMarkupObjectAtSelectionStartAndEnd){this.insertCroppedMarkups([relevantMarkupObjectAtSelectionStartAndEnd],rangeObject,false,tagComparator);this.insertCroppedMarkups([relevantMarkupObjectAtSelectionStartAndEnd],rangeObject,true,tagComparator)}else{this.insertCroppedMarkups(relevantMarkupObjectsAtSelectionStart,rangeObject,false,tagComparator);this.insertCroppedMarkups(relevantMarkupObjectsAtSelectionEnd,rangeObject,true,tagComparator)}return true};GENTICS.Aloha.Selection.prototype.intersectRelevantMarkupObjects=function(relevantMarkupObjectsAtSelectionStart,relevantMarkupObjectsAtSelectionEnd){var intersection=false;if(!relevantMarkupObjectsAtSelectionStart||!relevantMarkupObjectsAtSelectionEnd){return intersection}for(var i=0;i<relevantMarkupObjectsAtSelectionStart.length;i++){var elStart=relevantMarkupObjectsAtSelectionStart[i];for(var j=0;j<relevantMarkupObjectsAtSelectionEnd.length;j++){var elEnd=relevantMarkupObjectsAtSelectionEnd[j];if(elStart===elEnd){intersection=elStart}}}return intersection};GENTICS.Aloha.Selection.prototype.extendExistingMarkupWithSelection=function(relevantMarkupObjects,rangeObject,startOrEnd,tagComparator){if(!startOrEnd){var extendMarkupsAtStart=true}if(startOrEnd){var extendMarkupsAtEnd=true}var objects=[];for(var i=0;i<relevantMarkupObjects.length;i++){objects[i]=new this.SelectionRange();el=relevantMarkupObjects[i];if(extendMarkupsAtEnd&&!extendMarkupsAtStart){objects[i].startContainer=rangeObject.startContainer;objects[i].startOffset=rangeObject.startOffset;textnodes=jQuery(el).textNodes(true);objects[i].endContainer=textnodes[textnodes.length-1];objects[i].endOffset=textnodes[textnodes.length-1].length;objects[i].update();this.applyMarkup(objects[i].getSelectionTree(),rangeObject,this.getClonedMarkup4Wrapping(el),tagComparator,{setRangeObject2NewMarkup:true})}if(!extendMarkupsAtEnd&&extendMarkupsAtStart){textnodes=jQuery(el).textNodes(true);objects[i].startContainer=textnodes[0];objects[i].startOffset=0;objects[i].endContainer=rangeObject.endContainer;objects[i].endOffset=rangeObject.endOffset;objects[i].update();this.applyMarkup(objects[i].getSelectionTree(),rangeObject,this.getClonedMarkup4Wrapping(el),tagComparator,{setRangeObject2NewMarkup:true})}}return true};GENTICS.Aloha.Selection.prototype.getClonedMarkup4Wrapping=function(domobj){var wrapper=jQuery(domobj).clone().removeClass("preparedForRemoval").empty();if(wrapper.attr("class").length==0){wrapper.removeAttr("class")}return wrapper};GENTICS.Aloha.Selection.prototype.insertCroppedMarkups=function(relevantMarkupObjects,rangeObject,startOrEnd,tagComparator){if(!startOrEnd){var cropMarkupsAtEnd=true}if(startOrEnd){var cropMarkupsAtStart=true}var objects=[];for(var i=0;i<relevantMarkupObjects.length;i++){objects[i]=new this.SelectionRange();var el=relevantMarkupObjects[i];if(cropMarkupsAtEnd&&!cropMarkupsAtStart){var textNodes=jQuery(el).textNodes(true);objects[i].startContainer=textNodes[0];objects[i].startOffset=0;if(objects[i].startContainer===rangeObject.startContainer&&objects[i].startOffset===rangeObject.startOffset){continue}if(rangeObject.startOffset==0){objects[i].endContainer=this.getTextNodeSibling(false,el,rangeObject.startContainer);objects[i].endOffset=objects[i].endContainer.length}else{objects[i].endContainer=rangeObject.startContainer;objects[i].endOffset=rangeObject.startOffset}objects[i].update();this.applyMarkup(objects[i].getSelectionTree(),rangeObject,this.getClonedMarkup4Wrapping(el),tagComparator,{setRangeObject2NextSibling:true})}if(!cropMarkupsAtEnd&&cropMarkupsAtStart){objects[i].startContainer=rangeObject.endContainer;objects[i].startOffset=rangeObject.endOffset;textnodes=jQuery(el).textNodes(true);objects[i].endContainer=textnodes[textnodes.length-1];objects[i].endOffset=textnodes[textnodes.length-1].length;objects[i].update();this.applyMarkup(objects[i].getSelectionTree(),rangeObject,this.getClonedMarkup4Wrapping(el),tagComparator,{setRangeObject2PreviousSibling:true})}}return true};GENTICS.Aloha.Selection.prototype.changeMarkupOnSelection=function(markupObject){this.changeMarkup(this.getRangeObject(),markupObject,this.getStandardTagComparator(markupObject));GENTICS.Utils.Dom.doCleanup({mergetext:true},this.rangeObject);this.rangeObject.update();this.rangeObject.select()};GENTICS.Aloha.Selection.prototype.applyMarkup=function(selectionTree,rangeObject,markupObject,tagComparator,options){options=options?options:new Object();this.prepareForRemoval(selectionTree,markupObject,tagComparator);var optimizedSelectionTree=this.optimizeSelectionTree4Markup(selectionTree,markupObject,tagComparator);breakpoint=true;for(var i=0;i<optimizedSelectionTree.length;i++){var el=optimizedSelectionTree[i];if(el.wrappable){this.wrapMarkupAroundSelectionTree(el.elements,rangeObject,markupObject,tagComparator,options)}else{GENTICS.Aloha.Log.debug(this,"dive further into non-wrappable object");this.applyMarkup(el.element.children,rangeObject,markupObject,tagComparator,options)}}};GENTICS.Aloha.Selection.prototype.getMarkupType=function(markupObject){var nn=jQuery(markupObject)[0].nodeName.toLowerCase();if(markupObject.outerHTML){GENTICS.Aloha.Log.debug(this,"Node name detected: "+nn+" for: "+markupObject.outerHTML())}if(nn=="#text"){return"textNode"}if(this.replacingElements[nn]){return"sectionOrGroupingContent"}if(this.tagHierarchy[nn]){return"textLevelSemantics"}GENTICS.Aloha.Log.warn(this,"unknown markup passed to this.getMarkupType(...): "+markupObject.outerHTML())};GENTICS.Aloha.Selection.prototype.getStandardTagComparator=function(markupObject){var that=this;switch(this.getMarkupType(markupObject)){case"textNode":return function(p1,p2){return false};break;case"sectionOrGroupingContent":return function(domobj,markupObject){return that.standardSectionsAndGroupingContentComparator(domobj,markupObject)};break;case"textLevelSemantics":default:return function(domobj,markupObject){return that.standardTextLevelSemanticsComparator(domobj,markupObject)}}};GENTICS.Aloha.Selection.prototype.prepareForRemoval=function(selectionTree,markupObject,tagComparator){var that=this;if(typeof tagComparator!=="undefined"&&typeof tagComparator!=="function"){GENTICS.Aloha.Log.error(this,"parameter tagComparator is not a function")}if(typeof tagComparator==="undefined"){tagComparator=this.getStandardTagComparator(markupObject)}for(var i=0;i<selectionTree.length;i++){var el=selectionTree[i];if(el.domobj&&(el.selection=="full"||(el.selection=="partial"&&markupObject.isReplacingElement))){if(el.domobj.nodeType===1&&tagComparator(el.domobj,markupObject)){GENTICS.Aloha.Log.debug(this,"Marking for removal: "+el.domobj.nodeName);jQuery(el.domobj).addClass("preparedForRemoval")}}if(el.selection!="none"&&el.children.length>0){this.prepareForRemoval(el.children,markupObject,tagComparator)}}};GENTICS.Aloha.Selection.prototype.wrapMarkupAroundSelectionTree=function(selectionTree,rangeObject,markupObject,tagComparator,options){var objects2wrap=new Array;var j=-1;GENTICS.Aloha.Log.debug(this,"The formatting <"+markupObject[0].tagName+"> will be wrapped around the selection");var preText="";var postText="";for(var i=0;i<selectionTree.length;i++){var el=selectionTree[i];if(el.domobj&&!this.canTag1WrapTag2(el.domobj.parentNode.tagName.toLowerCase(),markupObject[0].tagName.toLowerCase())){GENTICS.Aloha.Log.info(this,"Skipping the wrapping of <"+markupObject[0].tagName.toLowerCase()+"> because this tag is not allowed inside <"+el.domobj.parentNode.tagName.toLowerCase()+">");continue}if(el.domobj&&el.domobj.nodeType==3&&jQuery.trim(jQuery(el.domobj).outerHTML()).length==0){continue}if(el.domobj&&el.selection=="partial"&&!markupObject.isReplacingElement){if(el.startOffset!==undefined&&el.endOffset===undefined){j++;preText+=el.domobj.data.substr(0,el.startOffset);el.domobj.data=el.domobj.data.substr(el.startOffset,el.domobj.data.length-el.startOffset);objects2wrap[j]=el.domobj}else{if(el.endOffset!==undefined&&el.startOffset===undefined){j++;postText+=el.domobj.data.substr(el.endOffset,el.domobj.data.length-el.endOffset);el.domobj.data=el.domobj.data.substr(0,el.endOffset);objects2wrap[j]=el.domobj}else{if(el.endOffset!==undefined&&el.startOffset!==undefined){if(el.startOffset==el.endOffset){GENTICS.Aloha.Log.debug(this,"skipping empty selection");continue}j++;preText+=el.domobj.data.substr(0,el.startOffset);var middleText=el.domobj.data.substr(el.startOffset,el.endOffset-el.startOffset);postText+=el.domobj.data.substr(el.endOffset,el.domobj.data.length-el.endOffset);el.domobj.data=middleText;objects2wrap[j]=el.domobj}else{GENTICS.Aloha.Log.debug(this,"diving into object");this.applyMarkup(el.children,rangeObject,markupObject,tagComparator,options)}}}}if(el.domobj&&(el.selection=="full"||(el.selection=="partial"&&markupObject.isReplacingElement))){j++;objects2wrap[j]=el.domobj}}breakpoint=true;if(objects2wrap.length>0){objects2wrap=jQuery(objects2wrap);jQuery.each(objects2wrap,function(index,element){if(jQuery.browser.msie&&element.nodeType==3&&!element.nextSibling&&!element.previousSibling&&element.parentNode&&element.parentNode.nodeName.toLowerCase()=="li"){element.data=jQuery.trim(element.data)}});var newMarkup=objects2wrap.wrapAll(markupObject).parent();newMarkup.before(preText).after(postText);var breakpoint=true;if(options.setRangeObject2NewMarkup){var textnodes=objects2wrap.textNodes();if(textnodes.index(rangeObject.startContainer)!=-1){rangeObject.startOffset=0}if(textnodes.index(rangeObject.endContainer)!=-1){rangeObject.endOffset=rangeObject.endContainer.length}var breakpoint=true}if(options.setRangeObject2NextSibling){var prevOrNext=true;var textNode2Start=newMarkup.textNodes(true).last()[0];if(objects2wrap.index(rangeObject.startContainer)!=-1){rangeObject.startContainer=this.getTextNodeSibling(prevOrNext,newMarkup.parent(),textNode2Start);rangeObject.startOffset=0}if(objects2wrap.index(rangeObject.endContainer)!=-1){rangeObject.endContainer=this.getTextNodeSibling(prevOrNext,newMarkup.parent(),textNode2Start);rangeObject.endOffset=rangeObject.endOffset-textNode2Start.length}}if(options.setRangeObject2PreviousSibling){var prevOrNext=false;var textNode2Start=newMarkup.textNodes(true).first()[0];if(objects2wrap.index(rangeObject.startContainer)!=-1){rangeObject.startContainer=this.getTextNodeSibling(prevOrNext,newMarkup.parent(),textNode2Start);rangeObject.startOffset=0}if(objects2wrap.index(rangeObject.endContainer)!=-1){rangeObject.endContainer=this.getTextNodeSibling(prevOrNext,newMarkup.parent(),textNode2Start);rangeObject.endOffset=rangeObject.endContainer.length}}}};GENTICS.Aloha.Selection.prototype.getTextNodeSibling=function(previousOrNext,commonAncestorContainer,currentTextNode){var textNodes=jQuery(commonAncestorContainer).textNodes(true);index=textNodes.index(currentTextNode);if(index==-1){return false}var newIndex=index+(!previousOrNext?-1:1);return textNodes[newIndex]?textNodes[newIndex]:false};GENTICS.Aloha.Selection.prototype.optimizeSelectionTree4Markup=function(selectionTree,markupObject,tagComparator){var groupMap=[];var outerGroupIndex=0;var innerGroupIndex=0;var that=this;if(typeof tagComparator==="undefined"){tagComparator=function(domobj,markupObject){return that.standardTextLevelSemanticsComparator(markupObject)}}for(var i=0;i<selectionTree.length;i++){if(selectionTree[i].domobj&&selectionTree[i].selection!="none"){if(markupObject.isReplacingElement&&tagComparator(markupObject[0],jQuery(selectionTree[i].domobj))){if(groupMap[outerGroupIndex]!==undefined){outerGroupIndex++}groupMap[outerGroupIndex]=new Object();groupMap[outerGroupIndex].wrappable=true;groupMap[outerGroupIndex].elements=new Array();groupMap[outerGroupIndex].elements[innerGroupIndex]=selectionTree[i];outerGroupIndex++}else{if(this.canMarkupBeApplied2ElementAsWhole([selectionTree[i]],markupObject)){if(groupMap[outerGroupIndex]===undefined){groupMap[outerGroupIndex]=new Object();groupMap[outerGroupIndex].wrappable=true;groupMap[outerGroupIndex].elements=new Array()}if(markupObject.isReplacingElement){var startPosition=i;for(var j=i-1;j>=0;j--){if(this.canMarkupBeApplied2ElementAsWhole([selectionTree[j]],markupObject)&&this.isMarkupAllowedToStealSelectionTreeElement(selectionTree[j],markupObject)){startPosition=j}else{break}}var endPosition=i;for(var j=i+1;j<selectionTree.length;j++){if(this.canMarkupBeApplied2ElementAsWhole([selectionTree[j]],markupObject)&&this.isMarkupAllowedToStealSelectionTreeElement(selectionTree[j],markupObject)){endPosition=j}else{break}}innerGroupIndex=0;for(var j=startPosition;j<=endPosition;j++){groupMap[outerGroupIndex].elements[innerGroupIndex]=selectionTree[j];groupMap[outerGroupIndex].elements[innerGroupIndex].selection="full";innerGroupIndex++}innerGroupIndex=0}else{groupMap[outerGroupIndex].elements[innerGroupIndex]=selectionTree[i];innerGroupIndex++}}else{if(groupMap[outerGroupIndex]!==undefined){outerGroupIndex++}groupMap[outerGroupIndex]=new Object();groupMap[outerGroupIndex].wrappable=false;groupMap[outerGroupIndex].element=selectionTree[i];innerGroupIndex=0;outerGroupIndex++}}}}return groupMap};GENTICS.Aloha.Selection.prototype.isMarkupAllowedToStealSelectionTreeElement=function(selectionTreeElement,markupObject){if(!selectionTreeElement.domobj){return false}var nodeName=selectionTreeElement.domobj.nodeName.toLowerCase();nodeName=(nodeName=="#text")?"textNode":nodeName;var markupName=markupObject[0].nodeName.toLowerCase();if(!this.allowedToStealElements[markupName]){return false}if(this.allowedToStealElements[markupName].indexOf(nodeName)==-1){return false}return true};GENTICS.Aloha.Selection.prototype.canMarkupBeApplied2ElementAsWhole=function(selectionTree,markupObject){if(markupObject.jquery){htmlTag=markupObject[0].tagName}if(markupObject.tagName){htmlTag=markupObject.tagName}returnVal=true;for(var i=0;i<selectionTree.length;i++){var el=selectionTree[i];if(el.domobj&&(el.selection!="none"||markupObject.isReplacingElement)){if(!this.canTag1WrapTag2(htmlTag,el.domobj.nodeName)){return false}if(el.children.length>0&&!this.canMarkupBeApplied2ElementAsWhole(el.children,markupObject)){return false}}}return returnVal};GENTICS.Aloha.Selection.prototype.canTag1WrapTag2=function(t1,t2){t1=(t1=="#text")?"textNode":t1.toLowerCase();t2=(t2=="#text")?"textNode":t2.toLowerCase();if(!this.tagHierarchy[t1]){return true}if(!this.tagHierarchy[t2]){return true}var t1Array=this.tagHierarchy[t1];var returnVal=(t1Array.indexOf(t2)!=-1)?true:false;return returnVal};GENTICS.Aloha.Selection.prototype.mayInsertTag=function(tagName){if(typeof this.rangeObject.unmodifiableMarkupAtStart=="object"){for(var i=0;i<this.rangeObject.unmodifiableMarkupAtStart.length;++i){if(!this.canTag1WrapTag2(this.rangeObject.unmodifiableMarkupAtStart[i].nodeName,tagName)){return false}}return true}else{GENTICS.Aloha.Log.warn(this,"Unable to determine whether tag "+tagName+" may be inserted");return true}};GENTICS.Aloha.Selection.prototype.toString=function(){return"GENTICS.Aloha.Selection"};GENTICS.Aloha.Selection.prototype.SelectionRange=function(rangeObject){GENTICS.Utils.RangeObject.apply(this,arguments);this.commonAncestorContainer;this.selectionTree;this.markupEffectiveAtStart=[];this.unmodifiableMarkupAtStart=[];this.limitObject;this.splitObject;if(rangeObject){if(rangeObject.commonAncestorContainer){this.commonAncestorContainer=rangeObject.commonAncestorContainer}if(rangeObject.selectionTree){this.selectionTree=rangeObject.selectionTree}if(rangeObject.limitObject){this.limitObject=rangeObject.limitObject}if(rangeObject.markupEffectiveAtStart){this.markupEffectiveAtStart=rangeObject.markupEffectiveAtStart}if(rangeObject.unmodifiableMarkupAtStart){this.unmodifiableMarkupAtStart=rangeObject.unmodifiableMarkupAtStart}if(rangeObject.splitObject){this.splitObject=rangeObject.splitObject}}};GENTICS.Aloha.Selection.prototype.SelectionRange.prototype=new GENTICS.Utils.RangeObject();GENTICS.Aloha.Selection.prototype.SelectionRange.prototype.select=function(){GENTICS.Utils.RangeObject.prototype.select.apply(this,arguments);GENTICS.Aloha.Selection.updateSelection()};GENTICS.Aloha.Selection.prototype.SelectionRange.prototype.update=function(commonAncestorContainer){this.updatelimitObject();this.updateMarkupEffectiveAtStart();this.updateCommonAncestorContainer(commonAncestorContainer);this.selectionTree=undefined};GENTICS.Aloha.Selection.prototype.SelectionRange.prototype.getSelectionTree=function(){if(!this.selectionTree){this.selectionTree=GENTICS.Aloha.Selection.getSelectionTree(this)}return this.selectionTree};GENTICS.Aloha.Selection.prototype.SelectionRange.prototype.getSelectedSiblings=function(domobj){var selectionTree=this.getSelectionTree();return this.recursionGetSelectedSiblings(domobj,selectionTree)};GENTICS.Aloha.Selection.prototype.SelectionRange.prototype.recursionGetSelectedSiblings=function(domobj,selectionTree){var selectedSiblings=false;var foundObj=false;for(var i=0;i<selectionTree.length;++i){if(selectionTree[i].domobj===domobj){foundObj=true;selectedSiblings=[]}else{if(!foundObj&&selectionTree[i].children){selectedSiblings=this.recursionGetSelectedSiblings(domobj,selectionTree[i].children);if(selectedSiblings!==false){break}}else{if(foundObj&&selectionTree[i].domobj&&selectionTree[i].selection!="collapsed"&&selectionTree[i].selection!="none"){selectedSiblings.push(selectionTree[i].domobj)}else{if(foundObj&&selectionTree[i].selection=="none"){break}}}}}return selectedSiblings};GENTICS.Aloha.Selection.prototype.SelectionRange.prototype.updateMarkupEffectiveAtStart=function(){this.markupEffectiveAtStart=[];this.unmodifiableMarkupAtStart=[];var parents=this.getStartContainerParents();var limitFound=false;for(var i=0;i<parents.length;i++){var el=parents[i];if(!limitFound&&(el!==this.limitObject)){this.markupEffectiveAtStart[i]=el;if(!splitObjectWasSet&&GENTICS.Utils.Dom.isSplitObject(el)){var splitObjectWasSet=true;this.splitObject=el}}else{limitFound=true;this.unmodifiableMarkupAtStart.push(el)}}if(!splitObjectWasSet){this.splitObject=false}return};GENTICS.Aloha.Selection.prototype.SelectionRange.prototype.updatelimitObject=function(){if(GENTICS.Aloha.editables&&GENTICS.Aloha.editables.length>0){var parents=jQuery(this.startContainer).parents();var editables=GENTICS.Aloha.editables;for(var i=0;i<parents.length;i++){var el=parents[i];for(var j=0;j<editables.length;j++){var editable=editables[j].obj[0];if(el===editable){this.limitObject=el;return true}}}}this.limitObject=document.body;return true};GENTICS.Aloha.Selection.prototype.SelectionRange.prototype.toString=function(verbose){if(!verbose){return"GENTICS.Aloha.Selection.SelectionRange"}return"GENTICS.Aloha.Selection.SelectionRange {start ["+this.startContainer.nodeValue+"] offset "+this.startOffset+", end ["+this.endContainer.nodeValue+"] offset "+this.endOffset+"}"};GENTICS.Aloha.Selection=new GENTICS.Aloha.Selection();
168
+ jQuery.fn.zap=function(){return this.each(function(){jQuery(this.childNodes).insertBefore(this)}).remove()};jQuery.fn.textNodes=function(excludeBreaks,includeEmptyTextNodes){var ret=[];(function(el){if((el.nodeType==3&&jQuery.trim(el.data)!=""&&!includeEmptyTextNodes)||(el.nodeType==3&&includeEmptyTextNodes)||(el.nodeName=="BR"&&!excludeBreaks)){ret.push(el)}else{for(var i=0;i<el.childNodes.length;++i){arguments.callee(el.childNodes[i])}}})(this[0]);return jQuery(ret)};GENTICS.Aloha.Selection=function(){this.rangeObject={};this.tagHierarchy={textNode:[],abbr:["textNode"],b:["textNode","b","i","em","sup","sub","br","span","img","a","del","ins","u","cite","q","code","abbr","strong"],pre:["textNode","b","i","em","sup","sub","br","span","img","a","del","ins","u","cite","q","code","abbr","code"],blockquote:["textNode","b","i","em","sup","sub","br","span","img","a","del","ins","u","cite","q","code","abbr","p","h1","h2","h3","h4","h5","h6"],ins:["textNode","b","i","em","sup","sub","br","span","img","a","u","p","h1","h2","h3","h4","h5","h6"],ul:["li"],ol:["li"],li:["textNode","b","i","em","sup","sub","br","span","img","ul","ol","h1","h2","h3","h4","h5","h6","del","ins","u"],tr:["td","th"],table:["tr"],div:["textNode","b","i","em","sup","sub","br","span","img","ul","ol","table","h1","h2","h3","h4","h5","h6","del","ins","u","p","div","pre","blockquote"],h1:["textNode","b","i","em","sup","sub","br","span","img","a","del","ins","u"]};this.tagHierarchy={textNode:this.tagHierarchy.textNode,abbr:this.tagHierarchy.abbr,br:this.tagHierarchy.textNode,img:this.tagHierarchy.textNode,b:this.tagHierarchy.b,strong:this.tagHierarchy.b,code:this.tagHierarchy.b,q:this.tagHierarchy.b,blockquote:this.tagHierarchy.blockquote,cite:this.tagHierarchy.b,i:this.tagHierarchy.b,em:this.tagHierarchy.b,sup:this.tagHierarchy.b,sub:this.tagHierarchy.b,span:this.tagHierarchy.b,del:this.tagHierarchy.del,ins:this.tagHierarchy.ins,u:this.tagHierarchy.b,p:this.tagHierarchy.b,pre:this.tagHierarchy.pre,a:this.tagHierarchy.b,ul:this.tagHierarchy.ul,ol:this.tagHierarchy.ol,li:this.tagHierarchy.li,td:this.tagHierarchy.li,div:this.tagHierarchy.div,h1:this.tagHierarchy.h1,h2:this.tagHierarchy.h1,h3:this.tagHierarchy.h1,h4:this.tagHierarchy.h1,h5:this.tagHierarchy.h1,h6:this.tagHierarchy.h1,table:this.tagHierarchy.table};this.replacingElements={h1:["p","h1","h2","h3","h4","h5","h6","pre"],blockquote:["blockquote"]};this.replacingElements={h1:this.replacingElements.h1,h2:this.replacingElements.h1,h3:this.replacingElements.h1,h4:this.replacingElements.h1,h5:this.replacingElements.h1,h6:this.replacingElements.h1,pre:this.replacingElements.h1,p:this.replacingElements.h1,blockquote:this.replacingElements.blockquote};this.allowedToStealElements={h1:["textNode"]};this.allowedToStealElements={h1:this.allowedToStealElements.h1,h2:this.allowedToStealElements.h1,h3:this.allowedToStealElements.h1,h4:this.allowedToStealElements.h1,h5:this.allowedToStealElements.h1,h6:this.allowedToStealElements.h1,p:this.tagHierarchy.b}};GENTICS.Aloha.Selection.prototype.SelectionTree=function(){this.domobj={};this.selection;this.children=[]};GENTICS.Aloha.Selection.prototype.onChange=function(objectClicked,event){if(this.updateSelectionTimeout){window.clearTimeout(this.updateSelectionTimeout);this.updateSelectionTimeout=undefined}this.updateSelectionTimeout=window.setTimeout(function(){GENTICS.Aloha.Selection.updateSelection(event)},5)};GENTICS.Aloha.Selection.prototype.updateSelection=function(event){var rangeObject=this.rangeObject=new GENTICS.Aloha.Selection.SelectionRange(true);rangeObject.update();GENTICS.Aloha.FloatingMenu.setScope("GENTICS.Aloha.continuoustext");GENTICS.Aloha.EventRegistry.trigger(new GENTICS.Aloha.Event("selectionChanged",GENTICS.Aloha,[rangeObject,event]));return true};GENTICS.Aloha.Selection.prototype.getSelectionTree=function(rangeObject){if(!rangeObject){return this.rangeObject.getSelectionTree()}if(!rangeObject.commonAncestorContainer){GENTICS.Aloha.Log.error(this,"the rangeObject is missing the commonAncestorContainer");return false}this.inselection=false;if(GENTICS.Utils.Dom.doCleanup({mergetext:true},rangeObject)){this.rangeObject.update();this.rangeObject.select()}return this.recursiveGetSelectionTree(rangeObject,rangeObject.commonAncestorContainer)};GENTICS.Aloha.Selection.prototype.recursiveGetSelectionTree=function(rangeObject,currentObject){var jQueryCurrentObject=jQuery(currentObject);var childCount=0;var that=this;var currentElements=[];jQueryCurrentObject.contents().each(function(index){var selectionType="none";var startOffset=false;var endOffset=false;var collapsedFound=false;if(rangeObject.isCollapsed()&&currentObject===rangeObject.startContainer&&rangeObject.startOffset==index){currentElements[childCount]=new GENTICS.Aloha.Selection.SelectionTree();currentElements[childCount].selection="collapsed";currentElements[childCount].domobj=undefined;that.inselection=false;collapsedFound=true;childCount++}if(!that.inselection&&!collapsedFound){switch(this.nodeType){case 3:if(this===rangeObject.startContainer){that.inselection=true;selectionType=rangeObject.startOffset>0?"partial":"full";startOffset=rangeObject.startOffset;endOffset=this.length}break;case 1:if(this===rangeObject.startContainer&&rangeObject.startOffset==0){that.inselection=true;selectionType="full"}if(currentObject===rangeObject.startContainer&&rangeObject.startOffset==index){that.inselection=true;selectionType="full"}break}}if(that.inselection&&!collapsedFound){if(selectionType=="none"){selectionType="full"}switch(this.nodeType){case 3:if(this===rangeObject.endContainer){that.inselection=false;if(rangeObject.endOffset<this.length){selectionType="partial"}if(startOffset===false){startOffset=0}endOffset=rangeObject.endOffset}break;case 1:if(this===rangeObject.endContainer&&rangeObject.endOffset==0){that.inselection=false}break}if(currentObject===rangeObject.endContainer&&rangeObject.endOffset<=index){that.inselection=false;selectionType="none"}}currentElements[childCount]=new GENTICS.Aloha.Selection.SelectionTree();currentElements[childCount].domobj=this;currentElements[childCount].selection=selectionType;if(selectionType=="partial"){currentElements[childCount].startOffset=startOffset;currentElements[childCount].endOffset=endOffset}currentElements[childCount].children=that.recursiveGetSelectionTree(rangeObject,this);if(currentElements[childCount].children.length>0){var noneFound=false;var partialFound=false;var fullFound=false;for(var i=0;i<currentElements[childCount].children.length;++i){switch(currentElements[childCount].children[i].selection){case"none":noneFound=true;break;case"full":fullFound=true;break;case"partial":partialFound=true;break}}if(partialFound||(fullFound&&noneFound)){currentElements[childCount].selection="partial"}else{if(fullFound&&!partialFound&&!noneFound){currentElements[childCount].selection="full"}}}childCount++});if(rangeObject.isCollapsed()&&currentObject===rangeObject.startContainer&&rangeObject.startOffset==currentObject.childNodes.length){currentElements[childCount]=new GENTICS.Aloha.Selection.SelectionTree();currentElements[childCount].selection="collapsed";currentElements[childCount].domobj=undefined}return currentElements};GENTICS.Aloha.Selection.prototype.getRangeObject=function(){return this.rangeObject};GENTICS.Aloha.Selection.prototype.isRangeObjectWithinMarkup=function(rangeObject,startOrEnd,markupObject,tagComparator,limitObject){domObj=!startOrEnd?rangeObject.startContainer:rangeObject.endContainer;if(typeof tagComparator!=="undefined"&&typeof tagComparator!=="function"){GENTICS.Aloha.Log.error(this,"parameter tagComparator is not a function")}var that=this;if(typeof tagComparator==="undefined"){tagComparator=function(domobj,markupObject){return that.standardTextLevelSemanticsComparator(domobj,markupObject)}}var parents=jQuery(domObj).parents();var returnVal=false;var i=-1;var that=this;if(parents.length>0){parents.each(function(){if(this===limitObject){GENTICS.Aloha.Log.debug(that,"reached limit dom obj");return false}if(tagComparator(this,markupObject)){if(returnVal===false){returnVal=[]}GENTICS.Aloha.Log.debug(that,"reached object equal to markup");i++;returnVal[i]=this;return true}})}return returnVal};GENTICS.Aloha.Selection.prototype.standardSectionsAndGroupingContentComparator=function(domobj,markupObject){if(domobj.nodeType===1){if(markupObject[0].tagName&&GENTICS.Aloha.Selection.replacingElements[domobj.tagName.toLowerCase()]&&GENTICS.Aloha.Selection.replacingElements[domobj.tagName.toLowerCase()].indexOf(markupObject[0].tagName.toLowerCase())!=-1){return true}}else{GENTICS.Aloha.Log.debug(this,"only element nodes (nodeType == 1) can be compared")}return false};GENTICS.Aloha.Selection.prototype.standardTextLevelSemanticsComparator=function(domobj,markupObject){if(domobj.nodeType===1){if(domobj.tagName.toLowerCase()!=markupObject[0].tagName.toLowerCase()){return false}if(!this.standardAttributesComparator(domobj,markupObject)){return false}return true}else{GENTICS.Aloha.Log.debug(this,"only element nodes (nodeType == 1) can be compared")}return false};GENTICS.Aloha.Selection.prototype.standardAttributesComparator=function(domobj,markupObject){if(domobj.attributes&&domobj.attributes.length&&domobj.attributes.length>0){for(var i=0;i<domobj.attributes.length;i++){var attr=domobj.attributes[i];if(attr.nodeName.toLowerCase()=="class"&&attr.nodeValue.length>0){var classString=attr.nodeValue;var classes=classString.split(" ")}}}if(markupObject[0].attributes&&markupObject[0].attributes.length&&markupObject[0].attributes.length>0){for(var i=0;i<markupObject[0].attributes.length;i++){var attr=markupObject[0].attributes[i];if(attr.nodeName.toLowerCase()=="class"&&attr.nodeValue.length>0){var classString=attr.nodeValue;var classes2=classString.split(" ")}}}if(classes&&!classes2||classes2&&!classes){GENTICS.Aloha.Log.debug(this,"tag comparison for <"+domobj.tagName.toLowerCase()+"> failed because one element has classes and the other has not");return false}if(classes&&classes2&&classes.length!=classes.length){GENTICS.Aloha.Log.debug(this,"tag comparison for <"+domobj.tagName.toLowerCase()+"> failed because of a different amount of classes");return false}if(classes&&classes2&&classes.length==classes2.length&&classes.length!=0){for(var i=0;i<classes.length;i++){if(!markupObject.hasClass(classes[i])){GENTICS.Aloha.Log.debug(this,"tag comparison for <"+domobj.tagName.toLowerCase()+"> failed because of different classes");return false}}}return true};GENTICS.Aloha.Selection.prototype.changeMarkup=function(rangeObject,markupObject,tagComparator){var tagName=markupObject[0].tagName.toLowerCase();if(this.replacingElements[tagName]){var backupRangeObject=rangeObject;rangeObject=new this.SelectionRange(rangeObject);if(GENTICS.Aloha.activeEditable){var newCAC=GENTICS.Aloha.activeEditable.obj.get(0)}else{var newCAC=jQuery("body")}rangeObject.update(newCAC);markupObject.isReplacingElement=true}else{if(rangeObject.isCollapsed()){GENTICS.Aloha.Log.debug(this,"early returning from applying markup because nothing is currently selected");return false}}if(GENTICS.Aloha.activeEditable){var limitObject=GENTICS.Aloha.activeEditable.obj[0]}else{var limitObject=jQuery("body")}var relevantMarkupObjectsAtSelectionStart=this.isRangeObjectWithinMarkup(rangeObject,false,markupObject,tagComparator,limitObject);var relevantMarkupObjectsAtSelectionEnd=this.isRangeObjectWithinMarkup(rangeObject,true,markupObject,tagComparator,limitObject);if(!markupObject.isReplacingElement&&rangeObject.startOffset==0){var prevSibling;if(prevSibling=this.getTextNodeSibling(false,rangeObject.commonAncestorContainer.parentNode,rangeObject.startContainer)){var relevantMarkupObjectBeforeSelection=this.isRangeObjectWithinMarkup({startContainer:prevSibling,startOffset:0},false,markupObject,tagComparator,limitObject)}}if(!markupObject.isReplacingElement&&(rangeObject.endOffset==rangeObject.endContainer.length)){var nextSibling;if(nextSibling=this.getTextNodeSibling(true,rangeObject.commonAncestorContainer.parentNode,rangeObject.endContainer)){var relevantMarkupObjectAfterSelection=this.isRangeObjectWithinMarkup({startContainer:nextSibling,startOffset:0},false,markupObject,tagComparator,limitObject)}}if(!markupObject.isReplacingElement&&(relevantMarkupObjectsAtSelectionStart&&!relevantMarkupObjectsAtSelectionEnd)){GENTICS.Aloha.Log.info(this,"markup 2 non-markup");this.prepareForRemoval(rangeObject.getSelectionTree(),markupObject,tagComparator);jQuery(relevantMarkupObjectsAtSelectionStart).addClass("preparedForRemoval");this.insertCroppedMarkups(relevantMarkupObjectsAtSelectionStart,rangeObject,false,tagComparator)}else{if(!markupObject.isReplacingElement&&relevantMarkupObjectsAtSelectionStart&&relevantMarkupObjectsAtSelectionEnd){GENTICS.Aloha.Log.info(this,"markup 2 markup");this.prepareForRemoval(rangeObject.getSelectionTree(),markupObject,tagComparator);this.splitRelevantMarkupObject(relevantMarkupObjectsAtSelectionStart,relevantMarkupObjectsAtSelectionEnd,rangeObject,tagComparator)}else{if(!markupObject.isReplacingElement&&((!relevantMarkupObjectsAtSelectionStart&&relevantMarkupObjectsAtSelectionEnd)||relevantMarkupObjectAfterSelection||relevantMarkupObjectBeforeSelection)){GENTICS.Aloha.Log.info(this,"non-markup 2 markup OR with next2markup");if(relevantMarkupObjectBeforeSelection&&relevantMarkupObjectAfterSelection){var extendedRangeObject=new GENTICS.Aloha.Selection.SelectionRange(rangeObject);extendedRangeObject.startContainer=jQuery(relevantMarkupObjectBeforeSelection[relevantMarkupObjectBeforeSelection.length-1]).textNodes()[0];extendedRangeObject.startOffset=0;extendedRangeObject.endContainer=jQuery(relevantMarkupObjectAfterSelection[relevantMarkupObjectAfterSelection.length-1]).textNodes().last()[0];extendedRangeObject.endOffset=extendedRangeObject.endContainer.length;extendedRangeObject.update();this.applyMarkup(extendedRangeObject.getSelectionTree(),rangeObject,markupObject,tagComparator);GENTICS.Aloha.Log.info(this,"double extending previous markup(previous and after selection), actually wrapping it ...")}else{if(relevantMarkupObjectBeforeSelection&&!relevantMarkupObjectAfterSelection&&!relevantMarkupObjectsAtSelectionEnd){this.extendExistingMarkupWithSelection(relevantMarkupObjectBeforeSelection,rangeObject,false,tagComparator);GENTICS.Aloha.Log.info(this,"extending previous markup")}else{if(relevantMarkupObjectBeforeSelection&&!relevantMarkupObjectAfterSelection&&relevantMarkupObjectsAtSelectionEnd){var extendedRangeObject=new GENTICS.Aloha.Selection.SelectionRange(rangeObject);extendedRangeObject.startContainer=jQuery(relevantMarkupObjectBeforeSelection[relevantMarkupObjectBeforeSelection.length-1]).textNodes()[0];extendedRangeObject.startOffset=0;extendedRangeObject.endContainer=jQuery(relevantMarkupObjectsAtSelectionEnd[relevantMarkupObjectsAtSelectionEnd.length-1]).textNodes().last()[0];extendedRangeObject.endOffset=extendedRangeObject.endContainer.length;extendedRangeObject.update();this.applyMarkup(extendedRangeObject.getSelectionTree(),rangeObject,markupObject,tagComparator);GENTICS.Aloha.Log.info(this,"double extending previous markup(previous and relevant at the end), actually wrapping it ...")}else{if(!relevantMarkupObjectBeforeSelection&&relevantMarkupObjectAfterSelection){this.extendExistingMarkupWithSelection(relevantMarkupObjectAfterSelection,rangeObject,true,tagComparator);GENTICS.Aloha.Log.info(this,"extending following markup backwards")}else{this.extendExistingMarkupWithSelection(relevantMarkupObjectsAtSelectionEnd,rangeObject,true,tagComparator)}}}}}else{if(markupObject.isReplacingElement||(!relevantMarkupObjectsAtSelectionStart&&!relevantMarkupObjectsAtSelectionEnd&&!relevantMarkupObjectBeforeSelection&&!relevantMarkupObjectAfterSelection)){GENTICS.Aloha.Log.info(this,"non-markup 2 non-markup");this.applyMarkup(rangeObject.getSelectionTree(),rangeObject,markupObject,tagComparator,{setRangeObject2NewMarkup:true})}}}}jQuery(".preparedForRemoval").zap();rangeObject.update();if(markupObject.isReplacingElement){backupRangeObject.select()}else{rangeObject.select()}};GENTICS.Aloha.Selection.prototype.areMarkupObjectsAsLongAsRangeObject=function(relevantMarkupObjectsAtSelectionStart,relevantMarkupObjectsAtSelectionEnd,rangeObject){if(rangeObject.startOffset!==0){return false}for(var i=0;i<relevantMarkupObjectsAtSelectionStart.length;i++){var el=jQuery(relevantMarkupObjectsAtSelectionStart[i]);if(el.textNodes().first()[0]!==rangeObject.startContainer){return false}}for(var i=0;i<relevantMarkupObjectsAtSelectionEnd.length;i++){var el=jQuery(relevantMarkupObjectsAtSelectionEnd[i]);if(el.textNodes().last()[0]!==rangeObject.endContainer||el.textNodes().last()[0].length!=rangeObject.endOffset){return false}}return true};GENTICS.Aloha.Selection.prototype.splitRelevantMarkupObject=function(relevantMarkupObjectsAtSelectionStart,relevantMarkupObjectsAtSelectionEnd,rangeObject,tagComparator){jQuery(relevantMarkupObjectsAtSelectionStart).addClass("preparedForRemoval");jQuery(relevantMarkupObjectsAtSelectionEnd).addClass("preparedForRemoval");if(this.areMarkupObjectsAsLongAsRangeObject(relevantMarkupObjectsAtSelectionStart,relevantMarkupObjectsAtSelectionEnd,rangeObject)){return true}var relevantMarkupObjectAtSelectionStartAndEnd=this.intersectRelevantMarkupObjects(relevantMarkupObjectsAtSelectionStart,relevantMarkupObjectsAtSelectionEnd);if(relevantMarkupObjectAtSelectionStartAndEnd){this.insertCroppedMarkups([relevantMarkupObjectAtSelectionStartAndEnd],rangeObject,false,tagComparator);this.insertCroppedMarkups([relevantMarkupObjectAtSelectionStartAndEnd],rangeObject,true,tagComparator)}else{this.insertCroppedMarkups(relevantMarkupObjectsAtSelectionStart,rangeObject,false,tagComparator);this.insertCroppedMarkups(relevantMarkupObjectsAtSelectionEnd,rangeObject,true,tagComparator)}return true};GENTICS.Aloha.Selection.prototype.intersectRelevantMarkupObjects=function(relevantMarkupObjectsAtSelectionStart,relevantMarkupObjectsAtSelectionEnd){var intersection=false;if(!relevantMarkupObjectsAtSelectionStart||!relevantMarkupObjectsAtSelectionEnd){return intersection}for(var i=0;i<relevantMarkupObjectsAtSelectionStart.length;i++){var elStart=relevantMarkupObjectsAtSelectionStart[i];for(var j=0;j<relevantMarkupObjectsAtSelectionEnd.length;j++){var elEnd=relevantMarkupObjectsAtSelectionEnd[j];if(elStart===elEnd){intersection=elStart}}}return intersection};GENTICS.Aloha.Selection.prototype.extendExistingMarkupWithSelection=function(relevantMarkupObjects,rangeObject,startOrEnd,tagComparator){if(!startOrEnd){var extendMarkupsAtStart=true}if(startOrEnd){var extendMarkupsAtEnd=true}var objects=[];for(var i=0;i<relevantMarkupObjects.length;i++){objects[i]=new this.SelectionRange();el=relevantMarkupObjects[i];if(extendMarkupsAtEnd&&!extendMarkupsAtStart){objects[i].startContainer=rangeObject.startContainer;objects[i].startOffset=rangeObject.startOffset;textnodes=jQuery(el).textNodes(true);objects[i].endContainer=textnodes[textnodes.length-1];objects[i].endOffset=textnodes[textnodes.length-1].length;objects[i].update();this.applyMarkup(objects[i].getSelectionTree(),rangeObject,this.getClonedMarkup4Wrapping(el),tagComparator,{setRangeObject2NewMarkup:true})}if(!extendMarkupsAtEnd&&extendMarkupsAtStart){textnodes=jQuery(el).textNodes(true);objects[i].startContainer=textnodes[0];objects[i].startOffset=0;objects[i].endContainer=rangeObject.endContainer;objects[i].endOffset=rangeObject.endOffset;objects[i].update();this.applyMarkup(objects[i].getSelectionTree(),rangeObject,this.getClonedMarkup4Wrapping(el),tagComparator,{setRangeObject2NewMarkup:true})}}return true};GENTICS.Aloha.Selection.prototype.getClonedMarkup4Wrapping=function(domobj){var wrapper=jQuery(domobj).clone().removeClass("preparedForRemoval").empty();if(wrapper.attr("class").length==0){wrapper.removeAttr("class")}return wrapper};GENTICS.Aloha.Selection.prototype.insertCroppedMarkups=function(relevantMarkupObjects,rangeObject,startOrEnd,tagComparator){if(!startOrEnd){var cropMarkupsAtEnd=true}else{var cropMarkupsAtStart=true}var objects=[];for(var i=0;i<relevantMarkupObjects.length;i++){objects[i]=new this.SelectionRange();var el=relevantMarkupObjects[i];if(cropMarkupsAtEnd&&!cropMarkupsAtStart){var textNodes=jQuery(el).textNodes(true);objects[i].startContainer=textNodes[0];objects[i].startOffset=0;if(objects[i].startContainer===rangeObject.startContainer&&objects[i].startOffset===rangeObject.startOffset){continue}if(rangeObject.startOffset==0){objects[i].endContainer=this.getTextNodeSibling(false,el,rangeObject.startContainer);objects[i].endOffset=objects[i].endContainer.length}else{objects[i].endContainer=rangeObject.startContainer;objects[i].endOffset=rangeObject.startOffset}objects[i].update();this.applyMarkup(objects[i].getSelectionTree(),rangeObject,this.getClonedMarkup4Wrapping(el),tagComparator,{setRangeObject2NextSibling:true})}if(!cropMarkupsAtEnd&&cropMarkupsAtStart){objects[i].startContainer=rangeObject.endContainer;objects[i].startOffset=rangeObject.endOffset;textnodes=jQuery(el).textNodes(true);objects[i].endContainer=textnodes[textnodes.length-1];objects[i].endOffset=textnodes[textnodes.length-1].length;objects[i].update();this.applyMarkup(objects[i].getSelectionTree(),rangeObject,this.getClonedMarkup4Wrapping(el),tagComparator,{setRangeObject2PreviousSibling:true})}}return true};GENTICS.Aloha.Selection.prototype.changeMarkupOnSelection=function(markupObject){this.changeMarkup(this.getRangeObject(),markupObject,this.getStandardTagComparator(markupObject));GENTICS.Utils.Dom.doCleanup({mergetext:true},this.rangeObject);this.rangeObject.update();this.rangeObject.select()};GENTICS.Aloha.Selection.prototype.applyMarkup=function(selectionTree,rangeObject,markupObject,tagComparator,options){options=options?options:{};this.prepareForRemoval(selectionTree,markupObject,tagComparator);var optimizedSelectionTree=this.optimizeSelectionTree4Markup(selectionTree,markupObject,tagComparator);breakpoint=true;for(var i=0;i<optimizedSelectionTree.length;i++){var el=optimizedSelectionTree[i];if(el.wrappable){this.wrapMarkupAroundSelectionTree(el.elements,rangeObject,markupObject,tagComparator,options)}else{GENTICS.Aloha.Log.debug(this,"dive further into non-wrappable object");this.applyMarkup(el.element.children,rangeObject,markupObject,tagComparator,options)}}};GENTICS.Aloha.Selection.prototype.getMarkupType=function(markupObject){var nn=jQuery(markupObject)[0].nodeName.toLowerCase();if(markupObject.outerHTML){GENTICS.Aloha.Log.debug(this,"Node name detected: "+nn+" for: "+markupObject.outerHTML())}if(nn=="#text"){return"textNode"}if(this.replacingElements[nn]){return"sectionOrGroupingContent"}if(this.tagHierarchy[nn]){return"textLevelSemantics"}GENTICS.Aloha.Log.warn(this,"unknown markup passed to this.getMarkupType(...): "+markupObject.outerHTML())};GENTICS.Aloha.Selection.prototype.getStandardTagComparator=function(markupObject){var that=this;switch(this.getMarkupType(markupObject)){case"textNode":return function(p1,p2){return false};break;case"sectionOrGroupingContent":return function(domobj,markupObject){return that.standardSectionsAndGroupingContentComparator(domobj,markupObject)};break;case"textLevelSemantics":default:return function(domobj,markupObject){return that.standardTextLevelSemanticsComparator(domobj,markupObject)}}};GENTICS.Aloha.Selection.prototype.prepareForRemoval=function(selectionTree,markupObject,tagComparator){var that=this;if(typeof tagComparator!=="undefined"&&typeof tagComparator!=="function"){GENTICS.Aloha.Log.error(this,"parameter tagComparator is not a function")}if(typeof tagComparator==="undefined"){tagComparator=this.getStandardTagComparator(markupObject)}for(var i=0;i<selectionTree.length;i++){var el=selectionTree[i];if(el.domobj&&(el.selection=="full"||(el.selection=="partial"&&markupObject.isReplacingElement))){if(el.domobj.nodeType===1&&tagComparator(el.domobj,markupObject)){GENTICS.Aloha.Log.debug(this,"Marking for removal: "+el.domobj.nodeName);jQuery(el.domobj).addClass("preparedForRemoval")}}if(el.selection!="none"&&el.children.length>0){this.prepareForRemoval(el.children,markupObject,tagComparator)}}};GENTICS.Aloha.Selection.prototype.wrapMarkupAroundSelectionTree=function(selectionTree,rangeObject,markupObject,tagComparator,options){var objects2wrap=[];var j=-1;GENTICS.Aloha.Log.debug(this,"The formatting <"+markupObject[0].tagName+"> will be wrapped around the selection");var preText="";var postText="";for(var i=0;i<selectionTree.length;i++){var el=selectionTree[i];if(el.domobj&&!this.canTag1WrapTag2(el.domobj.parentNode.tagName.toLowerCase(),markupObject[0].tagName.toLowerCase())){GENTICS.Aloha.Log.info(this,"Skipping the wrapping of <"+markupObject[0].tagName.toLowerCase()+"> because this tag is not allowed inside <"+el.domobj.parentNode.tagName.toLowerCase()+">");continue}if(el.domobj&&el.domobj.nodeType==3&&jQuery.trim(jQuery(el.domobj).outerHTML()).length==0){continue}if(el.domobj&&el.selection=="partial"&&!markupObject.isReplacingElement){if(el.startOffset!==undefined&&el.endOffset===undefined){j++;preText+=el.domobj.data.substr(0,el.startOffset);el.domobj.data=el.domobj.data.substr(el.startOffset,el.domobj.data.length-el.startOffset);objects2wrap[j]=el.domobj}else{if(el.endOffset!==undefined&&el.startOffset===undefined){j++;postText+=el.domobj.data.substr(el.endOffset,el.domobj.data.length-el.endOffset);el.domobj.data=el.domobj.data.substr(0,el.endOffset);objects2wrap[j]=el.domobj}else{if(el.endOffset!==undefined&&el.startOffset!==undefined){if(el.startOffset==el.endOffset){GENTICS.Aloha.Log.debug(this,"skipping empty selection");continue}j++;preText+=el.domobj.data.substr(0,el.startOffset);var middleText=el.domobj.data.substr(el.startOffset,el.endOffset-el.startOffset);postText+=el.domobj.data.substr(el.endOffset,el.domobj.data.length-el.endOffset);el.domobj.data=middleText;objects2wrap[j]=el.domobj}else{GENTICS.Aloha.Log.debug(this,"diving into object");this.applyMarkup(el.children,rangeObject,markupObject,tagComparator,options)}}}}if(el.domobj&&(el.selection=="full"||(el.selection=="partial"&&markupObject.isReplacingElement))){j++;objects2wrap[j]=el.domobj}}breakpoint=true;if(objects2wrap.length>0){objects2wrap=jQuery(objects2wrap);jQuery.each(objects2wrap,function(index,element){if(jQuery.browser.msie&&element.nodeType==3&&!element.nextSibling&&!element.previousSibling&&element.parentNode&&element.parentNode.nodeName.toLowerCase()=="li"){element.data=jQuery.trim(element.data)}});var newMarkup=objects2wrap.wrapAll(markupObject).parent();newMarkup.before(preText).after(postText);var breakpoint=true;if(options.setRangeObject2NewMarkup){var textnodes=objects2wrap.textNodes();if(textnodes.index(rangeObject.startContainer)!=-1){rangeObject.startOffset=0}if(textnodes.index(rangeObject.endContainer)!=-1){rangeObject.endOffset=rangeObject.endContainer.length}var breakpoint=true}if(options.setRangeObject2NextSibling){var prevOrNext=true;var textNode2Start=newMarkup.textNodes(true).last()[0];if(objects2wrap.index(rangeObject.startContainer)!=-1){rangeObject.startContainer=this.getTextNodeSibling(prevOrNext,newMarkup.parent(),textNode2Start);rangeObject.startOffset=0}if(objects2wrap.index(rangeObject.endContainer)!=-1){rangeObject.endContainer=this.getTextNodeSibling(prevOrNext,newMarkup.parent(),textNode2Start);rangeObject.endOffset=rangeObject.endOffset-textNode2Start.length}}if(options.setRangeObject2PreviousSibling){var prevOrNext=false;var textNode2Start=newMarkup.textNodes(true).first()[0];if(objects2wrap.index(rangeObject.startContainer)!=-1){rangeObject.startContainer=this.getTextNodeSibling(prevOrNext,newMarkup.parent(),textNode2Start);rangeObject.startOffset=0}if(objects2wrap.index(rangeObject.endContainer)!=-1){rangeObject.endContainer=this.getTextNodeSibling(prevOrNext,newMarkup.parent(),textNode2Start);rangeObject.endOffset=rangeObject.endContainer.length}}}};GENTICS.Aloha.Selection.prototype.getTextNodeSibling=function(previousOrNext,commonAncestorContainer,currentTextNode){var textNodes=jQuery(commonAncestorContainer).textNodes(true);index=textNodes.index(currentTextNode);if(index==-1){return false}var newIndex=index+(!previousOrNext?-1:1);return textNodes[newIndex]?textNodes[newIndex]:false};GENTICS.Aloha.Selection.prototype.optimizeSelectionTree4Markup=function(selectionTree,markupObject,tagComparator){var groupMap=[];var outerGroupIndex=0;var innerGroupIndex=0;var that=this;if(typeof tagComparator==="undefined"){tagComparator=function(domobj,markupObject){return that.standardTextLevelSemanticsComparator(markupObject)}}for(var i=0;i<selectionTree.length;i++){if(selectionTree[i].domobj&&selectionTree[i].selection!="none"){if(markupObject.isReplacingElement&&tagComparator(markupObject[0],jQuery(selectionTree[i].domobj))){if(groupMap[outerGroupIndex]!==undefined){outerGroupIndex++}groupMap[outerGroupIndex]={};groupMap[outerGroupIndex].wrappable=true;groupMap[outerGroupIndex].elements=[];groupMap[outerGroupIndex].elements[innerGroupIndex]=selectionTree[i];outerGroupIndex++}else{if(this.canMarkupBeApplied2ElementAsWhole([selectionTree[i]],markupObject)){if(groupMap[outerGroupIndex]===undefined){groupMap[outerGroupIndex]={};groupMap[outerGroupIndex].wrappable=true;groupMap[outerGroupIndex].elements=[]}if(markupObject.isReplacingElement){var startPosition=i;for(var j=i-1;j>=0;j--){if(this.canMarkupBeApplied2ElementAsWhole([selectionTree[j]],markupObject)&&this.isMarkupAllowedToStealSelectionTreeElement(selectionTree[j],markupObject)){startPosition=j}else{break}}var endPosition=i;for(var j=i+1;j<selectionTree.length;j++){if(this.canMarkupBeApplied2ElementAsWhole([selectionTree[j]],markupObject)&&this.isMarkupAllowedToStealSelectionTreeElement(selectionTree[j],markupObject)){endPosition=j}else{break}}innerGroupIndex=0;for(var j=startPosition;j<=endPosition;j++){groupMap[outerGroupIndex].elements[innerGroupIndex]=selectionTree[j];groupMap[outerGroupIndex].elements[innerGroupIndex].selection="full";innerGroupIndex++}innerGroupIndex=0}else{groupMap[outerGroupIndex].elements[innerGroupIndex]=selectionTree[i];innerGroupIndex++}}else{if(groupMap[outerGroupIndex]!==undefined){outerGroupIndex++}groupMap[outerGroupIndex]={};groupMap[outerGroupIndex].wrappable=false;groupMap[outerGroupIndex].element=selectionTree[i];innerGroupIndex=0;outerGroupIndex++}}}}return groupMap};GENTICS.Aloha.Selection.prototype.isMarkupAllowedToStealSelectionTreeElement=function(selectionTreeElement,markupObject){if(!selectionTreeElement.domobj){return false}var nodeName=selectionTreeElement.domobj.nodeName.toLowerCase();nodeName=(nodeName=="#text")?"textNode":nodeName;var markupName=markupObject[0].nodeName.toLowerCase();if(!this.allowedToStealElements[markupName]){return false}if(this.allowedToStealElements[markupName].indexOf(nodeName)==-1){return false}return true};GENTICS.Aloha.Selection.prototype.canMarkupBeApplied2ElementAsWhole=function(selectionTree,markupObject){if(markupObject.jquery){htmlTag=markupObject[0].tagName}if(markupObject.tagName){htmlTag=markupObject.tagName}returnVal=true;for(var i=0;i<selectionTree.length;i++){var el=selectionTree[i];if(el.domobj&&(el.selection!="none"||markupObject.isReplacingElement)){if(!this.canTag1WrapTag2(htmlTag,el.domobj.nodeName)){return false}if(el.children.length>0&&!this.canMarkupBeApplied2ElementAsWhole(el.children,markupObject)){return false}}}return returnVal};GENTICS.Aloha.Selection.prototype.canTag1WrapTag2=function(t1,t2){t1=(t1=="#text")?"textNode":t1.toLowerCase();t2=(t2=="#text")?"textNode":t2.toLowerCase();if(!this.tagHierarchy[t1]){return true}if(!this.tagHierarchy[t2]){return true}var t1Array=this.tagHierarchy[t1];var returnVal=(t1Array.indexOf(t2)!=-1)?true:false;return returnVal};GENTICS.Aloha.Selection.prototype.mayInsertTag=function(tagName){if(typeof this.rangeObject.unmodifiableMarkupAtStart=="object"){for(var i=0;i<this.rangeObject.unmodifiableMarkupAtStart.length;++i){if(!this.canTag1WrapTag2(this.rangeObject.unmodifiableMarkupAtStart[i].nodeName,tagName)){return false}}return true}else{GENTICS.Aloha.Log.warn(this,"Unable to determine whether tag "+tagName+" may be inserted");return true}};GENTICS.Aloha.Selection.prototype.toString=function(){return"GENTICS.Aloha.Selection"};GENTICS.Aloha.Selection.prototype.SelectionRange=function(rangeObject){GENTICS.Utils.RangeObject.apply(this,arguments);this.commonAncestorContainer;this.selectionTree;this.markupEffectiveAtStart=[];this.unmodifiableMarkupAtStart=[];this.limitObject;this.splitObject;if(rangeObject){if(rangeObject.commonAncestorContainer){this.commonAncestorContainer=rangeObject.commonAncestorContainer}if(rangeObject.selectionTree){this.selectionTree=rangeObject.selectionTree}if(rangeObject.limitObject){this.limitObject=rangeObject.limitObject}if(rangeObject.markupEffectiveAtStart){this.markupEffectiveAtStart=rangeObject.markupEffectiveAtStart}if(rangeObject.unmodifiableMarkupAtStart){this.unmodifiableMarkupAtStart=rangeObject.unmodifiableMarkupAtStart}if(rangeObject.splitObject){this.splitObject=rangeObject.splitObject}}};GENTICS.Aloha.Selection.prototype.SelectionRange.prototype=new GENTICS.Utils.RangeObject();GENTICS.Aloha.Selection.prototype.SelectionRange.prototype.select=function(){GENTICS.Utils.RangeObject.prototype.select.apply(this,arguments);GENTICS.Aloha.Selection.updateSelection()};GENTICS.Aloha.Selection.prototype.SelectionRange.prototype.update=function(commonAncestorContainer){this.updatelimitObject();this.updateMarkupEffectiveAtStart();this.updateCommonAncestorContainer(commonAncestorContainer);this.selectionTree=undefined};GENTICS.Aloha.Selection.prototype.SelectionRange.prototype.getSelectionTree=function(){if(!this.selectionTree){this.selectionTree=GENTICS.Aloha.Selection.getSelectionTree(this)}return this.selectionTree};GENTICS.Aloha.Selection.prototype.SelectionRange.prototype.getSelectedSiblings=function(domobj){var selectionTree=this.getSelectionTree();return this.recursionGetSelectedSiblings(domobj,selectionTree)};GENTICS.Aloha.Selection.prototype.SelectionRange.prototype.recursionGetSelectedSiblings=function(domobj,selectionTree){var selectedSiblings=false;var foundObj=false;for(var i=0;i<selectionTree.length;++i){if(selectionTree[i].domobj===domobj){foundObj=true;selectedSiblings=[]}else{if(!foundObj&&selectionTree[i].children){selectedSiblings=this.recursionGetSelectedSiblings(domobj,selectionTree[i].children);if(selectedSiblings!==false){break}}else{if(foundObj&&selectionTree[i].domobj&&selectionTree[i].selection!="collapsed"&&selectionTree[i].selection!="none"){selectedSiblings.push(selectionTree[i].domobj)}else{if(foundObj&&selectionTree[i].selection=="none"){break}}}}}return selectedSiblings};GENTICS.Aloha.Selection.prototype.SelectionRange.prototype.updateMarkupEffectiveAtStart=function(){this.markupEffectiveAtStart=[];this.unmodifiableMarkupAtStart=[];var parents=this.getStartContainerParents();var limitFound=false;for(var i=0;i<parents.length;i++){var el=parents[i];if(!limitFound&&(el!==this.limitObject)){this.markupEffectiveAtStart[i]=el;if(!splitObjectWasSet&&GENTICS.Utils.Dom.isSplitObject(el)){var splitObjectWasSet=true;this.splitObject=el}}else{limitFound=true;this.unmodifiableMarkupAtStart.push(el)}}if(!splitObjectWasSet){this.splitObject=false}return};GENTICS.Aloha.Selection.prototype.SelectionRange.prototype.updatelimitObject=function(){if(GENTICS.Aloha.editables&&GENTICS.Aloha.editables.length>0){var parents=this.getStartContainerParents();var editables=GENTICS.Aloha.editables;for(var i=0;i<parents.length;i++){var el=parents[i];for(var j=0;j<editables.length;j++){var editable=editables[j].obj[0];if(el===editable){this.limitObject=el;return true}}}}this.limitObject=jQuery("body");return true};GENTICS.Aloha.Selection.prototype.SelectionRange.prototype.toString=function(verbose){if(!verbose){return"GENTICS.Aloha.Selection.SelectionRange"}return"GENTICS.Aloha.Selection.SelectionRange {start ["+this.startContainer.nodeValue+"] offset "+this.startOffset+", end ["+this.endContainer.nodeValue+"] offset "+this.endOffset+"}"};GENTICS.Aloha.Selection=new GENTICS.Aloha.Selection();
126
169
  /*
127
- * Aloha Editor
128
- * Author & Copyright (c) 2010 Gentics Software GmbH
129
- * aloha-sales@gentics.com
130
- * Licensed unter the terms of http://www.aloha-editor.com/license.html
170
+ * This file is part of Aloha Editor
171
+ * Author & Copyright (c) 2010 Gentics Software GmbH, aloha@gentics.com
172
+ * Licensed unter the terms of http://www.aloha-editor.com/license.html
131
173
  */
132
- GENTICS.Aloha.Sidebar=function(){};GENTICS.Aloha.Sidebar.prototype.add=function(panel){};GENTICS.Aloha.Sidebar.prototype.render=function(){};GENTICS.Aloha.Sidebar.prototype.openPanel=function(panel){};GENTICS.Aloha.Sidebar.prototype.closePanel=function(panel){};GENTICS.Aloha.Sidebar.prototype.togglePinPanel=function(panel){};GENTICS.Aloha.SidebarRight=new GENTICS.Aloha.Sidebar();GENTICS.Aloha.SidebarLeft=new GENTICS.Aloha.Sidebar();GENTICS.Aloha.Sidebar.Panel=function(){};GENTICS.Aloha.Sidebar.Panel.prototype.render=function(){};(function($){$.fn.extend({autocomplete:function(urlOrData,options){var isUrl=typeof urlOrData=="string";options=$.extend({},$.Autocompleter.defaults,{url:isUrl?urlOrData:null,data:isUrl?null:urlOrData,delay:isUrl?$.Autocompleter.defaults.delay:10,max:options&&!options.scroll?10:150},options);options.highlight=options.highlight||function(value){return value};options.formatMatch=options.formatMatch||options.formatItem;return this.each(function(){new $.Autocompleter(this,options)})},result:function(handler){return this.bind("result",handler)},search:function(handler){return this.trigger("search",[handler])},flushCache:function(){return this.trigger("flushCache")},setOptions:function(options){return this.trigger("setOptions",[options])},unautocomplete:function(){return this.trigger("unautocomplete")}});$.Autocompleter=function(input,options){var KEY={UP:38,DOWN:40,DEL:46,TAB:9,RETURN:13,ESC:27,COMMA:188,PAGEUP:33,PAGEDOWN:34,BACKSPACE:8};var $input=$(input).attr("autocomplete","off").addClass(options.inputClass);var timeout;var previousValue="";var cache=$.Autocompleter.Cache(options);var hasFocus=0;var lastKeyPressCode;var config={mouseDownOnSelect:false};var select=$.Autocompleter.Select(options,input,selectCurrent,config);var blockSubmit;$.browser.opera&&$(input.form).bind("submit.autocomplete",function(){if(blockSubmit){blockSubmit=false;return false}});$input.bind(($.browser.opera?"keypress":"keydown")+".autocomplete",function(event){hasFocus=1;lastKeyPressCode=event.keyCode;switch(event.keyCode){case KEY.UP:event.preventDefault();if(select.visible()){select.prev()}else{onChange(0,true)}break;case KEY.DOWN:event.preventDefault();if(select.visible()){select.next()}else{onChange(0,true)}break;case KEY.PAGEUP:event.preventDefault();if(select.visible()){select.pageUp()}else{onChange(0,true)}break;case KEY.PAGEDOWN:event.preventDefault();if(select.visible()){select.pageDown()}else{onChange(0,true)}break;case options.multiple&&$.trim(options.multipleSeparator)==","&&KEY.COMMA:case KEY.TAB:case KEY.RETURN:if(selectCurrent()){event.preventDefault();blockSubmit=true;return false}break;case KEY.ESC:select.hide();break;default:clearTimeout(timeout);timeout=setTimeout(onChange,options.delay);break}}).focus(function(){hasFocus++}).blur(function(){hasFocus=0;if(!config.mouseDownOnSelect){hideResults()}}).click(function(){if(hasFocus++>1&&!select.visible()){onChange(0,true)}}).bind("search",function(){var fn=(arguments.length>1)?arguments[1]:null;function findValueCallback(q,data){var result;if(data&&data.length){for(var i=0;i<data.length;i++){if(data[i].result.toLowerCase()==q.toLowerCase()){result=data[i];break}}}if(typeof fn=="function"){fn(result)}else{$input.trigger("result",result&&[result.data,result.value])}}$.each(trimWords($input.val()),function(i,value){request(value,findValueCallback,findValueCallback)})}).bind("flushCache",function(){cache.flush()}).bind("setOptions",function(){$.extend(options,arguments[1]);if("data" in arguments[1]){cache.populate()}}).bind("unautocomplete",function(){select.unbind();$input.unbind();$(input.form).unbind(".autocomplete")});function selectCurrent(){var selected=select.selected();if(!selected){return false}var v=selected.result;previousValue=v;if(options.multiple){var words=trimWords($input.val());if(words.length>1){var seperator=options.multipleSeparator.length;var cursorAt=$(input).selection().start;var wordAt,progress=0;$.each(words,function(i,word){progress+=word.length;if(cursorAt<=progress){wordAt=i;return false}progress+=seperator});words[wordAt]=v;v=words.join(options.multipleSeparator)}v+=options.multipleSeparator}$input.val(v);hideResultsNow();$input.trigger("result",[selected.data,selected.value]);return true}function onChange(crap,skipPrevCheck){if(lastKeyPressCode==KEY.DEL){select.hide();return}var currentValue=$input.val();if(!skipPrevCheck&&currentValue==previousValue){return}previousValue=currentValue;currentValue=lastWord(currentValue);if(currentValue.length>=options.minChars){$input.addClass(options.loadingClass);if(!options.matchCase){currentValue=currentValue.toLowerCase()}request(currentValue,receiveData,hideResultsNow)}else{stopLoading();select.hide()}}function trimWords(value){if(!value){return[""]}if(!options.multiple){return[$.trim(value)]}return $.map(value.split(options.multipleSeparator),function(word){return $.trim(value).length?$.trim(word):null})}function lastWord(value){if(!options.multiple){return value}var words=trimWords(value);if(words.length==1){return words[0]}var cursorAt=$(input).selection().start;if(cursorAt==value.length){words=trimWords(value)}else{words=trimWords(value.replace(value.substring(cursorAt),""))}return words[words.length-1]}function autoFill(q,sValue){if(options.autoFill&&(lastWord($input.val()).toLowerCase()==q.toLowerCase())&&lastKeyPressCode!=KEY.BACKSPACE){$input.val($input.val()+sValue.substring(lastWord(previousValue).length));$(input).selection(previousValue.length,previousValue.length+sValue.length)}}function hideResults(){clearTimeout(timeout);timeout=setTimeout(hideResultsNow,200)}function hideResultsNow(){var wasVisible=select.visible();select.hide();clearTimeout(timeout);stopLoading();if(options.mustMatch){$input.search(function(result){if(!result){if(options.multiple){var words=trimWords($input.val()).slice(0,-1);$input.val(words.join(options.multipleSeparator)+(words.length?options.multipleSeparator:""))}else{$input.val("");$input.trigger("result",null)}}})}}function receiveData(q,data){if(data&&data.length&&hasFocus){stopLoading();select.display(data,q);autoFill(q,data[0].value);select.show()}else{hideResultsNow()}}function request(term,success,failure){if(!options.matchCase){term=term.toLowerCase()}var data=cache.load(term);if(data&&data.length){success(term,data)}else{if((typeof options.url=="string")&&(options.url.length>0)){var extraParams={timestamp:+new Date()};$.each(options.extraParams,function(key,param){extraParams[key]=typeof param=="function"?param():param});$.ajax({mode:"abort",port:"autocomplete"+input.name,dataType:options.dataType,url:options.url,data:$.extend({q:lastWord(term),limit:options.max},extraParams),success:function(data){var parsed=options.parse&&options.parse(data)||parse(data);cache.add(term,parsed);success(term,parsed)}})}else{select.emptyList();failure(term)}}}function parse(data){var parsed=[];var rows=data.split("\n");for(var i=0;i<rows.length;i++){var row=$.trim(rows[i]);if(row){row=row.split("|");parsed[parsed.length]={data:row,value:row[0],result:options.formatResult&&options.formatResult(row,row[0])||row[0]}}}return parsed}function stopLoading(){$input.removeClass(options.loadingClass)}};$.Autocompleter.defaults={inputClass:"ac_input",resultsClass:"ac_results",loadingClass:"ac_loading",minChars:1,delay:400,matchCase:false,matchSubset:true,matchContains:false,cacheLength:10,max:100,mustMatch:false,extraParams:{},selectFirst:true,formatItem:function(row){return row[0]},formatMatch:null,autoFill:false,width:0,multiple:false,multipleSeparator:", ",highlight:function(value,term){return value.replace(new RegExp("(?![^&;]+;)(?!<[^<>]*)("+term.replace(/([\^\$\(\)\[\]\{\}\*\.\+\?\|\\])/gi,"\\$1")+")(?![^<>]*>)(?![^&;]+;)","gi"),"<strong>$1</strong>")},scroll:true,scrollHeight:180};$.Autocompleter.Cache=function(options){var data={};var length=0;function matchSubset(s,sub){if(!options.matchCase){s=s.toLowerCase()}var i=s.indexOf(sub);if(options.matchContains=="word"){i=s.toLowerCase().search("\\b"+sub.toLowerCase())}if(i==-1){return false}return i==0||options.matchContains}function add(q,value){if(length>options.cacheLength){flush()}if(!data[q]){length++}data[q]=value}function populate(){if(!options.data){return false}var stMatchSets={},nullData=0;if(!options.url){options.cacheLength=1}stMatchSets[""]=[];for(var i=0,ol=options.data.length;i<ol;i++){var rawValue=options.data[i];rawValue=(typeof rawValue=="string")?[rawValue]:rawValue;var value=options.formatMatch(rawValue,i+1,options.data.length);if(value===false){continue}var firstChar=value.charAt(0).toLowerCase();if(!stMatchSets[firstChar]){stMatchSets[firstChar]=[]}var row={value:value,data:rawValue,result:options.formatResult&&options.formatResult(rawValue)||value};stMatchSets[firstChar].push(row);if(nullData++<options.max){stMatchSets[""].push(row)}}$.each(stMatchSets,function(i,value){options.cacheLength++;add(i,value)})}setTimeout(populate,25);function flush(){data={};length=0}return{flush:flush,add:add,populate:populate,load:function(q){if(!options.cacheLength||!length){return null}if(!options.url&&options.matchContains){var csub=[];for(var k in data){if(k.length>0){var c=data[k];$.each(c,function(i,x){if(matchSubset(x.value,q)){csub.push(x)}})}}return csub}else{if(data[q]){return data[q]}else{if(options.matchSubset){for(var i=q.length-1;i>=options.minChars;i--){var c=data[q.substr(0,i)];if(c){var csub=[];$.each(c,function(i,x){if(matchSubset(x.value,q)){csub[csub.length]=x}});return csub}}}}}return null}}};$.Autocompleter.Select=function(options,input,select,config){var CLASSES={ACTIVE:"ac_over"};var listItems,active=-1,data,term="",needsInit=true,element,list;function init(){if(!needsInit){return}element=$("<div/>").hide().addClass(options.resultsClass).css("position","absolute").appendTo(document.body);list=$("<ul/>").appendTo(element).mouseover(function(event){if(target(event).nodeName&&target(event).nodeName.toUpperCase()=="LI"){active=$("li",list).removeClass(CLASSES.ACTIVE).index(target(event));$(target(event)).addClass(CLASSES.ACTIVE)}}).click(function(event){$(target(event)).addClass(CLASSES.ACTIVE);select();input.focus();return false}).mousedown(function(){config.mouseDownOnSelect=true}).mouseup(function(){config.mouseDownOnSelect=false});if(options.width>0){element.css("width",options.width)}needsInit=false}function target(event){var element=event.target;while(element&&element.tagName!="LI"){element=element.parentNode}if(!element){return[]}return element}function moveSelect(step){listItems.slice(active,active+1).removeClass(CLASSES.ACTIVE);movePosition(step);var activeItem=listItems.slice(active,active+1).addClass(CLASSES.ACTIVE);if(options.scroll){var offset=0;listItems.slice(0,active).each(function(){offset+=this.offsetHeight});if((offset+activeItem[0].offsetHeight-list.scrollTop())>list[0].clientHeight){list.scrollTop(offset+activeItem[0].offsetHeight-list.innerHeight())}else{if(offset<list.scrollTop()){list.scrollTop(offset)}}}}function movePosition(step){active+=step;if(active<0){active=listItems.size()-1}else{if(active>=listItems.size()){active=0}}}function limitNumberOfItems(available){return options.max&&options.max<available?options.max:available}function fillList(){list.empty();var max=limitNumberOfItems(data.length);for(var i=0;i<max;i++){if(!data[i]){continue}var formatted=options.formatItem(data[i].data,i+1,max,data[i].value,term);if(formatted===false){continue}var li=$("<li/>").html(options.highlight(formatted,term)).addClass(i%2==0?"ac_even":"ac_odd").appendTo(list)[0];$.data(li,"ac_data",data[i])}listItems=list.find("li");if(options.selectFirst){listItems.slice(0,1).addClass(CLASSES.ACTIVE);active=0}if($.fn.bgiframe){list.bgiframe()}}return{display:function(d,q){init();data=d;term=q;fillList()},next:function(){moveSelect(1)},prev:function(){moveSelect(-1)},pageUp:function(){if(active!=0&&active-8<0){moveSelect(-active)}else{moveSelect(-8)}},pageDown:function(){if(active!=listItems.size()-1&&active+8>listItems.size()){moveSelect(listItems.size()-1-active)}else{moveSelect(8)}},hide:function(){element&&element.hide();listItems&&listItems.removeClass(CLASSES.ACTIVE);active=-1},visible:function(){return element&&element.is(":visible")},current:function(){return this.visible()&&(listItems.filter("."+CLASSES.ACTIVE)[0]||options.selectFirst&&listItems[0])},show:function(){var offset=$(input).offset();element.css({width:typeof options.width=="string"||options.width>0?options.width:$(input).width(),top:offset.top+input.offsetHeight,left:offset.left}).show();if(options.scroll){list.scrollTop(0);list.css({maxHeight:options.scrollHeight,overflow:"auto"});if($.browser.msie&&typeof document.body.style.maxHeight==="undefined"){var listHeight=0;listItems.each(function(){listHeight+=this.offsetHeight});var scrollbarsVisible=listHeight>options.scrollHeight;list.css("height",scrollbarsVisible?options.scrollHeight:listHeight);if(!scrollbarsVisible){listItems.width(list.width()-parseInt(listItems.css("padding-left"))-parseInt(listItems.css("padding-right")))}}}},selected:function(){var selected=listItems&&listItems.filter("."+CLASSES.ACTIVE).removeClass(CLASSES.ACTIVE);return selected&&selected.length&&$.data(selected[0],"ac_data")},emptyList:function(){list&&list.empty()},unbind:function(){element&&element.remove()}}};$.fn.selection=function(start,end){if(start!==undefined){return this.each(function(){if(this.createTextRange){var selRange=this.createTextRange();if(end===undefined||start==end){selRange.move("character",start);selRange.select()}else{selRange.collapse(true);selRange.moveStart("character",start);selRange.moveEnd("character",end);selRange.select()}}else{if(this.setSelectionRange){this.setSelectionRange(start,end)}else{if(this.selectionStart){this.selectionStart=start;this.selectionEnd=end}}}})}var field=this[0];if(field.createTextRange){var range=document.selection.createRange(),orig=field.value,teststring="<->",textLength=range.text.length;range.text=teststring;var caretAt=field.value.indexOf(teststring);field.value=orig;this.selection(caretAt,caretAt+textLength);return{start:caretAt,end:caretAt+textLength}}else{if(field.selectionStart!==undefined){return{start:field.selectionStart,end:field.selectionEnd}}}}})(jQuery);
174
+ GENTICS.Aloha.Sidebar=function(){};GENTICS.Aloha.Sidebar.prototype.add=function(panel){};GENTICS.Aloha.Sidebar.prototype.render=function(){};GENTICS.Aloha.Sidebar.prototype.openPanel=function(panel){};GENTICS.Aloha.Sidebar.prototype.closePanel=function(panel){};GENTICS.Aloha.Sidebar.prototype.togglePinPanel=function(panel){};GENTICS.Aloha.SidebarRight=new GENTICS.Aloha.Sidebar();GENTICS.Aloha.SidebarLeft=new GENTICS.Aloha.Sidebar();GENTICS.Aloha.Sidebar.Panel=function(){};GENTICS.Aloha.Sidebar.Panel.prototype.render=function(){};
133
175
  /*
134
- * Aloha Editor
135
- * Author & Copyright (c) 2010 Gentics Software GmbH
136
- * aloha-sales@gentics.com
137
- * Licensed unter the terms of http://www.aloha-editor.com/license.html
176
+ * This file is part of Aloha Editor
177
+ * Author & Copyright (c) 2010 Gentics Software GmbH, aloha@gentics.com
178
+ * Licensed unter the terms of http://www.aloha-editor.com/license.html
138
179
  */
139
- GENTICS.Aloha.RessourceRegistry=function(){this.ressources=new Array()};GENTICS.Aloha.RessourceRegistry.prototype.register=function(ressource){if(ressource instanceof GENTICS.Aloha.Ressource){this.ressources.push(ressource)}};GENTICS.Aloha.RessourceRegistry.prototype.init=function(){for(var i=0;i<this.ressources.length;i++){var ressource=this.ressources[i];if(GENTICS.Aloha.settings.ressources==undefined){GENTICS.Aloha.settings.ressources={}}ressource.settings=GENTICS.Aloha.settings.ressources[ressource.prefix];if(ressource.settings==undefined){ressource.settings={}}if(ressource.settings.enabled==undefined){ressource.settings.enabled=true}if(ressource.settings.enabled==true){this.ressources[i].init()}}};GENTICS.Aloha.RessourceRegistry.toString=function(){return"com.gentics.aloha.RessourceRegistry"};GENTICS.Aloha.RessourceRegistry=new GENTICS.Aloha.RessourceRegistry();GENTICS.Aloha.Ressources={};
180
+ GENTICS.Aloha.RepositoryManager=function(){this.repositories=[]};GENTICS.Aloha.RepositoryManager.prototype.openCallbacks=[];GENTICS.Aloha.RepositoryManager.prototype.init=function(){if(GENTICS.Aloha.settings.repositories==undefined){GENTICS.Aloha.settings.repositories={}}for(var i=0;i<this.repositories.length;i++){var repository=this.repositories[i];if(repository.settings==undefined){repository.settings={}}if(GENTICS.Aloha.settings.repositories[repository.repositoryId]){jQuery.extend(repository.settings,GENTICS.Aloha.settings.repositories[repository.repositoryId])}repository.init()}};GENTICS.Aloha.RepositoryManager.prototype.register=function(repository){if(repository instanceof GENTICS.Aloha.Repository){if(!this.getRepository(repository.repositoryId)){this.repositories.push(repository)}else{GENTICS.Aloha.Log.warn(this,"A repository with name { "+repository.repositoryId+" } already registerd. Ignoring this.")}}else{GENTICS.Aloha.Log.error(this,"Trying to register a repository which is not an instance of GENTICS.Aloha.Repository.")}};GENTICS.Aloha.RepositoryManager.prototype.getRepository=function(repositoryId){for(var i=0;i<this.repositories.length;i++){if(this.repositories[i].repositoryId==repositoryId){return this.repositories[i]}}return null};GENTICS.Aloha.RepositoryManager.prototype.query=function(params,callback){var that=this;var allitems=[];var repositories=[];this.openCallbacks=[];var timer=setTimeout(function(){that.openCallbacks=[];that.queryCallback(callback,allitems,timer)},5000);if(params.repositoryId){repositories.push(this.getRepository(params.repositoryId))}else{repositories=this.repositories}for(var i=0;i<repositories.length;i++){this.openCallbacks.push(repositories[i].repositoryId);try{var notImplemented=repositories[i].query(params,function(items){var id=that.openCallbacks.indexOf(this.repositoryId);if(id!=-1){that.openCallbacks.splice(id,1)}if(!items.length==0&&!items[0].repositoryId){for(var j=0;j<items.length;j++){items[j].repositoryId=this.repositoryId}}jQuery.merge(allitems,items);that.queryCallback(callback,allitems,timer)})}catch(e){notImplemented=true}if(notImplemented){var id=that.openCallbacks.indexOf(repositories[i].repositoryId);if(id!=-1){this.openCallbacks.splice(id,1);if(i==repositories.length-1){this.queryCallback(callback,allitems,timer)}}}}};GENTICS.Aloha.RepositoryManager.prototype.queryCallback=function(cb,items,timer){if(this.openCallbacks.length==0){clearTimeout(timer);items.sort(function(a,b){return b.weight-a.weight});var result={results:items.length,items:items};cb.call(this,result)}};GENTICS.Aloha.RepositoryManager.prototype.getChildren=function(params,callback){var that=this;var allitems=[];var repositories=[];this.openChildrenCallbacks=[];if(params.inFolderId=="aloha"&&this.repositories.length>0){var repos=[];for(var i=0;i<this.repositories.length;i++){repos.push(new GENTICS.Aloha.Repository.Folder({id:this.repositories[i].repositoryId,name:this.repositories[i].repositoryName,repositoryId:this.repositories[i].repositoryId,type:"repository",hasMoreItems:true}))}that.getChildrenCallback(callback,repos,null);return}var timer=setTimeout(function(){that.openChildrenCallbacks=[];that.getChildrenCallback(callback,allitems,timer)},5000);if(params.repositoryId){repositories.push(this.getRepository(params.repositoryId))}else{repositories=this.repositories}for(var i=0;i<repositories.length;i++){this.openChildrenCallbacks.push(repositories[i].repositoryId);try{var notImplemented=repositories[i].getChildren(params,function(items){var id=that.openChildrenCallbacks.indexOf(this.repositoryId);if(id!=-1){that.openChildrenCallbacks.splice(id,1)}jQuery.merge(allitems,items);that.getChildrenCallback(callback,allitems,timer)})}catch(e){notImplemented=true}if(notImplemented){var id=that.openChildrenCallbacks.indexOf(repositories[i].repositoryId);if(id!=-1){this.openChildrenCallbacks.splice(id,1);if(i==repositories.length-1){this.getChildrenCallback(callback,allitems,timer)}}}}};GENTICS.Aloha.RepositoryManager.prototype.getChildrenCallback=function(cb,items,timer){if(this.openChildrenCallbacks.length==0){if(timer){clearTimeout(timer)}cb.call(this,items)}};GENTICS.Aloha.RepositoryManager.prototype.makeClean=function(obj){var that=this;var repository={};obj.find("[data-GENTICS-aloha-repository="+this.prefix+"]").each(function(){for(var i=0;i<that.repositories.length;i++){repository.makeClean(obj)}GENTICS.Aloha.Log.debug(that,"Passing contents of HTML Element with id { "+this.attr("id")+" } for cleaning to repository { "+repository.repositoryId+" }");repository.makeClean(this)})};GENTICS.Aloha.RepositoryManager.prototype.markObject=function(obj,item){var repository=this.getRepository(item.repositoryId);if(repository){jQuery(obj).attr({"data-GENTICS-aloha-repository":item.repositoryId,"data-GENTICS-aloha-object-id":item.id});repository.markObject(obj,item)}else{GENTICS.Aloha.Log.error(this,"Trying to apply a repository { "+item.name+" } to an object, but item has no repositoryId.")}};GENTICS.Aloha.RepositoryManager=new GENTICS.Aloha.RepositoryManager();GENTICS.Aloha.RepositoryManager.toString=function(){return"com.gentics.aloha.RepositoryManager"};
140
181
  /*
141
- * Aloha Editor
142
- * Author & Copyright (c) 2010 Gentics Software GmbH
143
- * aloha-sales@gentics.com
144
- * Licensed unter the terms of http://www.aloha-editor.com/license.html
182
+ * This file is part of Aloha Editor
183
+ * Author & Copyright (c) 2010 Gentics Software GmbH, aloha@gentics.com
184
+ * Licensed unter the terms of http://www.aloha-editor.com/license.html
145
185
  */
146
- GENTICS.Aloha.Ressource=function(ressourcePrefix,basePath){this.prefix=ressourcePrefix;this.basePath=basePath?basePath:ressourcePrefix;GENTICS.Aloha.RessourceRegistry.register(this)};GENTICS.Aloha.Ressource.prototype.settings=null;GENTICS.Aloha.Ressource.prototype.init=function(){};GENTICS.Aloha.Ressource.prototype.query=function(attrs){return null};GENTICS.Aloha.Ressource.prototype.resolveRessource=function(obj){return null};
186
+ GENTICS.Aloha.Repository=function(repositoryId,repositoryName){this.repositoryId=repositoryId;this.settings={};this.repositoryName=(repositoryName)?repositoryName:repositoryId;GENTICS.Aloha.RepositoryManager.register(this)};GENTICS.Aloha.Repository.prototype.init=function(){};GENTICS.Aloha.Repository.prototype.query=function(params,callback){return true};GENTICS.Aloha.Repository.prototype.getChildren=function(params,callback){return true};GENTICS.Aloha.Repository.prototype.makeClean=function(obj){};GENTICS.Aloha.Repository.prototype.markObject=function(obj,repositoryItem){};
147
187
  /*
148
- * Aloha Editor
149
- * Author & Copyright (c) 2010 Gentics Software GmbH
150
- * aloha-sales@gentics.com
151
- * Licensed unter the terms of http://www.aloha-editor.com/license.html
188
+ * This file is part of Aloha Editor
189
+ * Author & Copyright (c) 2010 Gentics Software GmbH, aloha@gentics.com
190
+ * Licensed unter the terms of http://www.aloha-editor.com/license.html
152
191
  */
153
- GENTICS.Aloha.Ressources.Dummy=new GENTICS.Aloha.Ressource("com.gentics.aloha.resources.Dummy");GENTICS.Aloha.Ressources.Dummy.init=function(){var data=[{id:1,text:"Link A",url:"/page1"},{id:2,text:"Link B",url:"/page2"},{id:3,text:"Link C",url:"/page3"},{id:4,text:"Link D",url:"/page4"}]};GENTICS.Aloha.Ressources.Dummy.query=function(attrs){return this.data};GENTICS.Aloha.Ressources.Dummy.resolve=function(obj){return null};
192
+ GENTICS.Aloha.Repository.Document=function(properties){var p=properties;this.type="document";if(!p.id||!p.name||!p.repositoryId){return}GENTICS.Utils.applyProperties(this,properties);this.baseType="document"};GENTICS.Aloha.Repository.Folder=function(properties){var p=properties;this.type="folder";if(!p.id||!p.name||!p.repositoryId){return}GENTICS.Utils.applyProperties(this,properties);this.baseType="folder"};