{"id":21890112,"url":"https://github.com/ejfox/sstepper","last_synced_at":"2026-05-18T01:06:14.002Z","repository":{"id":7568701,"uuid":"8922891","full_name":"ejfox/sStepper","owner":"ejfox","description":"A stepper utility for interactive stories","archived":false,"fork":false,"pushed_at":"2013-03-25T01:16:42.000Z","size":166,"stargazers_count":4,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2026-04-03T21:49:49.449Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://ejfox.github.com/sStepper/","language":"CoffeeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ejfox.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-03-21T06:50:28.000Z","updated_at":"2014-05-13T05:23:42.000Z","dependencies_parsed_at":"2022-09-13T14:13:03.221Z","dependency_job_id":null,"html_url":"https://github.com/ejfox/sStepper","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ejfox/sStepper","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ejfox%2FsStepper","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ejfox%2FsStepper/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ejfox%2FsStepper/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ejfox%2FsStepper/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ejfox","download_url":"https://codeload.github.com/ejfox/sStepper/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ejfox%2FsStepper/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33161411,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-17T22:39:12.733Z","status":"ssl_error","status_checked_at":"2026-05-17T22:39:10.741Z","response_time":107,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-28T11:28:52.505Z","updated_at":"2026-05-18T01:06:13.988Z","avatar_url":"https://github.com/ejfox.png","language":"CoffeeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# sStepper\n## Lightweight story stepper\n\nOften when creating interactive stories, we need to control different \"steps\" in our interactive. Often this is a text box with different sections or steps of a story that have information about what the user is seeing. \n\n## How to use\n\nTo create our stepper, we must first create it's basic HTML structure. You want to wrap the whole stepper in an element with the ID **#sStepper**. Inside the sStepper you have the **#stepper-sections**. Optionally, you could also have **#stepper-navigation** if you'd like persistent previous/next buttons.\n\nAny element with the class of **.stepper-next** or **.stepper-prev** will change the stepper in the corresponding direction.\n\n## HTML Example\n\nAll you need to create a stepper is the correctly formatted HTML, and jQuery and sStepper included. \n```\n\u003cstyle type=\"text/css\" media=\"screen\"\u003e\n    .hidden-step { display: none;}\n    #stepper-navigation { padding: 0;}\n    #stepper-navigation li { \n        background-color: white;\n        display: inline-block;\n        list-style-type: none;\n        cursor: pointer;\n        padding: 1em;\n        border-radius: 4px;\n        border: 1px solid #CCC;\n        margin: 0;\n    }\n\u003c/style\u003e\n\n\u003cdiv id=\"sStepper\"\u003e\n\u003cul id=\"stepper-navigation\"\u003e\n    \u003cli href=\"#prev\" class=\"stepper-prev\"\u003ePrev\u003c/li\u003e\n    \u003cli href=\"#next\" class=\"stepper-next\"\u003eNext\u003c/li\u003e\n\u003c/ul\u003e\n\n\u003cdiv id=\"stepper-sections\"\u003e\n    \u003cdiv class=\"stepper-section\"\u003e\u003ch2\u003eStep one!\u003c/h2\u003e\u003c/div\u003e\n    \u003cdiv class=\"stepper-section\" data-enter-callback=\"alert('Hi!')\"\u003e\u003ch2\u003eStep two!\u003c/h2\u003e\u003c/div\u003e\n\u003c/div\u003e\n\n\u003c/div\u003e\n\n\u003cscript src=\"http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js\"\u003e\u003c/script\u003e\n\u003cscript src=\"sStepper.js\" type=\"text/javascript\" charset=\"utf-8\"\u003e\u003c/script\u003e        \n\u003cscript type=\"text/javascript\" charset=\"utf-8\"\u003e\n$(document).ready(function(){\n    sStepper.init(\"#sStepper\");\n})\n\u003c/script\u003e\n```\n\nThe **#stepper-sections** contains as many elements as you want with the class **.stepper-section**. \n    \n# sStepper.js\n    \n    sStepper = {}\n    sectionCount = 0\n    sections = []\n    options = {}\n    \n    sStepper.init = (stepperElement, sStepperOptions) -\u003e   \n    \n        options = sStepperOptions\n    \n        sections = $(stepperElement+\" .stepper-section\")\n    \n\nWe want to hide all of the sections but the first.\n\n        sections.each((i) -\u003e\n            sectionCount++\n            $(this).attr(\"id\", \"stepper-section-\"+ (i+1))\n        \n            if i is 0\n                $(this).addClass(\"active-step\")\n            else\n                $(this).addClass(\"hidden-step\")\n        )\n    \n### Adding listeners for previous/next    \nThe user would advance to the next step through either a link in the text, or directional buttons in the stepper. Whatever it is, it needs to have the class of \"stepper-next\" or \"stepper-prev\".\n\n    $(\"#sStepper .stepper-next\").click( -\u003e \n        sStepper.nextStep();\n    )\n    $(\"#sStepper .stepper-prev\").click( -\u003e    \n        sStepper.prevStep();\n    )\n\n### Checking which section we're on\n    \nWe're gonna want to be able to check on which step we're on, it will have the class **.active-step**.     \n    \n    sStepper.currentStep = () -\u003e\n        activeStep = $(\".active-step\")\n\n        if activeStep.attr(\"id\") isnt undefined\n            stepID = activeStep.attr(\"id\")\n            stepNumber = activeStep.attr(\"id\").split(\"-\")[2]        \n            parseInt(stepNumber)\n\n\n### Switching to a section        \nWe also need to handle users moving to the next and previous steps.\n        \n    sStepper.switchTo = (targetNum) -\u003e        \n        \nIf the user reaches the last step which we keep track of in **sectionCount**, we want to loop them back around to the beginning.\n         \n        if targetNum \u003e sectionCount\n            targetNum = 1\n        else if targetNum \u003c= 0\n            targetNum = sectionCount\n            \n        currentStep = sStepper.currentStep();\n        \n        #console.log \"current\", currentStep, \"target\", targetNum\n        \n        $(\"#stepper-section-\"+currentStep).removeClass(\"active-step\").addClass(\"hidden-step\")                \n        \n        newStep = $(\"#stepper-section-\"+targetNum)        \n        newStep.addClass(\"active-step\").removeClass(\"hidden-step\")\n\n        \nIn addition, whenever we change a step, there should be callback functions to exit the old step and enter the new one. That way we could do things like start an animation once a step starts, or change the type of visualization shown on the entire page. We define the callback functions for each section as a data attribute in the options or HTML. If options are supplied, we ignore the HTML callbacks.        \n    \n        if options isnt undefined\n            if options.callbacks isnt undefined\n                if options.callbacks['section'+currentStep] isnt undefined\n                    exitCallback = options.callbacks['section'+currentStep].exit\n                if options.callbacks['section'+targetNum] isnt undefined\n                    enterCallback = options.callbacks['section'+targetNum].enter\n        else\n            exitCallback = $(\"#stepper-section-\"+currentStep).attr(\"data-exit-callback\")\n            enterCallback = $(\"#stepper-section-\"+targetNum).attr(\"data-enter-callback\")\n        \n        if enterCallback isnt undefined\n            eval(enterCallback)\n\n        if exitCallback isnt undefined\n            eval(exitCallback)\n            \n        return true\n\nCall the switchTo function for +1 or -1 of the currentStep depending on whether it's the next or previous step.                                \n    \n    sStepper.nextStep = -\u003e    \n        currentStep = sStepper.currentStep();\n        sStepper.switchTo(currentStep + 1)            \n\n    sStepper.prevStep = -\u003e\n        currentStep = sStepper.currentStep();\n        sStepper.switchTo(currentStep - 1) \n        \n        \n### Navigation        \nFor navigation we add a link for each section.\n\n    if $(\"#stepper-navigation\").length \u003e 0   \n        for i in [1..$(\".stepper-section\").length]\n            navLink = $(\"\u003ca href='#' onclick='sStepper.switchTo(\"+i+\")'\u003eSection \"+i+\" \u003c/a\u003e \")\n            #navLink.on(\"click\", sStepper.switchTo(i));\n        \n            $(\"#stepper-navigation\").append(navLink)\n\n            \n        \n    \n    \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fejfox%2Fsstepper","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fejfox%2Fsstepper","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fejfox%2Fsstepper/lists"}