Giter Site home page Giter Site logo

routeur.js's Introduction

Routeur.js

A simple client-side Javascript/jQuery router.

I created this project because I needed a navigation that maintains some parts of the page running when the user navigate through the website. The idea here is to use js/jquery to load the pages via ajax.

It was created without any planning, the features were emerging according to the needs of each project, so the code is not finished yet.

What can be done with this project

  • Maintains parts of the page running during navigation (music players, timesheets).
  • Separating mobile and desktop pages dynamic, running under the same domain. For example: at the address http://domain.com/products we can load on desktop the page /views/desktop/products.php and on mobile /views/mobile/products.php.
  • Create different types of navigations and a better experience on different devices. For example: on mobile we can navigate like apps, using tabs and maintaining the content loaded, but normal on desktop, loading the full page.

Usage

Init the router

var router = new Routeur(allLinks = true, mobilePages = true, rootFolder = 'views');

mobilePages set true is to create different pages for desktop and mobile. rootFolder is where the pages are located.

Set the routes

router.add({ url:'product/{id}/{tab}', phpFile: 'product-tab.php'});
router.add({ url:'product/{id}', phpFile: 'product.php'});
router.add({ url:'categories', phpFile: 'categories.php'});
router.add({ url:'list', phpFile: 'list.php'});
router.add({ url:'/', phpFile: 'index.php'});
router.add({ url:'*', phpFile: 'profile.php'});

The last item, * uses id as parameter. The page used in the example, profile.php, will be loading like profile.php?id={url_typed}

Start navigation

router.run();

.htaccess

Remember to point all pages to index.php or to the default page you use.

Requires

  • jQuery
  • History.js

Similar projects

routeur.js's People

Stargazers

Roman avatar Renan Bastos avatar

Watchers

James Cloos avatar Beto Figueiredo avatar Renan Bastos 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.