Skip to content
This repository was archived by the owner on May 23, 2020. It is now read-only.
/ frame Public archive

Ajax and modals pattern with the aim of pushState, enjoy the power of google+ like navigation

License

Notifications You must be signed in to change notification settings

toloco/frame

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FRAME.js

Ajax and modals pattern with pushState update, enjoy the power of google+ like navigation

Ajax load into a main div and updates browser history with pushState Ajax load modal Open in new tab will work if you take care

Requeriments:

  • Jquery >= 1.8
  • Bootstrap >= 3.0 (only if you plan to use modals)

Configuration:

Add this javascript on your html code ( after jquery definition )

    $(document).ready(function (){
        Frame.init();
    });

Or the full config (just overiding default)

    $(document).ready(function (){
        Frame.init(
        	{
        		//Classes that points the elements
        		'ajax-marker'    : 'ajax',
        		'modal-marker'   : 'modalist',
        		'confirm-marker' : 'confirm',

        		'history-update' : true,

        		//Ids for main and mainloader
        		'ajax-frame'     : 'main',
        		'ajax-loader'    : 'mainloader',
        		'modal-frame'    : 'theModal',
        	}
        );
    });

Use:

Ajax links into a container:

Easy just add the ajax-marker class (or default value ajax), frame.js wil catch the click event and load into ajax-frame

	<a class="btn **ajax**" href="test2.html">

Or if you do not need browser history for the link add the attribute history="false"

	<a class="btn **ajax**" href="test2.html" **history="false"** >
Bonus

Add a loader, design a nice loader and add the id mainLoader or define it at ajax-loader

	<div id="mainloader"><img src='loading.gif' alt='' /></div>
	<div id="main"></div>

Modal links:

It is very add the modal-marker class (or default value modalist), frame.js wil catch the click event and show the url in a modal box

	<a class="btn **modalist**" href="ajax-center.html">

Programatically close the modal

	Frame.closeModal();

Or use bootstrap way inside the modal

	<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
New, full size pictures

Add pictures links very easy with a full size modal view

    <a class="modalist" href="path/to/fullsize.png">
        <img src="path/to/thumbnail.png">
        <label> Click me to enlarge</label>
    </a>

Confirm links:

Add a confirm message (like alerts, I know they are ugly but I promise making them nicer) and still having the ajax and modal behavior.

As usual in frame.js ;), add the class confirm or the confirm-marker if you overide it, set the message with the attribute confirm-message="MESAGE"

Confirm and redirect
	<a class="btn confirm" href="test2.html" confirm-message="Sure X ?">
Confirm and load ajax
	<a class="btn confirm ajax" href="test2.html" confirm-message="Sure X ?" >
Confirm and load, forgetting the history
	<a class="btn confirm ajax" href="test2.html" confirm-message="Sure X ?" history="false" >
Confirm and show modal
	<a class="btn confirm modalist" href="ajax-center.html" confirm-message="Sure X ?">

githalytics.com alpha

About

Ajax and modals pattern with the aim of pushState, enjoy the power of google+ like navigation

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published