bootstrap_helpers 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (65) hide show
  1. data/.gitignore +5 -0
  2. data/Gemfile +4 -0
  3. data/Rakefile +1 -0
  4. data/bootstrap_helpers.gemspec +23 -0
  5. data/lib/bootstrap_helpers.rb +3 -0
  6. data/lib/bootstrap_helpers/railtie.rb +9 -0
  7. data/lib/bootstrap_helpers/version.rb +3 -0
  8. data/lib/bootstrap_helpers/view_helpers.rb +20 -0
  9. data/test_app/.gitignore +4 -0
  10. data/test_app/.rspec +1 -0
  11. data/test_app/Gemfile +19 -0
  12. data/test_app/Guardfile +22 -0
  13. data/test_app/README +256 -0
  14. data/test_app/Rakefile +7 -0
  15. data/test_app/app/controllers/application_controller.rb +3 -0
  16. data/test_app/app/controllers/samples_controller.rb +7 -0
  17. data/test_app/app/helpers/application_helper.rb +2 -0
  18. data/test_app/app/views/layouts/application.html.erb +14 -0
  19. data/test_app/app/views/samples/bootstrap_form_input.html.erb +3 -0
  20. data/test_app/app/views/samples/index.html.erb +3 -0
  21. data/test_app/config.ru +4 -0
  22. data/test_app/config/application.rb +42 -0
  23. data/test_app/config/boot.rb +6 -0
  24. data/test_app/config/database.yml +22 -0
  25. data/test_app/config/environment.rb +5 -0
  26. data/test_app/config/environments/development.rb +26 -0
  27. data/test_app/config/environments/production.rb +49 -0
  28. data/test_app/config/environments/test.rb +35 -0
  29. data/test_app/config/initializers/backtrace_silencers.rb +7 -0
  30. data/test_app/config/initializers/inflections.rb +10 -0
  31. data/test_app/config/initializers/mime_types.rb +5 -0
  32. data/test_app/config/initializers/secret_token.rb +7 -0
  33. data/test_app/config/initializers/session_store.rb +8 -0
  34. data/test_app/config/locales/en.yml +5 -0
  35. data/test_app/config/routes.rb +6 -0
  36. data/test_app/db/seeds.rb +7 -0
  37. data/test_app/doc/README_FOR_APP +2 -0
  38. data/test_app/lib/tasks/.gitkeep +0 -0
  39. data/test_app/public/404.html +26 -0
  40. data/test_app/public/422.html +26 -0
  41. data/test_app/public/500.html +26 -0
  42. data/test_app/public/favicon.ico +0 -0
  43. data/test_app/public/images/rails.png +0 -0
  44. data/test_app/public/javascripts/application.js +2 -0
  45. data/test_app/public/javascripts/bootstrap-alerts.js +124 -0
  46. data/test_app/public/javascripts/bootstrap-buttons.js +62 -0
  47. data/test_app/public/javascripts/bootstrap-dropdown.js +55 -0
  48. data/test_app/public/javascripts/bootstrap-modal.js +260 -0
  49. data/test_app/public/javascripts/bootstrap-scrollspy.js +107 -0
  50. data/test_app/public/javascripts/bootstrap-tabs.js +80 -0
  51. data/test_app/public/javascripts/bootstrap-twipsy-popover.js +90 -0
  52. data/test_app/public/javascripts/bootstrap-twipsy.js +321 -0
  53. data/test_app/public/javascripts/jquery-ui.js +11729 -0
  54. data/test_app/public/javascripts/jquery-ui.min.js +412 -0
  55. data/test_app/public/javascripts/jquery.js +8981 -0
  56. data/test_app/public/javascripts/jquery.min.js +18 -0
  57. data/test_app/public/javascripts/jquery_ujs.js +363 -0
  58. data/test_app/public/robots.txt +5 -0
  59. data/test_app/public/stylesheets/.gitkeep +0 -0
  60. data/test_app/public/stylesheets/bootstrap.css +2467 -0
  61. data/test_app/script/rails +6 -0
  62. data/test_app/spec/requests/bootstrap_form_input_spec.rb +18 -0
  63. data/test_app/spec/spec_helper.rb +34 -0
  64. data/test_app/vendor/plugins/.gitkeep +0 -0
  65. metadata +131 -0
@@ -0,0 +1,80 @@
1
+ /* ========================================================
2
+ * bootstrap-tabs.js v1.4.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
+ "use strict"
24
+
25
+ function activate ( element, container ) {
26
+ container
27
+ .find('> .active')
28
+ .removeClass('active')
29
+ .find('> .dropdown-menu > .active')
30
+ .removeClass('active')
31
+
32
+ element.addClass('active')
33
+
34
+ if ( element.parent('.dropdown-menu') ) {
35
+ element.closest('li.dropdown').addClass('active')
36
+ }
37
+ }
38
+
39
+ function tab( e ) {
40
+ var $this = $(this)
41
+ , $ul = $this.closest('ul:not(.dropdown-menu)')
42
+ , href = $this.attr('href')
43
+ , previous
44
+ , $href
45
+
46
+ if ( /^#\w+/.test(href) ) {
47
+ e.preventDefault()
48
+
49
+ if ( $this.parent('li').hasClass('active') ) {
50
+ return
51
+ }
52
+
53
+ previous = $ul.find('.active a').last()[0]
54
+ $href = $(href)
55
+
56
+ activate($this.parent('li'), $ul)
57
+ activate($href, $href.parent())
58
+
59
+ $this.trigger({
60
+ type: 'change'
61
+ , relatedTarget: previous
62
+ })
63
+ }
64
+ }
65
+
66
+
67
+ /* TABS/PILLS PLUGIN DEFINITION
68
+ * ============================ */
69
+
70
+ $.fn.tabs = $.fn.pills = function ( selector ) {
71
+ return this.each(function () {
72
+ $(this).delegate(selector || '.tabs li > a, .pills > li > a', 'click', tab)
73
+ })
74
+ }
75
+
76
+ $(document).ready(function () {
77
+ $('body').tabs('ul[data-tabs] li > a, ul[data-pills] > li > a')
78
+ })
79
+
80
+ }( window.jQuery || window.ender );
@@ -0,0 +1,90 @@
1
+ /* ===========================================================
2
+ * bootstrap-popover.js v1.4.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
+ "use strict"
24
+
25
+ var Popover = function ( element, options ) {
26
+ this.$element = $(element)
27
+ this.options = options
28
+ this.enabled = true
29
+ this.fixTitle()
30
+ }
31
+
32
+ /* NOTE: POPOVER EXTENDS BOOTSTRAP-TWIPSY.js
33
+ ========================================= */
34
+
35
+ Popover.prototype = $.extend({}, $.fn.twipsy.Twipsy.prototype, {
36
+
37
+ setContent: function () {
38
+ var $tip = this.tip()
39
+ $tip.find('.title')[this.options.html ? 'html' : 'text'](this.getTitle())
40
+ $tip.find('.content > *')[this.options.html ? 'html' : 'text'](this.getContent())
41
+ $tip[0].className = 'popover'
42
+ }
43
+
44
+ , hasContent: function () {
45
+ return this.getTitle() || this.getContent()
46
+ }
47
+
48
+ , getContent: function () {
49
+ var content
50
+ , $e = this.$element
51
+ , o = this.options
52
+
53
+ if (typeof this.options.content == 'string') {
54
+ content = $e.attr(this.options.content)
55
+ } else if (typeof this.options.content == 'function') {
56
+ content = this.options.content.call(this.$element[0])
57
+ }
58
+
59
+ return content
60
+ }
61
+
62
+ , tip: function() {
63
+ if (!this.$tip) {
64
+ this.$tip = $('<div class="popover" />')
65
+ .html(this.options.template)
66
+ }
67
+ return this.$tip
68
+ }
69
+
70
+ })
71
+
72
+
73
+ /* POPOVER PLUGIN DEFINITION
74
+ * ======================= */
75
+
76
+ $.fn.popover = function (options) {
77
+ if (typeof options == 'object') options = $.extend({}, $.fn.popover.defaults, options)
78
+ $.fn.twipsy.initWith.call(this, options, Popover, 'popover')
79
+ return this
80
+ }
81
+
82
+ $.fn.popover.defaults = $.extend({} , $.fn.twipsy.defaults, {
83
+ placement: 'right'
84
+ , content: 'data-content'
85
+ , template: '<div class="arrow"></div><div class="inner"><h3 class="title"></h3><div class="content"><p></p></div></div>'
86
+ })
87
+
88
+ $.fn.twipsy.rejectAttrOptions.push( 'content' )
89
+
90
+ }( window.jQuery || window.ender );
@@ -0,0 +1,321 @@
1
+ /* ==========================================================
2
+ * bootstrap-twipsy.js v1.4.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
+ "use strict"
25
+
26
+ /* CSS TRANSITION SUPPORT (https://gist.github.com/373874)
27
+ * ======================================================= */
28
+
29
+ var transitionEnd
30
+
31
+ $(document).ready(function () {
32
+
33
+ $.support.transition = (function () {
34
+ var thisBody = document.body || document.documentElement
35
+ , thisStyle = thisBody.style
36
+ , support = thisStyle.transition !== undefined || thisStyle.WebkitTransition !== undefined || thisStyle.MozTransition !== undefined || thisStyle.MsTransition !== undefined || thisStyle.OTransition !== undefined
37
+ return support
38
+ })()
39
+
40
+ // set CSS transition event type
41
+ if ( $.support.transition ) {
42
+ transitionEnd = "TransitionEnd"
43
+ if ( $.browser.webkit ) {
44
+ transitionEnd = "webkitTransitionEnd"
45
+ } else if ( $.browser.mozilla ) {
46
+ transitionEnd = "transitionend"
47
+ } else if ( $.browser.opera ) {
48
+ transitionEnd = "oTransitionEnd"
49
+ }
50
+ }
51
+
52
+ })
53
+
54
+
55
+ /* TWIPSY PUBLIC CLASS DEFINITION
56
+ * ============================== */
57
+
58
+ var Twipsy = function ( element, options ) {
59
+ this.$element = $(element)
60
+ this.options = options
61
+ this.enabled = true
62
+ this.fixTitle()
63
+ }
64
+
65
+ Twipsy.prototype = {
66
+
67
+ show: function() {
68
+ var pos
69
+ , actualWidth
70
+ , actualHeight
71
+ , placement
72
+ , $tip
73
+ , tp
74
+
75
+ if (this.hasContent() && this.enabled) {
76
+ $tip = this.tip()
77
+ this.setContent()
78
+
79
+ if (this.options.animate) {
80
+ $tip.addClass('fade')
81
+ }
82
+
83
+ $tip
84
+ .remove()
85
+ .css({ top: 0, left: 0, display: 'block' })
86
+ .prependTo(document.body)
87
+
88
+ pos = $.extend({}, this.$element.offset(), {
89
+ width: this.$element[0].offsetWidth
90
+ , height: this.$element[0].offsetHeight
91
+ })
92
+
93
+ actualWidth = $tip[0].offsetWidth
94
+ actualHeight = $tip[0].offsetHeight
95
+
96
+ placement = maybeCall(this.options.placement, this, [ $tip[0], this.$element[0] ])
97
+
98
+ switch (placement) {
99
+ case 'below':
100
+ tp = {top: pos.top + pos.height + this.options.offset, left: pos.left + pos.width / 2 - actualWidth / 2}
101
+ break
102
+ case 'above':
103
+ tp = {top: pos.top - actualHeight - this.options.offset, left: pos.left + pos.width / 2 - actualWidth / 2}
104
+ break
105
+ case 'left':
106
+ tp = {top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left - actualWidth - this.options.offset}
107
+ break
108
+ case 'right':
109
+ tp = {top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left + pos.width + this.options.offset}
110
+ break
111
+ }
112
+
113
+ $tip
114
+ .css(tp)
115
+ .addClass(placement)
116
+ .addClass('in')
117
+ }
118
+ }
119
+
120
+ , setContent: function () {
121
+ var $tip = this.tip()
122
+ $tip.find('.twipsy-inner')[this.options.html ? 'html' : 'text'](this.getTitle())
123
+ $tip[0].className = 'twipsy'
124
+ }
125
+
126
+ , hide: function() {
127
+ var that = this
128
+ , $tip = this.tip()
129
+
130
+ $tip.removeClass('in')
131
+
132
+ function removeElement () {
133
+ $tip.remove()
134
+ }
135
+
136
+ $.support.transition && this.$tip.hasClass('fade') ?
137
+ $tip.bind(transitionEnd, removeElement) :
138
+ removeElement()
139
+ }
140
+
141
+ , fixTitle: function() {
142
+ var $e = this.$element
143
+ if ($e.attr('title') || typeof($e.attr('data-original-title')) != 'string') {
144
+ $e.attr('data-original-title', $e.attr('title') || '').removeAttr('title')
145
+ }
146
+ }
147
+
148
+ , hasContent: function () {
149
+ return this.getTitle()
150
+ }
151
+
152
+ , getTitle: function() {
153
+ var title
154
+ , $e = this.$element
155
+ , o = this.options
156
+
157
+ this.fixTitle()
158
+
159
+ if (typeof o.title == 'string') {
160
+ title = $e.attr(o.title == 'title' ? 'data-original-title' : o.title)
161
+ } else if (typeof o.title == 'function') {
162
+ title = o.title.call($e[0])
163
+ }
164
+
165
+ title = ('' + title).replace(/(^\s*|\s*$)/, "")
166
+
167
+ return title || o.fallback
168
+ }
169
+
170
+ , tip: function() {
171
+ return this.$tip = this.$tip || $('<div class="twipsy" />').html(this.options.template)
172
+ }
173
+
174
+ , validate: function() {
175
+ if (!this.$element[0].parentNode) {
176
+ this.hide()
177
+ this.$element = null
178
+ this.options = null
179
+ }
180
+ }
181
+
182
+ , enable: function() {
183
+ this.enabled = true
184
+ }
185
+
186
+ , disable: function() {
187
+ this.enabled = false
188
+ }
189
+
190
+ , toggleEnabled: function() {
191
+ this.enabled = !this.enabled
192
+ }
193
+
194
+ , toggle: function () {
195
+ this[this.tip().hasClass('in') ? 'hide' : 'show']()
196
+ }
197
+
198
+ }
199
+
200
+
201
+ /* TWIPSY PRIVATE METHODS
202
+ * ====================== */
203
+
204
+ function maybeCall ( thing, ctx, args ) {
205
+ return typeof thing == 'function' ? thing.apply(ctx, args) : thing
206
+ }
207
+
208
+ /* TWIPSY PLUGIN DEFINITION
209
+ * ======================== */
210
+
211
+ $.fn.twipsy = function (options) {
212
+ $.fn.twipsy.initWith.call(this, options, Twipsy, 'twipsy')
213
+ return this
214
+ }
215
+
216
+ $.fn.twipsy.initWith = function (options, Constructor, name) {
217
+ var twipsy
218
+ , binder
219
+ , eventIn
220
+ , eventOut
221
+
222
+ if (options === true) {
223
+ return this.data(name)
224
+ } else if (typeof options == 'string') {
225
+ twipsy = this.data(name)
226
+ if (twipsy) {
227
+ twipsy[options]()
228
+ }
229
+ return this
230
+ }
231
+
232
+ options = $.extend({}, $.fn[name].defaults, options)
233
+
234
+ function get(ele) {
235
+ var twipsy = $.data(ele, name)
236
+
237
+ if (!twipsy) {
238
+ twipsy = new Constructor(ele, $.fn.twipsy.elementOptions(ele, options))
239
+ $.data(ele, name, twipsy)
240
+ }
241
+
242
+ return twipsy
243
+ }
244
+
245
+ function enter() {
246
+ var twipsy = get(this)
247
+ twipsy.hoverState = 'in'
248
+
249
+ if (options.delayIn == 0) {
250
+ twipsy.show()
251
+ } else {
252
+ twipsy.fixTitle()
253
+ setTimeout(function() {
254
+ if (twipsy.hoverState == 'in') {
255
+ twipsy.show()
256
+ }
257
+ }, options.delayIn)
258
+ }
259
+ }
260
+
261
+ function leave() {
262
+ var twipsy = get(this)
263
+ twipsy.hoverState = 'out'
264
+ if (options.delayOut == 0) {
265
+ twipsy.hide()
266
+ } else {
267
+ setTimeout(function() {
268
+ if (twipsy.hoverState == 'out') {
269
+ twipsy.hide()
270
+ }
271
+ }, options.delayOut)
272
+ }
273
+ }
274
+
275
+ if (!options.live) {
276
+ this.each(function() {
277
+ get(this)
278
+ })
279
+ }
280
+
281
+ if (options.trigger != 'manual') {
282
+ binder = options.live ? 'live' : 'bind'
283
+ eventIn = options.trigger == 'hover' ? 'mouseenter' : 'focus'
284
+ eventOut = options.trigger == 'hover' ? 'mouseleave' : 'blur'
285
+ this[binder](eventIn, enter)[binder](eventOut, leave)
286
+ }
287
+
288
+ return this
289
+ }
290
+
291
+ $.fn.twipsy.Twipsy = Twipsy
292
+
293
+ $.fn.twipsy.defaults = {
294
+ animate: true
295
+ , delayIn: 0
296
+ , delayOut: 0
297
+ , fallback: ''
298
+ , placement: 'above'
299
+ , html: false
300
+ , live: false
301
+ , offset: 0
302
+ , title: 'title'
303
+ , trigger: 'hover'
304
+ , template: '<div class="twipsy-arrow"></div><div class="twipsy-inner"></div>'
305
+ }
306
+
307
+ $.fn.twipsy.rejectAttrOptions = [ 'title' ]
308
+
309
+ $.fn.twipsy.elementOptions = function(ele, options) {
310
+ var data = $(ele).data()
311
+ , rejects = $.fn.twipsy.rejectAttrOptions
312
+ , i = rejects.length
313
+
314
+ while (i--) {
315
+ delete data[rejects[i]]
316
+ }
317
+
318
+ return $.extend({}, options, data)
319
+ }
320
+
321
+ }( window.jQuery || window.ender );