Sha256: e14f59c445e94b297be1517ef0288aefa975968916fbe4a25f6324a98ab2dbd2
Contents?: true
Size: 1.52 KB
Versions: 2
Compression:
Stored size: 1.52 KB
Contents
module FullstackCarouselHelper # <%= carousel_page_part(:slideshow, :id => 'myCarousel') do |item| %> # <img src="<%= item.photo.url %>" alt=""> # <div class="carousel-caption"> # <h4><%= item.label %></h4> # <p><%= item.description %></p> # </div> # <% end %> def carousel_page_part(key, options = {}, &block) @_fullstack_carousel_counter ||= 0 @_fullstack_carousel_counter += 1 options = { :arrows => true }.merge(options) htmlid = options.delete(:id) || "carousel-#{key}-#{@_fullstack_carousel_counter}" htmlclass = ((options.delete(:class) || "").split(/\s+/) + [ "carousel" ]).join(" ") options[:class] = htmlclass options[:id] = htmlid arrows = !!options.delete(:arrows) arrows_html = !arrows ? "" : <<-eos <a class="carousel-control left" href="##{htmlid}" data-slide="prev">‹</a> <a class="carousel-control right" href="##{htmlid}" data-slide="next">›</a> eos items_html = "" part( key, :schema => :slideshow ) do |slideshow| slideshow.items.each_with_index do |item, i| slideshow_page = capture do content_tag :div, :class => ( i == 0 ? "item active" : "item" ) do yield(item) end end items_html << slideshow_page end end content_tag :div, options do raw <<-eos <div class="carousel-inner"> #{items_html} </div> #{arrows_html} eos end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
fullstack-carousel-0.1.3 | app/helpers/fullstack_carousel_helper.rb |
fullstack-carousel-0.1.2 | app/helpers/fullstack_carousel_helper.rb |