tennpipes-su 3.6.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (192) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE.txt +20 -0
  3. data/README.rdoc +70 -0
  4. data/Rakefile +22 -0
  5. data/lib/tennpipes-su.rb +35 -0
  6. data/lib/tennpipes-su/access_control.rb +191 -0
  7. data/lib/tennpipes-su/bootstrap-less/alerts.less +67 -0
  8. data/lib/tennpipes-su/bootstrap-less/badges.less +55 -0
  9. data/lib/tennpipes-su/bootstrap-less/bootstrap.less +49 -0
  10. data/lib/tennpipes-su/bootstrap-less/breadcrumbs.less +26 -0
  11. data/lib/tennpipes-su/bootstrap-less/button-groups.less +226 -0
  12. data/lib/tennpipes-su/bootstrap-less/buttons.less +155 -0
  13. data/lib/tennpipes-su/bootstrap-less/carousel.less +232 -0
  14. data/lib/tennpipes-su/bootstrap-less/close.less +33 -0
  15. data/lib/tennpipes-su/bootstrap-less/code.less +63 -0
  16. data/lib/tennpipes-su/bootstrap-less/component-animations.less +29 -0
  17. data/lib/tennpipes-su/bootstrap-less/dropdowns.less +213 -0
  18. data/lib/tennpipes-su/bootstrap-less/font-awesome/bordered-pulled.less +16 -0
  19. data/lib/tennpipes-su/bootstrap-less/font-awesome/core.less +12 -0
  20. data/lib/tennpipes-su/bootstrap-less/font-awesome/fixed-width.less +6 -0
  21. data/lib/tennpipes-su/bootstrap-less/font-awesome/font-awesome.less +17 -0
  22. data/lib/tennpipes-su/bootstrap-less/font-awesome/icons.less +412 -0
  23. data/lib/tennpipes-su/bootstrap-less/font-awesome/larger.less +13 -0
  24. data/lib/tennpipes-su/bootstrap-less/font-awesome/list.less +19 -0
  25. data/lib/tennpipes-su/bootstrap-less/font-awesome/mixins.less +20 -0
  26. data/lib/tennpipes-su/bootstrap-less/font-awesome/path.less +14 -0
  27. data/lib/tennpipes-su/bootstrap-less/font-awesome/rotated-flipped.less +9 -0
  28. data/lib/tennpipes-su/bootstrap-less/font-awesome/spinning.less +30 -0
  29. data/lib/tennpipes-su/bootstrap-less/font-awesome/stacked.less +20 -0
  30. data/lib/tennpipes-su/bootstrap-less/font-awesome/variables.less +381 -0
  31. data/lib/tennpipes-su/bootstrap-less/forms.less +419 -0
  32. data/lib/tennpipes-su/bootstrap-less/glyphicons.less +233 -0
  33. data/lib/tennpipes-su/bootstrap-less/grid.less +100 -0
  34. data/lib/tennpipes-su/bootstrap-less/input-groups.less +157 -0
  35. data/lib/tennpipes-su/bootstrap-less/jumbotron.less +44 -0
  36. data/lib/tennpipes-su/bootstrap-less/labels.less +64 -0
  37. data/lib/tennpipes-su/bootstrap-less/list-group.less +110 -0
  38. data/lib/tennpipes-su/bootstrap-less/media.less +56 -0
  39. data/lib/tennpipes-su/bootstrap-less/mixins.less +926 -0
  40. data/lib/tennpipes-su/bootstrap-less/modals.less +138 -0
  41. data/lib/tennpipes-su/bootstrap-less/navbar.less +616 -0
  42. data/lib/tennpipes-su/bootstrap-less/navs.less +242 -0
  43. data/lib/tennpipes-su/bootstrap-less/normalize.less +423 -0
  44. data/lib/tennpipes-su/bootstrap-less/pager.less +55 -0
  45. data/lib/tennpipes-su/bootstrap-less/pagination.less +88 -0
  46. data/lib/tennpipes-su/bootstrap-less/panels.less +230 -0
  47. data/lib/tennpipes-su/bootstrap-less/popovers.less +133 -0
  48. data/lib/tennpipes-su/bootstrap-less/print.less +101 -0
  49. data/lib/tennpipes-su/bootstrap-less/progress-bars.less +80 -0
  50. data/lib/tennpipes-su/bootstrap-less/responsive-utilities.less +93 -0
  51. data/lib/tennpipes-su/bootstrap-less/scaffolding.less +134 -0
  52. data/lib/tennpipes-su/bootstrap-less/tables.less +233 -0
  53. data/lib/tennpipes-su/bootstrap-less/tennpipes-su.less +18 -0
  54. data/lib/tennpipes-su/bootstrap-less/theme.less +247 -0
  55. data/lib/tennpipes-su/bootstrap-less/thumbnails.less +36 -0
  56. data/lib/tennpipes-su/bootstrap-less/tooltip.less +95 -0
  57. data/lib/tennpipes-su/bootstrap-less/type.less +296 -0
  58. data/lib/tennpipes-su/bootstrap-less/utilities.less +56 -0
  59. data/lib/tennpipes-su/bootstrap-less/variables.less +827 -0
  60. data/lib/tennpipes-su/bootstrap-less/wells.less +29 -0
  61. data/lib/tennpipes-su/generators/actions.rb +78 -0
  62. data/lib/tennpipes-su/generators/admin_app.rb +169 -0
  63. data/lib/tennpipes-su/generators/admin_page.rb +68 -0
  64. data/lib/tennpipes-su/generators/orm.rb +172 -0
  65. data/lib/tennpipes-su/generators/templates/account/activerecord.rb.tt +41 -0
  66. data/lib/tennpipes-su/generators/templates/account/couchrest.rb.tt +67 -0
  67. data/lib/tennpipes-su/generators/templates/account/datamapper.rb.tt +56 -0
  68. data/lib/tennpipes-su/generators/templates/account/dynamoid.rb.tt +55 -0
  69. data/lib/tennpipes-su/generators/templates/account/minirecord.rb.tt +44 -0
  70. data/lib/tennpipes-su/generators/templates/account/mongoid.rb.tt +54 -0
  71. data/lib/tennpipes-su/generators/templates/account/mongomapper.rb.tt +47 -0
  72. data/lib/tennpipes-su/generators/templates/account/ohm.rb.tt +70 -0
  73. data/lib/tennpipes-su/generators/templates/account/seeds.rb.tt +29 -0
  74. data/lib/tennpipes-su/generators/templates/account/sequel.rb.tt +53 -0
  75. data/lib/tennpipes-su/generators/templates/app.rb.tt +42 -0
  76. data/lib/tennpipes-su/generators/templates/app/controllers/base.rb.tt +5 -0
  77. data/lib/tennpipes-su/generators/templates/app/controllers/sessions.rb.tt +29 -0
  78. data/lib/tennpipes-su/generators/templates/assets/images/favicon.ico +0 -0
  79. data/lib/tennpipes-su/generators/templates/assets/images/font/FontAwesome.otf +0 -0
  80. data/lib/tennpipes-su/generators/templates/assets/images/font/fontawesome-webfont.eot +0 -0
  81. data/lib/tennpipes-su/generators/templates/assets/images/font/fontawesome-webfont.svg +414 -0
  82. data/lib/tennpipes-su/generators/templates/assets/images/font/fontawesome-webfont.ttf +0 -0
  83. data/lib/tennpipes-su/generators/templates/assets/images/font/fontawesome-webfont.woff +0 -0
  84. data/lib/tennpipes-su/generators/templates/assets/images/logo.png +0 -0
  85. data/lib/tennpipes-su/generators/templates/assets/javascripts/application.js +118 -0
  86. data/lib/tennpipes-su/generators/templates/assets/javascripts/bootstrap/affix.js +137 -0
  87. data/lib/tennpipes-su/generators/templates/assets/javascripts/bootstrap/alert.js +88 -0
  88. data/lib/tennpipes-su/generators/templates/assets/javascripts/bootstrap/bootstrap.min.js +6 -0
  89. data/lib/tennpipes-su/generators/templates/assets/javascripts/bootstrap/button.js +107 -0
  90. data/lib/tennpipes-su/generators/templates/assets/javascripts/bootstrap/carousel.js +205 -0
  91. data/lib/tennpipes-su/generators/templates/assets/javascripts/bootstrap/collapse.js +170 -0
  92. data/lib/tennpipes-su/generators/templates/assets/javascripts/bootstrap/dropdown.js +147 -0
  93. data/lib/tennpipes-su/generators/templates/assets/javascripts/bootstrap/modal.js +243 -0
  94. data/lib/tennpipes-su/generators/templates/assets/javascripts/bootstrap/popover.js +110 -0
  95. data/lib/tennpipes-su/generators/templates/assets/javascripts/bootstrap/scrollspy.js +153 -0
  96. data/lib/tennpipes-su/generators/templates/assets/javascripts/bootstrap/tab.js +125 -0
  97. data/lib/tennpipes-su/generators/templates/assets/javascripts/bootstrap/tooltip.js +399 -0
  98. data/lib/tennpipes-su/generators/templates/assets/javascripts/bootstrap/transition.js +48 -0
  99. data/lib/tennpipes-su/generators/templates/assets/javascripts/jquery-1.11.0.min.js +4 -0
  100. data/lib/tennpipes-su/generators/templates/assets/stylesheets/application.css +353 -0
  101. data/lib/tennpipes-su/generators/templates/assets/stylesheets/bootstrap.css +4 -0
  102. data/lib/tennpipes-su/generators/templates/assets/stylesheets/fonts/FontAwesome.otf +0 -0
  103. data/lib/tennpipes-su/generators/templates/assets/stylesheets/fonts/fontawesome-webfont.eot +0 -0
  104. data/lib/tennpipes-su/generators/templates/assets/stylesheets/fonts/fontawesome-webfont.svg +414 -0
  105. data/lib/tennpipes-su/generators/templates/assets/stylesheets/fonts/fontawesome-webfont.ttf +0 -0
  106. data/lib/tennpipes-su/generators/templates/assets/stylesheets/fonts/fontawesome-webfont.woff +0 -0
  107. data/lib/tennpipes-su/generators/templates/erb/app/base/index.erb.tt +15 -0
  108. data/lib/tennpipes-su/generators/templates/erb/app/errors/403.erb.tt +3 -0
  109. data/lib/tennpipes-su/generators/templates/erb/app/errors/404.erb.tt +3 -0
  110. data/lib/tennpipes-su/generators/templates/erb/app/errors/500.erb.tt +3 -0
  111. data/lib/tennpipes-su/generators/templates/erb/app/layouts/application.erb.tt +64 -0
  112. data/lib/tennpipes-su/generators/templates/erb/app/layouts/error.erb.tt +23 -0
  113. data/lib/tennpipes-su/generators/templates/erb/app/sessions/new.erb.tt +44 -0
  114. data/lib/tennpipes-su/generators/templates/erb/page/_form.erb.tt +18 -0
  115. data/lib/tennpipes-su/generators/templates/erb/page/edit.erb.tt +10 -0
  116. data/lib/tennpipes-su/generators/templates/erb/page/index.erb.tt +81 -0
  117. data/lib/tennpipes-su/generators/templates/erb/page/new.erb.tt +9 -0
  118. data/lib/tennpipes-su/generators/templates/haml/app/base/index.haml.tt +12 -0
  119. data/lib/tennpipes-su/generators/templates/haml/app/errors/403.haml.tt +3 -0
  120. data/lib/tennpipes-su/generators/templates/haml/app/errors/404.haml.tt +3 -0
  121. data/lib/tennpipes-su/generators/templates/haml/app/errors/500.haml.tt +3 -0
  122. data/lib/tennpipes-su/generators/templates/haml/app/layouts/application.haml.tt +49 -0
  123. data/lib/tennpipes-su/generators/templates/haml/app/layouts/error.haml.tt +18 -0
  124. data/lib/tennpipes-su/generators/templates/haml/app/sessions/new.haml.tt +38 -0
  125. data/lib/tennpipes-su/generators/templates/haml/page/_form.haml.tt +16 -0
  126. data/lib/tennpipes-su/generators/templates/haml/page/edit.haml.tt +8 -0
  127. data/lib/tennpipes-su/generators/templates/haml/page/index.haml.tt +58 -0
  128. data/lib/tennpipes-su/generators/templates/haml/page/new.haml.tt +7 -0
  129. data/lib/tennpipes-su/generators/templates/page/controller.rb.tt +92 -0
  130. data/lib/tennpipes-su/generators/templates/slim/app/base/index.slim.tt +12 -0
  131. data/lib/tennpipes-su/generators/templates/slim/app/errors/403.slim.tt +3 -0
  132. data/lib/tennpipes-su/generators/templates/slim/app/errors/404.slim.tt +3 -0
  133. data/lib/tennpipes-su/generators/templates/slim/app/errors/500.slim.tt +3 -0
  134. data/lib/tennpipes-su/generators/templates/slim/app/layouts/application.slim.tt +48 -0
  135. data/lib/tennpipes-su/generators/templates/slim/app/layouts/error.slim.tt +19 -0
  136. data/lib/tennpipes-su/generators/templates/slim/app/sessions/new.slim.tt +37 -0
  137. data/lib/tennpipes-su/generators/templates/slim/page/_form.slim.tt +16 -0
  138. data/lib/tennpipes-su/generators/templates/slim/page/edit.slim.tt +8 -0
  139. data/lib/tennpipes-su/generators/templates/slim/page/index.slim.tt +56 -0
  140. data/lib/tennpipes-su/generators/templates/slim/page/new.slim.tt +7 -0
  141. data/lib/tennpipes-su/helpers/authentication_helpers.rb +108 -0
  142. data/lib/tennpipes-su/helpers/view_helpers.rb +87 -0
  143. data/lib/tennpipes-su/locale/admin/cs.yml +56 -0
  144. data/lib/tennpipes-su/locale/admin/da.yml +56 -0
  145. data/lib/tennpipes-su/locale/admin/de.yml +56 -0
  146. data/lib/tennpipes-su/locale/admin/en.yml +56 -0
  147. data/lib/tennpipes-su/locale/admin/es.yml +56 -0
  148. data/lib/tennpipes-su/locale/admin/fr.yml +56 -0
  149. data/lib/tennpipes-su/locale/admin/hu.yml +56 -0
  150. data/lib/tennpipes-su/locale/admin/it.yml +56 -0
  151. data/lib/tennpipes-su/locale/admin/ja.yml +57 -0
  152. data/lib/tennpipes-su/locale/admin/lv.yml +56 -0
  153. data/lib/tennpipes-su/locale/admin/nl.yml +56 -0
  154. data/lib/tennpipes-su/locale/admin/no.yml +56 -0
  155. data/lib/tennpipes-su/locale/admin/pl.yml +56 -0
  156. data/lib/tennpipes-su/locale/admin/pt_br.yml +56 -0
  157. data/lib/tennpipes-su/locale/admin/ro.yml +56 -0
  158. data/lib/tennpipes-su/locale/admin/ru.yml +57 -0
  159. data/lib/tennpipes-su/locale/admin/sv.yml +56 -0
  160. data/lib/tennpipes-su/locale/admin/tr.yml +56 -0
  161. data/lib/tennpipes-su/locale/admin/uk.yml +56 -0
  162. data/lib/tennpipes-su/locale/admin/zh_cn.yml +56 -0
  163. data/lib/tennpipes-su/locale/admin/zh_tw.yml +56 -0
  164. data/lib/tennpipes-su/locale/orm/cs.yml +12 -0
  165. data/lib/tennpipes-su/locale/orm/da.yml +12 -0
  166. data/lib/tennpipes-su/locale/orm/de.yml +12 -0
  167. data/lib/tennpipes-su/locale/orm/en.yml +12 -0
  168. data/lib/tennpipes-su/locale/orm/es.yml +12 -0
  169. data/lib/tennpipes-su/locale/orm/fr.yml +12 -0
  170. data/lib/tennpipes-su/locale/orm/hu.yml +12 -0
  171. data/lib/tennpipes-su/locale/orm/it.yml +12 -0
  172. data/lib/tennpipes-su/locale/orm/ja.yml +12 -0
  173. data/lib/tennpipes-su/locale/orm/lv.yml +12 -0
  174. data/lib/tennpipes-su/locale/orm/nl.yml +12 -0
  175. data/lib/tennpipes-su/locale/orm/no.yml +12 -0
  176. data/lib/tennpipes-su/locale/orm/pl.yml +38 -0
  177. data/lib/tennpipes-su/locale/orm/pt_br.yml +12 -0
  178. data/lib/tennpipes-su/locale/orm/ro.yml +12 -0
  179. data/lib/tennpipes-su/locale/orm/ru.yml +12 -0
  180. data/lib/tennpipes-su/locale/orm/sv.yml +12 -0
  181. data/lib/tennpipes-su/locale/orm/tr.yml +12 -0
  182. data/lib/tennpipes-su/locale/orm/uk.yml +12 -0
  183. data/lib/tennpipes-su/locale/orm/zh_cn.yml +12 -0
  184. data/lib/tennpipes-su/locale/orm/zh_tw.yml +12 -0
  185. data/test/fixtures/sequel.rb +72 -0
  186. data/test/generators/test_account_model_generator.rb +108 -0
  187. data/test/generators/test_admin_app_generator.rb +218 -0
  188. data/test/generators/test_admin_page_generator.rb +140 -0
  189. data/test/helper.rb +47 -0
  190. data/test/test_admin_application.rb +271 -0
  191. data/test/test_locale.rb +25 -0
  192. metadata +298 -0
@@ -0,0 +1,125 @@
1
+ /* ========================================================================
2
+ * Bootstrap: tab.js v3.1.0
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);
@@ -0,0 +1,399 @@
1
+ /* ========================================================================
2
+ * Bootstrap: tooltip.js v3.1.0
3
+ * http://getbootstrap.com/javascript/#tooltip
4
+ * Inspired by the original jQuery.tipsy by Jason Frame
5
+ * ========================================================================
6
+ * Copyright 2011-2014 Twitter, Inc.
7
+ * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
8
+ * ======================================================================== */
9
+
10
+
11
+ +function ($) {
12
+ 'use strict';
13
+
14
+ // TOOLTIP PUBLIC CLASS DEFINITION
15
+ // ===============================
16
+
17
+ var Tooltip = function (element, options) {
18
+ this.type =
19
+ this.options =
20
+ this.enabled =
21
+ this.timeout =
22
+ this.hoverState =
23
+ this.$element = null
24
+
25
+ this.init('tooltip', element, options)
26
+ }
27
+
28
+ Tooltip.DEFAULTS = {
29
+ animation: true,
30
+ placement: 'top',
31
+ selector: false,
32
+ template: '<div class="tooltip"><div class="tooltip-arrow"></div><div class="tooltip-inner"></div></div>',
33
+ trigger: 'hover focus',
34
+ title: '',
35
+ delay: 0,
36
+ html: false,
37
+ container: false
38
+ }
39
+
40
+ Tooltip.prototype.init = function (type, element, options) {
41
+ this.enabled = true
42
+ this.type = type
43
+ this.$element = $(element)
44
+ this.options = this.getOptions(options)
45
+
46
+ var triggers = this.options.trigger.split(' ')
47
+
48
+ for (var i = triggers.length; i--;) {
49
+ var trigger = triggers[i]
50
+
51
+ if (trigger == 'click') {
52
+ this.$element.on('click.' + this.type, this.options.selector, $.proxy(this.toggle, this))
53
+ } else if (trigger != 'manual') {
54
+ var eventIn = trigger == 'hover' ? 'mouseenter' : 'focusin'
55
+ var eventOut = trigger == 'hover' ? 'mouseleave' : 'focusout'
56
+
57
+ this.$element.on(eventIn + '.' + this.type, this.options.selector, $.proxy(this.enter, this))
58
+ this.$element.on(eventOut + '.' + this.type, this.options.selector, $.proxy(this.leave, this))
59
+ }
60
+ }
61
+
62
+ this.options.selector ?
63
+ (this._options = $.extend({}, this.options, { trigger: 'manual', selector: '' })) :
64
+ this.fixTitle()
65
+ }
66
+
67
+ Tooltip.prototype.getDefaults = function () {
68
+ return Tooltip.DEFAULTS
69
+ }
70
+
71
+ Tooltip.prototype.getOptions = function (options) {
72
+ options = $.extend({}, this.getDefaults(), this.$element.data(), options)
73
+
74
+ if (options.delay && typeof options.delay == 'number') {
75
+ options.delay = {
76
+ show: options.delay,
77
+ hide: options.delay
78
+ }
79
+ }
80
+
81
+ return options
82
+ }
83
+
84
+ Tooltip.prototype.getDelegateOptions = function () {
85
+ var options = {}
86
+ var defaults = this.getDefaults()
87
+
88
+ this._options && $.each(this._options, function (key, value) {
89
+ if (defaults[key] != value) options[key] = value
90
+ })
91
+
92
+ return options
93
+ }
94
+
95
+ Tooltip.prototype.enter = function (obj) {
96
+ var self = obj instanceof this.constructor ?
97
+ obj : $(obj.currentTarget)[this.type](this.getDelegateOptions()).data('bs.' + this.type)
98
+
99
+ clearTimeout(self.timeout)
100
+
101
+ self.hoverState = 'in'
102
+
103
+ if (!self.options.delay || !self.options.delay.show) return self.show()
104
+
105
+ self.timeout = setTimeout(function () {
106
+ if (self.hoverState == 'in') self.show()
107
+ }, self.options.delay.show)
108
+ }
109
+
110
+ Tooltip.prototype.leave = function (obj) {
111
+ var self = obj instanceof this.constructor ?
112
+ obj : $(obj.currentTarget)[this.type](this.getDelegateOptions()).data('bs.' + this.type)
113
+
114
+ clearTimeout(self.timeout)
115
+
116
+ self.hoverState = 'out'
117
+
118
+ if (!self.options.delay || !self.options.delay.hide) return self.hide()
119
+
120
+ self.timeout = setTimeout(function () {
121
+ if (self.hoverState == 'out') self.hide()
122
+ }, self.options.delay.hide)
123
+ }
124
+
125
+ Tooltip.prototype.show = function () {
126
+ var e = $.Event('show.bs.' + this.type)
127
+
128
+ if (this.hasContent() && this.enabled) {
129
+ this.$element.trigger(e)
130
+
131
+ if (e.isDefaultPrevented()) return
132
+ var that = this;
133
+
134
+ var $tip = this.tip()
135
+
136
+ this.setContent()
137
+
138
+ if (this.options.animation) $tip.addClass('fade')
139
+
140
+ var placement = typeof this.options.placement == 'function' ?
141
+ this.options.placement.call(this, $tip[0], this.$element[0]) :
142
+ this.options.placement
143
+
144
+ var autoToken = /\s?auto?\s?/i
145
+ var autoPlace = autoToken.test(placement)
146
+ if (autoPlace) placement = placement.replace(autoToken, '') || 'top'
147
+
148
+ $tip
149
+ .detach()
150
+ .css({ top: 0, left: 0, display: 'block' })
151
+ .addClass(placement)
152
+
153
+ this.options.container ? $tip.appendTo(this.options.container) : $tip.insertAfter(this.$element)
154
+
155
+ var pos = this.getPosition()
156
+ var actualWidth = $tip[0].offsetWidth
157
+ var actualHeight = $tip[0].offsetHeight
158
+
159
+ if (autoPlace) {
160
+ var $parent = this.$element.parent()
161
+
162
+ var orgPlacement = placement
163
+ var docScroll = document.documentElement.scrollTop || document.body.scrollTop
164
+ var parentWidth = this.options.container == 'body' ? window.innerWidth : $parent.outerWidth()
165
+ var parentHeight = this.options.container == 'body' ? window.innerHeight : $parent.outerHeight()
166
+ var parentLeft = this.options.container == 'body' ? 0 : $parent.offset().left
167
+
168
+ placement = placement == 'bottom' && pos.top + pos.height + actualHeight - docScroll > parentHeight ? 'top' :
169
+ placement == 'top' && pos.top - docScroll - actualHeight < 0 ? 'bottom' :
170
+ placement == 'right' && pos.right + actualWidth > parentWidth ? 'left' :
171
+ placement == 'left' && pos.left - actualWidth < parentLeft ? 'right' :
172
+ placement
173
+
174
+ $tip
175
+ .removeClass(orgPlacement)
176
+ .addClass(placement)
177
+ }
178
+
179
+ var calculatedOffset = this.getCalculatedOffset(placement, pos, actualWidth, actualHeight)
180
+
181
+ this.applyPlacement(calculatedOffset, placement)
182
+ this.hoverState = null
183
+
184
+ var complete = function() {
185
+ that.$element.trigger('shown.bs.' + that.type)
186
+ }
187
+
188
+ $.support.transition && this.$tip.hasClass('fade') ?
189
+ $tip
190
+ .one($.support.transition.end, complete)
191
+ .emulateTransitionEnd(150) :
192
+ complete()
193
+ }
194
+ }
195
+
196
+ Tooltip.prototype.applyPlacement = function (offset, placement) {
197
+ var replace
198
+ var $tip = this.tip()
199
+ var width = $tip[0].offsetWidth
200
+ var height = $tip[0].offsetHeight
201
+
202
+ // manually read margins because getBoundingClientRect includes difference
203
+ var marginTop = parseInt($tip.css('margin-top'), 10)
204
+ var marginLeft = parseInt($tip.css('margin-left'), 10)
205
+
206
+ // we must check for NaN for ie 8/9
207
+ if (isNaN(marginTop)) marginTop = 0
208
+ if (isNaN(marginLeft)) marginLeft = 0
209
+
210
+ offset.top = offset.top + marginTop
211
+ offset.left = offset.left + marginLeft
212
+
213
+ // $.fn.offset doesn't round pixel values
214
+ // so we use setOffset directly with our own function B-0
215
+ $.offset.setOffset($tip[0], $.extend({
216
+ using: function (props) {
217
+ $tip.css({
218
+ top: Math.round(props.top),
219
+ left: Math.round(props.left)
220
+ })
221
+ }
222
+ }, offset), 0)
223
+
224
+ $tip.addClass('in')
225
+
226
+ // check to see if placing tip in new offset caused the tip to resize itself
227
+ var actualWidth = $tip[0].offsetWidth
228
+ var actualHeight = $tip[0].offsetHeight
229
+
230
+ if (placement == 'top' && actualHeight != height) {
231
+ replace = true
232
+ offset.top = offset.top + height - actualHeight
233
+ }
234
+
235
+ if (/bottom|top/.test(placement)) {
236
+ var delta = 0
237
+
238
+ if (offset.left < 0) {
239
+ delta = offset.left * -2
240
+ offset.left = 0
241
+
242
+ $tip.offset(offset)
243
+
244
+ actualWidth = $tip[0].offsetWidth
245
+ actualHeight = $tip[0].offsetHeight
246
+ }
247
+
248
+ this.replaceArrow(delta - width + actualWidth, actualWidth, 'left')
249
+ } else {
250
+ this.replaceArrow(actualHeight - height, actualHeight, 'top')
251
+ }
252
+
253
+ if (replace) $tip.offset(offset)
254
+ }
255
+
256
+ Tooltip.prototype.replaceArrow = function (delta, dimension, position) {
257
+ this.arrow().css(position, delta ? (50 * (1 - delta / dimension) + '%') : '')
258
+ }
259
+
260
+ Tooltip.prototype.setContent = function () {
261
+ var $tip = this.tip()
262
+ var title = this.getTitle()
263
+
264
+ $tip.find('.tooltip-inner')[this.options.html ? 'html' : 'text'](title)
265
+ $tip.removeClass('fade in top bottom left right')
266
+ }
267
+
268
+ Tooltip.prototype.hide = function () {
269
+ var that = this
270
+ var $tip = this.tip()
271
+ var e = $.Event('hide.bs.' + this.type)
272
+
273
+ function complete() {
274
+ if (that.hoverState != 'in') $tip.detach()
275
+ that.$element.trigger('hidden.bs.' + that.type)
276
+ }
277
+
278
+ this.$element.trigger(e)
279
+
280
+ if (e.isDefaultPrevented()) return
281
+
282
+ $tip.removeClass('in')
283
+
284
+ $.support.transition && this.$tip.hasClass('fade') ?
285
+ $tip
286
+ .one($.support.transition.end, complete)
287
+ .emulateTransitionEnd(150) :
288
+ complete()
289
+
290
+ this.hoverState = null
291
+
292
+ return this
293
+ }
294
+
295
+ Tooltip.prototype.fixTitle = function () {
296
+ var $e = this.$element
297
+ if ($e.attr('title') || typeof($e.attr('data-original-title')) != 'string') {
298
+ $e.attr('data-original-title', $e.attr('title') || '').attr('title', '')
299
+ }
300
+ }
301
+
302
+ Tooltip.prototype.hasContent = function () {
303
+ return this.getTitle()
304
+ }
305
+
306
+ Tooltip.prototype.getPosition = function () {
307
+ var el = this.$element[0]
308
+ return $.extend({}, (typeof el.getBoundingClientRect == 'function') ? el.getBoundingClientRect() : {
309
+ width: el.offsetWidth,
310
+ height: el.offsetHeight
311
+ }, this.$element.offset())
312
+ }
313
+
314
+ Tooltip.prototype.getCalculatedOffset = function (placement, pos, actualWidth, actualHeight) {
315
+ return placement == 'bottom' ? { top: pos.top + pos.height, left: pos.left + pos.width / 2 - actualWidth / 2 } :
316
+ placement == 'top' ? { top: pos.top - actualHeight, left: pos.left + pos.width / 2 - actualWidth / 2 } :
317
+ placement == 'left' ? { top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left - actualWidth } :
318
+ /* placement == 'right' */ { top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left + pos.width }
319
+ }
320
+
321
+ Tooltip.prototype.getTitle = function () {
322
+ var title
323
+ var $e = this.$element
324
+ var o = this.options
325
+
326
+ title = $e.attr('data-original-title')
327
+ || (typeof o.title == 'function' ? o.title.call($e[0]) : o.title)
328
+
329
+ return title
330
+ }
331
+
332
+ Tooltip.prototype.tip = function () {
333
+ return this.$tip = this.$tip || $(this.options.template)
334
+ }
335
+
336
+ Tooltip.prototype.arrow = function () {
337
+ return this.$arrow = this.$arrow || this.tip().find('.tooltip-arrow')
338
+ }
339
+
340
+ Tooltip.prototype.validate = function () {
341
+ if (!this.$element[0].parentNode) {
342
+ this.hide()
343
+ this.$element = null
344
+ this.options = null
345
+ }
346
+ }
347
+
348
+ Tooltip.prototype.enable = function () {
349
+ this.enabled = true
350
+ }
351
+
352
+ Tooltip.prototype.disable = function () {
353
+ this.enabled = false
354
+ }
355
+
356
+ Tooltip.prototype.toggleEnabled = function () {
357
+ this.enabled = !this.enabled
358
+ }
359
+
360
+ Tooltip.prototype.toggle = function (e) {
361
+ var self = e ? $(e.currentTarget)[this.type](this.getDelegateOptions()).data('bs.' + this.type) : this
362
+ self.tip().hasClass('in') ? self.leave(self) : self.enter(self)
363
+ }
364
+
365
+ Tooltip.prototype.destroy = function () {
366
+ clearTimeout(this.timeout)
367
+ this.hide().$element.off('.' + this.type).removeData('bs.' + this.type)
368
+ }
369
+
370
+
371
+ // TOOLTIP PLUGIN DEFINITION
372
+ // =========================
373
+
374
+ var old = $.fn.tooltip
375
+
376
+ $.fn.tooltip = function (option) {
377
+ return this.each(function () {
378
+ var $this = $(this)
379
+ var data = $this.data('bs.tooltip')
380
+ var options = typeof option == 'object' && option
381
+
382
+ if (!data && option == 'destroy') return
383
+ if (!data) $this.data('bs.tooltip', (data = new Tooltip(this, options)))
384
+ if (typeof option == 'string') data[option]()
385
+ })
386
+ }
387
+
388
+ $.fn.tooltip.Constructor = Tooltip
389
+
390
+
391
+ // TOOLTIP NO CONFLICT
392
+ // ===================
393
+
394
+ $.fn.tooltip.noConflict = function () {
395
+ $.fn.tooltip = old
396
+ return this
397
+ }
398
+
399
+ }(jQuery);