GithubHelp home page GithubHelp logo

munizart / irouter.js Goto Github PK

View Code? Open in Web Editor NEW

This project forked from alhacen/irouter.js

0.0 1.0 0.0 195 KB

irouter.js a tiny, light-weight JavaScript page navigator

License: Other

JavaScript 0.39% HTML 99.61%

irouter.js's Introduction

irouter

irouter.js is a tiny, light-weight JavaScript page navigator

Getting Started

Include the library :

include irouter in your page <script src="https://irouter.js.org/lib/ver-0.2/irouter.min.js"></script>

usage :

add ipage class to every navigation container, and also add ipage-default to the default container.
if there is no hash in url then ipage-default will be navigate.

<div id="page1" class="ipage ">
  page 1
</div>
<div id="page2" class="ipage">
  page 2
</div>
<div id="page3" class="ipage ipage-default">
  page 3
</div>

<a href="#!page1">page1</a>
<a href="#!page2">page2</a>
<a href="#!page3">page3</a>

live example

By HTTP request:

for using advanced functions of the library use irouter attribute. irouter take values in json format
i.e. irouter='{"[prop name]":"[prop value]",...}'

<div id="page1" class="ipage ipage-default" irouter='{"get":"component/about-html.html"}'>
  page 1
</div>
<div id="page2" class="ipage" irouter='{"get":"component/about-javascript.html","cache":"false"}'>
  page 2
</div>
<div id="page3" class="ipage" irouter='{"get":"component/about-php.html","loading-screen":"loading-screen-id"}'>
  page 3
</div>
<div id="loading-screen-id" class="iloading-screen">
  <div class="loader">Wait its loading...</div>
</div>
<a href="#!page1">page1</a>
<a href="#!page2">page2</a>
<a href="#!page3">page3</a>

custom loading:

add class iloading-screen in custom loading container and use id of that container as value of loading-screen prop in irouter.
{..."loading-screen":"[loading-screen-id]"...}
live example

Prop Name Default Description
`get / post` its required Request method
`insert-into` id of that container where to insert server response
`cache` true if content if fetched form server then it will not requested again if `{"cache":"true"}`
`loading-screen` Loading... custom loading screen

irouter.js's People

Contributors

alhacen avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.