clean up nev ui code; add hover class -- show undo only on hover over nev

This commit is contained in:
Jeremy Penner 2011-02-10 13:34:32 -08:00
parent dee1904af0
commit f0281afe38
2 changed files with 31 additions and 8 deletions

View file

@ -153,8 +153,14 @@ class Gst
<h1>#{@story.jStory.attr('title')}</h1>
<h2>#{@story.jStory.attr('author')}</h2>
</div>")
dgEnter = () -> $(this).addClass('hover')
dgLeave = () -> $(this).removeClass('hover')
for wst in @RgwstRun()
@jDiv.append($("<div class='nev'/>").append(wst.nev.StHtmlDisplay(this, wst)))
jDivNev = $("<div class='iffy-nev'/>")
jDivNev.append(wst.nev.StHtmlDisplay(this, wst))
@jDiv.append(jDivNev)
jDivNev.hover(dgEnter, dgLeave)
for stId_dgOnClick in @mpstId_dgOnClick
@jDiv.find("##{stId_dgOnClick[0]}").click(stId_dgOnClick[1])
@ -227,6 +233,14 @@ class Gst
catch error
stHtml = stHtml + "<p class='error'>[[error interpreting markup: #{error}]]</p>"
stHtml
StHtmlUi: (wst) ->
stHtmlUi = ""
for actor in @story.rgactor
if actor.StHtmlUi?
stHtmlUiT = actor.StHtmlUi(wst)
if stHtmlUiT?
stHtmlUi += stHtmlUiT
stHtmlUi
bind = (fn, me) -> ((args...) -> fn.apply(me, args))# argh new coffeescript won't let me use __bind :(
@ -255,7 +269,7 @@ class Nev
for dHTML in $(@dNev).contents()
jdivTmp.append(document.importNode(dHTML, true))
stHtml = jdivTmp[0].innerHTML
gst.FilterStHtml(stHtml, wst)
"<div class='iffy-nev-ui'>#{gst.StHtmlUi(wst)}</div><div class='iffy-nev-text'>#{gst.FilterStHtml(stHtml, wst)}</div>"
#[word text to display] -- links to a word, usually a noun, that the player can interact with in some way.
#[word] == [word word]
@ -411,13 +425,12 @@ class ActorPlayer
if rgnev? then new EniArray(rgnev) else EniEmpty
FilterStHtml: (stHtml, wst) ->
stHtmlNew = TemplateFromStNev(stHtml, wst)(wst)
TemplateFromStNev(stHtml, wst)(wst)
StHtmlUi: (wst) ->
if (wst.nev.player_nevIDRespondedTo?)
stId = wst.gst.RegOnClick(() => @RemoveResponse(wst.nev); wst.gst.Display())
stHtmlNew = "<div class='iffy-player-action'>#{stHtmlNew}</div>" +
"<div class='iffy-player-ui'><a href='javascript:void(0)' id='#{stId}' class='iffy-undo'>Undo</a></div>"
stHtmlNew
"<a href='javascript:void(0)' id='#{stId}' class='iffy-undo'>Undo</a>"
class Story
constructor: (@jStory) ->

View file

@ -8,6 +8,16 @@
position: absolute;
background-color: #eeeeee;
}
div.hover div {
background-color: #f2f2f2;
}
div.iffy-nev-ui {
display: none;
}
div.hover div.iffy-nev-ui {
display: inline;
float: right;
}
// a.iffy-word:link {
// text-decoration: none;
// color: #000000;