Module: jQuery/cairn

jQuery/cairn

Methods for the Cairn jQuery plugin for navigating to URI from within JavaScript for faster browsing.
Version:
  • 1.0
Source:

Methods

<static> click(elm, event)

Replace the default link behavior for faster navigation.
Parameters:
Name Type Description
elm object The anchor tag element.
event event A click event.
Source:
Example
 
$('a').live('click', function(event){
    $().cairn('click', this, event);
})

<static> goto(uri, pushstate, request)

Prepare the environment and request the URI be rendered.
Parameters:
Name Type Description
uri string The URI to navigate to.
pushstate boolean If true it will push thet history state in the browser.
request array Any additional variables sent on the request query variable.
Source:
Example
 
$().cairn('goto', '/gallery/');

<static> init(d)

Initialize the environment with our uri rules
Parameters:
Name Type Description
d array An array of uri rules.
Source:
Example
 
var data = {
    "uri": [
        { 
            "path" : "^/$",
            "view" : "main",
            "title": "Welcome",
            "callback" : "welcome_callback",
            "class" : "welcome",
            "template": "/templates/welcome.ejs"
        },
        { 
            "path" : "^/news/%year%/%monthnum%/%postname%/?$",
            "callback" : "news_callback",
            "view" : "main",
            "title": "News",
            "request" : {
                "post_type" : "post", 
                "year" : "%year%",
                "monthnum" : "%monthnum%",
                "name" : "%postname%"
            },
            "class" : "single",
            "template": "/templates/single.ejs"
         }
    ]
}
$().cairn('init', data, 'stage_loaded_callback', 'stage_leaving_callback');

<static> post(uri, pushstate, request)

Posts data and goes to the desired URI.
Parameters:
Name Type Description
uri string The URI to navigate to.
pushstate boolean Weither or not to push the history state in the browser.
request array The associative array to post to the server.
Source:
Example
 
$().cairn('post', '/gallery/invoice/bitcoin/', false, data['request'] )

<static> preclick(elm)

Request a link in advance, so that when the link is clicked it loads instantly.
Parameters:
Name Type Description
elm object An anchor tag HTML element.
Source:
Example
 
$().cairn('preclick', $('#previous'));

<static> preload(preload)

Preload images in advance.
Parameters:
Name Type Description
preload array An array of image sources.
Source:
Example
 
var images = ['a.png', 'b.png', 'c.png'];
$().cairn('preload', images);

<static> request(uri)

Request the URI be rendered by matching rules defined using init.
Parameters:
Name Type Description
uri string The URI to navigate to.
Source:
Example
 
$().cairn('request', '/gallery/');