somatics3-generators 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (181) hide show
  1. data/.document +5 -0
  2. data/.gitignore +21 -0
  3. data/LICENSE +20 -0
  4. data/README.rdoc +17 -0
  5. data/Rakefile +60 -0
  6. data/VERSION +1 -0
  7. data/bin/somatics +21 -0
  8. data/bin/somatify +21 -0
  9. data/lib/generators/somatics/authenticated/authenticated_generator.rb +220 -0
  10. data/lib/generators/somatics/authenticated/templates/mailer.rb +25 -0
  11. data/lib/generators/somatics/authenticated/templates/migration.rb +26 -0
  12. data/lib/generators/somatics/authenticated/templates/model.rb +83 -0
  13. data/lib/generators/somatics/authenticated/templates/observer.rb +11 -0
  14. data/lib/generators/somatics/authenticated/templates/test/mailer_test.rb +31 -0
  15. data/lib/generators/somatics/authenticated/templates/test/model_functional_test.rb +93 -0
  16. data/lib/generators/somatics/authenticated/templates/test/sessions_functional_test.rb +82 -0
  17. data/lib/generators/somatics/authenticated/templates/test/unit_test.rb +164 -0
  18. data/lib/generators/somatics/authenticated/templates/test/users.yml +60 -0
  19. data/lib/generators/somatics/authenticated_controller/authenticated_controller_generator.rb +323 -0
  20. data/lib/generators/somatics/authenticated_controller/templates/_model_partial.html.erb +8 -0
  21. data/lib/generators/somatics/authenticated_controller/templates/activation.erb +3 -0
  22. data/lib/generators/somatics/authenticated_controller/templates/authenticated_system.rb +189 -0
  23. data/lib/generators/somatics/authenticated_controller/templates/authenticated_test_helper.rb +10 -0
  24. data/lib/generators/somatics/authenticated_controller/templates/config/initializers/site_keys.rb +38 -0
  25. data/lib/generators/somatics/authenticated_controller/templates/controller.rb +55 -0
  26. data/lib/generators/somatics/authenticated_controller/templates/helper.rb +91 -0
  27. data/lib/generators/somatics/authenticated_controller/templates/login.html.erb +29 -0
  28. data/lib/generators/somatics/authenticated_controller/templates/mailer.rb +25 -0
  29. data/lib/generators/somatics/authenticated_controller/templates/migration.rb +26 -0
  30. data/lib/generators/somatics/authenticated_controller/templates/model.rb +83 -0
  31. data/lib/generators/somatics/authenticated_controller/templates/observer.rb +11 -0
  32. data/lib/generators/somatics/authenticated_controller/templates/session_helper.rb +2 -0
  33. data/lib/generators/somatics/authenticated_controller/templates/sessions_controller.rb +43 -0
  34. data/lib/generators/somatics/authenticated_controller/templates/signup.html.erb +19 -0
  35. data/lib/generators/somatics/authenticated_controller/templates/signup_notification.erb +8 -0
  36. data/lib/generators/somatics/authenticated_controller/templates/test/mailer_test.rb +31 -0
  37. data/lib/generators/somatics/authenticated_controller/templates/test/model_functional_test.rb +93 -0
  38. data/lib/generators/somatics/authenticated_controller/templates/test/sessions_functional_test.rb +82 -0
  39. data/lib/generators/somatics/authenticated_controller/templates/test/unit_test.rb +164 -0
  40. data/lib/generators/somatics/authenticated_controller/templates/test/users.yml +60 -0
  41. data/lib/generators/somatics/helper/helper_generator.rb +16 -0
  42. data/lib/generators/somatics/install/install_generator.rb +65 -0
  43. data/lib/generators/somatics/install/templates/config/locales/somatics_en.yml +33 -0
  44. data/lib/generators/somatics/install/templates/config/locales/somatics_zh-TW.yml +33 -0
  45. data/lib/generators/somatics/install/templates/controller_admin.rb +16 -0
  46. data/lib/generators/somatics/install/templates/controller_home.rb +4 -0
  47. data/lib/generators/somatics/install/templates/helper_admin.rb +68 -0
  48. data/lib/generators/somatics/install/templates/layout_admin.html.erb +88 -0
  49. data/lib/generators/somatics/install/templates/lib/somatic_link_renderer.rb +42 -0
  50. data/lib/generators/somatics/install/templates/partial_menu.html.erb +1 -0
  51. data/lib/generators/somatics/install/templates/public/images/somatics/add.png +0 -0
  52. data/lib/generators/somatics/install/templates/public/images/somatics/arrow_collapsed.png +0 -0
  53. data/lib/generators/somatics/install/templates/public/images/somatics/arrow_expanded.png +0 -0
  54. data/lib/generators/somatics/install/templates/public/images/somatics/attachment.png +0 -0
  55. data/lib/generators/somatics/install/templates/public/images/somatics/bullet_arrow_left.png +0 -0
  56. data/lib/generators/somatics/install/templates/public/images/somatics/bullet_arrow_right.png +0 -0
  57. data/lib/generators/somatics/install/templates/public/images/somatics/bullet_diamond.png +0 -0
  58. data/lib/generators/somatics/install/templates/public/images/somatics/bullet_end.png +0 -0
  59. data/lib/generators/somatics/install/templates/public/images/somatics/bullet_go.png +0 -0
  60. data/lib/generators/somatics/install/templates/public/images/somatics/bullet_toggle_minus.png +0 -0
  61. data/lib/generators/somatics/install/templates/public/images/somatics/bullet_toggle_plus.png +0 -0
  62. data/lib/generators/somatics/install/templates/public/images/somatics/c.png +0 -0
  63. data/lib/generators/somatics/install/templates/public/images/somatics/cancel.png +0 -0
  64. data/lib/generators/somatics/install/templates/public/images/somatics/changeset.png +0 -0
  65. data/lib/generators/somatics/install/templates/public/images/somatics/comment.png +0 -0
  66. data/lib/generators/somatics/install/templates/public/images/somatics/comments.png +0 -0
  67. data/lib/generators/somatics/install/templates/public/images/somatics/content-left.png +0 -0
  68. data/lib/generators/somatics/install/templates/public/images/somatics/content-right.png +0 -0
  69. data/lib/generators/somatics/install/templates/public/images/somatics/copy.png +0 -0
  70. data/lib/generators/somatics/install/templates/public/images/somatics/csharp.png +0 -0
  71. data/lib/generators/somatics/install/templates/public/images/somatics/database_key.png +0 -0
  72. data/lib/generators/somatics/install/templates/public/images/somatics/default.png +0 -0
  73. data/lib/generators/somatics/install/templates/public/images/somatics/delete.png +0 -0
  74. data/lib/generators/somatics/install/templates/public/images/somatics/document.png +0 -0
  75. data/lib/generators/somatics/install/templates/public/images/somatics/draft.png +0 -0
  76. data/lib/generators/somatics/install/templates/public/images/somatics/duplicate.png +0 -0
  77. data/lib/generators/somatics/install/templates/public/images/somatics/edit.png +0 -0
  78. data/lib/generators/somatics/install/templates/public/images/somatics/exclamation.png +0 -0
  79. data/lib/generators/somatics/install/templates/public/images/somatics/external.png +0 -0
  80. data/lib/generators/somatics/install/templates/public/images/somatics/fav.png +0 -0
  81. data/lib/generators/somatics/install/templates/public/images/somatics/fav_off.png +0 -0
  82. data/lib/generators/somatics/install/templates/public/images/somatics/feed.png +0 -0
  83. data/lib/generators/somatics/install/templates/public/images/somatics/folder.png +0 -0
  84. data/lib/generators/somatics/install/templates/public/images/somatics/folder_open.png +0 -0
  85. data/lib/generators/somatics/install/templates/public/images/somatics/footer-bg.png +0 -0
  86. data/lib/generators/somatics/install/templates/public/images/somatics/footer-left.png +0 -0
  87. data/lib/generators/somatics/install/templates/public/images/somatics/footer-right.png +0 -0
  88. data/lib/generators/somatics/install/templates/public/images/somatics/group.png +0 -0
  89. data/lib/generators/somatics/install/templates/public/images/somatics/help.png +0 -0
  90. data/lib/generators/somatics/install/templates/public/images/somatics/history.png +0 -0
  91. data/lib/generators/somatics/install/templates/public/images/somatics/image.png +0 -0
  92. data/lib/generators/somatics/install/templates/public/images/somatics/lightning.png +0 -0
  93. data/lib/generators/somatics/install/templates/public/images/somatics/link.png +0 -0
  94. data/lib/generators/somatics/install/templates/public/images/somatics/loading.gif +0 -0
  95. data/lib/generators/somatics/install/templates/public/images/somatics/locked.png +0 -0
  96. data/lib/generators/somatics/install/templates/public/images/somatics/message.png +0 -0
  97. data/lib/generators/somatics/install/templates/public/images/somatics/milestone.png +0 -0
  98. data/lib/generators/somatics/install/templates/public/images/somatics/move.png +0 -0
  99. data/lib/generators/somatics/install/templates/public/images/somatics/news.png +0 -0
  100. data/lib/generators/somatics/install/templates/public/images/somatics/openid-bg.gif +0 -0
  101. data/lib/generators/somatics/install/templates/public/images/somatics/package.png +0 -0
  102. data/lib/generators/somatics/install/templates/public/images/somatics/pdf.png +0 -0
  103. data/lib/generators/somatics/install/templates/public/images/somatics/php.png +0 -0
  104. data/lib/generators/somatics/install/templates/public/images/somatics/plugin.png +0 -0
  105. data/lib/generators/somatics/install/templates/public/images/somatics/projects.png +0 -0
  106. data/lib/generators/somatics/install/templates/public/images/somatics/rails.png +0 -0
  107. data/lib/generators/somatics/install/templates/public/images/somatics/reload.png +0 -0
  108. data/lib/generators/somatics/install/templates/public/images/somatics/report.png +0 -0
  109. data/lib/generators/somatics/install/templates/public/images/somatics/ruby.png +0 -0
  110. data/lib/generators/somatics/install/templates/public/images/somatics/save.png +0 -0
  111. data/lib/generators/somatics/install/templates/public/images/somatics/sort_asc.png +0 -0
  112. data/lib/generators/somatics/install/templates/public/images/somatics/sort_desc.png +0 -0
  113. data/lib/generators/somatics/install/templates/public/images/somatics/stats.png +0 -0
  114. data/lib/generators/somatics/install/templates/public/images/somatics/table_multiple.png +0 -0
  115. data/lib/generators/somatics/install/templates/public/images/somatics/task_done.png +0 -0
  116. data/lib/generators/somatics/install/templates/public/images/somatics/task_late.png +0 -0
  117. data/lib/generators/somatics/install/templates/public/images/somatics/task_parent_end.png +0 -0
  118. data/lib/generators/somatics/install/templates/public/images/somatics/task_todo.png +0 -0
  119. data/lib/generators/somatics/install/templates/public/images/somatics/text.png +0 -0
  120. data/lib/generators/somatics/install/templates/public/images/somatics/text_list_bullets.png +0 -0
  121. data/lib/generators/somatics/install/templates/public/images/somatics/textfield.png +0 -0
  122. data/lib/generators/somatics/install/templates/public/images/somatics/ticket.png +0 -0
  123. data/lib/generators/somatics/install/templates/public/images/somatics/ticket_checked.png +0 -0
  124. data/lib/generators/somatics/install/templates/public/images/somatics/ticket_edit.png +0 -0
  125. data/lib/generators/somatics/install/templates/public/images/somatics/ticket_go.png +0 -0
  126. data/lib/generators/somatics/install/templates/public/images/somatics/ticket_note.png +0 -0
  127. data/lib/generators/somatics/install/templates/public/images/somatics/time.png +0 -0
  128. data/lib/generators/somatics/install/templates/public/images/somatics/time_add.png +0 -0
  129. data/lib/generators/somatics/install/templates/public/images/somatics/toggle_check.png +0 -0
  130. data/lib/generators/somatics/install/templates/public/images/somatics/true.png +0 -0
  131. data/lib/generators/somatics/install/templates/public/images/somatics/unlock.png +0 -0
  132. data/lib/generators/somatics/install/templates/public/images/somatics/user.png +0 -0
  133. data/lib/generators/somatics/install/templates/public/images/somatics/warning.png +0 -0
  134. data/lib/generators/somatics/install/templates/public/images/somatics/wiki_edit.png +0 -0
  135. data/lib/generators/somatics/install/templates/public/images/somatics/xml.png +0 -0
  136. data/lib/generators/somatics/install/templates/public/images/somatics/zip.png +0 -0
  137. data/lib/generators/somatics/install/templates/public/images/somatics/zoom_in.png +0 -0
  138. data/lib/generators/somatics/install/templates/public/javascripts/somatics/base.js +231 -0
  139. data/lib/generators/somatics/install/templates/public/javascripts/somatics/context_menu.js +237 -0
  140. data/lib/generators/somatics/install/templates/public/javascripts/somatics/controls.js +965 -0
  141. data/lib/generators/somatics/install/templates/public/javascripts/somatics/dragdrop.js +974 -0
  142. data/lib/generators/somatics/install/templates/public/javascripts/somatics/effects.js +1123 -0
  143. data/lib/generators/somatics/install/templates/public/javascripts/somatics/prototype.js +6001 -0
  144. data/lib/generators/somatics/install/templates/public/javascripts/somatics/rails.js +175 -0
  145. data/lib/generators/somatics/install/templates/public/javascripts/somatics/select_list_move.js +82 -0
  146. data/lib/generators/somatics/install/templates/public/stylesheets/somatics/base.css +948 -0
  147. data/lib/generators/somatics/install/templates/public/stylesheets/somatics/context_menu.css +52 -0
  148. data/lib/generators/somatics/install/templates/public/stylesheets/somatics/csshover.htc +122 -0
  149. data/lib/generators/somatics/install/templates/public/stylesheets/somatics/jstoolbar.css +95 -0
  150. data/lib/generators/somatics/install/templates/view_index.html.erb +1 -0
  151. data/lib/generators/somatics/scaffold/scaffold_generator.rb +25 -0
  152. data/lib/generators/somatics/scaffold/templates/_form.html.erb +23 -0
  153. data/lib/generators/somatics/scaffold/templates/edit.html.erb +6 -0
  154. data/lib/generators/somatics/scaffold/templates/index.html.erb +27 -0
  155. data/lib/generators/somatics/scaffold/templates/new.html.erb +5 -0
  156. data/lib/generators/somatics/scaffold/templates/show.html.erb +12 -0
  157. data/lib/generators/somatics/scaffold_controller/USAGE +20 -0
  158. data/lib/generators/somatics/scaffold_controller/scaffold_controller_generator.rb +137 -0
  159. data/lib/generators/somatics/scaffold_controller/templates/builder_index.pdf.prawn +25 -0
  160. data/lib/generators/somatics/scaffold_controller/templates/builder_index.xls.builder +24 -0
  161. data/lib/generators/somatics/scaffold_controller/templates/builder_index.xml.builder +10 -0
  162. data/lib/generators/somatics/scaffold_controller/templates/controller.rb +140 -0
  163. data/lib/generators/somatics/scaffold_controller/templates/locales_en.yml +17 -0
  164. data/lib/generators/somatics/scaffold_controller/templates/locales_zh-TW.yml +20 -0
  165. data/lib/generators/somatics/scaffold_controller/templates/partial_bulk.html.erb +12 -0
  166. data/lib/generators/somatics/scaffold_controller/templates/partial_edit.html.erb +7 -0
  167. data/lib/generators/somatics/scaffold_controller/templates/partial_form.html.erb +13 -0
  168. data/lib/generators/somatics/scaffold_controller/templates/partial_list.html.erb +42 -0
  169. data/lib/generators/somatics/scaffold_controller/templates/partial_menu.html.erb +1 -0
  170. data/lib/generators/somatics/scaffold_controller/templates/partial_show.html.erb +31 -0
  171. data/lib/generators/somatics/scaffold_controller/templates/view_edit.html.erb +24 -0
  172. data/lib/generators/somatics/scaffold_controller/templates/view_index.html.erb +28 -0
  173. data/lib/generators/somatics/scaffold_controller/templates/view_new.html.erb +14 -0
  174. data/lib/generators/somatics/scaffold_controller/templates/view_show.html.erb +24 -0
  175. data/lib/generators/somatics.rb +95 -0
  176. data/lib/somatics3-generators.rb +19 -0
  177. data/somatics3-generators.gemspec +223 -0
  178. data/templates/somatics.rb +128 -0
  179. data/test/helper.rb +10 -0
  180. data/test/test_somatics3-generators.rb +7 -0
  181. metadata +301 -0
@@ -0,0 +1,88 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
3
+ <head>
4
+ <meta http-equiv="content-type" content="text/html; charset=utf-8" />
5
+ <title>Inspire Synergy Limited</title>
6
+
7
+ <%%= stylesheet_link_tag 'somatics/base', 'somatics/jstoolbar', :media => 'all' %>
8
+ <%%#= stylesheet_link_tag 'somatics/context_menu', :media => 'all' %>
9
+ <!--[if IE]>
10
+ <style type="text/css">
11
+ * html body{ width: expression( document.documentElement.clientWidth < 900 ? '900px' : '100%' ); }
12
+ body {behavior: url(/stylesheets/somatics/csshover.htc);}
13
+ </style>
14
+ <![endif]-->
15
+
16
+ <%%= javascript_include_tag 'somatics/prototype.js', 'somatics/effects.js', 'somatics/dragdrop.js', 'somatics/controls.js','somatics/base.js','somatics/select_list_move.js','somatics/context_menu.js' %>
17
+ <!--
18
+ <link href="http://www.redmine.org/issues.atom?query_id=" rel="alternate" title="Issues" type="application/atom+xml" />
19
+ <link href="http://www.redmine.org/issues/changes?format=atom&amp;query_id=" rel="alternate" title="Details of all changes" type="application/atom+xml" />
20
+ -->
21
+ <%%= init_tinymce_hammer_if_required %>
22
+ </head>
23
+ <body>
24
+ <div id="wrapper">
25
+ <div id="wrapper2">
26
+ <div id="top-menu">
27
+ <%% if current_user %>
28
+ <div id="account">
29
+ <ul>
30
+ <li><%%= t('Logged_in_as') %> <%%= link_to current_user.name, admin_user_url(current_user) %></li>
31
+ <li><%%= link_to t('Logout'), admin_user_logout_url %></li>
32
+ </ul>
33
+ </div>
34
+ <%% end %>
35
+ <ul>
36
+ <li><%%= link_to t('Home'), '/' %></li>
37
+ <li><%%= link_to t('Admin_Panel'), admin_root_path %></li>
38
+ <li><%%= link_to t('Support'), 'http://support.inspiresynergy.com', :class => 'supports' %></li>
39
+ </ul>
40
+ </div> <!-- End of Top Menu -->
41
+ <div id="header">
42
+ <!-- <div id="quick-search">
43
+ <form action="" method="get">
44
+ <input name="" type="hidden" value="1" />
45
+ <a href="" accesskey="4"><%#= t('Search') %></a>:
46
+ <input accesskey="f" class="small" id="q" name="q" size="20" type="text" />
47
+ </form>
48
+ </div> -->
49
+ <h1>Somatics - <%%= t('Admin_Panel') %></h1>
50
+ <%% if current_user %>
51
+ <div id="main-menu">
52
+ <ul>
53
+ <%%= render :partial => 'admin/shared/menu' %>
54
+ </ul>
55
+ </div>
56
+ <%% end %>
57
+ </div> <!-- End of Header -->
58
+ <div class="main <%%='nosidebar' unless has_content?(:sidebar)%>" id="main">
59
+ <div id="sidebar">
60
+ <%%= yield :sidebar %>
61
+ <!-- <h3>Issues</h3>
62
+ <h3>Custom queries</h3> -->
63
+ </div> <!-- End of Sidebar -->
64
+ <div id="content">
65
+ <%% if flash[:notice] %>
66
+ <div class="flash notice"><%%= flash[:notice] %></div>
67
+ <%% end %>
68
+ <%% if flash[:error] %>
69
+ <div class="flash error"><%%= flash[:error] %></div>
70
+ <%% end %>
71
+ <%% if flash[:warning] %>
72
+ <div class="flash warning"><%%= flash[:warning] %></div>
73
+ <%% end %>
74
+ <%%= yield %>
75
+ </div> <!-- End of Content -->
76
+ <div id="ajax-indicator" style="display:none;"><span><%%= t('Loading') %>...</span></div>
77
+ <div id="footer">
78
+ <div class="bgl">
79
+ <div class="bgr">
80
+ Somatics. Powered by &copy; <%= Time.now.year %> Inspire Synergy Limited. MIT License
81
+ </div>
82
+ </div>
83
+ </div> <!-- End of Footer -->
84
+ </div> <!-- End of Main -->
85
+ </div> <!-- End of Wrapper2 -->
86
+ </div> <!-- End of Wrapper -->
87
+ </body>
88
+ </html>
@@ -0,0 +1,42 @@
1
+ class SomaticLinkRenderer < WillPaginate::ViewHelpers::LinkRenderer
2
+
3
+ def to_html
4
+ links = @options[:page_links] ? windowed_links : []
5
+ # previous/next buttons
6
+ links.unshift page_link_or_span(@collection.previous_page, 'disabled prev_page', @options[:previous_label])
7
+ links.push page_link_or_span(@collection.next_page, 'disabled next_page', @options[:next_label])
8
+
9
+ html = links.join(@options[:separator])
10
+ html += "( #{@collection.offset+1}-#{@collection.offset + @collection.per_page}/#{@collection.total_entries} )"
11
+ @options[:container] ? @template.content_tag(:p, html, html_attributes) : html
12
+ end
13
+
14
+ def prepare(collection, options, template)
15
+ super
16
+ @collection_name = template.controller.controller_name
17
+ @param_name = "#{@collection_name}_page"
18
+ @options[:previous_label] = I18n.t(:previous)
19
+ @options[:next_label] = I18n.t(:next)
20
+ end
21
+
22
+ protected
23
+
24
+ def page_link(page, text, attributes = {})
25
+ # @template.content_tag(:li, @template.link_to(text, url_for(page)), attributes)
26
+ # @template.link_to(text, url_for(page), attributes)
27
+ @template.link_to_remote(text,{
28
+ :url => url_for(page),
29
+ :update => 'content',
30
+ :method => :get
31
+ },attributes.merge({
32
+ :href => url_for(page)
33
+ })
34
+ )
35
+ end
36
+
37
+ def page_span(page, text, attributes = {})
38
+ # @template.content_tag(:li, text, attributes)
39
+ @template.content_tag(:span, text, attributes)
40
+ end
41
+
42
+ end
@@ -0,0 +1 @@
1
+ <li><%%= link_to t('Overview'), '/admin', :class => (match_controller?("home")) ? 'selected' : ''%></li>
@@ -0,0 +1,231 @@
1
+ /* redMine - project management software
2
+ Copyright (C) 2006-2008 Jean-Philippe Lang */
3
+
4
+ function checkAll (id, checked) {
5
+ var els = Element.descendants(id);
6
+ for (var i = 0; i < els.length; i++) {
7
+ if (els[i].disabled==false) {
8
+ els[i].checked = checked;
9
+ }
10
+ }
11
+ }
12
+
13
+ function toggleCheckboxesBySelector(selector) {
14
+ boxes = $$(selector);
15
+ var all_checked = true;
16
+ for (i = 0; i < boxes.length; i++) { if (boxes[i].checked == false) { all_checked = false; } }
17
+ for (i = 0; i < boxes.length; i++) { boxes[i].checked = !all_checked; }
18
+ }
19
+
20
+ function showAndScrollTo(id, focus) {
21
+ Element.show(id);
22
+ if (focus!=null) { Form.Element.focus(focus); }
23
+ Element.scrollTo(id);
24
+ }
25
+
26
+ function toggleRowGroup(el) {
27
+ var tr = Element.up(el, 'tr');
28
+ var n = Element.next(tr);
29
+ tr.toggleClassName('open');
30
+ while (n != undefined && !n.hasClassName('group')) {
31
+ Element.toggle(n);
32
+ n = Element.next(n);
33
+ }
34
+ }
35
+
36
+ function toggleFieldset(el) {
37
+ var fieldset = Element.up(el, 'fieldset');
38
+ fieldset.toggleClassName('collapsed');
39
+ Effect.toggle(fieldset.down('div'), 'slide', {duration:0.2});
40
+ }
41
+
42
+ var fileFieldCount = 1;
43
+
44
+ function addFileField() {
45
+ if (fileFieldCount >= 10) return false
46
+ fileFieldCount++;
47
+ var f = document.createElement("input");
48
+ f.type = "file";
49
+ f.name = "attachments[" + fileFieldCount + "][file]";
50
+ f.size = 30;
51
+ var d = document.createElement("input");
52
+ d.type = "text";
53
+ d.name = "attachments[" + fileFieldCount + "][description]";
54
+ d.size = 60;
55
+
56
+ p = document.getElementById("attachments_fields");
57
+ p.appendChild(document.createElement("br"));
58
+ p.appendChild(f);
59
+ p.appendChild(d);
60
+ }
61
+
62
+ function showTab(name) {
63
+ var f = $$('div#content .tab-content');
64
+ for(var i=0; i<f.length; i++){
65
+ Element.hide(f[i]);
66
+ }
67
+ var f = $$('div.tabs a');
68
+ for(var i=0; i<f.length; i++){
69
+ Element.removeClassName(f[i], "selected");
70
+ }
71
+ Element.show('tab-content-' + name);
72
+ Element.addClassName('tab-' + name, "selected");
73
+ return false;
74
+ }
75
+
76
+ function moveTabRight(el) {
77
+ var lis = Element.up(el, 'div.tabs').down('ul').childElements();
78
+ var tabsWidth = 0;
79
+ var i;
80
+ for (i=0; i<lis.length; i++) {
81
+ if (lis[i].visible()) {
82
+ tabsWidth += lis[i].getWidth() + 6;
83
+ }
84
+ }
85
+ if (tabsWidth < Element.up(el, 'div.tabs').getWidth() - 60) {
86
+ return;
87
+ }
88
+ i=0;
89
+ while (i<lis.length && !lis[i].visible()) {
90
+ i++;
91
+ }
92
+ lis[i].hide();
93
+ }
94
+
95
+ function moveTabLeft(el) {
96
+ var lis = Element.up(el, 'div.tabs').down('ul').childElements();
97
+ var i = 0;
98
+ while (i<lis.length && !lis[i].visible()) {
99
+ i++;
100
+ }
101
+ if (i>0) {
102
+ lis[i-1].show();
103
+ }
104
+ }
105
+
106
+ function displayTabsButtons() {
107
+ var lis;
108
+ var tabsWidth = 0;
109
+ var i;
110
+ $$('div.tabs').each(function(el) {
111
+ lis = el.down('ul').childElements();
112
+ for (i=0; i<lis.length; i++) {
113
+ if (lis[i].visible()) {
114
+ tabsWidth += lis[i].getWidth() + 6;
115
+ }
116
+ }
117
+ if ((tabsWidth < el.getWidth() - 60) && (lis[0].visible())) {
118
+ el.down('div.tabs-buttons').hide();
119
+ } else {
120
+ el.down('div.tabs-buttons').show();
121
+ }
122
+ });
123
+ }
124
+
125
+ function setPredecessorFieldsVisibility() {
126
+ relationType = $('relation_relation_type');
127
+ if (relationType && (relationType.value == "precedes" || relationType.value == "follows")) {
128
+ Element.show('predecessor_fields');
129
+ } else {
130
+ Element.hide('predecessor_fields');
131
+ }
132
+ }
133
+
134
+ function promptToRemote(text, param, url) {
135
+ value = prompt(text + ':');
136
+ if (value) {
137
+ new Ajax.Request(url + '?' + param + '=' + encodeURIComponent(value), {asynchronous:true, evalScripts:true});
138
+ return false;
139
+ }
140
+ }
141
+
142
+ function collapseScmEntry(id) {
143
+ var els = document.getElementsByClassName(id, 'browser');
144
+ for (var i = 0; i < els.length; i++) {
145
+ if (els[i].hasClassName('open')) {
146
+ collapseScmEntry(els[i].id);
147
+ }
148
+ Element.hide(els[i]);
149
+ }
150
+ $(id).removeClassName('open');
151
+ }
152
+
153
+ function expandScmEntry(id) {
154
+ var els = document.getElementsByClassName(id, 'browser');
155
+ for (var i = 0; i < els.length; i++) {
156
+ Element.show(els[i]);
157
+ if (els[i].hasClassName('loaded') && !els[i].hasClassName('collapsed')) {
158
+ expandScmEntry(els[i].id);
159
+ }
160
+ }
161
+ $(id).addClassName('open');
162
+ }
163
+
164
+ function scmEntryClick(id) {
165
+ el = $(id);
166
+ if (el.hasClassName('open')) {
167
+ collapseScmEntry(id);
168
+ el.addClassName('collapsed');
169
+ return false;
170
+ } else if (el.hasClassName('loaded')) {
171
+ expandScmEntry(id);
172
+ el.removeClassName('collapsed');
173
+ return false;
174
+ }
175
+ if (el.hasClassName('loading')) {
176
+ return false;
177
+ }
178
+ el.addClassName('loading');
179
+ return true;
180
+ }
181
+
182
+ function scmEntryLoaded(id) {
183
+ Element.addClassName(id, 'open');
184
+ Element.addClassName(id, 'loaded');
185
+ Element.removeClassName(id, 'loading');
186
+ }
187
+
188
+ function randomKey(size) {
189
+ var chars = new Array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z');
190
+ var key = '';
191
+ for (i = 0; i < size; i++) {
192
+ key += chars[Math.floor(Math.random() * chars.length)];
193
+ }
194
+ return key;
195
+ }
196
+
197
+ function observeParentIssueField(url) {
198
+ new Ajax.Autocompleter('issue_parent_issue_id',
199
+ 'parent_issue_candidates',
200
+ url,
201
+ { minChars: 3,
202
+ frequency: 0.5,
203
+ paramName: 'q',
204
+ updateElement: function(value) {
205
+ document.getElementById('issue_parent_issue_id').value = value.id;
206
+ }});
207
+ }
208
+
209
+ /* shows and hides ajax indicator */
210
+ Ajax.Responders.register({
211
+ onCreate: function(){
212
+ if ($('ajax-indicator') && Ajax.activeRequestCount > 0) {
213
+ Element.show('ajax-indicator');
214
+ }
215
+ },
216
+ onComplete: function(){
217
+ if ($('ajax-indicator') && Ajax.activeRequestCount == 0) {
218
+ Element.hide('ajax-indicator');
219
+ }
220
+ }
221
+ });
222
+
223
+ Event.observe(window, 'load', function() {
224
+ $$('.hol').each(function(el) {
225
+ el.hide();
226
+ });
227
+ });
228
+
229
+ function link_to(url) {
230
+ window.location = url;
231
+ }