view editor.tp @ 12:6e4851a204a5

Add ability to load code into editor
author Mike Pavone <pavone@retrodev.com>
date Wed, 21 Mar 2012 23:13:51 -0700
parents 5447cff52da6
children 85fb6ba15bc6
line wrap: on
line source
#{
//mquery functions
q <- foreign: :query {}
qall <- foreign: :query {}
each <- foreign: :iterable fun {}
addClass <- foreign: :node className {}
removeClass <- foreign: :node className {}
get <- foreign: :url onSuccess onFail onOther {}

//tabletprog JS helpers
setP <- foreign: :object property val {}
getP <- foreign: :object property {}

//js builtins
console <- foreign: #{
	log <- foreign: #{}
}

main <- {
	//bind handlers for file browser links
	each: (qall: "a") :idx el {
		el setP: "onclick" :event {
			console log: "click"
			link <- foreign: this
			get: (link getP: "href") :request {
				addClass: (q: "body") "editorMode"
				console log: (request getP: "responseText")
				(q: "#src") setP: "textContent" (request getP: "responseText")
			}
			console log: "returning false"
			foreign: false
		}
	}
	
	//bind handlers for editor buttons
	each: (qall: ".controls li") :idx el {
		el setP: "onclick" :event {
			srcel <- (q: "#src")
			srcel setP: "textContent" (srcel getP: "textContent") + (el getP: "textContent")
		}
	}
	(q: "#ops_button") setP: "onclick" :event {
		addClass: (q: ".controls") "showops"
	}
	
	(q: "#builtin_button") setP: "onclick" :event {
		removeClass: (q: ".controls") "showops"
	}
}

}