anjlab-bootstrap-rails 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,17 @@
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
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'http://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in bootstrap-rails.gemspec
4
+ gemspec
data/README.md ADDED
@@ -0,0 +1,64 @@
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
+ gem 'anjlab-bootstrap-rails'
13
+
14
+ or you can install from latest build;
15
+
16
+ gem 'anjlab-bootstrap-rails', :git => 'http://github.com/anjlab/bootstrap-rails.git'
17
+
18
+ and run bundle install.
19
+
20
+ ## Stylesheets
21
+
22
+ Add necessary stylesheet file to app/assets/stylesheets/application.css
23
+
24
+ *= require bootstrap
25
+
26
+ You can override boostrapr variables:
27
+
28
+
29
+ // Create app/assets/stylesheets/bootstrap.scss
30
+ // CSS Reset
31
+ @import "reset.scss";
32
+
33
+ // Core variables and mixins
34
+ @import "variables.scss"; // Modify this for custom colors, font-sizes, etc
35
+ $linkColor: red; // Make all links red
36
+
37
+ @import "mixins.scss";
38
+
39
+ // Grid system and page structure
40
+ @import "scaffolding.scss";
41
+
42
+ // Styled patterns and elements
43
+ @import "type.scss";
44
+ @import "forms.scss";
45
+ @import "tables.scss";
46
+ @import "patterns.scss";
47
+
48
+ ## Javascripts
49
+
50
+ Add necessary javascripts files to app/assets/javascripts/application.js
51
+
52
+ //= require bootstrap
53
+
54
+ ## Thanks
55
+ Thanks Twitter for Bootstrap
56
+ http://twitter.github.com/bootstrap
57
+ Inspired by Seyhun Akyürek and his (twitter-bootstrap-rails gem)[https://github.com/seyhunak/twitter-bootstrap-rails]
58
+
59
+ ## License
60
+ Copyright (c) 2011 AnjLab
61
+
62
+ 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:
63
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
64
+ 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.
data/Rakefile ADDED
@@ -0,0 +1,31 @@
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/, Time.now.to_s)
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
+ bootstrap_js = js_files.map{|f| "//= require #{File.basename(f)}"}.join("\n")
27
+ File.open("vendor/assets/javascripts/bootstrap.js", "w") do |f|
28
+ f.write "// Bootstrap v#{boostrap_version}\n"
29
+ f.write(bootstrap_js)
30
+ end
31
+ end
@@ -0,0 +1,23 @@
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 = ""
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 = "anjlab-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
@@ -0,0 +1,11 @@
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
@@ -0,0 +1,6 @@
1
+ module Bootstrap
2
+ module Rails
3
+ class Engine < ::Rails::Engine
4
+ end
5
+ end
6
+ end
@@ -0,0 +1,5 @@
1
+ module Bootstrap
2
+ module Rails
3
+ class Railtie < ::Rails::Railtie; end
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ module Bootstrap
2
+ module Rails
3
+ VERSION = "0.0.2"
4
+ end
5
+ end
@@ -0,0 +1,104 @@
1
+ /* ==========================================================
2
+ * bootstrap-alerts.js v1.3.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
+ /* CSS TRANSITION SUPPORT (https://gist.github.com/373874)
24
+ * ======================================================= */
25
+
26
+ var transitionEnd
27
+
28
+ $(document).ready(function () {
29
+
30
+ $.support.transition = (function () {
31
+ var thisBody = document.body || document.documentElement
32
+ , thisStyle = thisBody.style
33
+ , support = thisStyle.transition !== undefined || thisStyle.WebkitTransition !== undefined || thisStyle.MozTransition !== undefined || thisStyle.MsTransition !== undefined || thisStyle.OTransition !== undefined
34
+ return support
35
+ })()
36
+
37
+ // set CSS transition event type
38
+ if ( $.support.transition ) {
39
+ transitionEnd = "TransitionEnd"
40
+ if ( $.browser.webkit ) {
41
+ transitionEnd = "webkitTransitionEnd"
42
+ } else if ( $.browser.mozilla ) {
43
+ transitionEnd = "transitionend"
44
+ } else if ( $.browser.opera ) {
45
+ transitionEnd = "oTransitionEnd"
46
+ }
47
+ }
48
+
49
+ })
50
+
51
+ /* ALERT CLASS DEFINITION
52
+ * ====================== */
53
+
54
+ var Alert = function ( content, selector ) {
55
+ this.$element = $(content)
56
+ .delegate(selector || '.close', 'click', this.close)
57
+ }
58
+
59
+ Alert.prototype = {
60
+
61
+ close: function (e) {
62
+ var $element = $(this).parent('.alert-message')
63
+
64
+ e && e.preventDefault()
65
+ $element.removeClass('in')
66
+
67
+ function removeElement () {
68
+ $element.remove()
69
+ }
70
+
71
+ $.support.transition && $element.hasClass('fade') ?
72
+ $element.bind(transitionEnd, removeElement) :
73
+ removeElement()
74
+ }
75
+
76
+ }
77
+
78
+
79
+ /* ALERT PLUGIN DEFINITION
80
+ * ======================= */
81
+
82
+ $.fn.alert = function ( options ) {
83
+
84
+ if ( options === true ) {
85
+ return this.data('alert')
86
+ }
87
+
88
+ return this.each(function () {
89
+ var $this = $(this)
90
+
91
+ if ( typeof options == 'string' ) {
92
+ return $this.data('alert')[options]()
93
+ }
94
+
95
+ $(this).data('alert', new Alert( this ))
96
+
97
+ })
98
+ }
99
+
100
+ $(document).ready(function () {
101
+ new Alert($('body'), '.alert-message[data-alert] .close')
102
+ })
103
+
104
+ }( window.jQuery || window.ender )
@@ -0,0 +1,50 @@
1
+ /* ============================================================
2
+ * bootstrap-dropdown.js v1.3.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
+ var d = 'a.menu, .dropdown-toggle'
24
+
25
+ function clearMenus() {
26
+ $(d).parent('li').removeClass('open')
27
+ }
28
+
29
+ $(function () {
30
+ $('html').bind("click", clearMenus)
31
+ $('body').dropdown( '[data-dropdown] a.menu, [data-dropdown] .dropdown-toggle' )
32
+ })
33
+
34
+ /* DROPDOWN PLUGIN DEFINITION
35
+ * ========================== */
36
+
37
+ $.fn.dropdown = function ( selector ) {
38
+ return this.each(function () {
39
+ $(this).delegate(selector || d, 'click', function (e) {
40
+ var li = $(this).parent('li')
41
+ , isActive = li.hasClass('open')
42
+
43
+ clearMenus()
44
+ !isActive && li.toggleClass('open')
45
+ return false
46
+ })
47
+ })
48
+ }
49
+
50
+ }( window.jQuery || window.ender )
@@ -0,0 +1,238 @@
1
+ /* =========================================================
2
+ * bootstrap-modal.js v1.3.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
+ /* CSS TRANSITION SUPPORT (https://gist.github.com/373874)
24
+ * ======================================================= */
25
+
26
+ var transitionEnd
27
+
28
+ $(document).ready(function () {
29
+
30
+ $.support.transition = (function () {
31
+ var thisBody = document.body || document.documentElement
32
+ , thisStyle = thisBody.style
33
+ , support = thisStyle.transition !== undefined || thisStyle.WebkitTransition !== undefined || thisStyle.MozTransition !== undefined || thisStyle.MsTransition !== undefined || thisStyle.OTransition !== undefined
34
+ return support
35
+ })()
36
+
37
+ // set CSS transition event type
38
+ if ( $.support.transition ) {
39
+ transitionEnd = "TransitionEnd"
40
+ if ( $.browser.webkit ) {
41
+ transitionEnd = "webkitTransitionEnd"
42
+ } else if ( $.browser.mozilla ) {
43
+ transitionEnd = "transitionend"
44
+ } else if ( $.browser.opera ) {
45
+ transitionEnd = "oTransitionEnd"
46
+ }
47
+ }
48
+
49
+ })
50
+
51
+
52
+ /* MODAL PUBLIC CLASS DEFINITION
53
+ * ============================= */
54
+
55
+ var Modal = function ( content, options ) {
56
+ this.settings = $.extend({}, $.fn.modal.defaults)
57
+ this.$element = $(content)
58
+ .delegate('.close', 'click.modal', $.proxy(this.hide, this))
59
+
60
+ if ( options ) {
61
+ $.extend( this.settings, options )
62
+
63
+ if ( options.show ) {
64
+ this.show()
65
+ }
66
+ }
67
+
68
+ return this
69
+ }
70
+
71
+ Modal.prototype = {
72
+
73
+ toggle: function () {
74
+ return this[!this.isShown ? 'show' : 'hide']()
75
+ }
76
+
77
+ , show: function () {
78
+ var that = this
79
+ this.isShown = true
80
+ this.$element.trigger('show')
81
+
82
+ escape.call(this)
83
+ backdrop.call(this, function () {
84
+ that.$element
85
+ .appendTo(document.body)
86
+ .show()
87
+
88
+ if ($.support.transition && that.$element.hasClass('fade')) {
89
+ that.$backdrop[0].offsetWidth // force reflow
90
+ }
91
+
92
+ that.$element
93
+ .addClass('in')
94
+ .trigger('shown')
95
+ })
96
+
97
+ return this
98
+ }
99
+
100
+ , hide: function (e) {
101
+ e && e.preventDefault()
102
+
103
+ var that = this
104
+ this.isShown = false
105
+
106
+ escape.call(this)
107
+
108
+ this.$element
109
+ .trigger('hide')
110
+ .removeClass('in')
111
+
112
+ function removeElement () {
113
+ that.$element
114
+ .hide()
115
+ .trigger('hidden')
116
+
117
+ backdrop.call(that)
118
+ }
119
+
120
+ $.support.transition && this.$element.hasClass('fade') ?
121
+ this.$element.one(transitionEnd, removeElement) :
122
+ removeElement()
123
+
124
+ return this
125
+ }
126
+
127
+ }
128
+
129
+
130
+ /* MODAL PRIVATE METHODS
131
+ * ===================== */
132
+
133
+ function backdrop ( callback ) {
134
+ var that = this
135
+ , animate = this.$element.hasClass('fade') ? 'fade' : ''
136
+ if ( this.isShown && this.settings.backdrop ) {
137
+ var doAnimate = $.support.transition && animate
138
+
139
+ this.$backdrop = $('<div class="modal-backdrop ' + animate + '" />')
140
+ .appendTo(document.body)
141
+
142
+ if ( this.settings.backdrop != 'static' ) {
143
+ this.$backdrop.click($.proxy(this.hide, this))
144
+ }
145
+
146
+ if ( doAnimate ) {
147
+ that.$backdrop[0].offsetWidth // force reflow
148
+ }
149
+
150
+ that.$backdrop && that.$backdrop.addClass('in')
151
+
152
+ doAnimate ?
153
+ that.$backdrop.one(transitionEnd, callback) :
154
+ callback()
155
+
156
+ } else if ( !this.isShown && this.$backdrop ) {
157
+ this.$backdrop.removeClass('in')
158
+
159
+ function removeElement() {
160
+ that.$backdrop.remove()
161
+ that.$backdrop = null
162
+ }
163
+
164
+ $.support.transition && this.$element.hasClass('fade')?
165
+ this.$backdrop.one(transitionEnd, removeElement) :
166
+ removeElement()
167
+ } else if ( callback ) {
168
+ callback()
169
+ }
170
+ }
171
+
172
+ function escape() {
173
+ var that = this
174
+ if ( this.isShown && this.settings.keyboard ) {
175
+ $(document).bind('keyup.modal', function ( e ) {
176
+ if ( e.which == 27 ) {
177
+ that.hide()
178
+ }
179
+ })
180
+ } else if ( !this.isShown ) {
181
+ $(document).unbind('keyup.modal')
182
+ }
183
+ }
184
+
185
+
186
+ /* MODAL PLUGIN DEFINITION
187
+ * ======================= */
188
+
189
+ $.fn.modal = function ( options ) {
190
+ var modal = this.data('modal')
191
+
192
+ if (!modal) {
193
+
194
+ if (typeof options == 'string') {
195
+ options = {
196
+ show: /show|toggle/.test(options)
197
+ }
198
+ }
199
+
200
+ return this.each(function () {
201
+ $(this).data('modal', new Modal(this, options))
202
+ })
203
+ }
204
+
205
+ if ( options === true ) {
206
+ return modal
207
+ }
208
+
209
+ if ( typeof options == 'string' ) {
210
+ modal[options]()
211
+ } else if ( modal ) {
212
+ modal.toggle()
213
+ }
214
+
215
+ return this
216
+ }
217
+
218
+ $.fn.modal.Modal = Modal
219
+
220
+ $.fn.modal.defaults = {
221
+ backdrop: false
222
+ , keyboard: false
223
+ , show: true
224
+ }
225
+
226
+
227
+ /* MODAL DATA- IMPLEMENTATION
228
+ * ========================== */
229
+
230
+ $(document).ready(function () {
231
+ $('body').delegate('[data-controls-modal]', 'click', function (e) {
232
+ e.preventDefault()
233
+ var $this = $(this).data('show', true)
234
+ $('#' + $this.attr('data-controls-modal')).modal( $this.data() )
235
+ })
236
+ })
237
+
238
+ }( window.jQuery || window.ender )