diff options
Diffstat (limited to 'public')
| -rw-r--r-- | public/assets/javascripts/ui/DocumentModal.js | 41 | ||||
| -rw-r--r-- | public/assets/javascripts/ui/Router.js | 53 | ||||
| -rw-r--r-- | public/assets/javascripts/util.js | 4 | ||||
| -rw-r--r-- | public/assets/javascripts/vendor/ModalFormView.js | 2 | ||||
| -rwxr-xr-x | public/assets/stylesheets/app.css | 22 |
5 files changed, 111 insertions, 11 deletions
diff --git a/public/assets/javascripts/ui/DocumentModal.js b/public/assets/javascripts/ui/DocumentModal.js new file mode 100644 index 0000000..f821d07 --- /dev/null +++ b/public/assets/javascripts/ui/DocumentModal.js @@ -0,0 +1,41 @@ + + +var DocumentModal = ModalFormView.extend({ + el: ".mediaDrawer.editDocument", + createAction: "/api/docs/new", + updateAction: "/api/docs/edit", + + load: function(name, isNew){ + this.reset() + + if (isNew || name === "new") { + name = sanitize(name) + if (name !== "new") { + this.$("[name='new_name']").val( name.replace(/\s+/g,"-") ) + this.$("[name='displayName']").val( capitalize(name.replace(/-/g," ")) ) + } + this.action = this.createAction + return this.show() + } + + this.action = this.updateAction + + $.get("/api/docs", { name: name }, $.proxy(function(data){ + if (data.isNew) { + this.action = this.createAction + } + + for (var i in data) { + this.$("[name='" + i + "']").val(data[i]) + } + this.$("[name='new_name']").val(name) + + this.show() + }, this)) + }, + + success: function(res){ + window.location.pathname = "/about/" + res.name + } + +}) diff --git a/public/assets/javascripts/ui/Router.js b/public/assets/javascripts/ui/Router.js index a518e27..fea3698 100644 --- a/public/assets/javascripts/ui/Router.js +++ b/public/assets/javascripts/ui/Router.js @@ -8,14 +8,18 @@ var Router = View.extend({ "click [data-role='new-project-modal']": 'newProject', "click [data-role='edit-project-modal']": 'editProject', "click [data-role='edit-profile-modal']": 'editProfile', + "click [data-role='new-document-modal']": 'newDocument', + "click [data-role='edit-document-modal']": 'editDocument', }, routes: { - "/login": 'signin', - "/signup": 'signup', - "/project/new": 'newProject', - "/profile/edit": 'editProfile', - "/app": 'launch', + "/login": 'signin', + "/signup": 'signup', + "/project/new": 'newProject', + "/profile/edit": 'editProfile', + "/about/:name/edit": 'editDocument', + "/about/new": 'newDocument', + "/app": 'launch', }, initialize: function(){ @@ -24,13 +28,29 @@ var Router = View.extend({ this.newProjectModal = new NewProjectModal() this.editProjectModal = new EditProjectModal() this.editProfileModal = new EditProfileModal() + this.documentModal = new DocumentModal() this.originalPath = window.location.pathname + var path = window.location.pathname.split("/") + console.log(path) for (var route in this.routes) { - if (window.location.pathname.indexOf(route) === 0) { - this[this.routes[route]]() - break; + var routePath = route.split("/") + if (routePath[1] == path[1]) { + if (routePath[2] && routePath[2].indexOf(":") !== -1 && path[2] && (path[3] === routePath[3]) ) { + console.log("GOT :") + console.log(routePath) + this[this.routes[route]](null, path[2]) + break; + } + else if (routePath[2] == path[2]) { + this[this.routes[route]](null) + break; + } + else if (! routePath[2] && (! path[2].length || ! path[2])) { + this[this.routes[route]](null) + break; + } } } @@ -73,5 +93,22 @@ var Router = View.extend({ this.editProfileModal.load() }, + newDocument: function(e){ + e && e.preventDefault() + + var name = e ? $(e.currentTarget).data("name") : "new" + + window.history.pushState(null, document.title, "/about/new") + this.documentModal.load(name, true) + }, + + editDocument: function(e, name){ + e && e.preventDefault() + + var name = e ? $(e.currentTarget).data("name") : name + window.history.pushState(null, document.title, "/about/" + name + "/edit") + this.documentModal.load(name, false) + }, + }) diff --git a/public/assets/javascripts/util.js b/public/assets/javascripts/util.js index 64bda4d..ec2760c 100644 --- a/public/assets/javascripts/util.js +++ b/public/assets/javascripts/util.js @@ -7,6 +7,10 @@ if (window.$) { } function trim(s){ return s.replace(/^\s+/,"").replace(/\s+$/,"") } +function sanitize (s){ return (s || "").replace(new RegExp("[<>&\"\']", 'g'), "") } +function capitalize (s){ return s.split(" ").map(capitalizeWord).join(" ") } +function capitalizeWord (s){ return s.charAt(0).toUpperCase() + s.slice(1) } + var E = Math.E var PI = Math.PI diff --git a/public/assets/javascripts/vendor/ModalFormView.js b/public/assets/javascripts/vendor/ModalFormView.js index bb926d1..3ef7810 100644 --- a/public/assets/javascripts/vendor/ModalFormView.js +++ b/public/assets/javascripts/vendor/ModalFormView.js @@ -14,7 +14,7 @@ var ModalFormView = ModalView.extend({ }, reset: function(){ - this.$("input").not("[type='submit']").not("[type='hidden']").val("") + this.$("input,textarea").not("[type='submit']").not("[type='hidden']").val("") }, load: function(){ diff --git a/public/assets/stylesheets/app.css b/public/assets/stylesheets/app.css index 4a17214..e3f4de5 100755 --- a/public/assets/stylesheets/app.css +++ b/public/assets/stylesheets/app.css @@ -318,6 +318,18 @@ h5{ padding-top: 25px; } +/* DOCUMENTATION / ABOUT SECTION / FAQ PAGES */ + +.docs .content { + width: 600px; + margin: 0 auto; + text-align: left; +} + +.docs .content p { + margin: 1em 0; +} + .footer { width: 100%; margin: 80px 0; @@ -427,7 +439,6 @@ h5{ .profilepage .bio span:after { content: ' \00b7 ' } .profilepage .bio span:last-of-type:after { display: none; } - .templates { padding-top: 7vh; } @@ -1279,7 +1290,14 @@ form li div div { text-align: left; margin: 0 10px 10px 0; } - +form li img#load_avatar { + max-width: 200px; +} +form li textarea { + width: 100%; + height: 300px; + margin-top: 20px; +} .video { height:80vh; |
