corrade-http-templates – Blame information for rev 62

Subversion Repositories:
Rev:
Rev Author Line No. Line
62 office 1 /* ========================================================================
2 * Bootstrap: tab.js v3.1.1
3 * http://getbootstrap.com/javascript/#tabs
4 * ========================================================================
5 * Copyright 2011-2014 Twitter, Inc.
6 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
7 * ======================================================================== */
8  
9  
10 +function ($) {
11 'use strict';
12  
13 // TAB CLASS DEFINITION
14 // ====================
15  
16 var Tab = function (element) {
17 this.element = $(element)
18 }
19  
20 Tab.prototype.show = function () {
21 var $this = this.element
22 var $ul = $this.closest('ul:not(.dropdown-menu)')
23 var selector = $this.data('target')
24  
25 if (!selector) {
26 selector = $this.attr('href')
27 selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') //strip for ie7
28 }
29  
30 if ($this.parent('li').hasClass('active')) return
31  
32 var previous = $ul.find('.active:last a')[0]
33 var e = $.Event('show.bs.tab', {
34 relatedTarget: previous
35 })
36  
37 $this.trigger(e)
38  
39 if (e.isDefaultPrevented()) return
40  
41 var $target = $(selector)
42  
43 this.activate($this.parent('li'), $ul)
44 this.activate($target, $target.parent(), function () {
45 $this.trigger({
46 type: 'shown.bs.tab',
47 relatedTarget: previous
48 })
49 })
50 }
51  
52 Tab.prototype.activate = function (element, container, callback) {
53 var $active = container.find('> .active')
54 var transition = callback
55 && $.support.transition
56 && $active.hasClass('fade')
57  
58 function next() {
59 $active
60 .removeClass('active')
61 .find('> .dropdown-menu > .active')
62 .removeClass('active')
63  
64 element.addClass('active')
65  
66 if (transition) {
67 element[0].offsetWidth // reflow for transition
68 element.addClass('in')
69 } else {
70 element.removeClass('fade')
71 }
72  
73 if (element.parent('.dropdown-menu')) {
74 element.closest('li.dropdown').addClass('active')
75 }
76  
77 callback && callback()
78 }
79  
80 transition ?
81 $active
82 .one($.support.transition.end, next)
83 .emulateTransitionEnd(150) :
84 next()
85  
86 $active.removeClass('in')
87 }
88  
89  
90 // TAB PLUGIN DEFINITION
91 // =====================
92  
93 var old = $.fn.tab
94  
95 $.fn.tab = function ( option ) {
96 return this.each(function () {
97 var $this = $(this)
98 var data = $this.data('bs.tab')
99  
100 if (!data) $this.data('bs.tab', (data = new Tab(this)))
101 if (typeof option == 'string') data[option]()
102 })
103 }
104  
105 $.fn.tab.Constructor = Tab
106  
107  
108 // TAB NO CONFLICT
109 // ===============
110  
111 $.fn.tab.noConflict = function () {
112 $.fn.tab = old
113 return this
114 }
115  
116  
117 // TAB DATA-API
118 // ============
119  
120 $(document).on('click.bs.tab.data-api', '[data-toggle="tab"], [data-toggle="pill"]', function (e) {
121 e.preventDefault()
122 $(this).tab('show')
123 })
124  
125 }(jQuery);