bootstrap-generators 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (36) hide show
  1. data/.gitignore +1 -0
  2. data/bootstrap-generators.gemspec +4 -2
  3. data/lib/bootstrap-generators.rb +31 -3
  4. data/lib/bootstrap-generators/engine.rb +6 -0
  5. data/lib/bootstrap-generators/version.rb +1 -1
  6. data/lib/generators/erubis.rb +10 -0
  7. data/lib/generators/{erb → erubis}/controller/controller_generator.rb +3 -3
  8. data/lib/generators/erubis/controller/templates/view.html.erb +3 -0
  9. data/lib/generators/{erb → erubis}/scaffold/scaffold_generator.rb +3 -4
  10. data/lib/generators/erubis/scaffold/templates/_form.html.erb +24 -0
  11. data/lib/generators/erubis/scaffold/templates/edit.html.erb +9 -0
  12. data/lib/generators/erubis/scaffold/templates/index.html.erb +31 -0
  13. data/lib/generators/erubis/scaffold/templates/new.html.erb +8 -0
  14. data/lib/generators/erubis/scaffold/templates/show.html.erb +13 -0
  15. data/lib/generators/layout/application.html.erb +42 -0
  16. data/lib/generators/layout/bootstrap-layout.css +3 -0
  17. data/test/lib/generators/{erb → erubis}/controller_generator_test.rb +2 -2
  18. data/test/lib/generators/{erb → erubis}/scaffold_generator_test.rb +3 -3
  19. data/test/test_helper.rb +1 -1
  20. data/vendor/assets/javascripts/bootstrap-alerts.js +111 -0
  21. data/vendor/assets/javascripts/bootstrap-dropdown.js +53 -0
  22. data/vendor/assets/javascripts/bootstrap-modal.js +244 -0
  23. data/vendor/assets/javascripts/bootstrap-popover.js +77 -0
  24. data/vendor/assets/javascripts/bootstrap-scrollspy.js +105 -0
  25. data/vendor/assets/javascripts/bootstrap-tabs.js +77 -0
  26. data/vendor/assets/javascripts/bootstrap-twipsy.js +303 -0
  27. data/vendor/assets/stylesheets/bootstrap.css +2363 -0
  28. data/vendor/assets/stylesheets/bootstrap.min.css +330 -0
  29. metadata +56 -22
  30. data/lib/generators/erb.rb +0 -10
  31. data/lib/generators/erb/controller/templates/view.html.erb +0 -1
  32. data/lib/generators/erb/scaffold/templates/_form.html.erb +0 -1
  33. data/lib/generators/erb/scaffold/templates/edit.html.erb +0 -1
  34. data/lib/generators/erb/scaffold/templates/index.html.erb +0 -1
  35. data/lib/generators/erb/scaffold/templates/new.html.erb +0 -1
  36. data/lib/generators/erb/scaffold/templates/show.html.erb +0 -1
@@ -0,0 +1,244 @@
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, options)
57
+ this.$element = $(content)
58
+ .delegate('.close', 'click.modal', $.proxy(this.hide, this))
59
+
60
+ if ( this.settings.show ) {
61
+ this.show()
62
+ }
63
+
64
+ return this
65
+ }
66
+
67
+ Modal.prototype = {
68
+
69
+ toggle: function () {
70
+ return this[!this.isShown ? 'show' : 'hide']()
71
+ }
72
+
73
+ , show: function () {
74
+ var that = this
75
+ this.isShown = true
76
+ this.$element.trigger('show')
77
+
78
+ escape.call(this)
79
+ backdrop.call(this, function () {
80
+ var transition = $.support.transition && that.$element.hasClass('fade')
81
+
82
+ that.$element
83
+ .appendTo(document.body)
84
+ .show()
85
+
86
+ if (transition) {
87
+ that.$element[0].offsetWidth // force reflow
88
+ }
89
+
90
+ that.$element
91
+ .addClass('in')
92
+
93
+ transition ?
94
+ that.$element.one(transitionEnd, function () { that.$element.trigger('shown') }) :
95
+ that.$element.trigger('shown')
96
+
97
+ })
98
+
99
+ return this
100
+ }
101
+
102
+ , hide: function (e) {
103
+ e && e.preventDefault()
104
+
105
+ if ( !this.isShown ) {
106
+ return this
107
+ }
108
+
109
+ var that = this
110
+ this.isShown = false
111
+
112
+ escape.call(this)
113
+
114
+ this.$element
115
+ .trigger('hide')
116
+ .removeClass('in')
117
+
118
+ function removeElement () {
119
+ that.$element
120
+ .hide()
121
+ .trigger('hidden')
122
+
123
+ backdrop.call(that)
124
+ }
125
+
126
+ $.support.transition && this.$element.hasClass('fade') ?
127
+ this.$element.one(transitionEnd, removeElement) :
128
+ removeElement()
129
+
130
+ return this
131
+ }
132
+
133
+ }
134
+
135
+
136
+ /* MODAL PRIVATE METHODS
137
+ * ===================== */
138
+
139
+ function backdrop ( callback ) {
140
+ var that = this
141
+ , animate = this.$element.hasClass('fade') ? 'fade' : ''
142
+ if ( this.isShown && this.settings.backdrop ) {
143
+ var doAnimate = $.support.transition && animate
144
+
145
+ this.$backdrop = $('<div class="modal-backdrop ' + animate + '" />')
146
+ .appendTo(document.body)
147
+
148
+ if ( this.settings.backdrop != 'static' ) {
149
+ this.$backdrop.click($.proxy(this.hide, this))
150
+ }
151
+
152
+ if ( doAnimate ) {
153
+ this.$backdrop[0].offsetWidth // force reflow
154
+ }
155
+
156
+ this.$backdrop.addClass('in')
157
+
158
+ doAnimate ?
159
+ this.$backdrop.one(transitionEnd, callback) :
160
+ callback()
161
+
162
+ } else if ( !this.isShown && this.$backdrop ) {
163
+ this.$backdrop.removeClass('in')
164
+
165
+ function removeElement() {
166
+ that.$backdrop.remove()
167
+ that.$backdrop = null
168
+ }
169
+
170
+ $.support.transition && this.$element.hasClass('fade')?
171
+ this.$backdrop.one(transitionEnd, removeElement) :
172
+ removeElement()
173
+ } else if ( callback ) {
174
+ callback()
175
+ }
176
+ }
177
+
178
+ function escape() {
179
+ var that = this
180
+ if ( this.isShown && this.settings.keyboard ) {
181
+ $(document).bind('keyup.modal', function ( e ) {
182
+ if ( e.which == 27 ) {
183
+ that.hide()
184
+ }
185
+ })
186
+ } else if ( !this.isShown ) {
187
+ $(document).unbind('keyup.modal')
188
+ }
189
+ }
190
+
191
+
192
+ /* MODAL PLUGIN DEFINITION
193
+ * ======================= */
194
+
195
+ $.fn.modal = function ( options ) {
196
+ var modal = this.data('modal')
197
+
198
+ if (!modal) {
199
+
200
+ if (typeof options == 'string') {
201
+ options = {
202
+ show: /show|toggle/.test(options)
203
+ }
204
+ }
205
+
206
+ return this.each(function () {
207
+ $(this).data('modal', new Modal(this, options))
208
+ })
209
+ }
210
+
211
+ if ( options === true ) {
212
+ return modal
213
+ }
214
+
215
+ if ( typeof options == 'string' ) {
216
+ modal[options]()
217
+ } else if ( modal ) {
218
+ modal.toggle()
219
+ }
220
+
221
+ return this
222
+ }
223
+
224
+ $.fn.modal.Modal = Modal
225
+
226
+ $.fn.modal.defaults = {
227
+ backdrop: false
228
+ , keyboard: false
229
+ , show: false
230
+ }
231
+
232
+
233
+ /* MODAL DATA- IMPLEMENTATION
234
+ * ========================== */
235
+
236
+ $(document).ready(function () {
237
+ $('body').delegate('[data-controls-modal]', 'click', function (e) {
238
+ e.preventDefault()
239
+ var $this = $(this).data('show', true)
240
+ $('#' + $this.attr('data-controls-modal')).modal( $this.data() )
241
+ })
242
+ })
243
+
244
+ }( window.jQuery || window.ender );
@@ -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 );