summaryrefslogtreecommitdiff
path: root/public/assets/javascripts/ui/_router.js
diff options
context:
space:
mode:
Diffstat (limited to 'public/assets/javascripts/ui/_router.js')
-rw-r--r--public/assets/javascripts/ui/_router.js101
1 files changed, 78 insertions, 23 deletions
diff --git a/public/assets/javascripts/ui/_router.js b/public/assets/javascripts/ui/_router.js
index 6d41d5b..d070d55 100644
--- a/public/assets/javascripts/ui/_router.js
+++ b/public/assets/javascripts/ui/_router.js
@@ -5,6 +5,7 @@ var SiteRouter = Router.extend({
events: {
"click [data-role='show-signup-modal']": 'signup',
"click [data-role='show-signin-modal']": 'signin',
+ "click [data-role='forgot-password']": 'passwordForgot',
"click [data-role='new-project-modal']": 'newProject',
"click [data-role='edit-project-modal']": 'editProject',
"click [data-role='edit-profile-modal']": 'editProfile',
@@ -18,6 +19,11 @@ var SiteRouter = Router.extend({
routes: {
"/login": 'signin',
"/signup": 'signup',
+
+ "/auth/usernameTaken": 'usernameTaken',
+ "/auth/password": 'passwordReset',
+ "/auth/forgotPassword": 'passwordForgot',
+
"/profile": 'profile',
"/profile/edit": 'editProfile',
"/about/:name/edit": 'editDocument',
@@ -29,7 +35,10 @@ var SiteRouter = Router.extend({
"/project": 'projectPicker',
"/project/new": 'newProject',
"/project/new/:layout": 'projectNewWithLayout',
- "/project/:name": 'projectEditor',
+ "/project/:name": 'project',
+ "/project/:name/view": 'projectViewer',
+
+ "/test/wallpaper": 'testWallpaper',
},
initialize: function(){
@@ -40,7 +49,9 @@ var SiteRouter = Router.extend({
this.newProjectModal = new NewProjectModal()
this.editProjectModal = new EditProjectModal()
this.editProfileModal = new EditProfileModal()
+ this.passwordForgotModal = new PasswordForgot()
this.documentModal = new DocumentModal()
+ this.profileView = new ProfileView()
this.route()
@@ -52,7 +63,7 @@ var SiteRouter = Router.extend({
app.mode.builder = true
app.launch()
- this.builderView = new BuilderView()
+ this.builderView = app.controller = new BuilderView()
this.builderView.load(name)
},
@@ -83,25 +94,35 @@ var SiteRouter = Router.extend({
layout = slugify(layout)
window.history.pushState(null, document.title, "/project/new/" + layout)
- this.editorView = new EditorView()
+ this.editorView = app.controller = new EditorView()
this.editorView.loadLayout(layout)
},
- projectEditor: function(e, name){
- app.mode.editor = true
- app.launch()
-
+ project: function(e, name){
if ($(".aboutRoom").length) {
- this.readerView = new ReaderView()
- this.readerView.load(name)
+ this.projectViewer(e, name)
}
else {
- this.editorView = new EditorView()
- this.editorView.load(name)
+ this.projectEditor(e, name)
}
},
+ projectEditor: function(e, name){
+ app.mode.editor = true
+ app.launch()
+
+ this.editorView = app.controller = new EditorView()
+ this.editorView.load(name)
+ },
+ projectViewer: function(e, name){
+ app.mode.editor = true
+ app.launch()
+
+ this.readerView = app.controller = new ReaderView()
+ this.readerView.load(name)
+ },
+
/*
editProject: function(e){
e && e.preventDefault()
@@ -122,14 +143,23 @@ var SiteRouter = Router.extend({
this.signInModal.load()
},
- profile: function(e){
- var classes = ['one', 'two', 'three', 'four',
- 'five', 'six', 'seven', 'eight',
- 'nine', 'ten', 'eleven', 'twelve',
- 'thirteen'];
- $(".bio").addClass(choice(classes));
+ usernameTaken: function(e){
+ this.usernameTakenModal = new UsernameTaken ()
+ this.usernameTakenModal.load()
+ },
+ passwordForgot: function(e){
+ e && e.preventDefault()
+ window.history.pushState(null, document.title, "/auth/forgotPassword")
+ this.passwordForgotModal.load()
+ },
+ passwordReset: function(e){
+ this.passwordResetModal = new PasswordReset ()
+ this.passwordResetModal.load()
},
+ profile: function(e){
+ this.profileView.load()
+ },
editProfile: function(e){
e && e.preventDefault()
window.history.pushState(null, document.title, "/profile/edit")
@@ -160,16 +190,41 @@ var SiteRouter = Router.extend({
var name = e ? $(e.currentTarget).data("name") : name
- confirmModal.confirm("Are you sure you want to delete " + name + "?", $.proxy(function(){
- this.documentModal.destroy(name, $.proxy(function(){
- AlertModal.alert("Document deleted!", $.proxy(function(){
+ ConfirmModal.confirm("Are you sure you want to delete " + name + "?", function(){
+ this.documentModal.destroy(name, function(){
+ AlertModal.alert("Document deleted!", function(){
window.location.href = "/about"
- }, this))
- }, this))
- }, this))
+ }.bind(this))
+ }.bind(this))
+ }.bind(this))
// this.documentModal.destroy(name)
},
+
+ testWallpaper: function(e){
+ var content = document.getElementById("content")
+ content.style.width = "680px"
+ content.style.margin = "0 auto"
+ var wm = new WallpaperManager()
+ app.on('wallpaper-ready', function(){
+ var black = [0,0,0,0]
+ var white = [255,255,255,1.0]
+ var swatches = wm.buildSwatches(black, white, 4)
+ document.body.style.backgroundColor = "#eee"
+ swatches.forEach(function(swatch){
+ swatch.style.margin = "4px"
+ swatch.style.border = "1px solid lime"
+ swatch.style.backgroundColor = "#888"
+ content.appendChild(swatch)
+ swatch.onclick = function(){
+ dataUrl = swatch.toDataURL()
+ document.body.style.backgroundImage = "url(" + dataUrl + ")"
+ }
+ })
+ })
+ wm.init()
+ },
+
})