Skip to content

Commit

Permalink
Added Usermenu
Browse files Browse the repository at this point in the history
  • Loading branch information
sueastside committed Jan 29, 2014
1 parent 3a638f6 commit 44247d4
Show file tree
Hide file tree
Showing 5 changed files with 200 additions and 149 deletions.
195 changes: 99 additions & 96 deletions app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,111 +3,114 @@
<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]> <html class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js"> <!--<![endif]-->
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>damn</title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width">
<!-- Place favicon.ico and apple-touch-icon.png in the root directory -->
<!-- build:css styles/vendor.css -->
<!-- bower:css -->
<!-- endbower -->
<!-- endbuild -->
<!-- build:css(.tmp) styles/main.css -->
<link rel="stylesheet" href="styles/main.css">
<!-- endbuild -->
<script src="bower_components/modernizr/modernizr.js"></script>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>damn</title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width">
<!-- Place favicon.ico and apple-touch-icon.png in the root directory -->
<!-- build:css styles/vendor.css -->
<!-- bower:css -->
<!-- endbower -->
<!-- endbuild -->
<!-- build:css(.tmp) styles/main.css -->
<link rel="stylesheet" href="styles/main.css">
<!-- endbuild -->
<script src="bower_components/modernizr/modernizr.js"></script>

<link rel="stylesheet" href="bower_components/normalize-css/normalize.css">
<link rel="stylesheet" href="bower_components/font-awesome/css/font-awesome.css">
<link href='http://fonts.googleapis.com/css?family=Roboto:400,400italic,500,500italic,700,700italic,900,900italic,300italic,300,100,100italic|Roboto+Condensed:300italic,400italic,700italic,400,300,700' rel='stylesheet' type='text/css'>
<link rel="stylesheet" href="bower_components/normalize-css/normalize.css">
<link rel="stylesheet" href="bower_components/font-awesome/css/font-awesome.css">
<link href='http://fonts.googleapis.com/css?family=Roboto:400,400italic,500,500italic,700,700italic,900,900italic,300italic,300,100,100italic|Roboto+Condensed:300italic,400italic,700italic,400,300,700' rel='stylesheet' type='text/css'>

</head>
<body>
<!--[if lt IE 10]>
<p class="browsehappy">You are using an <strong>outdated</strong> browser. Please <a href="http://browsehappy.com/">upgrade your browser</a> to improve your experience.</p>
<![endif]-->
</head>
<body>
<!--[if lt IE 10]>
<p class="browsehappy">You are using an <strong>outdated</strong> browser. Please <a href="http://browsehappy.com/">upgrade your browser</a> to improve your experience.</p>
<![endif]-->

<div id="header">
<nav>
<ul id="menu">
<li class="logo">
<a href="#"><img src="/images/logo32x32.png"></a>
</li>
<li class="active">
<a href="#!dashboard"><i class="fa fa-pagelines"></i> Dashboard</a>
</li>
<li>
<a href="#!users"><i class="fa fa-bullhorn"></i> Users</a>
</li>
<li>
<a href="#"><i class="fa fa-desktop"></i> App 1</a>
</li>
<li>
<a href="#"><i class="fa fa-dot-circle-o"></i> App 1</a>
</li>
<li>
<a href="#"><i class="fa fa-fire"></i> App 1</a>
</li>
</ul>
<ul id="user">
<li class="user_button">
<a href="#">
<span>Your Name</span>
<img src="http://placekitten.com/32/32">
</a>
</li>
</ul>
</nav>
</div>
<div id="workspace">
<div id="workspace-menu">
<div class="dashboard">
<ul>
<li><a href="#!dashboard;tasks">My tasks</a></li>
<li><a href="#!dashboard;projects">Projects</a></li>
</ul>
</div>
<div id="header">
<nav>
<ul id="menu">
<li class="logo">
<a href="#"><img src="/images/logo32x32.png"></a>
</li>
<li class="active">
<a href="#!dashboard"><i class="fa fa-pagelines"></i> Dashboard</a>
</li>
<li>
<a href="#!users"><i class="fa fa-bullhorn"></i> Projects</a>
</li>
<li>
<a href="#"><i class="fa fa-desktop"></i> Tasks</a>
</li>
<li>
<a href="#"><i class="fa fa-dot-circle-o"></i> Assets</a>
</li>
<li>
<a href="#"><i class="fa fa-fire"></i> Scenes</a>
</li>
</ul>
<ul id="user">
<!--
<li class="user_button">
<a href="#">
<span>Your Name</span>
<img src="http://placekitten.com/32/32">
</a>
</li>
-->
</ul>
</nav>
</div>
<div id="workspace">
<div id="workspace-menu">
<div class="dashboard">
<ul>
<li><a href="#!dashboard;tasks">My tasks</a></li>
<li><a href="#!dashboard;projects">Projects</a></li>
</ul>
</div>

<div class="users">
<ul>
<li><a href="#!users;userlist">Userlist</a></li>
<li><a href="#!users;projects">Projects</a></li>
<li><a href="#!users;groups">Groups</a></li>
</ul>
</div>
</div>
<div id="workspace-area">
</div>
</div>
<div class="users">
<ul>
<li><a href="#!users;userlist">Userlist</a></li>
<li><a href="#!users;projects">Projects</a></li>
<li><a href="#!users;groups">Groups</a></li>
</ul>
</div>
</div>
<div id="workspace-area">
</div>
</div>


<!-- build:js scripts/vendor.js -->
<!-- bower:js -->
<script src="bower_components/jquery/jquery.js"></script>
<script src="bower_components/react/react.js"></script>
<script src="bower_components/react/JSXTransformer.js"></script>
<!-- endbower -->
<!-- endbuild -->
<!-- build:js scripts/vendor.js -->
<!-- bower:js -->
<script src="bower_components/jquery/jquery.js"></script>
<script src="bower_components/react/react.js"></script>
<script src="bower_components/react/JSXTransformer.js"></script>
<!-- endbower -->
<!-- endbuild -->

<!-- Google Analytics: change UA-XXXXX-X to be your site's ID. -->
<script>
(function(b,o,i,l,e,r){b.GoogleAnalyticsObject=l;b[l]||(b[l]=
function(){(b[l].q=b[l].q||[]).push(arguments)});b[l].l=+new Date;
e=o.createElement(i);r=o.getElementsByTagName(i)[0];
e.src='//www.google-analytics.com/analytics.js';
r.parentNode.insertBefore(e,r)}(window,document,'script','ga'));
ga('create','UA-XXXXX-X');ga('send','pageview');
</script>
<!-- Google Analytics: change UA-XXXXX-X to be your site's ID. -->
<script>
(function(b,o,i,l,e,r){b.GoogleAnalyticsObject=l;b[l]||(b[l]=
function(){(b[l].q=b[l].q||[]).push(arguments)});b[l].l=+new Date;
e=o.createElement(i);r=o.getElementsByTagName(i)[0];
e.src='//www.google-analytics.com/analytics.js';
r.parentNode.insertBefore(e,r)}(window,document,'script','ga'));
ga('create','UA-XXXXX-X');ga('send','pageview');
</script>

<!-- build:js scripts/main.js -->
<script src="scripts/classes/api.js"></script>
<!-- build:js scripts/main.js -->
<script src="scripts/classes/api.js"></script>
<script type="text/jsx" src="scripts/components/filteredlist.js"></script>
<script type="text/jsx" src="scripts/components/notificationstream.js"></script>
<script type="text/jsx" src="scripts/dashboard.js"></script>
<script src="scripts/main.js"></script>
<!-- endbuild -->
<script type="text/jsx" src="scripts/components/usermenu.js"></script>
<script type="text/jsx" src="scripts/dashboard.js"></script>
<script src="scripts/main.js"></script>
<!-- endbuild -->
</body>
</html>
4 changes: 0 additions & 4 deletions app/scripts/components/notificationstream.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
/** @jsx React.DOM */

/*
This will be used as a reference module.
*/

(function() {
"use strict";

Expand Down
48 changes: 48 additions & 0 deletions app/scripts/components/usermenu.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/** @jsx React.DOM */

(function() {
"use strict";

$.ajaxSetup ({
cache: false,
headers: {'Authorization': 'Token 740a04407a34316403eba0cceaf395a812180c0d'}
});

var UserMenu = React.createClass({
getInitialState: function() {
return {username: 'Loading...', avatar_src:null};
},
componentWillMount: function() {
var component = this;
var data_xhr = Request('/user/');
data_xhr.done(function( data ) {
component.state.username = data.username;
component.state.url = data.url;
component.state.id = data.id;
component.state.avatar_src = 'http://placekitten.com/32/32';
component.setState(component.state);
});
data_xhr.fail(function () {
component.state = component.getInitialState();
component.state.username = 'Please login.';
component.setState(component.state);
});
},
render: function() {
return (
<li className="user_button" data-url={this.state.url} data-id={this.state.id}>
<a href="#">
<span>{this.state.username}</span>
<img src={this.state.avatar_src} />
</a>
</li>
);
}
});
window.UserMenu = UserMenu;

window.renderUserMenu = function () {
React.renderComponent(<UserMenu></UserMenu>, $("#user")[0]);
};

} ());
100 changes: 51 additions & 49 deletions app/scripts/main.js
Original file line number Diff line number Diff line change
@@ -1,58 +1,60 @@
(function() {
"use strict";
var currentView = false;

var workspace = {
init: function() {
var workspace_height = $(window).height() - $("#menu").height();
$("body").css("height", workspace_height);
$("#workspace").css("height", workspace_height);
}
};

$(function() {
$(window).on("resize", function() {
workspace.init();
});

workspace.init();
});


var LoadView = function(view, viewName, state) {
if ( currentView ) {
$("#workspace-menu > div").removeClass("active");
$("#workspace-area > div").removeClass("active");
}

$("#workspace-menu > div." + viewName).addClass("active");
$("workspace-area > div." + viewName).addClass("active");

/*
Setting up menu and submenu highlights.
*/
$("#workspace-menu > div." + viewName + " li").removeClass("active");
$("#workspace-menu > div." + viewName).find("li a[href='#!" + viewName + ";" + state + "']").parent().addClass("active");

$("#menu li").removeClass("active");
$("#menu li a[href='#!" + viewName + "']").parent().addClass("active");

view(state);
//Keepin' track of ma state.
currentView = viewName;
}

$(window).on("hashchange", function() {
var clickedView = window.location.hash.substr(2).split(";")[0];
console.log(clickedView+' '+clickedView.charAt(0).toUpperCase() + clickedView.slice(1));
console.log(window.location.hash.substr(2).split(";")[1]);
LoadView( window[clickedView.charAt(0).toUpperCase() + clickedView.slice(1)], clickedView, window.location.hash.substr(2).split(";")[1] );
});
"use strict";
var currentView = false;

var workspace = {
init: function() {
var workspace_height = $(window).height() - $("#menu").height();
$("body").css("height", workspace_height);
$("#workspace").css("height", workspace_height);
}
};

$(function() {
$(window).on("resize", function() {
workspace.init();
});

workspace.init();
});


var LoadView = function(view, viewName, state) {
if ( currentView ) {
$("#workspace-menu > div").removeClass("active");
$("#workspace-area > div").removeClass("active");
}

$("#workspace-menu > div." + viewName).addClass("active");
$("workspace-area > div." + viewName).addClass("active");

/*
Setting up menu and submenu highlights.
*/
$("#workspace-menu > div." + viewName + " li").removeClass("active");
$("#workspace-menu > div." + viewName).find("li a[href='#!" + viewName + ";" + state + "']").parent().addClass("active");

$("#menu li").removeClass("active");
$("#menu li a[href='#!" + viewName + "']").parent().addClass("active");

view(state);

//Keepin' track of ma state.
currentView = viewName;
}

$(window).on("hashchange", function() {
var clickedView = window.location.hash.substr(2).split(";")[0];
console.log(clickedView+' '+clickedView.charAt(0).toUpperCase() + clickedView.slice(1));
console.log(window.location.hash.substr(2).split(";")[1]);
LoadView( window[clickedView.charAt(0).toUpperCase() + clickedView.slice(1)], clickedView, window.location.hash.substr(2).split(";")[1] );
});

$(document).ready(function () {
if ( window.location.hash ) {
var hash = window.location.hash.substr(2).split(";")[0];
LoadView( window[hash.charAt(0).toUpperCase() + hash.slice(1)], hash, window.location.hash.substr(2).split(";")[1] );
}
setTimeout(function () {window.renderUserMenu();}, 100);
});
} ());
2 changes: 2 additions & 0 deletions app/styles/main.scss
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ a {
}
img {
margin-left: 5px;
width: 32px;
height: 32px;
}
}
}
Expand Down

0 comments on commit 44247d4

Please sign in to comment.