clean up nev ui code; add hover class -- show undo only on hover over nev
This commit is contained in:
parent
dee1904af0
commit
f0281afe38
29
iffy.coffee
29
iffy.coffee
|
@ -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,7 +233,15 @@ 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 :(
|
||||
|
||||
# narrative event -- the story is told as a sequence of these. Contains the HTML to display when the
|
||||
|
@ -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) ->
|
||||
|
|
Loading…
Reference in a new issue