midas-g_toggle_block 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +3 -0
- data/Manifest.txt +18 -0
- data/PostInstall.txt +7 -0
- data/README.rdoc +71 -0
- data/Rakefile +30 -0
- data/lib/g_toggle_block/view_helpers.rb +31 -0
- data/lib/g_toggle_block.rb +10 -0
- data/rails_generators/toggle_block_assets/templates/guilded.toggle_block.js +25 -0
- data/rails_generators/toggle_block_assets/templates/guilded.toggle_block.min.js +2 -0
- data/rails_generators/toggle_block_assets/toggle_block_assets_generator.rb +12 -0
- data/script/console +10 -0
- data/script/destroy +14 -0
- data/script/generate +14 -0
- data/spec/g_toggle_block_spec.rb +11 -0
- data/spec/spec.opts +1 -0
- data/spec/spec_helper.rb +10 -0
- data/tasks/rspec.rake +21 -0
- metadata +113 -0
data/History.txt
ADDED
data/Manifest.txt
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
History.txt
|
2
|
+
Manifest.txt
|
3
|
+
PostInstall.txt
|
4
|
+
README.rdoc
|
5
|
+
Rakefile
|
6
|
+
g_toggle_block.gemspec
|
7
|
+
lib/g_toggle_block.rb
|
8
|
+
lib/g_toggle_block/view_helpers.rb
|
9
|
+
rails_generators/toggle_block_assets/templates/guilded.toggle_block.js
|
10
|
+
rails_generators/toggle_block_assets/templates/guilded.toggle_block.min.js
|
11
|
+
rails_generators/toggle_block_assets/toggle_block_assets_generator.rb
|
12
|
+
script/console
|
13
|
+
script/destroy
|
14
|
+
script/generate
|
15
|
+
spec/g_toggle_block_spec.rb
|
16
|
+
spec/spec.opts
|
17
|
+
spec/spec_helper.rb
|
18
|
+
tasks/rspec.rake
|
data/PostInstall.txt
ADDED
data/README.rdoc
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
= g_toggle_block
|
2
|
+
|
3
|
+
http://github.com/midas/g_toggle_block/tree/master
|
4
|
+
|
5
|
+
|
6
|
+
== DESCRIPTION:
|
7
|
+
|
8
|
+
A Rails Guilded (http://github.com/midas/guilded/tree/master) component allowing a block of markup to be shown and
|
9
|
+
hidden by toggling another control.
|
10
|
+
|
11
|
+
|
12
|
+
== FEATURES:
|
13
|
+
|
14
|
+
* Easily create a collapsible area that can be toggled using another HTML control or element.
|
15
|
+
|
16
|
+
|
17
|
+
== USAGE:
|
18
|
+
|
19
|
+
This is just one possible use of the toggle block control. In this example we will be showing or hiding additional form fields
|
20
|
+
based on a check box being checked.
|
21
|
+
|
22
|
+
# within form ...
|
23
|
+
|
24
|
+
<%= f.check_box "user[role_ids][]", role.id, @user.roles.include?(role), {:id => "toggle-optional-fields"} %> Role with Optional Fields
|
25
|
+
|
26
|
+
<% g_toggle_block :id => "optional-fields", :toggler_id => "toggle-cecbems-required" do %>
|
27
|
+
<%= f.text_field :another_field_1 %>
|
28
|
+
<%= f.text_field :another_field_2 %>
|
29
|
+
# ...
|
30
|
+
<% end %>
|
31
|
+
|
32
|
+
|
33
|
+
== REQUIREMENTS:
|
34
|
+
|
35
|
+
* Rails >= 2.2.0
|
36
|
+
* Guilded >= 0.1.4 (http://github.com/midas/guilded/tree/master)
|
37
|
+
|
38
|
+
|
39
|
+
== INSTALL:
|
40
|
+
|
41
|
+
sudo gem install midas-g_toggle_block
|
42
|
+
|
43
|
+
In rails environment.rb file:
|
44
|
+
|
45
|
+
config.gem 'midas-g_toggle_block', :version => "1.0.0", :lib => 'g_toggle_block', :source => 'http://gems.github.com'
|
46
|
+
|
47
|
+
|
48
|
+
== LICENSE:
|
49
|
+
|
50
|
+
(The MIT License)
|
51
|
+
|
52
|
+
Copyright (c) 2009 C. Jason Harrelson (midas)
|
53
|
+
|
54
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
55
|
+
a copy of this software and associated documentation files (the
|
56
|
+
'Software'), to deal in the Software without restriction, including
|
57
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
58
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
59
|
+
permit persons to whom the Software is furnished to do so, subject to
|
60
|
+
the following conditions:
|
61
|
+
|
62
|
+
The above copyright notice and this permission notice shall be
|
63
|
+
included in all copies or substantial portions of the Software.
|
64
|
+
|
65
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
66
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
67
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
68
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
69
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
70
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
71
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
%w[rubygems rake rake/clean fileutils newgem rubigen].each { |f| require f }
|
2
|
+
require File.dirname(__FILE__) + '/lib/g_toggle_block'
|
3
|
+
|
4
|
+
# Generate all the Rake tasks
|
5
|
+
# Run 'rake -T' to see list of generated tasks (from gem root directory)
|
6
|
+
$hoe = Hoe.new('g_toggle_block', GToggleBlock::VERSION) do |p|
|
7
|
+
p.developer('C. Jason Harrelson (midas)', 'jason@lookforwardenterprises.com')
|
8
|
+
p.changes = p.paragraphs_of("History.txt", 0..1).join("\n\n")
|
9
|
+
p.post_install_message = 'PostInstall.txt' # TODO remove if post-install message not required
|
10
|
+
p.rubyforge_name = p.name # TODO this is default value
|
11
|
+
# p.extra_deps = [
|
12
|
+
# ['activesupport','>= 2.0.2'],
|
13
|
+
# ]
|
14
|
+
p.extra_dev_deps = [
|
15
|
+
['newgem', ">= #{::Newgem::VERSION}"],
|
16
|
+
['rails', ">= 2.2.0"],
|
17
|
+
['midas-guilded', ">=0.1.4"]
|
18
|
+
]
|
19
|
+
|
20
|
+
p.clean_globs |= %w[**/.DS_Store tmp *.log]
|
21
|
+
path = (p.rubyforge_name == p.name) ? p.rubyforge_name : "\#{p.rubyforge_name}/\#{p.name}"
|
22
|
+
p.remote_rdoc_dir = File.join(path.gsub(/^#{p.rubyforge_name}\/?/,''), 'rdoc')
|
23
|
+
p.rsync_args = '-av --delete --ignore-errors'
|
24
|
+
end
|
25
|
+
|
26
|
+
require 'newgem/tasks' # load /tasks/*.rake
|
27
|
+
Dir['tasks/**/*.rake'].each { |t| load t }
|
28
|
+
|
29
|
+
# TODO - want other tests/tasks run by default? Add them to the list
|
30
|
+
# task :default => [:spec, :features]
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module GToggleBlock
|
2
|
+
module ViewHelpers
|
3
|
+
|
4
|
+
# GUIlded component. This is a div container that will show and hide itself based
|
5
|
+
# on the state of another element (currently only a check box). Different animations
|
6
|
+
# can be used.
|
7
|
+
#
|
8
|
+
# The HTML included inside of this block is rendered inside the block element in the HTML.
|
9
|
+
#
|
10
|
+
# *options*
|
11
|
+
# id:: (required) The id of the element. Must be unique on the page.
|
12
|
+
# exclude_css:: A boolean indicating if Guilded should create a stylesheet inlcude tag for
|
13
|
+
# this element. Defaults to false.
|
14
|
+
# toggler_id:: The id of the element that will toggle the block. Defaults to toggle-{id}.
|
15
|
+
# animation:: The animation to use when showing or hiding. Valid values are: [ 'slide', 'fade' ].
|
16
|
+
# Defaults to 'slide'.
|
17
|
+
#
|
18
|
+
def g_toggle_block( options={}, &block )
|
19
|
+
raise ArgumentError, "Block required" unless block_given?
|
20
|
+
# Set the default value for the toggler id if not provided
|
21
|
+
options[:toggler_id] ||= "toggle-#{options[:id]}"
|
22
|
+
# Add the element to the inits data structure so that the javascript initialization
|
23
|
+
# code can be generated.
|
24
|
+
options.merge! :exclude_css => true
|
25
|
+
Guilded::Guilder.instance.add( :toggle_block, options )
|
26
|
+
# Add the HTML to the caller.
|
27
|
+
concat( content_tag( :div, capture( &block ), options ), block.binding )
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
$:.unshift(File.dirname(__FILE__)) unless
|
2
|
+
$:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
|
3
|
+
|
4
|
+
module GToggleBlock
|
5
|
+
VERSION = '1.0.0'
|
6
|
+
end
|
7
|
+
|
8
|
+
if defined? ActionView::Base
|
9
|
+
ActionView::Base.send( :include, GToggleBlock::ViewHelpers ) unless ActionView::Base.include?( GToggleBlock::ViewHelpers )
|
10
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
g.toggle = function( e )
|
2
|
+
{
|
3
|
+
$j( e.data.selector ).slideToggle();
|
4
|
+
};
|
5
|
+
|
6
|
+
g.toggleBlockInit = function( options )
|
7
|
+
{
|
8
|
+
if( !options )
|
9
|
+
{
|
10
|
+
options = {};
|
11
|
+
}
|
12
|
+
|
13
|
+
var toggleSel = '#' + options.id; //jQuery selector for the toggle element
|
14
|
+
var toggleDiv = $j( toggleSel );
|
15
|
+
var toggleChk = $jid( options.toggler_id );
|
16
|
+
|
17
|
+
toggleChk.bind( "click", { selector: toggleSel }, g.toggle );
|
18
|
+
|
19
|
+
// Toggle to initial state
|
20
|
+
if( toggleChk[0].checked == false )
|
21
|
+
{
|
22
|
+
toggleDiv.hide();
|
23
|
+
}
|
24
|
+
};
|
25
|
+
|
@@ -0,0 +1,2 @@
|
|
1
|
+
g.toggle=function(e){$j( e.data.selector ).slideToggle();};g.toggleBlockInit=function(options){if(!options){options={};}var toggleDiv=$j( toggleSel );var toggleChk=$jid(options.toggler_id);toggleChk.bind("click",{selector:toggleSel},g.toggle);if(toggleChk[0].checked==false){toggleDiv.hide();}};
|
2
|
+
|
@@ -0,0 +1,12 @@
|
|
1
|
+
class ToggleBlockAssetsGenerator < Rails::Generator::Base
|
2
|
+
def initialize(runtime_args, runtime_options = {})
|
3
|
+
super
|
4
|
+
end
|
5
|
+
|
6
|
+
def manifest
|
7
|
+
record do |m|
|
8
|
+
m.file "guilded.toggle_block.js", "public/javascripts/guilded.toggle_block.js"
|
9
|
+
m.file "guilded.toggle_block.min.js", "public/javascripts/guilded.toggle_block.min.js"
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
data/script/console
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# File: script/console
|
3
|
+
irb = RUBY_PLATFORM =~ /(:?mswin|mingw)/ ? 'irb.bat' : 'irb'
|
4
|
+
|
5
|
+
libs = " -r irb/completion"
|
6
|
+
# Perhaps use a console_lib to store any extra methods I may want available in the cosole
|
7
|
+
# libs << " -r #{File.dirname(__FILE__) + '/../lib/console_lib/console_logger.rb'}"
|
8
|
+
libs << " -r #{File.dirname(__FILE__) + '/../lib/g_toggle_block.rb'}"
|
9
|
+
puts "Loading g_toggle_block gem"
|
10
|
+
exec "#{irb} #{libs} --simple-prompt"
|
data/script/destroy
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'rubigen'
|
6
|
+
rescue LoadError
|
7
|
+
require 'rubygems'
|
8
|
+
require 'rubigen'
|
9
|
+
end
|
10
|
+
require 'rubigen/scripts/destroy'
|
11
|
+
|
12
|
+
ARGV.shift if ['--help', '-h'].include?(ARGV[0])
|
13
|
+
RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
|
14
|
+
RubiGen::Scripts::Destroy.new.run(ARGV)
|
data/script/generate
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'rubigen'
|
6
|
+
rescue LoadError
|
7
|
+
require 'rubygems'
|
8
|
+
require 'rubigen'
|
9
|
+
end
|
10
|
+
require 'rubigen/scripts/generate'
|
11
|
+
|
12
|
+
ARGV.shift if ['--help', '-h'].include?(ARGV[0])
|
13
|
+
RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
|
14
|
+
RubiGen::Scripts::Generate.new.run(ARGV)
|
data/spec/spec.opts
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--colour
|
data/spec/spec_helper.rb
ADDED
data/tasks/rspec.rake
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
begin
|
2
|
+
require 'spec'
|
3
|
+
rescue LoadError
|
4
|
+
require 'rubygems'
|
5
|
+
require 'spec'
|
6
|
+
end
|
7
|
+
begin
|
8
|
+
require 'spec/rake/spectask'
|
9
|
+
rescue LoadError
|
10
|
+
puts <<-EOS
|
11
|
+
To use rspec for testing you must install rspec gem:
|
12
|
+
gem install rspec
|
13
|
+
EOS
|
14
|
+
exit(0)
|
15
|
+
end
|
16
|
+
|
17
|
+
desc "Run the specs under spec/models"
|
18
|
+
Spec::Rake::SpecTask.new do |t|
|
19
|
+
t.spec_opts = ['--options', "spec/spec.opts"]
|
20
|
+
t.spec_files = FileList['spec/**/*_spec.rb']
|
21
|
+
end
|
metadata
ADDED
@@ -0,0 +1,113 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: midas-g_toggle_block
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- C. Jason Harrelson (midas)
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-03-18 00:00:00 -07:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: newgem
|
17
|
+
type: :development
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 1.2.3
|
24
|
+
version:
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: rails
|
27
|
+
type: :development
|
28
|
+
version_requirement:
|
29
|
+
version_requirements: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 2.2.0
|
34
|
+
version:
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: midas-guilded
|
37
|
+
type: :development
|
38
|
+
version_requirement:
|
39
|
+
version_requirements: !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: 0.1.4
|
44
|
+
version:
|
45
|
+
- !ruby/object:Gem::Dependency
|
46
|
+
name: hoe
|
47
|
+
type: :development
|
48
|
+
version_requirement:
|
49
|
+
version_requirements: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - ">="
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: 1.8.0
|
54
|
+
version:
|
55
|
+
description: A Rails Guilded (http://github.com/midas/guilded/tree/master) component allowing a block of markup to be shown and hidden by toggling another control.
|
56
|
+
email:
|
57
|
+
- jason@lookforwardenterprises.com
|
58
|
+
executables: []
|
59
|
+
|
60
|
+
extensions: []
|
61
|
+
|
62
|
+
extra_rdoc_files:
|
63
|
+
- History.txt
|
64
|
+
- Manifest.txt
|
65
|
+
- PostInstall.txt
|
66
|
+
- README.rdoc
|
67
|
+
files:
|
68
|
+
- History.txt
|
69
|
+
- Manifest.txt
|
70
|
+
- PostInstall.txt
|
71
|
+
- README.rdoc
|
72
|
+
- Rakefile
|
73
|
+
- lib/g_toggle_block.rb
|
74
|
+
- lib/g_toggle_block/view_helpers.rb
|
75
|
+
- rails_generators/toggle_block_assets/templates/guilded.toggle_block.js
|
76
|
+
- rails_generators/toggle_block_assets/templates/guilded.toggle_block.min.js
|
77
|
+
- rails_generators/toggle_block_assets/toggle_block_assets_generator.rb
|
78
|
+
- script/console
|
79
|
+
- script/destroy
|
80
|
+
- script/generate
|
81
|
+
- spec/g_toggle_block_spec.rb
|
82
|
+
- spec/spec.opts
|
83
|
+
- spec/spec_helper.rb
|
84
|
+
- tasks/rspec.rake
|
85
|
+
has_rdoc: true
|
86
|
+
homepage: http://github.com/midas/g_toggle_block/tree/master
|
87
|
+
post_install_message: PostInstall.txt
|
88
|
+
rdoc_options:
|
89
|
+
- --main
|
90
|
+
- README.rdoc
|
91
|
+
require_paths:
|
92
|
+
- lib
|
93
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
94
|
+
requirements:
|
95
|
+
- - ">="
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: "0"
|
98
|
+
version:
|
99
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: "0"
|
104
|
+
version:
|
105
|
+
requirements: []
|
106
|
+
|
107
|
+
rubyforge_project: g_toggle_block
|
108
|
+
rubygems_version: 1.2.0
|
109
|
+
signing_key:
|
110
|
+
specification_version: 2
|
111
|
+
summary: A Rails Guilded (http://github.com/midas/guilded/tree/master) component allowing a block of markup to be shown and hidden by toggling another control.
|
112
|
+
test_files: []
|
113
|
+
|