Documentation

include MVC MVC.Animate MVC.Class MVC.Controller MVC.Controller.Action MVC.Controller.Action.Drag MVC.Controller.Action.Drop MVC.Controller.Action.EnterLeave MVC.Controller.Action.Event MVC.Controller.Action.Hover MVC.Controller.Action.Lasso MVC.Controller.Action.Selectable MVC.Controller.Action.Subscribe MVC.Controller.Comet MVC.Controller.Params MVC.Controller.Params.Drag MVC.Controller.Params.Drop MVC.Controller.Stateful MVC.Delegator MVC.Doc MVC.Element MVC.Event MVC.File MVC.History MVC.IO MVC.IO.Ajax MVC.IO.Comet MVC.IO.JsonP MVC.IO.WindowName MVC.IO.XDoc MVC.Model MVC.Model.Ajax MVC.Model.Cookie MVC.Model.JsonP MVC.Model.JsonRest MVC.Model.WindowName MVC.Model.XmlRest MVC.Native MVC.Native.Array MVC.Native.Date MVC.Native.Function MVC.Native.Number MVC.Native.Object MVC.Native.String MVC.Options MVC.Store MVC.SyntheticEvent MVC.Test MVC.Test.Assertions MVC.Test.Controller MVC.Test.Functional MVC.Test.Runner MVC.Test.Unit MVC.Timer MVC.Timer.Easings MVC.Vector MVC.View MVC.View.Helpers OpenAjax

MVC.History

Provides history, history data, and bookmarking for DHTML and Ajax applications.

create

create(options) -> undefined
Creates the DHTML history infrastructure
{} -

UA

set user-agent flags

initialize

initialize() -> undefined
Initialize our DHTML history. You must call this after the page is finished loading.

addListener

addListener(listener) -> undefined
Adds a history change listener. Note that only one listener is supported at this time.
{} -

addEventListener

addEventListener(o, e, l) -> undefined
Generic utility function for attaching events
{} -
{} -
{} -

add

add(newLocation, historyData) -> undefined
Adds a new history point. Equivalent to this.redirect_to
{String} -
{Object} -

isFirstLoad

isFirstLoad() -> undefined

getVersion

getVersion() -> undefined

getCurrentHash

getCurrentHash() -> undefined
Manually parse the current url for a hash; tip of the hat to YUI

listener

Our history change listener.

waitTime

MS to wait between add requests - will be reset for certain browsers

currentWaitTime

MS before an add request can execute

currentLocation

Our current hash location, without the "#" symbol.

iframe

Hidden iframe used to IE to detect history changes

safariHistoryStartPoint

Flags and DOM references used only by Safari

ignoreLocationChange

Private: Flag used to keep checkLocation() from doing anything when it discovers location changes we've made ourselves programmatically with the add() method. Basically, add() sets this to true. When checkLocation() discovers it's true, it refrains from firing our listener, then resets the flag to false for next cycle. That way, our listener only gets fired on history change events triggered by the user via back/forward buttons and manual hash changes. This flag also helps us set up IE's special iframe-based method of handling history changes.

fireOnNewListener

Private: A flag that indicates that we should fire a history change event when we are ready, i.e. after we are initialized and we have a history change listener. This is needed due to an edge case in browsers other than IE; if you leave a page entirely then return, we must fire this as a history change event. Unfortunately, we have lost all references to listeners from earlier, because JavaScript clears out.

firstLoad

Private: A variable that indicates whether this is the first time this page has been loaded. If you go to a web page, leave it for another one, and then return, the page's onload listener fires again. We need a way to differentiate between the first page load and subsequent ones. This variable works hand in hand with the pageLoaded variable we store into historyStorage.

ieAtomicLocationChange

Private: A variable to handle an important edge case in IE. In IE, if a user manually types an address into their browser's location bar, we must intercept this by calling checkLocation() at regular intervals. However, if we are programmatically changing the location bar ourselves using the add() method, we need to ignore these changes in checkLocation(). Unfortunately, these changes take several lines of code to complete, so for the duration of those lines of code, we set this variable to true. That signals to checkLocation() to ignore the change-in-progress. Once we're done with our chunk of location-change code in add(), we set this back to false. We'll do the same thing when capturing user-entered address changes in checkLocation itself.

createIE

createIE(initialHash) -> undefined
Private: Create IE-specific DOM nodes and overrides
{} -

waitTime

write out a hidden iframe for IE and set the amount of time to wait between add() requests

createOpera

createOpera() -> undefined
Private: Create Opera-specific DOM nodes and overrides

imgHTML

Opera needs longer between history updates

createSafari

createSafari() -> undefined
Private: Create Safari-specific DOM nodes and overrides

getSafariStack

getSafariStack() -> undefined
Private: Safari method to read the history stack from a hidden form field

getSafariState

getSafariState() -> undefined
Private: Safari method to read from the history stack

putSafariState

putSafariState(newLocation) -> undefined
Private: Safari method to write the history stack to a hidden form field
{} -

fireHistoryEvent

fireHistoryEvent(newHash) -> undefined
Private: Notify the listener of new history changes.
{} -

checkLocation

checkLocation() -> undefined
Private: See if the browser has changed location. This is the primary history mechanism for Firefox. For IE, we use this to handle an important edge case: if a user manually types in a new hash value into their IE location bar and press enter, we want to to intercept this and notify any history listener.

hash

Get hash location

hash

Do nothing if there's been no change

ieAtomicLocationChange

In IE, users manually entering locations into the browser; we do this by comparing the browser's location against the iframe's location; if they differ, we are dealing with a manual event and need to place it inside our history, otherwise we can return

currentLocation

Save this new location

getIframeHash

getIframeHash() -> undefined
Private: Get the current location of IE's hidden iframe.

removeHash

removeHash(hashValue) -> undefined
Private: Remove any leading hash that might be on a location.
{} -

iframeLoaded

iframeLoaded(newLocation) -> undefined
Private: For IE, tell when the hidden iframe has finished loading.
{} -

hash

Get the new location

hash

Keep the browser location bar in sync with the iframe hash

historyStorage

historyStorage: An object that uses a hidden form to store history state across page loads. The mechanism for doing so relies on the fact that browsers save the text in form data for the life of the browser session, which means the text is still there when the user navigates back to the page. This object can be used independently of the MVC.History object for caching of Ajax session information. dependencies: json2007.js (included in a separate file) or alternate JSON methods passed in through an options bundle.

setup

setup(options) -> undefined
Public: Set up our historyStorage object for use by MVC.History or other objects
{} -

formID

write a hidden form and textarea into the page; we'll stow our history stack here

get

get(key) -> undefined
Public
{} -

remove

remove(key) -> undefined
Public
{} -

reset

reset() -> undefined
Public: Clears out all saved data.

hasKey

hasKey(key) -> undefined
Public
{} -

isValidKey

isValidKey(key) -> undefined
Public
{} -

showStyles

Public - CSS strings utilized by both objects to hide or show behind-the-scenes DOM elements

debugMode

Public - debug mode flag

Private

hashLoaded

Private: If true, we have loaded our hash table out of the storage form.

storageField

Private: DOM reference to our history field

assertValidKey

assertValidKey(key) -> undefined
Private: Assert that a key is valid; throw an exception if it not.
{} -

loadHashTable

loadHashTable() -> undefined
Private: Load the hash table up from the form.

saveHashTable

saveHashTable() -> undefined
Private: Save the hash table into the form.

toJSON

toJSON(o) -> undefined
Private: Bridges for our JSON implementations - both rely on 2007 JSON.org library - can be overridden by options bundle
{} -

historyChange

historyChange(newLocation, historyData) -> undefined
Called when history changes
{Object} -
{Object} -