jabysoft-base 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (153) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +8 -0
  3. data/.rspec +3 -0
  4. data/CODE_OF_CONDUCT.md +49 -0
  5. data/Gemfile +6 -0
  6. data/Gemfile.lock +180 -0
  7. data/LICENSE +21 -0
  8. data/README.md +37 -0
  9. data/Rakefile +6 -0
  10. data/app/assets/javascripts/jabysoft.js +1 -0
  11. data/app/assets/stylesheets/jabysoft.sass +42 -0
  12. data/app/controllers/base_controller.rb +111 -0
  13. data/app/helpers/base_helper.rb +63 -0
  14. data/app/helpers/devise_helper.rb +17 -0
  15. data/app/helpers/links_helper.rb +84 -0
  16. data/app/helpers/render_helper.rb +19 -0
  17. data/app/models/concerns/extension_model_behaviour.rb +16 -0
  18. data/app/models/concerns/searchable_behaviour.rb +47 -0
  19. data/app/views/layouts/admin.html.haml +46 -0
  20. data/app/views/layouts/application.html.haml +31 -0
  21. data/app/views/shared/_datepicker_field.html.haml +9 -0
  22. data/app/views/shared/_layout.html.haml +7 -0
  23. data/app/views/shared/_messages.html.haml +7 -0
  24. data/app/views/shared/_panel.html.haml +5 -0
  25. data/app/views/shared/_search_form.html.haml +6 -0
  26. data/app/views/shared/form/_error_messages.html.haml +6 -0
  27. data/app/views/shared/modals/_delete_confirmation.html.haml +17 -0
  28. data/bin/console +14 -0
  29. data/bin/setup +8 -0
  30. data/config/locales/en.yml +35 -0
  31. data/config/locales/pt-BR.yml +35 -0
  32. data/jabysoft-base.gemspec +37 -0
  33. data/lib/generators/haml/scaffold/scaffold_generator.rb +36 -0
  34. data/lib/generators/jabysoft/setup/USAGE +19 -0
  35. data/lib/generators/jabysoft/setup/setup_generator.rb +57 -0
  36. data/lib/generators/jabysoft/setup/templates/.rspec +3 -0
  37. data/lib/generators/jabysoft/setup/templates/Gemfile +48 -0
  38. data/lib/generators/jabysoft/setup/templates/assets/stylesheets/base.scss +24 -0
  39. data/lib/generators/jabysoft/setup/templates/assets/stylesheets/bootstrap-variables.scss +875 -0
  40. data/lib/generators/jabysoft/setup/templates/layouts/admin.html.haml +46 -0
  41. data/lib/generators/jabysoft/setup/templates/layouts/application.html.haml +31 -0
  42. data/lib/generators/jabysoft/setup/templates/spec/rails_helper.rb +92 -0
  43. data/lib/generators/jabysoft/setup/templates/spec/spec_helper.rb +97 -0
  44. data/lib/generators/rspec/scaffold/scaffold_generator.rb +167 -0
  45. data/lib/jabysoft/base/version.rb +5 -0
  46. data/lib/jabysoft/base.rb +16 -0
  47. data/lib/templates/haml/scaffold/_form.html.haml +14 -0
  48. data/lib/templates/haml/scaffold/_index.html.haml +25 -0
  49. data/lib/templates/haml/scaffold/edit.html.haml +1 -0
  50. data/lib/templates/haml/scaffold/index.html.haml +1 -0
  51. data/lib/templates/haml/scaffold/new.html.haml +1 -0
  52. data/lib/templates/haml/scaffold/show.html.haml +1 -0
  53. data/lib/templates/rails/scaffold_controller/controller.rb +29 -0
  54. data/lib/templates/rspec/scaffold/controller_spec.rb +148 -0
  55. data/lib/templates/rspec/scaffold/model_spec.rb +14 -0
  56. data/lib/templates/rspec/scaffold/request_spec.rb +10 -0
  57. data/lib/templates/rspec/scaffold/routing_spec.rb +44 -0
  58. data/vendor/assets/fonts/bootstrap/glyphicons-halflings-regular.eot +0 -0
  59. data/vendor/assets/fonts/bootstrap/glyphicons-halflings-regular.svg +288 -0
  60. data/vendor/assets/fonts/bootstrap/glyphicons-halflings-regular.ttf +0 -0
  61. data/vendor/assets/fonts/bootstrap/glyphicons-halflings-regular.woff +0 -0
  62. data/vendor/assets/fonts/bootstrap/glyphicons-halflings-regular.woff2 +0 -0
  63. data/vendor/assets/images/.keep +0 -0
  64. data/vendor/assets/javascripts/bootstrap/affix.js +162 -0
  65. data/vendor/assets/javascripts/bootstrap/alert.js +94 -0
  66. data/vendor/assets/javascripts/bootstrap/button.js +120 -0
  67. data/vendor/assets/javascripts/bootstrap/carousel.js +237 -0
  68. data/vendor/assets/javascripts/bootstrap/collapse.js +211 -0
  69. data/vendor/assets/javascripts/bootstrap/dropdown.js +165 -0
  70. data/vendor/assets/javascripts/bootstrap/modal.js +337 -0
  71. data/vendor/assets/javascripts/bootstrap/popover.js +108 -0
  72. data/vendor/assets/javascripts/bootstrap/scrollspy.js +172 -0
  73. data/vendor/assets/javascripts/bootstrap/tab.js +155 -0
  74. data/vendor/assets/javascripts/bootstrap/tooltip.js +514 -0
  75. data/vendor/assets/javascripts/bootstrap/transition.js +59 -0
  76. data/vendor/assets/javascripts/bootstrap-sprockets.js +12 -0
  77. data/vendor/assets/javascripts/bootstrap.js +2363 -0
  78. data/vendor/assets/javascripts/bootstrap.min.js +7 -0
  79. data/vendor/assets/stylesheets/_bootstrap-compass.scss +9 -0
  80. data/vendor/assets/stylesheets/_bootstrap-mincer.scss +19 -0
  81. data/vendor/assets/stylesheets/_bootstrap-sprockets.scss +9 -0
  82. data/vendor/assets/stylesheets/_bootstrap.scss +56 -0
  83. data/vendor/assets/stylesheets/bootstrap/_alerts.scss +73 -0
  84. data/vendor/assets/stylesheets/bootstrap/_badges.scss +68 -0
  85. data/vendor/assets/stylesheets/bootstrap/_breadcrumbs.scss +28 -0
  86. data/vendor/assets/stylesheets/bootstrap/_button-groups.scss +244 -0
  87. data/vendor/assets/stylesheets/bootstrap/_buttons.scss +168 -0
  88. data/vendor/assets/stylesheets/bootstrap/_carousel.scss +270 -0
  89. data/vendor/assets/stylesheets/bootstrap/_close.scss +36 -0
  90. data/vendor/assets/stylesheets/bootstrap/_code.scss +69 -0
  91. data/vendor/assets/stylesheets/bootstrap/_component-animations.scss +37 -0
  92. data/vendor/assets/stylesheets/bootstrap/_dropdowns.scss +216 -0
  93. data/vendor/assets/stylesheets/bootstrap/_forms.scss +617 -0
  94. data/vendor/assets/stylesheets/bootstrap/_glyphicons.scss +307 -0
  95. data/vendor/assets/stylesheets/bootstrap/_grid.scss +84 -0
  96. data/vendor/assets/stylesheets/bootstrap/_input-groups.scss +171 -0
  97. data/vendor/assets/stylesheets/bootstrap/_jumbotron.scss +54 -0
  98. data/vendor/assets/stylesheets/bootstrap/_labels.scss +66 -0
  99. data/vendor/assets/stylesheets/bootstrap/_list-group.scss +130 -0
  100. data/vendor/assets/stylesheets/bootstrap/_media.scss +66 -0
  101. data/vendor/assets/stylesheets/bootstrap/_mixins.scss +40 -0
  102. data/vendor/assets/stylesheets/bootstrap/_modals.scss +150 -0
  103. data/vendor/assets/stylesheets/bootstrap/_navbar.scss +662 -0
  104. data/vendor/assets/stylesheets/bootstrap/_navs.scss +242 -0
  105. data/vendor/assets/stylesheets/bootstrap/_normalize.scss +424 -0
  106. data/vendor/assets/stylesheets/bootstrap/_pager.scss +54 -0
  107. data/vendor/assets/stylesheets/bootstrap/_pagination.scss +89 -0
  108. data/vendor/assets/stylesheets/bootstrap/_panels.scss +271 -0
  109. data/vendor/assets/stylesheets/bootstrap/_popovers.scss +131 -0
  110. data/vendor/assets/stylesheets/bootstrap/_print.scss +101 -0
  111. data/vendor/assets/stylesheets/bootstrap/_progress-bars.scss +87 -0
  112. data/vendor/assets/stylesheets/bootstrap/_responsive-embed.scss +35 -0
  113. data/vendor/assets/stylesheets/bootstrap/_responsive-utilities.scss +179 -0
  114. data/vendor/assets/stylesheets/bootstrap/_scaffolding.scss +161 -0
  115. data/vendor/assets/stylesheets/bootstrap/_tables.scss +234 -0
  116. data/vendor/assets/stylesheets/bootstrap/_theme.scss +291 -0
  117. data/vendor/assets/stylesheets/bootstrap/_thumbnails.scss +38 -0
  118. data/vendor/assets/stylesheets/bootstrap/_tooltip.scss +101 -0
  119. data/vendor/assets/stylesheets/bootstrap/_type.scss +298 -0
  120. data/vendor/assets/stylesheets/bootstrap/_utilities.scss +55 -0
  121. data/vendor/assets/stylesheets/bootstrap/_variables.scss +874 -0
  122. data/vendor/assets/stylesheets/bootstrap/_wells.scss +29 -0
  123. data/vendor/assets/stylesheets/bootstrap/mixins/_alerts.scss +14 -0
  124. data/vendor/assets/stylesheets/bootstrap/mixins/_background-variant.scss +12 -0
  125. data/vendor/assets/stylesheets/bootstrap/mixins/_border-radius.scss +18 -0
  126. data/vendor/assets/stylesheets/bootstrap/mixins/_buttons.scss +65 -0
  127. data/vendor/assets/stylesheets/bootstrap/mixins/_center-block.scss +7 -0
  128. data/vendor/assets/stylesheets/bootstrap/mixins/_clearfix.scss +22 -0
  129. data/vendor/assets/stylesheets/bootstrap/mixins/_forms.scss +88 -0
  130. data/vendor/assets/stylesheets/bootstrap/mixins/_gradients.scss +58 -0
  131. data/vendor/assets/stylesheets/bootstrap/mixins/_grid-framework.scss +81 -0
  132. data/vendor/assets/stylesheets/bootstrap/mixins/_grid.scss +122 -0
  133. data/vendor/assets/stylesheets/bootstrap/mixins/_hide-text.scss +21 -0
  134. data/vendor/assets/stylesheets/bootstrap/mixins/_image.scss +33 -0
  135. data/vendor/assets/stylesheets/bootstrap/mixins/_labels.scss +12 -0
  136. data/vendor/assets/stylesheets/bootstrap/mixins/_list-group.scss +32 -0
  137. data/vendor/assets/stylesheets/bootstrap/mixins/_nav-divider.scss +10 -0
  138. data/vendor/assets/stylesheets/bootstrap/mixins/_nav-vertical-align.scss +9 -0
  139. data/vendor/assets/stylesheets/bootstrap/mixins/_opacity.scss +8 -0
  140. data/vendor/assets/stylesheets/bootstrap/mixins/_pagination.scss +24 -0
  141. data/vendor/assets/stylesheets/bootstrap/mixins/_panels.scss +24 -0
  142. data/vendor/assets/stylesheets/bootstrap/mixins/_progress-bar.scss +10 -0
  143. data/vendor/assets/stylesheets/bootstrap/mixins/_reset-filter.scss +8 -0
  144. data/vendor/assets/stylesheets/bootstrap/mixins/_reset-text.scss +18 -0
  145. data/vendor/assets/stylesheets/bootstrap/mixins/_resize.scss +6 -0
  146. data/vendor/assets/stylesheets/bootstrap/mixins/_responsive-visibility.scss +21 -0
  147. data/vendor/assets/stylesheets/bootstrap/mixins/_size.scss +10 -0
  148. data/vendor/assets/stylesheets/bootstrap/mixins/_tab-focus.scss +9 -0
  149. data/vendor/assets/stylesheets/bootstrap/mixins/_table-row.scss +28 -0
  150. data/vendor/assets/stylesheets/bootstrap/mixins/_text-emphasis.scss +12 -0
  151. data/vendor/assets/stylesheets/bootstrap/mixins/_text-overflow.scss +8 -0
  152. data/vendor/assets/stylesheets/bootstrap/mixins/_vendor-prefixes.scss +222 -0
  153. metadata +308 -0
@@ -0,0 +1,108 @@
1
+ /* ========================================================================
2
+ * Bootstrap: popover.js v3.3.6
3
+ * http://getbootstrap.com/javascript/#popovers
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
+ // POPOVER PUBLIC CLASS DEFINITION
14
+ // ===============================
15
+
16
+ var Popover = function (element, options) {
17
+ this.init('popover', element, options)
18
+ }
19
+
20
+ if (!$.fn.tooltip) throw new Error('Popover requires tooltip.js')
21
+
22
+ Popover.VERSION = '3.3.6'
23
+
24
+ Popover.DEFAULTS = $.extend({}, $.fn.tooltip.Constructor.DEFAULTS, {
25
+ placement: 'right',
26
+ trigger: 'click',
27
+ content: '',
28
+ template: '<div class="popover" role="tooltip"><div class="arrow"></div><h3 class="popover-title"></h3><div class="popover-content"></div></div>'
29
+ })
30
+
31
+
32
+ // NOTE: POPOVER EXTENDS tooltip.js
33
+ // ================================
34
+
35
+ Popover.prototype = $.extend({}, $.fn.tooltip.Constructor.prototype)
36
+
37
+ Popover.prototype.constructor = Popover
38
+
39
+ Popover.prototype.getDefaults = function () {
40
+ return Popover.DEFAULTS
41
+ }
42
+
43
+ Popover.prototype.setContent = function () {
44
+ var $tip = this.tip()
45
+ var title = this.getTitle()
46
+ var content = this.getContent()
47
+
48
+ $tip.find('.popover-title')[this.options.html ? 'html' : 'text'](title)
49
+ $tip.find('.popover-content').children().detach().end()[ // we use append for html objects to maintain js events
50
+ this.options.html ? (typeof content == 'string' ? 'html' : 'append') : 'text'
51
+ ](content)
52
+
53
+ $tip.removeClass('fade top bottom left right in')
54
+
55
+ // IE8 doesn't accept hiding via the `:empty` pseudo selector, we have to do
56
+ // this manually by checking the contents.
57
+ if (!$tip.find('.popover-title').html()) $tip.find('.popover-title').hide()
58
+ }
59
+
60
+ Popover.prototype.hasContent = function () {
61
+ return this.getTitle() || this.getContent()
62
+ }
63
+
64
+ Popover.prototype.getContent = function () {
65
+ var $e = this.$element
66
+ var o = this.options
67
+
68
+ return $e.attr('data-content')
69
+ || (typeof o.content == 'function' ?
70
+ o.content.call($e[0]) :
71
+ o.content)
72
+ }
73
+
74
+ Popover.prototype.arrow = function () {
75
+ return (this.$arrow = this.$arrow || this.tip().find('.arrow'))
76
+ }
77
+
78
+
79
+ // POPOVER PLUGIN DEFINITION
80
+ // =========================
81
+
82
+ function Plugin(option) {
83
+ return this.each(function () {
84
+ var $this = $(this)
85
+ var data = $this.data('bs.popover')
86
+ var options = typeof option == 'object' && option
87
+
88
+ if (!data && /destroy|hide/.test(option)) return
89
+ if (!data) $this.data('bs.popover', (data = new Popover(this, options)))
90
+ if (typeof option == 'string') data[option]()
91
+ })
92
+ }
93
+
94
+ var old = $.fn.popover
95
+
96
+ $.fn.popover = Plugin
97
+ $.fn.popover.Constructor = Popover
98
+
99
+
100
+ // POPOVER NO CONFLICT
101
+ // ===================
102
+
103
+ $.fn.popover.noConflict = function () {
104
+ $.fn.popover = old
105
+ return this
106
+ }
107
+
108
+ }(jQuery);
@@ -0,0 +1,172 @@
1
+ /* ========================================================================
2
+ * Bootstrap: scrollspy.js v3.3.6
3
+ * http://getbootstrap.com/javascript/#scrollspy
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
+ // SCROLLSPY CLASS DEFINITION
14
+ // ==========================
15
+
16
+ function ScrollSpy(element, options) {
17
+ this.$body = $(document.body)
18
+ this.$scrollElement = $(element).is(document.body) ? $(window) : $(element)
19
+ this.options = $.extend({}, ScrollSpy.DEFAULTS, options)
20
+ this.selector = (this.options.target || '') + ' .nav li > a'
21
+ this.offsets = []
22
+ this.targets = []
23
+ this.activeTarget = null
24
+ this.scrollHeight = 0
25
+
26
+ this.$scrollElement.on('scroll.bs.scrollspy', $.proxy(this.process, this))
27
+ this.refresh()
28
+ this.process()
29
+ }
30
+
31
+ ScrollSpy.VERSION = '3.3.6'
32
+
33
+ ScrollSpy.DEFAULTS = {
34
+ offset: 10
35
+ }
36
+
37
+ ScrollSpy.prototype.getScrollHeight = function () {
38
+ return this.$scrollElement[0].scrollHeight || Math.max(this.$body[0].scrollHeight, document.documentElement.scrollHeight)
39
+ }
40
+
41
+ ScrollSpy.prototype.refresh = function () {
42
+ var that = this
43
+ var offsetMethod = 'offset'
44
+ var offsetBase = 0
45
+
46
+ this.offsets = []
47
+ this.targets = []
48
+ this.scrollHeight = this.getScrollHeight()
49
+
50
+ if (!$.isWindow(this.$scrollElement[0])) {
51
+ offsetMethod = 'position'
52
+ offsetBase = this.$scrollElement.scrollTop()
53
+ }
54
+
55
+ this.$body
56
+ .find(this.selector)
57
+ .map(function () {
58
+ var $el = $(this)
59
+ var href = $el.data('target') || $el.attr('href')
60
+ var $href = /^#./.test(href) && $(href)
61
+
62
+ return ($href
63
+ && $href.length
64
+ && $href.is(':visible')
65
+ && [[$href[offsetMethod]().top + offsetBase, href]]) || null
66
+ })
67
+ .sort(function (a, b) { return a[0] - b[0] })
68
+ .each(function () {
69
+ that.offsets.push(this[0])
70
+ that.targets.push(this[1])
71
+ })
72
+ }
73
+
74
+ ScrollSpy.prototype.process = function () {
75
+ var scrollTop = this.$scrollElement.scrollTop() + this.options.offset
76
+ var scrollHeight = this.getScrollHeight()
77
+ var maxScroll = this.options.offset + scrollHeight - this.$scrollElement.height()
78
+ var offsets = this.offsets
79
+ var targets = this.targets
80
+ var activeTarget = this.activeTarget
81
+ var i
82
+
83
+ if (this.scrollHeight != scrollHeight) {
84
+ this.refresh()
85
+ }
86
+
87
+ if (scrollTop >= maxScroll) {
88
+ return activeTarget != (i = targets[targets.length - 1]) && this.activate(i)
89
+ }
90
+
91
+ if (activeTarget && scrollTop < offsets[0]) {
92
+ this.activeTarget = null
93
+ return this.clear()
94
+ }
95
+
96
+ for (i = offsets.length; i--;) {
97
+ activeTarget != targets[i]
98
+ && scrollTop >= offsets[i]
99
+ && (offsets[i + 1] === undefined || scrollTop < offsets[i + 1])
100
+ && this.activate(targets[i])
101
+ }
102
+ }
103
+
104
+ ScrollSpy.prototype.activate = function (target) {
105
+ this.activeTarget = target
106
+
107
+ this.clear()
108
+
109
+ var selector = this.selector +
110
+ '[data-target="' + target + '"],' +
111
+ this.selector + '[href="' + target + '"]'
112
+
113
+ var active = $(selector)
114
+ .parents('li')
115
+ .addClass('active')
116
+
117
+ if (active.parent('.dropdown-menu').length) {
118
+ active = active
119
+ .closest('li.dropdown')
120
+ .addClass('active')
121
+ }
122
+
123
+ active.trigger('activate.bs.scrollspy')
124
+ }
125
+
126
+ ScrollSpy.prototype.clear = function () {
127
+ $(this.selector)
128
+ .parentsUntil(this.options.target, '.active')
129
+ .removeClass('active')
130
+ }
131
+
132
+
133
+ // SCROLLSPY PLUGIN DEFINITION
134
+ // ===========================
135
+
136
+ function Plugin(option) {
137
+ return this.each(function () {
138
+ var $this = $(this)
139
+ var data = $this.data('bs.scrollspy')
140
+ var options = typeof option == 'object' && option
141
+
142
+ if (!data) $this.data('bs.scrollspy', (data = new ScrollSpy(this, options)))
143
+ if (typeof option == 'string') data[option]()
144
+ })
145
+ }
146
+
147
+ var old = $.fn.scrollspy
148
+
149
+ $.fn.scrollspy = Plugin
150
+ $.fn.scrollspy.Constructor = ScrollSpy
151
+
152
+
153
+ // SCROLLSPY NO CONFLICT
154
+ // =====================
155
+
156
+ $.fn.scrollspy.noConflict = function () {
157
+ $.fn.scrollspy = old
158
+ return this
159
+ }
160
+
161
+
162
+ // SCROLLSPY DATA-API
163
+ // ==================
164
+
165
+ $(window).on('load.bs.scrollspy.data-api', function () {
166
+ $('[data-spy="scroll"]').each(function () {
167
+ var $spy = $(this)
168
+ Plugin.call($spy, $spy.data())
169
+ })
170
+ })
171
+
172
+ }(jQuery);
@@ -0,0 +1,155 @@
1
+ /* ========================================================================
2
+ * Bootstrap: tab.js v3.3.6
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
+ // jscs:disable requireDollarBeforejQueryAssignment
18
+ this.element = $(element)
19
+ // jscs:enable requireDollarBeforejQueryAssignment
20
+ }
21
+
22
+ Tab.VERSION = '3.3.6'
23
+
24
+ Tab.TRANSITION_DURATION = 150
25
+
26
+ Tab.prototype.show = function () {
27
+ var $this = this.element
28
+ var $ul = $this.closest('ul:not(.dropdown-menu)')
29
+ var selector = $this.data('target')
30
+
31
+ if (!selector) {
32
+ selector = $this.attr('href')
33
+ selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') // strip for ie7
34
+ }
35
+
36
+ if ($this.parent('li').hasClass('active')) return
37
+
38
+ var $previous = $ul.find('.active:last a')
39
+ var hideEvent = $.Event('hide.bs.tab', {
40
+ relatedTarget: $this[0]
41
+ })
42
+ var showEvent = $.Event('show.bs.tab', {
43
+ relatedTarget: $previous[0]
44
+ })
45
+
46
+ $previous.trigger(hideEvent)
47
+ $this.trigger(showEvent)
48
+
49
+ if (showEvent.isDefaultPrevented() || hideEvent.isDefaultPrevented()) return
50
+
51
+ var $target = $(selector)
52
+
53
+ this.activate($this.closest('li'), $ul)
54
+ this.activate($target, $target.parent(), function () {
55
+ $previous.trigger({
56
+ type: 'hidden.bs.tab',
57
+ relatedTarget: $this[0]
58
+ })
59
+ $this.trigger({
60
+ type: 'shown.bs.tab',
61
+ relatedTarget: $previous[0]
62
+ })
63
+ })
64
+ }
65
+
66
+ Tab.prototype.activate = function (element, container, callback) {
67
+ var $active = container.find('> .active')
68
+ var transition = callback
69
+ && $.support.transition
70
+ && ($active.length && $active.hasClass('fade') || !!container.find('> .fade').length)
71
+
72
+ function next() {
73
+ $active
74
+ .removeClass('active')
75
+ .find('> .dropdown-menu > .active')
76
+ .removeClass('active')
77
+ .end()
78
+ .find('[data-toggle="tab"]')
79
+ .attr('aria-expanded', false)
80
+
81
+ element
82
+ .addClass('active')
83
+ .find('[data-toggle="tab"]')
84
+ .attr('aria-expanded', true)
85
+
86
+ if (transition) {
87
+ element[0].offsetWidth // reflow for transition
88
+ element.addClass('in')
89
+ } else {
90
+ element.removeClass('fade')
91
+ }
92
+
93
+ if (element.parent('.dropdown-menu').length) {
94
+ element
95
+ .closest('li.dropdown')
96
+ .addClass('active')
97
+ .end()
98
+ .find('[data-toggle="tab"]')
99
+ .attr('aria-expanded', true)
100
+ }
101
+
102
+ callback && callback()
103
+ }
104
+
105
+ $active.length && transition ?
106
+ $active
107
+ .one('bsTransitionEnd', next)
108
+ .emulateTransitionEnd(Tab.TRANSITION_DURATION) :
109
+ next()
110
+
111
+ $active.removeClass('in')
112
+ }
113
+
114
+
115
+ // TAB PLUGIN DEFINITION
116
+ // =====================
117
+
118
+ function Plugin(option) {
119
+ return this.each(function () {
120
+ var $this = $(this)
121
+ var data = $this.data('bs.tab')
122
+
123
+ if (!data) $this.data('bs.tab', (data = new Tab(this)))
124
+ if (typeof option == 'string') data[option]()
125
+ })
126
+ }
127
+
128
+ var old = $.fn.tab
129
+
130
+ $.fn.tab = Plugin
131
+ $.fn.tab.Constructor = Tab
132
+
133
+
134
+ // TAB NO CONFLICT
135
+ // ===============
136
+
137
+ $.fn.tab.noConflict = function () {
138
+ $.fn.tab = old
139
+ return this
140
+ }
141
+
142
+
143
+ // TAB DATA-API
144
+ // ============
145
+
146
+ var clickHandler = function (e) {
147
+ e.preventDefault()
148
+ Plugin.call($(this), 'show')
149
+ }
150
+
151
+ $(document)
152
+ .on('click.bs.tab.data-api', '[data-toggle="tab"]', clickHandler)
153
+ .on('click.bs.tab.data-api', '[data-toggle="pill"]', clickHandler)
154
+
155
+ }(jQuery);