mtoros-mega_menus 0.5.9 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +16 -20
- data/Rakefile +1 -1
- data/mega_menus.gemspec +1 -1
- data/rails_generators/menu/templates/helpers/menu_helper.rb +14 -12
- metadata +1 -1
data/README.rdoc
CHANGED
@@ -5,33 +5,29 @@
|
|
5
5
|
This gem makes working with menu structures in Rails easier.
|
6
6
|
|
7
7
|
== FEATURES/PROBLEMS:
|
8
|
-
The current version creates
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
*
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
* delete
|
19
|
-
* edit
|
20
|
-
* move up
|
21
|
-
* move down
|
8
|
+
The current version creates:
|
9
|
+
* a controller for editing the menu
|
10
|
+
* views associated to methods written in rjs
|
11
|
+
* a partial for rendering the menu(for example to be rendered from a menu)
|
12
|
+
* a helper to configure its working in normal mode and edit mode, selection of menu depths(levels) to be shown
|
13
|
+
* the builtin functions are (add, delete, edit, move up, move down)
|
14
|
+
* a model for storing the menu with fields absolute_position and depth to improve performance when the menu is in normal mode
|
15
|
+
* a generator for rails to ease the developers work for using this gem, the menu generator creates a template menu structure that the developer can customize.
|
16
|
+
* uses session[:menu_id] to identify the selected menu
|
17
|
+
|
22
18
|
|
23
19
|
== STATUS
|
24
|
-
|
20
|
+
* Currently writing tests to ensure proper working for future versions.
|
25
21
|
|
26
22
|
|
27
23
|
== REQUIREMENTS:
|
28
|
-
|
24
|
+
* Rails 2.2
|
29
25
|
|
30
26
|
== NOTES:
|
31
|
-
|
32
|
-
|
33
|
-
|
27
|
+
* The menu is located in <div id="mega_menus\">
|
28
|
+
* The selected menu is located in <li class="li_menu_class_selected">
|
29
|
+
* This two id and class values can be easly changed by editing the mega_menu partial and its helper.
|
34
30
|
|
35
31
|
== INSTALL:
|
36
|
-
|
32
|
+
* script/generate menu menu_name
|
37
33
|
|
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
|
+
Echoe.new('mega_menus', '0.6.0') 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']
|
data/mega_menus.gemspec
CHANGED
@@ -35,8 +35,15 @@ module <%= "#{file_name.capitalize}Helper" %>
|
|
35
35
|
allmenus=menu_model.find(:all, :order => "absolute_position")
|
36
36
|
#mdp...previous menu depth
|
37
37
|
pmd=1
|
38
|
+
|
39
|
+
if(!params[:menu_id].nil?)
|
40
|
+
menu_id=params[:menu_id]
|
41
|
+
elsif(!session[:menu_id].nil?)
|
42
|
+
menu_id=session[:menu_id]
|
43
|
+
end
|
44
|
+
#concat "p= #{params[:menu_id]} ... s= #{session[:menu_id]} .... menu_id = #{menu_id} "
|
45
|
+
|
38
46
|
firstm=TRUE
|
39
|
-
selectm=TRUE
|
40
47
|
allmenus.each do |m|
|
41
48
|
if(m.id!=1)
|
42
49
|
#check if your depth is correct
|
@@ -53,14 +60,13 @@ module <%= "#{file_name.capitalize}Helper" %>
|
|
53
60
|
#write the actual menu line for each record
|
54
61
|
|
55
62
|
#make the selected view appear nicer
|
56
|
-
if(
|
63
|
+
if(m.id==menu_id.to_i)
|
57
64
|
concat "<li id=\"li_menu_#{m.id}\" class=\"li_menu_class_selected\">"
|
58
|
-
|
59
|
-
|
60
|
-
selectm=false
|
65
|
+
concat "<a class=\"selected_menu\", id =\"menu_link_#{m.id}\" href=\"#{m.link}?menu_id=#{m.id}\"> #{m.title} #{m.id} </a>"
|
66
|
+
session[:menu_id]=menu_id
|
61
67
|
else
|
62
68
|
concat "<li id=\"li_menu_#{m.id}\" class=\"li_menu_class\">"
|
63
|
-
concat
|
69
|
+
concat "<a class=\"menu_link_depth_#{m.depth}\", id =\"menu_link_#{m.id}\" href=\"#{m.link}?menu_id=#{m.id}\"> #{m.title} #{m.id} </a>"
|
64
70
|
end
|
65
71
|
if(admin_condition)
|
66
72
|
concat link_to_remote "Add", {:url => {:controller => menu_controller, :action => 'add_menu_form', :menu_id => m.id,:menu_model=>menu_model, :menu_controller=>menu_controller}}, {:class => "menu_links_add_#{m.depth}", :id => "add_menu_link_#{m.id}"}
|
@@ -82,15 +88,13 @@ module <%= "#{file_name.capitalize}Helper" %>
|
|
82
88
|
|
83
89
|
def add_menu_form(menu_model, menu_controller, menu_id)
|
84
90
|
form_remote_tag :url => {:controller=>menu_controller, :action=> 'add_menu'}, :html => {:id => "add_menu_form_#{menu_id}", :style=>"display: none"} do
|
85
|
-
concat "<div>"
|
86
91
|
concat "Title:"
|
87
92
|
concat text_field_tag "title", "title"
|
88
93
|
concat "Link:"
|
89
94
|
concat text_field_tag "link", "link"
|
90
95
|
concat hidden_field_tag :menu_id, menu_id
|
91
96
|
#content_tag :button, "Submit", {:type=>"submit", :class=>"button-submit"}
|
92
|
-
concat submit_tag "Add", :class => "
|
93
|
-
concat "</div>"
|
97
|
+
concat submit_tag "Add", :class => "add_button"
|
94
98
|
end
|
95
99
|
return nil
|
96
100
|
end
|
@@ -98,7 +102,6 @@ module <%= "#{file_name.capitalize}Helper" %>
|
|
98
102
|
|
99
103
|
def edit_menu_form(menu_model, menu_controller,m)
|
100
104
|
form_remote_tag :url => {:controller=>menu_controller, :action=> 'edit_menu'}, :html => {:id => "edit_menu_form_#{m.id}", :style=>"display: none"} do
|
101
|
-
concat "<div>"
|
102
105
|
concat "Title:"
|
103
106
|
concat text_field_tag "title", m.title
|
104
107
|
concat "Link:"
|
@@ -107,8 +110,7 @@ module <%= "#{file_name.capitalize}Helper" %>
|
|
107
110
|
concat text_field_tag "parent_id", m.parent_id
|
108
111
|
concat hidden_field_tag :menu_id, m.id
|
109
112
|
#concat content_tag :button, "Submit", {:type=>"submit", :class=>"button-submit"}
|
110
|
-
concat submit_tag "Edit", :class => "
|
111
|
-
concat "</div>"
|
113
|
+
concat submit_tag "Edit", :class => "edit__button"
|
112
114
|
end
|
113
115
|
return nil
|
114
116
|
end
|