From 18b40a06135521046fbb464049e65ea6b21a8366 Mon Sep 17 00:00:00 2001 From: Jim Phillips Date: Tue, 26 May 2015 10:09:05 -0400 Subject: [PATCH] enable back button for tabs Change-Id: Ia2f40a5266a974133d32867eb699ceaea817ab71 --- _templates/mirantis/static/abtest.js | 47 +++++++---- _templates/mirantis/static/styles.css | 110 ++++++++++++++------------ 2 files changed, 92 insertions(+), 65 deletions(-) diff --git a/_templates/mirantis/static/abtest.js b/_templates/mirantis/static/abtest.js index d62518044..bacb3fccf 100644 --- a/_templates/mirantis/static/abtest.js +++ b/_templates/mirantis/static/abtest.js @@ -1,6 +1,17 @@ var _conv_host = (("https:" == document.location.protocol) ? "https://d9jmv9u00p0mv.cloudfront.net" : "http://cdn-1.convertexperiments.com"); document.write(unescape("%3Cscript src='" + _conv_host + "/js/10012224-10012014.js' type='text/javascript'%3E%3C/script%3E")); +(function () { + window.addEventListener("popstate", function (e) { + var activeTab = location.hash ? $('[href=' + location.hash + ']') : $('[href=#home]'); + if (activeTab.length) { + activeTab.tab('show'); + } else { + $('.nav-tabs a:first').tab('show'); + } + }); +})(); + function generateLinks(url, title) { var currentLocation = window.location; var linkUrl = currentLocation.protocol + '//' + currentLocation.host + currentLocation.pathname + url; @@ -43,7 +54,7 @@ function generateCopyButton(url) { function populateGuides(guides) { - $(guides).find('.section').each(function(i){ + $(guides).find('.section').each(function (i) { var index = i + 1; var el = $(this).find('.reference'); var href = $(el).attr('href'); @@ -53,27 +64,27 @@ function populateGuides(guides) { }); var columns = $('#guides .col-sm-3'); - for(var i = 0; i < columns.length; i+=4) { - columns.slice(i, i+4).wrapAll("
"); + for (var i = 0; i < columns.length; i += 4) { + columns.slice(i, i + 4).wrapAll("
"); } } -function populatePdfs(pdfs){ - - $(pdfs).each(function(){ +function populatePdfs(pdfs) { + + $(pdfs).each(function () { var href = $(this).attr('href'); var link = $(this).text(); $('#pdfs').append('
' + link + '
'); }); var columns = $('#pdfs .col-lg-6'); - for(var i = 0; i < columns.length; i+=2) { - columns.slice(i, i+2).wrapAll("
"); + for (var i = 0; i < columns.length; i += 2) { + columns.slice(i, i + 2).wrapAll("
"); } } -function populateDownload(download){ +function populateDownload(download) { var el = $(download).find('h1 > .reference'); var href = $(el).attr('href'); var link = $(el).text(); @@ -89,9 +100,9 @@ $(document).ready(function () { $('ul.nav.navbar-nav li.dropdown').not('.globaltoc-container').hide(); - $.get( "index_content.html", function( data ) { - var homeTitle = $(data).find('.home-title').html(); - var home = $(data).find('.what-is-mirantis-openstack').html(); + $.get("index_content.html", function (data) { + var homeTitle = $(data).find('.home-title').html(); + var home = $(data).find('.what-is-mirantis-openstack').html(); var guides = $(data).find('#guides'); populateGuides(guides); var pdfs = $(data).find('#pdf .reference'); @@ -103,14 +114,14 @@ $(document).ready(function () { $('#main').html(homeTitle); }); - $.get("eula.html", function(data) { + $.get("eula.html", function (data) { var fuel_license = $(data).find('#fuel-license').html(); $('#fuel-license').html($(fuel_license).find('pre')); }); - $.get("third-party-licenses.html", function(data){ + $.get("third-party-licenses.html", function (data) { var third_party = $(data).find(".section > .section"); - $(third_party).each(function(i,v){ + $(third_party).each(function (i, v) { var el = $(v).find('.reference'); var href = $(el).attr('href'); var heading = $(el).text(); @@ -143,7 +154,7 @@ $(document).ready(function () { $('.headerlink').each(function () { $(this).replaceWith(generateLinks($(this).attr('href'), $(this).parent().children('.toc-backref').text())); }); - + $('[data-toggle="tooltip"]').tooltip(); ZeroClipboard.config({ @@ -174,4 +185,8 @@ $(document).ready(function () { } ); + $('a[data-toggle="tab"]').on('click', function (e) { + history.pushState(null, null, $(this).attr('href')); + }); + }); \ No newline at end of file diff --git a/_templates/mirantis/static/styles.css b/_templates/mirantis/static/styles.css index 3dc4d3a1a..48cd106ca 100644 --- a/_templates/mirantis/static/styles.css +++ b/_templates/mirantis/static/styles.css @@ -26,7 +26,9 @@ h4, h5 { font-weight: bold; } -h3.no-margin { margin-top: 0; } +h3.no-margin { + margin-top: 0; +} a.toc-backref { color: #41454D; @@ -426,8 +428,8 @@ a:hover .panel .panel-body { } div#home { - min-height: 392px; - position: relative; + min-height: 392px; + position: relative; } ul#menuNav { @@ -435,84 +437,94 @@ ul#menuNav { } a.list-group-item:focus, a.list-group-item:hover { - color: #FFF; - text-decoration: none; - background-color: #D3301A; + color: #FFF; + text-decoration: none; + background-color: #D3301A; } #preview-area { - width: 60px; - height: 60px; - position: absolute; - top: 0; - left: 0; - bottom: 60px; - right: 0; - margin: auto auto; - -webkit-user-select: none; - -moz-user-select: none; - -ms-user-select: none; - user-select: none; + width: 60px; + height: 60px; + position: absolute; + top: 0; + left: 0; + bottom: 60px; + right: 0; + margin: auto auto; + -webkit-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; } .btn-default.red { - margin-bottom: 15px; - text-align: left; + margin-bottom: 15px; + text-align: left; } .btn-default.red.active, .btn-default.red.focus, .btn-default.red:active, .btn-default.red:focus, .btn-default.red:hover { - color: #fff; - background-color: #D3301A; - border-color: #AD2816; + color: #fff; + background-color: #D3301A; + border-color: #AD2816; } i.fa-file-pdf-o { - color: #D3301A; + color: #D3301A; } .btn-default.red:hover i.fa-file-pdf-o { - color: #fff; + color: #fff; } .btn-danger { - background-color: #D3301A; - border-color: #AD2816; - margin-bottom: 15px; + background-color: #D3301A; + border-color: #AD2816; + margin-bottom: 15px; } #pdfs h3 { - margin-top: 0; + margin-top: 0; } .spinner { - width: 30px; - height: 30px; - background-color: #D3301A; - margin: 0 auto; - -webkit-animation: rotateplane 1.2s infinite ease-in-out; - animation: rotateplane 1.2s infinite ease-in-out; + width: 30px; + height: 30px; + background-color: #D3301A; + margin: 0 auto; + -webkit-animation: rotateplane 1.2s infinite ease-in-out; + animation: rotateplane 1.2s infinite ease-in-out; } @-webkit-keyframes rotateplane { - 0% { -webkit-transform: perspective(120px) } - 50% { -webkit-transform: perspective(120px) rotateY(180deg) } - 100% { -webkit-transform: perspective(120px) rotateY(180deg) rotateX(180deg) } + 0% { + -webkit-transform: perspective(120px) + } + 50% { + -webkit-transform: perspective(120px) rotateY(180deg) + } + 100% { + -webkit-transform: perspective(120px) rotateY(180deg) rotateX(180deg) + } } @keyframes rotateplane { - 0% { - transform: perspective(120px) rotateX(0deg) rotateY(0deg); - -webkit-transform: perspective(120px) rotateX(0deg) rotateY(0deg) - } 50% { - transform: perspective(120px) rotateX(-180.1deg) rotateY(0deg); - -webkit-transform: perspective(120px) rotateX(-180.1deg) rotateY(0deg) - } 100% { - transform: perspective(120px) rotateX(-180deg) rotateY(-179.9deg); - -webkit-transform: perspective(120px) rotateX(-180deg) rotateY(-179.9deg); - } + 0% { + transform: perspective(120px) rotateX(0deg) rotateY(0deg); + -webkit-transform: perspective(120px) rotateX(0deg) rotateY(0deg) + } + 50% { + transform: perspective(120px) rotateX(-180.1deg) rotateY(0deg); + -webkit-transform: perspective(120px) rotateX(-180.1deg) rotateY(0deg) + } + 100% { + transform: perspective(120px) rotateX(-180deg) rotateY(-179.9deg); + -webkit-transform: perspective(120px) rotateX(-180deg) rotateY(-179.9deg); + } } -.navbar-version { display: none; } +.navbar-version { + display: none; +} @media (max-width: 767px) and (min-width: 0px) { .navbar-default .navbar-text {