Skip to content
GitLab
    • Explore Projects Groups Snippets
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • B bootstrap
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 263
    • Issues 263
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 114
    • Merge requests 114
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Bootstrap
  • bootstrap
  • Merge requests
  • !6705

Tooltips replaced when possible on edge cases

  • Review changes

  • Download
  • Email patches
  • Plain diff
Closed Administrator requested to merge github/fork/ghusse/master into master 12 years ago
  • Overview 0
  • Commits 2
  • Pipelines 0
  • Changes 2

Created by: ghusse

Before: tooltipPosition

After:

withCorrection

Compare
  • master (base)

and
  • latest version
    db6f777e
    2 commits, 2 years ago

2 files
+ 62
- 9

    Preferences

    File browser
    Compare changes
j‎s‎
bootstrap-‎tooltip.js‎ +58 -4
le‎ss‎
toolti‎p.less‎ +4 -5
js/bootstrap-tooltip.js
+ 58
- 4
  • View file @ db6f777e


@@ -117,6 +117,7 @@
this.options.placement
inside = /in/.test(placement)
placement = inside ? placement.split(' ')[1] : placement;
$tip
.detach()
@@ -128,7 +129,7 @@
actualWidth = $tip[0].offsetWidth
actualHeight = $tip[0].offsetHeight
switch (inside ? placement.split(' ')[1] : placement) {
switch (placement) {
case 'bottom':
tp = {top: pos.top + pos.height, left: pos.left + pos.width / 2 - actualWidth / 2}
break
@@ -143,13 +144,62 @@
break
}
$tip
.offset(tp)
this.applyPlacement(tp, placement);
}
}
, applyPlacement: function(offset, placement){
var $tip
, $arrow
, width
, height
, actualWidth
, actualHeight
, deltaX
, replace = false;
$tip = this.tip();
width = $tip[0].offsetWidth;
height = $tip[0].offsetHeight;
$tip
.offset(offset)
.addClass(placement)
.addClass('in')
.addClass('in');
actualWidth = $tip[0].offsetWidth;
actualHeight = $tip[0].offsetHeight;
if (placement == "top" && actualHeight != actualWidth){
offset.top = offset.top + height - actualHeight;
replace = true;
}
if (placement == "bottom" || placement == "top"){
deltaX = 0;
if (offset.left < 0){
deltaX = -offset.left * 2;
offset.left = 0;
$tip.offset(offset);
actualWidth = $tip[0].offsetWidth;
actualHeight = $tip[0].offsetHeight;
}
deltaX = deltaX - width + actualWidth;
$arrow = this.arrow();
if (deltaX !== 0){
$arrow.css("left", 50 * (1 - deltaX / actualWidth) + "%");
}else{
$arrow.css("left", "");
}
}
if (replace) $tip.offset(offset);
}
, setContent: function () {
var $tip = this.tip()
, title = this.getTitle()
@@ -215,6 +265,10 @@
return this.$tip = this.$tip || $(this.options.template)
}
, arrow: function(){
return this.$arrow = this.$arrow || this.tip().find(".tooltip-arrow");
}
, validate: function () {
if (!this.$element[0].parentNode) {
this.hide()
less/tooltip.less
+ 4
- 5
  • View file @ db6f777e


@@ -9,14 +9,13 @@
z-index: @zindexTooltip;
display: block;
visibility: visible;
padding: 5px;
font-size: 11px;
.opacity(0);
&.in { .opacity(80); }
&.top { margin-top: -3px; }
&.right { margin-left: 3px; }
&.bottom { margin-top: 3px; }
&.left { margin-left: -3px; }
&.top { margin-top: -3px; padding: 5px 0;}
&.right { margin-left: 3px; padding: 0 5px; }
&.bottom { margin-top: 3px; padding: 5px 0;}
&.left { margin-left: -3px; padding: 0 5px;}
}
// Wrapper for the tooltip content
0 Assignees
None
Assign to
0 Reviewers
None
Request review from
Labels
0
None
0
None
    Assign labels
  • Manage project labels

Milestone
No milestone
None
None
Time tracking
No estimate or time spent
Lock merge request
Unlocked
1
1 participant
Administrator
Reference: twbs/bootstrap!6705
Source branch: github/fork/ghusse/master

Menu

Explore Projects Groups Snippets