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
@@ -0,0 +1,7 @@
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
6
+ */
7
+ GENTICS.Aloha.PastePlugin.WordPasteHandler=new GENTICS.Aloha.PastePlugin.PasteHandler();GENTICS.Aloha.PastePlugin.WordPasteHandler.handlePaste=function(jqPasteDiv){if(this.detectWordContent(jqPasteDiv)){this.transformWordContent(jqPasteDiv)}};GENTICS.Aloha.PastePlugin.WordPasteHandler.detectWordContent=function(jqPasteDiv){var wordDetected=false;jqPasteDiv.find("*").each(function(){var style=jQuery(this).attr("style");if(style){if(style.toLowerCase().indexOf("mso")>=0){wordDetected=true;return false}}var clazz=jQuery(this).attr("class");if(clazz){if(clazz.toLowerCase().indexOf("mso")>=0){wordDetected=true;return false}}});return wordDetected};GENTICS.Aloha.PastePlugin.WordPasteHandler.isOrderedList=function(listSpan){if(listSpan.css("fontFamily")=="Wingdings"||listSpan.css("fontFamily")=="Symbol"){return false}return listSpan.text().match(/^([0-9]{1,3}\.)|([0-9]{1,3}\)|([a-zA-Z]{1,5}\.)|([a-zA-Z]{1,5}\)))$/)?true:false};GENTICS.Aloha.PastePlugin.WordPasteHandler.transformListsFromWord=function(jqPasteDiv){var that=this;var listElementClass="aloha-list-element";var bulletClass="aloha-list-bullet";var detectionFilter="p.MsoListParagraphCxSpFirst,p.MsoListParagraph,p span";var paragraphs=jqPasteDiv.find(detectionFilter);paragraphs.each(function(){var jqElem=jQuery(this);if(jqElem.hasClass("MsoListParagraphCxSpFirst")||jqElem.hasClass("MsoListParagraph")){jqElem.addClass(listElementClass)}else{if(jqElem.css("font-family").indexOf("Symbol")>=0){jqElem.closest("p").addClass(listElementClass)}else{if(jqElem.css("mso-list")!=""){jqElem.closest("p").addClass(listElementClass)}}}});detectionFilter="p span span span";var spans=jqPasteDiv.find(detectionFilter);spans.each(function(){var jqElem=jQuery(this);var innerText=jqElem.text().trim().replace(/&nbsp;/g,"");if(innerText.length==0){var outerText=jqElem.parent().parent().text().trim().replace(/&nbsp;/g,"");if(outerText.match(/^([0-9]{1,3}\.)|([0-9]{1,3}\)|([a-zA-Z]{1,5}\.)|([a-zA-Z]{1,5}\)))$/)){jqElem.closest("p").addClass(listElementClass);jqElem.parent().parent().addClass(bulletClass)}}});detectionFilter="p."+listElementClass;var negateDetectionFilter=":not("+detectionFilter+")";paragraphs=jqPasteDiv.find(detectionFilter);if(paragraphs.length>0){paragraphs.each(function(){var jqElem=jQuery(this);jqElem.removeClass(listElementClass);jqElem.find("font").each(function(){jQuery(this).contents().unwrap()});var nestLevel=0;var margin=parseFloat(jqElem.css("marginLeft"));var lists=[];var following=jqElem.nextUntil(negateDetectionFilter);var firstSpan=jQuery(jqElem.find("span."+bulletClass));if(firstSpan.length==0){firstSpan=jQuery(jqElem.children("span:first"))}var ordered=that.isOrderedList(firstSpan);firstSpan.remove();var jqList=jQuery(ordered?"<ol></ol>":"<ul></ul>");lists.push(jqList);var jqNewLi=jQuery("<li></li>");jqList.append(jqNewLi);jqElem.contents().appendTo(jqNewLi);jqElem.replaceWith(jqList);following.each(function(){var jqElem=jQuery(this);jqElem.find("font").each(function(){jQuery(this).contents().unwrap()});var newMargin=parseFloat(jqElem.css("marginLeft"));firstSpan=jQuery(jqElem.find("span."+bulletClass));if(firstSpan.length==0){firstSpan=jQuery(jqElem.children("span:first"))}ordered=that.isOrderedList(firstSpan);firstSpan.remove();if(newMargin>margin){var jqNewList=jQuery(ordered?"<ol></ol>":"<ul></ul>");jqList.children(":last").append(jqNewList);jqList=jqNewList;lists.push(jqList);nestLevel++;margin=newMargin}else{if(newMargin<margin&&nestLevel>0){lists.pop();nestLevel--;jqList=lists[nestLevel];margin=newMargin}}jqNewLi=jQuery("<li></li>");jqList.append(jqNewLi);jqElem.contents().appendTo(jqNewLi);jqElem.remove()})})}};GENTICS.Aloha.PastePlugin.WordPasteHandler.transformTitles=function(jqPasteDiv){jqPasteDiv.find("p.MsoTitle").each(function(){GENTICS.Aloha.Markup.transformDomObject(jQuery(this),"h1")});jqPasteDiv.find("p.MsoSubtitle").each(function(){GENTICS.Aloha.Markup.transformDomObject(jQuery(this),"h2")})};GENTICS.Aloha.PastePlugin.WordPasteHandler.transformTables=function(jqPasteDiv){jqPasteDiv.find("table").each(function(){jQuery(this).removeAttr("border").removeAttr("cellspacing").removeAttr("cellpadding")});jqPasteDiv.find("td").each(function(){jQuery(this).removeAttr("width").removeAttr("height").removeAttr("valign")})};GENTICS.Aloha.PastePlugin.WordPasteHandler.transformFormattings=function(jqPasteDiv){jqPasteDiv.find("strong,em,s,u").each(function(){if(this.nodeName.toLowerCase()=="strong"){GENTICS.Aloha.Markup.transformDomObject(jQuery(this),"b")}else{if(this.nodeName.toLowerCase()=="em"){GENTICS.Aloha.Markup.transformDomObject(jQuery(this),"i")}else{if(this.nodeName.toLowerCase()=="s"){GENTICS.Aloha.Markup.transformDomObject(jQuery(this),"del")}else{if(this.nodeName.toLowerCase()=="u"){jQuery(this).contents().unwrap()}}}}})};GENTICS.Aloha.PastePlugin.WordPasteHandler.removeComments=function(jqPasteDiv){jqPasteDiv.contents().each(function(){if(this.nodeType==8){jQuery(this).remove()}})};GENTICS.Aloha.PastePlugin.WordPasteHandler.unwrapTags=function(jqPasteDiv){jqPasteDiv.find("span,font,div").each(function(){jQuery(this).contents().unwrap()})};GENTICS.Aloha.PastePlugin.WordPasteHandler.removeStyles=function(jqPasteDiv){jqPasteDiv.find("*").each(function(){jQuery(this).removeAttr("style").removeClass()})};GENTICS.Aloha.PastePlugin.WordPasteHandler.removeNamespacedElements=function(jqPasteDiv){jqPasteDiv.find("*").each(function(){var nsPrefix=this.prefix?this.prefix:(this.scopeName?this.scopeName:undefined);if(nsPrefix&&nsPrefix!="HTML"){jQuery(this).remove()}})};GENTICS.Aloha.PastePlugin.WordPasteHandler.transformWordContent=function(jqPasteDiv){this.transformListsFromWord(jqPasteDiv);this.transformTables(jqPasteDiv);this.transformTitles(jqPasteDiv);this.removeComments(jqPasteDiv);this.unwrapTags(jqPasteDiv);this.removeStyles(jqPasteDiv);this.removeNamespacedElements(jqPasteDiv);this.transformFormattings(jqPasteDiv)};
@@ -0,0 +1 @@
1
+ button.addtoc.tooltip=Inhaltsverzeichnis
@@ -0,0 +1 @@
1
+ button.addtoc.tooltip=Table of contents
@@ -1 +1 @@
1
- (function(){var deps=GENTICS.Aloha.TOC||{jQuery:jQuery},$=deps.jQuery;function last(a){return a[a.length-1]}function head(a){return a[0]}function tail(a){return a.slice(1)}function indexOf(a,item){return detect(a,function(cmp){return cmp===item})}function detect(a,f){for(var i=0;i<a.length;i++){if(f(a[i])){return a[i]}}return null}function map(a,f){var result=[];for(var i=0;i<a.length;i++){result.push(f(a[i]))}return result}function each(a,f){map(a,f)}var namespace="com.gentics.aloha.plugins.TOC";var TOC=GENTICS.Aloha.TOC=new GENTICS.Aloha.Plugin(namespace);var $containers=null;var allTocs=[];TOC.init=function(){var s=TOC.settings;s.updateInterval=s.updateInterval||5000;TOC.initButtons();TOC.spawn()};TOC.initButtons=function(){TOC.insertTocButton=new GENTICS.Aloha.ui.Button({iconClass:"GENTICS_button GENTICS_button_a",size:"small",onclick:function(){TOC.insertAtSelection($containers)},tooltip:this.i18n("button.addtoc.tooltip"),toggle:false});GENTICS.Aloha.FloatingMenu.addButton("GENTICS.Aloha.continuoustext",this.insertTocButton,GENTICS.Aloha.i18n(GENTICS.Aloha,"floatingmenu.tab.insert"),1)};TOC.register=function($c){$containers=$c};TOC.generateId=function(elemOrText){var validId;if(typeof elemOrText=="object"){validId=$(elemOrText).text().replace(/[^a-zA-Z-]+/g,"-").replace(/^[^a-zA-Z]+/,"")}else{if(elemOrText){validId=elemOrText}}for(var uniquifier=0;;uniquifier++){var uniqueId=validId;if(uniquifier){uniqueId+="-"+uniquifier}var conflict=document.getElementById(uniqueId);if(!conflict||(typeof elemOrText=="object"&&conflict===elemOrText)){return uniqueId}}};TOC.outline=function(ctx){var rootNode=[$()];var potentialParents=[rootNode];TOC.headings(ctx).each(function(){var $heading=$(this);var nodeName=this.nodeName.toLowerCase();var hLevels=["h6","h5","h4","h3","h2","h1"];var currLevel=$.inArray(nodeName,hLevels);var higherEq=hLevels.slice(currLevel).join(",");var $section=$heading.nextUntil(higherEq).andSelf();var node=[$section];var parent=detect(potentialParents,function(parent){var parentSection=parent[0];return !parentSection.length||detect(parentSection,function(sectionElem){return $heading.get(0)===sectionElem||$.contains(sectionElem,$heading.get(0))})});parent.push(node);potentialParents.splice(0,indexOf(potentialParents,parent),node)});return rootNode};TOC.editableContainers=function(){return $(map(GENTICS.Aloha.editables,function(editable){return document.getElementById(editable.getId())}))};TOC.headings=function($ctx){return $ctx.find(":header").add($ctx.filter(":header"))};TOC.anchorFromLinkId=function($ctx,linkId){return linkId?$ctx.find('a[href $= "#'+linkId+'"]'):$()};TOC.linkIdFromAnchor=function($anchor){var href=$anchor.attr("href");return href?href.match(/#(.*?)$/)[1]:null};TOC.insertAtSelection=function($containers){$containers=$containers||TOC.editableContainers();var id=TOC.generateId("toc");var $tocElement=$("<ol class='toc_root'></ol>").attr("id",id);var range=GENTICS.Aloha.Selection.getRangeObject();var tocEditable=GENTICS.Aloha.activeEditable;var $tocContainer=$(document.getElementById(tocEditable.getId()));GENTICS.Utils.Dom.insertIntoDOM($tocElement,range,$tocContainer);TOC.create(id).register($containers).update().tickTock()};TOC.spawn=function($ctx,$containers){$ctx=$ctx||$("body");$containers=$containers||TOC.editableContainers();$ctx.find("ol.toc_root").each(function(){var id=$(this).attr("id");if(!id){id=TOC.generateId("toc");$(this).attr("id",id)}TOC.create(id).register($containers).tickTock()})};TOC.create=function(id){allTocs.push(this);return{id:id,"$containers":$(),root:function(){return $(document.getElementById(this.id))},register:function($containers){var self=this;self.$containers=self.$containers.add($containers);self.$containers.filter(function(){return !$(this).data(namespace+"."+self.id+".listening")}).each(function(){var $container=$(this);$container.data(namespace+"."+self.id+".listening",true);$container.bind("blur",function(){self.cleanupIds($container.get(0));self.update($container)})});return self},tickTock:function(interval){var self=this;interval=interval||TOC.settings.updateInterval;if(!interval){return}window.setInterval(function(){self.update()},interval);return self},cleanupIds:function(ctx){var ids=[];TOC.headings(this.$containers).each(function(){var id=$(this).attr("id");if((id&&-1!=$.inArray(id,ids))||(ctx&&($.contains(ctx,this)||ctx===this))){$(this).attr("id",TOC.generateId(this))}ids.push(id)});return this},update:function($ctx){var self=this;$ctx=$ctx||self.$containers;var outline=TOC.outline(self.$containers);var ancestors=[self.root()];var prevSiblings=[];last(ancestors).empty();(function descend(outline){var prevSiblings=[];each(outline,function(node){var $section=head(node);var $entry=self.linkSection($section,ancestors,prevSiblings);ancestors.push($entry);descend(tail(node));ancestors.pop();prevSiblings.push($entry)})})(tail(outline));return this},linkSection:function($section,ancestors,prevSiblings){var linkId=$section.eq(0).attr("id");if(!linkId){linkId=TOC.generateId($section.get(0));$section.eq(0).attr("id",linkId)}var $root=this.root();var $entry=TOC.anchorFromLinkId($root,linkId);if(!$entry.length){$entry=$("<li><a/></li>")}$entry.find("a").attr("href","#"+linkId).text($section.eq(0).text());if(last(prevSiblings)){last(prevSiblings).after($entry)}else{if(last(ancestors).get(0)==$root.get(0)){$root.append($entry)}else{var $subToc=$("<ol/>").append($entry);last(ancestors).append($subToc)}}return $entry}}}}());
1
+ (function(){var deps=GENTICS.Aloha.TOC||{jQuery:jQuery},$=deps.jQuery;function last(a){return a[a.length-1]}function head(a){return a[0]}function tail(a){return a.slice(1)}function indexOf(a,item){return detect(a,function(cmp){return cmp===item})}function detect(a,f){for(var i=0;i<a.length;i++){if(f(a[i])){return a[i]}}return null}function map(a,f){var result=[];for(var i=0;i<a.length;i++){result.push(f(a[i]))}return result}function each(a,f){map(a,f)}var namespace="com.gentics.aloha.plugins.TOC";var TOC=GENTICS.Aloha.TOC=new GENTICS.Aloha.Plugin(namespace);GENTICS.Aloha.TOC.languages=["en","de"];var $containers=null;var allTocs=[];TOC.init=function(){var s=TOC.settings;s.updateInterval=s.updateInterval||5000;s.minEntries=s.minEntries||0;TOC.initButtons();$(document).ready(function(){TOC.spawn()})};TOC.initButtons=function(){TOC.insertTocButton=new GENTICS.Aloha.ui.Button({iconClass:"GENTICS_button GENTICS_button_ul",size:"small",onclick:function(){TOC.insertAtSelection($containers)},tooltip:this.i18n("button.addtoc.tooltip"),toggle:false});GENTICS.Aloha.FloatingMenu.addButton("GENTICS.Aloha.continuoustext",this.insertTocButton,GENTICS.Aloha.i18n(GENTICS.Aloha,"floatingmenu.tab.insert"),1)};TOC.register=function($c){$containers=$c};TOC.generateId=function(elemOrText){var validId;if(typeof elemOrText=="object"){validId=$(elemOrText).text().replace(/[^a-zA-Z-]+/g,"-").replace(/^[^a-zA-Z]+/,"")}else{if(elemOrText){validId=elemOrText}}for(var uniquifier=0;;uniquifier++){var uniqueId=validId;if(uniquifier){uniqueId+="-"+uniquifier}var conflict=document.getElementById(uniqueId);if(!conflict||(typeof elemOrText=="object"&&conflict===elemOrText)){return uniqueId}}};TOC.outline=function(ctx){var rootNode=[$()];var potentialParents=[rootNode];TOC.headings(ctx).each(function(){var $heading=$(this);var nodeName=this.nodeName.toLowerCase();var hLevels=["h6","h5","h4","h3","h2","h1"];var currLevel=$.inArray(nodeName,hLevels);var higherEq=hLevels.slice(currLevel).join(",");var $section=$heading.nextUntil(higherEq).andSelf();var node=[$section];var parent=detect(potentialParents,function(parent){var parentSection=parent[0];return !parentSection.length||detect(parentSection,function(sectionElem){return $heading.get(0)===sectionElem||$.contains(sectionElem,$heading.get(0))})});parent.push(node);potentialParents.splice(0,indexOf(potentialParents,parent),node)});return rootNode};TOC.editableContainers=function(){return $(map(GENTICS.Aloha.editables,function(editable){return document.getElementById(editable.getId())}))};TOC.headings=function($ctx){return $ctx.find(":header").add($ctx.filter(":header"))};TOC.anchorFromLinkId=function($ctx,linkId){return linkId?$ctx.find('a[href $= "#'+linkId+'"]'):$()};TOC.linkIdFromAnchor=function($anchor){var href=$anchor.attr("href");return href?href.match(/#(.*?)$/)[1]:null};TOC.insertAtSelection=function($containers){$containers=$containers||TOC.editableContainers();var id=TOC.generateId("toc");var $tocElement=$("<ol class='toc_root'></ol>").attr("id",id).attr("contentEditable","false");var range=GENTICS.Aloha.Selection.getRangeObject();var tocEditable=GENTICS.Aloha.activeEditable;var $tocContainer=$(document.getElementById(tocEditable.getId()));GENTICS.Utils.Dom.insertIntoDOM($tocElement,range,$tocContainer);TOC.create(id).register($containers).update().tickTock()};TOC.spawn=function($ctx,$containers){$ctx=$ctx||$("body");$containers=$containers||TOC.editableContainers();$ctx.find("ol.toc_root").each(function(){var id=$(this).attr("id");if(!id){id=TOC.generateId("toc");$(this).attr("id",id)}TOC.create(id).register($containers).tickTock()})};TOC.create=function(id){allTocs.push(this);return{id:id,"$containers":$(),root:function(){return $(document.getElementById(this.id))},register:function($containers){var self=this;self.$containers=self.$containers.add($containers);self.$containers.filter(function(){return !$(this).data(namespace+"."+self.id+".listening")}).each(function(){var $container=$(this);$container.data(namespace+"."+self.id+".listening",true);$container.bind("blur",function(){self.cleanupIds($container.get(0));self.update($container)})});return self},tickTock:function(interval){var self=this;interval=interval||TOC.settings.updateInterval;if(!interval){return}window.setInterval(function(){self.register(TOC.editableContainers());self.update()},interval);return self},cleanupIds:function(ctx){var ids=[];TOC.headings(this.$containers).each(function(){var id=$(this).attr("id");if((id&&-1!=$.inArray(id,ids))||(ctx&&($.contains(ctx,this)||ctx===this))){$(this).attr("id",TOC.generateId(this))}ids.push(id)});return this},update:function($ctx){var self=this;$ctx=$ctx||self.$containers;var outline=TOC.outline(self.$containers);var ancestors=[self.root()];var prevSiblings=[];last(ancestors).empty();(function descend(outline){var prevSiblings=[];each(outline,function(node){var $section=head(node);var $entry=self.linkSection($section,ancestors,prevSiblings);ancestors.push($entry);descend(tail(node));ancestors.pop();prevSiblings.push($entry)})})(tail(outline));var minEntries=self.root().attr("data-TOC-minEntries")||TOC.settings.minEntries;if(self.root().find("li").length>=minEntries){self.root().show()}else{self.root().hide()}return this},linkSection:function($section,ancestors,prevSiblings){var linkId=$section.eq(0).attr("id");if(!linkId){linkId=TOC.generateId($section.get(0));$section.eq(0).attr("id",linkId)}var $root=this.root();var $entry=TOC.anchorFromLinkId($root,linkId);if(!$entry.length){$entry=$("<li><a/></li>")}$entry.find("a").attr("href","#"+linkId).text($section.eq(0).text());if(last(prevSiblings)){last(prevSiblings).after($entry)}else{if(last(ancestors).get(0)==$root.get(0)){$root.append($entry)}else{var $subToc=$("<ol/>").append($entry);last(ancestors).append($subToc)}}return $entry}}}}());
@@ -10,3 +10,5 @@ button.delcols.tooltip=Spalten löschen
10
10
  button.addrowbefore.tooltip=Zeile darüber einfügen
11
11
  button.addrowafter.tooltip=Zeile darunter einfügen
12
12
  button.delrows.tooltip=Zeilen löschen
13
+ button.caption.tooltip=Tabellen Bezeichnung
14
+ empty.caption=Tabellen Bezeichnung
@@ -10,3 +10,5 @@ button.delcols.tooltip=Delete Columns
10
10
  button.addrowbefore.tooltip=Add Row before
11
11
  button.addrowafter.tooltip=Add Row after
12
12
  button.delrows.tooltip=Delete Rows
13
+ button.caption.tooltip=Table caption
14
+ empty.caption=Table caption
@@ -0,0 +1,12 @@
1
+ floatingmenu.tab.table=Tabela
2
+ deleterows.confirm=Czy na pewno chcesz usunąć zaznaczone wiersze?
3
+ deletecolumns.confirm=Czy na pewno chcesz usunąć zaznaczone kolumny?
4
+ deletetable.confirm=Czy na pewno chcesz usunąć tabelę?
5
+ Table=Tabela
6
+ button.createtable.tooltip=Wstaw tabelę
7
+ button.addcolleft.tooltip=Dodaj kolumnę na lewo
8
+ button.addcolright.tooltip=Dodaj kolumnę na prawo
9
+ button.delcols.tooltip=Usuń kolumny
10
+ button.addrowbefore.tooltip=Dodaj wiersz przed
11
+ button.addrowafter.tooltip=Dodaj wiersz po
12
+ button.delrows.tooltip=Usuń wiersze
@@ -4,4 +4,4 @@
4
4
  * aloha-sales@gentics.com
5
5
  * Licensed unter the terms of http://www.aloha-editor.com/license.html
6
6
  */
7
- GENTICS.Aloha.TablePlugin=new GENTICS.Aloha.Plugin("com.gentics.aloha.plugins.Table");GENTICS.Aloha.TablePlugin.createLayer=undefined;GENTICS.Aloha.TablePlugin.languages=["en","de","fr","eo","fi","ru","it"];GENTICS.Aloha.TablePlugin.config=["table"];GENTICS.Aloha.TablePlugin.TableRegistry=new Array();GENTICS.Aloha.TablePlugin.activeTable=undefined;GENTICS.Aloha.TablePlugin.parameters={className:"GENTICS_Aloha_Table",classSelectionRow:"GENTICS_Aloha_Table_selectColumn",classSelectionColumn:"GENTICS_Aloha_Table_selectRow",classLeftUpperCorner:"GENTICS_Aloha_Table_leftUpperCorner",classTableWrapper:"GENTICS_Aloha_Table_wrapper",classCellSelected:"GENTICS_Aloha_Cell_selected",selectionArea:10};GENTICS.Aloha.TablePlugin.config=new Object();GENTICS.Aloha.TablePlugin.init=function(){this.createLayer=new GENTICS.Aloha.Table.CreateLayer();var that=this;GENTICS.Aloha.EventRegistry.subscribe(GENTICS.Aloha,"editableCreated",function(event,editable){editable.obj.bind("mousedown",function(jqEvent){GENTICS.Aloha.TablePlugin.setFocusedTable(undefined)});editable.obj.find("table").each(function(){if(that.isEditableTable(this)){var table=new GENTICS.Aloha.Table(this);table.parentEditable=editable;table.activate();GENTICS.Aloha.TablePlugin.TableRegistry.push(table)}})});this.initTableButtons();GENTICS.Aloha.EventRegistry.subscribe(GENTICS.Aloha,"selectionChanged",function(event,properties){if(GENTICS.Aloha.activeEditable){var config=that.getEditableConfig(GENTICS.Aloha.activeEditable.obj);if(jQuery.inArray("table",config)!=-1&&GENTICS.Aloha.Selection.mayInsertTag("table")){that.createTableButton.show()}else{that.createTableButton.hide()}if(typeof GENTICS.Aloha.TableHelper.selectionType!=undefined){GENTICS.Aloha.FloatingMenu.setScope(that.getUID(GENTICS.Aloha.TableHelper.selectionType))}GENTICS.Aloha.FloatingMenu.doLayout()}});GENTICS.Aloha.EventRegistry.subscribe(GENTICS.Aloha,"editableDeactivated",function(event,properties){GENTICS.Aloha.TablePlugin.setFocusedTable(undefined);GENTICS.Aloha.TableHelper.unselectCells()})};GENTICS.Aloha.TablePlugin.isEditableTable=function(table){var parent=jQuery(table.parentNode);if(parent.attr("contenteditable")=="true"){return true}else{return false}};GENTICS.Aloha.TablePlugin.initTableButtons=function(){var that=this;this.createTableButton=new GENTICS.Aloha.ui.Button({iconClass:"GENTICS_button GENTICS_button_table",size:"small",tooltip:this.i18n("button.createtable.tooltip"),onclick:function(element,event){GENTICS.Aloha.TablePlugin.createDialog(element.btnEl.dom)}});GENTICS.Aloha.FloatingMenu.addButton("GENTICS.Aloha.continuoustext",this.createTableButton,GENTICS.Aloha.i18n(GENTICS.Aloha,"floatingmenu.tab.insert"),1);GENTICS.Aloha.FloatingMenu.createScope(this.getUID("row"),"GENTICS.Aloha.global");GENTICS.Aloha.FloatingMenu.createScope(this.getUID("column"),"GENTICS.Aloha.global");GENTICS.Aloha.FloatingMenu.addButton(this.getUID("column"),new GENTICS.Aloha.ui.Button({iconClass:"GENTICS_button GENTICS_button_addColumnLeft",size:"small",tooltip:this.i18n("button.addcolleft.tooltip"),onclick:function(){if(that.activeTable){that.activeTable.addColumnsLeft()}}}),GENTICS.Aloha.i18n(this,"floatingmenu.tab.table"),1);GENTICS.Aloha.FloatingMenu.addButton(this.getUID("column"),new GENTICS.Aloha.ui.Button({iconClass:"GENTICS_button GENTICS_button_addColumnRight",size:"small",tooltip:this.i18n("button.addcolright.tooltip"),onclick:function(){if(that.activeTable){that.activeTable.addColumnsRight()}}}),GENTICS.Aloha.i18n(this,"floatingmenu.tab.table"),1);GENTICS.Aloha.FloatingMenu.addButton(this.getUID("column"),new GENTICS.Aloha.ui.Button({iconClass:"GENTICS_button GENTICS_button_deleteColumns",size:"small",tooltip:this.i18n("button.delcols.tooltip"),onclick:function(){if(that.activeTable){var aTable=that.activeTable;GENTICS.Aloha.showMessage(new GENTICS.Aloha.Message({title:GENTICS.Aloha.i18n(that,"Table"),text:GENTICS.Aloha.i18n(that,"deletecolumns.confirm"),type:GENTICS.Aloha.Message.Type.CONFIRM,callback:function(sel){if(sel=="yes"){aTable.deleteColumns()}}}))}}}),GENTICS.Aloha.i18n(this,"floatingmenu.tab.table"),1);GENTICS.Aloha.FloatingMenu.addButton(this.getUID("row"),new GENTICS.Aloha.ui.Button({iconClass:"GENTICS_button GENTICS_button_addRowBefore",size:"small",tooltip:this.i18n("button.addrowbefore.tooltip"),onclick:function(){if(that.activeTable){that.activeTable.addRowsBefore(true)}}}),GENTICS.Aloha.i18n(this,"floatingmenu.tab.table"),1);GENTICS.Aloha.FloatingMenu.addButton(this.getUID("row"),new GENTICS.Aloha.ui.Button({iconClass:"GENTICS_button GENTICS_button_addRowAfter",size:"small",tooltip:this.i18n("button.addrowafter.tooltip"),onclick:function(){if(that.activeTable){that.activeTable.addRowsAfter(true)}}}),GENTICS.Aloha.i18n(this,"floatingmenu.tab.table"),1);GENTICS.Aloha.FloatingMenu.addButton(this.getUID("row"),new GENTICS.Aloha.ui.Button({iconClass:"GENTICS_button GENTICS_button_deleteRows",size:"small",tooltip:this.i18n("button.delrows.tooltip"),onclick:function(){if(that.activeTable){var aTable=that.activeTable;GENTICS.Aloha.showMessage(new GENTICS.Aloha.Message({title:GENTICS.Aloha.i18n(that,"Table"),text:GENTICS.Aloha.i18n(that,"deleterows.confirm"),type:GENTICS.Aloha.Message.Type.CONFIRM,callback:function(sel){if(sel=="yes"){aTable.deleteRows()}}}))}}}),GENTICS.Aloha.i18n(this,"floatingmenu.tab.table"),1)};GENTICS.Aloha.TablePlugin.createDialog=function(callingElement){this.createLayer.set("target",callingElement);this.createLayer.show()};GENTICS.Aloha.TablePlugin.createTable=function(cols,rows){if(GENTICS.Aloha.activeEditable!=null&&typeof GENTICS.Aloha.activeEditable.obj!="undefined"){var table=document.createElement("table");var tableId=table.id=GENTICS.Aloha.TableHelper.getNewTableID();var tbody=document.createElement("tbody");for(var i=0;i<rows;i++){var tr=document.createElement("tr");for(var j=0;j<cols;j++){var text=document.createTextNode("\u00a0");var td=document.createElement("td");td.appendChild(text);tr.appendChild(td)}tbody.appendChild(tr)}table.appendChild(tbody);GENTICS.Utils.Dom.insertIntoDOM(jQuery(table),GENTICS.Aloha.Selection.getRangeObject(),jQuery(GENTICS.Aloha.activeEditable.obj));var tableReloadedFromDOM=document.getElementById(tableId);var tableObj=new GENTICS.Aloha.Table(tableReloadedFromDOM);tableObj.parentEditable=GENTICS.Aloha.activeEditable;tableObj.activate();if(jQuery.browser.msie){window.setTimeout(function(){tableObj.cells[0].wrapper.get(0).focus()},20)}else{tableObj.cells[0].wrapper.get(0).focus()}GENTICS.Aloha.TablePlugin.TableRegistry.push(tableObj)}else{this.error("There is no active Editable where the table can be inserted!")}};GENTICS.Aloha.TablePlugin.setFocusedTable=function(focusTable){for(var i=0;i<GENTICS.Aloha.TablePlugin.TableRegistry.length;i++){GENTICS.Aloha.TablePlugin.TableRegistry[i].hasFocus=false}if(typeof focusTable!="undefined"){focusTable.hasFocus=true}GENTICS.Aloha.TablePlugin.activeTable=focusTable};GENTICS.Aloha.TablePlugin.error=function(msg){GENTICS.Aloha.Log.error(this,msg)};GENTICS.Aloha.TablePlugin.debug=function(msg){GENTICS.Aloha.Log.debug(this,msg)};GENTICS.Aloha.TablePlugin.info=function(msg){GENTICS.Aloha.Log.info(this,msg)};GENTICS.Aloha.TablePlugin.log=function(msg){GENTICS.Aloha.log("log",this,msg)};GENTICS.Aloha.TablePlugin.get=function(property){if(this.config[property]){return this.config[property]}if(this.parameters[property]){return this.parameters[property]}return undefined};GENTICS.Aloha.TablePlugin.set=function(key,value){if(this.config[key]){this.config[key]=value}else{this.parameters[key]=value}};GENTICS.Aloha.TablePlugin.makeClean=function(obj){obj.find("table").each(function(){var table=new GENTICS.Aloha.Table(this);table.deactivate()})};GENTICS.Aloha.TablePlugin.toString=function(){return this.prefix};GENTICS.Aloha.Table=function(table){this.obj=jQuery(table);var rows=this.obj.find("tr");var firstRow=jQuery(rows.get(0));this.numCols=firstRow.children("td, th").length;this.numRows=rows.length;this.cells=new Array();var rows=this.obj.find("tr");for(var i=0;i<rows.length;i++){var row=jQuery(rows[i]);var cols=row.children();for(var j=0;j<cols.length;j++){var col=cols[j];var Cell=new GENTICS.Aloha.Table.Cell(col,this);this.cells.push(Cell)}}};GENTICS.Aloha.Table.prototype.obj=undefined;GENTICS.Aloha.Table.prototype.tableWrapper=undefined;GENTICS.Aloha.Table.prototype.cells=undefined;GENTICS.Aloha.Table.prototype.numRows=undefined;GENTICS.Aloha.Table.prototype.numCols=undefined;GENTICS.Aloha.Table.prototype.isActive=false;GENTICS.Aloha.Table.prototype.hasFocus=false;GENTICS.Aloha.Table.prototype.parentEditable=undefined;GENTICS.Aloha.Table.prototype.mousedown=false;GENTICS.Aloha.Table.prototype.clickedColumnId=-1;GENTICS.Aloha.Table.prototype.clickedRowId=-1;GENTICS.Aloha.Table.prototype.columnsToSelect=new Array();GENTICS.Aloha.Table.prototype.rowsToSelect=new Array();GENTICS.Aloha.Table.prototype.fmPluginId=undefined;GENTICS.Aloha.Table.prototype.get=function(property){return GENTICS.Aloha.TablePlugin.get(property)};GENTICS.Aloha.Table.prototype.set=function(key,value){GENTICS.Aloha.TablePlugin.set(key,value)};GENTICS.Aloha.Table.prototype.activate=function(){if(this.isActive){return}var that=this;this.obj.addClass(this.get("className"));this.obj.attr("contenteditable","false");if(this.obj.attr("id")==""){this.obj.attr("id",GENTICS.Aloha.TableHelper.getNewTableID())}GENTICS.Aloha.TableHelper.selectionType=undefined;this.obj.bind("keydown",function(jqEvent){if(!jqEvent.ctrlKey&&!jqEvent.shiftKey){if(GENTICS.Aloha.TableHelper.selectedCells.length>0&&GENTICS.Aloha.TableHelper.selectedCells[0].length>0){GENTICS.Aloha.TableHelper.selectedCells[0][0].firstChild.focus()}}});this.obj.bind("click",function(e){e.stopPropagation();return false});this.obj.bind("mousedown",function(jqEvent){if(!that.hasFocus){that.focus()}setTimeout(function(){var firstCell=that.obj.find("tr:nth-child(2) td:nth-child(2)").children("div[contenteditable=true]").get(0);GENTICS.Aloha.TableHelper.unselectCells();jQuery(firstCell).get(0).focus()},5);jqEvent.stopPropagation();jqEvent.preventDefault();return false});var tableWrapper=jQuery('<div class="'+this.get("classTableWrapper")+'" contenteditable="false"></div>');this.obj.wrap(tableWrapper);var htmlTableWrapper=this.obj.parents("."+this.get("classTableWrapper"));htmlTableWrapper.get(0).onresizestart=function(e){return false};htmlTableWrapper.get(0).oncontrolselect=function(e){return false};this.tableWrapper=this.obj.parents("."+this.get("classTableWrapper")).get(0);jQuery(this.cells).each(function(){this.activate()});this.attachSelectionColumn();this.attachSelectionRow();this.attachLastCellEvents();this.isActive=true;GENTICS.Aloha.EventRegistry.trigger(new GENTICS.Aloha.Event("tableActivated",GENTICS.Aloha,[this]))};GENTICS.Aloha.Table.prototype.attachSelectionColumn=function(){var emptyCell=jQuery("<td>");emptyCell.html("\u00a0");var that=this;var rows=this.obj.context.rows;for(var i=0;i<rows.length;i++){var rowObj=jQuery(rows[i]);var columnToInsert=emptyCell.clone();columnToInsert.addClass(this.get("classSelectionColumn"));columnToInsert.css("width",this.get("selectionArea")+"px");rowObj.find("td:first").before(columnToInsert);var rowIndex=i+1;this.attachRowSelectionEventsToCell(columnToInsert)}};GENTICS.Aloha.Table.prototype.attachRowSelectionEventsToCell=function(cell){var that=this;cell.unbind("mousedown");cell.unbind("mouseover");cell.get(0).onselectstart=function(){return false};cell.bind("mousedown",function(e){that.rowSelectionMouseDown(e);that.focus();e.stopPropagation()});cell.bind("mouseover",function(e){that.rowSelectionMouseOver(e);e.preventDefault()})};GENTICS.Aloha.Table.prototype.rowSelectionMouseDown=function(jqEvent){this.mousedown=true;if(GENTICS.Aloha.TableHelper.selectedCells.length==0){this.rowsToSelect=new Array()}this.clickedRowId=jqEvent.currentTarget.parentNode.rowIndex;if(jqEvent.ctrlKey){var arrayIndex=jQuery.inArray(this.clickedRowId,this.rowsToSelect);if(arrayIndex>=0){this.rowsToSelect.splice(arrayIndex,1)}else{this.rowsToSelect.push(this.clickedRowId)}}else{if(jqEvent.shiftKey){this.rowsToSelect.sort(function(a,b){return a-b});var start=this.rowsToSelect[0];var end=this.clickedRowId;if(start>end){start=end;end=this.rowsToSelect[0]}this.rowsToSelect=new Array();for(var i=start;i<=end;i++){this.rowsToSelect.push(i)}}else{this.rowsToSelect=[this.clickedRowId]}}this.selectRows();jqEvent.preventDefault()};GENTICS.Aloha.Table.prototype.rowSelectionMouseOver=function(jqEvent){var rowIndex=jqEvent.currentTarget.parentNode.rowIndex;if(this.mousedown&&this.clickedRowId>=0){var indexInArray=jQuery.inArray(rowIndex,this.rowsToSelect);var start=(rowIndex<this.clickedRowId)?rowIndex:this.clickedRowId;var end=(rowIndex<this.clickedRowId)?this.clickedRowId:rowIndex;this.rowsToSelect=new Array();for(var i=start;i<=end;i++){this.rowsToSelect.push(i)}this.selectRows()}};GENTICS.Aloha.Table.prototype.attachSelectionRow=function(){var that=this;var emptyCell=jQuery("<td>");emptyCell.html("\u00a0");var numColumns=this.obj.context.rows[0].cells.length;var selectionRow=jQuery("<tr>");selectionRow.addClass(this.get("classSelectionRow"));selectionRow.css("height",this.get("selectionArea")+"px");for(var i=0;i<numColumns;i++){var columnToInsert=emptyCell.clone();if(i>0){this.attachColumnSelectEventsToCell(columnToInsert)}selectionRow.append(columnToInsert)}jQuery(document).bind("mouseup",function(e){that.mousedown=false;that.clickedColumnId=-1;that.clickedRowId=-1});selectionRow.find("td:first").addClass(this.get("classLeftUpperCorner"));this.obj.find("tr:first").before(selectionRow)};GENTICS.Aloha.Table.prototype.attachColumnSelectEventsToCell=function(cell){var that=this;cell.unbind("mousedown");cell.unbind("mouseover");cell.get(0).onselectstart=function(){return false};cell.bind("mousedown",function(e){that.columnSelectionMouseDown(e);that.focus();e.stopPropagation();return false});cell.bind("mouseover",function(e){that.columnSelectionMouseOver(e)})};GENTICS.Aloha.Table.prototype.columnSelectionMouseDown=function(jqEvent){this.mousedown=true;if(GENTICS.Aloha.TableHelper.selectedCells.length==0){this.columnsToSelect=new Array()}this.clickedColumnId=jqEvent.currentTarget.cellIndex;if(jqEvent.ctrlKey){var arrayIndex=jQuery.inArray(this.clickedColumnId,this.columnsToSelect);if(arrayIndex>=0){this.columnsToSelect.splice(arrayIndex,1)}else{this.columnsToSelect.push(this.clickedColumnId)}}else{if(jqEvent.shiftKey){this.columnsToSelect.sort(function(a,b){return a-b});var start=this.columnsToSelect[0];var end=this.clickedColumnId;if(start>end){start=end;end=this.columnsToSelect[0]}this.columnsToSelect=new Array();for(var i=start;i<=end;i++){this.columnsToSelect.push(i)}}else{this.columnsToSelect=[this.clickedColumnId]}}this.selectColumns();jqEvent.preventDefault()};GENTICS.Aloha.Table.prototype.columnSelectionMouseOver=function(jqEvent){var colIndex=jqEvent.currentTarget.cellIndex;if(this.mousedown&&this.clickedColumnId>0){var indexInArray=jQuery.inArray(colIndex,this.columnsToSelect);var start=(colIndex<this.clickedColumnId)?colIndex:this.clickedColumnId;var end=(colIndex<this.clickedColumnId)?this.clickedColumnId:colIndex;this.columnsToSelect=new Array();for(var i=start;i<=end;i++){this.columnsToSelect.push(i)}this.selectColumns()}};GENTICS.Aloha.Table.prototype.releaseLastCellEvents=function(){this.obj.find("tr:last td:last").unbind()};GENTICS.Aloha.Table.prototype.attachLastCellEvents=function(){var that=this;this.obj.find("tr:last td:last").bind("keydown",function(jqEvent){that.lastCellKeyDown(jqEvent)})};GENTICS.Aloha.Table.prototype.lastCellKeyDown=function(jqEvent){var KEYCODE_TAB=9;if(KEYCODE_TAB==jqEvent.keyCode&&!jqEvent.altKey&&!jqEvent.shiftKey&&!jqEvent.ctrlKey){this.addRowsAfter(false);jqEvent.stopPropagation();if(jQuery.browser.msie){this.obj.find("tr:last td:nth-child(1) div.GENTICS_Table_Cell_editable").get(0).focus();return false}}};GENTICS.Aloha.Table.prototype.deleteRows=function(){var rowIDs=new Array();var deleteTable=false;if(GENTICS.Aloha.TableHelper.selectedCells.length>0){for(var i=0;i<GENTICS.Aloha.TableHelper.selectedCells.length;i++){rowIDs.push(GENTICS.Aloha.TableHelper.selectedCells[i][0].parentNode.rowIndex)}}else{if(typeof GENTICS.Aloha.Table.Cell.lastActiveCell!="undefined"){rowIDs.push(GENTICS.Aloha.Table.Cell.lastActiveCell.obj.context.parentNode.rowIndex)}}if(rowIDs.length==this.numRows){deleteTable=true}if(deleteTable){var that=this;GENTICS.Aloha.showMessage(new GENTICS.Aloha.Message({title:GENTICS.Aloha.i18n(GENTICS.Aloha.TablePlugin,"Table"),text:GENTICS.Aloha.i18n(GENTICS.Aloha.TablePlugin,"deletetable.confirm"),type:GENTICS.Aloha.Message.Type.CONFIRM,callback:function(sel){if(sel=="yes"){that.deleteTable()}}}))}else{rowIDs.sort(function(a,b){return a-b});var focusRowId=rowIDs[0];if(focusRowId>(this.numRows-rowIDs.length)){focusRowId--}this.releaseLastCellEvents();var rows=this.obj.find("tr");var rows2delete=new Array();for(var i=0;i<rowIDs.length;i++){rows2delete.push(jQuery(rows[rowIDs[i]]))}for(var i=0;i<rows2delete.length;i++){var cols=rows2delete[i].children("td").toArray();for(var j=0;j<cols.length;j++){for(var m=0;m<this.cells.length;m++){if(cols[j]==this.cells[m].obj.get(0)){this.cells.splice(m,1);m=this.cells.length}}}}for(var i=0;i<rows2delete.length;i++){rows2delete[i].remove()}this.numRows-=rows2delete.length;if(jQuery.browser.msie){setTimeout(this.obj.find("tr:nth-child("+(focusRowId+1)+") td:nth-child(2) div.GENTICS_Table_Cell_editable").get(0).focus,5)}else{this.obj.find("tr:nth-child("+(focusRowId+1)+") td:nth-child(2) div.GENTICS_Table_Cell_editable").get(0).focus()}this.attachLastCellEvents();GENTICS.Aloha.TableHelper.unselectCells()}};GENTICS.Aloha.Table.prototype.deleteColumns=function(){var colIDs=new Array();var deleteTable=false;if(GENTICS.Aloha.TableHelper.selectedCells.length>0){for(var i=0;i<GENTICS.Aloha.TableHelper.selectedCells[0].length;i++){colIDs.push(GENTICS.Aloha.TableHelper.selectedCells[0][i].cellIndex)}}else{if(typeof GENTICS.Aloha.Table.Cell.lastActiveCell!="undefined"){colIDs.push(GENTICS.Aloha.Table.Cell.lastActiveCell.obj.context.cellIndex)}}if(colIDs.length==this.numCols){deleteTable=true}if(deleteTable){var that=this;GENTICS.Aloha.showMessage(new GENTICS.Aloha.Message({title:GENTICS.Aloha.i18n(GENTICS.Aloha.TablePlugin,"Table"),text:GENTICS.Aloha.i18n(GENTICS.Aloha.TablePlugin,"deletetable.confirm"),type:GENTICS.Aloha.Message.Type.CONFIRM,callback:function(sel){if(sel=="yes"){that.deleteTable()}}}))}else{colIDs.sort(function(a,b){return a-b});var focusColID=colIDs[0];if(focusColID>(this.numCols-colIDs.length)){focusColID--}this.releaseLastCellEvents();var rows=this.obj.find("tr");var cols2delete=new Array();for(var i=0;i<rows.length;i++){var cells=jQuery(rows[i]).children("td").toArray();for(var j=0;j<colIDs.length;j++){cols2delete.push(cells[colIDs[j]])}}for(var i=0;i<cols2delete.length;i++){for(var j=0;j<this.cells.length;j++){if(cols2delete[i]==this.cells[j].obj.get(0)){this.cells.splice(j,1);j=this.cells.length}}}for(var i=0;i<cols2delete.length;i++){jQuery(cols2delete[i]).remove()}this.numCols-=colIDs.length;if(jQuery.browser.msie){setTimeout(this.obj.find("tr:nth-child(2) td:nth-child("+(focusColID+1)+") div.GENTICS_Table_Cell_editable").get(0).focus,5)}else{this.obj.find("tr:nth-child(2) td:nth-child("+(focusColID+1)+") div.GENTICS_Table_Cell_editable").get(0).focus()}this.attachLastCellEvents();GENTICS.Aloha.TableHelper.unselectCells()}};GENTICS.Aloha.Table.prototype.deleteTable=function(){var deleteIndex=-1;for(var i=0;i<GENTICS.Aloha.TablePlugin.TableRegistry.length;i++){if(GENTICS.Aloha.TablePlugin.TableRegistry[i].obj.attr("id")==this.obj.attr("id")){deleteIndex=i;break}}if(deleteIndex>=0){this.deactivate();GENTICS.Aloha.TableHelper.selectionType=undefined;GENTICS.Aloha.TablePlugin.TableRegistry.splice(i,1);var newRange=GENTICS.Aloha.Selection.rangeObject;newRange.startContainer=newRange.endContainer=this.obj.get(0).parentNode;newRange.startOffset=newRange.endOffset=GENTICS.Utils.Dom.getIndexInParent(this.obj.get(0).parentNode);newRange.clearCaches();this.obj.remove();this.parentEditable.obj.focus();newRange.correctRange();newRange.select()}};GENTICS.Aloha.Table.prototype.addRowsBefore=function(highlightNewRows){this.addRows("before",highlightNewRows)};GENTICS.Aloha.Table.prototype.addRowsAfter=function(highlightNewRows){this.addRows("after",highlightNewRows)};GENTICS.Aloha.Table.prototype.addRows=function(position,highlightNewRows){if(typeof GENTICS.Aloha.TablePlugin.activeTable!="undefined"){this.releaseLastCellEvents();var that=this;var numCols=this.numCols;var rowsToInsert=1;var rowId=1;if(GENTICS.Aloha.TableHelper.selectedCells.length>0){rowsToInsert=GENTICS.Aloha.TableHelper.selectedCells.length;switch(position){case"before":if(GENTICS.Aloha.TableHelper.selectedCells[0].length){rowId=GENTICS.Aloha.TableHelper.selectedCells[0][0].parentNode.rowIndex}break;case"after":var lastRow=GENTICS.Aloha.TableHelper.selectedCells.length-1;if(GENTICS.Aloha.TableHelper.selectedCells[lastRow].length){rowId=GENTICS.Aloha.TableHelper.selectedCells[lastRow][0].parentNode.rowIndex}break}}else{if(typeof GENTICS.Aloha.Table.Cell.lastActiveCell!="undefined"){rowId=GENTICS.Aloha.Table.Cell.lastActiveCell.obj.context.parentNode.rowIndex}}var newRowIndex=rowId;if(position=="after"){newRowIndex+=1}var rowIdArray=new Array();for(var j=0;j<rowsToInsert;j++){rowIdArray.push(newRowIndex);var insertionRow=jQuery("<tr>");var selectionColumn=jQuery("<td>");selectionColumn.addClass(this.get("classSelectionColumn"));this.attachRowSelectionEventsToCell(selectionColumn);insertionRow.append(selectionColumn);for(i=0;i<numCols;i++){var newCol=jQuery("<td>");newCol.html("\u00a0");var cell=new GENTICS.Aloha.Table.Cell(newCol.get(0),GENTICS.Aloha.TablePlugin.activeTable);cell.activate();this.cells.push(cell);insertionRow.append(cell.obj)}var currentRow=jQuery(GENTICS.Aloha.TablePlugin.activeTable.obj.find("tr").get(rowId));switch(position){case"before":currentRow.before(insertionRow);break;case"after":currentRow.after(insertionRow);break;default:this.warn(this,"Wrong call of GENTICS.Aloha.Table.prototype.addRow!")}newRowIndex++;this.numRows++}GENTICS.Aloha.TableHelper.unselectCells();this.rowsToSelect=rowIdArray;if(highlightNewRows){this.selectRows()}this.attachLastCellEvents()}};GENTICS.Aloha.Table.prototype.addColumnsRight=function(){this.addColumns("right")};GENTICS.Aloha.Table.prototype.addColumnsLeft=function(){this.addColumns("left")};GENTICS.Aloha.Table.prototype.addColumns=function(position){if(typeof GENTICS.Aloha.TablePlugin.activeTable!="undefined"){this.releaseLastCellEvents();var that=this;var columnsToInsert=1;var colId=1;if(GENTICS.Aloha.TableHelper.selectedCells.length>0){columnsToInsert=GENTICS.Aloha.TableHelper.selectedCells[0].length;switch(position){case"left":if(GENTICS.Aloha.TableHelper.selectedCells[0].length){colId=GENTICS.Aloha.TableHelper.selectedCells[0][0].cellIndex}break;case"right":var lastColumn=GENTICS.Aloha.TableHelper.selectedCells[0].length-1;if(GENTICS.Aloha.TableHelper.selectedCells[0].length){colId=GENTICS.Aloha.TableHelper.selectedCells[0][lastColumn].cellIndex}break}}else{if(typeof GENTICS.Aloha.Table.Cell.lastActiveCell!="undefined"){colId=GENTICS.Aloha.Table.Cell.lastActiveCell.obj.context.cellIndex}}var newColId=colId;var emptyCell=jQuery("<td>");var rows=this.obj.find("tr");var colIdArray=new Array();for(var i=0;i<rows.length;i++){var currentColId=newColId;var row=rows[i];for(var j=0;j<columnsToInsert;j++){var cell=emptyCell.clone();cell.html("\u00a0");if(i==0){this.attachColumnSelectEventsToCell(cell)}else{cellObj=new GENTICS.Aloha.Table.Cell(cell.get(0),GENTICS.Aloha.TablePlugin.activeTable);this.cells.push(cellObj);cellObj.activate();cell=cellObj.obj}var insertionColumn=jQuery(jQuery(row).find("td").get(newColId));switch(position){case"left":if(jQuery.inArray(currentColId,colIdArray)<0){colIdArray.push(currentColId)}insertionColumn.before(cell);break;case"right":if(jQuery.inArray((currentColId+1),colIdArray)<0){colIdArray.push(currentColId+1)}insertionColumn.after(cell);break}currentColId++}}this.numCols+=columnsToInsert;GENTICS.Aloha.TableHelper.unselectCells();this.columnsToSelect=colIdArray;this.selectColumns();this.attachLastCellEvents()}};GENTICS.Aloha.Table.prototype.focus=function(){if(!this.hasFocus){if(!this.parentEditable.isActive){this.parentEditable.obj.focus()}GENTICS.Aloha.TablePlugin.setFocusedTable(this)}setTimeout("GENTICS.Aloha.Selection.updateSelection(false, true)",50)};GENTICS.Aloha.Table.prototype.focusOut=function(){if(this.hasFocus){this.hasFocus=false;GENTICS.Aloha.TablePlugin.setFocusedTable(undefined)}};GENTICS.Aloha.Table.prototype.selectColumns=function(){var selectClass=this.get("classCellSelected");GENTICS.Aloha.TableHelper.unselectCells();GENTICS.Aloha.TableHelper.selectionType="column";this.columnsToSelect.sort(function(a,b){return a-b});var rows=this.obj.find("tr").toArray();rows.shift();var toSelect=new Array();for(var i=0;i<rows.length;i++){var rowCells=rows[i].cells;var selectedCellsInCol=new Array();for(var j=0;j<this.columnsToSelect.length;j++){var colIndex=this.columnsToSelect[j];var cell=rowCells[colIndex];toSelect.push(cell);selectedCellsInCol.push(cell)}GENTICS.Aloha.TableHelper.selectedCells.push(selectedCellsInCol)}this.obj.find("div.GENTICS_Table_Cell_editable").blur();jQuery(toSelect).addClass(selectClass)};GENTICS.Aloha.Table.prototype.selectRows=function(){var selectClass=this.get("classCellSelected");GENTICS.Aloha.TableHelper.unselectCells();this.rowsToSelect.sort(function(a,b){return a-b});for(var i=0;i<this.rowsToSelect.length;i++){var rowId=this.rowsToSelect[i];var rowCells=jQuery(this.obj.find("tr").get(rowId).cells).toArray();rowCells.shift();GENTICS.Aloha.TableHelper.selectedCells.push(rowCells);jQuery(rowCells).addClass(this.get("classCellSelected"))}GENTICS.Aloha.TableHelper.selectionType="row";this.obj.find("div.GENTICS_Table_Cell_editable").blur()};GENTICS.Aloha.Table.prototype.deactivate=function(){this.obj.removeClass(this.get("className"));if(GENTICS.Aloha.trim(this.obj.attr("class"))==""){this.obj.removeAttr("class")}this.obj.removeAttr("contenteditable");this.obj.removeAttr("id");if(this.obj.parents("."+this.get("classTableWrapper")).length){this.obj.unwrap()}this.obj.find("tr."+this.get("classSelectionRow")+":first").remove();var that=this;jQuery.each(this.obj.context.rows,function(){jQuery(this).children("td."+that.get("classSelectionColumn")).remove()});this.obj.find("td, th").removeClass(this.get("classCellSelected"));this.obj.unbind();for(var i=0;i<this.cells.length;i++){var Cell=this.cells[i];Cell.deactivate()}};GENTICS.Aloha.Table.prototype.toString=function(){return"GENTICS.Aloha.Table"};GENTICS.Aloha.Table.Cell=function(originalTd,tableObj){this.obj=jQuery(originalTd);this.tableObj=tableObj};GENTICS.Aloha.Table.Cell.prototype.tableObj=undefined;GENTICS.Aloha.Table.Cell.prototype.obj=undefined;GENTICS.Aloha.Table.Cell.prototype.wrapper=undefined;GENTICS.Aloha.Table.Cell.prototype.hasFocus=false;GENTICS.Aloha.Table.Cell.activeCell=undefined;GENTICS.Aloha.Table.Cell.lastActiveCell=undefined;GENTICS.Aloha.Table.Cell.prototype.editableFocus=function(e){if(!this.hasFocus){this.tableObj.focus();GENTICS.Aloha.Table.Cell.activeCell=this;GENTICS.Aloha.Table.Cell.lastActiveCell=this;this.obj.addClass("GENTICS_Table_Cell_active");this.hasFocus=true;this.selectAll(this.wrapper.get(0));GENTICS.Aloha.TableHelper.selectionType=undefined}};GENTICS.Aloha.Table.Cell.prototype.editableBlur=function(jqEvent){GENTICS.Aloha.Table.Cell.activeCell=undefined;this.hasFocus=false;this.obj.removeClass("GENTICS_Table_Cell_active")};GENTICS.Aloha.Table.Cell.prototype.activate=function(){this.obj.wrapInner("<div/>");var wrapper=this.obj.children("div").eq(0);wrapper.attr("contenteditable","true");wrapper.addClass("GENTICS_Table_Cell_editable");var that=this;wrapper.bind("focus",function(jqEvent){if(jqEvent.currentTarget){jqEvent.currentTarget.indexOf=function(){return -1}}that.editableFocus(jqEvent)});wrapper.bind("mousedown",function(jqEvent){if(jqEvent.currentTarget){jqEvent.currentTarget.indexOf=function(){return -1}}that.editableMouseDown(jqEvent)});wrapper.bind("blur",function(jqEvent){that.editableBlur(jqEvent)});wrapper.bind("keyup",function(jqEvent){that.editableKeyUp(jqEvent)});wrapper.bind("keydown",function(jqEvent){that.editableKeyDown(jqEvent)});wrapper.GENTICS_contentEditableSelectionChange(function(event){GENTICS.Aloha.Selection.onChange(wrapper,event);return wrapper});this.obj.bind("mousedown",function(jqEvent){setTimeout(function(){that.wrapper.trigger("focus")},1);GENTICS.Aloha.TableHelper.unselectCells();jqEvent.stopPropagation()});this.obj.get(0).onselectstart=function(jqEvent){return false};this.wrapper=this.obj.children();this.wrapper.get(0).onselectstart=function(){window.event.cancelBubble=true};return this};GENTICS.Aloha.Table.Cell.prototype.deactivate=function(){var wrapper=this.obj.children(".GENTICS_Table_Cell_editable");if(wrapper.length){var innerHtml=wrapper.html();wrapper.unbind();wrapper.remove();this.obj.unbind("click");if(GENTICS.Aloha.trim(this.obj.attr("class"))==""){this.obj.removeAttr("class")}this.obj.html(innerHtml)}};GENTICS.Aloha.Table.Cell.prototype.toString=function(){return"GENTICS.Aloha.Table.Cell"};GENTICS.Aloha.Table.Cell.prototype.selectAll=function(editableNode){var e=(editableNode.jquery)?editableNode.get(0):editableNode;if(!jQuery.browser.msie){var s=window.getSelection();if(s.setBaseAndExtent){s.setBaseAndExtent(e,0,e,e.innerText.length-1)}else{if(window.opera&&e.innerHTML.substring(e.innerHTML.length-4)=="<BR>"){e.innerHTML=e.innerHTML+"&#160;"}var r=document.createRange();r.selectNodeContents(e);s.removeAllRanges();s.addRange(r)}}else{if(document.getSelection){var s=document.getSelection();var r=document.createRange();r.selectNodeContents(e);s.removeAllRanges();s.addRange(r)}else{if(document.selection){var r=document.body.createTextRange();r.moveToElementText(e);r.select()}}}GENTICS.Aloha.Selection.updateSelection(editableNode)};GENTICS.Aloha.Table.Cell.prototype.editableMouseDown=function(jqEvent){GENTICS.Aloha.TableHelper.unselectCells();if(this.tableObj.hasFocus){jqEvent.stopPropagation()}};GENTICS.Aloha.Table.Cell.prototype.editableKeyUp=function(jqEvent){this.checkForEmptyEvent(jqEvent)};GENTICS.Aloha.Table.Cell.prototype.editableKeyDown=function(jqEvent){this.checkForEmptyEvent(jqEvent);if(!jqEvent.ctrlKey&&!jqEvent.shiftKey){if(GENTICS.Aloha.TableHelper.selectedCells.length>0&&GENTICS.Aloha.TableHelper.selectedCells[0].length>0){GENTICS.Aloha.TableHelper.selectedCells[0][0].firstChild.focus();GENTICS.Aloha.TableHelper.unselectCells();jqEvent.stopPropagation()}}else{if(jqEvent.shiftKey&&GENTICS.Aloha.TableHelper.selectedCells.length>0){var KEYCODE_ARROWLEFT=37;var KEYCODE_ARROWUP=38;var KEYCODE_ARROWRIGHT=39;var KEYCODE_ARROWDOWN=40;switch(GENTICS.Aloha.TableHelper.selectionType){case"row":switch(jqEvent.keyCode){case KEYCODE_ARROWUP:var firstSelectedRow=GENTICS.Aloha.TableHelper.selectedCells[0][0].parentNode.rowIndex;if(firstSelectedRow>1){this.tableObj.rowsToSelect.push(firstSelectedRow-1)}break;case KEYCODE_ARROWDOWN:var lastRowIndex=GENTICS.Aloha.TableHelper.selectedCells.length-1;var lastSelectedRow=GENTICS.Aloha.TableHelper.selectedCells[lastRowIndex][0].parentNode.rowIndex;if(lastSelectedRow<this.tableObj.numRows){this.tableObj.rowsToSelect.push(lastSelectedRow+1)}break}this.tableObj.selectRows();break;case"column":switch(jqEvent.keyCode){case KEYCODE_ARROWLEFT:var firstColSelected=GENTICS.Aloha.TableHelper.selectedCells[0][0].cellIndex;if(firstColSelected>1){this.tableObj.columnsToSelect.push(firstColSelected-1)}break;case KEYCODE_ARROWRIGHT:var lastColIndex=GENTICS.Aloha.TableHelper.selectedCells[0].length-1;var lastColSelected=GENTICS.Aloha.TableHelper.selectedCells[0][lastColIndex].cellIndex;if(lastColSelected<this.tableObj.numCols){this.tableObj.columnsToSelect.push(lastColSelected+1)}break}this.tableObj.selectColumns();break}jqEvent.stopPropagation();jqEvent.preventDefault();return false}}};GENTICS.Aloha.Table.Cell.prototype.checkForEmptyEvent=function(jqEvent){if(jQuery(this.wrapper).children().length>0){return}var text=this.wrapper.text();if(text==""){this.wrapper.text("\u00a0");this.wrapper.get(0).blur();this.wrapper.get(0).focus()}};GENTICS.Aloha.Table.CreateLayer=function(){};GENTICS.Aloha.Table.CreateLayer.prototype.parameters={elemId:"GENTICS_Aloha_Table_createLayer",className:"GENTICS_Table_Createdialog",numX:10,numY:10,layer:undefined,target:undefined};GENTICS.Aloha.Table.CreateLayer.prototype.config=new Object();GENTICS.Aloha.Table.CreateLayer.prototype.visible=false;GENTICS.Aloha.Table.CreateLayer.prototype.show=function(){var layer=this.get("layer");if(layer==null){this.create()}else{this.setPosition(layer);layer.find("td").removeClass("hover");layer.show()}this.visible=true};GENTICS.Aloha.Table.CreateLayer.prototype.create=function(){var that=this;var layer=jQuery("<div></div>");layer.id=this.get("elemId");layer.addClass(this.get("className"));var table=jQuery("<table></table>");table.css("width",(this.get("numX")+6)*15);var tr;var td;for(var i=0;i<this.get("numY");i++){tr=jQuery("<tr></tr>");for(var j=0;j<this.get("numX");j++){td=jQuery("<td>\u00a0</td>");if(i==0&&j==0){td.addClass("hover")}td.bind("mouseover",{rowId:i,colId:j},function(e){that.handleMouseOver(e,table)});td.bind("click",{rowId:i,colId:j},function(e){var rows=e.data.rowId+1;var cols=e.data.colId+1;GENTICS.Aloha.TablePlugin.createTable(cols,rows);that.hide()});tr.append(td)}table.append(tr)}layer.append(table);this.set("layer",layer);this.setPosition();layer.bind("click",function(e){e.stopPropagation()}).mousedown(function(e){e.stopPropagation()});jQuery("body").append(layer).bind("click",function(e){if(e.target!=that.get("target")&&that.visible){that.hide()}})};GENTICS.Aloha.Table.CreateLayer.prototype.handleMouseOver=function(e,table){var rowId=e.data.rowId;var colId=e.data.colId;var innerRows=table.find("tr");for(var n=0;n<=innerRows.length;n++){var innerCells=jQuery(innerRows[n]).find("td");for(var k=0;k<=innerCells.length;k++){if(n<=rowId&&k<=colId){jQuery(innerCells[k]).addClass("hover")}else{jQuery(innerCells[k]).removeClass("hover")}}}};GENTICS.Aloha.Table.CreateLayer.prototype.setPosition=function(){var targetObj=jQuery(this.get("target"));var pos=targetObj.offset();this.get("layer").css("left",pos.left+"px");this.get("layer").css("top",(pos.top+targetObj.height())+"px")};GENTICS.Aloha.Table.CreateLayer.prototype.hide=function(){this.get("layer").hide();this.visible=false};GENTICS.Aloha.Table.CreateLayer.prototype.get=function(property){if(this.config[property]){return this.config[property]}if(this.parameters[property]){return this.parameters[property]}return undefined};GENTICS.Aloha.Table.CreateLayer.prototype.set=function(key,value){if(this.config[key]){this.config[key]=value}else{this.parameters[key]=value}};GENTICS.Aloha.TableHelper=function(){};GENTICS.Aloha.TableHelper.prototype.selectionType=undefined;GENTICS.Aloha.TableHelper.prototype.selectedCells=new Array();GENTICS.Aloha.TableHelper.prototype.unselectCells=function(){if(this.selectedCells.length>0){for(var i=0;i<this.selectedCells.length;i++){jQuery(this.selectedCells[i]).removeClass(GENTICS.Aloha.TablePlugin.get("classCellSelected"))}this.selectedCells=new Array();this.selectionType=undefined}};GENTICS.Aloha.TableHelper.prototype.getNewTableID=function(){var idPrefix="GENTICS_Table_";var factor=1000000;for(this.tableCounter;true;this.tableCounter++){var id=idPrefix+(Math.ceil(Math.random()*factor));for(var j=id.length;j<idPrefix.length+factor.toString().length;j++){id+="0"}if(!jQuery("#"+id).length){return id}}};GENTICS.Aloha.TableHelper=new GENTICS.Aloha.TableHelper();
7
+ GENTICS.Aloha.TablePlugin=new GENTICS.Aloha.Plugin("com.gentics.aloha.plugins.Table");GENTICS.Aloha.TablePlugin.createLayer=undefined;GENTICS.Aloha.TablePlugin.languages=["en","de","fr","eo","fi","ru","it","pl"];GENTICS.Aloha.TablePlugin.config=["table"];GENTICS.Aloha.TablePlugin.TableRegistry=new Array();GENTICS.Aloha.TablePlugin.activeTable=undefined;GENTICS.Aloha.TablePlugin.parameters={className:"GENTICS_Aloha_Table",classSelectionRow:"GENTICS_Aloha_Table_selectColumn",classSelectionColumn:"GENTICS_Aloha_Table_selectRow",classLeftUpperCorner:"GENTICS_Aloha_Table_leftUpperCorner",classTableWrapper:"GENTICS_Aloha_Table_wrapper",classCellSelected:"GENTICS_Aloha_Cell_selected",waiRed:"GENTICS_WAI_RED",waiGreen:"GENTICS_WAI_GREEN",selectionArea:10};GENTICS.Aloha.TablePlugin.init=function(){this.createLayer=new GENTICS.Aloha.Table.CreateLayer();var that=this;GENTICS.Aloha.EventRegistry.subscribe(GENTICS.Aloha,"editableCreated",function(event,editable){editable.obj.bind("mousedown",function(jqEvent){GENTICS.Aloha.TablePlugin.setFocusedTable(undefined)});editable.obj.find("table").each(function(){if(that.isEditableTable(this)){var table=new GENTICS.Aloha.Table(this);table.parentEditable=editable;GENTICS.Aloha.TablePlugin.TableRegistry.push(table)}})});this.initTableButtons();GENTICS.Aloha.EventRegistry.subscribe(GENTICS.Aloha,"selectionChanged",function(event,rangeObject){if(GENTICS.Aloha.activeEditable){var config=that.getEditableConfig(GENTICS.Aloha.activeEditable.obj);if(jQuery.inArray("table",config)!=-1&&GENTICS.Aloha.Selection.mayInsertTag("table")){that.createTableButton.show()}else{that.createTableButton.hide()}GENTICS.Aloha.TableHelper.unselectCells();var table=rangeObject.findMarkup(function(){return this.nodeName.toLowerCase()=="table"},GENTICS.Aloha.activeEditable.obj);if(table){GENTICS.Aloha.FloatingMenu.setScope(that.getUID(GENTICS.Aloha.TableHelper.selectionType))}else{if(that.activeTable){that.activeTable.focusOut()}}GENTICS.Aloha.FloatingMenu.doLayout()}});GENTICS.Aloha.EventRegistry.subscribe(GENTICS.Aloha,"editableActivated",function(event,props){props.editable.obj.find("table").each(function(){var tr=GENTICS.Aloha.TablePlugin.TableRegistry;for(var i=0;i<tr.length;i++){if(tr[i].obj.attr("id")==jQuery(this).attr("id")){tr[i].activate();return true}}if(that.isEditableTable(this)){var table=new GENTICS.Aloha.Table(this);table.parentEditable=props.editable;table.activate();GENTICS.Aloha.TablePlugin.TableRegistry.push(table)}})});GENTICS.Aloha.EventRegistry.subscribe(GENTICS.Aloha,"editableDeactivated",function(event,properties){GENTICS.Aloha.TablePlugin.setFocusedTable(undefined);GENTICS.Aloha.TableHelper.unselectCells();var tr=GENTICS.Aloha.TablePlugin.TableRegistry;for(var i=0;i<tr.length;i++){tr[i].deactivate()}})};GENTICS.Aloha.TablePlugin.isEditableTable=function(table){var parent=jQuery(table.parentNode);if(parent.contentEditable()=="true"){return true}else{return false}};GENTICS.Aloha.TablePlugin.initTableButtons=function(){var that=this;GENTICS.Aloha.FloatingMenu.createScope(this.getUID("row"),"GENTICS.Aloha.global");GENTICS.Aloha.FloatingMenu.createScope(this.getUID("column"),"GENTICS.Aloha.global");GENTICS.Aloha.FloatingMenu.createScope(this.getUID("cell"),"GENTICS.Aloha.continuoustext");this.createTableButton=new GENTICS.Aloha.ui.Button({iconClass:"GENTICS_button GENTICS_button_table",size:"small",tooltip:this.i18n("button.createtable.tooltip"),onclick:function(element,event){GENTICS.Aloha.TablePlugin.createDialog(element.btnEl.dom)}});GENTICS.Aloha.FloatingMenu.addButton("GENTICS.Aloha.continuoustext",this.createTableButton,GENTICS.Aloha.i18n(GENTICS.Aloha,"floatingmenu.tab.insert"),1);GENTICS.Aloha.FloatingMenu.addButton(this.getUID("column"),new GENTICS.Aloha.ui.Button({iconClass:"GENTICS_button GENTICS_button_addColumnLeft",size:"small",tooltip:this.i18n("button.addcolleft.tooltip"),onclick:function(){if(that.activeTable){that.activeTable.addColumnsLeft()}}}),GENTICS.Aloha.i18n(this,"floatingmenu.tab.table"),1);GENTICS.Aloha.FloatingMenu.addButton(this.getUID("column"),new GENTICS.Aloha.ui.Button({iconClass:"GENTICS_button GENTICS_button_addColumnRight",size:"small",tooltip:this.i18n("button.addcolright.tooltip"),onclick:function(){if(that.activeTable){that.activeTable.addColumnsRight()}}}),GENTICS.Aloha.i18n(this,"floatingmenu.tab.table"),1);GENTICS.Aloha.FloatingMenu.addButton(this.getUID("column"),new GENTICS.Aloha.ui.Button({iconClass:"GENTICS_button GENTICS_button_deleteColumns",size:"small",tooltip:this.i18n("button.delcols.tooltip"),onclick:function(){if(that.activeTable){var aTable=that.activeTable;GENTICS.Aloha.showMessage(new GENTICS.Aloha.Message({title:GENTICS.Aloha.i18n(that,"Table"),text:GENTICS.Aloha.i18n(that,"deletecolumns.confirm"),type:GENTICS.Aloha.Message.Type.CONFIRM,callback:function(sel){if(sel=="yes"){aTable.deleteColumns()}}}))}}}),GENTICS.Aloha.i18n(this,"floatingmenu.tab.table"),1);GENTICS.Aloha.FloatingMenu.addButton(this.getUID("row"),new GENTICS.Aloha.ui.Button({iconClass:"GENTICS_button GENTICS_button_addRowBefore",size:"small",tooltip:this.i18n("button.addrowbefore.tooltip"),onclick:function(){if(that.activeTable){that.activeTable.addRowsBefore(true)}}}),GENTICS.Aloha.i18n(this,"floatingmenu.tab.table"),1);GENTICS.Aloha.FloatingMenu.addButton(this.getUID("row"),new GENTICS.Aloha.ui.Button({iconClass:"GENTICS_button GENTICS_button_addRowAfter",size:"small",tooltip:this.i18n("button.addrowafter.tooltip"),onclick:function(){if(that.activeTable){that.activeTable.addRowsAfter(true)}}}),GENTICS.Aloha.i18n(this,"floatingmenu.tab.table"),1);GENTICS.Aloha.FloatingMenu.addButton(this.getUID("row"),new GENTICS.Aloha.ui.Button({iconClass:"GENTICS_button GENTICS_button_deleteRows",size:"small",tooltip:this.i18n("button.delrows.tooltip"),onclick:function(){if(that.activeTable){var aTable=that.activeTable;GENTICS.Aloha.showMessage(new GENTICS.Aloha.Message({title:GENTICS.Aloha.i18n(that,"Table"),text:GENTICS.Aloha.i18n(that,"deleterows.confirm"),type:GENTICS.Aloha.Message.Type.CONFIRM,callback:function(sel){if(sel=="yes"){aTable.deleteRows()}}}))}}}),GENTICS.Aloha.i18n(this,"floatingmenu.tab.table"),1);this.captionButton=new GENTICS.Aloha.ui.Button({iconClass:"GENTICS_button GENTICS_button_table_caption",size:"small",tooltip:this.i18n("button.caption.tooltip"),toggle:true,onclick:function(){if(that.activeTable){if(that.activeTable.obj.children("caption").is("caption")){that.activeTable.obj.children("caption").remove()}else{var captionText=that.i18n("empty.caption");var c=jQuery("<caption></caption>");that.activeTable.obj.append(c);that.makeCaptionEditable(c,captionText);var cDiv=c.find("div").eq(0);var captionContent=cDiv.contents().eq(0);if(captionContent.length>0){var newRange=new GENTICS.Utils.RangeObject();newRange.startContainer=newRange.endContainer=captionContent.get(0);newRange.startOffset=0;newRange.endOffset=captionContent.text().length;that.activeTable.obj.find("div.GENTICS_Table_Cell_editable").blur();cDiv.focus();newRange.select();GENTICS.Aloha.Selection.updateSelection()}}}}});GENTICS.Aloha.FloatingMenu.addButton(this.getUID("cell"),this.captionButton,GENTICS.Aloha.i18n(this,"floatingmenu.tab.table"),1);this.summary=new GENTICS.Aloha.ui.AttributeField({width:350});this.summary.addListener("keyup",function(obj,event){that.activeTable.checkWai()});GENTICS.Aloha.FloatingMenu.addButton(this.getUID("cell"),this.summary,GENTICS.Aloha.i18n(this,"floatingmenu.tab.table"),1)};GENTICS.Aloha.TablePlugin.makeCaptionEditable=function(caption,captionText){var that=this;var cSpan=caption.children("div").eq(0);if(cSpan.length==0){cSpan=jQuery("<div></div>");if(caption.contents().length>0){caption.contents().wrap(cSpan)}else{if(captionText){cSpan.text(captionText)}caption.append(cSpan)}}cSpan.contentEditable(true);cSpan.unbind("mousedown");cSpan.bind("mousedown",function(jqEvent){cSpan.focus();jqEvent.preventDefault();jqEvent.stopPropagation();return false})};GENTICS.Aloha.TablePlugin.createDialog=function(callingElement){this.createLayer.set("target",callingElement);this.createLayer.show()};GENTICS.Aloha.TablePlugin.createTable=function(cols,rows){if(GENTICS.Aloha.activeEditable!=null&&typeof GENTICS.Aloha.activeEditable.obj!="undefined"){var table=document.createElement("table");var tableId=table.id=GENTICS.Aloha.TableHelper.getNewTableID();var tbody=document.createElement("tbody");for(var i=0;i<rows;i++){var tr=document.createElement("tr");for(var j=0;j<cols;j++){var text=document.createTextNode("\u00a0");var td=document.createElement("td");td.appendChild(text);tr.appendChild(td)}tbody.appendChild(tr)}table.appendChild(tbody);GENTICS.Utils.Dom.insertIntoDOM(jQuery(table),GENTICS.Aloha.Selection.getRangeObject(),jQuery(GENTICS.Aloha.activeEditable.obj));var tableReloadedFromDOM=document.getElementById(tableId);var tableObj=new GENTICS.Aloha.Table(tableReloadedFromDOM);tableObj.parentEditable=GENTICS.Aloha.activeEditable;tableObj.activate();if(jQuery.browser.msie){window.setTimeout(function(){tableObj.cells[0].wrapper.get(0).focus()},20)}else{tableObj.cells[0].wrapper.get(0).focus()}GENTICS.Aloha.TablePlugin.TableRegistry.push(tableObj)}else{this.error("There is no active Editable where the table can be inserted!")}};GENTICS.Aloha.TablePlugin.setFocusedTable=function(focusTable){var that=this;for(var i=0;i<GENTICS.Aloha.TablePlugin.TableRegistry.length;i++){GENTICS.Aloha.TablePlugin.TableRegistry[i].hasFocus=false}if(typeof focusTable!="undefined"){this.summary.setTargetObject(focusTable.obj,"summary");if(focusTable.obj.children("caption").is("caption")){that.captionButton.setPressed(true);var c=focusTable.obj.children("caption");that.makeCaptionEditable(c)}focusTable.hasFocus=true}GENTICS.Aloha.TablePlugin.activeTable=focusTable};GENTICS.Aloha.TablePlugin.error=function(msg){GENTICS.Aloha.Log.error(this,msg)};GENTICS.Aloha.TablePlugin.debug=function(msg){GENTICS.Aloha.Log.debug(this,msg)};GENTICS.Aloha.TablePlugin.info=function(msg){GENTICS.Aloha.Log.info(this,msg)};GENTICS.Aloha.TablePlugin.log=function(msg){GENTICS.Aloha.log("log",this,msg)};GENTICS.Aloha.TablePlugin.get=function(property){if(this.config[property]){return this.config[property]}if(this.parameters[property]){return this.parameters[property]}return undefined};GENTICS.Aloha.TablePlugin.set=function(key,value){if(this.config[key]){this.config[key]=value}else{this.parameters[key]=value}};GENTICS.Aloha.TablePlugin.makeClean=function(obj){obj.find("table").each(function(){var table=new GENTICS.Aloha.Table(this);table.deactivate()})};GENTICS.Aloha.TablePlugin.toString=function(){return this.prefix};GENTICS.Aloha.Table=function(table){this.obj=jQuery(table);if(!this.obj.attr("id")){this.obj.attr("id",GENTICS.Utils.guid())}var rows=this.obj.find("tr");var firstRow=jQuery(rows.get(0));this.numCols=firstRow.children("td, th").length;this.numRows=rows.length;this.cells=new Array();var rows=this.obj.find("tr");for(var i=0;i<rows.length;i++){var row=jQuery(rows[i]);var cols=row.children();for(var j=0;j<cols.length;j++){var col=cols[j];var Cell=new GENTICS.Aloha.Table.Cell(col,this);this.cells.push(Cell)}}};GENTICS.Aloha.Table.prototype.obj=undefined;GENTICS.Aloha.Table.prototype.tableWrapper=undefined;GENTICS.Aloha.Table.prototype.cells=undefined;GENTICS.Aloha.Table.prototype.numRows=undefined;GENTICS.Aloha.Table.prototype.numCols=undefined;GENTICS.Aloha.Table.prototype.isActive=false;GENTICS.Aloha.Table.prototype.hasFocus=false;GENTICS.Aloha.Table.prototype.parentEditable=undefined;GENTICS.Aloha.Table.prototype.mousedown=false;GENTICS.Aloha.Table.prototype.clickedColumnId=-1;GENTICS.Aloha.Table.prototype.clickedRowId=-1;GENTICS.Aloha.Table.prototype.columnsToSelect=new Array();GENTICS.Aloha.Table.prototype.rowsToSelect=new Array();GENTICS.Aloha.Table.prototype.fmPluginId=undefined;GENTICS.Aloha.Table.prototype.get=function(property){return GENTICS.Aloha.TablePlugin.get(property)};GENTICS.Aloha.Table.prototype.set=function(key,value){GENTICS.Aloha.TablePlugin.set(key,value)};GENTICS.Aloha.Table.prototype.activate=function(){if(this.isActive){return}var that=this;this.obj.addClass(this.get("className"));this.obj.contentEditable(false);if(this.obj.attr("id")==""){this.obj.attr("id",GENTICS.Aloha.TableHelper.getNewTableID())}GENTICS.Aloha.TableHelper.selectionType=undefined;this.obj.bind("keydown",function(jqEvent){if(!jqEvent.ctrlKey&&!jqEvent.shiftKey){if(GENTICS.Aloha.TableHelper.selectedCells.length>0&&GENTICS.Aloha.TableHelper.selectedCells[0].length>0){GENTICS.Aloha.TableHelper.selectedCells[0][0].firstChild.focus()}}});this.obj.bind("mousedown",function(jqEvent){if(!that.hasFocus){that.focus()}jqEvent.stopPropagation();jqEvent.preventDefault();return false});var tableWrapper=jQuery('<div class="'+this.get("classTableWrapper")+'"></div>');tableWrapper.contentEditable(false);this.obj.wrap(tableWrapper);var htmlTableWrapper=this.obj.parents("."+this.get("classTableWrapper"));htmlTableWrapper.get(0).onresizestart=function(e){return false};htmlTableWrapper.get(0).oncontrolselect=function(e){return false};this.tableWrapper=this.obj.parents("."+this.get("classTableWrapper")).get(0);jQuery(this.cells).each(function(){this.activate()});this.attachSelectionColumn();this.attachSelectionRow();this.attachLastCellEvents();this.makeCaptionEditable();this.checkWai();this.isActive=true;GENTICS.Aloha.EventRegistry.trigger(new GENTICS.Aloha.Event("tableActivated",GENTICS.Aloha,[this]))};GENTICS.Aloha.Table.prototype.makeCaptionEditable=function(){var caption=this.obj.find("caption").eq(0);if(caption){GENTICS.Aloha.TablePlugin.makeCaptionEditable(caption)}};GENTICS.Aloha.Table.prototype.checkWai=function(){var w=this.wai;w.removeClass(this.get("waiGreen"));w.removeClass(this.get("waiRed"));if(this.obj[0].summary.length>5){w.addClass(this.get("waiGreen"))}else{w.addClass(this.get("waiRed"))}};GENTICS.Aloha.Table.prototype.attachSelectionColumn=function(){var emptyCell=jQuery("<td>");emptyCell.html("\u00a0");var that=this;var rows=this.obj.context.rows;for(var i=0;i<rows.length;i++){var rowObj=jQuery(rows[i]);var columnToInsert=emptyCell.clone();columnToInsert.addClass(this.get("classSelectionColumn"));columnToInsert.css("width",this.get("selectionArea")+"px");rowObj.find("td:first").before(columnToInsert);var rowIndex=i+1;this.attachRowSelectionEventsToCell(columnToInsert)}};GENTICS.Aloha.Table.prototype.attachRowSelectionEventsToCell=function(cell){var that=this;cell.unbind("mousedown");cell.unbind("mouseover");cell.get(0).onselectstart=function(){return false};cell.bind("mousedown",function(e){that.mousedown=true;return that.rowSelectionMouseDown(e)});cell.bind("mouseover",function(e){if(that.mousedown){return that.rowSelectionMouseOver(e)}})};GENTICS.Aloha.Table.prototype.rowSelectionMouseDown=function(jqEvent){this.focus();if(GENTICS.Aloha.TableHelper.selectedCells.length==0){this.rowsToSelect=new Array()}this.clickedRowId=jqEvent.currentTarget.parentNode.rowIndex;if(jqEvent.metaKey){var arrayIndex=jQuery.inArray(this.clickedRowId,this.rowsToSelect);if(arrayIndex>=0){this.rowsToSelect.splice(arrayIndex,1)}else{this.rowsToSelect.push(this.clickedRowId)}}else{if(jqEvent.shiftKey){this.rowsToSelect.sort(function(a,b){return a-b});var start=this.rowsToSelect[0];var end=this.clickedRowId;if(start>end){start=end;end=this.rowsToSelect[0]}this.rowsToSelect=new Array();for(var i=start;i<=end;i++){this.rowsToSelect.push(i)}}else{this.rowsToSelect=[this.clickedRowId]}}this.selectRows();jqEvent.preventDefault();jqEvent.stopPropagation();return false};GENTICS.Aloha.Table.prototype.rowSelectionMouseOver=function(jqEvent){var rowIndex=jqEvent.currentTarget.parentNode.rowIndex;if(this.mousedown&&this.clickedRowId>=0){var indexInArray=jQuery.inArray(rowIndex,this.rowsToSelect);var start=(rowIndex<this.clickedRowId)?rowIndex:this.clickedRowId;var end=(rowIndex<this.clickedRowId)?this.clickedRowId:rowIndex;this.rowsToSelect=new Array();for(var i=start;i<=end;i++){this.rowsToSelect.push(i)}this.selectRows();jqEvent.preventDefault();jqEvent.stopPropagation();return false}};GENTICS.Aloha.Table.prototype.attachSelectionRow=function(){var that=this;var emptyCell=jQuery("<td>");emptyCell.html("\u00a0");var numColumns=this.obj.context.rows[0].cells.length;var selectionRow=jQuery("<tr>");selectionRow.addClass(this.get("classSelectionRow"));selectionRow.css("height",this.get("selectionArea")+"px");for(var i=0;i<numColumns;i++){var columnToInsert=emptyCell.clone();if(i>0){this.attachColumnSelectEventsToCell(columnToInsert)}else{var columnToInsert=jQuery("<td>").clone();columnToInsert.addClass(this.get("classLeftUpperCorner"));this.wai=jQuery("<div/>");this.wai.width(25);this.wai.height(12);this.wai.click(function(e){that.focus();GENTICS.Aloha.FloatingMenu.userActivatedTab=GENTICS.Aloha.TablePlugin.i18n("floatingmenu.tab.table");GENTICS.Aloha.FloatingMenu.doLayout();GENTICS.Aloha.TablePlugin.summary.focus();e.stopPropagation();e.preventDefault();return false});columnToInsert.append(this.wai)}selectionRow.append(columnToInsert)}jQuery(document).bind("mouseup",function(e){that.mousedown=false;that.clickedColumnId=-1;that.clickedRowId=-1});this.obj.find("tr:first").before(selectionRow)};GENTICS.Aloha.Table.prototype.attachColumnSelectEventsToCell=function(cell){var that=this;cell.unbind("mousedown");cell.unbind("mouseover");cell.get(0).onselectstart=function(){return false};cell.bind("mousedown",function(e){that.mousedown=true;that.columnSelectionMouseDown(e)});cell.bind("mouseover",function(e){if(that.mousedown){that.columnSelectionMouseOver(e)}})};GENTICS.Aloha.Table.prototype.columnSelectionMouseDown=function(jqEvent){this.focus();if(GENTICS.Aloha.TableHelper.selectedCells.length==0){this.columnsToSelect=new Array()}this.clickedColumnId=jqEvent.currentTarget.cellIndex;if(jqEvent.metaKey){var arrayIndex=jQuery.inArray(this.clickedColumnId,this.columnsToSelect);if(arrayIndex>=0){this.columnsToSelect.splice(arrayIndex,1)}else{this.columnsToSelect.push(this.clickedColumnId)}}else{if(jqEvent.shiftKey){this.columnsToSelect.sort(function(a,b){return a-b});var start=this.columnsToSelect[0];var end=this.clickedColumnId;if(start>end){start=end;end=this.columnsToSelect[0]}this.columnsToSelect=new Array();for(var i=start;i<=end;i++){this.columnsToSelect.push(i)}}else{this.columnsToSelect=[this.clickedColumnId]}}this.selectColumns();jqEvent.preventDefault();jqEvent.stopPropagation();return false};GENTICS.Aloha.Table.prototype.columnSelectionMouseOver=function(jqEvent){var colIndex=jqEvent.currentTarget.cellIndex;if(this.mousedown&&this.clickedColumnId>0){var indexInArray=jQuery.inArray(colIndex,this.columnsToSelect);var start=(colIndex<this.clickedColumnId)?colIndex:this.clickedColumnId;var end=(colIndex<this.clickedColumnId)?this.clickedColumnId:colIndex;this.columnsToSelect=new Array();for(var i=start;i<=end;i++){this.columnsToSelect.push(i)}this.selectColumns()}};GENTICS.Aloha.Table.prototype.releaseLastCellEvents=function(){this.obj.find("tr:last td:last").unbind()};GENTICS.Aloha.Table.prototype.attachLastCellEvents=function(){var that=this;this.obj.find("tr:last td:last").bind("keydown",function(jqEvent){that.lastCellKeyDown(jqEvent)})};GENTICS.Aloha.Table.prototype.lastCellKeyDown=function(jqEvent){var KEYCODE_TAB=9;if(KEYCODE_TAB==jqEvent.keyCode&&!jqEvent.altKey&&!jqEvent.shiftKey&&!jqEvent.ctrlKey){this.addRowsAfter(false);jqEvent.stopPropagation();if(jQuery.browser.msie){this.obj.find("tr:last td:nth-child(1) div.GENTICS_Table_Cell_editable").get(0).focus();return false}}};GENTICS.Aloha.Table.prototype.deleteRows=function(){var rowIDs=new Array();var deleteTable=false;if(GENTICS.Aloha.TableHelper.selectedCells.length>0){for(var i=0;i<GENTICS.Aloha.TableHelper.selectedCells.length;i++){rowIDs.push(GENTICS.Aloha.TableHelper.selectedCells[i][0].parentNode.rowIndex)}}else{if(typeof GENTICS.Aloha.Table.Cell.lastActiveCell!="undefined"){rowIDs.push(GENTICS.Aloha.Table.Cell.lastActiveCell.obj.context.parentNode.rowIndex)}}if(rowIDs.length==this.numRows){deleteTable=true}if(deleteTable){var that=this;GENTICS.Aloha.showMessage(new GENTICS.Aloha.Message({title:GENTICS.Aloha.i18n(GENTICS.Aloha.TablePlugin,"Table"),text:GENTICS.Aloha.i18n(GENTICS.Aloha.TablePlugin,"deletetable.confirm"),type:GENTICS.Aloha.Message.Type.CONFIRM,callback:function(sel){if(sel=="yes"){that.deleteTable()}}}))}else{rowIDs.sort(function(a,b){return a-b});var focusRowId=rowIDs[0];if(focusRowId>(this.numRows-rowIDs.length)){focusRowId--}this.releaseLastCellEvents();var rows=this.obj.find("tr");var rows2delete=new Array();for(var i=0;i<rowIDs.length;i++){rows2delete.push(jQuery(rows[rowIDs[i]]))}for(var i=0;i<rows2delete.length;i++){var cols=rows2delete[i].children("td").toArray();for(var j=0;j<cols.length;j++){for(var m=0;m<this.cells.length;m++){if(cols[j]==this.cells[m].obj.get(0)){this.cells.splice(m,1);m=this.cells.length}}}}for(var i=0;i<rows2delete.length;i++){rows2delete[i].remove()}this.numRows-=rows2delete.length;if(jQuery.browser.msie){setTimeout(this.obj.find("tr:nth-child("+(focusRowId+1)+") td:nth-child(2) div.GENTICS_Table_Cell_editable").get(0).focus,5)}else{this.obj.find("tr:nth-child("+(focusRowId+1)+") td:nth-child(2) div.GENTICS_Table_Cell_editable").get(0).focus()}this.attachLastCellEvents();GENTICS.Aloha.TableHelper.unselectCells()}};GENTICS.Aloha.Table.prototype.deleteColumns=function(){var colIDs=new Array();var deleteTable=false;if(GENTICS.Aloha.TableHelper.selectedCells.length>0){for(var i=0;i<GENTICS.Aloha.TableHelper.selectedCells[0].length;i++){colIDs.push(GENTICS.Aloha.TableHelper.selectedCells[0][i].cellIndex)}}else{if(typeof GENTICS.Aloha.Table.Cell.lastActiveCell!="undefined"){colIDs.push(GENTICS.Aloha.Table.Cell.lastActiveCell.obj.context.cellIndex)}}if(colIDs.length==this.numCols){deleteTable=true}if(deleteTable){var that=this;GENTICS.Aloha.showMessage(new GENTICS.Aloha.Message({title:GENTICS.Aloha.i18n(GENTICS.Aloha.TablePlugin,"Table"),text:GENTICS.Aloha.i18n(GENTICS.Aloha.TablePlugin,"deletetable.confirm"),type:GENTICS.Aloha.Message.Type.CONFIRM,callback:function(sel){if(sel=="yes"){that.deleteTable()}}}))}else{colIDs.sort(function(a,b){return a-b});var focusColID=colIDs[0];if(focusColID>(this.numCols-colIDs.length)){focusColID--}this.releaseLastCellEvents();var rows=this.obj.find("tr");var cols2delete=new Array();for(var i=0;i<rows.length;i++){var cells=jQuery(rows[i]).children("td").toArray();for(var j=0;j<colIDs.length;j++){cols2delete.push(cells[colIDs[j]])}}for(var i=0;i<cols2delete.length;i++){for(var j=0;j<this.cells.length;j++){if(cols2delete[i]==this.cells[j].obj.get(0)){this.cells.splice(j,1);j=this.cells.length}}}for(var i=0;i<cols2delete.length;i++){jQuery(cols2delete[i]).remove()}this.numCols-=colIDs.length;if(jQuery.browser.msie){setTimeout(this.obj.find("tr:nth-child(2) td:nth-child("+(focusColID+1)+") div.GENTICS_Table_Cell_editable").get(0).focus,5)}else{this.obj.find("tr:nth-child(2) td:nth-child("+(focusColID+1)+") div.GENTICS_Table_Cell_editable").get(0).focus()}this.attachLastCellEvents();GENTICS.Aloha.TableHelper.unselectCells()}};GENTICS.Aloha.Table.prototype.deleteTable=function(){var deleteIndex=-1;for(var i=0;i<GENTICS.Aloha.TablePlugin.TableRegistry.length;i++){if(GENTICS.Aloha.TablePlugin.TableRegistry[i].obj.attr("id")==this.obj.attr("id")){deleteIndex=i;break}}if(deleteIndex>=0){this.deactivate();GENTICS.Aloha.TableHelper.selectionType=undefined;GENTICS.Aloha.TablePlugin.TableRegistry.splice(i,1);var newRange=GENTICS.Aloha.Selection.rangeObject;newRange.startContainer=newRange.endContainer=this.obj.get(0).parentNode;newRange.startOffset=newRange.endOffset=GENTICS.Utils.Dom.getIndexInParent(this.obj.get(0).parentNode);newRange.clearCaches();this.obj.remove();this.parentEditable.obj.focus();newRange.correctRange();newRange.select()}};GENTICS.Aloha.Table.prototype.addRowsBefore=function(highlightNewRows){this.addRows("before",highlightNewRows)};GENTICS.Aloha.Table.prototype.addRowsAfter=function(highlightNewRows){this.addRows("after",highlightNewRows)};GENTICS.Aloha.Table.prototype.addRows=function(position,highlightNewRows){if(typeof GENTICS.Aloha.TablePlugin.activeTable!="undefined"){this.releaseLastCellEvents();var that=this;var numCols=this.numCols;var rowsToInsert=1;var rowId=1;if(GENTICS.Aloha.TableHelper.selectedCells.length>0){rowsToInsert=GENTICS.Aloha.TableHelper.selectedCells.length;switch(position){case"before":if(GENTICS.Aloha.TableHelper.selectedCells[0].length){rowId=GENTICS.Aloha.TableHelper.selectedCells[0][0].parentNode.rowIndex}break;case"after":var lastRow=GENTICS.Aloha.TableHelper.selectedCells.length-1;if(GENTICS.Aloha.TableHelper.selectedCells[lastRow].length){rowId=GENTICS.Aloha.TableHelper.selectedCells[lastRow][0].parentNode.rowIndex}break}}else{if(typeof GENTICS.Aloha.Table.Cell.lastActiveCell!="undefined"){rowId=GENTICS.Aloha.Table.Cell.lastActiveCell.obj.context.parentNode.rowIndex}}var newRowIndex=rowId;if(position=="after"){newRowIndex+=1}var rowIdArray=new Array();for(var j=0;j<rowsToInsert;j++){rowIdArray.push(newRowIndex);var insertionRow=jQuery("<tr>");var selectionColumn=jQuery("<td>");selectionColumn.addClass(this.get("classSelectionColumn"));this.attachRowSelectionEventsToCell(selectionColumn);insertionRow.append(selectionColumn);for(i=0;i<numCols;i++){var newCol=jQuery("<td>");newCol.html("\u00a0");var cell=new GENTICS.Aloha.Table.Cell(newCol.get(0),GENTICS.Aloha.TablePlugin.activeTable);cell.activate();this.cells.push(cell);insertionRow.append(cell.obj)}var currentRow=jQuery(GENTICS.Aloha.TablePlugin.activeTable.obj.find("tr").get(rowId));switch(position){case"before":currentRow.before(insertionRow);break;case"after":currentRow.after(insertionRow);break;default:this.warn(this,"Wrong call of GENTICS.Aloha.Table.prototype.addRow!")}newRowIndex++;this.numRows++}GENTICS.Aloha.TableHelper.unselectCells();this.rowsToSelect=rowIdArray;if(highlightNewRows){this.selectRows()}this.attachLastCellEvents()}};GENTICS.Aloha.Table.prototype.addColumnsRight=function(){this.addColumns("right")};GENTICS.Aloha.Table.prototype.addColumnsLeft=function(){this.addColumns("left")};GENTICS.Aloha.Table.prototype.addColumns=function(position){if(typeof GENTICS.Aloha.TablePlugin.activeTable!="undefined"){this.releaseLastCellEvents();var that=this;var columnsToInsert=1;var colId=1;if(GENTICS.Aloha.TableHelper.selectedCells.length>0){columnsToInsert=GENTICS.Aloha.TableHelper.selectedCells[0].length;switch(position){case"left":if(GENTICS.Aloha.TableHelper.selectedCells[0].length){colId=GENTICS.Aloha.TableHelper.selectedCells[0][0].cellIndex}break;case"right":var lastColumn=GENTICS.Aloha.TableHelper.selectedCells[0].length-1;if(GENTICS.Aloha.TableHelper.selectedCells[0].length){colId=GENTICS.Aloha.TableHelper.selectedCells[0][lastColumn].cellIndex}break}}else{if(typeof GENTICS.Aloha.Table.Cell.lastActiveCell!="undefined"){colId=GENTICS.Aloha.Table.Cell.lastActiveCell.obj.context.cellIndex}}var newColId=colId;var emptyCell=jQuery("<td>");var rows=this.obj.find("tr");var colIdArray=new Array();for(var i=0;i<rows.length;i++){var currentColId=newColId;var row=rows[i];for(var j=0;j<columnsToInsert;j++){var cell=emptyCell.clone();cell.html("\u00a0");if(i==0){this.attachColumnSelectEventsToCell(cell)}else{cellObj=new GENTICS.Aloha.Table.Cell(cell.get(0),GENTICS.Aloha.TablePlugin.activeTable);this.cells.push(cellObj);cellObj.activate();cell=cellObj.obj}var insertionColumn=jQuery(jQuery(row).find("td").get(newColId));switch(position){case"left":if(jQuery.inArray(currentColId,colIdArray)<0){colIdArray.push(currentColId)}insertionColumn.before(cell);break;case"right":if(jQuery.inArray((currentColId+1),colIdArray)<0){colIdArray.push(currentColId+1)}insertionColumn.after(cell);break}currentColId++}}this.numCols+=columnsToInsert;GENTICS.Aloha.TableHelper.unselectCells();this.columnsToSelect=colIdArray;this.selectColumns();this.attachLastCellEvents()}};GENTICS.Aloha.Table.prototype.focus=function(){if(!this.hasFocus){if(!this.parentEditable.isActive){this.parentEditable.obj.focus()}GENTICS.Aloha.TablePlugin.setFocusedTable(this)}};GENTICS.Aloha.Table.prototype.focusOut=function(){if(this.hasFocus){GENTICS.Aloha.TablePlugin.setFocusedTable(undefined);GENTICS.Aloha.TableHelper.selectionType=undefined}};GENTICS.Aloha.Table.prototype.selectColumns=function(){var selectClass=this.get("classCellSelected");GENTICS.Aloha.TableHelper.unselectCells();GENTICS.Aloha.TableHelper.selectionType="column";GENTICS.Aloha.FloatingMenu.setScope(GENTICS.Aloha.TablePlugin.getUID("column"));this.columnsToSelect.sort(function(a,b){return a-b});var rows=this.obj.find("tr").toArray();rows.shift();var toSelect=new Array();for(var i=0;i<rows.length;i++){var rowCells=rows[i].cells;var selectedCellsInCol=new Array();for(var j=0;j<this.columnsToSelect.length;j++){var colIndex=this.columnsToSelect[j];var cell=rowCells[colIndex];toSelect.push(cell);selectedCellsInCol.push(cell)}GENTICS.Aloha.TableHelper.selectedCells.push(selectedCellsInCol)}this.obj.find("div.GENTICS_Table_Cell_editable").blur();jQuery(toSelect).addClass(selectClass)};GENTICS.Aloha.Table.prototype.selectRows=function(){var selectClass=this.get("classCellSelected");GENTICS.Aloha.TableHelper.unselectCells();this.rowsToSelect.sort(function(a,b){return a-b});for(var i=0;i<this.rowsToSelect.length;i++){var rowId=this.rowsToSelect[i];var rowCells=jQuery(this.obj.find("tr").get(rowId).cells).toArray();rowCells.shift();GENTICS.Aloha.TableHelper.selectedCells.push(rowCells);jQuery(rowCells).addClass(this.get("classCellSelected"))}GENTICS.Aloha.TableHelper.selectionType="row";GENTICS.Aloha.FloatingMenu.setScope(GENTICS.Aloha.TablePlugin.getUID("row"));this.obj.find("div.GENTICS_Table_Cell_editable").blur()};GENTICS.Aloha.Table.prototype.deactivate=function(){this.obj.removeClass(this.get("className"));if(GENTICS.Aloha.trim(this.obj.attr("class"))==""){this.obj.removeAttr("class")}if(this.obj.parents("."+this.get("classTableWrapper")).length){this.obj.unwrap()}this.obj.find("tr."+this.get("classSelectionRow")+":first").remove();var that=this;jQuery.each(this.obj.context.rows,function(){jQuery(this).children("td."+that.get("classSelectionColumn")).remove()});this.obj.find("td, th").removeClass(this.get("classCellSelected"));this.obj.unbind();for(var i=0;i<this.cells.length;i++){var Cell=this.cells[i];Cell.deactivate()}this.obj.find("caption div").each(function(){jQuery(this).contents().unwrap()});this.isActive=false};GENTICS.Aloha.Table.prototype.toString=function(){return"GENTICS.Aloha.Table"};GENTICS.Aloha.Table.Cell=function(originalTd,tableObj){this.obj=jQuery(originalTd);this.tableObj=tableObj};GENTICS.Aloha.Table.Cell.prototype.tableObj=undefined;GENTICS.Aloha.Table.Cell.prototype.obj=undefined;GENTICS.Aloha.Table.Cell.prototype.wrapper=undefined;GENTICS.Aloha.Table.Cell.prototype.hasFocus=false;GENTICS.Aloha.Table.Cell.activeCell=undefined;GENTICS.Aloha.Table.Cell.lastActiveCell=undefined;GENTICS.Aloha.Table.Cell.prototype.editableFocus=function(e){if(!this.hasFocus){this.tableObj.focus();GENTICS.Aloha.Table.Cell.activeCell=this;GENTICS.Aloha.Table.Cell.lastActiveCell=this;this.obj.addClass("GENTICS_Table_Cell_active");this.hasFocus=true;this.selectAll(this.wrapper.get(0));GENTICS.Aloha.TableHelper.selectionType="cell"}};GENTICS.Aloha.Table.Cell.prototype.editableBlur=function(jqEvent){GENTICS.Aloha.Table.Cell.activeCell=undefined;this.hasFocus=false;this.obj.removeClass("GENTICS_Table_Cell_active")};GENTICS.Aloha.Table.Cell.prototype.activate=function(){this.obj.wrapInner("<div/>");var wrapper=this.obj.children("div").eq(0);wrapper.contentEditable(true);wrapper.addClass("GENTICS_Table_Cell_editable");var that=this;wrapper.bind("focus",function(jqEvent){if(jqEvent.currentTarget){jqEvent.currentTarget.indexOf=function(){return -1}}that.editableFocus(jqEvent)});wrapper.bind("mousedown",function(jqEvent){if(jqEvent.currentTarget){jqEvent.currentTarget.indexOf=function(){return -1}}that.editableMouseDown(jqEvent)});wrapper.bind("blur",function(jqEvent){that.editableBlur(jqEvent)});wrapper.bind("keyup",function(jqEvent){that.editableKeyUp(jqEvent)});wrapper.bind("keydown",function(jqEvent){that.editableKeyDown(jqEvent)});wrapper.GENTICS_contentEditableSelectionChange(function(event){GENTICS.Aloha.Selection.onChange(wrapper,event);return wrapper});this.obj.bind("mousedown",function(jqEvent){setTimeout(function(){that.wrapper.trigger("focus")},1);GENTICS.Aloha.TableHelper.unselectCells();jqEvent.stopPropagation()});this.obj.get(0).onselectstart=function(jqEvent){return false};this.wrapper=this.obj.children();this.wrapper.get(0).onselectstart=function(){window.event.cancelBubble=true};return this};GENTICS.Aloha.Table.Cell.prototype.deactivate=function(){var wrapper=this.obj.children(".GENTICS_Table_Cell_editable");if(wrapper.length){var innerHtml=wrapper.html();wrapper.unbind();wrapper.remove();this.obj.unbind("click");if(GENTICS.Aloha.trim(this.obj.attr("class"))==""){this.obj.removeAttr("class")}this.obj.html(innerHtml)}};GENTICS.Aloha.Table.Cell.prototype.toString=function(){return"GENTICS.Aloha.Table.Cell"};GENTICS.Aloha.Table.Cell.prototype.selectAll=function(editableNode){var e=(editableNode.jquery)?editableNode.get(0):editableNode;if(!jQuery.browser.msie){var s=window.getSelection();if(s.setBaseAndExtent){s.setBaseAndExtent(e,0,e,e.innerText.length-1)}else{if(window.opera&&e.innerHTML.substring(e.innerHTML.length-4)=="<BR>"){e.innerHTML=e.innerHTML+"&#160;"}var r=document.createRange();r.selectNodeContents(e);s.removeAllRanges();s.addRange(r)}}else{if(document.getSelection){var s=document.getSelection();var r=document.createRange();r.selectNodeContents(e);s.removeAllRanges();s.addRange(r)}else{if(document.selection){var r=document.body.createTextRange();r.moveToElementText(e);r.select()}}}GENTICS.Aloha.Selection.updateSelection(editableNode)};GENTICS.Aloha.Table.Cell.prototype.editableMouseDown=function(jqEvent){GENTICS.Aloha.TableHelper.unselectCells();if(this.tableObj.hasFocus){jqEvent.stopPropagation()}};GENTICS.Aloha.Table.Cell.prototype.editableKeyUp=function(jqEvent){this.checkForEmptyEvent(jqEvent)};GENTICS.Aloha.Table.Cell.prototype.editableKeyDown=function(jqEvent){this.checkForEmptyEvent(jqEvent);if(!jqEvent.ctrlKey&&!jqEvent.shiftKey){if(GENTICS.Aloha.TableHelper.selectedCells.length>0&&GENTICS.Aloha.TableHelper.selectedCells[0].length>0){GENTICS.Aloha.TableHelper.selectedCells[0][0].firstChild.focus();GENTICS.Aloha.TableHelper.unselectCells();jqEvent.stopPropagation()}}else{if(jqEvent.shiftKey&&GENTICS.Aloha.TableHelper.selectedCells.length>0){var KEYCODE_ARROWLEFT=37;var KEYCODE_ARROWUP=38;var KEYCODE_ARROWRIGHT=39;var KEYCODE_ARROWDOWN=40;switch(GENTICS.Aloha.TableHelper.selectionType){case"row":switch(jqEvent.keyCode){case KEYCODE_ARROWUP:var firstSelectedRow=GENTICS.Aloha.TableHelper.selectedCells[0][0].parentNode.rowIndex;if(firstSelectedRow>1){this.tableObj.rowsToSelect.push(firstSelectedRow-1)}break;case KEYCODE_ARROWDOWN:var lastRowIndex=GENTICS.Aloha.TableHelper.selectedCells.length-1;var lastSelectedRow=GENTICS.Aloha.TableHelper.selectedCells[lastRowIndex][0].parentNode.rowIndex;if(lastSelectedRow<this.tableObj.numRows){this.tableObj.rowsToSelect.push(lastSelectedRow+1)}break}this.tableObj.selectRows();break;case"column":switch(jqEvent.keyCode){case KEYCODE_ARROWLEFT:var firstColSelected=GENTICS.Aloha.TableHelper.selectedCells[0][0].cellIndex;if(firstColSelected>1){this.tableObj.columnsToSelect.push(firstColSelected-1)}break;case KEYCODE_ARROWRIGHT:var lastColIndex=GENTICS.Aloha.TableHelper.selectedCells[0].length-1;var lastColSelected=GENTICS.Aloha.TableHelper.selectedCells[0][lastColIndex].cellIndex;if(lastColSelected<this.tableObj.numCols){this.tableObj.columnsToSelect.push(lastColSelected+1)}break}this.tableObj.selectColumns();break}jqEvent.stopPropagation();jqEvent.preventDefault();return false}}};GENTICS.Aloha.Table.Cell.prototype.checkForEmptyEvent=function(jqEvent){if(jQuery(this.wrapper).children().length>0){return}var text=this.wrapper.text();if(text==""){this.wrapper.text("\u00a0");this.wrapper.get(0).blur();this.wrapper.get(0).focus()}};GENTICS.Aloha.Table.CreateLayer=function(){};GENTICS.Aloha.Table.CreateLayer.prototype.parameters={elemId:"GENTICS_Aloha_Table_createLayer",className:"GENTICS_Table_Createdialog",numX:10,numY:10,layer:undefined,target:undefined};GENTICS.Aloha.Table.CreateLayer.prototype.config=new Object();GENTICS.Aloha.Table.CreateLayer.prototype.visible=false;GENTICS.Aloha.Table.CreateLayer.prototype.show=function(){var layer=this.get("layer");if(layer==null){this.create()}else{this.setPosition(layer);layer.find("td").removeClass("hover");layer.show()}this.visible=true};GENTICS.Aloha.Table.CreateLayer.prototype.create=function(){var that=this;var layer=jQuery("<div></div>");layer.id=this.get("elemId");layer.addClass(this.get("className"));var table=jQuery("<table></table>");table.css("width",(this.get("numX")+6)*15);var tr;var td;for(var i=0;i<this.get("numY");i++){tr=jQuery("<tr></tr>");for(var j=0;j<this.get("numX");j++){td=jQuery("<td>\u00a0</td>");if(i==0&&j==0){td.addClass("hover")}td.bind("mouseover",{rowId:i,colId:j},function(e){that.handleMouseOver(e,table)});td.bind("click",{rowId:i,colId:j},function(e){var rows=e.data.rowId+1;var cols=e.data.colId+1;GENTICS.Aloha.TablePlugin.createTable(cols,rows);that.hide()});tr.append(td)}table.append(tr)}layer.append(table);this.set("layer",layer);this.setPosition();layer.bind("click",function(e){e.stopPropagation()}).mousedown(function(e){e.stopPropagation()});jQuery("body").append(layer).bind("click",function(e){if(e.target!=that.get("target")&&that.visible){that.hide()}})};GENTICS.Aloha.Table.CreateLayer.prototype.handleMouseOver=function(e,table){var rowId=e.data.rowId;var colId=e.data.colId;var innerRows=table.find("tr");for(var n=0;n<=innerRows.length;n++){var innerCells=jQuery(innerRows[n]).find("td");for(var k=0;k<=innerCells.length;k++){if(n<=rowId&&k<=colId){jQuery(innerCells[k]).addClass("hover")}else{jQuery(innerCells[k]).removeClass("hover")}}}};GENTICS.Aloha.Table.CreateLayer.prototype.setPosition=function(){var targetObj=jQuery(this.get("target"));var pos=targetObj.offset();this.get("layer").css("left",pos.left+"px");this.get("layer").css("top",(pos.top+targetObj.height())+"px")};GENTICS.Aloha.Table.CreateLayer.prototype.hide=function(){this.get("layer").hide();this.visible=false};GENTICS.Aloha.Table.CreateLayer.prototype.get=function(property){if(this.config[property]){return this.config[property]}if(this.parameters[property]){return this.parameters[property]}return undefined};GENTICS.Aloha.Table.CreateLayer.prototype.set=function(key,value){if(this.config[key]){this.config[key]=value}else{this.parameters[key]=value}};GENTICS.Aloha.TableHelper=function(){};GENTICS.Aloha.TableHelper.prototype.selectionType=undefined;GENTICS.Aloha.TableHelper.prototype.selectedCells=new Array();GENTICS.Aloha.TableHelper.prototype.unselectCells=function(){if(this.selectedCells.length>0){for(var i=0;i<this.selectedCells.length;i++){jQuery(this.selectedCells[i]).removeClass(GENTICS.Aloha.TablePlugin.get("classCellSelected"))}this.selectedCells=new Array();this.selectionType=undefined}};GENTICS.Aloha.TableHelper.prototype.getNewTableID=function(){var idPrefix="GENTICS_Table_";var factor=1000000;for(this.tableCounter;true;this.tableCounter++){var id=idPrefix+(Math.ceil(Math.random()*factor));for(var j=id.length;j<idPrefix.length+factor.toString().length;j++){id+="0"}if(!jQuery("#"+id).length){return id}}};GENTICS.Aloha.TableHelper=new GENTICS.Aloha.TableHelper();
@@ -1,23 +1,6 @@
1
- .GENTICS_Aloha_Table {
2
- border: 0px solid #AFAFAF;
3
- width: 100%;
4
- box-sizing : none !important;
5
- cursor: default;
6
- }
7
- .GENTICS_Aloha_Table td {
8
- border: 1px solid #AFAFAF;
9
- padding: 1px;
10
- margin: 0;
11
- vertical-align: top;
12
- cursor: text;
13
- }
14
- .GENTICS_Aloha_Table td .GENTICS_Table_Cell_editable {
15
- cursor: text !important;
16
- }
17
-
18
1
  /**
19
2
  * Hide the border for contenteditables
20
- */
3
+ */
21
4
  .GENTICS_Table_Cell_editable,
22
5
  .GENTICS_Aloha_Table_wrapper {
23
6
  outline: 0px solid transparent;
@@ -44,18 +27,36 @@ td.GENTICS_Aloha_Table_selectRow {
44
27
  height: 10px;
45
28
  }
46
29
 
30
+ .GENTICS_Aloha_Table td .GENTICS_Table_Cell_editable {
31
+ cursor: text !important;
32
+ }
33
+
47
34
  .GENTICS_Aloha_Table tr.GENTICS_Aloha_Table_selectColumn td {
48
- cursor: url(down.cur),url(../plugins/table/resources/down.cur),default;
35
+ cursor: url(down.cur),default;
49
36
  }
50
37
 
51
38
  /* :TODO: make custom cursors visible in IE */
52
39
  .GENTICS_Aloha_Table td.GENTICS_Aloha_Table_selectRow {
53
- cursor: url(left.cur),url(../plugins/table/resources/left.cur),default;
40
+ cursor: url(left.cur),default;
41
+ }
42
+
43
+ .GENTICS_WAI_RED {
44
+ background-image: url(wai_red.png);
45
+ }
46
+
47
+ .GENTICS_WAI_GREEN {
48
+ background-image: url(wai_green.png);
49
+ }
50
+
51
+ .GENTICS_Aloha_Table td.GENTICS_Aloha_Table_leftUpperCorner div {
52
+ cursor: pointer !important;
54
53
  }
55
54
 
56
55
  .GENTICS_Aloha_Table td.GENTICS_Aloha_Table_selectRow,
57
56
  .GENTICS_Aloha_Table tr.GENTICS_Aloha_Table_selectColumn td {
58
57
  border: 0;
58
+ margin:0;
59
+ padding:0;
59
60
  background-color: #D0D0D0;
60
61
  font-size: 0.01em;
61
62
  }
@@ -73,9 +74,9 @@ td.GENTICS_Aloha_Table_selectRow {
73
74
  position: absolute;
74
75
  background-color: #F0F0F0;
75
76
  border: 1px solid #cccccc;
76
- -moz-border-radius: 3px;
77
- -webkit-border-radius: 3px;
78
- border-radius: 3px;
77
+ -moz-border-radius: 2px;
78
+ -webkit-border-radius: 2px;
79
+ border-radius: 2px;
79
80
  }
80
81
  .GENTICS_Table_Createdialog table {
81
82
  padding: 0px;
@@ -84,111 +85,28 @@ td.GENTICS_Aloha_Table_selectRow {
84
85
  .GENTICS_Table_Createdialog table td {
85
86
  margin: 0px;
86
87
  padding: 0px;
87
- border: 2px solid #AFAFAF;
88
+ border: 1px solid #AFAFAF;
88
89
  font-size: 8px;
89
90
  width: 15px;
90
91
  height: 15px;
91
- -moz-border-radius: 3px;
92
- -webkit-border-radius: 3px;
93
- border-radius: 3px;
94
92
  }
95
93
  .GENTICS_Table_Createdialog table td.hover {
96
- border-color: #1c94c4;
94
+ background-color: #1c94c4;
97
95
  }
98
96
  .GENTICS_Table_Createdialog #table-size-info {
99
97
  text-align: center;
100
98
  font-size: 0.8em;
101
99
  }
102
-
103
100
  .GENTICS_Aloha_Cell_selected {
104
101
  background-color: #3399FF !important;
105
102
  color: #FFF;
106
103
  }
107
-
108
- table td {
109
- height: 100%;
110
- min-height: 100%;
111
- }
112
104
  div.GENTICS_Table_Cell_editable {
113
105
  height: 100%;
114
106
  min-height: 100%;
115
107
  width: 100%;
116
108
  z-index: 99999;
117
109
  }
118
-
119
- /*
120
-
121
- floating menu buttons
122
-
123
- */
124
- .GENTICS_floatingmenu a.GENTICS_Aloha_addColumnLeft {
125
- background-position: -540px 0;
126
- }
127
-
128
- .GENTICS_floatingmenu a:hover.GENTICS_Aloha_addColumnLeft {
129
- background-position: -540px -20px;
130
- }
131
-
132
- .GENTICS_floatingmenu .pressed a.GENTICS_Aloha_addColumnLeft {
133
- background-position: -540px -40px;
134
- }
135
-
136
- .GENTICS_floatingmenu a.GENTICS_Aloha_addColumnRight {
137
- background-position: -560px 0;
138
- }
139
-
140
- .GENTICS_floatingmenu a:hover.GENTICS_Aloha_addColumnRight {
141
- background-position: -560px -20px;
142
- }
143
-
144
- .GENTICS_floatingmenu .pressed a.GENTICS_Aloha_addColumnRight {
145
- background-position: -560px -40px;
146
- }
147
-
148
- .GENTICS_floatingmenu a.GENTICS_Aloha_addRowBefore {
149
- background-position: -580px 0;
150
- }
151
-
152
- .GENTICS_floatingmenu a:hover.GENTICS_Aloha_addRowBefore {
153
- background-position: -580px -20px;
154
- }
155
-
156
- .GENTICS_floatingmenu .pressed a.GENTICS_Aloha_addRowBefore {
157
- background-position: -580px -40px;
158
- }
159
-
160
- .GENTICS_floatingmenu a.GENTICS_Aloha_addRowAfter {
161
- background-position: -600px 0;
162
- }
163
-
164
- .GENTICS_floatingmenu a:hover.GENTICS_Aloha_addRowAfter {
165
- background-position: -600px -20px;
166
- }
167
-
168
- .GENTICS_floatingmenu .pressed a.GENTICS_Aloha_addRowAfter {
169
- background-position: -600px -40px;
170
- }
171
-
172
- .GENTICS_floatingmenu a.GENTICS_Aloha_deleteRows {
173
- background-position: -620px 0;
174
- }
175
-
176
- .GENTICS_floatingmenu a:hover.GENTICS_Aloha_deleteRows {
177
- background-position: -620px -20px;
178
- }
179
-
180
- .GENTICS_floatingmenu .pressed a.GENTICS_Aloha_deleteRows {
181
- background-position: -620px -40px;
182
- }
183
-
184
- .GENTICS_floatingmenu a.GENTICS_Aloha_deleteColumns {
185
- background-position: -640px 0;
186
- }
187
-
188
- .GENTICS_floatingmenu a:hover.GENTICS_Aloha_deleteColumns {
189
- background-position: -640px -20px;
190
- }
191
-
192
- .GENTICS_floatingmenu .pressed a.GENTICS_Aloha_deleteColumns {
193
- background-position: -640px -40px;
110
+ button.GENTICS_button_table_caption {
111
+ background-position: -320px 0px !important;
194
112
  }
@@ -24,9 +24,18 @@ $(document).ready(function() {
24
24
  $('#asset_collection_assets_order').val(ids || '');
25
25
  }
26
26
 
27
+ var setLastClassForAssets = function() {
28
+ $('ul.assets li.last').removeClass('last');
29
+ var i = parseInt($('ul.assets li.asset').size() / 6);
30
+ while (i > 0) {
31
+ $('ul.assets li.asset:eq(' + (i * 6 - 1) + ')').addClass('last');
32
+ i--;
33
+ }
34
+ }
35
+
27
36
  $('ul.assets.sortable').sortable({
28
37
  items: 'li.asset',
29
- stop: function(event, ui) { updateAssetsOrder(); }
38
+ stop: function(event, ui) { updateAssetsOrder(); setLastClassForAssets(); }
30
39
  });
31
40
 
32
41
  $('ul.assets.sortable li div.actions a.remove').click(function(e) {
@@ -37,12 +46,7 @@ $(document).ready(function() {
37
46
 
38
47
  if ($('ul.assets li.asset').size() == 0) $('p.no-items').show();
39
48
 
40
- $('ul.assets li.last').removeClass('last');
41
- var i = parseInt($('ul.assets li.asset').size() / 6);
42
- while (i > 0) {
43
- $('ul.assets li.asset:eq(' + (i * 6 - 1) + ')').addClass('last');
44
- i--;
45
- }
49
+ setLastClassForAssets();
46
50
  }
47
51
  e.preventDefault();
48
52
  e.stopPropagation();
@@ -15,7 +15,9 @@ $(document).ready(function() {
15
15
  stop: function(event, ui) { updateContentsOrder(); }
16
16
  });
17
17
 
18
- $('textarea.html').tinymce(TinyMceDefaultSettings);
18
+ try {
19
+ $('textarea.html').tinymce(TinyMceDefaultSettings);
20
+ } catch (e) { /* tinymce not loaded */ }
19
21
 
20
22
  $.datepicker.setDefaults($.datepicker.regional[I18nLocale]);
21
23
  $('input[type=text].date').datepicker($.datepicker.regional[I18nLocale]);
@@ -17,12 +17,14 @@ $(document).ready(function() {
17
17
  var newRow = lastRow.clone(true).removeClass('template').addClass('added').insertBefore(lastRow);
18
18
 
19
19
  // should copy the value of the select box
20
- var input_name = $('input#current_site_subdomain').attr('name').split('[')[0];
20
+ var input_name = $('input#site_subdomain').attr('name').split('[')[0];
21
21
  var input = newRow.find('input.label')
22
22
  .attr('name', input_name + '[domains][]');
23
23
  if (lastRow.find('input.label').val() == '') input.val("undefined");
24
24
 
25
- // then reset the form
25
+ // then reset and clean the form
26
+ $('fieldset.editable-list input.empty-domains').remove();
27
+
26
28
  lastRow.find('input').val(defaultValue).addClass('void');
27
29
  lastRow.find('select').val('input');
28
30
  });
@@ -30,12 +32,16 @@ $(document).ready(function() {
30
32
  $('fieldset.editable-list li a.remove').click(function(e) {
31
33
  if (confirm($(this).attr('data-confirm')))
32
34
  $(this).parents('li').remove();
35
+
36
+ if ($('fieldset.editable-list .item.added').size() == 0)
37
+ $('fieldset.editable-list').append('<input name="site[domains]" type="hidden" value="" class="empty-domains" />');
38
+
33
39
  e.preventDefault();
34
40
  e.stopPropagation();
35
41
  });
36
42
 
37
43
  $.subscribe('form.saved.success', function(event, data) {
38
- var value = $('#current_site_name').val();
44
+ var value = $('#site_name').val();
39
45
  $('#header h1 a.single').html(value);
40
46
  $('#header h1 a span.ui-selectmenu-status').html(value);
41
47
  $('#site-selector-menu li.ui-selectmenu-item-selected a').html(value);
@@ -16,7 +16,7 @@ $(document).ready(function() {
16
16
 
17
17
  $('a#image-picker-link').imagepicker({
18
18
  insertFn: function(link) {
19
- return "{{ theme_images." + link.attr('data-slug') + " }}";
19
+ return "{{ '" + link.attr('data-local-path') + "' | theme_image_url }}";
20
20
  }
21
21
  });
22
22
  });
@@ -65,6 +65,11 @@ body { background: #000 url(/images/admin/background/body.png) repeat 0 0; }
65
65
  color: #222;
66
66
  }
67
67
 
68
+ #panel fieldset ol li input[type=file] {
69
+ background: none;
70
+ padding: 0px;
71
+ }
72
+
68
73
  #panel fieldset ol li p.inline-errors {
69
74
  padding: 3px 5px;
70
75
  margin: 5px 0px;
@@ -175,7 +175,7 @@ form.formtastic div.actions p {
175
175
  }
176
176
 
177
177
  form.formtastic div.actions a {
178
- color: #fff;
178
+ color: #fff !important;
179
179
  text-decoration: none;
180
180
  font-size: 0.8em;
181
181
  position: relative;
@@ -299,6 +299,10 @@ form.formtastic fieldset.editable-list ol li.added input {
299
299
  cursor: pointer;
300
300
  }
301
301
 
302
+ form.formtastic fieldset.editable-list ol li.added input.domain {
303
+ width: 250px;
304
+ }
305
+
302
306
  form.formtastic fieldset.editable-list ol li.added input:hover {
303
307
  background: #fffbe5;
304
308
  border: 1px dotted #efe4a5;