Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/twbs/bootstrap.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
authorfat <jacobthornton@gmail.com>2013-02-06 10:29:59 +0400
committerfat <jacobthornton@gmail.com>2013-02-06 10:29:59 +0400
commit481428154084a9fafd31d8654157d6f6f78231d0 (patch)
treebe95c0621248574864f79141c1e6103721c84354 /js
parent5e4db94c240c5ac2af18bbf4238358a043ad4037 (diff)
clean up styles
Diffstat (limited to 'js')
-rw-r--r--js/bootstrap-tooltip.js88
-rw-r--r--js/tests/index.html3
-rw-r--r--js/tests/unit/bootstrap-tooltip.css13
-rw-r--r--js/tests/unit/bootstrap-tooltip.js21
4 files changed, 39 insertions, 86 deletions
diff --git a/js/bootstrap-tooltip.js b/js/bootstrap-tooltip.js
index f17b311573..7a1d7254fc 100644
--- a/js/bootstrap-tooltip.js
+++ b/js/bootstrap-tooltip.js
@@ -153,66 +153,56 @@
}
this.applyPlacement(tp, placement)
-
this.$element.trigger('shown')
}
}
, applyPlacement: function(offset, placement){
- var $tip
- , width
- , height
- , actualWidth
- , actualHeight
- , delta
- , replace = false
-
- $tip = this.tip()
-
- width = $tip[0].offsetWidth
- height = $tip[0].offsetHeight
-
- $tip
- .offset(offset)
- .addClass(placement)
- .addClass('in')
-
- actualWidth = $tip[0].offsetWidth
- actualHeight = $tip[0].offsetHeight
-
- if (placement == "top" && actualHeight != height){
- offset.top = offset.top + height - actualHeight
- replace = true
- }
+ var $tip = this.tip()
+ , width = $tip[0].offsetWidth
+ , height = $tip[0].offsetHeight
+ , actualWidth
+ , actualHeight
+ , delta
+ , replace
- if (placement == "bottom" || placement == "top"){
- delta = 0
+ $tip
+ .offset(offset)
+ .addClass(placement)
+ .addClass('in')
- if (offset.left < 0){
- delta = -offset.left * 2
- offset.left = 0
- $tip.offset(offset)
- actualWidth = $tip[0].offsetWidth
- actualHeight = $tip[0].offsetHeight
+ actualWidth = $tip[0].offsetWidth
+ actualHeight = $tip[0].offsetHeight
+
+ if (placement == 'top' && actualHeight != height) {
+ offset.top = offset.top + height - actualHeight
+ replace = true
}
- this.replaceArrow(delta - width + actualWidth, actualWidth, "left")
- }else{
- this.replaceArrow(actualHeight - height, actualHeight, "top")
- }
+ if (placement == 'bottom' || placement == 'top') {
+ delta = 0
- if (replace) $tip.offset(offset)
- }
+ if (offset.left < 0){
+ delta = offset.left * -2
+ offset.left = 0
+ $tip.offset(offset)
+ actualWidth = $tip[0].offsetWidth
+ actualHeight = $tip[0].offsetHeight
+ }
- , replaceArrow: function(delta, dimension, position){
- var $arrow = this.arrow()
+ this.replaceArrow(delta - width + actualWidth, actualWidth, 'left')
+ } else {
+ this.replaceArrow(actualHeight - height, actualHeight, 'top')
+ }
- if (delta !== 0){
- $arrow.css(position, 50 * (1 - delta / dimension) + "%")
- }else{
- $arrow.css(position, "")
+ if (replace) $tip.offset(offset)
+ }
+
+ , replaceArrow: function(delta, dimension, position){
+ this
+ .arrow()
+ .css(position, delta ? (50 * (1 - delta / dimension) + "%") : '')
}
- }
, setContent: function () {
var $tip = this.tip()
@@ -287,8 +277,8 @@
}
, arrow: function(){
- return this.$arrow = this.$arrow || this.tip().find(".tooltip-arrow")
- }
+ return this.$arrow = this.$arrow || this.tip().find(".tooltip-arrow")
+ }
, validate: function () {
if (!this.$element[0].parentNode) {
diff --git a/js/tests/index.html b/js/tests/index.html
index e9ad01d67a..976ca16872 100644
--- a/js/tests/index.html
+++ b/js/tests/index.html
@@ -29,9 +29,6 @@
<script src="../../js/bootstrap-typeahead.js"></script>
<script src="../../js/bootstrap-affix.js"></script>
- <!-- Needed for testing -->
- <link rel="stylesheet" type="text/css" href="unit/bootstrap-tooltip.css" />
-
<!-- unit tests -->
<script src="unit/bootstrap-transition.js"></script>
<script src="unit/bootstrap-alert.js"></script>
diff --git a/js/tests/unit/bootstrap-tooltip.css b/js/tests/unit/bootstrap-tooltip.css
deleted file mode 100644
index 8614e60d7d..0000000000
--- a/js/tests/unit/bootstrap-tooltip.css
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-.tooltip{
- position: absolute;
-}
-
-.tooltip-inner{
- max-width: 200px;
-}
-
-.tooltip.top .tooltip-arrow{
- position: absolute;
-} \ No newline at end of file
diff --git a/js/tests/unit/bootstrap-tooltip.js b/js/tests/unit/bootstrap-tooltip.js
index dc4c19bcfd..97571d243e 100644
--- a/js/tests/unit/bootstrap-tooltip.js
+++ b/js/tests/unit/bootstrap-tooltip.js
@@ -291,25 +291,4 @@ $(function () {
container.remove()
}, 100)
})
-
- test("arrow should point to element", function(){
- var container = $("<div />").appendTo("body")
- .css({position: "absolute", bottom: 0, left: 0, textAlign: "right", width: 300, height: 300})
- , p = $("<p style='margin-top:200px' />").appendTo(container)
- , tooltiped = $("<a href='#' title='very very very very very very very long tooltip'>Hover me</a>")
- .css({marginTop: 200})
- .appendTo(p)
- .tooltip({placement: "top", animate: false})
- .tooltip("show")
-
- stop()
-
- setTimeout(function(){
- var arrow = container.find(".tooltip-arrow")
-
- start()
- ok(Math.abs(arrow.offset().left - tooltiped.offset().left - tooltiped.outerWidth()/2) <= 1)
- container.remove()
- }, 100)
- })
})