Add section navigation controls
This commit is contained in:
parent
200333b787
commit
6129bbce17
23
iffy.coffee
23
iffy.coffee
|
@ -127,6 +127,8 @@ class Nevgen
|
|||
nevgen = nevgen.NextI()
|
||||
nevgen
|
||||
NextI: () ->
|
||||
if @wst.nev.FEndsSection()
|
||||
return null
|
||||
if @respo?
|
||||
respoNext = @respo.Next(this)
|
||||
wst = @wst
|
||||
|
@ -150,6 +152,12 @@ class Gst
|
|||
isectionRemove = @rgsection.length - 1
|
||||
@rgsection.splice(isectionRemove, 1)
|
||||
@rgwstInit.splice(isectionRemove, 1)
|
||||
@Display()
|
||||
|
||||
PushSection: (section, wst) ->
|
||||
@rgsection.push(section)
|
||||
@rgwstInit.push(wst)
|
||||
@Display()
|
||||
|
||||
SectionCurrent: () ->
|
||||
@rgsection[@rgsection.length - 1]
|
||||
|
@ -166,6 +174,11 @@ class Gst
|
|||
dgEnter = () -> $(this).addClass('hover')
|
||||
dgLeave = () -> $(this).removeClass('hover')
|
||||
|
||||
# show "previous section" link
|
||||
if @rgsection.length > 1
|
||||
@jDiv.append("<div class='iffy-section-nav'>#{@Link("Previous section", () => @GoBackOneSection())}</div>")
|
||||
|
||||
# show all nevs in section
|
||||
@rgwst = null
|
||||
@rgwst = @RgwstRun()
|
||||
for wst in @rgwst
|
||||
|
@ -175,6 +188,11 @@ class Gst
|
|||
jDivNev.hover(dgEnter, dgLeave)
|
||||
@wstLast = wst
|
||||
|
||||
# show "next section" link
|
||||
stHtmlNav = @wstLast.nev.StHtmlNextSection(this, @wstLast)
|
||||
if stHtmlNav?
|
||||
@jDiv.append("<div class='iffy-section-nav'>#{stHtmlNav}</div>")
|
||||
|
||||
for stId_dgOnClick in @mpstId_dgOnClick
|
||||
@jDiv.find("##{stId_dgOnClick[0]}").click(stId_dgOnClick[1])
|
||||
|
||||
|
@ -288,7 +306,12 @@ class Nev
|
|||
wst = wst.WstPrev()
|
||||
return false
|
||||
FCanRun: (gst, wst) -> not @FHasRun(wst)
|
||||
FEndsSection: () -> $(@dNev).attr("nextsection")?
|
||||
RunAction: (gst, wst) ->
|
||||
StHtmlNextSection: (gst, wst) ->
|
||||
stSectionNext = $(@dNev).attr("nextsection")
|
||||
if stSectionNext?
|
||||
gst.Link("Next section", () -> gst.PushSection(gst.story.SectionByName(stSectionNext), wst))
|
||||
StHtmlDisplay: (gst, wst) ->
|
||||
jdivTmp = $("<div/>")
|
||||
for dHTML in $(@dNev).contents()
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
</verb>
|
||||
</word>
|
||||
<word name="button">
|
||||
<verb name="Push">
|
||||
<verb name="Push" nextsection="next">
|
||||
<p>Larry reaches for the button and gives it a push.</p>
|
||||
<p>"Nothing happened", says Larry, looking at the [computer].</p>
|
||||
<p>"I <i>told</i> you you were going to push it," says [Richard].</p>
|
||||
|
@ -45,4 +45,9 @@
|
|||
<p>"Never mind," says [Richard].</p>
|
||||
</pastresponse>
|
||||
</section>
|
||||
<section name="next">
|
||||
<nev name="start">
|
||||
Larry is alone with the DeLorean in the lab, for the first time.
|
||||
</nev>
|
||||
</section>
|
||||
</story>
|
||||
|
|
Loading…
Reference in a new issue