compass_twitter_bootstrap 2.2.2.2 → 2.3.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (83) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG.md +3 -0
  3. data/README.md +5 -4
  4. data/lib/compass_twitter_bootstrap/version.rb +1 -1
  5. data/stylesheets/_compass_twitter_bootstrap.scss +15 -5
  6. data/stylesheets/_compass_twitter_bootstrap_awesome.scss +17 -6
  7. data/stylesheets/_compass_twitter_bootstrap_responsive.scss +17 -5
  8. data/stylesheets/compass_twitter_bootstrap/_button-groups.scss +4 -2
  9. data/stylesheets/compass_twitter_bootstrap/_buttons.scss +9 -11
  10. data/stylesheets/compass_twitter_bootstrap/_carousel.scss +34 -7
  11. data/stylesheets/compass_twitter_bootstrap/_close.scss +2 -1
  12. data/stylesheets/compass_twitter_bootstrap/_dropdowns.scss +16 -12
  13. data/stylesheets/compass_twitter_bootstrap/_forms.scss +5 -2
  14. data/stylesheets/compass_twitter_bootstrap/_labels-badges.scss +4 -2
  15. data/stylesheets/compass_twitter_bootstrap/_media.scss +2 -2
  16. data/stylesheets/compass_twitter_bootstrap/_mixins.scss +39 -8
  17. data/stylesheets/compass_twitter_bootstrap/_navbar.scss +20 -13
  18. data/stylesheets/compass_twitter_bootstrap/_navs.scss +39 -21
  19. data/stylesheets/compass_twitter_bootstrap/_pager.scss +3 -1
  20. data/stylesheets/compass_twitter_bootstrap/_pagination.scss +3 -1
  21. data/stylesheets/compass_twitter_bootstrap/_popovers.scss +5 -1
  22. data/stylesheets/compass_twitter_bootstrap/_responsive-767px-max.scss +2 -2
  23. data/stylesheets/compass_twitter_bootstrap/_responsive-navbar.scss +6 -2
  24. data/stylesheets/compass_twitter_bootstrap/_responsive-utilities.scss +16 -0
  25. data/stylesheets/compass_twitter_bootstrap/_scaffolding.scss +2 -1
  26. data/stylesheets/compass_twitter_bootstrap/_sprites.scss +7 -3
  27. data/stylesheets/compass_twitter_bootstrap/_tables.scss +24 -17
  28. data/stylesheets/compass_twitter_bootstrap/_thumbnails.scss +3 -2
  29. data/stylesheets/compass_twitter_bootstrap/_tooltip.scss +6 -6
  30. data/stylesheets/compass_twitter_bootstrap/_type.scss +19 -7
  31. data/stylesheets/compass_twitter_bootstrap/_utilities.scss +1 -3
  32. data/stylesheets/compass_twitter_bootstrap/_variables.scss +4 -4
  33. data/stylesheets_sass/_compass_twitter_bootstrap.sass +14 -6
  34. data/stylesheets_sass/_compass_twitter_bootstrap_awesome.sass +16 -7
  35. data/stylesheets_sass/_compass_twitter_bootstrap_responsive.sass +14 -5
  36. data/stylesheets_sass/compass_twitter_bootstrap/_button-groups.sass +4 -3
  37. data/stylesheets_sass/compass_twitter_bootstrap/_buttons.sass +9 -11
  38. data/stylesheets_sass/compass_twitter_bootstrap/_carousel.sass +30 -6
  39. data/stylesheets_sass/compass_twitter_bootstrap/_close.sass +2 -1
  40. data/stylesheets_sass/compass_twitter_bootstrap/_code.sass +1 -1
  41. data/stylesheets_sass/compass_twitter_bootstrap/_dropdowns.sass +18 -13
  42. data/stylesheets_sass/compass_twitter_bootstrap/_font-awesome.sass +339 -46
  43. data/stylesheets_sass/compass_twitter_bootstrap/_forms.sass +12 -15
  44. data/stylesheets_sass/compass_twitter_bootstrap/_labels-badges.sass +4 -2
  45. data/stylesheets_sass/compass_twitter_bootstrap/_media.sass +2 -2
  46. data/stylesheets_sass/compass_twitter_bootstrap/_mixins.sass +41 -7
  47. data/stylesheets_sass/compass_twitter_bootstrap/_modals.sass +4 -4
  48. data/stylesheets_sass/compass_twitter_bootstrap/_navbar.sass +23 -14
  49. data/stylesheets_sass/compass_twitter_bootstrap/_navs.sass +51 -30
  50. data/stylesheets_sass/compass_twitter_bootstrap/_pager.sass +4 -2
  51. data/stylesheets_sass/compass_twitter_bootstrap/_pagination.sass +3 -1
  52. data/stylesheets_sass/compass_twitter_bootstrap/_popovers.sass +4 -2
  53. data/stylesheets_sass/compass_twitter_bootstrap/_reset.sass +2 -2
  54. data/stylesheets_sass/compass_twitter_bootstrap/_responsive-767px-max.sass +1 -1
  55. data/stylesheets_sass/compass_twitter_bootstrap/_responsive-navbar.sass +6 -2
  56. data/stylesheets_sass/compass_twitter_bootstrap/_responsive-utilities.sass +19 -0
  57. data/stylesheets_sass/compass_twitter_bootstrap/_scaffolding.sass +3 -2
  58. data/stylesheets_sass/compass_twitter_bootstrap/_sprites.sass +8 -3
  59. data/stylesheets_sass/compass_twitter_bootstrap/_tables.sass +24 -16
  60. data/stylesheets_sass/compass_twitter_bootstrap/_thumbnails.sass +5 -3
  61. data/stylesheets_sass/compass_twitter_bootstrap/_tooltip.sass +6 -2
  62. data/stylesheets_sass/compass_twitter_bootstrap/_type.sass +24 -7
  63. data/stylesheets_sass/compass_twitter_bootstrap/_utilities.sass +0 -3
  64. data/stylesheets_sass/compass_twitter_bootstrap/_variables.sass +4 -4
  65. data/vendor/assets/images/glyphicons-halflings-white.png +0 -0
  66. data/vendor/assets/images/glyphicons-halflings.png +0 -0
  67. data/vendor/assets/javascripts/bootstrap-affix.js +1 -1
  68. data/vendor/assets/javascripts/bootstrap-alert.js +1 -1
  69. data/vendor/assets/javascripts/bootstrap-all.js +0 -1
  70. data/vendor/assets/javascripts/bootstrap-button.js +1 -1
  71. data/vendor/assets/javascripts/bootstrap-carousel.js +32 -10
  72. data/vendor/assets/javascripts/bootstrap-collapse.js +4 -4
  73. data/vendor/assets/javascripts/bootstrap-dropdown.js +14 -10
  74. data/vendor/assets/javascripts/bootstrap-modal.js +14 -12
  75. data/vendor/assets/javascripts/bootstrap-popover.js +5 -5
  76. data/vendor/assets/javascripts/bootstrap-scrollspy.js +2 -2
  77. data/vendor/assets/javascripts/bootstrap-tab.js +1 -1
  78. data/vendor/assets/javascripts/bootstrap-tooltip.js +104 -30
  79. data/vendor/assets/javascripts/bootstrap-transition.js +1 -1
  80. data/vendor/assets/javascripts/bootstrap-typeahead.js +16 -4
  81. metadata +10 -22
  82. data/stylesheets/compass_twitter_bootstrap/_responsive.scss +0 -48
  83. data/stylesheets_sass/compass_twitter_bootstrap/_responsive.sass +0 -44
@@ -1,5 +1,5 @@
1
1
  /* ==========================================================
2
- * bootstrap-affix.js v2.2.2
2
+ * bootstrap-affix.js v2.3.1
3
3
  * http://twitter.github.com/bootstrap/javascript.html#affix
4
4
  * ==========================================================
5
5
  * Copyright 2012 Twitter, Inc.
@@ -1,5 +1,5 @@
1
1
  /* ==========================================================
2
- * bootstrap-alert.js v2.2.2
2
+ * bootstrap-alert.js v2.3.1
3
3
  * http://twitter.github.com/bootstrap/javascript.html#alerts
4
4
  * ==========================================================
5
5
  * Copyright 2012 Twitter, Inc.
@@ -1,5 +1,4 @@
1
1
  //=require bootstrap-transition
2
- //=require bootstrap-affix
3
2
  //=require bootstrap-alert
4
3
  //-require bootstrap-affix
5
4
  //=require bootstrap-modal
@@ -1,5 +1,5 @@
1
1
  /* ============================================================
2
- * bootstrap-button.js v2.2.2
2
+ * bootstrap-button.js v2.3.1
3
3
  * http://twitter.github.com/bootstrap/javascript.html#buttons
4
4
  * ============================================================
5
5
  * Copyright 2012 Twitter, Inc.
@@ -1,5 +1,5 @@
1
1
  /* ==========================================================
2
- * bootstrap-carousel.js v2.2.2
2
+ * bootstrap-carousel.js v2.3.1
3
3
  * http://twitter.github.com/bootstrap/javascript.html#carousel
4
4
  * ==========================================================
5
5
  * Copyright 2012 Twitter, Inc.
@@ -28,6 +28,7 @@
28
28
 
29
29
  var Carousel = function (element, options) {
30
30
  this.$element = $(element)
31
+ this.$indicators = this.$element.find('.carousel-indicators')
31
32
  this.options = options
32
33
  this.options.pause == 'hover' && this.$element
33
34
  .on('mouseenter', $.proxy(this.pause, this))
@@ -38,19 +39,24 @@
38
39
 
39
40
  cycle: function (e) {
40
41
  if (!e) this.paused = false
42
+ if (this.interval) clearInterval(this.interval);
41
43
  this.options.interval
42
44
  && !this.paused
43
45
  && (this.interval = setInterval($.proxy(this.next, this), this.options.interval))
44
46
  return this
45
47
  }
46
48
 
49
+ , getActiveIndex: function () {
50
+ this.$active = this.$element.find('.item.active')
51
+ this.$items = this.$active.parent().children()
52
+ return this.$items.index(this.$active)
53
+ }
54
+
47
55
  , to: function (pos) {
48
- var $active = this.$element.find('.item.active')
49
- , children = $active.parent().children()
50
- , activePos = children.index($active)
56
+ var activeIndex = this.getActiveIndex()
51
57
  , that = this
52
58
 
53
- if (pos > (children.length - 1) || pos < 0) return
59
+ if (pos > (this.$items.length - 1) || pos < 0) return
54
60
 
55
61
  if (this.sliding) {
56
62
  return this.$element.one('slid', function () {
@@ -58,18 +64,18 @@
58
64
  })
59
65
  }
60
66
 
61
- if (activePos == pos) {
67
+ if (activeIndex == pos) {
62
68
  return this.pause().cycle()
63
69
  }
64
70
 
65
- return this.slide(pos > activePos ? 'next' : 'prev', $(children[pos]))
71
+ return this.slide(pos > activeIndex ? 'next' : 'prev', $(this.$items[pos]))
66
72
  }
67
73
 
68
74
  , pause: function (e) {
69
75
  if (!e) this.paused = true
70
76
  if (this.$element.find('.next, .prev').length && $.support.transition.end) {
71
77
  this.$element.trigger($.support.transition.end)
72
- this.cycle()
78
+ this.cycle(true)
73
79
  }
74
80
  clearInterval(this.interval)
75
81
  this.interval = null
@@ -103,10 +109,19 @@
103
109
 
104
110
  e = $.Event('slide', {
105
111
  relatedTarget: $next[0]
112
+ , direction: direction
106
113
  })
107
114
 
108
115
  if ($next.hasClass('active')) return
109
116
 
117
+ if (this.$indicators.length) {
118
+ this.$indicators.find('.active').removeClass('active')
119
+ this.$element.one('slid', function () {
120
+ var $nextIndicator = $(that.$indicators.children()[that.getActiveIndex()])
121
+ $nextIndicator && $nextIndicator.addClass('active')
122
+ })
123
+ }
124
+
110
125
  if ($.support.transition && this.$element.hasClass('slide')) {
111
126
  this.$element.trigger(e)
112
127
  if (e.isDefaultPrevented()) return
@@ -151,7 +166,7 @@
151
166
  if (!data) $this.data('carousel', (data = new Carousel(this, options)))
152
167
  if (typeof option == 'number') data.to(option)
153
168
  else if (action) data[action]()
154
- else if (options.interval) data.cycle()
169
+ else if (options.interval) data.pause().cycle()
155
170
  })
156
171
  }
157
172
 
@@ -174,11 +189,18 @@
174
189
  /* CAROUSEL DATA-API
175
190
  * ================= */
176
191
 
177
- $(document).on('click.carousel.data-api', '[data-slide]', function (e) {
192
+ $(document).on('click.carousel.data-api', '[data-slide], [data-slide-to]', function (e) {
178
193
  var $this = $(this), href
179
194
  , $target = $($this.attr('data-target') || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '')) //strip for ie7
180
195
  , options = $.extend({}, $target.data(), $this.data())
196
+ , slideIndex
197
+
181
198
  $target.carousel(options)
199
+
200
+ if (slideIndex = $this.attr('data-slide-to')) {
201
+ $target.data('carousel').pause().to(slideIndex).cycle()
202
+ }
203
+
182
204
  e.preventDefault()
183
205
  })
184
206
 
@@ -1,5 +1,5 @@
1
1
  /* =============================================================
2
- * bootstrap-collapse.js v2.2.2
2
+ * bootstrap-collapse.js v2.3.1
3
3
  * http://twitter.github.com/bootstrap/javascript.html#collapse
4
4
  * =============================================================
5
5
  * Copyright 2012 Twitter, Inc.
@@ -52,7 +52,7 @@
52
52
  , actives
53
53
  , hasData
54
54
 
55
- if (this.transitioning) return
55
+ if (this.transitioning || this.$element.hasClass('in')) return
56
56
 
57
57
  dimension = this.dimension()
58
58
  scroll = $.camelCase(['scroll', dimension].join('-'))
@@ -72,7 +72,7 @@
72
72
 
73
73
  , hide: function () {
74
74
  var dimension
75
- if (this.transitioning) return
75
+ if (this.transitioning || !this.$element.hasClass('in')) return
76
76
  dimension = this.dimension()
77
77
  this.reset(this.$element[dimension]())
78
78
  this.transition('removeClass', $.Event('hide'), 'hidden')
@@ -129,7 +129,7 @@
129
129
  return this.each(function () {
130
130
  var $this = $(this)
131
131
  , data = $this.data('collapse')
132
- , options = typeof option == 'object' && option
132
+ , options = $.extend({}, $.fn.collapse.defaults, $this.data(), typeof option == 'object' && option)
133
133
  if (!data) $this.data('collapse', (data = new Collapse(this, options)))
134
134
  if (typeof option == 'string') data[option]()
135
135
  })
@@ -1,5 +1,5 @@
1
1
  /* ============================================================
2
- * bootstrap-dropdown.js v2.2.2
2
+ * bootstrap-dropdown.js v2.3.1
3
3
  * http://twitter.github.com/bootstrap/javascript.html#dropdowns
4
4
  * ============================================================
5
5
  * Copyright 2012 Twitter, Inc.
@@ -81,7 +81,10 @@
81
81
 
82
82
  isActive = $parent.hasClass('open')
83
83
 
84
- if (!isActive || (isActive && e.keyCode == 27)) return $this.click()
84
+ if (!isActive || (isActive && e.keyCode == 27)) {
85
+ if (e.which == 27) $parent.find(toggle).focus()
86
+ return $this.click()
87
+ }
85
88
 
86
89
  $items = $('[role=menu] li:not(.divider):visible a', $parent)
87
90
 
@@ -115,8 +118,9 @@
115
118
  selector = selector && /#/.test(selector) && selector.replace(/.*(?=#[^\s]*$)/, '') //strip for ie7
116
119
  }
117
120
 
118
- $parent = $(selector)
119
- $parent.length || ($parent = $this.parent())
121
+ $parent = selector && $(selector)
122
+
123
+ if (!$parent || !$parent.length) $parent = $this.parent()
120
124
 
121
125
  return $parent
122
126
  }
@@ -152,10 +156,10 @@
152
156
  * =================================== */
153
157
 
154
158
  $(document)
155
- .on('click.dropdown.data-api touchstart.dropdown.data-api', clearMenus)
156
- .on('click.dropdown touchstart.dropdown.data-api', '.dropdown form', function (e) { e.stopPropagation() })
157
- .on('touchstart.dropdown.data-api', '.dropdown-menu', function (e) { e.stopPropagation() })
158
- .on('click.dropdown.data-api touchstart.dropdown.data-api' , toggle, Dropdown.prototype.toggle)
159
- .on('keydown.dropdown.data-api touchstart.dropdown.data-api', toggle + ', [role=menu]' , Dropdown.prototype.keydown)
159
+ .on('click.dropdown.data-api', clearMenus)
160
+ .on('click.dropdown.data-api', '.dropdown form', function (e) { e.stopPropagation() })
161
+ .on('click.dropdown-menu', function (e) { e.stopPropagation() })
162
+ .on('click.dropdown.data-api' , toggle, Dropdown.prototype.toggle)
163
+ .on('keydown.dropdown.data-api', toggle + ', [role=menu]' , Dropdown.prototype.keydown)
160
164
 
161
- }(window.jQuery);
165
+ }(window.jQuery);
@@ -1,5 +1,5 @@
1
1
  /* =========================================================
2
- * bootstrap-modal.js v2.2.2
2
+ * bootstrap-modal.js v2.3.1
3
3
  * http://twitter.github.com/bootstrap/javascript.html#modals
4
4
  * =========================================================
5
5
  * Copyright 2012 Twitter, Inc.
@@ -60,8 +60,7 @@
60
60
  that.$element.appendTo(document.body) //don't move modals dom position
61
61
  }
62
62
 
63
- that.$element
64
- .show()
63
+ that.$element.show()
65
64
 
66
65
  if (transition) {
67
66
  that.$element[0].offsetWidth // force reflow
@@ -139,16 +138,17 @@
139
138
  })
140
139
  }
141
140
 
142
- , hideModal: function (that) {
143
- this.$element
144
- .hide()
145
- .trigger('hidden')
146
-
147
- this.backdrop()
141
+ , hideModal: function () {
142
+ var that = this
143
+ this.$element.hide()
144
+ this.backdrop(function () {
145
+ that.removeBackdrop()
146
+ that.$element.trigger('hidden')
147
+ })
148
148
  }
149
149
 
150
150
  , removeBackdrop: function () {
151
- this.$backdrop.remove()
151
+ this.$backdrop && this.$backdrop.remove()
152
152
  this.$backdrop = null
153
153
  }
154
154
 
@@ -172,6 +172,8 @@
172
172
 
173
173
  this.$backdrop.addClass('in')
174
174
 
175
+ if (!callback) return
176
+
175
177
  doAnimate ?
176
178
  this.$backdrop.one($.support.transition.end, callback) :
177
179
  callback()
@@ -180,8 +182,8 @@
180
182
  this.$backdrop.removeClass('in')
181
183
 
182
184
  $.support.transition && this.$element.hasClass('fade')?
183
- this.$backdrop.one($.support.transition.end, $.proxy(this.removeBackdrop, this)) :
184
- this.removeBackdrop()
185
+ this.$backdrop.one($.support.transition.end, callback) :
186
+ callback()
185
187
 
186
188
  } else if (callback) {
187
189
  callback()
@@ -1,5 +1,5 @@
1
1
  /* ===========================================================
2
- * bootstrap-popover.js v2.2.2
2
+ * bootstrap-popover.js v2.3.1
3
3
  * http://twitter.github.com/bootstrap/javascript.html#popovers
4
4
  * ===========================================================
5
5
  * Copyright 2012 Twitter, Inc.
@@ -58,8 +58,8 @@
58
58
  , $e = this.$element
59
59
  , o = this.options
60
60
 
61
- content = $e.attr('data-content')
62
- || (typeof o.content == 'function' ? o.content.call($e[0]) : o.content)
61
+ content = (typeof o.content == 'function' ? o.content.call($e[0]) : o.content)
62
+ || $e.attr('data-content')
63
63
 
64
64
  return content
65
65
  }
@@ -99,7 +99,7 @@
99
99
  placement: 'right'
100
100
  , trigger: 'click'
101
101
  , content: ''
102
- , template: '<div class="popover"><div class="arrow"></div><div class="popover-inner"><h3 class="popover-title"></h3><div class="popover-content"></div></div></div>'
102
+ , template: '<div class="popover"><div class="arrow"></div><h3 class="popover-title"></h3><div class="popover-content"></div></div>'
103
103
  })
104
104
 
105
105
 
@@ -111,4 +111,4 @@
111
111
  return this
112
112
  }
113
113
 
114
- }(window.jQuery);
114
+ }(window.jQuery);
@@ -1,5 +1,5 @@
1
1
  /* =============================================================
2
- * bootstrap-scrollspy.js v2.2.2
2
+ * bootstrap-scrollspy.js v2.3.1
3
3
  * http://twitter.github.com/bootstrap/javascript.html#scrollspy
4
4
  * =============================================================
5
5
  * Copyright 2012 Twitter, Inc.
@@ -59,7 +59,7 @@
59
59
  , $href = /^#\w/.test(href) && $(href)
60
60
  return ( $href
61
61
  && $href.length
62
- && [[ $href.position().top + self.$scrollElement.scrollTop(), href ]] ) || null
62
+ && [[ $href.position().top + (!$.isWindow(self.$scrollElement.get(0)) && self.$scrollElement.scrollTop()), href ]] ) || null
63
63
  })
64
64
  .sort(function (a, b) { return a[0] - b[0] })
65
65
  .each(function () {
@@ -1,5 +1,5 @@
1
1
  /* ========================================================
2
- * bootstrap-tab.js v2.2.2
2
+ * bootstrap-tab.js v2.3.1
3
3
  * http://twitter.github.com/bootstrap/javascript.html#tabs
4
4
  * ========================================================
5
5
  * Copyright 2012 Twitter, Inc.
@@ -1,5 +1,5 @@
1
1
  /* ===========================================================
2
- * bootstrap-tooltip.js v2.2.2
2
+ * bootstrap-tooltip.js v2.3.1
3
3
  * http://twitter.github.com/bootstrap/javascript.html#tooltips
4
4
  * Inspired by the original jQuery.tipsy by Jason Frame
5
5
  * ===========================================================
@@ -38,19 +38,27 @@
38
38
  , init: function (type, element, options) {
39
39
  var eventIn
40
40
  , eventOut
41
+ , triggers
42
+ , trigger
43
+ , i
41
44
 
42
45
  this.type = type
43
46
  this.$element = $(element)
44
47
  this.options = this.getOptions(options)
45
48
  this.enabled = true
46
49
 
47
- if (this.options.trigger == 'click') {
48
- this.$element.on('click.' + this.type, this.options.selector, $.proxy(this.toggle, this))
49
- } else if (this.options.trigger != 'manual') {
50
- eventIn = this.options.trigger == 'hover' ? 'mouseenter' : 'focus'
51
- eventOut = this.options.trigger == 'hover' ? 'mouseleave' : 'blur'
52
- this.$element.on(eventIn + '.' + this.type, this.options.selector, $.proxy(this.enter, this))
53
- this.$element.on(eventOut + '.' + this.type, this.options.selector, $.proxy(this.leave, this))
50
+ triggers = this.options.trigger.split(' ')
51
+
52
+ for (i = triggers.length; i--;) {
53
+ trigger = triggers[i]
54
+ if (trigger == 'click') {
55
+ this.$element.on('click.' + this.type, this.options.selector, $.proxy(this.toggle, this))
56
+ } else if (trigger != 'manual') {
57
+ eventIn = trigger == 'hover' ? 'mouseenter' : 'focus'
58
+ eventOut = trigger == 'hover' ? 'mouseleave' : 'blur'
59
+ this.$element.on(eventIn + '.' + this.type, this.options.selector, $.proxy(this.enter, this))
60
+ this.$element.on(eventOut + '.' + this.type, this.options.selector, $.proxy(this.leave, this))
61
+ }
54
62
  }
55
63
 
56
64
  this.options.selector ?
@@ -59,7 +67,7 @@
59
67
  }
60
68
 
61
69
  , getOptions: function (options) {
62
- options = $.extend({}, $.fn[this.type].defaults, options, this.$element.data())
70
+ options = $.extend({}, $.fn[this.type].defaults, this.$element.data(), options)
63
71
 
64
72
  if (options.delay && typeof options.delay == 'number') {
65
73
  options.delay = {
@@ -72,7 +80,15 @@
72
80
  }
73
81
 
74
82
  , enter: function (e) {
75
- var self = $(e.currentTarget)[this.type](this._options).data(this.type)
83
+ var defaults = $.fn[this.type].defaults
84
+ , options = {}
85
+ , self
86
+
87
+ this._options && $.each(this._options, function (key, value) {
88
+ if (defaults[key] != value) options[key] = value
89
+ }, this)
90
+
91
+ self = $(e.currentTarget)[this.type](options).data(this.type)
76
92
 
77
93
  if (!self.options.delay || !self.options.delay.show) return self.show()
78
94
 
@@ -97,14 +113,16 @@
97
113
 
98
114
  , show: function () {
99
115
  var $tip
100
- , inside
101
116
  , pos
102
117
  , actualWidth
103
118
  , actualHeight
104
119
  , placement
105
120
  , tp
121
+ , e = $.Event('show')
106
122
 
107
123
  if (this.hasContent() && this.enabled) {
124
+ this.$element.trigger(e)
125
+ if (e.isDefaultPrevented()) return
108
126
  $tip = this.tip()
109
127
  this.setContent()
110
128
 
@@ -116,19 +134,18 @@
116
134
  this.options.placement.call(this, $tip[0], this.$element[0]) :
117
135
  this.options.placement
118
136
 
119
- inside = /in/.test(placement)
120
-
121
137
  $tip
122
138
  .detach()
123
139
  .css({ top: 0, left: 0, display: 'block' })
124
- .insertAfter(this.$element)
125
140
 
126
- pos = this.getPosition(inside)
141
+ this.options.container ? $tip.appendTo(this.options.container) : $tip.insertAfter(this.$element)
142
+
143
+ pos = this.getPosition()
127
144
 
128
145
  actualWidth = $tip[0].offsetWidth
129
146
  actualHeight = $tip[0].offsetHeight
130
147
 
131
- switch (inside ? placement.split(' ')[1] : placement) {
148
+ switch (placement) {
132
149
  case 'bottom':
133
150
  tp = {top: pos.top + pos.height, left: pos.left + pos.width / 2 - actualWidth / 2}
134
151
  break
@@ -143,13 +160,58 @@
143
160
  break
144
161
  }
145
162
 
146
- $tip
147
- .offset(tp)
148
- .addClass(placement)
149
- .addClass('in')
163
+ this.applyPlacement(tp, placement)
164
+ this.$element.trigger('shown')
150
165
  }
151
166
  }
152
167
 
168
+ , applyPlacement: function(offset, placement){
169
+ var $tip = this.tip()
170
+ , width = $tip[0].offsetWidth
171
+ , height = $tip[0].offsetHeight
172
+ , actualWidth
173
+ , actualHeight
174
+ , delta
175
+ , replace
176
+
177
+ $tip
178
+ .offset(offset)
179
+ .addClass(placement)
180
+ .addClass('in')
181
+
182
+ actualWidth = $tip[0].offsetWidth
183
+ actualHeight = $tip[0].offsetHeight
184
+
185
+ if (placement == 'top' && actualHeight != height) {
186
+ offset.top = offset.top + height - actualHeight
187
+ replace = true
188
+ }
189
+
190
+ if (placement == 'bottom' || placement == 'top') {
191
+ delta = 0
192
+
193
+ if (offset.left < 0){
194
+ delta = offset.left * -2
195
+ offset.left = 0
196
+ $tip.offset(offset)
197
+ actualWidth = $tip[0].offsetWidth
198
+ actualHeight = $tip[0].offsetHeight
199
+ }
200
+
201
+ this.replaceArrow(delta - width + actualWidth, actualWidth, 'left')
202
+ } else {
203
+ this.replaceArrow(actualHeight - height, actualHeight, 'top')
204
+ }
205
+
206
+ if (replace) $tip.offset(offset)
207
+ }
208
+
209
+ , replaceArrow: function(delta, dimension, position){
210
+ this
211
+ .arrow()
212
+ .css(position, delta ? (50 * (1 - delta / dimension) + "%") : '')
213
+ }
214
+
153
215
  , setContent: function () {
154
216
  var $tip = this.tip()
155
217
  , title = this.getTitle()
@@ -161,6 +223,10 @@
161
223
  , hide: function () {
162
224
  var that = this
163
225
  , $tip = this.tip()
226
+ , e = $.Event('hide')
227
+
228
+ this.$element.trigger(e)
229
+ if (e.isDefaultPrevented()) return
164
230
 
165
231
  $tip.removeClass('in')
166
232
 
@@ -179,13 +245,15 @@
179
245
  removeWithAnimation() :
180
246
  $tip.detach()
181
247
 
248
+ this.$element.trigger('hidden')
249
+
182
250
  return this
183
251
  }
184
252
 
185
253
  , fixTitle: function () {
186
254
  var $e = this.$element
187
255
  if ($e.attr('title') || typeof($e.attr('data-original-title')) != 'string') {
188
- $e.attr('data-original-title', $e.attr('title') || '').removeAttr('title')
256
+ $e.attr('data-original-title', $e.attr('title') || '').attr('title', '')
189
257
  }
190
258
  }
191
259
 
@@ -193,11 +261,12 @@
193
261
  return this.getTitle()
194
262
  }
195
263
 
196
- , getPosition: function (inside) {
197
- return $.extend({}, (inside ? {top: 0, left: 0} : this.$element.offset()), {
198
- width: this.$element[0].offsetWidth
199
- , height: this.$element[0].offsetHeight
200
- })
264
+ , getPosition: function () {
265
+ var el = this.$element[0]
266
+ return $.extend({}, (typeof el.getBoundingClientRect == 'function') ? el.getBoundingClientRect() : {
267
+ width: el.offsetWidth
268
+ , height: el.offsetHeight
269
+ }, this.$element.offset())
201
270
  }
202
271
 
203
272
  , getTitle: function () {
@@ -215,6 +284,10 @@
215
284
  return this.$tip = this.$tip || $(this.options.template)
216
285
  }
217
286
 
287
+ , arrow: function(){
288
+ return this.$arrow = this.$arrow || this.tip().find(".tooltip-arrow")
289
+ }
290
+
218
291
  , validate: function () {
219
292
  if (!this.$element[0].parentNode) {
220
293
  this.hide()
@@ -236,8 +309,8 @@
236
309
  }
237
310
 
238
311
  , toggle: function (e) {
239
- var self = $(e.currentTarget)[this.type](this._options).data(this.type)
240
- self[self.tip().hasClass('in') ? 'hide' : 'show']()
312
+ var self = e ? $(e.currentTarget)[this.type](this._options).data(this.type) : this
313
+ self.tip().hasClass('in') ? self.hide() : self.show()
241
314
  }
242
315
 
243
316
  , destroy: function () {
@@ -269,10 +342,11 @@
269
342
  , placement: 'top'
270
343
  , selector: false
271
344
  , template: '<div class="tooltip"><div class="tooltip-arrow"></div><div class="tooltip-inner"></div></div>'
272
- , trigger: 'hover'
345
+ , trigger: 'hover focus'
273
346
  , title: ''
274
347
  , delay: 0
275
348
  , html: false
349
+ , container: false
276
350
  }
277
351
 
278
352
 
@@ -284,4 +358,4 @@
284
358
  return this
285
359
  }
286
360
 
287
- }(window.jQuery);
361
+ }(window.jQuery);