mtoros-mega_menus 0.7.9 → 0.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/Rakefile CHANGED
@@ -4,7 +4,7 @@ require 'rake'
4
4
  begin
5
5
  require 'echoe'
6
6
 
7
- Echoe.new('mega_menus', '0.7.9') do |p|
7
+ Echoe.new('mega_menus', '0.8.1') do |p|
8
8
  p.summary = "Treeview menu Gem for Rails"
9
9
  p.description = "Adds a model, controller to perform the tasks in order to have a treeview menu. To use this gem simply install it and write script/generate menu name_of_the_menu"
10
10
  p.author = ['Marko Toros']
@@ -18,7 +18,8 @@ module MegaMenus
18
18
 
19
19
  def isRootOf( child_id)
20
20
  menu_id=self.id
21
- while(child_id != 1)
21
+
22
+ while(child_id!=1)
22
23
  child_id= self.class.parent_menu(child_id).id
23
24
  if(menu_id===child_id)
24
25
  return TRUE
@@ -178,6 +179,7 @@ module MegaMenus
178
179
  newmenu.save!
179
180
  children(menu.id).each do |c|
180
181
  c.parent_id=newmenu.id
182
+ c.save!
181
183
  end
182
184
  siblings(menu).each do |s|
183
185
  if(s.position>menu.position)
data/mega_menus.gemspec CHANGED
@@ -1,10 +1,12 @@
1
+ # -*- encoding: utf-8 -*-
2
+
1
3
  Gem::Specification.new do |s|
2
4
  s.name = %q{mega_menus}
3
- s.version = "0.7.9"
5
+ s.version = "0.8.1"
4
6
 
5
7
  s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
6
8
  s.authors = ["Marko Toros"]
7
- s.date = %q{2008-11-28}
9
+ s.date = %q{2008-12-01}
8
10
  s.description = %q{Adds a model, controller to perform the tasks in order to have a treeview menu. To use this gem simply install it and write script/generate menu name_of_the_menu}
9
11
  s.email = %q{mtoros@gmail.com}
10
12
  s.extra_rdoc_files = ["README.rdoc", "lib/mega_menus.rb", "lib/mega_menus/editor.rb", "lib/mega_menus/view_helpers.rb"]
@@ -14,7 +16,7 @@ Gem::Specification.new do |s|
14
16
  s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Mega_menus", "--main", "README.rdoc"]
15
17
  s.require_paths = ["lib"]
16
18
  s.rubyforge_project = %q{mega_menus}
17
- s.rubygems_version = %q{1.2.0}
19
+ s.rubygems_version = %q{1.3.1}
18
20
  s.summary = %q{Treeview menu Gem for Rails}
19
21
  s.test_files = ["test/test_editor.rb"]
20
22
 
@@ -22,7 +24,7 @@ Gem::Specification.new do |s|
22
24
  current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
23
25
  s.specification_version = 2
24
26
 
25
- if current_version >= 3 then
27
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
26
28
  s.add_development_dependency(%q<echoe>, [">= 0"])
27
29
  else
28
30
  s.add_dependency(%q<echoe>, [">= 0"])
@@ -15,7 +15,7 @@ class MenuGenerator < Rails::Generator::NamedBase
15
15
  m.template "views/publish_menu.rjs", "app/views/#{file_name}editor/publish_menu.rjs"
16
16
  m.template "views/_menu.html.erb", "app/views/#{file_name}editor/_#{file_name}.html.erb"
17
17
  #create the helper
18
- m.template "helpers/menu_helper.rb", "app/helpers/#{file_name}_helper.rb"
18
+ m.template "helpers/menu_helper.rb", "app/helpers/#{file_name}editor_helper.rb"
19
19
  #create the models
20
20
  m.directory 'db/migrate/'
21
21
  m.template "models/create_menus.rb", "db/migrate/#{Time.now.strftime("%Y%m%d%H%M%S")}_create_#{file_name}s.rb"
@@ -1,17 +1,17 @@
1
1
  class <%= "#{file_name.capitalize+ "editor" + "Controller"}" %> < ApplicationController
2
2
 
3
3
  def add_menu_form
4
- @menu_id=params[:menu_id]
4
+ @menu_id=params[:<%="#{file_name}"%>_id]
5
5
  end
6
6
 
7
7
  def add_menu
8
- <%= file_name.capitalize %>.add_child(params[:menu_id].to_i, params[:title], params[:link])
8
+ <%= file_name.capitalize %>.add_child(params[:<%="#{file_name}"%>_id].to_i, params[:title], params[:link])
9
9
  <%= file_name.capitalize %>.determine_abs_position_and_depth
10
10
 
11
11
  end
12
12
 
13
13
  def publish_menu
14
- m=<%= file_name.capitalize %>.find(params[:menu_id].to_i)
14
+ m=<%= file_name.capitalize %>.find(params[:<%="#{file_name}"%>_id].to_i)
15
15
  if(m.published)
16
16
  m.setNotPublished
17
17
  else
@@ -20,30 +20,30 @@ class <%= "#{file_name.capitalize+ "editor" + "Controller"}" %> < ApplicationCon
20
20
  end
21
21
 
22
22
  def delete_menu
23
- temp=<%= file_name.capitalize %>.find(params[:menu_id]).parent_id
23
+ temp=<%= file_name.capitalize %>.find(params[:<%="#{file_name}"%>_id]).parent_id
24
24
 
25
- <%= file_name.capitalize %>.delete_item(params[:menu_id].to_i)
25
+ <%= file_name.capitalize %>.delete_item(params[:<%="#{file_name}"%>_id].to_i)
26
26
  <%= file_name.capitalize %>.determine_abs_position_and_depth
27
- session[:menu_id]=temp
28
- params[:menu_id]=temp
27
+ session[:<%="#{file_name}"%>_id]=temp
28
+ params[:<%="#{file_name}"%>_id]=temp
29
29
  end
30
30
 
31
31
  def edit_menu_form
32
- @menu_id=params[:menu_id]
32
+ @menu_id=params[:<%="#{file_name}"%>_id]
33
33
  end
34
34
 
35
35
  def edit_menu
36
- <%= file_name.capitalize %>.edit(params[:menu_id].to_i, params[:parent_id].to_i, params[:title], params[:link])
36
+ <%= file_name.capitalize %>.edit(params[:<%="#{file_name}"%>_id].to_i, params[:parent_id].to_i, params[:title], params[:link])
37
37
  <%= file_name.capitalize %>.determine_abs_position_and_depth
38
38
  end
39
39
 
40
40
  def up_menu
41
- <%= file_name.capitalize %>.position_up(params[:menu_id].to_i)
41
+ <%= file_name.capitalize %>.position_up(params[:<%="#{file_name}"%>_id].to_i)
42
42
  <%= file_name.capitalize %>.determine_abs_position_and_depth
43
43
  end
44
44
 
45
45
  def down_menu
46
- <%= file_name.capitalize %>.position_down(params[:menu_id].to_i)
46
+ <%= file_name.capitalize %>.position_down(params[:<%="#{file_name}"%>_id].to_i)
47
47
  <%= file_name.capitalize %>.determine_abs_position_and_depth
48
48
  end
49
49
  end
@@ -1,4 +1,4 @@
1
- module <%= "#{file_name.capitalize}Helper" %>
1
+ module <%= "#{file_name.capitalize}editorHelper" %>
2
2
  def mega_menus(menu_model, menu_controller, admin_condition, admin_depth, admin_parent)
3
3
  #Checks
4
4
  if(!menu_checks(menu_model))
@@ -10,11 +10,11 @@ module <%= "#{file_name.capitalize}Helper" %>
10
10
 
11
11
  def menu_checks(menu_model)
12
12
  if(!defined?(menu_model.check_menus))
13
- concat( "Are you sure you have called acts_as_menu")
13
+ concat( <%="'Are you sure you have called acts_as_menu on model #{file_name.capitalize}.'"%>)
14
14
  return FALSE
15
15
  end
16
16
  if(!menu_model.check_menus)
17
- concat( "You have not set correctly up the model.")
17
+ concat( <%="'You have not set correctly up the model #{file_name.capitalize}.'"%>)
18
18
  return FALSE
19
19
  end
20
20
  return TRUE
@@ -25,10 +25,10 @@ module <%= "#{file_name.capitalize}Helper" %>
25
25
  #mdp...previous menu depth
26
26
  pmd=1
27
27
 
28
- if(!params[:menu_id].nil?)
29
- menu_id=params[:menu_id]
30
- elsif(!session[:menu_id].nil?)
31
- menu_id=session[:menu_id]
28
+ if(!params[:<%= "#{file_name}_id" %>].nil?)
29
+ menu_id=params[<%= ":#{file_name}_id" %>]
30
+ elsif(!session[:<%= "#{file_name}_id" %>].nil?)
31
+ menu_id=session[<%= ":#{file_name}_id" %>]
32
32
  end
33
33
 
34
34
  firstm=TRUE
@@ -39,10 +39,10 @@ module <%= "#{file_name.capitalize}Helper" %>
39
39
  if(admin_condition)
40
40
  add_menu_form(menu_model, menu_controller, m.id)
41
41
  end
42
- concat( "<ul id=\"ul_menu_#{m.depth}\" class=\"ul_menu_depth_#{m.depth} ul_menu\">")
42
+ concat( "<ul id=\"ul_<%= "#{file_name}" %>_#{m.depth}\" class=\"ul_<%= "#{file_name}" %>_depth_#{m.depth} ul_<%= "#{file_name}" %>\">")
43
43
  if(admin_condition)
44
- concat( "<li id=\"root_add_#{m.id}\" class=\"root_add\">")
45
- concat( link_to_remote( "<span>Add</span>", {:url => {:controller => menu_controller, :action => 'add_menu_form', :menu_id => m.id,:menu_model=>menu_model, :menu_controller=>menu_controller}}, {:class => "menu_links_add", :title=> "Add",:id => "add_menu_link_#{m.id}"}))
44
+ concat( "<li id=\"root_<%= "#{file_name}" %>_add_#{m.id}\" class=\"<%= "#{file_name}" %>_root_add\">")
45
+ concat( link_to_remote( "<span>Add</span>", {:url => {:controller => menu_controller, :action => '<%= "add_menu_form" %>', '<%= "#{file_name}_id" %>' => m.id,:menu_model=>menu_model, :menu_controller=>menu_controller}}, {:class => "<%= "#{file_name}" %>_links_add", :title=> "Add",:id => "add_<%= "#{file_name}" %>_link_#{m.id}"}))
46
46
  concat( "</li>")
47
47
  end
48
48
  firstm=FALSE
@@ -54,10 +54,10 @@ module <%= "#{file_name.capitalize}Helper" %>
54
54
  if(admin_condition)
55
55
  add_menu_form(menu_model, menu_controller, m.parent_id)
56
56
  end
57
- concat( "<ul id=\"ul_menu_#{m.depth}\" class=\"ul_menu_depth_#{m.depth} ul_menu\">")
57
+ concat( "<ul id=\"ul_<%= "#{file_name}" %>_#{m.depth}\" class=\"ul_<%= "#{file_name}" %>_depth_#{m.depth} ul_<%= "#{file_name}" %>\">")
58
58
  if(admin_condition)
59
59
  concat( "<li id=\"root_add_#{m.parent_id}\" class=\"root_add\">")
60
- concat( link_to_remote( "<span>Add</span>", {:url => {:controller => menu_controller, :action => 'add_menu_form', :menu_id => m.parent_id,:menu_model=>menu_model, :menu_controller=>menu_controller}}, {:class => "menu_links_add", :title=> "Add",:id => "add_menu_link_#{m.id}"}))
60
+ concat( link_to_remote( "<span>Add</span>", {:url => {:controller => menu_controller, :action => 'add_menu_form', <%= ":#{file_name}_id" %> => m.parent_id,:menu_model=>menu_model, :menu_controller=>menu_controller}}, {:class => "<%= "#{file_name}" %>_links_add", :title=> "Add",:id => "add_<%= "#{file_name}" %>_link_#{m.id}"}))
61
61
  concat( "</li>")
62
62
  end
63
63
  firstm=FALSE
@@ -67,42 +67,47 @@ module <%= "#{file_name.capitalize}Helper" %>
67
67
  pmd=m.depth
68
68
 
69
69
  #make the selected view appear nicer
70
+ if(!m.class.exists?(menu_id.to_i))
71
+ menu_id=1
72
+ end
70
73
  if(m.id==menu_id.to_i || m.isRootOf(menu_id.to_i))
71
- concat( "<li id=\"li_menu_#{m.id}\" class=\"active\">")
72
- concat( "<a class=\"active\" id =\"menu_link_#{m.id}\" href=\"#{m.link}?menu_id=#{m.id}\"> #{m.title} </a>")
73
- session[:menu_id]=menu_id
74
+ concat( "<li id=\"li_<%="#{file_name}"%>_#{m.id}\" class=\"<%= "#{file_name}" %>_active\">")
75
+ concat( "<a class=\"<%= "#{file_name}" %>_active\" id =\"<%= "#{file_name}" %>_link_#{m.id}\" href=\"#{m.link}?<%= "#{file_name}" %>_id=#{m.id}\"> #{m.title} </a>")
76
+ session[<%= ":#{file_name}_id" %>]=menu_id
74
77
  else
75
- concat( "<li id=\"li_menu_#{m.id}\" class=\"li_menu_class\">")
76
- concat( "<a class=\"menu_link\" id =\"menu_link_#{m.id}\" href=\"#{m.link}?menu_id=#{m.id}\"> #{m.title} </a>")
78
+ concat( "<li id=\"li_<%= "#{file_name}" %>_#{m.id}\" class=\"li_<%= "#{file_name}" %>_class\">")
79
+ concat( "<a class=\"<%= "#{file_name}" %>_link\" id =\"<%= "#{file_name}" %>_link_#{m.id}\" href=\"#{m.link}?<%= "#{file_name}" %>_id=#{m.id}\"> #{m.title} </a>")
77
80
  end
81
+
78
82
  if(admin_condition)
79
83
  #remove the comment on the following line depending on the view you want to have
80
- #concat( link_to_remote( "<span>Add</span>", {:url => {:controller => menu_controller, :action => 'add_menu_form', :menu_id => m.id,:menu_model=>menu_model, :menu_controller=>menu_controller}}, {:class => "menu_links_add", :title=> "Add",:id => "add_menu_link_#{m.id}"}))
84
+ #concat( link_to_remote( "<span>Add</span>", {:url => {:controller => menu_controller, :action => 'add_menu_form', <%= "#{file_name}_id" %> => m.id,:menu_model=>menu_model, :menu_controller=>menu_controller}}, {:class => "menu_links_add", :title=> "Add",:id => "add_menu_link_#{m.id}"}))
81
85
  # DELETE
82
- concat( link_to_remote( "<span>Delete</span>", {:url => {:controller => menu_controller, :action => 'delete_menu', :menu_id => m.id,:menu_model=>menu_model, :menu_controller=>menu_controller}, :confirm => "Are you sure?"}, {:class => "menu_links_delete", :title=> "Delete",:id => "delete_menu_link_#{m.id}"}))
86
+ concat( link_to_remote( "<span>Delete</span>", {:url => {:controller => menu_controller, :action => 'delete_menu', <%= ":#{file_name}_id" %> => m.id,:menu_model=>menu_model, :menu_controller=>menu_controller}, :confirm => "Are you sure?"}, {:class => "<%= "#{file_name}" %>_links_delete", :title=> "Delete",:id => "delete_<%= "#{file_name}" %>_link_#{m.id}"}))
83
87
  # EDIT
84
- concat( link_to_remote( "<span>Edit</span>", {:url => {:controller => menu_controller, :action => 'edit_menu_form', :menu_id => m.id,:menu_model=>menu_model, :menu_controller=>menu_controller}}, {:class => "menu_links_edit",:title=> "Edit", :id => "edit_menu_link_#{m.id}"}))
88
+ concat( link_to_remote( "<span>Edit</span>", {:url => {:controller => menu_controller, :action => 'edit_menu_form', <%= ":#{file_name}_id" %> => m.id,:menu_model=>menu_model, :menu_controller=>menu_controller}}, {:class => "<%= "#{file_name}" %>_links_edit",:title=> "Edit", :id => "edit_<%= "#{file_name}" %>_link_#{m.id}"}))
85
89
  # UP
86
- concat( link_to_remote( "<span>Up</span>", {:url => {:controller => menu_controller, :action => 'up_menu', :menu_id => m.id,:menu_model=>menu_model, :menu_controller=>menu_controller}}, {:class => "menu_links_up", :title=> "Up",:id => "up_menu_link_#{m.id}"}))
90
+ concat( link_to_remote( "<span>Up</span>", {:url => {:controller => menu_controller, :action => 'up_menu', <%= ":#{file_name}_id" %> => m.id,:menu_model=>menu_model, :menu_controller=>menu_controller}}, {:class => "<%= "#{file_name}" %>_links_up", :title=> "Up",:id => "up_<%= "#{file_name}" %>_link_#{m.id}"}))
87
91
  # DOWN
88
- concat( link_to_remote( "<span>Down</span>", {:url => {:controller => menu_controller, :action => 'down_menu', :menu_id => m.id,:menu_model=>menu_model, :menu_controller=>menu_controller}}, {:class => "menu_links_down", :title=> "Down", :id => "down_menu_link_#{m.id}"}))
92
+ concat( link_to_remote( "<span>Down</span>", {:url => {:controller => menu_controller, :action => 'down_menu', <%= ":#{file_name}_id" %> => m.id,:menu_model=>menu_model, :menu_controller=>menu_controller}}, {:class => "<%= "#{file_name}" %>_links_down", :title=> "Down", :id => "down_<%= "#{file_name}" %>_link_#{m.id}"}))
89
93
  # PUBLISH
90
94
  if(m.published==TRUE)
91
- mp="menu_links_published"
95
+ mp="<%= "#{file_name}" %>_links_published"
92
96
  mpt="published"
93
97
  else
94
- mp="menu_links_not_published"
98
+ mp="<%= "#{file_name}" %>_links_not_published"
95
99
  mpt="not published"
96
100
  end
97
- concat( link_to_remote( "<span>Publish</span>", {:url => {:controller => menu_controller, :action => 'publish_menu', :menu_id => m.id,:menu_model=>menu_model, :menu_controller=>menu_controller}}, {:class => mp, :title=> mpt, :id => "publish_menu_link_#{m.id}"}))
101
+ concat( link_to_remote( "<span>Publish</span>", {:url => {:controller => menu_controller, :action => 'publish_menu', <%= ":#{file_name}_id" %> => m.id,:menu_model=>menu_model, :menu_controller=>menu_controller}}, {:class => mp, :title=> mpt, :id => "publish_menu_link_#{m.id}"}))
98
102
  # EDIT FORM
99
103
  edit_menu_form(menu_model, menu_controller,m)
100
104
  end
105
+
101
106
  concat( "</li>")
102
107
  if(admin_condition and m.children.empty? and admin_depth.include?(m.depth+1))
103
- concat( "<ul id=\"ul_menu_#{m.depth+1}\" class=\"ul_menu_depth_#{m.depth+1} ul_menu\">")
104
- concat( "<li id=\"root_add_#{m.id}\" class=\"root_add\">")
105
- concat( link_to_remote( "<span>Add</span>", {:url => {:controller => menu_controller, :action => 'add_menu_form', :menu_id => m.id,:menu_model=>menu_model, :menu_controller=>menu_controller}}, {:class => "menu_links_add", :title=> "Add",:id => "add_menu_link_#{m.id}"}))
108
+ concat( "<ul id=\"ul_menu_#{m.depth+1}\" class=\"ul_<%= "#{file_name}" %>_depth_#{m.depth+1} ul_<%= "#{file_name}" %>\">")
109
+ concat( "<li id=\"root_<%= "#{file_name}" %>_add_#{m.id}\" class=\"root_<%= "#{file_name}" %>_add\">")
110
+ concat( link_to_remote( "<span>Add</span>", {:url => {:controller => menu_controller, :action => 'add_menu_form', <%= ":#{file_name}_id" %> => m.id,:menu_model=>menu_model, :menu_controller=>menu_controller}}, {:class => "menu_<%= "#{file_name}" %>_add", :title=> "Add",:id => "add_<%= "#{file_name}" %>_link_#{m.id}"}))
106
111
  add_menu_form(menu_model, menu_controller, m.id)
107
112
  concat( "</li>")
108
113
  concat( "</ul>")
@@ -112,16 +117,16 @@ module <%= "#{file_name.capitalize}Helper" %>
112
117
  end
113
118
  end
114
119
  if(firstm==TRUE and <%= "#{file_name.capitalize}" %>.exists?(admin_parent) and admin_parent!=1)
115
- concat( "<ul id=\"ul_menu_#{admin_depth.first}\" class=\"ul_menu_depth_#{admin_depth.first} ul_menu\">")
120
+ concat( "<ul id=\"ul_<%= "#{file_name}" %>_#{admin_depth.first}\" class=\"ul_<%= "#{file_name}" %>_depth_#{admin_depth.first} ul_<%= "#{file_name}" %>\">")
116
121
  if(admin_condition)
117
- concat( "<li id=\"root_add_#{admin_parent}\" class=\"root_add\">")
118
- concat( link_to_remote( "<span>Add</span>", {:url => {:controller => menu_controller, :action => 'add_menu_form', :menu_id => admin_parent,:menu_model=>menu_model, :menu_controller=>menu_controller}}, {:class => "menu_links_add", :title=> "Add",:id => "add_menu_link_#{admin_parent}"}))
122
+ concat( "<li id=\"root_<%= "#{file_name}" %>_add_#{admin_parent}\" class=\"root_<%= "#{file_name}" %>_add\">")
123
+ concat( link_to_remote( "<span>Add</span>", {:url => {:controller => menu_controller, :action => 'add_menu_form', <%= "#{file_name}_id" %> => admin_parent,:menu_model=>menu_model, :menu_controller=>menu_controller}}, {:class => "<%= "#{file_name}" %>_links_add", :title=> "Add",:id => "add_<%="#{file_name}"%>_link_#{admin_parent}"}))
119
124
  add_menu_form(menu_model, menu_controller, admin_parent)
120
125
  concat( "</li>")
121
126
  end
122
127
  pmd=admin_depth.first
123
128
  elsif(firstm==TRUE)
124
- concat( "<ul id=\"ul_menu_#{admin_depth.first}\" class=\"ul_menu_depth_#{admin_depth.first} ul_menu\">")
129
+ concat( "<ul id=\"ul_<%= "#{file_name}" %>_#{admin_depth.first}\" class=\"ul_<%= "#{file_name}" %>_depth_#{admin_depth.first} ul_menu\">")
125
130
  pmd=admin_depth.first
126
131
  end
127
132
  pmd.downto(admin_depth.first) {concat( "</ul>")}
@@ -130,12 +135,12 @@ module <%= "#{file_name.capitalize}Helper" %>
130
135
  end
131
136
 
132
137
  def add_menu_form(menu_model, menu_controller, menu_id)
133
- form_remote_tag( :url => {:controller=>menu_controller, :action=> 'add_menu'}, :html => {:id => "add_menu_form_#{menu_id}", :class => "add_menu_form", :style=>"display: none"}) do
138
+ form_remote_tag( :url => {:controller=>menu_controller, :action=> 'add_menu'}, :html => {:id => "add_<%= "#{file_name}" %>_form_#{menu_id}", :class => "add_<%= "#{file_name}" %>_form", :style=>"display: none"}) do
134
139
  concat( "Title:" )
135
140
  concat( text_field_tag( "title", "", :id=>"a_tft_title_#{menu_id}"))
136
141
  concat( "Link:")
137
142
  concat( text_field_tag("link", "",:id=>"a_tft_link_#{menu_id}"))
138
- concat( hidden_field_tag(:menu_id, menu_id, :id=>"a_tft_menu_id_#{menu_id}"))
143
+ concat( hidden_field_tag(<%= ":#{file_name}_id" %>, menu_id, :id=>"a_tft_<%= "#{file_name}" %>_id_#{menu_id}"))
139
144
  #content_tag :button, "Submit", {:type=>"submit", :class=>"button-submit"}
140
145
  concat( submit_tag( "Add", :class => "add_button"))
141
146
  end
@@ -144,14 +149,20 @@ module <%= "#{file_name.capitalize}Helper" %>
144
149
 
145
150
 
146
151
  def edit_menu_form(menu_model, menu_controller,m)
147
- form_remote_tag( :url => {:controller=>menu_controller, :action=> 'edit_menu'}, :html => {:id => "edit_menu_form_#{m.id}",:class => "edit_menu_form", :style=>"display: none"}) do
152
+
153
+ #select only menus that are not submenus!
154
+ cmenus=menu_model.all
155
+ cmenus.delete_if{|ame| (ame.id==m.id || ame.isChildOf(m.id))}
156
+
157
+ form_remote_tag( :url => {:controller=>menu_controller, :action=> 'edit_menu'}, :html => {:id => "edit_<%= "#{file_name}" %>_form_#{m.id}",:class => "edit_<%= "#{file_name}" %>_form", :style=>"display: none"}) do
148
158
  concat( "Title:")
149
159
  concat( text_field_tag( "title", m.title, :id=>"e_tft_title_#{m.id}" ))
150
160
  concat( "Link:")
151
161
  concat( text_field_tag( "link", m.link,:id=>"e_tft_link_#{m.id}"))
152
162
  concat( "Parent:")
153
- concat( text_field_tag("parent_id", m.parent_id, :id=>"e_tft_parent_id_#{m.id}"))
154
- concat( hidden_field_tag( :menu_id, m.id,:id=>"e_tft_menud_id_#{m.id}"))
163
+ #concat( text_field_tag("parent_id", m.parent_id, :id=>"e_tft_parent_id_#{m.id}"))
164
+ concat( select_tag( "parent_id", options_for_select(cmenus.map {|c| c.id}), :id=>"e_tft_parent_id_#{m.id}"))
165
+ concat( hidden_field_tag( <%= ":#{file_name}_id" %>, m.id,:id=>"e_tft_<%= "#{file_name}" %>_id_#{m.id}"))
155
166
  #concat content_tag :button, "Submit", {:type=>"submit", :class=>"button-submit"}
156
167
  concat( submit_tag( "Edit", :class => "edit__button"))
157
168
  end
@@ -11,7 +11,7 @@ class <%= "#{'Create' + file_name.capitalize + 's'}" %> < ActiveRecord::Migratio
11
11
  t.timestamps
12
12
  end
13
13
 
14
- <%= file_name.capitalize %>.create :id => 1, :position=>0, :absolute_position=>0, :depth=>1, :parent_id=>0,:published=>FALSE
14
+ <%= file_name.capitalize %>.create :id => 1, :position=>0, :absolute_position=>0, :depth=>1, :parent_id=>0,:published=>FALSE, :title=>"ROOT'
15
15
  end
16
16
 
17
17
 
@@ -1,4 +1,5 @@
1
1
  <%#"The 3. parameter determines normal mode(FALSE) or edit mode(TRUE)...remove this annoying line" %>
2
2
  <%# "The 4. parameter determines the depth of the menus to be shown...remove this annoying line" %>
3
+ <%% extend <%= file_name.capitalize %>editorHelper %>
3
4
  <%% mega_menus(<%= file_name.capitalize %>, <%= "'#{file_name+ "editor"}'"%>, TRUE, 1..10,1) %>
4
5
 
@@ -1 +1 @@
1
- page.replace "ul_menu_1", :partial => <%= "'#{file_name}editor/#{file_name}'" %>
1
+ page.replace <%="'ul_#{file_name}_1'"%>, :partial => <%= "'#{file_name}editor/#{file_name}'" %>
@@ -1,2 +1,2 @@
1
- page.toggle "add_menu_form_#{@menu_id}"
1
+ page.toggle "<%="add_#{file_name}"%>_form_#{@menu_id}"
2
2
 
@@ -1 +1 @@
1
- page.replace "ul_menu_1", :partial => <%= "'#{file_name}editor/#{file_name}'" %>
1
+ page.replace <%="'ul_#{file_name}_1'"%>, :partial => <%= "'#{file_name}editor/#{file_name}'" %>
@@ -1 +1 @@
1
- page.replace "ul_menu_1", :partial => <%= "'#{file_name}editor/#{file_name}'" %>
1
+ page.replace <%="'ul_#{file_name}_1'"%>, :partial => <%= "'#{file_name}editor/#{file_name}'" %>
@@ -1 +1 @@
1
- page.replace "ul_menu_1", :partial => <%= "'#{file_name}editor/#{file_name}'" %>
1
+ page.replace <%="'ul_#{file_name}_1'"%>, :partial => <%= "'#{file_name}editor/#{file_name}'" %>
@@ -1 +1 @@
1
- page.toggle "edit_menu_form_#{@menu_id}"
1
+ page.toggle "<%="edit_#{file_name}"%>_form_#{@menu_id}"
@@ -1 +1 @@
1
- page.replace "ul_menu_1", :partial => <%= "'#{file_name}editor/#{file_name}'" %>
1
+ page.replace <%="'ul_#{file_name}_1'"%>, :partial => <%= "'#{file_name}editor/#{file_name}'" %>
@@ -1 +1 @@
1
- page.replace "ul_menu_1", :partial => <%= "'#{file_name}editor/#{file_name}'" %>
1
+ page.replace <%="'ul_#{file_name}_1'"%>, :partial => <%= "'#{file_name}editor/#{file_name}'" %>
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mtoros-mega_menus
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.9
4
+ version: 0.8.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marko Toros
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-11-28 00:00:00 -08:00
12
+ date: 2008-12-01 00:00:00 -08:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency