newton-rails 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.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/.gitmodules +3 -0
- data/Gemfile +4 -0
- data/README.md +42 -0
- data/Rakefile +61 -0
- data/app/assets/javascripts/twitter/bootstrap.js +12 -0
- data/app/assets/javascripts/twitter/bootstrap/affix.js +120 -0
- data/app/assets/javascripts/twitter/bootstrap/alert.js +96 -0
- data/app/assets/javascripts/twitter/bootstrap/button.js +105 -0
- data/app/assets/javascripts/twitter/bootstrap/carousel.js +210 -0
- data/app/assets/javascripts/twitter/bootstrap/collapse.js +153 -0
- data/app/assets/javascripts/twitter/bootstrap/dropdown.js +155 -0
- data/app/assets/javascripts/twitter/bootstrap/modal.js +243 -0
- data/app/assets/javascripts/twitter/bootstrap/popover.js +109 -0
- data/app/assets/javascripts/twitter/bootstrap/scrollspy.js +156 -0
- data/app/assets/javascripts/twitter/bootstrap/tab.js +133 -0
- data/app/assets/javascripts/twitter/bootstrap/tooltip.js +356 -0
- data/app/assets/javascripts/twitter/bootstrap/transition.js +47 -0
- data/app/assets/stylesheets/newton/newton.scss +1 -0
- data/lib/newton-rails.rb +8 -0
- data/lib/newton-rails/engine.rb +10 -0
- data/lib/newton-rails/version.rb +5 -0
- data/newton-rails.gemspec +20 -0
- data/test/test_helper.rb +2 -0
- metadata +69 -0
@@ -0,0 +1,243 @@
|
|
1
|
+
/* ========================================================================
|
2
|
+
* Bootstrap: modal.js v3.0.0
|
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 ($) { "use strict";
|
22
|
+
|
23
|
+
// MODAL CLASS DEFINITION
|
24
|
+
// ======================
|
25
|
+
|
26
|
+
var Modal = function (element, options) {
|
27
|
+
this.options = options
|
28
|
+
this.$element = $(element).delegate('[data-dismiss="modal"]', 'click.dismiss.modal', $.proxy(this.hide, this))
|
29
|
+
this.$backdrop =
|
30
|
+
this.isShown = null
|
31
|
+
|
32
|
+
if (this.options.remote) this.$element.find('.modal-body').load(this.options.remote)
|
33
|
+
}
|
34
|
+
|
35
|
+
Modal.DEFAULTS = {
|
36
|
+
backdrop: true
|
37
|
+
, keyboard: true
|
38
|
+
, show: true
|
39
|
+
}
|
40
|
+
|
41
|
+
Modal.prototype.toggle = function () {
|
42
|
+
return this[!this.isShown ? 'show' : 'hide']()
|
43
|
+
}
|
44
|
+
|
45
|
+
Modal.prototype.show = function () {
|
46
|
+
var that = this
|
47
|
+
var e = $.Event('show.bs.modal')
|
48
|
+
|
49
|
+
this.$element.trigger(e)
|
50
|
+
|
51
|
+
if (this.isShown || e.isDefaultPrevented()) return
|
52
|
+
|
53
|
+
this.isShown = true
|
54
|
+
|
55
|
+
this.escape()
|
56
|
+
|
57
|
+
this.backdrop(function () {
|
58
|
+
var transition = $.support.transition && that.$element.hasClass('fade')
|
59
|
+
|
60
|
+
if (!that.$element.parent().length) {
|
61
|
+
that.$element.appendTo(document.body) // don't move modals dom position
|
62
|
+
}
|
63
|
+
|
64
|
+
that.$element.show()
|
65
|
+
|
66
|
+
if (transition) {
|
67
|
+
that.$element[0].offsetWidth // force reflow
|
68
|
+
}
|
69
|
+
|
70
|
+
that.$element
|
71
|
+
.addClass('in')
|
72
|
+
.attr('aria-hidden', false)
|
73
|
+
|
74
|
+
that.enforceFocus()
|
75
|
+
|
76
|
+
transition ?
|
77
|
+
that.$element.one($.support.transition.end, function () { that.$element.focus().trigger('shown.bs.modal') }) :
|
78
|
+
that.$element.focus().trigger('shown.bs.modal')
|
79
|
+
})
|
80
|
+
}
|
81
|
+
|
82
|
+
Modal.prototype.hide = function (e) {
|
83
|
+
if (e) e.preventDefault()
|
84
|
+
|
85
|
+
e = $.Event('hide.bs.modal')
|
86
|
+
|
87
|
+
this.$element.trigger(e)
|
88
|
+
|
89
|
+
if (!this.isShown || e.isDefaultPrevented()) return
|
90
|
+
|
91
|
+
this.isShown = false
|
92
|
+
|
93
|
+
this.escape()
|
94
|
+
|
95
|
+
$(document).off('focusin.bs.modal')
|
96
|
+
|
97
|
+
this.$element
|
98
|
+
.removeClass('in')
|
99
|
+
.attr('aria-hidden', true)
|
100
|
+
|
101
|
+
$.support.transition && this.$element.hasClass('fade') ?
|
102
|
+
this.hideWithTransition() :
|
103
|
+
this.hideModal()
|
104
|
+
}
|
105
|
+
|
106
|
+
Modal.prototype.enforceFocus = function () {
|
107
|
+
$(document)
|
108
|
+
.off('focusin.bs.modal') // guard against infinite focus loop
|
109
|
+
.on('focusin.bs.modal', $.proxy(function (e) {
|
110
|
+
if (this.$element[0] !== e.target && !this.$element.has(e.target).length) {
|
111
|
+
this.$element.focus()
|
112
|
+
}
|
113
|
+
}, this))
|
114
|
+
}
|
115
|
+
|
116
|
+
Modal.prototype.escape = function () {
|
117
|
+
if (this.isShown && this.options.keyboard) {
|
118
|
+
this.$element.on('keyup.dismiss.bs.modal', $.proxy(function (e) {
|
119
|
+
e.which == 27 && this.hide()
|
120
|
+
}, this))
|
121
|
+
} else if (!this.isShown) {
|
122
|
+
this.$element.off('keyup.dismiss.bs.modal')
|
123
|
+
}
|
124
|
+
}
|
125
|
+
|
126
|
+
Modal.prototype.hideWithTransition = function () {
|
127
|
+
var that = this
|
128
|
+
var timeout = setTimeout(function () {
|
129
|
+
that.$element.off($.support.transition.end)
|
130
|
+
that.hideModal()
|
131
|
+
}, 500)
|
132
|
+
|
133
|
+
this.$element.one($.support.transition.end, function () {
|
134
|
+
clearTimeout(timeout)
|
135
|
+
that.hideModal()
|
136
|
+
})
|
137
|
+
}
|
138
|
+
|
139
|
+
Modal.prototype.hideModal = function () {
|
140
|
+
var that = this
|
141
|
+
this.$element.hide()
|
142
|
+
this.backdrop(function () {
|
143
|
+
that.removeBackdrop()
|
144
|
+
that.$element.trigger('hidden.bs.modal')
|
145
|
+
})
|
146
|
+
}
|
147
|
+
|
148
|
+
Modal.prototype.removeBackdrop = function () {
|
149
|
+
this.$backdrop && this.$backdrop.remove()
|
150
|
+
this.$backdrop = null
|
151
|
+
}
|
152
|
+
|
153
|
+
Modal.prototype.backdrop = function (callback) {
|
154
|
+
var that = this
|
155
|
+
var animate = this.$element.hasClass('fade') ? 'fade' : ''
|
156
|
+
|
157
|
+
if (this.isShown && this.options.backdrop) {
|
158
|
+
var doAnimate = $.support.transition && animate
|
159
|
+
|
160
|
+
this.$backdrop = $('<div class="modal-backdrop ' + animate + '" />')
|
161
|
+
.appendTo(document.body)
|
162
|
+
|
163
|
+
this.$backdrop.click(
|
164
|
+
this.options.backdrop == 'static' ?
|
165
|
+
$.proxy(this.$element[0].focus, this.$element[0])
|
166
|
+
: $.proxy(this.hide, this)
|
167
|
+
)
|
168
|
+
|
169
|
+
if (doAnimate) this.$backdrop[0].offsetWidth // force reflow
|
170
|
+
|
171
|
+
this.$backdrop.addClass('in')
|
172
|
+
|
173
|
+
if (!callback) return
|
174
|
+
|
175
|
+
doAnimate ?
|
176
|
+
this.$backdrop.one($.support.transition.end, callback) :
|
177
|
+
callback()
|
178
|
+
|
179
|
+
} else if (!this.isShown && this.$backdrop) {
|
180
|
+
this.$backdrop.removeClass('in')
|
181
|
+
|
182
|
+
$.support.transition && this.$element.hasClass('fade')?
|
183
|
+
this.$backdrop.one($.support.transition.end, callback) :
|
184
|
+
callback()
|
185
|
+
|
186
|
+
} else if (callback) {
|
187
|
+
callback()
|
188
|
+
}
|
189
|
+
}
|
190
|
+
|
191
|
+
|
192
|
+
// MODAL PLUGIN DEFINITION
|
193
|
+
// =======================
|
194
|
+
|
195
|
+
var old = $.fn.modal
|
196
|
+
|
197
|
+
$.fn.modal = function (option) {
|
198
|
+
return this.each(function () {
|
199
|
+
var $this = $(this)
|
200
|
+
var data = $this.data('bs.modal')
|
201
|
+
var options = $.extend({}, Modal.DEFAULTS, $this.data(), typeof option == 'object' && option)
|
202
|
+
|
203
|
+
if (!data) $this.data('bs.modal', (data = new Modal(this, options)))
|
204
|
+
if (typeof option == 'string') data[option]()
|
205
|
+
else if (options.show) data.show()
|
206
|
+
})
|
207
|
+
}
|
208
|
+
|
209
|
+
$.fn.modal.Constructor = Modal
|
210
|
+
|
211
|
+
|
212
|
+
// MODAL NO CONFLICT
|
213
|
+
// =================
|
214
|
+
|
215
|
+
$.fn.modal.noConflict = function () {
|
216
|
+
$.fn.modal = old
|
217
|
+
return this
|
218
|
+
}
|
219
|
+
|
220
|
+
|
221
|
+
// MODAL DATA-API
|
222
|
+
// ==============
|
223
|
+
|
224
|
+
$(document).on('click.bs.modal.data-api', '[data-toggle="modal"]', function (e) {
|
225
|
+
var $this = $(this)
|
226
|
+
var href = $this.attr('href')
|
227
|
+
var $target = $($this.attr('data-target') || (href && href.replace(/.*(?=#[^\s]+$)/, ''))) //strip for ie7
|
228
|
+
var option = $target.data('modal') ? 'toggle' : $.extend({ remote:!/#/.test(href) && href }, $target.data(), $this.data())
|
229
|
+
|
230
|
+
e.preventDefault()
|
231
|
+
|
232
|
+
$target
|
233
|
+
.modal(option)
|
234
|
+
.one('hide', function () {
|
235
|
+
$this.focus()
|
236
|
+
})
|
237
|
+
})
|
238
|
+
|
239
|
+
var $body = $(document.body)
|
240
|
+
.on('bs.modal.shown', '.modal', function () { $body.addClass('modal-open') })
|
241
|
+
.on('bs.modal.hidden', '.modal', function () { $body.removeClass('modal-open') })
|
242
|
+
|
243
|
+
}(window.jQuery);
|
@@ -0,0 +1,109 @@
|
|
1
|
+
/* ========================================================================
|
2
|
+
* Bootstrap: popover.js v3.0.0
|
3
|
+
* http://twitter.github.com/bootstrap/javascript.html#popovers
|
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 ($) { "use strict";
|
22
|
+
|
23
|
+
// POPOVER PUBLIC CLASS DEFINITION
|
24
|
+
// ===============================
|
25
|
+
|
26
|
+
var Popover = function (element, options) {
|
27
|
+
this.init('popover', element, options)
|
28
|
+
}
|
29
|
+
|
30
|
+
Popover.DEFAULTS = $.extend({} , $.fn.tooltip.Constructor.DEFAULTS, {
|
31
|
+
placement: 'right'
|
32
|
+
, trigger: 'click'
|
33
|
+
, content: ''
|
34
|
+
, template: '<div class="popover"><div class="arrow"></div><h3 class="popover-title"></h3><div class="popover-content"></div></div>'
|
35
|
+
})
|
36
|
+
|
37
|
+
|
38
|
+
// NOTE: POPOVER EXTENDS tooltip.js
|
39
|
+
// ================================
|
40
|
+
|
41
|
+
Popover.prototype = $.extend({}, $.fn.tooltip.Constructor.prototype)
|
42
|
+
|
43
|
+
Popover.prototype.constructor = Popover
|
44
|
+
|
45
|
+
Popover.prototype.getDefaults = function () {
|
46
|
+
return Popover.DEFAULTS
|
47
|
+
}
|
48
|
+
|
49
|
+
Popover.prototype.setContent = function () {
|
50
|
+
var $tip = this.tip()
|
51
|
+
var title = this.getTitle()
|
52
|
+
var content = this.getContent()
|
53
|
+
|
54
|
+
$tip.find('.popover-title')[this.options.html ? 'html' : 'text'](title)
|
55
|
+
$tip.find('.popover-content')[this.options.html ? 'html' : 'text'](content)
|
56
|
+
|
57
|
+
$tip.removeClass('fade top bottom left right in')
|
58
|
+
}
|
59
|
+
|
60
|
+
Popover.prototype.hasContent = function () {
|
61
|
+
return this.getTitle() || this.getContent()
|
62
|
+
}
|
63
|
+
|
64
|
+
Popover.prototype.getContent = function () {
|
65
|
+
var content = typeof this.options.content == 'function' ?
|
66
|
+
this.options.content.call(this.$element[0]) :
|
67
|
+
this.options.content
|
68
|
+
|
69
|
+
return content || this.$element.attr('data-content')
|
70
|
+
}
|
71
|
+
|
72
|
+
Popover.prototype.tip = function () {
|
73
|
+
if (!this.$tip) this.$tip = $(this.options.template)
|
74
|
+
return this.$tip
|
75
|
+
}
|
76
|
+
|
77
|
+
Popover.prototype.destroy = function () {
|
78
|
+
this.hide().$element.off('.' + this.type).removeData(this.type)
|
79
|
+
}
|
80
|
+
|
81
|
+
|
82
|
+
// POPOVER PLUGIN DEFINITION
|
83
|
+
// =========================
|
84
|
+
|
85
|
+
var old = $.fn.popover
|
86
|
+
|
87
|
+
$.fn.popover = function (option) {
|
88
|
+
return this.each(function () {
|
89
|
+
var $this = $(this)
|
90
|
+
var data = $this.data('bs.popover')
|
91
|
+
var options = typeof option == 'object' && option
|
92
|
+
|
93
|
+
if (!data) $this.data('bs.popover', (data = new Popover(this, options)))
|
94
|
+
if (typeof option == 'string') data[option]()
|
95
|
+
})
|
96
|
+
}
|
97
|
+
|
98
|
+
$.fn.popover.Constructor = Popover
|
99
|
+
|
100
|
+
|
101
|
+
// POPOVER NO CONFLICT
|
102
|
+
// ===================
|
103
|
+
|
104
|
+
$.fn.popover.noConflict = function () {
|
105
|
+
$.fn.popover = old
|
106
|
+
return this
|
107
|
+
}
|
108
|
+
|
109
|
+
}(window.jQuery);
|
@@ -0,0 +1,156 @@
|
|
1
|
+
/* ========================================================================
|
2
|
+
* Bootstrap: scrollspy.js v3.0.0
|
3
|
+
* http://twitter.github.com/bootstrap/javascript.html#scrollspy
|
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 ($) { "use strict";
|
22
|
+
|
23
|
+
// SCROLLSPY CLASS DEFINITION
|
24
|
+
// ==========================
|
25
|
+
|
26
|
+
function ScrollSpy(element, options) {
|
27
|
+
var href
|
28
|
+
var process = $.proxy(this.process, this)
|
29
|
+
var $element = $(element).is('body') ? $(window) : $(element)
|
30
|
+
|
31
|
+
this.$body = $('body')
|
32
|
+
this.$scrollElement = $element.on('scroll.bs.scroll-spy.data-api', process)
|
33
|
+
this.options = $.extend({}, ScrollSpy.DEFAULTS, options)
|
34
|
+
this.selector = (this.options.target
|
35
|
+
|| ((href = $(element).attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '')) //strip for ie7
|
36
|
+
|| '') + ' .nav li > a'
|
37
|
+
this.offsets = $([])
|
38
|
+
this.targets = $([])
|
39
|
+
this.activeTarget = null
|
40
|
+
|
41
|
+
this.refresh()
|
42
|
+
this.process()
|
43
|
+
}
|
44
|
+
|
45
|
+
ScrollSpy.DEFAULTS = {
|
46
|
+
offset: 10
|
47
|
+
}
|
48
|
+
|
49
|
+
ScrollSpy.prototype.refresh = function () {
|
50
|
+
this.offsets = $([])
|
51
|
+
this.targets = $([])
|
52
|
+
|
53
|
+
var self = this
|
54
|
+
var $targets = this.$body
|
55
|
+
.find(this.selector)
|
56
|
+
.map(function () {
|
57
|
+
var $el = $(this)
|
58
|
+
var href = $el.data('target') || $el.attr('href')
|
59
|
+
var $href = /^#\w/.test(href) && $(href)
|
60
|
+
|
61
|
+
return ($href
|
62
|
+
&& $href.length
|
63
|
+
&& [[ $href.position().top + (!$.isWindow(self.$scrollElement.get(0)) && self.$scrollElement.scrollTop()), href ]]) || null
|
64
|
+
})
|
65
|
+
.sort(function (a, b) { return a[0] - b[0] })
|
66
|
+
.each(function () {
|
67
|
+
self.offsets.push(this[0])
|
68
|
+
self.targets.push(this[1])
|
69
|
+
})
|
70
|
+
}
|
71
|
+
|
72
|
+
ScrollSpy.prototype.process = function () {
|
73
|
+
var scrollTop = this.$scrollElement.scrollTop() + this.options.offset
|
74
|
+
var scrollHeight = this.$scrollElement[0].scrollHeight || this.$body[0].scrollHeight
|
75
|
+
var maxScroll = scrollHeight - this.$scrollElement.height()
|
76
|
+
var offsets = this.offsets
|
77
|
+
var targets = this.targets
|
78
|
+
var activeTarget = this.activeTarget
|
79
|
+
var i
|
80
|
+
|
81
|
+
if (scrollTop >= maxScroll) {
|
82
|
+
return activeTarget != (i = targets.last()[0]) && this.activate(i)
|
83
|
+
}
|
84
|
+
|
85
|
+
for (i = offsets.length; i--;) {
|
86
|
+
activeTarget != targets[i]
|
87
|
+
&& scrollTop >= offsets[i]
|
88
|
+
&& (!offsets[i + 1] || scrollTop <= offsets[i + 1])
|
89
|
+
&& this.activate( targets[i] )
|
90
|
+
}
|
91
|
+
}
|
92
|
+
|
93
|
+
ScrollSpy.prototype.activate = function (target) {
|
94
|
+
this.activeTarget = target
|
95
|
+
|
96
|
+
$(this.selector)
|
97
|
+
.parents('.active')
|
98
|
+
.removeClass('active')
|
99
|
+
|
100
|
+
var selector = this.selector
|
101
|
+
+ '[data-target="' + target + '"],'
|
102
|
+
+ this.selector + '[href="' + target + '"]'
|
103
|
+
|
104
|
+
var active = $(selector)
|
105
|
+
.parents('li')
|
106
|
+
.addClass('active')
|
107
|
+
|
108
|
+
if (active.parent('.dropdown-menu').length) {
|
109
|
+
active = active
|
110
|
+
.closest('li.dropdown')
|
111
|
+
.addClass('active')
|
112
|
+
}
|
113
|
+
|
114
|
+
active.trigger('activate')
|
115
|
+
}
|
116
|
+
|
117
|
+
|
118
|
+
// SCROLLSPY PLUGIN DEFINITION
|
119
|
+
// ===========================
|
120
|
+
|
121
|
+
var old = $.fn.scrollspy
|
122
|
+
|
123
|
+
$.fn.scrollspy = function (option) {
|
124
|
+
return this.each(function () {
|
125
|
+
var $this = $(this)
|
126
|
+
var data = $this.data('bs.scrollspy')
|
127
|
+
var options = typeof option == 'object' && option
|
128
|
+
|
129
|
+
if (!data) $this.data('bs.scrollspy', (data = new ScrollSpy(this, options)))
|
130
|
+
if (typeof option == 'string') data[option]()
|
131
|
+
})
|
132
|
+
}
|
133
|
+
|
134
|
+
$.fn.scrollspy.Constructor = ScrollSpy
|
135
|
+
|
136
|
+
|
137
|
+
// SCROLLSPY NO CONFLICT
|
138
|
+
// =====================
|
139
|
+
|
140
|
+
$.fn.scrollspy.noConflict = function () {
|
141
|
+
$.fn.scrollspy = old
|
142
|
+
return this
|
143
|
+
}
|
144
|
+
|
145
|
+
|
146
|
+
// SCROLLSPY DATA-API
|
147
|
+
// ==================
|
148
|
+
|
149
|
+
$(window).on('load', function () {
|
150
|
+
$('[data-spy="scroll"]').each(function () {
|
151
|
+
var $spy = $(this)
|
152
|
+
$spy.scrollspy($spy.data())
|
153
|
+
})
|
154
|
+
})
|
155
|
+
|
156
|
+
}(window.jQuery);
|