beanstalkd_view 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,1737 +0,0 @@
1
- /* ===================================================
2
- * bootstrap-transition.js v2.0.2
3
- * http://twitter.github.com/bootstrap/javascript.html#transitions
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
- !function( $ ) {
21
-
22
- $(function () {
23
-
24
- "use strict"
25
-
26
- /* CSS TRANSITION SUPPORT (https://gist.github.com/373874)
27
- * ======================================================= */
28
-
29
- $.support.transition = (function () {
30
- var thisBody = document.body || document.documentElement
31
- , thisStyle = thisBody.style
32
- , support = thisStyle.transition !== undefined || thisStyle.WebkitTransition !== undefined || thisStyle.MozTransition !== undefined || thisStyle.MsTransition !== undefined || thisStyle.OTransition !== undefined
33
-
34
- return support && {
35
- end: (function () {
36
- var transitionEnd = "TransitionEnd"
37
- if ( $.browser.webkit ) {
38
- transitionEnd = "webkitTransitionEnd"
39
- } else if ( $.browser.mozilla ) {
40
- transitionEnd = "transitionend"
41
- } else if ( $.browser.opera ) {
42
- transitionEnd = "oTransitionEnd"
43
- }
44
- return transitionEnd
45
- }())
46
- }
47
- })()
48
-
49
- })
50
-
51
- }( window.jQuery );
52
- /* =========================================================
53
- * bootstrap-modal.js v2.0.2
54
- * http://twitter.github.com/bootstrap/javascript.html#modals
55
- * =========================================================
56
- * Copyright 2012 Twitter, Inc.
57
- *
58
- * Licensed under the Apache License, Version 2.0 (the "License");
59
- * you may not use this file except in compliance with the License.
60
- * You may obtain a copy of the License at
61
- *
62
- * http://www.apache.org/licenses/LICENSE-2.0
63
- *
64
- * Unless required by applicable law or agreed to in writing, software
65
- * distributed under the License is distributed on an "AS IS" BASIS,
66
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
67
- * See the License for the specific language governing permissions and
68
- * limitations under the License.
69
- * ========================================================= */
70
-
71
-
72
- !function( $ ){
73
-
74
- "use strict"
75
-
76
- /* MODAL CLASS DEFINITION
77
- * ====================== */
78
-
79
- var Modal = function ( content, options ) {
80
- this.options = options
81
- this.$element = $(content)
82
- .delegate('[data-dismiss="modal"]', 'click.dismiss.modal', $.proxy(this.hide, this))
83
- }
84
-
85
- Modal.prototype = {
86
-
87
- constructor: Modal
88
-
89
- , toggle: function () {
90
- return this[!this.isShown ? 'show' : 'hide']()
91
- }
92
-
93
- , show: function () {
94
- var that = this
95
-
96
- if (this.isShown) return
97
-
98
- $('body').addClass('modal-open')
99
-
100
- this.isShown = true
101
- this.$element.trigger('show')
102
-
103
- escape.call(this)
104
- backdrop.call(this, function () {
105
- var transition = $.support.transition && that.$element.hasClass('fade')
106
-
107
- !that.$element.parent().length && that.$element.appendTo(document.body) //don't move modals dom position
108
-
109
- that.$element
110
- .show()
111
-
112
- if (transition) {
113
- that.$element[0].offsetWidth // force reflow
114
- }
115
-
116
- that.$element.addClass('in')
117
-
118
- transition ?
119
- that.$element.one($.support.transition.end, function () { that.$element.trigger('shown') }) :
120
- that.$element.trigger('shown')
121
-
122
- })
123
- }
124
-
125
- , hide: function ( e ) {
126
- e && e.preventDefault()
127
-
128
- if (!this.isShown) return
129
-
130
- var that = this
131
- this.isShown = false
132
-
133
- $('body').removeClass('modal-open')
134
-
135
- escape.call(this)
136
-
137
- this.$element
138
- .trigger('hide')
139
- .removeClass('in')
140
-
141
- $.support.transition && this.$element.hasClass('fade') ?
142
- hideWithTransition.call(this) :
143
- hideModal.call(this)
144
- }
145
-
146
- }
147
-
148
-
149
- /* MODAL PRIVATE METHODS
150
- * ===================== */
151
-
152
- function hideWithTransition() {
153
- var that = this
154
- , timeout = setTimeout(function () {
155
- that.$element.off($.support.transition.end)
156
- hideModal.call(that)
157
- }, 500)
158
-
159
- this.$element.one($.support.transition.end, function () {
160
- clearTimeout(timeout)
161
- hideModal.call(that)
162
- })
163
- }
164
-
165
- function hideModal( that ) {
166
- this.$element
167
- .hide()
168
- .trigger('hidden')
169
-
170
- backdrop.call(this)
171
- }
172
-
173
- function backdrop( callback ) {
174
- var that = this
175
- , animate = this.$element.hasClass('fade') ? 'fade' : ''
176
-
177
- if (this.isShown && this.options.backdrop) {
178
- var doAnimate = $.support.transition && animate
179
-
180
- this.$backdrop = $('<div class="modal-backdrop ' + animate + '" />')
181
- .appendTo(document.body)
182
-
183
- if (this.options.backdrop != 'static') {
184
- this.$backdrop.click($.proxy(this.hide, this))
185
- }
186
-
187
- if (doAnimate) this.$backdrop[0].offsetWidth // force reflow
188
-
189
- this.$backdrop.addClass('in')
190
-
191
- doAnimate ?
192
- this.$backdrop.one($.support.transition.end, callback) :
193
- callback()
194
-
195
- } else if (!this.isShown && this.$backdrop) {
196
- this.$backdrop.removeClass('in')
197
-
198
- $.support.transition && this.$element.hasClass('fade')?
199
- this.$backdrop.one($.support.transition.end, $.proxy(removeBackdrop, this)) :
200
- removeBackdrop.call(this)
201
-
202
- } else if (callback) {
203
- callback()
204
- }
205
- }
206
-
207
- function removeBackdrop() {
208
- this.$backdrop.remove()
209
- this.$backdrop = null
210
- }
211
-
212
- function escape() {
213
- var that = this
214
- if (this.isShown && this.options.keyboard) {
215
- $(document).on('keyup.dismiss.modal', function ( e ) {
216
- e.which == 27 && that.hide()
217
- })
218
- } else if (!this.isShown) {
219
- $(document).off('keyup.dismiss.modal')
220
- }
221
- }
222
-
223
-
224
- /* MODAL PLUGIN DEFINITION
225
- * ======================= */
226
-
227
- $.fn.modal = function ( option ) {
228
- return this.each(function () {
229
- var $this = $(this)
230
- , data = $this.data('modal')
231
- , options = $.extend({}, $.fn.modal.defaults, $this.data(), typeof option == 'object' && option)
232
- if (!data) $this.data('modal', (data = new Modal(this, options)))
233
- if (typeof option == 'string') data[option]()
234
- else if (options.show) data.show()
235
- })
236
- }
237
-
238
- $.fn.modal.defaults = {
239
- backdrop: true
240
- , keyboard: true
241
- , show: true
242
- }
243
-
244
- $.fn.modal.Constructor = Modal
245
-
246
-
247
- /* MODAL DATA-API
248
- * ============== */
249
-
250
- $(function () {
251
- $('body').on('click.modal.data-api', '[data-toggle="modal"]', function ( e ) {
252
- var $this = $(this), href
253
- , $target = $($this.attr('data-target') || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '')) //strip for ie7
254
- , option = $target.data('modal') ? 'toggle' : $.extend({}, $target.data(), $this.data())
255
-
256
- e.preventDefault()
257
- $target.modal(option)
258
- })
259
- })
260
-
261
- }( window.jQuery );
262
- /* ============================================================
263
- * bootstrap-dropdown.js v2.0.2
264
- * http://twitter.github.com/bootstrap/javascript.html#dropdowns
265
- * ============================================================
266
- * Copyright 2012 Twitter, Inc.
267
- *
268
- * Licensed under the Apache License, Version 2.0 (the "License");
269
- * you may not use this file except in compliance with the License.
270
- * You may obtain a copy of the License at
271
- *
272
- * http://www.apache.org/licenses/LICENSE-2.0
273
- *
274
- * Unless required by applicable law or agreed to in writing, software
275
- * distributed under the License is distributed on an "AS IS" BASIS,
276
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
277
- * See the License for the specific language governing permissions and
278
- * limitations under the License.
279
- * ============================================================ */
280
-
281
-
282
- !function( $ ){
283
-
284
- "use strict"
285
-
286
- /* DROPDOWN CLASS DEFINITION
287
- * ========================= */
288
-
289
- var toggle = '[data-toggle="dropdown"]'
290
- , Dropdown = function ( element ) {
291
- var $el = $(element).on('click.dropdown.data-api', this.toggle)
292
- $('html').on('click.dropdown.data-api', function () {
293
- $el.parent().removeClass('open')
294
- })
295
- }
296
-
297
- Dropdown.prototype = {
298
-
299
- constructor: Dropdown
300
-
301
- , toggle: function ( e ) {
302
- var $this = $(this)
303
- , selector = $this.attr('data-target')
304
- , $parent
305
- , isActive
306
-
307
- if (!selector) {
308
- selector = $this.attr('href')
309
- selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') //strip for ie7
310
- }
311
-
312
- $parent = $(selector)
313
- $parent.length || ($parent = $this.parent())
314
-
315
- isActive = $parent.hasClass('open')
316
-
317
- clearMenus()
318
- !isActive && $parent.toggleClass('open')
319
-
320
- return false
321
- }
322
-
323
- }
324
-
325
- function clearMenus() {
326
- $(toggle).parent().removeClass('open')
327
- }
328
-
329
-
330
- /* DROPDOWN PLUGIN DEFINITION
331
- * ========================== */
332
-
333
- $.fn.dropdown = function ( option ) {
334
- return this.each(function () {
335
- var $this = $(this)
336
- , data = $this.data('dropdown')
337
- if (!data) $this.data('dropdown', (data = new Dropdown(this)))
338
- if (typeof option == 'string') data[option].call($this)
339
- })
340
- }
341
-
342
- $.fn.dropdown.Constructor = Dropdown
343
-
344
-
345
- /* APPLY TO STANDARD DROPDOWN ELEMENTS
346
- * =================================== */
347
-
348
- $(function () {
349
- $('html').on('click.dropdown.data-api', clearMenus)
350
- $('body').on('click.dropdown.data-api', toggle, Dropdown.prototype.toggle)
351
- })
352
-
353
- }( window.jQuery );
354
- /* =============================================================
355
- * bootstrap-scrollspy.js v2.0.2
356
- * http://twitter.github.com/bootstrap/javascript.html#scrollspy
357
- * =============================================================
358
- * Copyright 2012 Twitter, Inc.
359
- *
360
- * Licensed under the Apache License, Version 2.0 (the "License");
361
- * you may not use this file except in compliance with the License.
362
- * You may obtain a copy of the License at
363
- *
364
- * http://www.apache.org/licenses/LICENSE-2.0
365
- *
366
- * Unless required by applicable law or agreed to in writing, software
367
- * distributed under the License is distributed on an "AS IS" BASIS,
368
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
369
- * See the License for the specific language governing permissions and
370
- * limitations under the License.
371
- * ============================================================== */
372
-
373
- !function ( $ ) {
374
-
375
- "use strict"
376
-
377
- /* SCROLLSPY CLASS DEFINITION
378
- * ========================== */
379
-
380
- function ScrollSpy( element, options) {
381
- var process = $.proxy(this.process, this)
382
- , $element = $(element).is('body') ? $(window) : $(element)
383
- , href
384
- this.options = $.extend({}, $.fn.scrollspy.defaults, options)
385
- this.$scrollElement = $element.on('scroll.scroll.data-api', process)
386
- this.selector = (this.options.target
387
- || ((href = $(element).attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '')) //strip for ie7
388
- || '') + ' .nav li > a'
389
- this.$body = $('body').on('click.scroll.data-api', this.selector, process)
390
- this.refresh()
391
- this.process()
392
- }
393
-
394
- ScrollSpy.prototype = {
395
-
396
- constructor: ScrollSpy
397
-
398
- , refresh: function () {
399
- this.targets = this.$body
400
- .find(this.selector)
401
- .map(function () {
402
- var href = $(this).attr('href')
403
- return /^#\w/.test(href) && $(href).length ? href : null
404
- })
405
-
406
- this.offsets = $.map(this.targets, function (id) {
407
- return $(id).position().top
408
- })
409
- }
410
-
411
- , process: function () {
412
- var scrollTop = this.$scrollElement.scrollTop() + this.options.offset
413
- , offsets = this.offsets
414
- , targets = this.targets
415
- , activeTarget = this.activeTarget
416
- , i
417
-
418
- for (i = offsets.length; i--;) {
419
- activeTarget != targets[i]
420
- && scrollTop >= offsets[i]
421
- && (!offsets[i + 1] || scrollTop <= offsets[i + 1])
422
- && this.activate( targets[i] )
423
- }
424
- }
425
-
426
- , activate: function (target) {
427
- var active
428
-
429
- this.activeTarget = target
430
-
431
- this.$body
432
- .find(this.selector).parent('.active')
433
- .removeClass('active')
434
-
435
- active = this.$body
436
- .find(this.selector + '[href="' + target + '"]')
437
- .parent('li')
438
- .addClass('active')
439
-
440
- if ( active.parent('.dropdown-menu') ) {
441
- active.closest('li.dropdown').addClass('active')
442
- }
443
- }
444
-
445
- }
446
-
447
-
448
- /* SCROLLSPY PLUGIN DEFINITION
449
- * =========================== */
450
-
451
- $.fn.scrollspy = function ( option ) {
452
- return this.each(function () {
453
- var $this = $(this)
454
- , data = $this.data('scrollspy')
455
- , options = typeof option == 'object' && option
456
- if (!data) $this.data('scrollspy', (data = new ScrollSpy(this, options)))
457
- if (typeof option == 'string') data[option]()
458
- })
459
- }
460
-
461
- $.fn.scrollspy.Constructor = ScrollSpy
462
-
463
- $.fn.scrollspy.defaults = {
464
- offset: 10
465
- }
466
-
467
-
468
- /* SCROLLSPY DATA-API
469
- * ================== */
470
-
471
- $(function () {
472
- $('[data-spy="scroll"]').each(function () {
473
- var $spy = $(this)
474
- $spy.scrollspy($spy.data())
475
- })
476
- })
477
-
478
- }( window.jQuery );
479
- /* ========================================================
480
- * bootstrap-tab.js v2.0.2
481
- * http://twitter.github.com/bootstrap/javascript.html#tabs
482
- * ========================================================
483
- * Copyright 2012 Twitter, Inc.
484
- *
485
- * Licensed under the Apache License, Version 2.0 (the "License");
486
- * you may not use this file except in compliance with the License.
487
- * You may obtain a copy of the License at
488
- *
489
- * http://www.apache.org/licenses/LICENSE-2.0
490
- *
491
- * Unless required by applicable law or agreed to in writing, software
492
- * distributed under the License is distributed on an "AS IS" BASIS,
493
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
494
- * See the License for the specific language governing permissions and
495
- * limitations under the License.
496
- * ======================================================== */
497
-
498
-
499
- !function( $ ){
500
-
501
- "use strict"
502
-
503
- /* TAB CLASS DEFINITION
504
- * ==================== */
505
-
506
- var Tab = function ( element ) {
507
- this.element = $(element)
508
- }
509
-
510
- Tab.prototype = {
511
-
512
- constructor: Tab
513
-
514
- , show: function () {
515
- var $this = this.element
516
- , $ul = $this.closest('ul:not(.dropdown-menu)')
517
- , selector = $this.attr('data-target')
518
- , previous
519
- , $target
520
-
521
- if (!selector) {
522
- selector = $this.attr('href')
523
- selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') //strip for ie7
524
- }
525
-
526
- if ( $this.parent('li').hasClass('active') ) return
527
-
528
- previous = $ul.find('.active a').last()[0]
529
-
530
- $this.trigger({
531
- type: 'show'
532
- , relatedTarget: previous
533
- })
534
-
535
- $target = $(selector)
536
-
537
- this.activate($this.parent('li'), $ul)
538
- this.activate($target, $target.parent(), function () {
539
- $this.trigger({
540
- type: 'shown'
541
- , relatedTarget: previous
542
- })
543
- })
544
- }
545
-
546
- , activate: function ( element, container, callback) {
547
- var $active = container.find('> .active')
548
- , transition = callback
549
- && $.support.transition
550
- && $active.hasClass('fade')
551
-
552
- function next() {
553
- $active
554
- .removeClass('active')
555
- .find('> .dropdown-menu > .active')
556
- .removeClass('active')
557
-
558
- element.addClass('active')
559
-
560
- if (transition) {
561
- element[0].offsetWidth // reflow for transition
562
- element.addClass('in')
563
- } else {
564
- element.removeClass('fade')
565
- }
566
-
567
- if ( element.parent('.dropdown-menu') ) {
568
- element.closest('li.dropdown').addClass('active')
569
- }
570
-
571
- callback && callback()
572
- }
573
-
574
- transition ?
575
- $active.one($.support.transition.end, next) :
576
- next()
577
-
578
- $active.removeClass('in')
579
- }
580
- }
581
-
582
-
583
- /* TAB PLUGIN DEFINITION
584
- * ===================== */
585
-
586
- $.fn.tab = function ( option ) {
587
- return this.each(function () {
588
- var $this = $(this)
589
- , data = $this.data('tab')
590
- if (!data) $this.data('tab', (data = new Tab(this)))
591
- if (typeof option == 'string') data[option]()
592
- })
593
- }
594
-
595
- $.fn.tab.Constructor = Tab
596
-
597
-
598
- /* TAB DATA-API
599
- * ============ */
600
-
601
- $(function () {
602
- $('body').on('click.tab.data-api', '[data-toggle="tab"], [data-toggle="pill"]', function (e) {
603
- e.preventDefault()
604
- $(this).tab('show')
605
- })
606
- })
607
-
608
- }( window.jQuery );
609
- /* ===========================================================
610
- * bootstrap-tooltip.js v2.0.2
611
- * http://twitter.github.com/bootstrap/javascript.html#tooltips
612
- * Inspired by the original jQuery.tipsy by Jason Frame
613
- * ===========================================================
614
- * Copyright 2012 Twitter, Inc.
615
- *
616
- * Licensed under the Apache License, Version 2.0 (the "License");
617
- * you may not use this file except in compliance with the License.
618
- * You may obtain a copy of the License at
619
- *
620
- * http://www.apache.org/licenses/LICENSE-2.0
621
- *
622
- * Unless required by applicable law or agreed to in writing, software
623
- * distributed under the License is distributed on an "AS IS" BASIS,
624
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
625
- * See the License for the specific language governing permissions and
626
- * limitations under the License.
627
- * ========================================================== */
628
-
629
- !function( $ ) {
630
-
631
- "use strict"
632
-
633
- /* TOOLTIP PUBLIC CLASS DEFINITION
634
- * =============================== */
635
-
636
- var Tooltip = function ( element, options ) {
637
- this.init('tooltip', element, options)
638
- }
639
-
640
- Tooltip.prototype = {
641
-
642
- constructor: Tooltip
643
-
644
- , init: function ( type, element, options ) {
645
- var eventIn
646
- , eventOut
647
-
648
- this.type = type
649
- this.$element = $(element)
650
- this.options = this.getOptions(options)
651
- this.enabled = true
652
-
653
- if (this.options.trigger != 'manual') {
654
- eventIn = this.options.trigger == 'hover' ? 'mouseenter' : 'focus'
655
- eventOut = this.options.trigger == 'hover' ? 'mouseleave' : 'blur'
656
- this.$element.on(eventIn, this.options.selector, $.proxy(this.enter, this))
657
- this.$element.on(eventOut, this.options.selector, $.proxy(this.leave, this))
658
- }
659
-
660
- this.options.selector ?
661
- (this._options = $.extend({}, this.options, { trigger: 'manual', selector: '' })) :
662
- this.fixTitle()
663
- }
664
-
665
- , getOptions: function ( options ) {
666
- options = $.extend({}, $.fn[this.type].defaults, options, this.$element.data())
667
-
668
- if (options.delay && typeof options.delay == 'number') {
669
- options.delay = {
670
- show: options.delay
671
- , hide: options.delay
672
- }
673
- }
674
-
675
- return options
676
- }
677
-
678
- , enter: function ( e ) {
679
- var self = $(e.currentTarget)[this.type](this._options).data(this.type)
680
-
681
- if (!self.options.delay || !self.options.delay.show) {
682
- self.show()
683
- } else {
684
- self.hoverState = 'in'
685
- setTimeout(function() {
686
- if (self.hoverState == 'in') {
687
- self.show()
688
- }
689
- }, self.options.delay.show)
690
- }
691
- }
692
-
693
- , leave: function ( e ) {
694
- var self = $(e.currentTarget)[this.type](this._options).data(this.type)
695
-
696
- if (!self.options.delay || !self.options.delay.hide) {
697
- self.hide()
698
- } else {
699
- self.hoverState = 'out'
700
- setTimeout(function() {
701
- if (self.hoverState == 'out') {
702
- self.hide()
703
- }
704
- }, self.options.delay.hide)
705
- }
706
- }
707
-
708
- , show: function () {
709
- var $tip
710
- , inside
711
- , pos
712
- , actualWidth
713
- , actualHeight
714
- , placement
715
- , tp
716
-
717
- if (this.hasContent() && this.enabled) {
718
- $tip = this.tip()
719
- this.setContent()
720
-
721
- if (this.options.animation) {
722
- $tip.addClass('fade')
723
- }
724
-
725
- placement = typeof this.options.placement == 'function' ?
726
- this.options.placement.call(this, $tip[0], this.$element[0]) :
727
- this.options.placement
728
-
729
- inside = /in/.test(placement)
730
-
731
- $tip
732
- .remove()
733
- .css({ top: 0, left: 0, display: 'block' })
734
- .appendTo(inside ? this.$element : document.body)
735
-
736
- pos = this.getPosition(inside)
737
-
738
- actualWidth = $tip[0].offsetWidth
739
- actualHeight = $tip[0].offsetHeight
740
-
741
- switch (inside ? placement.split(' ')[1] : placement) {
742
- case 'bottom':
743
- tp = {top: pos.top + pos.height, left: pos.left + pos.width / 2 - actualWidth / 2}
744
- break
745
- case 'top':
746
- tp = {top: pos.top - actualHeight, left: pos.left + pos.width / 2 - actualWidth / 2}
747
- break
748
- case 'left':
749
- tp = {top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left - actualWidth}
750
- break
751
- case 'right':
752
- tp = {top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left + pos.width}
753
- break
754
- }
755
-
756
- $tip
757
- .css(tp)
758
- .addClass(placement)
759
- .addClass('in')
760
- }
761
- }
762
-
763
- , setContent: function () {
764
- var $tip = this.tip()
765
- $tip.find('.tooltip-inner').html(this.getTitle())
766
- $tip.removeClass('fade in top bottom left right')
767
- }
768
-
769
- , hide: function () {
770
- var that = this
771
- , $tip = this.tip()
772
-
773
- $tip.removeClass('in')
774
-
775
- function removeWithAnimation() {
776
- var timeout = setTimeout(function () {
777
- $tip.off($.support.transition.end).remove()
778
- }, 500)
779
-
780
- $tip.one($.support.transition.end, function () {
781
- clearTimeout(timeout)
782
- $tip.remove()
783
- })
784
- }
785
-
786
- $.support.transition && this.$tip.hasClass('fade') ?
787
- removeWithAnimation() :
788
- $tip.remove()
789
- }
790
-
791
- , fixTitle: function () {
792
- var $e = this.$element
793
- if ($e.attr('title') || typeof($e.attr('data-original-title')) != 'string') {
794
- $e.attr('data-original-title', $e.attr('title') || '').removeAttr('title')
795
- }
796
- }
797
-
798
- , hasContent: function () {
799
- return this.getTitle()
800
- }
801
-
802
- , getPosition: function (inside) {
803
- return $.extend({}, (inside ? {top: 0, left: 0} : this.$element.offset()), {
804
- width: this.$element[0].offsetWidth
805
- , height: this.$element[0].offsetHeight
806
- })
807
- }
808
-
809
- , getTitle: function () {
810
- var title
811
- , $e = this.$element
812
- , o = this.options
813
-
814
- title = $e.attr('data-original-title')
815
- || (typeof o.title == 'function' ? o.title.call($e[0]) : o.title)
816
-
817
- title = (title || '').toString().replace(/(^\s*|\s*$)/, "")
818
-
819
- return title
820
- }
821
-
822
- , tip: function () {
823
- return this.$tip = this.$tip || $(this.options.template)
824
- }
825
-
826
- , validate: function () {
827
- if (!this.$element[0].parentNode) {
828
- this.hide()
829
- this.$element = null
830
- this.options = null
831
- }
832
- }
833
-
834
- , enable: function () {
835
- this.enabled = true
836
- }
837
-
838
- , disable: function () {
839
- this.enabled = false
840
- }
841
-
842
- , toggleEnabled: function () {
843
- this.enabled = !this.enabled
844
- }
845
-
846
- , toggle: function () {
847
- this[this.tip().hasClass('in') ? 'hide' : 'show']()
848
- }
849
-
850
- }
851
-
852
-
853
- /* TOOLTIP PLUGIN DEFINITION
854
- * ========================= */
855
-
856
- $.fn.tooltip = function ( option ) {
857
- return this.each(function () {
858
- var $this = $(this)
859
- , data = $this.data('tooltip')
860
- , options = typeof option == 'object' && option
861
- if (!data) $this.data('tooltip', (data = new Tooltip(this, options)))
862
- if (typeof option == 'string') data[option]()
863
- })
864
- }
865
-
866
- $.fn.tooltip.Constructor = Tooltip
867
-
868
- $.fn.tooltip.defaults = {
869
- animation: true
870
- , delay: 0
871
- , selector: false
872
- , placement: 'top'
873
- , trigger: 'hover'
874
- , title: ''
875
- , template: '<div class="tooltip"><div class="tooltip-arrow"></div><div class="tooltip-inner"></div></div>'
876
- }
877
-
878
- }( window.jQuery );
879
- /* ===========================================================
880
- * bootstrap-popover.js v2.0.2
881
- * http://twitter.github.com/bootstrap/javascript.html#popovers
882
- * ===========================================================
883
- * Copyright 2012 Twitter, Inc.
884
- *
885
- * Licensed under the Apache License, Version 2.0 (the "License");
886
- * you may not use this file except in compliance with the License.
887
- * You may obtain a copy of the License at
888
- *
889
- * http://www.apache.org/licenses/LICENSE-2.0
890
- *
891
- * Unless required by applicable law or agreed to in writing, software
892
- * distributed under the License is distributed on an "AS IS" BASIS,
893
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
894
- * See the License for the specific language governing permissions and
895
- * limitations under the License.
896
- * =========================================================== */
897
-
898
-
899
- !function( $ ) {
900
-
901
- "use strict"
902
-
903
- var Popover = function ( element, options ) {
904
- this.init('popover', element, options)
905
- }
906
-
907
- /* NOTE: POPOVER EXTENDS BOOTSTRAP-TOOLTIP.js
908
- ========================================== */
909
-
910
- Popover.prototype = $.extend({}, $.fn.tooltip.Constructor.prototype, {
911
-
912
- constructor: Popover
913
-
914
- , setContent: function () {
915
- var $tip = this.tip()
916
- , title = this.getTitle()
917
- , content = this.getContent()
918
-
919
- $tip.find('.popover-title')[ $.type(title) == 'object' ? 'append' : 'html' ](title)
920
- $tip.find('.popover-content > *')[ $.type(content) == 'object' ? 'append' : 'html' ](content)
921
-
922
- $tip.removeClass('fade top bottom left right in')
923
- }
924
-
925
- , hasContent: function () {
926
- return this.getTitle() || this.getContent()
927
- }
928
-
929
- , getContent: function () {
930
- var content
931
- , $e = this.$element
932
- , o = this.options
933
-
934
- content = $e.attr('data-content')
935
- || (typeof o.content == 'function' ? o.content.call($e[0]) : o.content)
936
-
937
- content = content.toString().replace(/(^\s*|\s*$)/, "")
938
-
939
- return content
940
- }
941
-
942
- , tip: function() {
943
- if (!this.$tip) {
944
- this.$tip = $(this.options.template)
945
- }
946
- return this.$tip
947
- }
948
-
949
- })
950
-
951
-
952
- /* POPOVER PLUGIN DEFINITION
953
- * ======================= */
954
-
955
- $.fn.popover = function ( option ) {
956
- return this.each(function () {
957
- var $this = $(this)
958
- , data = $this.data('popover')
959
- , options = typeof option == 'object' && option
960
- if (!data) $this.data('popover', (data = new Popover(this, options)))
961
- if (typeof option == 'string') data[option]()
962
- })
963
- }
964
-
965
- $.fn.popover.Constructor = Popover
966
-
967
- $.fn.popover.defaults = $.extend({} , $.fn.tooltip.defaults, {
968
- placement: 'right'
969
- , content: ''
970
- , template: '<div class="popover"><div class="arrow"></div><div class="popover-inner"><h3 class="popover-title"></h3><div class="popover-content"><p></p></div></div></div>'
971
- })
972
-
973
- }( window.jQuery );
974
- /* ==========================================================
975
- * bootstrap-alert.js v2.0.2
976
- * http://twitter.github.com/bootstrap/javascript.html#alerts
977
- * ==========================================================
978
- * Copyright 2012 Twitter, Inc.
979
- *
980
- * Licensed under the Apache License, Version 2.0 (the "License");
981
- * you may not use this file except in compliance with the License.
982
- * You may obtain a copy of the License at
983
- *
984
- * http://www.apache.org/licenses/LICENSE-2.0
985
- *
986
- * Unless required by applicable law or agreed to in writing, software
987
- * distributed under the License is distributed on an "AS IS" BASIS,
988
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
989
- * See the License for the specific language governing permissions and
990
- * limitations under the License.
991
- * ========================================================== */
992
-
993
-
994
- !function( $ ){
995
-
996
- "use strict"
997
-
998
- /* ALERT CLASS DEFINITION
999
- * ====================== */
1000
-
1001
- var dismiss = '[data-dismiss="alert"]'
1002
- , Alert = function ( el ) {
1003
- $(el).on('click', dismiss, this.close)
1004
- }
1005
-
1006
- Alert.prototype = {
1007
-
1008
- constructor: Alert
1009
-
1010
- , close: function ( e ) {
1011
- var $this = $(this)
1012
- , selector = $this.attr('data-target')
1013
- , $parent
1014
-
1015
- if (!selector) {
1016
- selector = $this.attr('href')
1017
- selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') //strip for ie7
1018
- }
1019
-
1020
- $parent = $(selector)
1021
- $parent.trigger('close')
1022
-
1023
- e && e.preventDefault()
1024
-
1025
- $parent.length || ($parent = $this.hasClass('alert') ? $this : $this.parent())
1026
-
1027
- $parent
1028
- .trigger('close')
1029
- .removeClass('in')
1030
-
1031
- function removeElement() {
1032
- $parent
1033
- .trigger('closed')
1034
- .remove()
1035
- }
1036
-
1037
- $.support.transition && $parent.hasClass('fade') ?
1038
- $parent.on($.support.transition.end, removeElement) :
1039
- removeElement()
1040
- }
1041
-
1042
- }
1043
-
1044
-
1045
- /* ALERT PLUGIN DEFINITION
1046
- * ======================= */
1047
-
1048
- $.fn.alert = function ( option ) {
1049
- return this.each(function () {
1050
- var $this = $(this)
1051
- , data = $this.data('alert')
1052
- if (!data) $this.data('alert', (data = new Alert(this)))
1053
- if (typeof option == 'string') data[option].call($this)
1054
- })
1055
- }
1056
-
1057
- $.fn.alert.Constructor = Alert
1058
-
1059
-
1060
- /* ALERT DATA-API
1061
- * ============== */
1062
-
1063
- $(function () {
1064
- $('body').on('click.alert.data-api', dismiss, Alert.prototype.close)
1065
- })
1066
-
1067
- }( window.jQuery );
1068
- /* ============================================================
1069
- * bootstrap-button.js v2.0.2
1070
- * http://twitter.github.com/bootstrap/javascript.html#buttons
1071
- * ============================================================
1072
- * Copyright 2012 Twitter, Inc.
1073
- *
1074
- * Licensed under the Apache License, Version 2.0 (the "License");
1075
- * you may not use this file except in compliance with the License.
1076
- * You may obtain a copy of the License at
1077
- *
1078
- * http://www.apache.org/licenses/LICENSE-2.0
1079
- *
1080
- * Unless required by applicable law or agreed to in writing, software
1081
- * distributed under the License is distributed on an "AS IS" BASIS,
1082
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1083
- * See the License for the specific language governing permissions and
1084
- * limitations under the License.
1085
- * ============================================================ */
1086
-
1087
- !function( $ ){
1088
-
1089
- "use strict"
1090
-
1091
- /* BUTTON PUBLIC CLASS DEFINITION
1092
- * ============================== */
1093
-
1094
- var Button = function ( element, options ) {
1095
- this.$element = $(element)
1096
- this.options = $.extend({}, $.fn.button.defaults, options)
1097
- }
1098
-
1099
- Button.prototype = {
1100
-
1101
- constructor: Button
1102
-
1103
- , setState: function ( state ) {
1104
- var d = 'disabled'
1105
- , $el = this.$element
1106
- , data = $el.data()
1107
- , val = $el.is('input') ? 'val' : 'html'
1108
-
1109
- state = state + 'Text'
1110
- data.resetText || $el.data('resetText', $el[val]())
1111
-
1112
- $el[val](data[state] || this.options[state])
1113
-
1114
- // push to event loop to allow forms to submit
1115
- setTimeout(function () {
1116
- state == 'loadingText' ?
1117
- $el.addClass(d).attr(d, d) :
1118
- $el.removeClass(d).removeAttr(d)
1119
- }, 0)
1120
- }
1121
-
1122
- , toggle: function () {
1123
- var $parent = this.$element.parent('[data-toggle="buttons-radio"]')
1124
-
1125
- $parent && $parent
1126
- .find('.active')
1127
- .removeClass('active')
1128
-
1129
- this.$element.toggleClass('active')
1130
- }
1131
-
1132
- }
1133
-
1134
-
1135
- /* BUTTON PLUGIN DEFINITION
1136
- * ======================== */
1137
-
1138
- $.fn.button = function ( option ) {
1139
- return this.each(function () {
1140
- var $this = $(this)
1141
- , data = $this.data('button')
1142
- , options = typeof option == 'object' && option
1143
- if (!data) $this.data('button', (data = new Button(this, options)))
1144
- if (option == 'toggle') data.toggle()
1145
- else if (option) data.setState(option)
1146
- })
1147
- }
1148
-
1149
- $.fn.button.defaults = {
1150
- loadingText: 'loading...'
1151
- }
1152
-
1153
- $.fn.button.Constructor = Button
1154
-
1155
-
1156
- /* BUTTON DATA-API
1157
- * =============== */
1158
-
1159
- $(function () {
1160
- $('body').on('click.button.data-api', '[data-toggle^=button]', function ( e ) {
1161
- var $btn = $(e.target)
1162
- if (!$btn.hasClass('btn')) $btn = $btn.closest('.btn')
1163
- $btn.button('toggle')
1164
- })
1165
- })
1166
-
1167
- }( window.jQuery );
1168
- /* =============================================================
1169
- * bootstrap-collapse.js v2.0.2
1170
- * http://twitter.github.com/bootstrap/javascript.html#collapse
1171
- * =============================================================
1172
- * Copyright 2012 Twitter, Inc.
1173
- *
1174
- * Licensed under the Apache License, Version 2.0 (the "License");
1175
- * you may not use this file except in compliance with the License.
1176
- * You may obtain a copy of the License at
1177
- *
1178
- * http://www.apache.org/licenses/LICENSE-2.0
1179
- *
1180
- * Unless required by applicable law or agreed to in writing, software
1181
- * distributed under the License is distributed on an "AS IS" BASIS,
1182
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1183
- * See the License for the specific language governing permissions and
1184
- * limitations under the License.
1185
- * ============================================================ */
1186
-
1187
- !function( $ ){
1188
-
1189
- "use strict"
1190
-
1191
- var Collapse = function ( element, options ) {
1192
- this.$element = $(element)
1193
- this.options = $.extend({}, $.fn.collapse.defaults, options)
1194
-
1195
- if (this.options["parent"]) {
1196
- this.$parent = $(this.options["parent"])
1197
- }
1198
-
1199
- this.options.toggle && this.toggle()
1200
- }
1201
-
1202
- Collapse.prototype = {
1203
-
1204
- constructor: Collapse
1205
-
1206
- , dimension: function () {
1207
- var hasWidth = this.$element.hasClass('width')
1208
- return hasWidth ? 'width' : 'height'
1209
- }
1210
-
1211
- , show: function () {
1212
- var dimension = this.dimension()
1213
- , scroll = $.camelCase(['scroll', dimension].join('-'))
1214
- , actives = this.$parent && this.$parent.find('.in')
1215
- , hasData
1216
-
1217
- if (actives && actives.length) {
1218
- hasData = actives.data('collapse')
1219
- actives.collapse('hide')
1220
- hasData || actives.data('collapse', null)
1221
- }
1222
-
1223
- this.$element[dimension](0)
1224
- this.transition('addClass', 'show', 'shown')
1225
- this.$element[dimension](this.$element[0][scroll])
1226
-
1227
- }
1228
-
1229
- , hide: function () {
1230
- var dimension = this.dimension()
1231
- this.reset(this.$element[dimension]())
1232
- this.transition('removeClass', 'hide', 'hidden')
1233
- this.$element[dimension](0)
1234
- }
1235
-
1236
- , reset: function ( size ) {
1237
- var dimension = this.dimension()
1238
-
1239
- this.$element
1240
- .removeClass('collapse')
1241
- [dimension](size || 'auto')
1242
- [0].offsetWidth
1243
-
1244
- this.$element[size ? 'addClass' : 'removeClass']('collapse')
1245
-
1246
- return this
1247
- }
1248
-
1249
- , transition: function ( method, startEvent, completeEvent ) {
1250
- var that = this
1251
- , complete = function () {
1252
- if (startEvent == 'show') that.reset()
1253
- that.$element.trigger(completeEvent)
1254
- }
1255
-
1256
- this.$element
1257
- .trigger(startEvent)
1258
- [method]('in')
1259
-
1260
- $.support.transition && this.$element.hasClass('collapse') ?
1261
- this.$element.one($.support.transition.end, complete) :
1262
- complete()
1263
- }
1264
-
1265
- , toggle: function () {
1266
- this[this.$element.hasClass('in') ? 'hide' : 'show']()
1267
- }
1268
-
1269
- }
1270
-
1271
- /* COLLAPSIBLE PLUGIN DEFINITION
1272
- * ============================== */
1273
-
1274
- $.fn.collapse = function ( option ) {
1275
- return this.each(function () {
1276
- var $this = $(this)
1277
- , data = $this.data('collapse')
1278
- , options = typeof option == 'object' && option
1279
- if (!data) $this.data('collapse', (data = new Collapse(this, options)))
1280
- if (typeof option == 'string') data[option]()
1281
- })
1282
- }
1283
-
1284
- $.fn.collapse.defaults = {
1285
- toggle: true
1286
- }
1287
-
1288
- $.fn.collapse.Constructor = Collapse
1289
-
1290
-
1291
- /* COLLAPSIBLE DATA-API
1292
- * ==================== */
1293
-
1294
- $(function () {
1295
- $('body').on('click.collapse.data-api', '[data-toggle=collapse]', function ( e ) {
1296
- var $this = $(this), href
1297
- , target = $this.attr('data-target')
1298
- || e.preventDefault()
1299
- || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '') //strip for ie7
1300
- , option = $(target).data('collapse') ? 'toggle' : $this.data()
1301
- $(target).collapse(option)
1302
- })
1303
- })
1304
-
1305
- }( window.jQuery );
1306
- /* ==========================================================
1307
- * bootstrap-carousel.js v2.0.2
1308
- * http://twitter.github.com/bootstrap/javascript.html#carousel
1309
- * ==========================================================
1310
- * Copyright 2012 Twitter, Inc.
1311
- *
1312
- * Licensed under the Apache License, Version 2.0 (the "License");
1313
- * you may not use this file except in compliance with the License.
1314
- * You may obtain a copy of the License at
1315
- *
1316
- * http://www.apache.org/licenses/LICENSE-2.0
1317
- *
1318
- * Unless required by applicable law or agreed to in writing, software
1319
- * distributed under the License is distributed on an "AS IS" BASIS,
1320
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1321
- * See the License for the specific language governing permissions and
1322
- * limitations under the License.
1323
- * ========================================================== */
1324
-
1325
-
1326
- !function( $ ){
1327
-
1328
- "use strict"
1329
-
1330
- /* CAROUSEL CLASS DEFINITION
1331
- * ========================= */
1332
-
1333
- var Carousel = function (element, options) {
1334
- this.$element = $(element)
1335
- this.options = $.extend({}, $.fn.carousel.defaults, options)
1336
- this.options.slide && this.slide(this.options.slide)
1337
- this.options.pause == 'hover' && this.$element
1338
- .on('mouseenter', $.proxy(this.pause, this))
1339
- .on('mouseleave', $.proxy(this.cycle, this))
1340
- }
1341
-
1342
- Carousel.prototype = {
1343
-
1344
- cycle: function () {
1345
- this.interval = setInterval($.proxy(this.next, this), this.options.interval)
1346
- return this
1347
- }
1348
-
1349
- , to: function (pos) {
1350
- var $active = this.$element.find('.active')
1351
- , children = $active.parent().children()
1352
- , activePos = children.index($active)
1353
- , that = this
1354
-
1355
- if (pos > (children.length - 1) || pos < 0) return
1356
-
1357
- if (this.sliding) {
1358
- return this.$element.one('slid', function () {
1359
- that.to(pos)
1360
- })
1361
- }
1362
-
1363
- if (activePos == pos) {
1364
- return this.pause().cycle()
1365
- }
1366
-
1367
- return this.slide(pos > activePos ? 'next' : 'prev', $(children[pos]))
1368
- }
1369
-
1370
- , pause: function () {
1371
- clearInterval(this.interval)
1372
- this.interval = null
1373
- return this
1374
- }
1375
-
1376
- , next: function () {
1377
- if (this.sliding) return
1378
- return this.slide('next')
1379
- }
1380
-
1381
- , prev: function () {
1382
- if (this.sliding) return
1383
- return this.slide('prev')
1384
- }
1385
-
1386
- , slide: function (type, next) {
1387
- var $active = this.$element.find('.active')
1388
- , $next = next || $active[type]()
1389
- , isCycling = this.interval
1390
- , direction = type == 'next' ? 'left' : 'right'
1391
- , fallback = type == 'next' ? 'first' : 'last'
1392
- , that = this
1393
-
1394
- this.sliding = true
1395
-
1396
- isCycling && this.pause()
1397
-
1398
- $next = $next.length ? $next : this.$element.find('.item')[fallback]()
1399
-
1400
- if ($next.hasClass('active')) return
1401
-
1402
- if (!$.support.transition && this.$element.hasClass('slide')) {
1403
- this.$element.trigger('slide')
1404
- $active.removeClass('active')
1405
- $next.addClass('active')
1406
- this.sliding = false
1407
- this.$element.trigger('slid')
1408
- } else {
1409
- $next.addClass(type)
1410
- $next[0].offsetWidth // force reflow
1411
- $active.addClass(direction)
1412
- $next.addClass(direction)
1413
- this.$element.trigger('slide')
1414
- this.$element.one($.support.transition.end, function () {
1415
- $next.removeClass([type, direction].join(' ')).addClass('active')
1416
- $active.removeClass(['active', direction].join(' '))
1417
- that.sliding = false
1418
- setTimeout(function () { that.$element.trigger('slid') }, 0)
1419
- })
1420
- }
1421
-
1422
- isCycling && this.cycle()
1423
-
1424
- return this
1425
- }
1426
-
1427
- }
1428
-
1429
-
1430
- /* CAROUSEL PLUGIN DEFINITION
1431
- * ========================== */
1432
-
1433
- $.fn.carousel = function ( option ) {
1434
- return this.each(function () {
1435
- var $this = $(this)
1436
- , data = $this.data('carousel')
1437
- , options = typeof option == 'object' && option
1438
- if (!data) $this.data('carousel', (data = new Carousel(this, options)))
1439
- if (typeof option == 'number') data.to(option)
1440
- else if (typeof option == 'string' || (option = options.slide)) data[option]()
1441
- else data.cycle()
1442
- })
1443
- }
1444
-
1445
- $.fn.carousel.defaults = {
1446
- interval: 5000
1447
- , pause: 'hover'
1448
- }
1449
-
1450
- $.fn.carousel.Constructor = Carousel
1451
-
1452
-
1453
- /* CAROUSEL DATA-API
1454
- * ================= */
1455
-
1456
- $(function () {
1457
- $('body').on('click.carousel.data-api', '[data-slide]', function ( e ) {
1458
- var $this = $(this), href
1459
- , $target = $($this.attr('data-target') || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '')) //strip for ie7
1460
- , options = !$target.data('modal') && $.extend({}, $target.data(), $this.data())
1461
- $target.carousel(options)
1462
- e.preventDefault()
1463
- })
1464
- })
1465
-
1466
- }( window.jQuery );
1467
- /* =============================================================
1468
- * bootstrap-typeahead.js v2.0.2
1469
- * http://twitter.github.com/bootstrap/javascript.html#typeahead
1470
- * =============================================================
1471
- * Copyright 2012 Twitter, Inc.
1472
- *
1473
- * Licensed under the Apache License, Version 2.0 (the "License");
1474
- * you may not use this file except in compliance with the License.
1475
- * You may obtain a copy of the License at
1476
- *
1477
- * http://www.apache.org/licenses/LICENSE-2.0
1478
- *
1479
- * Unless required by applicable law or agreed to in writing, software
1480
- * distributed under the License is distributed on an "AS IS" BASIS,
1481
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1482
- * See the License for the specific language governing permissions and
1483
- * limitations under the License.
1484
- * ============================================================ */
1485
-
1486
- !function( $ ){
1487
-
1488
- "use strict"
1489
-
1490
- var Typeahead = function ( element, options ) {
1491
- this.$element = $(element)
1492
- this.options = $.extend({}, $.fn.typeahead.defaults, options)
1493
- this.matcher = this.options.matcher || this.matcher
1494
- this.sorter = this.options.sorter || this.sorter
1495
- this.highlighter = this.options.highlighter || this.highlighter
1496
- this.$menu = $(this.options.menu).appendTo('body')
1497
- this.source = this.options.source
1498
- this.shown = false
1499
- this.listen()
1500
- }
1501
-
1502
- Typeahead.prototype = {
1503
-
1504
- constructor: Typeahead
1505
-
1506
- , select: function () {
1507
- var val = this.$menu.find('.active').attr('data-value')
1508
- this.$element.val(val)
1509
- this.$element.change();
1510
- return this.hide()
1511
- }
1512
-
1513
- , show: function () {
1514
- var pos = $.extend({}, this.$element.offset(), {
1515
- height: this.$element[0].offsetHeight
1516
- })
1517
-
1518
- this.$menu.css({
1519
- top: pos.top + pos.height
1520
- , left: pos.left
1521
- })
1522
-
1523
- this.$menu.show()
1524
- this.shown = true
1525
- return this
1526
- }
1527
-
1528
- , hide: function () {
1529
- this.$menu.hide()
1530
- this.shown = false
1531
- return this
1532
- }
1533
-
1534
- , lookup: function (event) {
1535
- var that = this
1536
- , items
1537
- , q
1538
-
1539
- this.query = this.$element.val()
1540
-
1541
- if (!this.query) {
1542
- return this.shown ? this.hide() : this
1543
- }
1544
-
1545
- items = $.grep(this.source, function (item) {
1546
- if (that.matcher(item)) return item
1547
- })
1548
-
1549
- items = this.sorter(items)
1550
-
1551
- if (!items.length) {
1552
- return this.shown ? this.hide() : this
1553
- }
1554
-
1555
- return this.render(items.slice(0, this.options.items)).show()
1556
- }
1557
-
1558
- , matcher: function (item) {
1559
- return ~item.toLowerCase().indexOf(this.query.toLowerCase())
1560
- }
1561
-
1562
- , sorter: function (items) {
1563
- var beginswith = []
1564
- , caseSensitive = []
1565
- , caseInsensitive = []
1566
- , item
1567
-
1568
- while (item = items.shift()) {
1569
- if (!item.toLowerCase().indexOf(this.query.toLowerCase())) beginswith.push(item)
1570
- else if (~item.indexOf(this.query)) caseSensitive.push(item)
1571
- else caseInsensitive.push(item)
1572
- }
1573
-
1574
- return beginswith.concat(caseSensitive, caseInsensitive)
1575
- }
1576
-
1577
- , highlighter: function (item) {
1578
- return item.replace(new RegExp('(' + this.query + ')', 'ig'), function ($1, match) {
1579
- return '<strong>' + match + '</strong>'
1580
- })
1581
- }
1582
-
1583
- , render: function (items) {
1584
- var that = this
1585
-
1586
- items = $(items).map(function (i, item) {
1587
- i = $(that.options.item).attr('data-value', item)
1588
- i.find('a').html(that.highlighter(item))
1589
- return i[0]
1590
- })
1591
-
1592
- items.first().addClass('active')
1593
- this.$menu.html(items)
1594
- return this
1595
- }
1596
-
1597
- , next: function (event) {
1598
- var active = this.$menu.find('.active').removeClass('active')
1599
- , next = active.next()
1600
-
1601
- if (!next.length) {
1602
- next = $(this.$menu.find('li')[0])
1603
- }
1604
-
1605
- next.addClass('active')
1606
- }
1607
-
1608
- , prev: function (event) {
1609
- var active = this.$menu.find('.active').removeClass('active')
1610
- , prev = active.prev()
1611
-
1612
- if (!prev.length) {
1613
- prev = this.$menu.find('li').last()
1614
- }
1615
-
1616
- prev.addClass('active')
1617
- }
1618
-
1619
- , listen: function () {
1620
- this.$element
1621
- .on('blur', $.proxy(this.blur, this))
1622
- .on('keypress', $.proxy(this.keypress, this))
1623
- .on('keyup', $.proxy(this.keyup, this))
1624
-
1625
- if ($.browser.webkit || $.browser.msie) {
1626
- this.$element.on('keydown', $.proxy(this.keypress, this))
1627
- }
1628
-
1629
- this.$menu
1630
- .on('click', $.proxy(this.click, this))
1631
- .on('mouseenter', 'li', $.proxy(this.mouseenter, this))
1632
- }
1633
-
1634
- , keyup: function (e) {
1635
- switch(e.keyCode) {
1636
- case 40: // down arrow
1637
- case 38: // up arrow
1638
- break
1639
-
1640
- case 9: // tab
1641
- case 13: // enter
1642
- if (!this.shown) return
1643
- this.select()
1644
- break
1645
-
1646
- case 27: // escape
1647
- if (!this.shown) return
1648
- this.hide()
1649
- break
1650
-
1651
- default:
1652
- this.lookup()
1653
- }
1654
-
1655
- e.stopPropagation()
1656
- e.preventDefault()
1657
- }
1658
-
1659
- , keypress: function (e) {
1660
- if (!this.shown) return
1661
-
1662
- switch(e.keyCode) {
1663
- case 9: // tab
1664
- case 13: // enter
1665
- case 27: // escape
1666
- e.preventDefault()
1667
- break
1668
-
1669
- case 38: // up arrow
1670
- e.preventDefault()
1671
- this.prev()
1672
- break
1673
-
1674
- case 40: // down arrow
1675
- e.preventDefault()
1676
- this.next()
1677
- break
1678
- }
1679
-
1680
- e.stopPropagation()
1681
- }
1682
-
1683
- , blur: function (e) {
1684
- var that = this
1685
- setTimeout(function () { that.hide() }, 150)
1686
- }
1687
-
1688
- , click: function (e) {
1689
- e.stopPropagation()
1690
- e.preventDefault()
1691
- this.select()
1692
- }
1693
-
1694
- , mouseenter: function (e) {
1695
- this.$menu.find('.active').removeClass('active')
1696
- $(e.currentTarget).addClass('active')
1697
- }
1698
-
1699
- }
1700
-
1701
-
1702
- /* TYPEAHEAD PLUGIN DEFINITION
1703
- * =========================== */
1704
-
1705
- $.fn.typeahead = function ( option ) {
1706
- return this.each(function () {
1707
- var $this = $(this)
1708
- , data = $this.data('typeahead')
1709
- , options = typeof option == 'object' && option
1710
- if (!data) $this.data('typeahead', (data = new Typeahead(this, options)))
1711
- if (typeof option == 'string') data[option]()
1712
- })
1713
- }
1714
-
1715
- $.fn.typeahead.defaults = {
1716
- source: []
1717
- , items: 8
1718
- , menu: '<ul class="typeahead dropdown-menu"></ul>'
1719
- , item: '<li><a href="#"></a></li>'
1720
- }
1721
-
1722
- $.fn.typeahead.Constructor = Typeahead
1723
-
1724
-
1725
- /* TYPEAHEAD DATA-API
1726
- * ================== */
1727
-
1728
- $(function () {
1729
- $('body').on('focus.typeahead.data-api', '[data-provide="typeahead"]', function (e) {
1730
- var $this = $(this)
1731
- if ($this.data('typeahead')) return
1732
- e.preventDefault()
1733
- $this.typeahead($this.data())
1734
- })
1735
- })
1736
-
1737
- }( window.jQuery );