padrino-admin 0.11.2 → 0.11.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (98) hide show
  1. data/lib/padrino-admin/bootstrap-less/accordion.less +6 -9
  2. data/lib/padrino-admin/bootstrap-less/alerts.less +46 -51
  3. data/lib/padrino-admin/bootstrap-less/badges.less +2 -7
  4. data/lib/padrino-admin/bootstrap-less/bootstrap.less +0 -1
  5. data/lib/padrino-admin/bootstrap-less/breadcrumbs.less +3 -3
  6. data/lib/padrino-admin/bootstrap-less/button-groups.less +37 -37
  7. data/lib/padrino-admin/bootstrap-less/buttons.less +52 -67
  8. data/lib/padrino-admin/bootstrap-less/carousel.less +24 -35
  9. data/lib/padrino-admin/bootstrap-less/close.less +14 -13
  10. data/lib/padrino-admin/bootstrap-less/code.less +4 -7
  11. data/lib/padrino-admin/bootstrap-less/component-animations.less +2 -11
  12. data/lib/padrino-admin/bootstrap-less/dropdowns.less +26 -82
  13. data/lib/padrino-admin/bootstrap-less/font-awesome-ie7.less +1895 -292
  14. data/lib/padrino-admin/bootstrap-less/font-awesome.less +26 -530
  15. data/lib/padrino-admin/bootstrap-less/font-awesome/bootstrap.less +84 -0
  16. data/lib/padrino-admin/bootstrap-less/font-awesome/core.less +129 -0
  17. data/lib/padrino-admin/bootstrap-less/font-awesome/extras.less +93 -0
  18. data/lib/padrino-admin/bootstrap-less/font-awesome/font-awesome-ie7.less +1953 -0
  19. data/lib/padrino-admin/bootstrap-less/font-awesome/font-awesome.less +33 -0
  20. data/lib/padrino-admin/bootstrap-less/font-awesome/icons.less +381 -0
  21. data/lib/padrino-admin/bootstrap-less/font-awesome/mixins.less +48 -0
  22. data/lib/padrino-admin/bootstrap-less/font-awesome/path.less +14 -0
  23. data/lib/padrino-admin/bootstrap-less/font-awesome/variables.less +735 -0
  24. data/lib/padrino-admin/bootstrap-less/forms.less +123 -227
  25. data/lib/padrino-admin/bootstrap-less/grid.less +174 -19
  26. data/lib/padrino-admin/bootstrap-less/jumbotron.less +4 -4
  27. data/lib/padrino-admin/bootstrap-less/labels.less +52 -28
  28. data/lib/padrino-admin/bootstrap-less/list-group.less +37 -44
  29. data/lib/padrino-admin/bootstrap-less/media.less +1 -1
  30. data/lib/padrino-admin/bootstrap-less/mixins.less +97 -120
  31. data/lib/padrino-admin/bootstrap-less/modals.less +5 -4
  32. data/lib/padrino-admin/bootstrap-less/navbar.less +148 -174
  33. data/lib/padrino-admin/bootstrap-less/navs.less +145 -164
  34. data/lib/padrino-admin/bootstrap-less/padrino-admin.less +2 -2
  35. data/lib/padrino-admin/bootstrap-less/pager.less +45 -33
  36. data/lib/padrino-admin/bootstrap-less/pagination.less +11 -23
  37. data/lib/padrino-admin/bootstrap-less/panels.less +11 -1
  38. data/lib/padrino-admin/bootstrap-less/popovers.less +6 -6
  39. data/lib/padrino-admin/bootstrap-less/print.less +13 -2
  40. data/lib/padrino-admin/bootstrap-less/progress-bars.less +3 -3
  41. data/lib/padrino-admin/bootstrap-less/responsive-utilities.less +92 -32
  42. data/lib/padrino-admin/bootstrap-less/scaffolding.less +9 -18
  43. data/lib/padrino-admin/bootstrap-less/tables.less +70 -67
  44. data/lib/padrino-admin/bootstrap-less/thumbnails.less +6 -6
  45. data/lib/padrino-admin/bootstrap-less/tooltip.less +25 -1
  46. data/lib/padrino-admin/bootstrap-less/type.less +39 -46
  47. data/lib/padrino-admin/bootstrap-less/variables.less +135 -63
  48. data/lib/padrino-admin/generators/admin_app.rb +9 -0
  49. data/lib/padrino-admin/generators/admin_page.rb +9 -0
  50. data/lib/padrino-admin/generators/orm.rb +1 -10
  51. data/lib/padrino-admin/generators/templates/account/activerecord.rb.tt +1 -1
  52. data/lib/padrino-admin/generators/templates/account/datamapper.rb.tt +1 -1
  53. data/lib/padrino-admin/generators/templates/account/minirecord.rb.tt +1 -1
  54. data/lib/padrino-admin/generators/templates/account/mongoid.rb.tt +1 -1
  55. data/lib/padrino-admin/generators/templates/account/mongomapper.rb.tt +1 -1
  56. data/lib/padrino-admin/generators/templates/account/sequel.rb.tt +1 -1
  57. data/lib/padrino-admin/generators/templates/assets/images/font/FontAwesome.otf +0 -0
  58. data/lib/padrino-admin/generators/templates/assets/images/font/fontawesome-webfont.eot +0 -0
  59. data/lib/padrino-admin/generators/templates/assets/images/font/fontawesome-webfont.svg +153 -38
  60. data/lib/padrino-admin/generators/templates/assets/images/font/fontawesome-webfont.ttf +0 -0
  61. data/lib/padrino-admin/generators/templates/assets/images/font/fontawesome-webfont.woff +0 -0
  62. data/lib/padrino-admin/generators/templates/assets/javascripts/bootstrap/affix.js +120 -0
  63. data/lib/padrino-admin/generators/templates/assets/javascripts/bootstrap/{bootstrap-alert.js → alert.js} +32 -35
  64. data/lib/padrino-admin/generators/templates/assets/javascripts/bootstrap/bootstrap.min.js +1 -1
  65. data/lib/padrino-admin/generators/templates/assets/javascripts/bootstrap/{bootstrap-button.js → button.js} +37 -37
  66. data/lib/padrino-admin/generators/templates/assets/javascripts/bootstrap/carousel.js +210 -0
  67. data/lib/padrino-admin/generators/templates/assets/javascripts/bootstrap/collapse.js +156 -0
  68. data/lib/padrino-admin/generators/templates/assets/javascripts/bootstrap/dropdown.js +155 -0
  69. data/lib/padrino-admin/generators/templates/assets/javascripts/bootstrap/modal.js +243 -0
  70. data/lib/padrino-admin/generators/templates/assets/javascripts/bootstrap/popover.js +111 -0
  71. data/lib/padrino-admin/generators/templates/assets/javascripts/bootstrap/scrollspy.js +156 -0
  72. data/lib/padrino-admin/generators/templates/assets/javascripts/bootstrap/tab.js +133 -0
  73. data/lib/padrino-admin/generators/templates/assets/javascripts/bootstrap/tooltip.js +356 -0
  74. data/lib/padrino-admin/generators/templates/assets/javascripts/bootstrap/transition.js +47 -0
  75. data/lib/padrino-admin/generators/templates/assets/stylesheets/bootstrap.css +406 -452
  76. data/lib/padrino-admin/generators/templates/erb/app/layouts/application.erb.tt +3 -3
  77. data/lib/padrino-admin/generators/templates/erb/app/sessions/new.erb.tt +1 -1
  78. data/lib/padrino-admin/generators/templates/haml/app/layouts/application.haml.tt +3 -3
  79. data/lib/padrino-admin/generators/templates/haml/app/sessions/new.haml.tt +1 -1
  80. data/lib/padrino-admin/generators/templates/page/controller.rb.tt +1 -1
  81. data/lib/padrino-admin/generators/templates/slim/app/layouts/application.slim.tt +3 -3
  82. data/lib/padrino-admin/generators/templates/slim/app/sessions/new.slim.tt +1 -1
  83. data/lib/padrino-admin/helpers/view_helpers.rb +1 -1
  84. data/test/generators/test_admin_app_generator.rb +9 -0
  85. data/test/generators/test_admin_page_generator.rb +11 -0
  86. metadata +27 -23
  87. data/lib/padrino-admin/bootstrap-less/glyphicons.less +0 -200
  88. data/lib/padrino-admin/generators/templates/assets/javascripts/bootstrap/bootstrap-affix.js +0 -117
  89. data/lib/padrino-admin/generators/templates/assets/javascripts/bootstrap/bootstrap-carousel.js +0 -207
  90. data/lib/padrino-admin/generators/templates/assets/javascripts/bootstrap/bootstrap-collapse.js +0 -167
  91. data/lib/padrino-admin/generators/templates/assets/javascripts/bootstrap/bootstrap-dropdown.js +0 -165
  92. data/lib/padrino-admin/generators/templates/assets/javascripts/bootstrap/bootstrap-modal.js +0 -251
  93. data/lib/padrino-admin/generators/templates/assets/javascripts/bootstrap/bootstrap-popover.js +0 -114
  94. data/lib/padrino-admin/generators/templates/assets/javascripts/bootstrap/bootstrap-scrollspy.js +0 -162
  95. data/lib/padrino-admin/generators/templates/assets/javascripts/bootstrap/bootstrap-tab.js +0 -144
  96. data/lib/padrino-admin/generators/templates/assets/javascripts/bootstrap/bootstrap-tooltip.js +0 -361
  97. data/lib/padrino-admin/generators/templates/assets/javascripts/bootstrap/bootstrap-transition.js +0 -60
  98. data/lib/padrino-admin/generators/templates/assets/javascripts/bootstrap/bootstrap-typeahead.js +0 -335
@@ -0,0 +1,111 @@
1
+ /* ========================================================================
2
+ * Bootstrap: popover.js v3.0.0
3
+ * http://twitter.github.com/bootstrap/javascript.html#popovers
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
+
21
+ +function ($) { "use strict";
22
+
23
+ // POPOVER PUBLIC CLASS DEFINITION
24
+ // ===============================
25
+
26
+ var Popover = function (element, options) {
27
+ this.init('popover', element, options)
28
+ }
29
+
30
+ Popover.DEFAULTS = $.extend({} , $.fn.tooltip.Constructor.DEFAULTS, {
31
+ placement: 'right'
32
+ , trigger: 'click'
33
+ , content: ''
34
+ , template: '<div class="popover"><div class="arrow"></div><h3 class="popover-title"></h3><div class="popover-content"></div></div>'
35
+ })
36
+
37
+
38
+ // NOTE: POPOVER EXTENDS tooltip.js
39
+ // ================================
40
+
41
+ Popover.prototype = $.extend({}, $.fn.tooltip.Constructor.prototype)
42
+
43
+ Popover.prototype.constructor = Popover
44
+
45
+ Popover.prototype.getDefaults = function () {
46
+ return Popover.DEFAULTS
47
+ }
48
+
49
+ Popover.prototype.setContent = function () {
50
+ var $tip = this.tip()
51
+ var title = this.getTitle()
52
+ var content = this.getContent()
53
+
54
+ $tip.find('.popover-title')[this.options.html ? 'html' : 'text'](title)
55
+ $tip.find('.popover-content')[this.options.html ? 'html' : 'text'](content)
56
+
57
+ $tip.removeClass('fade top bottom left right in')
58
+
59
+ $tip.find('.popover-title:empty').hide()
60
+ }
61
+
62
+ Popover.prototype.hasContent = function () {
63
+ return this.getTitle() || this.getContent()
64
+ }
65
+
66
+ Popover.prototype.getContent = function () {
67
+ var content = typeof this.options.content == 'function' ?
68
+ this.options.content.call(this.$element[0]) :
69
+ this.options.content
70
+
71
+ return content || this.$element.attr('data-content')
72
+ }
73
+
74
+ Popover.prototype.tip = function () {
75
+ if (!this.$tip) this.$tip = $(this.options.template)
76
+ return this.$tip
77
+ }
78
+
79
+ Popover.prototype.destroy = function () {
80
+ this.hide().$element.off('.' + this.type).removeData(this.type)
81
+ }
82
+
83
+
84
+ // POPOVER PLUGIN DEFINITION
85
+ // =========================
86
+
87
+ var old = $.fn.popover
88
+
89
+ $.fn.popover = function (option) {
90
+ return this.each(function () {
91
+ var $this = $(this)
92
+ var data = $this.data('bs.popover')
93
+ var options = typeof option == 'object' && option
94
+
95
+ if (!data) $this.data('bs.popover', (data = new Popover(this, options)))
96
+ if (typeof option == 'string') data[option]()
97
+ })
98
+ }
99
+
100
+ $.fn.popover.Constructor = Popover
101
+
102
+
103
+ // POPOVER NO CONFLICT
104
+ // ===================
105
+
106
+ $.fn.popover.noConflict = function () {
107
+ $.fn.popover = old
108
+ return this
109
+ }
110
+
111
+ }(window.jQuery);
@@ -0,0 +1,156 @@
1
+ /* ========================================================================
2
+ * Bootstrap: scrollspy.js v3.0.0
3
+ * http://twitter.github.com/bootstrap/javascript.html#scrollspy
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
+
21
+ +function ($) { "use strict";
22
+
23
+ // SCROLLSPY CLASS DEFINITION
24
+ // ==========================
25
+
26
+ function ScrollSpy(element, options) {
27
+ var href
28
+ var process = $.proxy(this.process, this)
29
+ var $element = $(element).is('body') ? $(window) : $(element)
30
+
31
+ this.$body = $('body')
32
+ this.$scrollElement = $element.on('scroll.bs.scroll-spy.data-api', process)
33
+ this.options = $.extend({}, ScrollSpy.DEFAULTS, options)
34
+ this.selector = (this.options.target
35
+ || ((href = $(element).attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '')) //strip for ie7
36
+ || '') + ' .nav li > a'
37
+ this.offsets = $([])
38
+ this.targets = $([])
39
+ this.activeTarget = null
40
+
41
+ this.refresh()
42
+ this.process()
43
+ }
44
+
45
+ ScrollSpy.DEFAULTS = {
46
+ offset: 10
47
+ }
48
+
49
+ ScrollSpy.prototype.refresh = function () {
50
+ this.offsets = $([])
51
+ this.targets = $([])
52
+
53
+ var self = this
54
+ var $targets = this.$body
55
+ .find(this.selector)
56
+ .map(function () {
57
+ var $el = $(this)
58
+ var href = $el.data('target') || $el.attr('href')
59
+ var $href = /^#\w/.test(href) && $(href)
60
+
61
+ return ($href
62
+ && $href.length
63
+ && [[ $href.position().top + (!$.isWindow(self.$scrollElement.get(0)) && self.$scrollElement.scrollTop()), href ]]) || null
64
+ })
65
+ .sort(function (a, b) { return a[0] - b[0] })
66
+ .each(function () {
67
+ self.offsets.push(this[0])
68
+ self.targets.push(this[1])
69
+ })
70
+ }
71
+
72
+ ScrollSpy.prototype.process = function () {
73
+ var scrollTop = this.$scrollElement.scrollTop() + this.options.offset
74
+ var scrollHeight = this.$scrollElement[0].scrollHeight || this.$body[0].scrollHeight
75
+ var maxScroll = scrollHeight - this.$scrollElement.height()
76
+ var offsets = this.offsets
77
+ var targets = this.targets
78
+ var activeTarget = this.activeTarget
79
+ var i
80
+
81
+ if (scrollTop >= maxScroll) {
82
+ return activeTarget != (i = targets.last()[0]) && this.activate(i)
83
+ }
84
+
85
+ for (i = offsets.length; i--;) {
86
+ activeTarget != targets[i]
87
+ && scrollTop >= offsets[i]
88
+ && (!offsets[i + 1] || scrollTop <= offsets[i + 1])
89
+ && this.activate( targets[i] )
90
+ }
91
+ }
92
+
93
+ ScrollSpy.prototype.activate = function (target) {
94
+ this.activeTarget = target
95
+
96
+ $(this.selector)
97
+ .parents('.active')
98
+ .removeClass('active')
99
+
100
+ var selector = this.selector
101
+ + '[data-target="' + target + '"],'
102
+ + this.selector + '[href="' + target + '"]'
103
+
104
+ var active = $(selector)
105
+ .parents('li')
106
+ .addClass('active')
107
+
108
+ if (active.parent('.dropdown-menu').length) {
109
+ active = active
110
+ .closest('li.dropdown')
111
+ .addClass('active')
112
+ }
113
+
114
+ active.trigger('activate')
115
+ }
116
+
117
+
118
+ // SCROLLSPY PLUGIN DEFINITION
119
+ // ===========================
120
+
121
+ var old = $.fn.scrollspy
122
+
123
+ $.fn.scrollspy = function (option) {
124
+ return this.each(function () {
125
+ var $this = $(this)
126
+ var data = $this.data('bs.scrollspy')
127
+ var options = typeof option == 'object' && option
128
+
129
+ if (!data) $this.data('bs.scrollspy', (data = new ScrollSpy(this, options)))
130
+ if (typeof option == 'string') data[option]()
131
+ })
132
+ }
133
+
134
+ $.fn.scrollspy.Constructor = ScrollSpy
135
+
136
+
137
+ // SCROLLSPY NO CONFLICT
138
+ // =====================
139
+
140
+ $.fn.scrollspy.noConflict = function () {
141
+ $.fn.scrollspy = old
142
+ return this
143
+ }
144
+
145
+
146
+ // SCROLLSPY DATA-API
147
+ // ==================
148
+
149
+ $(window).on('load', function () {
150
+ $('[data-spy="scroll"]').each(function () {
151
+ var $spy = $(this)
152
+ $spy.scrollspy($spy.data())
153
+ })
154
+ })
155
+
156
+ }(window.jQuery);
@@ -0,0 +1,133 @@
1
+ /* ========================================================================
2
+ * Bootstrap: tab.js v3.0.0
3
+ * http://twitter.github.com/bootstrap/javascript.html#tabs
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
+
21
+ +function ($) { "use strict";
22
+
23
+ // TAB CLASS DEFINITION
24
+ // ====================
25
+
26
+ var Tab = function (element) {
27
+ this.element = $(element)
28
+ }
29
+
30
+ Tab.prototype.show = function () {
31
+ var $this = this.element
32
+ var $ul = $this.closest('ul:not(.dropdown-menu)')
33
+ var selector = $this.attr('data-target')
34
+
35
+ if (!selector) {
36
+ selector = $this.attr('href')
37
+ selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') //strip for ie7
38
+ }
39
+
40
+ if ($this.parent('li').hasClass('active')) return
41
+
42
+ var previous = $ul.find('.active:last a')[0]
43
+ var e = $.Event('show.bs.tab', {
44
+ relatedTarget: previous
45
+ })
46
+
47
+ $this.trigger(e)
48
+
49
+ if (e.isDefaultPrevented()) return
50
+
51
+ var $target = $(selector)
52
+
53
+ this.activate($this.parent('li'), $ul)
54
+ this.activate($target, $target.parent(), function () {
55
+ $this.trigger({
56
+ type: 'shown.bs.tab'
57
+ , relatedTarget: previous
58
+ })
59
+ })
60
+ }
61
+
62
+ Tab.prototype.activate = function (element, container, callback) {
63
+ var $active = container.find('> .active')
64
+ var transition = callback
65
+ && $.support.transition
66
+ && $active.hasClass('fade')
67
+
68
+ function next() {
69
+ $active
70
+ .removeClass('active')
71
+ .find('> .dropdown-menu > .active')
72
+ .removeClass('active')
73
+
74
+ element.addClass('active')
75
+
76
+ if (transition) {
77
+ element[0].offsetWidth // reflow for transition
78
+ element.addClass('in')
79
+ } else {
80
+ element.removeClass('fade')
81
+ }
82
+
83
+ if (element.parent('.dropdown-menu')) {
84
+ element.closest('li.dropdown').addClass('active')
85
+ }
86
+
87
+ callback && callback()
88
+ }
89
+
90
+ transition ?
91
+ $active.one($.support.transition.end, next) :
92
+ next()
93
+
94
+ $active.removeClass('in')
95
+ }
96
+
97
+
98
+ // TAB PLUGIN DEFINITION
99
+ // =====================
100
+
101
+ var old = $.fn.tab
102
+
103
+ $.fn.tab = function ( option ) {
104
+ return this.each(function () {
105
+ var $this = $(this)
106
+ var data = $this.data('bs.tab')
107
+
108
+ if (!data) $this.data('bs.tab', (data = new Tab(this)))
109
+ if (typeof option == 'string') data[option]()
110
+ })
111
+ }
112
+
113
+ $.fn.tab.Constructor = Tab
114
+
115
+
116
+ // TAB NO CONFLICT
117
+ // ===============
118
+
119
+ $.fn.tab.noConflict = function () {
120
+ $.fn.tab = old
121
+ return this
122
+ }
123
+
124
+
125
+ // TAB DATA-API
126
+ // ============
127
+
128
+ $(document).on('click.bs.tab.data-api', '[data-toggle="tab"], [data-toggle="pill"]', function (e) {
129
+ e.preventDefault()
130
+ $(this).tab('show')
131
+ })
132
+
133
+ }(window.jQuery);
@@ -0,0 +1,356 @@
1
+ /* ========================================================================
2
+ * Bootstrap: tooltip.js v3.0.0
3
+ * http://twitter.github.com/bootstrap/javascript.html#affix
4
+ * Inspired by the original jQuery.tipsy by Jason Frame
5
+ * ========================================================================
6
+ * Copyright 2012 Twitter, Inc.
7
+ *
8
+ * Licensed under the Apache License, Version 2.0 (the "License");
9
+ * you may not use this file except in compliance with the License.
10
+ * You may obtain a copy of the License at
11
+ *
12
+ * http://www.apache.org/licenses/LICENSE-2.0
13
+ *
14
+ * Unless required by applicable law or agreed to in writing, software
15
+ * distributed under the License is distributed on an "AS IS" BASIS,
16
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
+ * See the License for the specific language governing permissions and
18
+ * limitations under the License.
19
+ * ======================================================================== */
20
+
21
+
22
+ +function ($) { "use strict";
23
+
24
+ // TOOLTIP PUBLIC CLASS DEFINITION
25
+ // ===============================
26
+
27
+ var Tooltip = function (element, options) {
28
+ this.type =
29
+ this.options =
30
+ this.enabled =
31
+ this.timeout =
32
+ this.hoverState =
33
+ this.$element = null
34
+
35
+ this.init('tooltip', element, options)
36
+ }
37
+
38
+ Tooltip.DEFAULTS = {
39
+ animation: true
40
+ , placement: 'top'
41
+ , selector: false
42
+ , template: '<div class="tooltip"><div class="tooltip-arrow"></div><div class="tooltip-inner"></div></div>'
43
+ , trigger: 'hover focus'
44
+ , title: ''
45
+ , delay: 0
46
+ , html: false
47
+ , container: false
48
+ }
49
+
50
+ Tooltip.prototype.init = function (type, element, options) {
51
+ this.enabled = true
52
+ this.type = type
53
+ this.$element = $(element)
54
+ this.options = this.getOptions(options)
55
+
56
+ var triggers = this.options.trigger.split(' ')
57
+
58
+ for (var i = triggers.length; i--;) {
59
+ var trigger = triggers[i]
60
+
61
+ if (trigger == 'click') {
62
+ this.$element.on('click.' + this.type, this.options.selector, $.proxy(this.toggle, this))
63
+ } else if (trigger != 'manual') {
64
+ var eventIn = trigger == 'hover' ? 'mouseenter' : 'focus'
65
+ var eventOut = trigger == 'hover' ? 'mouseleave' : 'blur'
66
+
67
+ this.$element.on(eventIn + '.' + this.type, this.options.selector, $.proxy(this.enter, this))
68
+ this.$element.on(eventOut + '.' + this.type, this.options.selector, $.proxy(this.leave, this))
69
+ }
70
+ }
71
+
72
+ this.options.selector ?
73
+ (this._options = $.extend({}, this.options, { trigger: 'manual', selector: '' })) :
74
+ this.fixTitle()
75
+ }
76
+
77
+ Tooltip.prototype.getDefaults = function () {
78
+ return Tooltip.DEFAULTS
79
+ }
80
+
81
+ Tooltip.prototype.getOptions = function (options) {
82
+ options = $.extend({}, this.getDefaults(), this.$element.data(), options)
83
+
84
+ if (options.delay && typeof options.delay == 'number') {
85
+ options.delay = {
86
+ show: options.delay
87
+ , hide: options.delay
88
+ }
89
+ }
90
+
91
+ return options
92
+ }
93
+
94
+ Tooltip.prototype.enter = function (obj) {
95
+ var defaults = this.getDefaults()
96
+ var options = {}
97
+
98
+ this._options && $.each(this._options, function (key, value) {
99
+ if (defaults[key] != value) options[key] = value
100
+ })
101
+
102
+ var self = obj instanceof this.constructor ?
103
+ obj : $(obj.currentTarget)[this.type](options).data('bs.' + this.type)
104
+
105
+ if (!self.options.delay || !self.options.delay.show) return self.show()
106
+
107
+ clearTimeout(this.timeout)
108
+
109
+ self.hoverState = 'in'
110
+ this.timeout = setTimeout(function () {
111
+ if (self.hoverState == 'in') self.show()
112
+ }, self.options.delay.show)
113
+ }
114
+
115
+ Tooltip.prototype.leave = function (obj) {
116
+ var self = obj instanceof this.constructor ?
117
+ obj : $(obj.currentTarget)[this.type](this._options).data('bs.' + this.type)
118
+
119
+ clearTimeout(this.timeout)
120
+
121
+ if (!self.options.delay || !self.options.delay.hide) return self.hide()
122
+
123
+ self.hoverState = 'out'
124
+ this.timeout = setTimeout(function () {
125
+ if (self.hoverState == 'out') self.hide()
126
+ }, self.options.delay.hide)
127
+ }
128
+
129
+ Tooltip.prototype.show = function () {
130
+ var e = $.Event('show.bs.'+ this.type)
131
+
132
+ if (this.hasContent() && this.enabled) {
133
+ this.$element.trigger(e)
134
+
135
+ if (e.isDefaultPrevented()) return
136
+
137
+ var $tip = this.tip()
138
+
139
+ this.setContent()
140
+
141
+ if (this.options.animation) $tip.addClass('fade')
142
+
143
+ var placement = typeof this.options.placement == 'function' ?
144
+ this.options.placement.call(this, $tip[0], this.$element[0]) :
145
+ this.options.placement
146
+
147
+ $tip
148
+ .detach()
149
+ .css({ top: 0, left: 0, display: 'block' })
150
+
151
+ this.options.container ? $tip.appendTo(this.options.container) : $tip.insertAfter(this.$element)
152
+
153
+ var tp
154
+ var pos = this.getPosition()
155
+ var actualWidth = $tip[0].offsetWidth
156
+ var actualHeight = $tip[0].offsetHeight
157
+
158
+ switch (placement) {
159
+ case 'bottom':
160
+ tp = {top: pos.top + pos.height, left: pos.left + pos.width / 2 - actualWidth / 2}
161
+ break
162
+ case 'top':
163
+ tp = {top: pos.top - actualHeight, left: pos.left + pos.width / 2 - actualWidth / 2}
164
+ break
165
+ case 'left':
166
+ tp = {top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left - actualWidth}
167
+ break
168
+ case 'right':
169
+ tp = {top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left + pos.width}
170
+ break
171
+ }
172
+
173
+ this.applyPlacement(tp, placement)
174
+ this.$element.trigger('shown.bs.' + this.type)
175
+ }
176
+ }
177
+
178
+ Tooltip.prototype.applyPlacement = function(offset, placement) {
179
+ var replace
180
+ var $tip = this.tip()
181
+ var width = $tip[0].offsetWidth
182
+ var height = $tip[0].offsetHeight
183
+
184
+ $tip
185
+ .offset(offset)
186
+ .addClass(placement)
187
+ .addClass('in')
188
+
189
+ var actualWidth = $tip[0].offsetWidth
190
+ var actualHeight = $tip[0].offsetHeight
191
+
192
+ if (placement == 'top' && actualHeight != height) {
193
+ replace = true
194
+ offset.top = offset.top + height - actualHeight
195
+ }
196
+
197
+ if (placement == 'bottom' || placement == 'top') {
198
+ var delta = 0
199
+
200
+ if (offset.left < 0){
201
+ delta = offset.left * -2
202
+ offset.left = 0
203
+
204
+ $tip.offset(offset)
205
+
206
+ actualWidth = $tip[0].offsetWidth
207
+ actualHeight = $tip[0].offsetHeight
208
+ }
209
+
210
+ this.replaceArrow(delta - width + actualWidth, actualWidth, 'left')
211
+ } else {
212
+ this.replaceArrow(actualHeight - height, actualHeight, 'top')
213
+ }
214
+
215
+ if (replace) $tip.offset(offset)
216
+ }
217
+
218
+ Tooltip.prototype.replaceArrow = function(delta, dimension, position) {
219
+ this.arrow().css(position, delta ? (50 * (1 - delta / dimension) + "%") : '')
220
+ }
221
+
222
+ Tooltip.prototype.setContent = function () {
223
+ var $tip = this.tip()
224
+ var title = this.getTitle()
225
+
226
+ $tip.find('.tooltip-inner')[this.options.html ? 'html' : 'text'](title)
227
+ $tip.removeClass('fade in top bottom left right')
228
+ }
229
+
230
+ Tooltip.prototype.hide = function () {
231
+ var that = this
232
+ var $tip = this.tip()
233
+ var e = $.Event('hide.bs.' + this.type)
234
+
235
+ this.$element.trigger(e)
236
+
237
+ if (e.isDefaultPrevented()) return
238
+
239
+ $tip.removeClass('in')
240
+
241
+ function removeWithAnimation() {
242
+ var timeout = setTimeout(function () {
243
+ $tip.off($.support.transition.end).detach()
244
+ }, 500)
245
+
246
+ $tip.one($.support.transition.end, function () {
247
+ clearTimeout(timeout)
248
+ $tip.detach()
249
+ })
250
+ }
251
+
252
+ $.support.transition && this.$tip.hasClass('fade') ?
253
+ removeWithAnimation() :
254
+ $tip.detach()
255
+
256
+ this.$element.trigger('hidden.bs.' + this.type)
257
+
258
+ return this
259
+ }
260
+
261
+ Tooltip.prototype.fixTitle = function () {
262
+ var $e = this.$element
263
+ if ($e.attr('title') || typeof($e.attr('data-original-title')) != 'string') {
264
+ $e.attr('data-original-title', $e.attr('title') || '').attr('title', '')
265
+ }
266
+ }
267
+
268
+ Tooltip.prototype.hasContent = function () {
269
+ return this.getTitle()
270
+ }
271
+
272
+ Tooltip.prototype.getPosition = function () {
273
+ var el = this.$element[0]
274
+ return $.extend({}, (typeof el.getBoundingClientRect == 'function') ? el.getBoundingClientRect() : {
275
+ width: el.offsetWidth
276
+ , height: el.offsetHeight
277
+ }, this.$element.offset())
278
+ }
279
+
280
+ Tooltip.prototype.getTitle = function () {
281
+ var title
282
+ var $e = this.$element
283
+ var o = this.options
284
+
285
+ title = $e.attr('data-original-title')
286
+ || (typeof o.title == 'function' ? o.title.call($e[0]) : o.title)
287
+
288
+ return title
289
+ }
290
+
291
+ Tooltip.prototype.tip = function () {
292
+ return this.$tip = this.$tip || $(this.options.template)
293
+ }
294
+
295
+ Tooltip.prototype.arrow =function(){
296
+ return this.$arrow = this.$arrow || this.tip().find(".tooltip-arrow")
297
+ }
298
+
299
+ Tooltip.prototype.validate = function () {
300
+ if (!this.$element[0].parentNode) {
301
+ this.hide()
302
+ this.$element = null
303
+ this.options = null
304
+ }
305
+ }
306
+
307
+ Tooltip.prototype.enable = function () {
308
+ this.enabled = true
309
+ }
310
+
311
+ Tooltip.prototype.disable = function () {
312
+ this.enabled = false
313
+ }
314
+
315
+ Tooltip.prototype.toggleEnabled = function () {
316
+ this.enabled = !this.enabled
317
+ }
318
+
319
+ Tooltip.prototype.toggle = function (e) {
320
+ var self = e ? $(e.currentTarget)[this.type](this._options).data('bs.' + this.type) : this
321
+ self.tip().hasClass('in') ? self.leave(self) : self.enter(self)
322
+ }
323
+
324
+ Tooltip.prototype.destroy = function () {
325
+ this.hide().$element.off('.' + this.type).removeData('bs.' + this.type)
326
+ }
327
+
328
+
329
+ // TOOLTIP PLUGIN DEFINITION
330
+ // =========================
331
+
332
+ var old = $.fn.tooltip
333
+
334
+ $.fn.tooltip = function (option) {
335
+ return this.each(function () {
336
+ var $this = $(this)
337
+ var data = $this.data('bs.tooltip')
338
+ var options = typeof option == 'object' && option
339
+
340
+ if (!data) $this.data('bs.tooltip', (data = new Tooltip(this, options)))
341
+ if (typeof option == 'string') data[option]()
342
+ })
343
+ }
344
+
345
+ $.fn.tooltip.Constructor = Tooltip
346
+
347
+
348
+ // TOOLTIP NO CONFLICT
349
+ // ===================
350
+
351
+ $.fn.tooltip.noConflict = function () {
352
+ $.fn.tooltip = old
353
+ return this
354
+ }
355
+
356
+ }(window.jQuery);