-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3a638f6
commit 44247d4
Showing
5 changed files
with
200 additions
and
149 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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]); | ||
}; | ||
|
||
} ()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
}); | ||
} ()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -55,6 +55,8 @@ a { | |
} | ||
img { | ||
margin-left: 5px; | ||
width: 32px; | ||
height: 32px; | ||
} | ||
} | ||
} | ||
|