Skip to content

Commit

Permalink
Fixed href's at top of page
Browse files Browse the repository at this point in the history
  • Loading branch information
atruskie committed Nov 22, 2013
1 parent 32df8bc commit 783cb81
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 62 deletions.
99 changes: 52 additions & 47 deletions src/baw.configuration.tpl.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,58 @@
angular.module('bawApp.configuration', [])
angular.module('bawApp.configuration', ['url'])

/**
* This module contains static paths that are stored centrally for easy configuration.
* App dependent.
*
* At least the root properties will need to be changed when the app is deployed.
* TODO: convert to template and let grunt do the hard work!
* The root properties changed when the app is built with grunt.
*/

.constant("conf.paths", (function () {
/**
* Joins path fragments together.
* @param {...[string]} fragments
* @returns {*}
*/
function joinPathFragments(fragments) {
fragments = Array.prototype.slice.call(arguments, 0);

if (fragments.length === 0) {
return undefined;
}
else if (fragments.length === 1) {
return fragments[0];
}
else {
var path = fragments[0];

if (path.slice(-1) === "/") {
path = path.slice(0, -1);
}

for (var i = 1; i < fragments.length; i++) {
var f = fragments[i];

if ((typeof f) !== "string") {
throw "Path fragment " + f + " is not a string";
}

var hasFirst = f[0] === "/";
var hasLast = (f.slice(-1))[0] === "/";

if (!hasFirst) {
f = "/" + f;
}

if (hasLast && i !== (fragments.length - 1)) {
f = f.slice(0, -1);
}

path += f;
}

return path;
}
};

var paths = {
api: {
Expand Down Expand Up @@ -41,6 +85,10 @@ angular.module('bawApp.configuration', [])
ping: "/security/sign_in",
signIn: "/my_account/sign_in"
}
},
links: {
projects: '/projects',
home: '/'
}
},
site: {
Expand Down Expand Up @@ -72,51 +120,7 @@ angular.module('bawApp.configuration', [])
}
};

/**
* Joins path fragments together.
* @param {...[string]} fragments
* @returns {*}
*/
function joinPathFragments(fragments) {
fragments = Array.prototype.slice.call(arguments, 0);

if (fragments.length === 0) {
return undefined;
}
else if (fragments.length === 1) {
return fragments[0];
}
else {
var path = fragments[0];

if (path.slice(-1) === "/") {
path = path.slice(0, -1);
}

for (var i = 1; i < fragments.length; i++) {
var f = fragments[i];

if ((typeof f) !== "string") {
throw "Path fragment " + f + " is not a string";
}

var hasFirst = f[0] === "/";
var hasLast = (f.slice(-1))[0] === "/";

if (!hasFirst) {
f = "/" + f;
}

if (hasLast && i !== (fragments.length - 1)) {
f = f.slice(0, -1);
}

path += f;
}

return path;
}
}

// add helper paths
function recursivePath(source, root) {
Expand All @@ -135,6 +139,7 @@ angular.module('bawApp.configuration', [])
}

recursivePath(paths.api.routes, paths.api.root);
recursivePath(paths.api.links, paths.api.root);
recursivePath(paths.site.files, paths.site.root);
recursivePath(paths.site.ngRoutes, paths.site.root);

Expand Down
1 change: 1 addition & 0 deletions src/components/services/url.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,4 +89,5 @@ angular.module('url', ['ng']).
};



});
17 changes: 2 additions & 15 deletions src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,6 @@
<!-- compiled JavaScript --><% scripts.forEach( function ( file ) { %>
<script type="text/javascript" src="<%= build_configs.current.siteDir %><%= file %>"></script>
<% }); %>


<!--<script src="https://login.persona.org/include.js"></script>-->

<!-- fot sticky footer -->
<!--[if !IE 7]>
<style type="text/css">
#wrap {
display: table;
height: 100%
}
</style>
<![endif]-->
</head>
<body baw-auth class="waiting-for-angular">

Expand All @@ -42,12 +29,12 @@
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="/">Bioacoustic Workbench</a>
<a class="navbar-brand" ng-href="{{paths.api.links.home}}">Bioacoustics Workbench</a>
</div>

<div class="collapse navbar-collapse">
<ul class="nav navbar-nav">
<li ng-class="{ active: $location.path().indexOf('/projects') != -1}"><a href="/projects">Projects</a></li>
<li ng-class="{ active: $location.path().indexOf('/projects') != -1}"><a ng-href="{{paths.api.links.projectsAbsolute}}">Projects</a></li>
<li ng-class="{ active: $location.path().indexOf('/listen') != -1}"><a href="/listen/">Listen</a></li>
<li ng-class="{ active: $location.path().indexOf('/bird') != -1}"><a href="/birdWalks">Bird Walks</a></li>

Expand Down

0 comments on commit 783cb81

Please sign in to comment.