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
  • !12101

Added optional history.pushState behaviour to Tab.show.

  • Review changes

  • Download
  • Email patches
  • Plain diff
Closed Administrator requested to merge github/fork/Robadob/master into master Jan 05, 2014
  • Overview 0
  • Commits 2
  • Pipelines 0
  • Changes 2

Created by: Robadob

history.pushState updates the browser history and address bar.

I found it unusual that the functionality of pressing tabs updating the address bar to this url was unavailable, so that tabs could be more easily treated as a single page nav. I understand this behaviour isn't always necessary, hence the optional usage by adding follow-url as an attribute to the anchor which is used to show the tab.

Loading the correct tab then works something like this where all tab anchors have .my_tabs

$(document).ready(function(){
    $address=document.URL;
    if($address.replace(/^[^#]*/, "").length==0)
       $address=$address+$(".my_tabs.active").attr("href");
    $selector = $address.replace(/^[^#]*/, "");
    $(".phase_link").each(
        function( index ) {
            if ($selector == $(this).attr("href"))
                $(this).tab("show");
        }
    );
});

history.pushState is HTML5 so wont work in older browsers, however this functionality is implemented at the end of the show method so any javascript error caused by it would't break the primary functionality of tabs. If it were desired for this to implemented for older browsers this stackoverflow post suggests a method which I haven't tested; http://stackoverflow.com/a/136506/1646387

Assignee
Assign to
Reviewers
Request review from
Time tracking
Source branch: github/fork/Robadob/master