Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

replacing spaces with tabs, uninstalling local textmate bundle for th…

…e win!
  • Loading branch information...
commit 1e35dd80d9bb840bde7589b902fdc9b0586230db 1 parent 3fdaa3d
@CodeOfficer authored
View
20 CHANGELOG
@@ -1,16 +1,20 @@
+== 01-24-2011
+
+ * rewrote for rails 3 && (ruby 1.8 || ruby 1.9), added tests
+
== 03-07-2009
- * big change: removed the 2nd param for concat, rails no longer requires the binding be passed.
- * added a helper for creating accordions
+ * big change: removed the 2nd param for concat, rails no longer requires the binding be passed.
+ * added a helper for creating accordions
== 09-04-2008
- * big change: renamed classes, and helper 'tabs_for' now requires a block
+ * big change: renamed classes, and helper 'tabs_for' now requires a block
-== 08-28-2008
-
- * added the ability to call TabsRenderer.new with a block parameter
+== 08-28-2008
+
+ * added the ability to call TabsRenderer.new with a block parameter
== 06-22-2008 initial import
-
- * TabsRenderer added
+
+ * TabsRenderer added
View
1  Gemfile
@@ -1,4 +1,3 @@
source "http://rubygems.org"
-# Specify your gem's dependencies in ui_helpers.gemspec
gemspec
View
28 README.textile
@@ -11,10 +11,10 @@ This helper simplifies the code required to use the jQuery UI Tab plugin.
<pre><code>
<% tabs_for do |tab| %>
<% tab.create('tab_one', 'Tab 1') do %>
- # ... insert tab contents
+ # ... insert tab contents
<% end %>
<% tab.create('tab_two', 'Tab 2') do %>
- # ... insert tab contents
+ # ... insert tab contents
<% end %>
<% end %>
</code></pre>
@@ -23,19 +23,19 @@ The above will generate this HTML in your view:
<pre><code>
<div id="tabs">
- <ul>
- <li><a href="#tab_one"><span>Tab 1</span></a></li>
- <li><a href="#tab_two"><span>Tab 2</span></a></li>
- </ul>
- <div id="tab_one">
- # ... insert tab contents
- </div>
- <div id="tab_two">
- # ... insert tab contents
- </div>
+ <ul>
+ <li><a href="#tab_one"><span>Tab 1</span></a></li>
+ <li><a href="#tab_two"><span>Tab 2</span></a></li>
+ </ul>
+ <div id="tab_one">
+ # ... insert tab contents
+ </div>
+ <div id="tab_two">
+ # ... insert tab contents
+ </div>
</div>
</code></pre>
-
+
Tabs will be rendered in the order you create them.
You can easily render a tab conditionally by appending your condition to the end of
@@ -53,7 +53,7 @@ DIV as you like ...
<pre><code>
<% tabs_for(:class => 'zippy') do |tab| %>
<% tab.create('tab_one', 'Tab 1', :style => 'background: #FFF') do %>
- # ... insert tab contents
+ # ... insert tab contents
<% end %>
<% end %>
</code></pre>
View
8 Rakefile
@@ -8,8 +8,8 @@ task :default => :test
desc 'Test the simple_form plugin.'
Rake::TestTask.new(:test) do |t|
- t.libs << 'lib'
- t.libs << 'test'
- t.pattern = 'test/**/*_test.rb'
- t.verbose = true
+ t.libs << 'lib'
+ t.libs << 'test'
+ t.pattern = 'test/**/*_test.rb'
+ t.verbose = true
end
View
30 jquery_ui_rails_helpers.gemspec
@@ -1,27 +1,25 @@
# -*- encoding: utf-8 -*-
+
$:.push File.expand_path("../lib", __FILE__)
require "jquery_ui_rails_helpers/version"
Gem::Specification.new do |s|
- s.name = "jquery_ui_rails_helpers"
- s.version = JqueryUiRailsHelpers::VERSION
- s.platform = Gem::Platform::RUBY
- s.summary = "jQuery UI Rails Helpers"
- s.authors = ["CodeOfficer"]
- s.email = ["codeofficer@gmail.com"]
- s.homepage = "http://www.codeofficer.com/"
- s.description = "jQuery UI Rails Helpers"
+ s.name = "jquery_ui_rails_helpers"
+ s.version = JqueryUiRailsHelpers::VERSION
+ s.platform = Gem::Platform::RUBY
+ s.summary = "jQuery UI Rails Helpers"
+ s.authors = ["CodeOfficer"]
+ s.email = ["codeofficer@gmail.com"]
+ s.homepage = "http://www.codeofficer.com/"
+ s.description = "jQuery UI Rails Helpers"
s.add_dependency("rails", "~> 3.0.0")
s.add_dependency("shoulda", "~> 3.0.0.beta2")
- s.files = `git ls-files`.split("\n")
- s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
- s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
- s.require_paths = ["lib"]
+ s.files = `git ls-files`.split("\n")
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
+ s.require_paths = ["lib"]
- s.rubyforge_project = "jquery_ui_rails_helpers"
+ s.rubyforge_project = "jquery_ui_rails_helpers"
end
-
-
-
View
60 lib/helpers/accordions_helper.rb
@@ -1,47 +1,47 @@
module AccordionsHelper
- def accordions_for( *options, &block )
- raise ArgumentError, "Missing block" unless block_given?
- raw AccordionsHelper::AccordionsRenderer.new( *options, &block ).render
- end
+ def accordions_for( *options, &block )
+ raise ArgumentError, "Missing block" unless block_given?
+ raw AccordionsHelper::AccordionsRenderer.new( *options, &block ).render
+ end
- class AccordionsRenderer
+ class AccordionsRenderer
- def initialize( options={}, &block )
- raise ArgumentError, "Missing block" unless block_given?
+ def initialize( options={}, &block )
+ raise ArgumentError, "Missing block" unless block_given?
- @template = eval( 'self', block.binding )
- @options = options
- @accordions = []
+ @template = eval( 'self', block.binding )
+ @options = options
+ @accordions = []
- yield self
- end
+ yield self
+ end
- def create( accordion_id, accordion_text, options={}, &block )
- raise "Block needed for AccordionsRenderer#CREATE" unless block_given?
- @accordions << [ accordion_id, accordion_text, options, block ]
- end
+ def create( accordion_id, accordion_text, options={}, &block )
+ raise "Block needed for AccordionsRenderer#CREATE" unless block_given?
+ @accordions << [ accordion_id, accordion_text, options, block ]
+ end
- def render
+ def render
content = @accordions.collect do |accordion|
accordion_head(accordion) << accordion_body(accordion)
end.join
- content_tag( :div, raw(content), { :id => :accordions }.merge( @options ) )
- end
+ content_tag( :div, raw(content), { :id => :accordions }.merge( @options ) )
+ end
- private # ---------------------------------------------------------------------------
+ private # ---------------------------------------------------------------------------
- def accordion_head(accordion)
- content_tag :h3, link_to(accordion[1], '#'), :id => accordion[0]
- end
+ def accordion_head(accordion)
+ content_tag :h3, link_to(accordion[1], '#'), :id => accordion[0]
+ end
- def accordion_body(accordion)
- content_tag :div, capture( &accordion[3] )
- end
+ def accordion_body(accordion)
+ content_tag :div, capture( &accordion[3] )
+ end
- def method_missing( *args, &block )
- @template.send( *args, &block )
- end
+ def method_missing( *args, &block )
+ @template.send( *args, &block )
+ end
- end
+ end
end
View
12 lib/helpers/javascripts_helper.rb
@@ -1,12 +1,12 @@
module JavascriptsHelper
- def stylesheet(*args)
- content_for(:head) { stylesheet_link_tag(*args) }
- end
+ def stylesheet(*args)
+ content_for(:head) { stylesheet_link_tag(*args) }
+ end
- def javascript(*args)
- content_for(:head) { javascript_include_tag(*args) }
- end
+ def javascript(*args)
+ content_for(:head) { javascript_include_tag(*args) }
+ end
def field_id_for_js(f, attribute)
"#{f.object_name}[#{attribute.to_s.sub(/\?$/,"")}]".gsub(/\]\[|[^-a-zA-Z0-9:.]/, "_").sub(/_$/, "")
View
82 lib/helpers/tabs_helper.rb
@@ -2,64 +2,64 @@
# module JqueryUiRailsHelpers
module TabsHelper
- def tabs_for( *options, &block )
- raise ArgumentError, "Missing block" unless block_given?
- raw TabsHelper::TabsRenderer.new( *options, &block ).render
- end
+ def tabs_for( *options, &block )
+ raise ArgumentError, "Missing block" unless block_given?
+ raw TabsHelper::TabsRenderer.new( *options, &block ).render
+ end
- class TabsRenderer
+ class TabsRenderer
- def initialize( options={}, &block )
- raise ArgumentError, "Missing block" unless block_given?
+ def initialize( options={}, &block )
+ raise ArgumentError, "Missing block" unless block_given?
- @template = eval( 'self', block.binding )
- @options = options
- @tabs = []
+ @template = eval( 'self', block.binding )
+ @options = options
+ @tabs = []
- yield self
- end
+ yield self
+ end
- def create( tab_id, tab_text, options={}, &block )
- raise "Block needed for TabsRenderer#CREATE" unless block_given?
- @tabs << [ tab_id, tab_text, options, block, {:ajax => false} ]
- end
+ def create( tab_id, tab_text, options={}, &block )
+ raise "Block needed for TabsRenderer#CREATE" unless block_given?
+ @tabs << [ tab_id, tab_text, options, block, {:ajax => false} ]
+ end
- def create_ajax( link, tab_text, options={})
- @tabs << [ link, tab_text, options, nil, {:ajax => true} ]
- end
+ def create_ajax( link, tab_text, options={})
+ @tabs << [ link, tab_text, options, nil, {:ajax => true} ]
+ end
- def render
- content_tag( :div, raw([render_tabs, render_bodies].join), { :id => :tabs }.merge( @options ) )
- end
+ def render
+ content_tag( :div, raw([render_tabs, render_bodies].join), { :id => :tabs }.merge( @options ) )
+ end
- private # ---------------------------------------------------------------------------
+ private # ---------------------------------------------------------------------------
- def render_tabs
- content_tag :ul do
- result = @tabs.collect do |tab|
+ def render_tabs
+ content_tag :ul do
+ result = @tabs.collect do |tab|
if tab[4][:ajax]
- content_tag( :li, link_to( content_tag( :span, raw(tab[1]) ), "#{tab[0]}" ) )
+ content_tag( :li, link_to( content_tag( :span, raw(tab[1]) ), "#{tab[0]}" ) )
else
- content_tag( :li, link_to( content_tag( :span, raw(tab[1]) ), "##{tab[0]}" ) )
+ content_tag( :li, link_to( content_tag( :span, raw(tab[1]) ), "##{tab[0]}" ) )
end
- end.join
+ end.join
raw(result)
- end
- end
+ end
+ end
- def render_bodies
- @tabs.collect do |tab|
+ def render_bodies
+ @tabs.collect do |tab|
if tab[4][:ajax]
- # there are no divs for ajaxed tabs
+ # there are no divs for ajaxed tabs
else
- content_tag( :div, capture( &tab[3] ), tab[2].merge( :id => tab[0] ) )
+ content_tag( :div, capture( &tab[3] ), tab[2].merge( :id => tab[0] ) )
end
- end.join.to_s
- end
+ end.join.to_s
+ end
- def method_missing( *args, &block )
- @template.send( *args, &block )
- end
+ def method_missing( *args, &block )
+ @template.send( *args, &block )
+ end
- end
+ end
end
View
2  lib/jquery_ui_rails_helpers/version.rb
@@ -1,3 +1,3 @@
module JqueryUiRailsHelpers
- VERSION = "0.0.2"
+ VERSION = "0.0.2"
end
View
14 test/test_helper.rb
@@ -22,13 +22,13 @@ class ActionView::TestCase
setup :shhhhhh_url_helpers
def shhhhhh_url_helpers
- def @controller._routes
- Module.new do
- def self.url_helpers
- Module.new
- end
- end
- end
+ def @controller._routes
+ Module.new do
+ def self.url_helpers
+ Module.new
+ end
+ end
+ end
end
end
View
14 test/unit/helper/accordions_helper_test.rb
@@ -4,9 +4,9 @@ class AccordionsHelperTest < ActionView::TestCase
context "creating accordions without a block syntax" do
should 'raises an exception' do
- assert_raise ArgumentError do
- @accordions = accordions_for
- end
+ assert_raise ArgumentError do
+ @accordions = accordions_for
+ end
end
end
@@ -32,8 +32,8 @@ class AccordionsHelperTest < ActionView::TestCase
end
# <div id="accordions">
-# <h3 id="accordion_one"><a href="#">One</a></h3>
-# <div>Accordion Two.</div>
-# <h3 id="accordion_two"><a href="#">Two</a></h3>
-# <div>Accordion One.</div>
+# <h3 id="accordion_one"><a href="#">One</a></h3>
+# <div>Accordion Two.</div>
+# <h3 id="accordion_two"><a href="#">Two</a></h3>
+# <div>Accordion One.</div>
# </div>
View
20 test/unit/helper/tabs_helper_test.rb
@@ -4,9 +4,9 @@ class TabsHelperTest < ActionView::TestCase
context "creating tabs without a block syntax" do
should 'raises an exception' do
- assert_raise ArgumentError do
- @tabs = tabs_for
- end
+ assert_raise ArgumentError do
+ @tabs = tabs_for
+ end
end
end
@@ -51,11 +51,11 @@ class TabsHelperTest < ActionView::TestCase
end
# <div id="tabs">
-# <ul>
-# <li><a href="#tab_one"><span>One</span></a></li>
-# <li><a href="#tab_two"><span>Two</span></a></li>
-# <li><a href="http://www.codeofficer.com/"><span>Ajax</span></a></li>
-# </ul>
-# <div id="tab_one">Tab One.</div>
-# <div id="tab_two">Tab Two.</div>
+# <ul>
+# <li><a href="#tab_one"><span>One</span></a></li>
+# <li><a href="#tab_two"><span>Two</span></a></li>
+# <li><a href="http://www.codeofficer.com/"><span>Ajax</span></a></li>
+# </ul>
+# <div id="tab_one">Tab One.</div>
+# <div id="tab_two">Tab Two.</div>
# </div>
Please sign in to comment.
Something went wrong with that request. Please try again.