Sha256: 2167b69a3222bd942d7fddfc412accfcbf512f50d04a0880242768833c566c42

Contents?: true

Size: 1.38 KB

Versions: 3

Compression:

Stored size: 1.38 KB

Contents

# -*- encoding : utf-8 -*-
# ============================================================================
#
#	RAILS BOOTSTRAP ENGINE
##
# ============================================================================
#
# Copyright 2012-2013 Luiz Eduardo de Oliveira Fonseca, AgĂȘncia Orangeweb
#
# Licensed under The MIT License
#
# http://opensource.org/licenses/MIT
#
module RailsBootstrapEngine

  class Navigation < Base
  
    attr_reader :collection

    def initialize(elements, options = {})
      super
      @elements = elements
    end

    def to_s
      output_buffer << content_tag(:ul, :class => build_class) do
        html = ""

        @elements.each do |e|
          html_class = build_html_class(e)
          #html << content_tag(:li, e.to_s, html_class)
          html << e.to_s
        end

        html.html_safe
      end
      super
    end

    private

    def default_options
      {}
    end

    def build_html_class(element)
      if element.options[:active_nav]
        element.options.reject! {|k,v| k == :active_nav }
        html_class = { :class => "active" }
      end
      html_class
    end

    def build_class
      classes = %w( nav )
      classes << "nav-#{ options[:type] || "tabs" }"
      classes << "nav-stacked" if options[:stacked]
      classes << options[:custom_classes]
      classes.join(" ")
    end
    
  end # Navigation
  
end # RailsBootstrapEngine

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rails-bootstrap-engine-0.0.5 lib/rails-bootstrap-engine/markup/navigation.rb
rails-bootstrap-engine-0.0.4 lib/rails-bootstrap-engine/markup/navigation.rb
rails-bootstrap-engine-0.0.3 lib/rails-bootstrap-engine/markup/navigation.rb