Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- module TwitterbootstrapHelper
- def data_table(options = {}, &block)
- options[:data] ||= {}
- options[:data].reverse_merge!(:handler => 'dataTables')
- table(options, &block)
- end
- def table(options = {}, &block)
- options[:class] ||= ""
- options[:class] << " table table-striped table-bordered"
- options[:class].strip!
- html = ""
- html << content_tag(:h2, options[:label]) if options[:label]
- html << content_tag(:table, options.except(:label), &block)
- html.html_safe
- end
- def btn_mini_danger(*args)
- args = append_class *args, "btn-danger"
- btn_mini *args
- end
- def btn_mini_info(*args)
- args = append_class *args, "btn-info"
- btn_mini *args
- end
- def btn_mini_inverse(*args)
- args = append_class *args, "btn-inverse"
- btn_mini *args
- end
- def btn_mini_primary(*args)
- args = append_class *args, "btn-primary"
- btn_mini *args
- end
- def btn_mini_warning(*args)
- args = append_class *args, "btn-warning"
- btn_mini *args
- end
- def btn_mini(*args)
- args = append_class *args, "btn btn-mini"
- btn *args
- end
- def btn_small_danger(*args)
- args = append_class *args, "btn-danger"
- btn_small *args
- end
- def btn_small_info(*args)
- args = append_class *args, "btn-info"
- btn_small *args
- end
- def btn_small_inverse(*args)
- args = append_class *args, "btn-inverse"
- btn_small *args
- end
- def btn_small_primary(*args)
- args = append_class *args, "btn-primary"
- btn_small *args
- end
- def btn_small_warning(*args)
- args = append_class *args, "btn-warning"
- btn_small *args
- end
- def btn_small(*args)
- args = append_class *args, "btn-small"
- btn *args
- end
- def btn_danger(*args)
- args = append_class *args, "btn-danger"
- btn *args
- end
- def btn_info(*args)
- args = append_class *args, "btn-info"
- btn *args
- end
- def btn_inverse(*args)
- args = append_class *args, "btn-inverse"
- btn *args
- end
- def btn_primary(*args)
- args = append_class *args, "btn-primary"
- btn *args
- end
- def btn_success(*args)
- args = append_class *args, "btn-success"
- btn *args
- end
- def btn_small_warning(*args)
- args = append_class *args, "btn-warning"
- btn *args
- end
- def btn(*args)
- args = append_class *args, "btn"
- link_to *args
- end
- private
- def append_class(*args, klass)
- args << {} unless args.last.is_a?(Hash)
- args.last[:class] ||= ""
- args.last[:class] << " " + klass
- return args
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement