Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

Commit

Permalink
rhbz1066756 - Add activity tab url on dashboard screen.
Browse files Browse the repository at this point in the history
  • Loading branch information
Carlos A. Munoz committed Apr 2, 2014
1 parent 0b6d583 commit 516b93d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
14 changes: 7 additions & 7 deletions zanata-war/src/main/webapp/dashboard/home.xhtml
Expand Up @@ -13,9 +13,9 @@

<script type="text/javascript">
jQuery(function(){
onTabClick(jQuery('#activity'));

crossroads.addRoute(':pre*:/dashboard/{section}/:subSection:', function(pre, section, subSection) {
crossroads.addRoute(':pre*:/dashboard/:section:/:subSection:', function(pre, section, subSection) {
section = section || 'activity'
onTabClick(jQuery('#' + section));
});

Expand Down Expand Up @@ -85,10 +85,10 @@
<li>
<a id="activity"
href="#{request.contextPath}/dashboard/activity"
class="js-tab is-active" onclick="return false;">
<i class="i i--clock"></i>
<span
class="is-hidden--s i__text--right">Activity</span>
class="js-tab"
onclick="changeBrowserUrl(this.href); return false;">
<i class="i i--clock"></i>
<span class="is-hidden--s i__text--right">Activity</span>
</a>
</li>
<li><a href="/dashboard/projects"><i class="i i--project"></i><span
Expand All @@ -101,7 +101,7 @@
<a href="#{request.contextPath}/dashboard/settings"
id="settings" class="js-tab"
title="Account Settings"
onclick="return false;">
onclick="changeBrowserUrl(this.href); return false;">
<span
class="is-hidden--s i__text--left">Settings</span><i class="i i--settings"
aria-hidden="true"></i>
Expand Down
10 changes: 10 additions & 0 deletions zanata-war/src/main/webapp/resources/script/components-script.js
Expand Up @@ -27,6 +27,7 @@ function updateStateFromUrl() {
crossroads.parse(window.location.pathname);
}

// TODO Deprecated. See method below
function updateUrl(urlPrefix, suffixToUpdate) {
var newUrl = window.location.pathname;
newUrl = newUrl.substring(0, newUrl.indexOf(urlPrefix) + urlPrefix.length)
Expand All @@ -36,6 +37,15 @@ function updateUrl(urlPrefix, suffixToUpdate) {
updateStateFromUrl();
}

function changeBrowserUrl(url, refresh) {
refresh = refresh || false

var status = {path: url}
window.history.pushState(status, document.title, url)
if(refresh)
updateStateFromUrl();
}

jQuery(function() {
jQuery(window).on("popstate", function(event) {
var state = event.originalEvent.state
Expand Down

0 comments on commit 516b93d

Please sign in to comment.