dynamic_menu 0.1.0 → 0.2.0
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/README.rdoc +28 -1
- data/Rakefile +1 -1
- data/dynamic_menu.gemspec +2 -2
- data/lib/dynamic_menu.rb +27 -11
- metadata +2 -2
data/README.rdoc
CHANGED
@@ -4,10 +4,18 @@ Dynamic Menu is a gem to make it easy to add a custom menu to your application v
|
|
4
4
|
== Install
|
5
5
|
You need to add:
|
6
6
|
|
7
|
+
gem "dynamic_menu"
|
8
|
+
|
9
|
+
to your gemfile if you would like the latest stable version
|
10
|
+
|
11
|
+
if you would like the latest version (could be broke at download) you can add
|
12
|
+
this line to your gemfile:
|
13
|
+
|
7
14
|
gem "dynamic_menu",:git=>"git://github.com/plowdawg/dynamic_menu.git"
|
8
15
|
|
9
|
-
to your gemfile
|
10
16
|
== How to use
|
17
|
+
|
18
|
+
===Option1
|
11
19
|
You can create an array in a controller like so:
|
12
20
|
|
13
21
|
@actionMenuItem = Array.new
|
@@ -30,3 +38,22 @@ option1 = DynamicMenu::ActionMenuItem.new("Link Name", link_to_path, :delete, "A
|
|
30
38
|
|
31
39
|
the first is what the link will look like on the view, second is the view, third is the method (only works
|
32
40
|
for delete) and the fourth is the confirmation method (which also only works on delete)
|
41
|
+
|
42
|
+
===Option2
|
43
|
+
Like Option1 except in your controller you can declare include DynamicForm right underneath the class
|
44
|
+
|
45
|
+
like so:
|
46
|
+
|
47
|
+
class SomeController < ApplicationController
|
48
|
+
|
49
|
+
include DynamicMenu
|
50
|
+
|
51
|
+
then instead of using DynamicMenu::ActionMenuItem.new you can use ActionMenuItem.new
|
52
|
+
|
53
|
+
|
54
|
+
==Tips
|
55
|
+
To prevent long code you can no arrays like so:
|
56
|
+
|
57
|
+
@actionMenuItems = Array.new
|
58
|
+
|
59
|
+
@actionMenuItems << ActionMenuItem.new("Link",link_path)
|
data/Rakefile
CHANGED
data/dynamic_menu.gemspec
CHANGED
@@ -2,11 +2,11 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{dynamic_menu}
|
5
|
-
s.version = "0.
|
5
|
+
s.version = "0.2.0"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = [%q{Travis Pessettto}]
|
9
|
-
s.date = %q{2011-08-
|
9
|
+
s.date = %q{2011-08-03}
|
10
10
|
s.description = %q{Allow the creation of Menus}
|
11
11
|
s.email = %q{travis@pessetto.com}
|
12
12
|
s.extra_rdoc_files = [%q{README.rdoc}, %q{lib/dynamic_menu.rb}]
|
data/lib/dynamic_menu.rb
CHANGED
@@ -2,23 +2,39 @@ module DynamicMenu
|
|
2
2
|
|
3
3
|
class ActionMenuItem
|
4
4
|
include ActionView::Helpers::UrlHelper
|
5
|
+
include ActionView::Helpers::JavaScriptHelper
|
5
6
|
|
6
7
|
attr_accessor :name, :link, :method, :link_tag
|
7
8
|
|
8
|
-
def initialize(name, link, method = :get, confirm="Are You Sure?")
|
9
|
+
def initialize(name, link , method = :get, confirm="Are You Sure?")
|
9
10
|
@name = name
|
10
11
|
@link = link
|
11
12
|
@method = method
|
12
13
|
@link_tag = ""
|
13
14
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
15
|
+
|
16
|
+
if method == :delete
|
17
|
+
@link_tag = link_to name, link, :method=>method, :confirm=>confirm
|
18
|
+
else
|
19
|
+
if link == :submit
|
20
|
+
#make it easy to include a submit button via link...for enter support...requires
|
21
|
+
#JQUERY!!!
|
22
|
+
@link_tag = link_to_function name, "$('form').submit()"
|
23
|
+
@link_tag += "<script type=\"text/javascript\">
|
24
|
+
$(document).ready(function(){
|
25
|
+
$('form').keypress(function(e){
|
26
|
+
if(e.which == 13){
|
27
|
+
$('form').submit();
|
28
|
+
return false;
|
29
|
+
}
|
30
|
+
});
|
31
|
+
});</script>".html_safe
|
32
|
+
else
|
33
|
+
@link_tag = link_to name, link
|
34
|
+
end #end if submit
|
35
|
+
end #end if delete
|
36
|
+
end #end initalize
|
21
37
|
|
22
|
-
|
23
|
-
|
24
|
-
end
|
38
|
+
end #end actionmenu Item
|
39
|
+
|
40
|
+
end #end Modlue
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dynamic_menu
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-08-
|
12
|
+
date: 2011-08-03 00:00:00.000000000Z
|
13
13
|
dependencies: []
|
14
14
|
description: Allow the creation of Menus
|
15
15
|
email: travis@pessetto.com
|