twitter-bootstrap 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (59) hide show
  1. data/MIT-LICENSE +20 -0
  2. data/README.rdoc +3 -0
  3. data/Rakefile +39 -0
  4. data/app/assets/javascripts/bootstrap-alerts.js +111 -0
  5. data/app/assets/javascripts/bootstrap-dropdown.js +53 -0
  6. data/app/assets/javascripts/bootstrap-modal.js +244 -0
  7. data/app/assets/javascripts/bootstrap-popover.js +77 -0
  8. data/app/assets/javascripts/bootstrap-scrollspy.js +105 -0
  9. data/app/assets/javascripts/bootstrap-tabs.js +77 -0
  10. data/app/assets/javascripts/bootstrap-twipsy.js +303 -0
  11. data/app/assets/javascripts/twitter_bootstrap/application.js +9 -0
  12. data/app/assets/stylesheets/bootsrap-defaults.css.less +26 -0
  13. data/app/assets/stylesheets/bootsrap-forms.css.less +464 -0
  14. data/app/assets/stylesheets/bootsrap-mixins.css.less +217 -0
  15. data/app/assets/stylesheets/bootsrap-patterns.css.less +1006 -0
  16. data/app/assets/stylesheets/bootsrap-reset.css.less +141 -0
  17. data/app/assets/stylesheets/bootsrap-scaffolding.css.less +135 -0
  18. data/app/assets/stylesheets/bootsrap-tables.css.less +170 -0
  19. data/app/assets/stylesheets/bootsrap-type.css.less +187 -0
  20. data/app/assets/stylesheets/bootsrap-variables.css.less +60 -0
  21. data/app/controllers/twitter_bootstrap/application_controller.rb +4 -0
  22. data/app/helpers/twitter_bootstrap/application_helper.rb +4 -0
  23. data/app/views/layouts/twitter_bootstrap/application.html.erb +14 -0
  24. data/config/routes.rb +2 -0
  25. data/lib/tasks/twitter_bootstrap_tasks.rake +4 -0
  26. data/lib/twitter_bootstrap.rb +4 -0
  27. data/lib/twitter_bootstrap/engine.rb +5 -0
  28. data/lib/twitter_bootstrap/version.rb +3 -0
  29. data/test/dummy/Rakefile +7 -0
  30. data/test/dummy/app/assets/javascripts/application.js +9 -0
  31. data/test/dummy/app/assets/stylesheets/application.css +7 -0
  32. data/test/dummy/app/controllers/application_controller.rb +3 -0
  33. data/test/dummy/app/helpers/application_helper.rb +2 -0
  34. data/test/dummy/app/views/layouts/application.html.erb +14 -0
  35. data/test/dummy/config.ru +4 -0
  36. data/test/dummy/config/application.rb +45 -0
  37. data/test/dummy/config/boot.rb +10 -0
  38. data/test/dummy/config/database.yml +25 -0
  39. data/test/dummy/config/environment.rb +5 -0
  40. data/test/dummy/config/environments/development.rb +30 -0
  41. data/test/dummy/config/environments/production.rb +60 -0
  42. data/test/dummy/config/environments/test.rb +42 -0
  43. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  44. data/test/dummy/config/initializers/inflections.rb +10 -0
  45. data/test/dummy/config/initializers/mime_types.rb +5 -0
  46. data/test/dummy/config/initializers/secret_token.rb +7 -0
  47. data/test/dummy/config/initializers/session_store.rb +8 -0
  48. data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
  49. data/test/dummy/config/locales/en.yml +5 -0
  50. data/test/dummy/config/routes.rb +4 -0
  51. data/test/dummy/public/404.html +26 -0
  52. data/test/dummy/public/422.html +26 -0
  53. data/test/dummy/public/500.html +26 -0
  54. data/test/dummy/public/favicon.ico +0 -0
  55. data/test/dummy/script/rails +6 -0
  56. data/test/integration/navigation_test.rb +10 -0
  57. data/test/test_helper.rb +10 -0
  58. data/test/twitter_bootstrap_test.rb +7 -0
  59. metadata +168 -0
@@ -0,0 +1,77 @@
1
+ /* ===========================================================
2
+ * bootstrap-popover.js v1.3.0
3
+ * http://twitter.github.com/bootstrap/javascript.html#popover
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 Popover = function ( element, options ) {
24
+ this.$element = $(element)
25
+ this.options = options
26
+ this.enabled = true
27
+ this.fixTitle()
28
+ }
29
+
30
+ /* NOTE: POPOVER EXTENDS BOOTSTRAP-TWIPSY.js
31
+ ========================================= */
32
+
33
+ Popover.prototype = $.extend({}, $.fn.twipsy.Twipsy.prototype, {
34
+
35
+ setContent: function () {
36
+ var $tip = this.tip()
37
+ $tip.find('.title')[this.options.html ? 'html' : 'text'](this.getTitle())
38
+ $tip.find('.content p')[this.options.html ? 'html' : 'text'](this.getContent())
39
+ $tip[0].className = 'popover'
40
+ }
41
+
42
+ , getContent: function () {
43
+ var content
44
+ , $e = this.$element
45
+ , o = this.options
46
+
47
+ if (typeof this.options.content == 'string') {
48
+ content = $e.attr(o.content)
49
+ } else if (typeof this.options.content == 'function') {
50
+ content = this.options.content.call(this.$element[0])
51
+ }
52
+ return content
53
+ }
54
+
55
+ , tip: function() {
56
+ if (!this.$tip) {
57
+ this.$tip = $('<div class="popover" />')
58
+ .html('<div class="arrow"></div><div class="inner"><h3 class="title"></h3><div class="content"><p></p></div></div>')
59
+ }
60
+ return this.$tip
61
+ }
62
+
63
+ })
64
+
65
+
66
+ /* POPOVER PLUGIN DEFINITION
67
+ * ======================= */
68
+
69
+ $.fn.popover = function (options) {
70
+ if (typeof options == 'object') options = $.extend({}, $.fn.popover.defaults, options)
71
+ $.fn.twipsy.initWith.call(this, options, Popover, 'popover')
72
+ return this
73
+ }
74
+
75
+ $.fn.popover.defaults = $.extend({} , $.fn.twipsy.defaults, { content: 'data-content', placement: 'right'})
76
+
77
+ }( window.jQuery || window.ender );
@@ -0,0 +1,105 @@
1
+ /* =============================================================
2
+ * bootstrap-scrollspy.js v1.3.0
3
+ * http://twitter.github.com/bootstrap/javascript.html#scrollspy
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 $window = $(window)
24
+
25
+ function ScrollSpy( topbar, selector ) {
26
+ var processScroll = $.proxy(this.processScroll, this)
27
+ this.$topbar = $(topbar)
28
+ this.selector = selector || 'li > a'
29
+ this.refresh()
30
+ this.$topbar.delegate(this.selector, 'click', processScroll)
31
+ $window.scroll(processScroll)
32
+ this.processScroll()
33
+ }
34
+
35
+ ScrollSpy.prototype = {
36
+
37
+ refresh: function () {
38
+ this.targets = this.$topbar.find(this.selector).map(function () {
39
+ var href = $(this).attr('href')
40
+ return /^#\w/.test(href) && $(href).length ? href : null
41
+ })
42
+
43
+ this.offsets = $.map(this.targets, function (id) {
44
+ return $(id).offset().top
45
+ })
46
+ }
47
+
48
+ , processScroll: function () {
49
+ var scrollTop = $window.scrollTop() + 10
50
+ , offsets = this.offsets
51
+ , targets = this.targets
52
+ , activeTarget = this.activeTarget
53
+ , i
54
+
55
+ for (i = offsets.length; i--;) {
56
+ activeTarget != targets[i]
57
+ && scrollTop >= offsets[i]
58
+ && (!offsets[i + 1] || scrollTop <= offsets[i + 1])
59
+ && this.activateButton( targets[i] )
60
+ }
61
+ }
62
+
63
+ , activateButton: function (target) {
64
+ this.activeTarget = target
65
+
66
+ this.$topbar
67
+ .find(this.selector).parent('.active')
68
+ .removeClass('active')
69
+
70
+ this.$topbar
71
+ .find(this.selector + '[href="' + target + '"]')
72
+ .parent('li')
73
+ .addClass('active')
74
+ }
75
+
76
+ }
77
+
78
+ /* SCROLLSPY PLUGIN DEFINITION
79
+ * =========================== */
80
+
81
+ $.fn.scrollSpy = function( options ) {
82
+ var scrollspy = this.data('scrollspy')
83
+
84
+ if (!scrollspy) {
85
+ return this.each(function () {
86
+ $(this).data('scrollspy', new ScrollSpy( this, options ))
87
+ })
88
+ }
89
+
90
+ if ( options === true ) {
91
+ return scrollspy
92
+ }
93
+
94
+ if ( typeof options == 'string' ) {
95
+ scrollspy[options]()
96
+ }
97
+
98
+ return this
99
+ }
100
+
101
+ $(document).ready(function () {
102
+ $('body').scrollSpy('[data-scrollspy] li > a')
103
+ })
104
+
105
+ }( window.jQuery || window.ender );
@@ -0,0 +1,77 @@
1
+ /* ========================================================
2
+ * bootstrap-tabs.js v1.3.0
3
+ * http://twitter.github.com/bootstrap/javascript.html#tabs
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
+ function activate ( element, container ) {
24
+ container
25
+ .find('> .active')
26
+ .removeClass('active')
27
+ .find('> .dropdown-menu > .active')
28
+ .removeClass('active')
29
+
30
+ element.addClass('active')
31
+
32
+ if ( element.parent('.dropdown-menu') ) {
33
+ element.closest('li.dropdown').addClass('active')
34
+ }
35
+ }
36
+
37
+ function tab( e ) {
38
+ var $this = $(this)
39
+ , $ul = $this.closest('ul:not(.dropdown-menu)')
40
+ , href = $this.attr('href')
41
+ , previous
42
+
43
+ if ( /^#\w+/.test(href) ) {
44
+ e.preventDefault()
45
+
46
+ if ( $this.parent('li').hasClass('active') ) {
47
+ return
48
+ }
49
+
50
+ previous = $ul.find('.active a').last()[0]
51
+ $href = $(href)
52
+
53
+ activate($this.parent('li'), $ul)
54
+ activate($href, $href.parent())
55
+
56
+ $this.trigger({
57
+ type: 'change'
58
+ , relatedTarget: previous
59
+ })
60
+ }
61
+ }
62
+
63
+
64
+ /* TABS/PILLS PLUGIN DEFINITION
65
+ * ============================ */
66
+
67
+ $.fn.tabs = $.fn.pills = function ( selector ) {
68
+ return this.each(function () {
69
+ $(this).delegate(selector || '.tabs li > a, .pills > li > a', 'click', tab)
70
+ })
71
+ }
72
+
73
+ $(document).ready(function () {
74
+ $('body').tabs('ul[data-tabs] li > a, ul[data-pills] > li > a')
75
+ })
76
+
77
+ }( window.jQuery || window.ender );
@@ -0,0 +1,303 @@
1
+ /* ==========================================================
2
+ * bootstrap-twipsy.js v1.3.0
3
+ * http://twitter.github.com/bootstrap/javascript.html#twipsy
4
+ * Adapted from the original jQuery.tipsy by Jason Frame
5
+ * ==========================================================
6
+ * Copyright 2011 Twitter, Inc.
7
+ *
8
+ * Licensed under the Apache License, Version 2.0 (the "License");
9
+ * you may not use this file except in compliance with the License.
10
+ * You may obtain a copy of the License at
11
+ *
12
+ * http://www.apache.org/licenses/LICENSE-2.0
13
+ *
14
+ * Unless required by applicable law or agreed to in writing, software
15
+ * distributed under the License is distributed on an "AS IS" BASIS,
16
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
+ * See the License for the specific language governing permissions and
18
+ * limitations under the License.
19
+ * ========================================================== */
20
+
21
+
22
+ !function( $ ) {
23
+
24
+ /* CSS TRANSITION SUPPORT (https://gist.github.com/373874)
25
+ * ======================================================= */
26
+
27
+ var transitionEnd
28
+
29
+ $(document).ready(function () {
30
+
31
+ $.support.transition = (function () {
32
+ var thisBody = document.body || document.documentElement
33
+ , thisStyle = thisBody.style
34
+ , support = thisStyle.transition !== undefined || thisStyle.WebkitTransition !== undefined || thisStyle.MozTransition !== undefined || thisStyle.MsTransition !== undefined || thisStyle.OTransition !== undefined
35
+ return support
36
+ })()
37
+
38
+ // set CSS transition event type
39
+ if ( $.support.transition ) {
40
+ transitionEnd = "TransitionEnd"
41
+ if ( $.browser.webkit ) {
42
+ transitionEnd = "webkitTransitionEnd"
43
+ } else if ( $.browser.mozilla ) {
44
+ transitionEnd = "transitionend"
45
+ } else if ( $.browser.opera ) {
46
+ transitionEnd = "oTransitionEnd"
47
+ }
48
+ }
49
+
50
+ })
51
+
52
+
53
+ /* TWIPSY PUBLIC CLASS DEFINITION
54
+ * ============================== */
55
+
56
+ var Twipsy = function ( element, options ) {
57
+ this.$element = $(element)
58
+ this.options = options
59
+ this.enabled = true
60
+ this.fixTitle()
61
+ }
62
+
63
+ Twipsy.prototype = {
64
+
65
+ show: function() {
66
+ var pos
67
+ , actualWidth
68
+ , actualHeight
69
+ , placement
70
+ , $tip
71
+ , tp
72
+
73
+ if (this.getTitle() && this.enabled) {
74
+ $tip = this.tip()
75
+ this.setContent()
76
+
77
+ if (this.options.animate) {
78
+ $tip.addClass('fade')
79
+ }
80
+
81
+ $tip
82
+ .remove()
83
+ .css({ top: 0, left: 0, display: 'block' })
84
+ .prependTo(document.body)
85
+
86
+ pos = $.extend({}, this.$element.offset(), {
87
+ width: this.$element[0].offsetWidth
88
+ , height: this.$element[0].offsetHeight
89
+ })
90
+
91
+ actualWidth = $tip[0].offsetWidth
92
+ actualHeight = $tip[0].offsetHeight
93
+
94
+ placement = maybeCall(this.options.placement, this, [ $tip[0], this.$element[0] ])
95
+
96
+ switch (placement) {
97
+ case 'below':
98
+ tp = {top: pos.top + pos.height + this.options.offset, left: pos.left + pos.width / 2 - actualWidth / 2}
99
+ break
100
+ case 'above':
101
+ tp = {top: pos.top - actualHeight - this.options.offset, left: pos.left + pos.width / 2 - actualWidth / 2}
102
+ break
103
+ case 'left':
104
+ tp = {top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left - actualWidth - this.options.offset}
105
+ break
106
+ case 'right':
107
+ tp = {top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left + pos.width + this.options.offset}
108
+ break
109
+ }
110
+
111
+ $tip
112
+ .css(tp)
113
+ .addClass(placement)
114
+ .addClass('in')
115
+ }
116
+ }
117
+
118
+ , setContent: function () {
119
+ var $tip = this.tip()
120
+ $tip.find('.twipsy-inner')[this.options.html ? 'html' : 'text'](this.getTitle())
121
+ $tip[0].className = 'twipsy'
122
+ }
123
+
124
+ , hide: function() {
125
+ var that = this
126
+ , $tip = this.tip()
127
+
128
+ $tip.removeClass('in')
129
+
130
+ function removeElement () {
131
+ $tip.remove()
132
+ }
133
+
134
+ $.support.transition && this.$tip.hasClass('fade') ?
135
+ $tip.bind(transitionEnd, removeElement) :
136
+ removeElement()
137
+ }
138
+
139
+ , fixTitle: function() {
140
+ var $e = this.$element
141
+ if ($e.attr('title') || typeof($e.attr('data-original-title')) != 'string') {
142
+ $e.attr('data-original-title', $e.attr('title') || '').removeAttr('title')
143
+ }
144
+ }
145
+
146
+ , getTitle: function() {
147
+ var title
148
+ , $e = this.$element
149
+ , o = this.options
150
+
151
+ this.fixTitle()
152
+
153
+ if (typeof o.title == 'string') {
154
+ title = $e.attr(o.title == 'title' ? 'data-original-title' : o.title)
155
+ } else if (typeof o.title == 'function') {
156
+ title = o.title.call($e[0])
157
+ }
158
+
159
+ title = ('' + title).replace(/(^\s*|\s*$)/, "")
160
+
161
+ return title || o.fallback
162
+ }
163
+
164
+ , tip: function() {
165
+ if (!this.$tip) {
166
+ this.$tip = $('<div class="twipsy" />').html('<div class="twipsy-arrow"></div><div class="twipsy-inner"></div>')
167
+ }
168
+ return this.$tip
169
+ }
170
+
171
+ , validate: function() {
172
+ if (!this.$element[0].parentNode) {
173
+ this.hide()
174
+ this.$element = null
175
+ this.options = null
176
+ }
177
+ }
178
+
179
+ , enable: function() {
180
+ this.enabled = true
181
+ }
182
+
183
+ , disable: function() {
184
+ this.enabled = false
185
+ }
186
+
187
+ , toggleEnabled: function() {
188
+ this.enabled = !this.enabled
189
+ }
190
+
191
+ }
192
+
193
+
194
+ /* TWIPSY PRIVATE METHODS
195
+ * ====================== */
196
+
197
+ function maybeCall ( thing, ctx, args ) {
198
+ return typeof thing == 'function' ? thing.apply(ctx, args) : thing
199
+ }
200
+
201
+ /* TWIPSY PLUGIN DEFINITION
202
+ * ======================== */
203
+
204
+ $.fn.twipsy = function (options) {
205
+ $.fn.twipsy.initWith.call(this, options, Twipsy, 'twipsy')
206
+ return this
207
+ }
208
+
209
+ $.fn.twipsy.initWith = function (options, Constructor, name) {
210
+ var twipsy
211
+ , binder
212
+ , eventIn
213
+ , eventOut
214
+
215
+ if (options === true) {
216
+ return this.data(name)
217
+ } else if (typeof options == 'string') {
218
+ twipsy = this.data(name)
219
+ if (twipsy) {
220
+ twipsy[options]()
221
+ }
222
+ return this
223
+ }
224
+
225
+ options = $.extend({}, $.fn[name].defaults, options)
226
+
227
+ function get(ele) {
228
+ var twipsy = $.data(ele, name)
229
+
230
+ if (!twipsy) {
231
+ twipsy = new Constructor(ele, $.fn.twipsy.elementOptions(ele, options))
232
+ $.data(ele, name, twipsy)
233
+ }
234
+
235
+ return twipsy
236
+ }
237
+
238
+ function enter() {
239
+ var twipsy = get(this)
240
+ twipsy.hoverState = 'in'
241
+
242
+ if (options.delayIn == 0) {
243
+ twipsy.show()
244
+ } else {
245
+ twipsy.fixTitle()
246
+ setTimeout(function() {
247
+ if (twipsy.hoverState == 'in') {
248
+ twipsy.show()
249
+ }
250
+ }, options.delayIn)
251
+ }
252
+ }
253
+
254
+ function leave() {
255
+ var twipsy = get(this)
256
+ twipsy.hoverState = 'out'
257
+ if (options.delayOut == 0) {
258
+ twipsy.hide()
259
+ } else {
260
+ setTimeout(function() {
261
+ if (twipsy.hoverState == 'out') {
262
+ twipsy.hide()
263
+ }
264
+ }, options.delayOut)
265
+ }
266
+ }
267
+
268
+ if (!options.live) {
269
+ this.each(function() {
270
+ get(this)
271
+ })
272
+ }
273
+
274
+ if (options.trigger != 'manual') {
275
+ binder = options.live ? 'live' : 'bind'
276
+ eventIn = options.trigger == 'hover' ? 'mouseenter' : 'focus'
277
+ eventOut = options.trigger == 'hover' ? 'mouseleave' : 'blur'
278
+ this[binder](eventIn, enter)[binder](eventOut, leave)
279
+ }
280
+
281
+ return this
282
+ }
283
+
284
+ $.fn.twipsy.Twipsy = Twipsy
285
+
286
+ $.fn.twipsy.defaults = {
287
+ animate: true
288
+ , delayIn: 0
289
+ , delayOut: 0
290
+ , fallback: ''
291
+ , placement: 'above'
292
+ , html: false
293
+ , live: false
294
+ , offset: 0
295
+ , title: 'title'
296
+ , trigger: 'hover'
297
+ }
298
+
299
+ $.fn.twipsy.elementOptions = function(ele, options) {
300
+ return $.metadata ? $.extend({}, options, $(ele).metadata()) : options
301
+ }
302
+
303
+ }( window.jQuery || window.ender );