Skip to content
GitLab
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
  • !16151

Tooltip/popover: Allow viewport option to be a function

  • Review changes

  • Download
  • Email patches
  • Plain diff
Closed Administrator requested to merge github/fork/dimelo/tooltip-viewport-function into master Mar 25, 2015
  • Overview 0
  • Commits 3
  • Pipelines 0
  • Changes 2

Created by: Intrepidd

It might be really useful to be able to pass a function to the viewport option in some cases, just like that :

$('body').tooltip({
  selector: '[data-toggle="tooltip"]',
  viewport: function($element) {
    var viewport = $element.closest('.tooltip-viewport');
    return (viewport.length > 0 ? viewport : $('body'));
  }
});

I implemented that in this PR.

I'm open to suggestions, I'm not sure if it's a good idea to accept either a string, an object, or a function. (Did not update the doc yet because of that)

Regarding tests, I noticed that there are no tests asserting that using functions instead of string work (placement for instance), so I copied an existing viewport test, you tell me if that's enough.

Thanks

Assignee
Assign to
Reviewers
Request review from
Time tracking
Source branch: github/fork/dimelo/tooltip-viewport-function