Canteen.Site Class
The Canteen Site is the client wrapper for the server API. Here's an example of how to initialize on your site:
$(function(){
var site = Canteen.Site.instance;
site.on('ready', function(){
// Site is ready!
});
});
Item Index
Methods
Properties
Events
Methods
_callbackIndex
-
name
-
callback
Returns callback array index.
Returns:
Callback array index, or -1 if isn't registered.
_enableHistory
-
enable
Enable the history
Parameters:
-
enable
BooleanIf the history state change should be on
_enterPage
()
private
Get the page for the current state
_fixInternalLinks
()
private
Fix the page links, form element and anything that requires jQuery
_gatewayReady
-
succes
Callback when a gateway is finished setting up
Parameters:
-
succes
BooleanIf gateway initialization was successfully
_onStateChanged
()
private
Handler for the history state change
_updatePageContent
-
uri
-
[params]
Update the page content
Parameters:
-
uri
StringThe uri to request page for
-
[params]
Dictionary optionalPost parameters to pass to the page
addPage
-
uriOrRegExp
-
pageInstance
Bind a uri to a page class
Parameters:
-
uriOrRegExp
String | RegExpThe page uri or regular expression of uri
-
pageInstance
Canteen.PageThe Page object to use for uri
getPageByUri
-
uri
Get a specific page by a uri
Parameters:
-
uri
StringThe uri to fetch page for
Returns:
The page object or null, if no page is found
off
-
name
-
callback
Remove the event listener
on
-
name
-
callback
Add an event listener
Parameters:
Returns:
Return this EventDispatcher
redirect
-
uri
-
[replaceInHistory=false]
-
[allowRefresh=false]
-
[asyncRefresh=true]
Redirect the page to a URI (about/overview)
Parameters:
-
uri
StringThe site uri, without the base url
-
[replaceInHistory=false]
Boolean optionalIf we should replace the current page in the history
-
[allowRefresh=false]
Boolean optionalIf we should allow page refreshes if the user redirects to the current page (default is false)
-
[asyncRefresh=true]
Boolean optionalIf the refresh should be asyncronous
refresh
-
[async=true]
-
[params]
Do a refresh of the page content
Parameters:
-
[async=true]
Boolean optionalIf the refresh should be asyncronous
-
[params]
Mixed optionalIf async, some optional post parameters
resize
()
Called whenever the window resizes, pass along to page
trigger
-
type
-
params
Dispatch an event
Parameters:
-
type
StringThe event string name,
-
params
Additional parameters
Properties
_currentId
Int
private
The current state count
_instance
Site
private
The singleton instance of the site
gateway
Gateway
The instancee of the gateway
instance
Site
static
Get the singleton instance of the site
options
Dictionary
The current setup options
options.pageLoadingId
String
The jQuery selector to add loading class for page loading
Default: "article"
parameters
Dictionary
The collection of query string parameters