GithubHelp home page GithubHelp logo

modulexcite / polypage Goto Github PK

View Code? Open in Web Editor NEW

This project forked from andykent/polypage

0.0 1.0 0.0 282 KB

A jQuery plugin to ease the development of dynamic html wireframes with state.

HTML 14.60% JavaScript 80.87% CSS 4.53%

polypage's Introduction

PolyPage

Polypage was designed to ease the process of showing multiple page states in html mock-ups. By simply adding class names to a document you can imply state and conditional view logic.

BASIC USAGE

Initialise PolyPage...

$(document).ready(function() {
	$('body').polypage();
});

Use stateful class names in your html...

<li class="pp_admin">pp_admin</li>
<li class="pp_not_logged_in other_test_class">pp_not_logged_in</li>
<li class="test_class pp_logged_in_or_admin other_test_class">pp_logged_in_or_admin</li>
<li class="pp_logged_in_and_admin">pp_logged_in_and_admin</li>
<li class="pp_not_logged_in_and_not_admin">pp_not_logged_in_and_not_admin</li>

Use special href attributes to trigger state changes if required...

<a href="#pp_toggle_logged_in">Log In Toggle</a>
<a href="#pp_set_logged_in_true">Log In</a>
<a href="#pp_set_logged_in_false">Log Out</a>

Use special form actions to trigger state changes if required...

<form action="#pp_toggle_logged_in" method="get">
  <input type="submit" value="Log in"/>
</form>

API

PolyPage makes extensive use of custom events and triggering/binding to these is the recommended way of interacting with page states programatically. Here are some examples (which assume you have bound polypage to the 'body')...

Toggle the logged in state...

$('body').trigger('pp_toggleState', 'logged_in');

Set the logged in state...

$('body').trigger('pp_setState', { logged_in:true });

Set the logged in state...

$('body').trigger('pp_setState', { logged_in:true });

Listen for state changes...

$('body').bind('pp_stateChange', function(e, state) { 
  alert("state "+ state.name + " changed to " + state.value); 
});

See the specs for some more examples.

ADVANCED USAGE

Under the hood PolyPage is logically separated into a core library and several extensions. The currently implemented extensions are...

  • Base: the core event system and bare essentials to get polypage working
  • GUI: the nav bar for pre-built GUI interactions
  • Events: some default event handlers for taking care of polypage formatted click and submit events automagically
  • Cookies: cookie support for maintaining state across pages
  • Keyboard: Keyboard shortcuts for toggling states via "ALT + first_letter_of_state_name"

Full documentation for all of the extensions will be coming soon but for now you can see the source code for available options.

Some usage examples

Starting PolyPage without cookie support or Event helpers...

$('body').polypage({ cookie:false, events:false });

Starting PolyPage with a 2 day cookie expiry a 'ux' prefix and no Event helpers...

$('body').polypage({ prefix:'ux', cookie:{ expires:2 }, events:false });

Roll your own PolyPage! if you want to completely customise PolyPage then you can break away from using the polypage() function and initialize the individual components yourself...

$(el).ppBase(opts);
$(el).ppEvents(opts);
$(el).ppGUI(opts);
$(el).ppCookie(opts);
$(el).ppKeyboard(opts);

MORE INFO

For an example open the index.html file in a web browser.

If you would prefer be using MooTools instead of jQuery then for the moment you really should checkout cheeaun's fork http://github.com/cheeaun/polypage which contains lots of MooTools goodness.

CONTRIBUTERS

polypage's People

Contributors

andykent avatar greut avatar

Watchers

 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.