diff --git a/iffy.coffee b/iffy.coffee index d6e98d2..49b75cb 100644 --- a/iffy.coffee +++ b/iffy.coffee @@ -153,8 +153,14 @@ class Gst

#{@story.jStory.attr('title')}

#{@story.jStory.attr('author')}

") + dgEnter = () -> $(this).addClass('hover') + dgLeave = () -> $(this).removeClass('hover') + for wst in @RgwstRun() - @jDiv.append($("
").append(wst.nev.StHtmlDisplay(this, wst))) + jDivNev = $("
") + 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 + "

[[error interpreting markup: #{error}]]

" 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) + "
#{gst.StHtmlUi(wst)}
#{gst.FilterStHtml(stHtml, wst)}
" #[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 = "
#{stHtmlNew}
" + - "" - stHtmlNew - + "Undo" class Story constructor: (@jStory) -> diff --git a/test.html b/test.html index 596b570..a8aa3a8 100644 --- a/test.html +++ b/test.html @@ -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;