Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
with
58 additions
and 25 deletions.
- +57 −0 src/debug.coffee
- +1 −25 src/init.coffee
@@ -0,0 +1,57 @@ | ||
utils = require "../utils" | ||
|
||
window.document.onkeydown = (event) -> | ||
|
||
if event.keyCode == 27 # Escape | ||
|
||
for view in View.Views | ||
|
||
if view._debug | ||
view._element.removeChild view._debug.node | ||
view.style = view._debug.style | ||
view.clip = view._debug.clip | ||
|
||
delete view._debug | ||
|
||
else | ||
|
||
color = "rgba(50,150,200,.35)" | ||
# color = utils.randomColor(.2) | ||
|
||
node = document.createElement "div" | ||
node.innerHTML = "#{view.name or view.id}" | ||
node.innerHTML += " <span style='opacity:.5'>in #{view.superView.name or view.superView.id}</span>" if view.superView | ||
|
||
node.style.position = "absolute" | ||
node.style.padding = "3px" | ||
|
||
view._debug = | ||
style: utils.extend {}, view.style | ||
node: node | ||
clip: view.clip | ||
|
||
view._element.appendChild node | ||
view.style = | ||
color: "white" | ||
margin: "-1px" | ||
font: "10px/1em Monaco" | ||
backgroundColor: "#{color}" | ||
# boxShadow: "inset 0 0 1px rgba(50,150,200,.8)"; | ||
border: "1px solid #{color}" | ||
backgroundImage: null | ||
view.clip = false | ||
|
||
|
||
window.onerror = (e) -> | ||
errorView = new View x:20, y:20, width:350, height:60 | ||
errorView.html = "<b>Javascript Error</b><br>Inspect the error console for more info." | ||
errorView.style = | ||
font: "13px/1.3em Menlo, Monaco" | ||
backgroundColor: "rgba(255,0,0,0.5)" | ||
padding: "12px" | ||
border: "1px solid rgba(255,0,0,0.5)" | ||
borderRadius: "5px" | ||
errorView.scale = 0.5 | ||
errorView.animate | ||
properties: {scale:1.0} | ||
curve: "spring(150,8,1500)" |