Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Snowman: display a specific passage in all passages?

I want to implement something like Harlowe's footer/header feature... specifically for a menu for inventory, character notes etc. And be able to hide it on some passages (probably based on passage tags)

I'm pretty comfortable with javascript but not JQuery.

Can I respond to all "about to show a passage" events & modify the passage before it is shown? I guess I would do this in the story javascript? How would I go about it?

Comments

  • edited May 2017
    Something like this in your scripts should work, but I imagine there's a better way than using $(document).ready() (which is what $(function(){... does ). Someone here will know, though.
    $(function () {
    	 var header = document.createElement('DIV');
    	 $(header)
    		  .attr('id', 'myHeader')
    			.appendTo('html')
    	 		.append( story.passage('header').render() );
    });
    

    In the CSS, I just fixed the div to the top of the viewport and bumped the passages down a few lines:
    #myHeader {
      position: fixed;
      top: 0;
      right: 0;
      left: 0;
      height: 3em; 
      width: 100%;
      border-bottom: 1px solid #111;
      padding: 1em 12em; /* or something, i don't know */
    }
    
    #passage {
      margin-top: 5em; 
    }
    

    Then just make a passage called 'header' and put whatever you want in there.

    I have no idea at all how to access passage tags in snowman. Might be easier to just set up the logic of your header in the header passage--just have it hide the element when you don't want it:
    <% $('#myHeader').hide(); %>
    

    Don't forget to show it again, though.

    This really isn't my forte, so I'd check back for some better answers in a bit, but this should get you started.
Sign In or Register to comment.