From 6129bbce177c13383198433bbd09c50b663157e8 Mon Sep 17 00:00:00 2001 From: Jeremy Penner Date: Tue, 15 Feb 2011 08:42:27 -0800 Subject: [PATCH] Add section navigation controls --- iffy.coffee | 25 ++++++++++++++++++++++++- timemachine.xml | 7 ++++++- 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/iffy.coffee b/iffy.coffee index 42748d8..92c788a 100644 --- a/iffy.coffee +++ b/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,7 +152,13 @@ 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("
#{@Link("Previous section", () => @GoBackOneSection())}
") + + # 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("
#{stHtmlNav}
") + 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 = $("
") for dHTML in $(@dNev).contents() diff --git a/timemachine.xml b/timemachine.xml index 6e3970e..039a616 100644 --- a/timemachine.xml +++ b/timemachine.xml @@ -31,7 +31,7 @@ - +

Larry reaches for the button and gives it a push.

"Nothing happened", says Larry, looking at the [computer].

"I told you you were going to push it," says [Richard].

@@ -45,4 +45,9 @@

"Never mind," says [Richard].

+
+ + Larry is alone with the DeLorean in the lab, for the first time. + +