├── .gitignore ├── Gemfile ├── README.md ├── Rakefile ├── bootstrap-rails.gemspec ├── lib ├── bootstrap-rails.rb ├── bootstrap-rails │ ├── breadcrumb.rb │ ├── engine.rb │ ├── helper.rb │ ├── railtie.rb │ └── version.rb └── bootstrap │ └── rails.rb └── vendor ├── assets ├── javascripts │ ├── bootstrap-alerts.js │ ├── bootstrap-buttons.js │ ├── bootstrap-dropdown.js │ ├── bootstrap-modal.js │ ├── bootstrap-popover.js │ ├── bootstrap-scrollspy.js │ ├── bootstrap-tabs.js │ ├── bootstrap-twipsy.js │ └── bootstrap.js └── stylesheets │ ├── bootstrap.scss │ ├── forms.scss │ ├── mixins.scss │ ├── patterns.scss │ ├── reset.scss │ ├── scaffolding.scss │ ├── tables.scss │ ├── type.scss │ └── variables.scss └── twitter ├── .gitignore ├── LICENSE ├── Makefile ├── README.md ├── bootstrap.css ├── bootstrap.min.css ├── docs ├── assets │ ├── css │ │ └── docs.css │ ├── ico │ │ ├── bootstrap-apple-114x114.png │ │ ├── bootstrap-apple-57x57.png │ │ ├── bootstrap-apple-72x72.png │ │ └── favicon.ico │ ├── img │ │ ├── bird.png │ │ ├── browsers.png │ │ ├── example-diagram-01.png │ │ ├── example-diagram-02.png │ │ ├── example-diagram-03.png │ │ ├── grid-18px.png │ │ └── twitter-logo-no-bird.png │ └── js │ │ ├── application.js │ │ └── google-code-prettify │ │ ├── prettify.css │ │ └── prettify.js ├── index.html └── javascript.html ├── examples ├── container-app.html ├── fluid.html └── hero.html ├── js ├── bootstrap-alerts.js ├── bootstrap-dropdown.js ├── bootstrap-modal.js ├── bootstrap-popover.js ├── bootstrap-scrollspy.js ├── bootstrap-tabs.js ├── bootstrap-twipsy.js └── tests │ ├── index.html │ ├── unit │ ├── bootstrap-alerts.js │ ├── bootstrap-dropdown.js │ ├── bootstrap-modal.js │ ├── bootstrap-popover.js │ ├── bootstrap-scrollspy.js │ ├── bootstrap-tabs.js │ └── bootstrap-twipsy.js │ └── vendor │ ├── qunit.css │ └── qunit.js └── lib ├── bootstrap.scss ├── forms.scss ├── mixins.scss ├── patterns.scss ├── reset.scss ├── scaffolding.scss ├── tables.scss ├── type.scss └── variables.scss /.gitignore: -------------------------------------------------------------------------------- 1 | *.gem 2 | *.rbc 3 | .bundle 4 | .config 5 | .yardoc 6 | Gemfile.lock 7 | InstalledFiles 8 | _yardoc 9 | coverage 10 | doc/ 11 | lib/bundler/man 12 | pkg 13 | rdoc 14 | spec/reports 15 | test/tmp 16 | test/version_tmp 17 | tmp 18 | -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | source 'http://rubygems.org' 2 | 3 | # Specify your gem's dependencies in bootstrap-rails.gemspec 4 | gemspec 5 | 6 | gem "simple_form", :require => "simple_form" -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Twitter Bootstrap for Rails 3 2 | Bootstrap is a toolkit from Twitter designed to kickstart development of webapps and sites. 3 | It includes base CSS and HTML for typography, forms, buttons, tables, grids, navigation, and more. 4 | 5 | 6 | 7 | anjlab-bootstrap-rails project integrates Bootstrap CSS (with SASS flavour) and JS toolkits for Rails 3 projects 8 | 9 | ## Rails 3.1 10 | Include Bootstrap in Gemfile; 11 | 12 | ``` ruby 13 | gem 'simple_form' 14 | gem 'bootstrap-rails', :require => 'bootstrap-rails', 15 | :git => 'git://github.com/xdite/bootstrap-rails.git' 16 | ``` 17 | 18 | and run bundle install. 19 | 20 | ## Stylesheets 21 | 22 | Add necessary stylesheet file to app/assets/stylesheets/application.css 23 | 24 | ``` css 25 | *= require bootstrap 26 | ``` 27 | 28 | You can override boostrapr variables: 29 | 30 | ``` csss 31 | // Create app/assets/stylesheets/bootstrap.scss 32 | // CSS Reset 33 | @import "reset.scss"; 34 | 35 | // Core variables and mixins 36 | @import "variables.scss"; // Modify this for custom colors, font-sizes, etc 37 | 38 | $linkColor: red; // Make all links red 39 | 40 | @import "mixins.scss"; 41 | 42 | // Grid system and page structure 43 | @import "scaffolding.scss"; 44 | 45 | // Styled patterns and elements 46 | @import "type.scss"; 47 | @import "forms.scss"; 48 | @import "tables.scss"; 49 | @import "patterns.scss"; 50 | ``` 51 | 52 | ## Javascripts 53 | 54 | Add necessary javascript(s) files to app/assets/javascripts/application.js 55 | 56 | ``` javascript 57 | // Include all twitter's javascripts 58 | //= require bootstrap 59 | 60 | // Or peek any of them yourself 61 | //= require bootstrap-alerts 62 | //= require bootstrap-dropdown 63 | //= require bootstrap-modal 64 | //= require bootstrap-twipsy 65 | //= require bootstrap-popover 66 | //= require bootstrap-scrollspy 67 | //= require bootstrap-tabs 68 | ``` 69 | 70 | ## Thanks 71 | Thanks Twitter for Bootstrap 72 | http://twitter.github.com/bootstrap 73 | 74 | Inspired by Seyhun Akyürek and his [twitter-bootstrap-rails gem](https://github.com/seyhunak/twitter-bootstrap-rails) 75 | 76 | ## License 77 | Copyright (c) 2011 AnjLab 78 | 79 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 80 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 81 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------- /Rakefile: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env rake 2 | require "bundler/gem_tasks" 3 | 4 | desc "Update Twitter's Bootstrap" 5 | task "update-twitter" do 6 | boostrap_version = "1.3.0" 7 | Dir["vendor/assets/stylesheets/*.*"].each {|f| FileUtils.rm(f)} 8 | Dir["vendor/twitter/lib/*.scss"].each do |file| 9 | cp file, "vendor/assets/stylesheets/", :verbose => true 10 | end 11 | bootstrap_scss = File.read("vendor/assets/stylesheets/bootstrap.scss") 12 | 13 | bootstrap_scss.gsub!(/@VERSION/, "v#{boostrap_version}") 14 | bootstrap_scss.gsub!(/^.*@DATE.*/, " *") 15 | 16 | File.open("vendor/assets/stylesheets/bootstrap.scss", "w") do |f| 17 | f.write(bootstrap_scss) 18 | end 19 | 20 | Dir["vendor/assets/javascripts/*.*"].each {|f| FileUtils.rm(f)} 21 | js_files = Dir["vendor/twitter/js/*.js"].map() 22 | js_files.each do |file| 23 | cp file, "vendor/assets/javascripts/", :verbose => true 24 | end 25 | 26 | js_priorities = {} 27 | js_files.each {|f| js_priorities[File.basename(f)] = 0} 28 | 29 | # popover depend on twipsy 30 | js_priorities["bootstrap-twipsy.js"] = 1 31 | js_priorities["bootstrap-popover.js"] = 2 32 | 33 | js_list = js_priorities.to_a.sort {|a,b| a[1] <=> b[1]}.map{|p| p[0]} 34 | 35 | File.open("vendor/assets/javascripts/bootstrap.js", "w") do |f| 36 | f.write "// Bootstrap v#{boostrap_version}\n" 37 | js_list.each do |js| 38 | f.write "//= require #{js}\n" 39 | end 40 | end 41 | end -------------------------------------------------------------------------------- /bootstrap-rails.gemspec: -------------------------------------------------------------------------------- 1 | # -*- encoding: utf-8 -*- 2 | require File.expand_path('../lib/bootstrap-rails/version', __FILE__) 3 | 4 | Gem::Specification.new do |gem| 5 | gem.authors = ["Yury Korolev"] 6 | gem.email = ["yury.korolev@gmail.com"] 7 | gem.description = %q{Twitter Bootstrap CSS (with SASS flavour) and JS toolkits for Rails 3 projects} 8 | gem.summary = %q{Bootstrap CSS (with SASS flavour) and JS toolkits for Rails 3 projects} 9 | gem.homepage = "https://github.com/anjlab/bootstrap-rails" 10 | 11 | gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) } 12 | gem.files = `git ls-files`.split("\n") 13 | gem.files.reject! { |fn| fn.include? "vendor/twitter" } 14 | gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n") 15 | gem.name = "bootstrap-rails" 16 | gem.require_paths = ["lib"] 17 | gem.version = Bootstrap::Rails::VERSION 18 | 19 | gem.add_dependency "railties", "~> 3.0" 20 | gem.add_dependency "thor", "~> 0.14" 21 | gem.add_development_dependency "bundler", ">= 1.0.0" 22 | gem.add_development_dependency "rails", "~> 3.0" 23 | end 24 | -------------------------------------------------------------------------------- /lib/bootstrap-rails.rb: -------------------------------------------------------------------------------- 1 | require "bootstrap-rails/version" 2 | 3 | module Bootstrap 4 | module Rails 5 | if ::Rails.version < "3.1" 6 | require "bootstrap-rails/railtie" 7 | else 8 | require "bootstrap-rails/engine" 9 | end 10 | end 11 | end -------------------------------------------------------------------------------- /lib/bootstrap-rails/breadcrumb.rb: -------------------------------------------------------------------------------- 1 | module Bootstrap 2 | module Breadcrumb 3 | def self.included(receiver) 4 | receiver.extend ClassMethods 5 | receiver.send :include, InstanceMethods 6 | receiver.send :helper, Helpers 7 | receiver.send :before_filter, :set_breadcrumbs 8 | end 9 | 10 | module ClassMethods 11 | 12 | end 13 | 14 | module InstanceMethods 15 | protected 16 | 17 | def set_breadcrumbs 18 | @breadcrumbs = ["Home".html_safe] 19 | end 20 | 21 | def drop_breadcrumb(title=nil, url=nil) 22 | title ||= @page_title 23 | url ||= url_for 24 | if title 25 | @breadcrumbs.push("#{title}".html_safe) 26 | end 27 | end 28 | 29 | def drop_page_title(title) 30 | @page_title = title 31 | return @page_title 32 | end 33 | 34 | def no_breadcrumbs 35 | @breadcrumbs = [] 36 | end 37 | end 38 | 39 | module Helpers 40 | 41 | def render_breadcrumb 42 | return "" if @breadcrumbs.size <= 0 43 | prefix = "".html_safe 44 | crumb = "".html_safe 45 | 46 | @breadcrumbs.each_with_index do |c, i| 47 | breadcrumb_class = [] 48 | breadcrumb_class << "first" if i == 0 49 | breadcrumb_class << "last active" if i == (@breadcrumbs.length - 1) 50 | 51 | if i == (@breadcrumbs.length - 1) 52 | breadcrumb_content = c 53 | else 54 | breadcrumb_content = c + content_tag(:span, "/", :class => "divider") 55 | end 56 | 57 | crumb += content_tag(:li, breadcrumb_content ,:class => breadcrumb_class ) 58 | end 59 | return prefix + content_tag(:ul, crumb, :class => "breadcrumb menu clearfix") 60 | end 61 | end 62 | end 63 | 64 | end -------------------------------------------------------------------------------- /lib/bootstrap-rails/engine.rb: -------------------------------------------------------------------------------- 1 | require "bootstrap-rails/helper" 2 | require "bootstrap-rails/breadcrumb" 3 | module Bootstrap 4 | module Rails 5 | class Engine < ::Rails::Engine 6 | initializer "bootstrap_helper.view_helpers" do 7 | ActionView::Base.send :include, Bootstrap::Helper 8 | end 9 | 10 | config.to_prepare do 11 | ApplicationController.send :include, Bootstrap::Breadcrumb 12 | end 13 | 14 | end 15 | end 16 | end -------------------------------------------------------------------------------- /lib/bootstrap-rails/helper.rb: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | module Bootstrap 3 | 4 | module Helper 5 | def yield_or_default(message, default_message = "") 6 | message.nil? ? default_message : message 7 | end 8 | 9 | 10 | def render_page_title 11 | title = @page_title ? "#{SITE_NAME} | #{@page_title}" : SITE_NAME rescue "SITE_NAME" 12 | content_tag("title", title, nil, false) 13 | end 14 | 15 | def render_body_tag 16 | class_attribute = ["#{controller_name}-controller","#{action_name}-action"].join(" ") 17 | id_attribute = (@body_id)? " id=\"#{@body_id}-page\"" : "" 18 | 19 | raw(%Q| 21 | 23 | 24 | 25 | |) 26 | 27 | end 28 | 29 | def s(html) 30 | sanitize( html, :tags => %w(table thead tbody tr td th ol ul li div span font img sup sub br hr a pre p h1 h2 h3 h4 h5 h6), :attributes => %w(id class style src href size color) ) 31 | end 32 | 33 | def render_table(rows, renderrers, table_options = {}) 34 | table_options = { 35 | :has_header => true, 36 | :has_row_info => false, 37 | :caption => "", 38 | :id => nil, 39 | :class_name => "auto" 40 | }.merge(table_options) 41 | 42 | table_tag_options = table_options[:id] ? { :id => table_options[:id], :class => table_options[:class_name] } : { :class => table_options[:class_name] } 43 | 44 | table = TagNode.new('table', table_tag_options) 45 | 46 | if !table_options[:caption].blank? 47 | table << caption = TagNode.new(:caption) 48 | caption << table_options[:caption] 49 | end 50 | 51 | if table_options[:has_header] == true 52 | table << thead = TagNode.new(:thead) 53 | thead << tr = TagNode.new(:tr, :class => 'odd') 54 | 55 | renderrers.each do |renderrer| 56 | tr << th = TagNode.new(:th) 57 | th << renderrer[0] 58 | end 59 | end 60 | 61 | table << tbody = TagNode.new('tbody') 62 | row_info = {} 63 | row_info[:total] = rows.length 64 | rows.each_with_index do |row,i| 65 | row_info[:current] = i 66 | tbody << tr = TagNode.new('tr', :class => cycle("","odd") ) 67 | renderrers.each do |renderrer| 68 | tr << td = TagNode.new('td') 69 | 70 | if renderrer[1].class == Proc 71 | if table_options[:has_row_info] == true 72 | td << renderrer[1].call(row, row_info) 73 | else 74 | td << renderrer[1].call(row) 75 | end 76 | else 77 | td << renderrer[1] 78 | end 79 | end 80 | end 81 | 82 | return table.to_s 83 | end 84 | 85 | # .current will be added to current action, but if you want to add .current to another link, you can set @current = ['/other_link'] 86 | # TODO: hot about render_list( *args ) 87 | def render_list(list=[], options={}) 88 | if list.is_a? Hash 89 | options = list 90 | list = [] 91 | end 92 | 93 | yield(list) if block_given? 94 | 95 | list_type ||= "ul" 96 | 97 | if options[:type] 98 | if ["ul", "dl", "ol"].include?(options[:type]) 99 | list_type = options[:type] 100 | end 101 | end 102 | 103 | ul = TagNode.new(list_type, :id => options[:id], :class => options[:class] ) 104 | ul.addClass("unstyled") if (options[:type] && options[:type] == "unstyled") 105 | 106 | list.each_with_index do |content, i| 107 | item_class = [] 108 | item_class << "first" if i == 0 109 | item_class << "last" if i == (list.length - 1) 110 | 111 | item_content = content 112 | item_options = {} 113 | 114 | if content.is_a? Array 115 | item_content = content[0] 116 | item_options = content[1] 117 | end 118 | 119 | if item_options[:class] 120 | item_class << item_options[:class] 121 | end 122 | 123 | link = item_content.match(/href=(["'])(.*?)(\1)/)[2] rescue nil 124 | 125 | if ( link && current_page?(link) ) || ( @current && @current.include?(link) ) 126 | item_class << "active" 127 | end 128 | 129 | item_class = (item_class.empty?)? nil : item_class.join(" ") 130 | ul << li = TagNode.new('li', :class => item_class ) 131 | li << item_content 132 | end 133 | 134 | return ul.to_s 135 | end 136 | 137 | # Composite pattern 138 | class TagNode 139 | include ActionView::Helpers::TagHelper 140 | 141 | def initialize(name, options = {}) 142 | @name = name.to_s 143 | @attributes = options 144 | @children = [] 145 | end 146 | 147 | def addClass(x) 148 | if @attributes[:class].blank? 149 | @attributes[:class] = x.to_s 150 | else 151 | @attributes[:class] = @attributes[:class] + " #{x}" 152 | end 153 | end 154 | 155 | def to_s 156 | value = @children.each { |c| c.to_s }.join 157 | content_tag(@name, value.to_s, @attributes, false) 158 | end 159 | 160 | def <<(tag_node) 161 | @children << tag_node 162 | end 163 | end 164 | end 165 | 166 | end 167 | -------------------------------------------------------------------------------- /lib/bootstrap-rails/railtie.rb: -------------------------------------------------------------------------------- 1 | module Bootstrap 2 | module Rails 3 | class Railtie < ::Rails::Railtie 4 | end 5 | end 6 | end -------------------------------------------------------------------------------- /lib/bootstrap-rails/version.rb: -------------------------------------------------------------------------------- 1 | module Bootstrap 2 | module Rails 3 | VERSION = "0.1.4" 4 | end 5 | end -------------------------------------------------------------------------------- /lib/bootstrap/rails.rb: -------------------------------------------------------------------------------- 1 | require "bootstrap-rails/version" 2 | module Bootstrap 3 | module Rails 4 | require "bootstrap-rails/engine" 5 | end 6 | end -------------------------------------------------------------------------------- /vendor/assets/javascripts/bootstrap-alerts.js: -------------------------------------------------------------------------------- 1 | /* ========================================================== 2 | * bootstrap-alerts.js v1.4.0 3 | * http://twitter.github.com/bootstrap/javascript.html#alerts 4 | * ========================================================== 5 | * Copyright 2011 Twitter, Inc. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | * ========================================================== */ 19 | 20 | 21 | !function( $ ){ 22 | 23 | "use strict" 24 | 25 | /* CSS TRANSITION SUPPORT (https://gist.github.com/373874) 26 | * ======================================================= */ 27 | 28 | var transitionEnd 29 | 30 | $(document).ready(function () { 31 | 32 | $.support.transition = (function () { 33 | var thisBody = document.body || document.documentElement 34 | , thisStyle = thisBody.style 35 | , support = thisStyle.transition !== undefined || thisStyle.WebkitTransition !== undefined || thisStyle.MozTransition !== undefined || thisStyle.MsTransition !== undefined || thisStyle.OTransition !== undefined 36 | return support 37 | })() 38 | 39 | // set CSS transition event type 40 | if ( $.support.transition ) { 41 | transitionEnd = "TransitionEnd" 42 | if ( $.browser.webkit ) { 43 | transitionEnd = "webkitTransitionEnd" 44 | } else if ( $.browser.mozilla ) { 45 | transitionEnd = "transitionend" 46 | } else if ( $.browser.opera ) { 47 | transitionEnd = "oTransitionEnd" 48 | } 49 | } 50 | 51 | }) 52 | 53 | /* ALERT CLASS DEFINITION 54 | * ====================== */ 55 | 56 | var Alert = function ( content, options ) { 57 | this.settings = $.extend({}, $.fn.alert.defaults, options) 58 | this.$element = $(content) 59 | .delegate(this.settings.selector, 'click', this.close) 60 | } 61 | 62 | Alert.prototype = { 63 | 64 | close: function (e) { 65 | var $element = $(this).parent('.alert-message') 66 | 67 | e && e.preventDefault() 68 | $element.removeClass('in') 69 | 70 | function removeElement () { 71 | $element.remove() 72 | } 73 | 74 | $.support.transition && $element.hasClass('fade') ? 75 | $element.bind(transitionEnd, removeElement) : 76 | removeElement() 77 | } 78 | 79 | } 80 | 81 | 82 | /* ALERT PLUGIN DEFINITION 83 | * ======================= */ 84 | 85 | $.fn.alert = function ( options ) { 86 | 87 | if ( options === true ) { 88 | return this.data('alert') 89 | } 90 | 91 | return this.each(function () { 92 | var $this = $(this) 93 | 94 | if ( typeof options == 'string' ) { 95 | return $this.data('alert')[options]() 96 | } 97 | 98 | $(this).data('alert', new Alert( this, options )) 99 | 100 | }) 101 | } 102 | 103 | $.fn.alert.defaults = { 104 | selector: '.close' 105 | } 106 | 107 | $(document).ready(function () { 108 | new Alert($('body'), { 109 | selector: '.alert-message[data-alert] .close' 110 | }) 111 | }) 112 | 113 | }( window.jQuery || window.ender ); -------------------------------------------------------------------------------- /vendor/assets/javascripts/bootstrap-buttons.js: -------------------------------------------------------------------------------- 1 | /* ============================================================ 2 | * bootstrap-buttons.js v1.4.0 3 | * http://twitter.github.com/bootstrap/javascript.html#buttons 4 | * ============================================================ 5 | * Copyright 2011 Twitter, Inc. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | * ============================================================ */ 19 | 20 | !function( $ ){ 21 | 22 | "use strict" 23 | 24 | function setState(el, state) { 25 | var d = 'disabled' 26 | , $el = $(el) 27 | , data = $el.data() 28 | 29 | state = state + 'Text' 30 | data.resetText || $el.data('resetText', $el.html()) 31 | 32 | $el.html( data[state] || $.fn.button.defaults[state] ) 33 | 34 | state == 'loadingText' ? 35 | $el.addClass(d).attr(d, d) : 36 | $el.removeClass(d).removeAttr(d) 37 | } 38 | 39 | function toggle(el) { 40 | $(el).toggleClass('active') 41 | } 42 | 43 | $.fn.button = function(options) { 44 | return this.each(function () { 45 | if (options == 'toggle') { 46 | return toggle(this) 47 | } 48 | options && setState(this, options) 49 | }) 50 | } 51 | 52 | $.fn.button.defaults = { 53 | loadingText: 'loading...' 54 | } 55 | 56 | $(function () { 57 | $('body').delegate('.btn[data-toggle]', 'click', function () { 58 | $(this).button('toggle') 59 | }) 60 | }) 61 | 62 | }( window.jQuery || window.ender ); -------------------------------------------------------------------------------- /vendor/assets/javascripts/bootstrap-dropdown.js: -------------------------------------------------------------------------------- 1 | /* ============================================================ 2 | * bootstrap-dropdown.js v1.4.0 3 | * http://twitter.github.com/bootstrap/javascript.html#dropdown 4 | * ============================================================ 5 | * Copyright 2011 Twitter, Inc. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | * ============================================================ */ 19 | 20 | 21 | !function( $ ){ 22 | 23 | "use strict" 24 | 25 | /* DROPDOWN PLUGIN DEFINITION 26 | * ========================== */ 27 | 28 | $.fn.dropdown = function ( selector ) { 29 | return this.each(function () { 30 | $(this).delegate(selector || d, 'click', function (e) { 31 | var li = $(this).parent('li') 32 | , isActive = li.hasClass('open') 33 | 34 | clearMenus() 35 | !isActive && li.toggleClass('open') 36 | return false 37 | }) 38 | }) 39 | } 40 | 41 | /* APPLY TO STANDARD DROPDOWN ELEMENTS 42 | * =================================== */ 43 | 44 | var d = 'a.menu, .dropdown-toggle' 45 | 46 | function clearMenus() { 47 | $(d).parent('li').removeClass('open') 48 | } 49 | 50 | $(function () { 51 | $('html').bind("click", clearMenus) 52 | $('body').dropdown( '[data-dropdown] a.menu, [data-dropdown] .dropdown-toggle' ) 53 | }) 54 | 55 | }( window.jQuery || window.ender ); 56 | -------------------------------------------------------------------------------- /vendor/assets/javascripts/bootstrap-modal.js: -------------------------------------------------------------------------------- 1 | /* ========================================================= 2 | * bootstrap-modal.js v1.4.0 3 | * http://twitter.github.com/bootstrap/javascript.html#modal 4 | * ========================================================= 5 | * Copyright 2011 Twitter, Inc. 6 | * 7 | * Licensed under the Apache License, Version 2.0 (the "License"); 8 | * you may not use this file except in compliance with the License. 9 | * You may obtain a copy of the License at 10 | * 11 | * http://www.apache.org/licenses/LICENSE-2.0 12 | * 13 | * Unless required by applicable law or agreed to in writing, software 14 | * distributed under the License is distributed on an "AS IS" BASIS, 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 | * See the License for the specific language governing permissions and 17 | * limitations under the License. 18 | * ========================================================= */ 19 | 20 | 21 | !function( $ ){ 22 | 23 | "use strict" 24 | 25 | /* CSS TRANSITION SUPPORT (https://gist.github.com/373874) 26 | * ======================================================= */ 27 | 28 | var transitionEnd 29 | 30 | $(document).ready(function () { 31 | 32 | $.support.transition = (function () { 33 | var thisBody = document.body || document.documentElement 34 | , thisStyle = thisBody.style 35 | , support = thisStyle.transition !== undefined || thisStyle.WebkitTransition !== undefined || thisStyle.MozTransition !== undefined || thisStyle.MsTransition !== undefined || thisStyle.OTransition !== undefined 36 | return support 37 | })() 38 | 39 | // set CSS transition event type 40 | if ( $.support.transition ) { 41 | transitionEnd = "TransitionEnd" 42 | if ( $.browser.webkit ) { 43 | transitionEnd = "webkitTransitionEnd" 44 | } else if ( $.browser.mozilla ) { 45 | transitionEnd = "transitionend" 46 | } else if ( $.browser.opera ) { 47 | transitionEnd = "oTransitionEnd" 48 | } 49 | } 50 | 51 | }) 52 | 53 | 54 | /* MODAL PUBLIC CLASS DEFINITION 55 | * ============================= */ 56 | 57 | var Modal = function ( content, options ) { 58 | this.settings = $.extend({}, $.fn.modal.defaults, options) 59 | this.$element = $(content) 60 | .delegate('.close', 'click.modal', $.proxy(this.hide, this)) 61 | 62 | if ( this.settings.show ) { 63 | this.show() 64 | } 65 | 66 | return this 67 | } 68 | 69 | Modal.prototype = { 70 | 71 | toggle: function () { 72 | return this[!this.isShown ? 'show' : 'hide']() 73 | } 74 | 75 | , show: function () { 76 | var that = this 77 | this.isShown = true 78 | this.$element.trigger('show') 79 | 80 | escape.call(this) 81 | backdrop.call(this, function () { 82 | var transition = $.support.transition && that.$element.hasClass('fade') 83 | 84 | that.$element 85 | .appendTo(document.body) 86 | .show() 87 | 88 | if (transition) { 89 | that.$element[0].offsetWidth // force reflow 90 | } 91 | 92 | that.$element.addClass('in') 93 | 94 | transition ? 95 | that.$element.one(transitionEnd, function () { that.$element.trigger('shown') }) : 96 | that.$element.trigger('shown') 97 | 98 | }) 99 | 100 | return this 101 | } 102 | 103 | , hide: function (e) { 104 | e && e.preventDefault() 105 | 106 | if ( !this.isShown ) { 107 | return this 108 | } 109 | 110 | var that = this 111 | this.isShown = false 112 | 113 | escape.call(this) 114 | 115 | this.$element 116 | .trigger('hide') 117 | .removeClass('in') 118 | 119 | $.support.transition && this.$element.hasClass('fade') ? 120 | hideWithTransition.call(this) : 121 | hideModal.call(this) 122 | 123 | return this 124 | } 125 | 126 | } 127 | 128 | 129 | /* MODAL PRIVATE METHODS 130 | * ===================== */ 131 | 132 | function hideWithTransition() { 133 | // firefox drops transitionEnd events :{o 134 | var that = this 135 | , timeout = setTimeout(function () { 136 | that.$element.unbind(transitionEnd) 137 | hideModal.call(that) 138 | }, 500) 139 | 140 | this.$element.one(transitionEnd, function () { 141 | clearTimeout(timeout) 142 | hideModal.call(that) 143 | }) 144 | } 145 | 146 | function hideModal (that) { 147 | this.$element 148 | .hide() 149 | .trigger('hidden') 150 | 151 | backdrop.call(this) 152 | } 153 | 154 | function backdrop ( callback ) { 155 | var that = this 156 | , animate = this.$element.hasClass('fade') ? 'fade' : '' 157 | if ( this.isShown && this.settings.backdrop ) { 158 | var doAnimate = $.support.transition && animate 159 | 160 | this.$backdrop = $('