Policy 1707 commit to LF
[policy/engine.git] / POLICY-SDK-APP / src / main / webapp / app / policyApp / CSS / bootstrap / js / tab.js
1 /* ========================================================================
2  * Bootstrap: tab.js v3.3.4
3  * http://getbootstrap.com/javascript/#tabs
4  * ========================================================================
5  * Copyright 2011-2015 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.VERSION = '3.3.4'
21
22   Tab.TRANSITION_DURATION = 150
23
24   Tab.prototype.show = function () {
25     var $this    = this.element
26     var $ul      = $this.closest('ul:not(.dropdown-menu)')
27     var selector = $this.data('target')
28
29     if (!selector) {
30       selector = $this.attr('href')
31       selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') // strip for ie7
32     }
33
34     if ($this.parent('li').hasClass('active')) return
35
36     var $previous = $ul.find('.active:last a')
37     var hideEvent = $.Event('hide.bs.tab', {
38       relatedTarget: $this[0]
39     })
40     var showEvent = $.Event('show.bs.tab', {
41       relatedTarget: $previous[0]
42     })
43
44     $previous.trigger(hideEvent)
45     $this.trigger(showEvent)
46
47     if (showEvent.isDefaultPrevented() || hideEvent.isDefaultPrevented()) return
48
49     var $target = $(selector)
50
51     this.activate($this.closest('li'), $ul)
52     this.activate($target, $target.parent(), function () {
53       $previous.trigger({
54         type: 'hidden.bs.tab',
55         relatedTarget: $this[0]
56       })
57       $this.trigger({
58         type: 'shown.bs.tab',
59         relatedTarget: $previous[0]
60       })
61     })
62   }
63
64   Tab.prototype.activate = function (element, container, callback) {
65     var $active    = container.find('> .active')
66     var transition = callback
67       && $.support.transition
68       && (($active.length && $active.hasClass('fade')) || !!container.find('> .fade').length)
69
70     function next() {
71       $active
72         .removeClass('active')
73         .find('> .dropdown-menu > .active')
74           .removeClass('active')
75         .end()
76         .find('[data-toggle="tab"]')
77           .attr('aria-expanded', false)
78
79       element
80         .addClass('active')
81         .find('[data-toggle="tab"]')
82           .attr('aria-expanded', true)
83
84       if (transition) {
85         element[0].offsetWidth // reflow for transition
86         element.addClass('in')
87       } else {
88         element.removeClass('fade')
89       }
90
91       if (element.parent('.dropdown-menu').length) {
92         element
93           .closest('li.dropdown')
94             .addClass('active')
95           .end()
96           .find('[data-toggle="tab"]')
97             .attr('aria-expanded', true)
98       }
99
100       callback && callback()
101     }
102
103     $active.length && transition ?
104       $active
105         .one('bsTransitionEnd', next)
106         .emulateTransitionEnd(Tab.TRANSITION_DURATION) :
107       next()
108
109     $active.removeClass('in')
110   }
111
112
113   // TAB PLUGIN DEFINITION
114   // =====================
115
116   function Plugin(option) {
117     return this.each(function () {
118       var $this = $(this)
119       var data  = $this.data('bs.tab')
120
121       if (!data) $this.data('bs.tab', (data = new Tab(this)))
122       if (typeof option == 'string') data[option]()
123     })
124   }
125
126   var old = $.fn.tab
127
128   $.fn.tab             = Plugin
129   $.fn.tab.Constructor = Tab
130
131
132   // TAB NO CONFLICT
133   // ===============
134
135   $.fn.tab.noConflict = function () {
136     $.fn.tab = old
137     return this
138   }
139
140
141   // TAB DATA-API
142   // ============
143
144   var clickHandler = function (e) {
145     e.preventDefault()
146     Plugin.call($(this), 'show')
147   }
148
149   $(document)
150     .on('click.bs.tab.data-api', '[data-toggle="tab"]', clickHandler)
151     .on('click.bs.tab.data-api', '[data-toggle="pill"]', clickHandler)
152
153 }(jQuery);