diff src/editor.tp @ 131:8285784f5ff5

Implement previous and next buttons
author Mike Pavone <pavone@retrodev.com>
date Wed, 07 Aug 2013 10:01:28 -0700
parents 2b25d0ce2946
children 15aac5334b64
line wrap: on
line diff
--- a/src/editor.tp	Tue Aug 06 00:53:03 2013 -0700
+++ b/src/editor.tp	Wed Aug 07 10:01:28 2013 -0700
@@ -49,18 +49,22 @@
 		stopPropagation <- :Blah {
 		}
 	}
+
 	selection <- #{
 		valid? <- true
 		in <- {
 			(innode domNode) onclick: fakeEvent
 		}
 		out <- {
-			fakeEvent <- #{
-				stopPropagation <- :Blah {
-				}
-			}
 			((astnode up) domNode) onclick: fakeEvent
 		}
+		next <- {
+			(((astnode up) getNext: astnode) domNode) onclick: fakeEvent
+		}
+
+		previous <- {
+			(((astnode up) getPrev: astnode) domNode) onclick: fakeEvent
+		}
 	}
 }
 
@@ -80,6 +84,13 @@
 			}
 			((astnode up) domNode) onclick: fakeEvent
 		}
+		next <- {
+			console log: "selection next"
+			(((astnode up) getNext: astnode) domNode) onclick: fakeEvent
+		}
+		previous <- {
+			(((astnode up) getPrev: astnode) domNode) onclick: fakeEvent
+		}
 	}
 }
 
@@ -321,6 +332,18 @@
 		}
 	}
 
+	(q: "#next") onclick!: :event {
+		if: (selection valid?) {
+			selection next
+		}
+	}
+
+	(q: "#prev") onclick!: :event {
+		if: (selection valid?) {
+			selection previous
+		}
+	}
+
 	path <- (window location) pathname
 	if: (path indexOf: "/edit/") = 0 {
 		editFile: (path substr: 5)