beautiful_scaffold 0.0.8 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (48) hide show
  1. data/beautiful_scaffold.gemspec +1 -1
  2. data/lib/generators/USAGE +0 -3
  3. data/lib/generators/beautiful_migration_generator.rb +13 -2
  4. data/lib/generators/beautiful_scaffold_common_methods.rb +4 -1
  5. data/lib/generators/beautiful_scaffold_generator.rb +35 -8
  6. data/lib/generators/templates/app/assets/images/glyphicons-halflings-white.png +0 -0
  7. data/lib/generators/templates/app/assets/images/glyphicons-halflings.png +0 -0
  8. data/lib/generators/templates/app/assets/javascripts/beautiful_scaffold.js +49 -73
  9. data/lib/generators/templates/app/assets/javascripts/bootstrap-alert.js +90 -0
  10. data/lib/generators/templates/app/assets/javascripts/bootstrap-dropdown.js +100 -0
  11. data/lib/generators/templates/app/assets/javascripts/bootstrap-modal.js +218 -0
  12. data/lib/generators/templates/app/assets/javascripts/bootstrap-tooltip.js +275 -0
  13. data/lib/generators/templates/app/assets/javascripts/bootstrap.js +1825 -0
  14. data/lib/generators/templates/app/assets/javascripts/bootstrap.min.js +6 -0
  15. data/lib/generators/templates/app/assets/stylesheets/beautiful-scaffold.css.scss +88 -0
  16. data/lib/generators/templates/app/assets/stylesheets/bootstrap-responsive.css +815 -0
  17. data/lib/generators/templates/app/assets/stylesheets/bootstrap-responsive.min.css +9 -0
  18. data/lib/generators/templates/app/assets/stylesheets/bootstrap.css +4983 -0
  19. data/lib/generators/templates/app/assets/stylesheets/bootstrap.min.css +9 -0
  20. data/lib/generators/templates/app/controllers/base.rb +3 -2
  21. data/lib/generators/templates/app/controllers/master_base.rb +22 -1
  22. data/lib/generators/templates/app/helpers/beautiful_helper.rb +75 -56
  23. data/lib/generators/templates/app/initializers/link_renderer.rb +51 -0
  24. data/lib/generators/templates/app/locales/beautiful_scaffold.en.yml +6 -2
  25. data/lib/generators/templates/app/locales/beautiful_scaffold.fr.yml +7 -3
  26. data/lib/generators/templates/app/views/_beautiful_menu.html.erb +1 -9
  27. data/lib/generators/templates/app/views/_form.html.erb +3 -3
  28. data/lib/generators/templates/app/views/_modal_columns.html.erb +41 -0
  29. data/lib/generators/templates/app/views/dashboard.html.erb +0 -0
  30. data/lib/generators/templates/app/views/edit.html.erb +5 -6
  31. data/lib/generators/templates/app/views/index.html.erb +87 -74
  32. data/lib/generators/templates/app/views/layout.html.erb +77 -41
  33. data/lib/generators/templates/app/views/new.html.erb +5 -5
  34. data/lib/generators/templates/app/views/partials/_form_field.html.erb +45 -25
  35. data/lib/generators/templates/app/views/partials/_index_batch.html.erb +2 -2
  36. data/lib/generators/templates/app/views/partials/_index_column.html.erb +1 -1
  37. data/lib/generators/templates/app/views/partials/_index_header.html.erb +1 -1
  38. data/lib/generators/templates/app/views/show.html.erb +8 -7
  39. metadata +18 -11
  40. data/lib/generators/templates/app/assets/images/bg-bottom-login.jpg +0 -0
  41. data/lib/generators/templates/app/assets/images/bg-error.png +0 -0
  42. data/lib/generators/templates/app/assets/images/bg-left.jpg +0 -0
  43. data/lib/generators/templates/app/assets/images/bg-notice.jpg +0 -0
  44. data/lib/generators/templates/app/assets/images/bg-notice.png +0 -0
  45. data/lib/generators/templates/app/assets/images/bg-success.png +0 -0
  46. data/lib/generators/templates/app/assets/images/bg-top-login.jpg +0 -0
  47. data/lib/generators/templates/app/assets/images/bg-warning.png +0 -0
  48. data/lib/generators/templates/app/assets/stylesheets/beautiful_scaffold.css.scss +0 -719
@@ -0,0 +1,218 @@
1
+ /* =========================================================
2
+ * bootstrap-modal.js v2.0.4
3
+ * http://twitter.github.com/bootstrap/javascript.html#modals
4
+ * =========================================================
5
+ * Copyright 2012 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"; // jshint ;_;
24
+
25
+
26
+ /* MODAL CLASS DEFINITION
27
+ * ====================== */
28
+
29
+ var Modal = function (content, options) {
30
+ this.options = options
31
+ this.$element = $(content)
32
+ .delegate('[data-dismiss="modal"]', 'click.dismiss.modal', $.proxy(this.hide, this))
33
+ }
34
+
35
+ Modal.prototype = {
36
+
37
+ constructor: Modal
38
+
39
+ , toggle: function () {
40
+ return this[!this.isShown ? 'show' : 'hide']()
41
+ }
42
+
43
+ , show: function () {
44
+ var that = this
45
+ , e = $.Event('show')
46
+
47
+ this.$element.trigger(e)
48
+
49
+ if (this.isShown || e.isDefaultPrevented()) return
50
+
51
+ $('body').addClass('modal-open')
52
+
53
+ this.isShown = true
54
+
55
+ escape.call(this)
56
+ backdrop.call(this, function () {
57
+ var transition = $.support.transition && that.$element.hasClass('fade')
58
+
59
+ if (!that.$element.parent().length) {
60
+ that.$element.appendTo(document.body) //don't move modals dom position
61
+ }
62
+
63
+ that.$element
64
+ .show()
65
+
66
+ if (transition) {
67
+ that.$element[0].offsetWidth // force reflow
68
+ }
69
+
70
+ that.$element.addClass('in')
71
+
72
+ transition ?
73
+ that.$element.one($.support.transition.end, function () { that.$element.trigger('shown') }) :
74
+ that.$element.trigger('shown')
75
+
76
+ })
77
+ }
78
+
79
+ , hide: function (e) {
80
+ e && e.preventDefault()
81
+
82
+ var that = this
83
+
84
+ e = $.Event('hide')
85
+
86
+ this.$element.trigger(e)
87
+
88
+ if (!this.isShown || e.isDefaultPrevented()) return
89
+
90
+ this.isShown = false
91
+
92
+ $('body').removeClass('modal-open')
93
+
94
+ escape.call(this)
95
+
96
+ this.$element.removeClass('in')
97
+
98
+ $.support.transition && this.$element.hasClass('fade') ?
99
+ hideWithTransition.call(this) :
100
+ hideModal.call(this)
101
+ }
102
+
103
+ }
104
+
105
+
106
+ /* MODAL PRIVATE METHODS
107
+ * ===================== */
108
+
109
+ function hideWithTransition() {
110
+ var that = this
111
+ , timeout = setTimeout(function () {
112
+ that.$element.off($.support.transition.end)
113
+ hideModal.call(that)
114
+ }, 500)
115
+
116
+ this.$element.one($.support.transition.end, function () {
117
+ clearTimeout(timeout)
118
+ hideModal.call(that)
119
+ })
120
+ }
121
+
122
+ function hideModal(that) {
123
+ this.$element
124
+ .hide()
125
+ .trigger('hidden')
126
+
127
+ backdrop.call(this)
128
+ }
129
+
130
+ function backdrop(callback) {
131
+ var that = this
132
+ , animate = this.$element.hasClass('fade') ? 'fade' : ''
133
+
134
+ if (this.isShown && this.options.backdrop) {
135
+ var doAnimate = $.support.transition && animate
136
+
137
+ this.$backdrop = $('<div class="modal-backdrop ' + animate + '" />')
138
+ .appendTo(document.body)
139
+
140
+ if (this.options.backdrop != 'static') {
141
+ this.$backdrop.click($.proxy(this.hide, this))
142
+ }
143
+
144
+ if (doAnimate) this.$backdrop[0].offsetWidth // force reflow
145
+
146
+ this.$backdrop.addClass('in')
147
+
148
+ doAnimate ?
149
+ this.$backdrop.one($.support.transition.end, callback) :
150
+ callback()
151
+
152
+ } else if (!this.isShown && this.$backdrop) {
153
+ this.$backdrop.removeClass('in')
154
+
155
+ $.support.transition && this.$element.hasClass('fade')?
156
+ this.$backdrop.one($.support.transition.end, $.proxy(removeBackdrop, this)) :
157
+ removeBackdrop.call(this)
158
+
159
+ } else if (callback) {
160
+ callback()
161
+ }
162
+ }
163
+
164
+ function removeBackdrop() {
165
+ this.$backdrop.remove()
166
+ this.$backdrop = null
167
+ }
168
+
169
+ function escape() {
170
+ var that = this
171
+ if (this.isShown && this.options.keyboard) {
172
+ $(document).on('keyup.dismiss.modal', function ( e ) {
173
+ e.which == 27 && that.hide()
174
+ })
175
+ } else if (!this.isShown) {
176
+ $(document).off('keyup.dismiss.modal')
177
+ }
178
+ }
179
+
180
+
181
+ /* MODAL PLUGIN DEFINITION
182
+ * ======================= */
183
+
184
+ $.fn.modal = function (option) {
185
+ return this.each(function () {
186
+ var $this = $(this)
187
+ , data = $this.data('modal')
188
+ , options = $.extend({}, $.fn.modal.defaults, $this.data(), typeof option == 'object' && option)
189
+ if (!data) $this.data('modal', (data = new Modal(this, options)))
190
+ if (typeof option == 'string') data[option]()
191
+ else if (options.show) data.show()
192
+ })
193
+ }
194
+
195
+ $.fn.modal.defaults = {
196
+ backdrop: true
197
+ , keyboard: true
198
+ , show: true
199
+ }
200
+
201
+ $.fn.modal.Constructor = Modal
202
+
203
+
204
+ /* MODAL DATA-API
205
+ * ============== */
206
+
207
+ $(function () {
208
+ $('body').on('click.modal.data-api', '[data-toggle="modal"]', function ( e ) {
209
+ var $this = $(this), href
210
+ , $target = $($this.attr('data-target') || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '')) //strip for ie7
211
+ , option = $target.data('modal') ? 'toggle' : $.extend({}, $target.data(), $this.data())
212
+
213
+ e.preventDefault()
214
+ $target.modal(option)
215
+ })
216
+ })
217
+
218
+ }(window.jQuery);
@@ -0,0 +1,275 @@
1
+ /* ===========================================================
2
+ * bootstrap-tooltip.js v2.0.4
3
+ * http://twitter.github.com/bootstrap/javascript.html#tooltips
4
+ * Inspired by the original jQuery.tipsy by Jason Frame
5
+ * ===========================================================
6
+ * Copyright 2012 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"; // jshint ;_;
25
+
26
+
27
+ /* TOOLTIP PUBLIC CLASS DEFINITION
28
+ * =============================== */
29
+
30
+ var Tooltip = function (element, options) {
31
+ this.init('tooltip', element, options)
32
+ }
33
+
34
+ Tooltip.prototype = {
35
+
36
+ constructor: Tooltip
37
+
38
+ , init: function (type, element, options) {
39
+ var eventIn
40
+ , eventOut
41
+
42
+ this.type = type
43
+ this.$element = $(element)
44
+ this.options = this.getOptions(options)
45
+ this.enabled = true
46
+
47
+ if (this.options.trigger != 'manual') {
48
+ eventIn = this.options.trigger == 'hover' ? 'mouseenter' : 'focus'
49
+ eventOut = this.options.trigger == 'hover' ? 'mouseleave' : 'blur'
50
+ this.$element.on(eventIn, this.options.selector, $.proxy(this.enter, this))
51
+ this.$element.on(eventOut, this.options.selector, $.proxy(this.leave, this))
52
+ }
53
+
54
+ this.options.selector ?
55
+ (this._options = $.extend({}, this.options, { trigger: 'manual', selector: '' })) :
56
+ this.fixTitle()
57
+ }
58
+
59
+ , getOptions: function (options) {
60
+ options = $.extend({}, $.fn[this.type].defaults, options, this.$element.data())
61
+
62
+ if (options.delay && typeof options.delay == 'number') {
63
+ options.delay = {
64
+ show: options.delay
65
+ , hide: options.delay
66
+ }
67
+ }
68
+
69
+ return options
70
+ }
71
+
72
+ , enter: function (e) {
73
+ var self = $(e.currentTarget)[this.type](this._options).data(this.type)
74
+
75
+ if (!self.options.delay || !self.options.delay.show) return self.show()
76
+
77
+ clearTimeout(this.timeout)
78
+ self.hoverState = 'in'
79
+ this.timeout = setTimeout(function() {
80
+ if (self.hoverState == 'in') self.show()
81
+ }, self.options.delay.show)
82
+ }
83
+
84
+ , leave: function (e) {
85
+ var self = $(e.currentTarget)[this.type](this._options).data(this.type)
86
+
87
+ if (this.timeout) clearTimeout(this.timeout)
88
+ if (!self.options.delay || !self.options.delay.hide) return self.hide()
89
+
90
+ self.hoverState = 'out'
91
+ this.timeout = setTimeout(function() {
92
+ if (self.hoverState == 'out') self.hide()
93
+ }, self.options.delay.hide)
94
+ }
95
+
96
+ , show: function () {
97
+ var $tip
98
+ , inside
99
+ , pos
100
+ , actualWidth
101
+ , actualHeight
102
+ , placement
103
+ , tp
104
+
105
+ if (this.hasContent() && this.enabled) {
106
+ $tip = this.tip()
107
+ this.setContent()
108
+
109
+ if (this.options.animation) {
110
+ $tip.addClass('fade')
111
+ }
112
+
113
+ placement = typeof this.options.placement == 'function' ?
114
+ this.options.placement.call(this, $tip[0], this.$element[0]) :
115
+ this.options.placement
116
+
117
+ inside = /in/.test(placement)
118
+
119
+ $tip
120
+ .remove()
121
+ .css({ top: 0, left: 0, display: 'block' })
122
+ .appendTo(inside ? this.$element : document.body)
123
+
124
+ pos = this.getPosition(inside)
125
+
126
+ actualWidth = $tip[0].offsetWidth
127
+ actualHeight = $tip[0].offsetHeight
128
+
129
+ switch (inside ? placement.split(' ')[1] : placement) {
130
+ case 'bottom':
131
+ tp = {top: pos.top + pos.height, left: pos.left + pos.width / 2 - actualWidth / 2}
132
+ break
133
+ case 'top':
134
+ tp = {top: pos.top - actualHeight, left: pos.left + pos.width / 2 - actualWidth / 2}
135
+ break
136
+ case 'left':
137
+ tp = {top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left - actualWidth}
138
+ break
139
+ case 'right':
140
+ tp = {top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left + pos.width}
141
+ break
142
+ }
143
+
144
+ $tip
145
+ .css(tp)
146
+ .addClass(placement)
147
+ .addClass('in')
148
+ }
149
+ }
150
+
151
+ , isHTML: function(text) {
152
+ // html string detection logic adapted from jQuery
153
+ return typeof text != 'string'
154
+ || ( text.charAt(0) === "<"
155
+ && text.charAt( text.length - 1 ) === ">"
156
+ && text.length >= 3
157
+ ) || /^(?:[^<]*<[\w\W]+>[^>]*$)/.exec(text)
158
+ }
159
+
160
+ , setContent: function () {
161
+ var $tip = this.tip()
162
+ , title = this.getTitle()
163
+
164
+ $tip.find('.tooltip-inner')[this.isHTML(title) ? 'html' : 'text'](title)
165
+ $tip.removeClass('fade in top bottom left right')
166
+ }
167
+
168
+ , hide: function () {
169
+ var that = this
170
+ , $tip = this.tip()
171
+
172
+ $tip.removeClass('in')
173
+
174
+ function removeWithAnimation() {
175
+ var timeout = setTimeout(function () {
176
+ $tip.off($.support.transition.end).remove()
177
+ }, 500)
178
+
179
+ $tip.one($.support.transition.end, function () {
180
+ clearTimeout(timeout)
181
+ $tip.remove()
182
+ })
183
+ }
184
+
185
+ $.support.transition && this.$tip.hasClass('fade') ?
186
+ removeWithAnimation() :
187
+ $tip.remove()
188
+ }
189
+
190
+ , fixTitle: function () {
191
+ var $e = this.$element
192
+ if ($e.attr('title') || typeof($e.attr('data-original-title')) != 'string') {
193
+ $e.attr('data-original-title', $e.attr('title') || '').removeAttr('title')
194
+ }
195
+ }
196
+
197
+ , hasContent: function () {
198
+ return this.getTitle()
199
+ }
200
+
201
+ , getPosition: function (inside) {
202
+ return $.extend({}, (inside ? {top: 0, left: 0} : this.$element.offset()), {
203
+ width: this.$element[0].offsetWidth
204
+ , height: this.$element[0].offsetHeight
205
+ })
206
+ }
207
+
208
+ , getTitle: function () {
209
+ var title
210
+ , $e = this.$element
211
+ , o = this.options
212
+
213
+ title = $e.attr('data-original-title')
214
+ || (typeof o.title == 'function' ? o.title.call($e[0]) : o.title)
215
+
216
+ return title
217
+ }
218
+
219
+ , tip: function () {
220
+ return this.$tip = this.$tip || $(this.options.template)
221
+ }
222
+
223
+ , validate: function () {
224
+ if (!this.$element[0].parentNode) {
225
+ this.hide()
226
+ this.$element = null
227
+ this.options = null
228
+ }
229
+ }
230
+
231
+ , enable: function () {
232
+ this.enabled = true
233
+ }
234
+
235
+ , disable: function () {
236
+ this.enabled = false
237
+ }
238
+
239
+ , toggleEnabled: function () {
240
+ this.enabled = !this.enabled
241
+ }
242
+
243
+ , toggle: function () {
244
+ this[this.tip().hasClass('in') ? 'hide' : 'show']()
245
+ }
246
+
247
+ }
248
+
249
+
250
+ /* TOOLTIP PLUGIN DEFINITION
251
+ * ========================= */
252
+
253
+ $.fn.tooltip = function ( option ) {
254
+ return this.each(function () {
255
+ var $this = $(this)
256
+ , data = $this.data('tooltip')
257
+ , options = typeof option == 'object' && option
258
+ if (!data) $this.data('tooltip', (data = new Tooltip(this, options)))
259
+ if (typeof option == 'string') data[option]()
260
+ })
261
+ }
262
+
263
+ $.fn.tooltip.Constructor = Tooltip
264
+
265
+ $.fn.tooltip.defaults = {
266
+ animation: true
267
+ , placement: 'top'
268
+ , selector: false
269
+ , template: '<div class="tooltip"><div class="tooltip-arrow"></div><div class="tooltip-inner"></div></div>'
270
+ , trigger: 'hover'
271
+ , title: ''
272
+ , delay: 0
273
+ }
274
+
275
+ }(window.jQuery);