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.
@@ -0,0 +1,133 @@
1
+ /* ========================================================================
2
+ * Bootstrap: tab.js v3.0.0
3
+ * http://twitter.github.com/bootstrap/javascript.html#tabs
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
+ // TAB CLASS DEFINITION
24
+ // ====================
25
+
26
+ var Tab = function (element) {
27
+ this.element = $(element)
28
+ }
29
+
30
+ Tab.prototype.show = function () {
31
+ var $this = this.element
32
+ var $ul = $this.closest('ul:not(.dropdown-menu)')
33
+ var selector = $this.attr('data-target')
34
+
35
+ if (!selector) {
36
+ selector = $this.attr('href')
37
+ selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') //strip for ie7
38
+ }
39
+
40
+ if ($this.parent('li').hasClass('active')) return
41
+
42
+ var previous = $ul.find('.active:last a')[0]
43
+ var e = $.Event('show.bs.tab', {
44
+ relatedTarget: previous
45
+ })
46
+
47
+ $this.trigger(e)
48
+
49
+ if (e.isDefaultPrevented()) return
50
+
51
+ var $target = $(selector)
52
+
53
+ this.activate($this.parent('li'), $ul)
54
+ this.activate($target, $target.parent(), function () {
55
+ $this.trigger({
56
+ type: 'shown.bs.tab'
57
+ , relatedTarget: previous
58
+ })
59
+ })
60
+ }
61
+
62
+ Tab.prototype.activate = function (element, container, callback) {
63
+ var $active = container.find('> .active')
64
+ var transition = callback
65
+ && $.support.transition
66
+ && $active.hasClass('fade')
67
+
68
+ function next() {
69
+ $active
70
+ .removeClass('active')
71
+ .find('> .dropdown-menu > .active')
72
+ .removeClass('active')
73
+
74
+ element.addClass('active')
75
+
76
+ if (transition) {
77
+ element[0].offsetWidth // reflow for transition
78
+ element.addClass('in')
79
+ } else {
80
+ element.removeClass('fade')
81
+ }
82
+
83
+ if (element.parent('.dropdown-menu')) {
84
+ element.closest('li.dropdown').addClass('active')
85
+ }
86
+
87
+ callback && callback()
88
+ }
89
+
90
+ transition ?
91
+ $active.one($.support.transition.end, next) :
92
+ next()
93
+
94
+ $active.removeClass('in')
95
+ }
96
+
97
+
98
+ // TAB PLUGIN DEFINITION
99
+ // =====================
100
+
101
+ var old = $.fn.tab
102
+
103
+ $.fn.tab = function ( option ) {
104
+ return this.each(function () {
105
+ var $this = $(this)
106
+ var data = $this.data('bs.tab')
107
+
108
+ if (!data) $this.data('bs.tab', (data = new Tab(this)))
109
+ if (typeof option == 'string') data[option]()
110
+ })
111
+ }
112
+
113
+ $.fn.tab.Constructor = Tab
114
+
115
+
116
+ // TAB NO CONFLICT
117
+ // ===============
118
+
119
+ $.fn.tab.noConflict = function () {
120
+ $.fn.tab = old
121
+ return this
122
+ }
123
+
124
+
125
+ // TAB DATA-API
126
+ // ============
127
+
128
+ $(document).on('click.bs.tab.data-api', '[data-toggle="tab"], [data-toggle="pill"]', function (e) {
129
+ e.preventDefault()
130
+ $(this).tab('show')
131
+ })
132
+
133
+ }(window.jQuery);
@@ -0,0 +1,356 @@
1
+ /* ========================================================================
2
+ * Bootstrap: tooltip.js v3.0.0
3
+ * http://twitter.github.com/bootstrap/javascript.html#affix
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 ($) { "use strict";
23
+
24
+ // TOOLTIP PUBLIC CLASS DEFINITION
25
+ // ===============================
26
+
27
+ var Tooltip = function (element, options) {
28
+ this.type =
29
+ this.options =
30
+ this.enabled =
31
+ this.timeout =
32
+ this.hoverState =
33
+ this.$element = null
34
+
35
+ this.init('tooltip', element, options)
36
+ }
37
+
38
+ Tooltip.DEFAULTS = {
39
+ animation: true
40
+ , placement: 'top'
41
+ , selector: false
42
+ , template: '<div class="tooltip"><div class="tooltip-arrow"></div><div class="tooltip-inner"></div></div>'
43
+ , trigger: 'hover focus'
44
+ , title: ''
45
+ , delay: 0
46
+ , html: false
47
+ , container: false
48
+ }
49
+
50
+ Tooltip.prototype.init = function (type, element, options) {
51
+ this.enabled = true
52
+ this.type = type
53
+ this.$element = $(element)
54
+ this.options = this.getOptions(options)
55
+
56
+ var triggers = this.options.trigger.split(' ')
57
+
58
+ for (var i = triggers.length; i--;) {
59
+ var trigger = triggers[i]
60
+
61
+ if (trigger == 'click') {
62
+ this.$element.on('click.' + this.type, this.options.selector, $.proxy(this.toggle, this))
63
+ } else if (trigger != 'manual') {
64
+ var eventIn = trigger == 'hover' ? 'mouseenter' : 'focus'
65
+ var eventOut = trigger == 'hover' ? 'mouseleave' : 'blur'
66
+
67
+ this.$element.on(eventIn + '.' + this.type, this.options.selector, $.proxy(this.enter, this))
68
+ this.$element.on(eventOut + '.' + this.type, this.options.selector, $.proxy(this.leave, this))
69
+ }
70
+ }
71
+
72
+ this.options.selector ?
73
+ (this._options = $.extend({}, this.options, { trigger: 'manual', selector: '' })) :
74
+ this.fixTitle()
75
+ }
76
+
77
+ Tooltip.prototype.getDefaults = function () {
78
+ return Tooltip.DEFAULTS
79
+ }
80
+
81
+ Tooltip.prototype.getOptions = function (options) {
82
+ options = $.extend({}, this.getDefaults(), this.$element.data(), options)
83
+
84
+ if (options.delay && typeof options.delay == 'number') {
85
+ options.delay = {
86
+ show: options.delay
87
+ , hide: options.delay
88
+ }
89
+ }
90
+
91
+ return options
92
+ }
93
+
94
+ Tooltip.prototype.enter = function (obj) {
95
+ var defaults = this.getDefaults()
96
+ var options = {}
97
+
98
+ this._options && $.each(this._options, function (key, value) {
99
+ if (defaults[key] != value) options[key] = value
100
+ })
101
+
102
+ var self = obj instanceof this.constructor ?
103
+ obj : $(obj.currentTarget)[this.type](options).data('bs.' + this.type)
104
+
105
+ if (!self.options.delay || !self.options.delay.show) return self.show()
106
+
107
+ clearTimeout(this.timeout)
108
+
109
+ self.hoverState = 'in'
110
+ this.timeout = setTimeout(function () {
111
+ if (self.hoverState == 'in') self.show()
112
+ }, self.options.delay.show)
113
+ }
114
+
115
+ Tooltip.prototype.leave = function (obj) {
116
+ var self = obj instanceof this.constructor ?
117
+ obj : $(obj.currentTarget)[this.type](this._options).data('bs.' + this.type)
118
+
119
+ clearTimeout(this.timeout)
120
+
121
+ if (!self.options.delay || !self.options.delay.hide) return self.hide()
122
+
123
+ self.hoverState = 'out'
124
+ this.timeout = setTimeout(function () {
125
+ if (self.hoverState == 'out') self.hide()
126
+ }, self.options.delay.hide)
127
+ }
128
+
129
+ Tooltip.prototype.show = function () {
130
+ var e = $.Event('show.bs.'+ this.type)
131
+
132
+ if (this.hasContent() && this.enabled) {
133
+ this.$element.trigger(e)
134
+
135
+ if (e.isDefaultPrevented()) return
136
+
137
+ var $tip = this.tip()
138
+
139
+ this.setContent()
140
+
141
+ if (this.options.animation) $tip.addClass('fade')
142
+
143
+ var placement = typeof this.options.placement == 'function' ?
144
+ this.options.placement.call(this, $tip[0], this.$element[0]) :
145
+ this.options.placement
146
+
147
+ $tip
148
+ .detach()
149
+ .css({ top: 0, left: 0, display: 'block' })
150
+
151
+ this.options.container ? $tip.appendTo(this.options.container) : $tip.insertAfter(this.$element)
152
+
153
+ var tp
154
+ var pos = this.getPosition()
155
+ var actualWidth = $tip[0].offsetWidth
156
+ var actualHeight = $tip[0].offsetHeight
157
+
158
+ switch (placement) {
159
+ case 'bottom':
160
+ tp = {top: pos.top + pos.height, left: pos.left + pos.width / 2 - actualWidth / 2}
161
+ break
162
+ case 'top':
163
+ tp = {top: pos.top - actualHeight, left: pos.left + pos.width / 2 - actualWidth / 2}
164
+ break
165
+ case 'left':
166
+ tp = {top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left - actualWidth}
167
+ break
168
+ case 'right':
169
+ tp = {top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left + pos.width}
170
+ break
171
+ }
172
+
173
+ this.applyPlacement(tp, placement)
174
+ this.$element.trigger('shown.bs.' + this.type)
175
+ }
176
+ }
177
+
178
+ Tooltip.prototype.applyPlacement = function(offset, placement) {
179
+ var replace
180
+ var $tip = this.tip()
181
+ var width = $tip[0].offsetWidth
182
+ var height = $tip[0].offsetHeight
183
+
184
+ $tip
185
+ .offset(offset)
186
+ .addClass(placement)
187
+ .addClass('in')
188
+
189
+ var actualWidth = $tip[0].offsetWidth
190
+ var actualHeight = $tip[0].offsetHeight
191
+
192
+ if (placement == 'top' && actualHeight != height) {
193
+ replace = true
194
+ offset.top = offset.top + height - actualHeight
195
+ }
196
+
197
+ if (placement == 'bottom' || placement == 'top') {
198
+ var delta = 0
199
+
200
+ if (offset.left < 0){
201
+ delta = offset.left * -2
202
+ offset.left = 0
203
+
204
+ $tip.offset(offset)
205
+
206
+ actualWidth = $tip[0].offsetWidth
207
+ actualHeight = $tip[0].offsetHeight
208
+ }
209
+
210
+ this.replaceArrow(delta - width + actualWidth, actualWidth, 'left')
211
+ } else {
212
+ this.replaceArrow(actualHeight - height, actualHeight, 'top')
213
+ }
214
+
215
+ if (replace) $tip.offset(offset)
216
+ }
217
+
218
+ Tooltip.prototype.replaceArrow = function(delta, dimension, position) {
219
+ this.arrow().css(position, delta ? (50 * (1 - delta / dimension) + "%") : '')
220
+ }
221
+
222
+ Tooltip.prototype.setContent = function () {
223
+ var $tip = this.tip()
224
+ var title = this.getTitle()
225
+
226
+ $tip.find('.tooltip-inner')[this.options.html ? 'html' : 'text'](title)
227
+ $tip.removeClass('fade in top bottom left right')
228
+ }
229
+
230
+ Tooltip.prototype.hide = function () {
231
+ var that = this
232
+ var $tip = this.tip()
233
+ var e = $.Event('hide.bs.' + this.type)
234
+
235
+ this.$element.trigger(e)
236
+
237
+ if (e.isDefaultPrevented()) return
238
+
239
+ $tip.removeClass('in')
240
+
241
+ function removeWithAnimation() {
242
+ var timeout = setTimeout(function () {
243
+ $tip.off($.support.transition.end).detach()
244
+ }, 500)
245
+
246
+ $tip.one($.support.transition.end, function () {
247
+ clearTimeout(timeout)
248
+ $tip.detach()
249
+ })
250
+ }
251
+
252
+ $.support.transition && this.$tip.hasClass('fade') ?
253
+ removeWithAnimation() :
254
+ $tip.detach()
255
+
256
+ this.$element.trigger('hidden.bs.' + this.type)
257
+
258
+ return this
259
+ }
260
+
261
+ Tooltip.prototype.fixTitle = function () {
262
+ var $e = this.$element
263
+ if ($e.attr('title') || typeof($e.attr('data-original-title')) != 'string') {
264
+ $e.attr('data-original-title', $e.attr('title') || '').attr('title', '')
265
+ }
266
+ }
267
+
268
+ Tooltip.prototype.hasContent = function () {
269
+ return this.getTitle()
270
+ }
271
+
272
+ Tooltip.prototype.getPosition = function () {
273
+ var el = this.$element[0]
274
+ return $.extend({}, (typeof el.getBoundingClientRect == 'function') ? el.getBoundingClientRect() : {
275
+ width: el.offsetWidth
276
+ , height: el.offsetHeight
277
+ }, this.$element.offset())
278
+ }
279
+
280
+ Tooltip.prototype.getTitle = function () {
281
+ var title
282
+ var $e = this.$element
283
+ var o = this.options
284
+
285
+ title = $e.attr('data-original-title')
286
+ || (typeof o.title == 'function' ? o.title.call($e[0]) : o.title)
287
+
288
+ return title
289
+ }
290
+
291
+ Tooltip.prototype.tip = function () {
292
+ return this.$tip = this.$tip || $(this.options.template)
293
+ }
294
+
295
+ Tooltip.prototype.arrow =function(){
296
+ return this.$arrow = this.$arrow || this.tip().find(".tooltip-arrow")
297
+ }
298
+
299
+ Tooltip.prototype.validate = function () {
300
+ if (!this.$element[0].parentNode) {
301
+ this.hide()
302
+ this.$element = null
303
+ this.options = null
304
+ }
305
+ }
306
+
307
+ Tooltip.prototype.enable = function () {
308
+ this.enabled = true
309
+ }
310
+
311
+ Tooltip.prototype.disable = function () {
312
+ this.enabled = false
313
+ }
314
+
315
+ Tooltip.prototype.toggleEnabled = function () {
316
+ this.enabled = !this.enabled
317
+ }
318
+
319
+ Tooltip.prototype.toggle = function (e) {
320
+ var self = e ? $(e.currentTarget)[this.type](this._options).data('bs.' + this.type) : this
321
+ self.tip().hasClass('in') ? self.leave(self) : self.enter(self)
322
+ }
323
+
324
+ Tooltip.prototype.destroy = function () {
325
+ this.hide().$element.off('.' + this.type).removeData('bs.' + this.type)
326
+ }
327
+
328
+
329
+ // TOOLTIP PLUGIN DEFINITION
330
+ // =========================
331
+
332
+ var old = $.fn.tooltip
333
+
334
+ $.fn.tooltip = function (option) {
335
+ return this.each(function () {
336
+ var $this = $(this)
337
+ var data = $this.data('bs.tooltip')
338
+ var options = typeof option == 'object' && option
339
+
340
+ if (!data) $this.data('bs.tooltip', (data = new Tooltip(this, options)))
341
+ if (typeof option == 'string') data[option]()
342
+ })
343
+ }
344
+
345
+ $.fn.tooltip.Constructor = Tooltip
346
+
347
+
348
+ // TOOLTIP NO CONFLICT
349
+ // ===================
350
+
351
+ $.fn.tooltip.noConflict = function () {
352
+ $.fn.tooltip = old
353
+ return this
354
+ }
355
+
356
+ }(window.jQuery);