removed history.js

Signed-off-by: bachy <git@g-u-i.net>
This commit is contained in:
bachy 2012-11-21 09:56:38 +01:00
parent 707403f8e7
commit 61c83b5a75
75 changed files with 0 additions and 31209 deletions

View File

@ -1 +0,0 @@
.build

View File

@ -1,76 +0,0 @@
## History
- v1.7.1 - October 4 2011
- Added a new native adapter which is framework agnostic (can be used with, or without any framework)
- Provided bundled files
- Added RightJS adapter
- Updated supported browser listing
- Added sessionStorage support in core instead of optional Amplify.js Store support
- Fixed issue with state id generation growing slower over time
- Closes #104, #95, #102, #92, #81, #90, #94, #93, #91, #67, #83, #54, #45
- v1.7.0 - April 1 2011
- Added `History.enabled` property (refer to usage section). This reflects whether or not History.js is enabled for our particular browser. For instance, if we have not included support for a HTML4 browser and we are accessing through a HTML4 browser then `History.enabled` will be `false`.
- Added (optional but recommended) Data Persistance and Synchronisation Support thanks to [AppendTo's](http://appendto.com/) [Amplify.js](http://amplifyjs.com/) (refer to installation and compatibility sections for details)
- Made HTML5 SUIDs more transparent - [Reported](https://github.com/balupton/history.js/issues#issue/34) by [azago](https://github.com/azago) and [Mark Jaquith](http://markjaquith.com/)
- Fixed Session Storage Issue - Reported by a whole bunch of different people; [one](https://github.com/balupton/history.js/issues#issue/36), [two](https://github.com/balupton/history.js/issues#issue/37), [three](http://getsatisfaction.com/balupton/topics/history_js_1_6_losing_state_after_manual_page_reload)
- Fixed URL Encoding Issue - [Reported](https://github.com/balupton/history.js/issues/#issue/33) by [Rob Madole](http://robmadole.com/)
- Disabled support for IE6,7,8 when using the Prototype Adapter (there is nothing we can do about this, it is due to a bug in the prototype library) - [Reported](https://github.com/balupton/history.js/issues#issue/39) by [Sindre Wimberger](http://sindre.at/)
- URLs in the State Hashes for HTML4 Browsers are now even shorter - [Discussion](https://github.com/balupton/history.js/issues#issue/28)
- Fixed a issue with the MooTools Adapter and JSON with IE7 and IE8
- v1.6.0 - March 22 2011
- Added Zepto adapter thanks to [Matt Garrett](http://twitter.com/#!/matthewgarrett)
- The readme now references the supported versions of the libraries we use
- Updated vendors to the most recent versions. jQuery 1.5.1 and Mootools 1.3.1
- Reverted versions of Safari iOS prior to version 4.3 to be HTML4 browsers, Safari iOS 4.3 is a HTML5 browser
- Refined code in History.js and its adapters
- Fixed issue with extra state being inserted on Safari 5 requiring an extra click on the back button to go home - [Reported](https://github.com/balupton/history.js/issues#issue/17) by [Rob Madole](http://robmadole.com/)
- Fixed issue with Safari 5 and Safari iOS 4 sometimes failing to apply the state change under busy conditions - Solution conceived with [Matt Garrett](http://twitter.com/matthewgarrett)
- Fixed issue with HTML4 browsers requiring a query-string in the urls of states - [Reported](https://github.com/balupton/history.js/issues#issue/26) by [azago](https://github.com/azago)
- Fixed issue with HTML4 browsers requiring title in the states in order to use state data - [Reported](https://github.com/balupton/history.js/issues#issue/25) by [Jonathan McLaughlin](http://system-werks.com/)
- Fixed issue with HTML4 browsers failing is a state is pushed/replaced twice in a row - [Reported](https://github.com/balupton/history.js/issues#issue/17) by [Joey Baker](http://byjoeybaker.com/)
- **B/C BREAK:** The `statechange` event now only fires if the state has changed; it no longer fires on page initialisation. This is following the [Firefox 4 History API Changes](http://hacks.mozilla.org/2011/03/history-api-changes-in-firefox-4/) which we agree with - this breaks standard, but makes more sense.
- v1.5.0 - February 12 2011
- Moved to UglifyJS instead of Google Closure
- Split HTML4 functionality from HTML5 functionality
- Installation details have changed (the filenames are different)
- v1.4.1 - February 10 2011
- Added HTML History API Support for Safari 5 and Safari iOS 4.2.1
- Cleaned code a bit (mostly with unit tests)
- v1.4.0 - February 10 2011
- Unit Testing now uses [QUnit](http://docs.jquery.com/Qunit)
- Corrected Safari 5 Support
- Now uses queues instead of timeouts
- This means the API works exactly as expected, no more need to wrap calls in timeouts
- Included a Subscribe Form in the Demo for Version Updates via Email
- Small updates to Documentation
- v1.3.1 - February 4 2011
- Improved Documentation
- v1.3.0 - January 31 2011
- Support for cleaner HTML4 States
- v1.2.1 - January 30 2011
- Fixed History.log always being called - [reported by dlee](https://github.com/balupton/history.js/issues/#issue/2)
- Re-Added `History.go(index)` support
- v1.2.0 - January 25 2011
- Support for HTML4 States in HTML5 Browsers (added test)
- Updates of Documentation
- v1.1.0 - January 24 2011
- Developed a series of automated test cases
- Fixed issue with traditional anchors
- Fixed issue with differing replaceState functionality in HTML4 Browsers
- Fixed issue with Google Chrome artefacts being carried over to the initial state
- Provided `onstatechange` and `onanchorchange` events
- v1.0.0 - January 22 2011
- Supported `History.pushState` and `History.replaceState` degradation
- Supported jQuery, MooTools and Prototype Frameworks

View File

@ -1,245 +0,0 @@
Welcome to History.js (v1.7.1 - October 4 2011)
==================
[![Flattr this project](http://api.flattr.com/button/flattr-badge-large.png)](https://flattr.com/submit/auto?user_id=balupton&url=https://github.com/balupton/history.js&title=History.js&language=&tags=github&category=software)
This project is the successor of [jQuery History](http://balupton.com/projects/jquery-history), it aims to:
- Follow the [HTML5 History API](https://developer.mozilla.org/en/DOM/Manipulating_the_browser_history) as much as possible
- Provide a cross-compatible experience for all HTML5 Browsers (they all implement the HTML5 History API a little bit differently causing different behaviours and sometimes bugs - History.js fixes this ensuring the experience is as expected / the same / great throughout the HTML5 browsers)
- Provide a backwards-compatible experience for all HTML4 Browsers using a hash-fallback (including continued support for the HTML5 History API's `data`, `title`, `pushState` and `replaceState`) with the option to [remove HTML4 support if it is not right for your application](https://github.com/balupton/history.js/wiki/Intelligent-State-Handling)
- Provide a forwards-compatible experience for HTML4 States to HTML5 States (so if a hash-fallbacked url is accessed by a HTML5 browser it is naturally transformed into its non-hashed url equivalent)
- Provide support for as many javascript frameworks as possible via adapters; especially [jQuery](http://jquery.com/), [MooTools](http://mootools.net/), [Prototype](http://www.prototypejs.org/) and [Zepto](http://zeptojs.com/)
## Usage
### Working with History.js:
``` javascript
(function(window,undefined){
// Prepare
var History = window.History; // Note: We are using a capital H instead of a lower h
if ( !History.enabled ) {
// History.js is disabled for this browser.
// This is because we can optionally choose to support HTML4 browsers or not.
return false;
}
// Bind to StateChange Event
History.Adapter.bind(window,'statechange',function(){ // Note: We are using statechange instead of popstate
var State = History.getState(); // Note: We are using History.getState() instead of event.state
History.log(State.data, State.title, State.url);
});
// Change our States
History.pushState({state:1}, "State 1", "?state=1"); // logs {state:1}, "State 1", "?state=1"
History.pushState({state:2}, "State 2", "?state=2"); // logs {state:2}, "State 2", "?state=2"
History.replaceState({state:3}, "State 3", "?state=3"); // logs {state:3}, "State 3", "?state=3"
History.pushState(null, null, "?state=4"); // logs {}, '', "?state=4"
History.back(); // logs {state:3}, "State 3", "?state=3"
History.back(); // logs {state:1}, "State 1", "?state=1"
History.back(); // logs {}, "Home Page", "?"
History.go(2); // logs {state:3}, "State 3", "?state=3"
})(window);
```
To ajaxify your entire website with the HTML5 History API, History.js and jQuery [this snippet of code](https://gist.github.com/854622) is all you need. It's that easy.
### How would the above operations look in a HTML5 Browser?
1. www.mysite.com
1. www.mysite.com/?state=1
1. www.mysite.com/?state=2
1. www.mysite.com/?state=3
1. www.mysite.com/?state=4
1. www.mysite.com/?state=3
1. www.mysite.com/?state=1
1. www.mysite.com
1. www.mysite.com/?state=3
> Note: These urls also work in HTML4 browsers and Search Engines. So no need for the hashbang (`#!`) fragment-identifier that google ["recommends"](https://github.com/balupton/history.js/wiki/Intelligent-State-Handling).
### How would they look in a HTML4 Browser?
1. www.mysite.com
1. www.mysite.com/#?state=1&_suid=1
1. www.mysite.com/#?state=2&_suid=2
1. www.mysite.com/#?state=3&_suid=3
1. www.mysite.com/#?state=4
1. www.mysite.com/#?state=3&_suid=3
1. www.mysite.com/#?state=1&_suid=1
1. www.mysite.com
1. www.mysite.com/#?state=3&_suid=3
> Note 1: These urls also work in HTML5 browsers - we use `replaceState` to transform these HTML4 states into their HTML5 equivalents so the user won't even notice :-)
>
> Note 2: These urls will be automatically url-encoded in IE6 to prevent certain browser-specific bugs.
>
> Note 3: Support for HTML4 browsers (this hash fallback) is optional [- why supporting HTML4 browsers could be either good or bad based on my app's use cases](https://github.com/balupton/history.js/wiki/Intelligent-State-Handling)
### What's the deal with the SUIDs used in the HTML4 States?
- SUIDs (State Unique Identifiers) are used when we utilise a `title` and/or `data` in our state. Adding a SUID allows us to associate particular states with data and titles while keeping the urls as simple as possible (don't worry it's all tested, working and a lot smarter than I'm making it out to be).
- If you aren't utilising `title` or `data` then we don't even include a SUID (as there is no need for it) - as seen by State 4 above :-)
- We also shrink the urls to make sure that the smallest url will be used. For instance we will adjust `http://www.mysite.com/#http://www.mysite.com/projects/History.js` to become `http://www.mysite.com/#/projects/History.js` automatically. (again tested, working, and smarter).
- It works with domains, subdomains, subdirectories, whatever - doesn't matter where you put it. It's smart.
- Safari 5 will also have a SUID appended to the URL, it is entirely transparent but just a visible side-effect. It is required to fix a bug with Safari 5.
### Is there a working demo?
- Sure is, give it a download and navigate to the demo directory in your browser :-)
- If you are after something a bit more adventurous than a end-user demo, open up the tests directory in your browser and editor - it'll rock your world and show all the vast use cases that History.js supports.
## Download & Installation
- Download History.js and upload it to your webserver. Download links: [tar.gz](https://github.com/balupton/history.js/tarball/master) or [zip](https://github.com/balupton/history.js/zipball/master)
- Include History.js
- For [jQuery](http://jquery.com/) v1.3+
``` html
<script src="http://www.yourwebsite.com/history.js/scripts/bundled/html4+html5/jquery.history.js"></script>
```
- For [Mootools](http://mootools.net/) v1.3+
``` html
<script src="http://www.yourwebsite.com/history.js/scripts/bundled/html4+html5/mootools.history.js"></script>
```
- For [Right.js](http://rightjs.org/) v2.2+
``` html
<script src="http://www.yourwebsite.com/history.js/scripts/bundled/html4+html5/right.history.js"></script>
```
- For [Zepto](http://zeptojs.com/) v0.5+
``` html
<script src="http://www.yourwebsite.com/history.js/scripts/bundled/html4+html5/zepto.history.js"></script>
```
- For everything else
``` html
<script src="http://www.yourwebsite.com/history.js/scripts/bundled/html4+html5/native.history.js"></script>
```
> Note: If you want to only support HTML5 Browsers and not HTML4 Browsers (so no hash fallback support) then just change the `/html4+html5/` part in the urls to just `/html5/`. [Why supporting HTML4 browsers could be either good or bad based on my app's use cases](https://github.com/balupton/history.js/wiki/Intelligent-State-Handling)
## Get Updates
- For Commit RSS/Atom Updates:
- You can subscribe via the [GitHub Commit Atom Feed](http://feeds.feedburner.com/historyjs)
- For GitHub News Feed Updates:
- You can click the "watch" button up the top right of History.js's [GitHub Project Page](https://github.com/balupton/history.js)
## Get Support
- History.js is maintained by people like you. If you find a bug, report it to the [GitHub Issue Tracker](https://github.com/balupton/history.js/issues). If you've fixed a bug submit a [Pull Request](https://github.com/balupton/history.js/pulls) and add your fork to the [Network Wiki Page](https://github.com/balupton/history.js/wiki/Network).
- If you would like paid support and trainings, or have job offers, then refer to the [Network Wiki Page](https://github.com/balupton/history.js/wiki/Network). If you are qualified with History.js, then be sure to add your details to that page too.
- If your company uses History.js on your projects, and would like to see it grow and prosper (better documentation, bugfixes, upgrades, maintenance, etc.) and would love to become a corporate sponsor then do email sponsor@bevry.me
- If you would like free support for History.js, then [post your question](http://stackoverflow.com/questions/ask) on [Stackoverflow](http://stackoverflow.com/about) and be sure to use the `history.js` tag when asking your question.
- If you've created a website that uses History.js, or know of one. Then be sure to add it to the [Showcase Wiki Page](https://github.com/balupton/history.js/wiki/Showcase).
- If you'd love to +1 or like this project, then be sure to tweet about it and click the "watch" button up the top of its [Project Page](https://github.com/balupton/history.js).
- For anything else, refer to the [History.js GitHub Wiki Site](https://github.com/balupton/history.js/wiki).
Thanks! every bit of help really does make a difference!
## Browsers: Tested and Working In
### HTML5 Browsers
- Firefox 4+
- Chrome 8+
- Opera 11.5
- Safari 5.0+
- Safari iOS 4.3+
### HTML4 Browsers
- IE 6, 7, 8, 9
- Firefox 3
- Opera 10, 11.0
- Safari 4
- Safari iOS 4.2, 4.1, 4.0, 3.2
## Exposed API
### Functions
- `History.pushState(data,title,url)` <br/> Pushes a new state to the browser; `data` can be null or an object, `title` can be null or a string, `url` must be a string
- `History.replaceState(data,title,url)` <br/> Replaces the existing state with a new state to the browser; `data` can be null or an object, `title` can be null or a string, `url` must be a string
- `History.getState()` <br/> Gets the current state of the browser, returns an object with `data`, `title` and `url`
- `History.getHash()` <br/> Gets the current hash of the browser
- `History.Adapter.bind(element,event,callback)` <br/> A framework independent event binder, you may either use this or your framework's native event binder.
- `History.Adapter.trigger(element,event)` <br/> A framework independent event trigger, you may either use this or your framework's native event trigger.
- `History.Adapter.onDomLoad(callback)` <br/> A framework independent onDomLoad binder, you may either use this or your framework's native onDomLoad binder.
- `History.back()` <br/> Go back once through the history (same as hitting the browser's back button)
- `History.forward()` <br/> Go forward once through the history (same as hitting the browser's forward button)
- `History.go(X)` <br/> If X is negative go back through history X times, if X is positive go forwards through history X times
- `History.log(...)` <br/> Logs messages to the console, the log element, and fallbacks to alert if neither of those two exist
- `History.debug(...)` <br/> Same as `History.log` but only runs if `History.debug.enable === true`
### Events
- `window.onstatechange` <br/> Fired when the state of the page changes (does not include hash changes)
- `window.onanchorchange` <br/> Fired when the anchor of the page changes (does not include state hashes)
## Notes on Compatibility
- History.js **solves** the following browser bugs:
- HTML5 Browsers
- Chrome 8 sometimes does not contain the correct state data when traversing back to the initial state
- Safari 5, Safari iOS 4 and Firefox 3 and 4 do not fire the `onhashchange` event when the page is loaded with a hash
- Safari 5 and Safari iOS 4 do not fire the `onpopstate` event when the hash has changed unlike the other browsers
- Safari 5 and Safari iOS 4 fail to return to the correct state once a hash is replaced by a `replaceState` call / [bug report](https://bugs.webkit.org/show_bug.cgi?id=56249)
- Safari 5 and Safari iOS 4 sometimes fail to apply the state change under busy conditions / [bug report](https://bugs.webkit.org/show_bug.cgi?id=42940)
- Google Chrome 8,9,10 and Firefox 4 prior to the RC will always fire `onpopstate` once the page has loaded / [change recommendation](http://hacks.mozilla.org/2011/03/history-api-changes-in-firefox-4/)
- Safari iOS 4.0, 4.1, 4.2 have a working HTML5 History API - although the actual back buttons of the browsers do not work, therefore we treat them as HTML4 browsers
- None of the HTML5 browsers actually utilise the `title` argument to the `pushState` and `replaceState` calls
- HTML4 Browsers
- Old browsers like MSIE 6,7 and Firefox 2 do not have a `onhashchange` event
- MSIE 6 and 7 sometimes do not apply a hash even it was told to (requiring a second call to the apply function)
- Non-Opera HTML4 browsers sometimes do not apply the hash when the hash is not `urlencoded`
- All Browsers
- State data and titles do not persist once the site is left and then returned (includes page refreshes)
- State titles are never applied to the `document.title`
- ReplaceState functionality is emulated in HTML4 browsers by discarding the replaced state, so when the discarded state is accessed it is skipped using the appropriate `History.back()` / `History.forward()` call
- Data persistance and synchronisation works like so: Every second or so, the SUIDs and URLs of the states will synchronise between the store and the local session. When a new session opens a familiar state (via the SUID or the URL) and it is not found locally then it will attempt to load the last known stored state with that information.
- URLs will be unescaped to the maximum, so for instance the URL `?key=a%20b%252c` will become `?key=a b c`. This is to ensure consistency between browser url encodings.
- Changing the hash of the page causes `onpopstate` to fire (this is expected/standard functionality). To ensure correct compatibility between HTML5 and HTML4 browsers the following events have been created:
- `window.onstatechange`: this is the same as the `onpopstate` event except it does not fire for traditional anchors
- `window.onanchorchange`: this is the same as the `onhashchange` event except it does not fire for states
- Known Issues
- Opera 11 fails to create history entries when under stressful loads (events fire perfectly, just the history events fail) - there is nothing we can do about this
- Mercury iOS fails to apply url changes (hashes and HTML5 History API states) - there is nothing we can do about this
## History
You can discover the history inside the [History.md](https://github.com/balupton/history.js/blob/master/History.md#files) file
## License
Licensed under the [New BSD License](http://opensource.org/licenses/BSD-3-Clause)
<br/>Copyright &copy; 2011-2012 [Benjamin Arthur Lupton](http://balupton.com)

View File

@ -1,281 +0,0 @@
# Requires
buildr = require 'buildr'
util = require 'util'
# Options
options =
watch: false
compress: true
# Configs
configs =
standard:
# Options
name: 'standard'
watch: options.watch
# Paths
srcPath: __dirname+'/scripts/uncompressed'
outPath: __dirname+'/scripts/compressed'
# Checking
checkScripts: true
jshintOptions:
browser: true
laxbreak: true
boss: true
undef: true
onevar: true
strict: true
noarg: true
# Compression (without outPath only the generated bundle files are compressed)
compressScripts: options.compress # Array or true or false
other: [
# -----------------------------
# JQUERY
{
# Options
name: 'html4+html5+jquery'
watch: options.watch
# Paths
srcPath: __dirname+'/scripts/uncompressed'
# Compression (without outPath only the generated bundle files are compressed)
compressScripts: options.compress # Array or true or false
# Order
scriptsOrder: [
'json2.js'
'history.adapter.jquery.js'
'history.html4.js'
'history.js'
]
# Bundling
bundleScriptPath: __dirname+'/scripts/bundled/html4+html5/jquery.history.js'
}
{
# Options
name: 'html5+jquery'
watch: options.watch
# Paths
srcPath: __dirname+'/scripts/uncompressed'
# Compression (without outPath only the generated bundle files are compressed)
compressScripts: options.compress # Array or true or false
# Order
scriptsOrder: [
'history.adapter.jquery.js'
'history.js'
]
# Bundling
bundleScriptPath: __dirname+'/scripts/bundled/html5/jquery.history.js'
}
# -----------------------------
# MOOTOOLS
{
# Options
name: 'html4+html5+mootools'
watch: options.watch
# Paths
srcPath: __dirname+'/scripts/uncompressed'
# Compression (without outPath only the generated bundle files are compressed)
compressScripts: options.compress # Array or true or false
# Order
scriptsOrder: [
'json2.js'
'history.adapter.mootools.js'
'history.html4.js'
'history.js'
]
# Bundling
bundleScriptPath: __dirname+'/scripts/bundled/html4+html5/mootools.history.js'
}
{
# Options
name: 'html5+mootools'
watch: options.watch
# Paths
srcPath: __dirname+'/scripts/uncompressed'
# Compression (without outPath only the generated bundle files are compressed)
compressScripts: options.compress # Array or true or false
# Order
scriptsOrder: [
'history.adapter.mootools.js'
'history.js'
]
# Bundling
bundleScriptPath: __dirname+'/scripts/bundled/html5/mootools.history.js'
}
# -----------------------------
# NATIVE
{
# Options
name: 'html4+html5+native'
watch: options.watch
# Paths
srcPath: __dirname+'/scripts/uncompressed'
# Compression (without outPath only the generated bundle files are compressed)
compressScripts: options.compress # Array or true or false
# Order
scriptsOrder: [
'json2.js'
'history.adapter.native.js'
'history.html4.js'
'history.js'
]
# Bundling
bundleScriptPath: __dirname+'/scripts/bundled/html4+html5/native.history.js'
}
{
# Options
name: 'html5+native'
watch: options.watch
# Paths
srcPath: __dirname+'/scripts/uncompressed'
# Compression (without outPath only the generated bundle files are compressed)
compressScripts: options.compress # Array or true or false
# Order
scriptsOrder: [
'history.adapter.native.js'
'history.js'
]
# Bundling
bundleScriptPath: __dirname+'/scripts/bundled/html5/native.history.js'
}
# -----------------------------
# RIGHT.JS
{
# Options
name: 'html4+html5+right'
watch: options.watch
# Paths
srcPath: __dirname+'/scripts/uncompressed'
# Compression (without outPath only the generated bundle files are compressed)
compressScripts: options.compress # Array or true or false
# Order
scriptsOrder: [
'json2.js'
'history.adapter.right.js'
'history.html4.js'
'history.js'
]
# Bundling
bundleScriptPath: __dirname+'/scripts/bundled/html4+html5/right.history.js'
}
{
# Options
name: 'html5+right'
watch: options.watch
# Paths
srcPath: __dirname+'/scripts/uncompressed'
# Compression (without outPath only the generated bundle files are compressed)
compressScripts: options.compress # Array or true or false
# Order
scriptsOrder: [
'history.adapter.right.js'
'history.js'
]
# Bundling
bundleScriptPath: __dirname+'/scripts/bundled/html5/right.history.js'
}
# -----------------------------
# ZEPTO
{
# Options
name: 'html4+html5+zepto'
watch: options.watch
# Paths
srcPath: __dirname+'/scripts/uncompressed'
# Compression (without outPath only the generated bundle files are compressed)
compressScripts: options.compress # Array or true or false
# Order
scriptsOrder: [
'json2.js'
'history.adapter.zepto.js'
'history.html4.js'
'history.js'
]
# Bundling
bundleScriptPath: __dirname+'/scripts/bundled/html4+html5/zepto.history.js'
}
{
# Options
name: 'html5+zepto'
watch: options.watch
# Paths
srcPath: __dirname+'/scripts/uncompressed'
# Compression (without outPath only the generated bundle files are compressed)
compressScripts: options.compress # Array or true or false
# Order
scriptsOrder: [
'history.adapter.zepto.js'
'history.js'
]
# Bundling
bundleScriptPath: __dirname+'/scripts/bundled/html5/zepto.history.js'
}
]
# Standard
standardConfig = configs.standard
standardConfig.successHandler = ->
for config in configs.other
buildrInstance = buildr.createInstance config
buildrInstance.process()
# Process
standardBuildr = buildr.createInstance configs.standard
standardBuildr.process()

View File

@ -1,58 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>WebKit is Dropping HTML5 "popstate" Events</title>
<link rel="stylesheet" href="/static/lib/css/blueprint/blueprint.min.css" media="screen, projection" />
<link rel="stylesheet" href="/static/lib/css/blueprint/print.min.css" media="print" />
<!--[if lt IE 8]>
<link rel="stylesheet" href="/static/lib/css/blueprint/ie.min.css" media="screen, projection">
<![endif]-->
<link href="/static/lib/css/bcherry.css" rel="stylesheet" media="screen" />
<style>
#n {
font-size: 48px;
}
p {
padding: 0 20px;
}
</style>
<script type="text/javascript" src="../vendor/jquery.js"></script>
<script type="text/javascript" src="../scripts/uncompressed/history.adapter.jquery.js"></script>
<script type="text/javascript" src="../scripts/uncompressed/history.js"></script>
</head>
<body>
<div id="n"></div>
<p>There's a bug in the HTML5 "popstate" event, as implemented in WebKit (Safari and Chrome). View this page in one of those browsers. Your browser has had history entries added from #0 to #19 (you should start at #19). Hitting back/forward will navigate through these. On each URL, the large number above should reflect the hash value. If you hit back/forward quickly, you'll notice that your number gets out of sync with the URL. This is because WebKit is dropping popstate events (they are not firing). It seems to happen when outbound network requests are in progress when the user navigates in their browser happens. In this case, your browser is downloading an image that takes 1s to serve on every popstate, so you'll have to wait 1s between backs/forwards to have the feature work correctly. You could also cause constant network traffic by putting an image download in a setInterval, in which case your popstate events will never fire. This implementation simulates an AJAX application that makes a network request when you navigate between URLs using pushState/popstate. View the source for more info.</p>
<p>This was filed as <a href="https://bugs.webkit.org/show_bug.cgi?id=42940">Bug 42940</a> with WebKit on July 24, 2010. The Firefox 4 beta does not have this bug, which is good news.</p>
<p>This is put together by <a href="http://www.adequatelygood.com">Ben Cherry</a>. Ben is a front-end engineer at <a href="http://twitter.com/">Twitter</a>, and you can follow him at <a href="http://twitter.com/bcherry">@bcherry</a>.</p>
<script>
// Bind to popstate
$(window).bind("popstate", function(e) {
var State = e.state;
// log that this event was fired, and the current URL
if (window.console && window.console.log) {
console.log("popstate", State, window.location.href);
}
// update the page
$("#n").text(typeof State.n !== 'undefined' ? State.n : document.location.href);
// Make an outbound image request that will take 1s. This request seems to be the cause of dropped popstates.
// Removing this, or replacing it with something else, avoids the issue. Even if it's replaced with slow, blocking code (i.e. 1s of execution) events are not dropped.
(new Image()).src = "http://www.bcherry.net/playground/pushstate.jpg";
});
// Seed the browser history
for (var i = 0; i < 20; i++) {
window.history.pushState({n:i}, i, "?" + i);
$("#n").text(i);
}
</script>
</body>
</html>

View File

@ -1,62 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>WebKit is Dropping HTML5 "popstate" Events</title>
<link rel="stylesheet" href="/static/lib/css/blueprint/blueprint.min.css" media="screen, projection" />
<link rel="stylesheet" href="/static/lib/css/blueprint/print.min.css" media="print" />
<!--[if lt IE 8]>
<link rel="stylesheet" href="/static/lib/css/blueprint/ie.min.css" media="screen, projection">
<![endif]-->
<link href="/static/lib/css/bcherry.css" rel="stylesheet" media="screen" />
<style>
#n {
font-size: 48px;
}
p {
padding: 0 20px;
}
</style>
<script type="text/javascript" src="../vendor/jquery.js"></script>
<script type="text/javascript" src="../scripts/uncompressed/history.adapter.jquery.js"></script>
<script type="text/javascript" src="../scripts/uncompressed/history.js"></script>
</head>
<body>
<div id="n"></div>
<p>There's a bug in the HTML5 "popstate" event, as implemented in WebKit (Safari and Chrome). View this page in one of those browsers. Your browser has had history entries added from #0 to #19 (you should start at #19). Hitting back/forward will navigate through these. On each URL, the large number above should reflect the hash value. If you hit back/forward quickly, you'll notice that your number gets out of sync with the URL. This is because WebKit is dropping popstate events (they are not firing). It seems to happen when outbound network requests are in progress when the user navigates in their browser happens. In this case, your browser is downloading an image that takes 1s to serve on every popstate, so you'll have to wait 1s between backs/forwards to have the feature work correctly. You could also cause constant network traffic by putting an image download in a setInterval, in which case your popstate events will never fire. This implementation simulates an AJAX application that makes a network request when you navigate between URLs using pushState/popstate. View the source for more info.</p>
<p>This was filed as <a href="https://bugs.webkit.org/show_bug.cgi?id=42940">Bug 42940</a> with WebKit on July 24, 2010. The Firefox 4 beta does not have this bug, which is good news.</p>
<p>This is put together by <a href="http://www.adequatelygood.com">Ben Cherry</a>. Ben is a front-end engineer at <a href="http://twitter.com/">Twitter</a>, and you can follow him at <a href="http://twitter.com/bcherry">@bcherry</a>.</p>
<p>This bug was fixed in <a href="http://github.com/balupton/history.js">History.js</a> by <a href="http://balupton.com">Benjamin Lupton</a>. Benjamin is a freelance web 2.0 consultant, and you can follow him at <a href="http://twitter.com/balupton">@balupton</a>.</p>
<script>
// Prepare
window.History.debug.enable = true;
// Bind to popstate
$(window).bind("statechange", function(e) {
var State = window.History.getState();
// log that this event was fired, and the current URL
if (window.console && window.console.log) {
console.log("popstate", State, window.location.href);
}
// update the page
$("#n").text(typeof State.data.n !== 'undefined' ? State.data.n : State.url);
// Make an outbound image request that will take 1s. This request seems to be the cause of dropped popstates.
// Removing this, or replacing it with something else, avoids the issue. Even if it's replaced with slow, blocking code (i.e. 1s of execution) events are not dropped.
(new Image()).src = "http://www.bcherry.net/playground/pushstate.jpg";
});
// Seed the browser history
for (var i = 0; i < 20; i++) {
window.History.pushState({n:i}, i, "?" + i);
$("#n").text(i);
}
</script>
</body>
</html>

View File

@ -1,37 +0,0 @@
<html>
<head>
<title>Chrome History API Data Artifact</title>
</head>
<body>
<p>This demo demonstrates an issue with Google Chrome versions 8-10 (possibly 11) where if you push a state with data, then do history.back to the initial state, the event.state will contain the pushed states data instead of being null.</p>
<p>Note: The issue requires a clean history list, as such this should always be opened in a new tab/window where there are no prior history items.</p>
<p>Reported by <a href="http://balupton.com">Benjamin Lupton</a> author of <a href="http://github.com/balupton/history.js">History.js</a></p>
<button id="bug">bug</button>
<button id="reset">reset</button>
<textarea id="log" style="width:100%;height:200px;margin-top:1em;"></textarea>
<script type="text/javascript">
(function(){
window.onpopstate = function(event) {
var message = ("onpopstate: location: " + document.location.href + ", data: " + JSON.stringify(event.state));
document.getElementById('log').innerHTML += message+"\n\n";
};
document.getElementById('bug').onclick = function(){
setTimeout(function(){
history.pushState({state:'new'},'New State','?new');
},1e3);
setTimeout(function(){
history.back();
},2e3);
};
document.getElementById('reset').onclick = function(){
document.location.href = document.location.href.replace(/[\#\?].*/,"");
};
})();
</script>
</body>
</html>

View File

@ -1,86 +0,0 @@
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>
History.js
</title>
</head>
<body style="padding-bottom:40px">
<!-- Scripts -->
<script>if ( typeof window.JSON === 'undefined' ) { document.write('<script src="../scripts/uncompressed/json2.js"><\/script>'); }</script>
<script src="../vendor/jquery.js"></script>
<script src="../scripts/bundled/html4+html5/jquery.history.js"></script>
<!-- HTML -->
<div id="wrap">
<!-- Intro -->
<h1><a href="https://github.com/balupton/History.js">History.js</a> by <a href="http://balupton.com">Benjamin Lupton</a></h1>
<p>History.js gracefully supports the <a href="https://developer.mozilla.org/en/DOM/Manipulating_the_browser_history">HTML5 History/State APIs</a> (pushState, replaceState, onPopState) in all browsers. Including continued support for data, titles, replaceState. Supports <a href="http://jquery.com/">jQuery</a>, <a href="http://mootools.net">MooTools</a> and <a href="http://prototypejs.org">Prototype</a>. For HTML5 browsers this means that you can modify the URL directly, without needing to use hashes anymore. For HTML4 browsers it will revert back to using the old onhashchange functionality.</p>
<!-- Textarea for Logging -->
<textarea id="log" style="width:100%;height:400px"></textarea>
<!-- Note -->
<p>Click through the buttons in order and you'll get the results demonstrated in the <a href="../README.md">README.md</a> file.</p>
<!-- Buttons -->
<ul id="buttons">
</ul>
<!-- Our Script -->
<script>
(function(window,undefined){
// Check Location
if ( document.location.protocol === 'file:' ) {
alert('The HTML5 History API (and thus History.js) do not work on files, please upload it to a server.');
}
// Establish Variables
var
History = window.History, // Note: We are using a capital H instead of a lower h
State = History.getState(),
$log = $('#log');
// Log Initial State
History.log('initial:', State.data, State.title, State.url);
// Bind to State Change
History.Adapter.bind(window,'statechange',function(){ // Note: We are using statechange instead of popstate
// Log the State
var State = History.getState(); // Note: We are using History.getState() instead of event.state
History.log('statechange:', State.data, State.title, State.url);
});
// Prepare Buttons
var
buttons = document.getElementById('buttons'),
scripts = [
'History.pushState({state:1,rand:Math.random()}, "State 1", "?state=1"); // logs {state:1,rand:"some random value"}, "State 1", "?state=1"',
'History.pushState({state:2,rand:Math.random()}, "State 2", "?state=2"); // logs {state:2,rand:"some random value"}, "State 2", "?state=2"',
'History.replaceState({state:3,rand:Math.random()}, "State 3", "?state=3"); // logs {state:3,rand:"some random value"}, "State 3", "?state=3"',
'History.pushState(null, null, "?state=4"); // logs {}, "", "?state=4"',
'History.back(); // logs {state:3}, "State 3", "?state=3"',
'History.back(); // logs {state:1}, "State 1", "?state=1"',
'History.back(); // logs {}, "The page you started at", "?"',
'History.go(2); // logs {state:3}, "State 3", "?state=3"'
],
buttonsHTML = ''
;
// Add Buttons
for ( var i=0,n=scripts.length; i<n; ++i ) {
var _script = scripts[i];
buttonsHTML +=
'<li><button onclick=\'javascript:'+_script+'\'>'+_script+'</button></li>';
}
buttons.innerHTML = buttonsHTML;
})(window);
</script>
</div>
</body>
</html>

View File

@ -1,43 +0,0 @@
<html>
<head>
</head>
<body>
<script type="text/javascript">
(function(){
window.onpopstate = function(event) {
console.log("onpopstate: location: " + document.location.href + ", data: " + JSON.stringify(event.state));
};
window.onhashchange = function(event) {
console.log("onhashchange: location: " + document.location.href);
};
setTimeout(function(){
history.pushState({page: 1}, "title 1", "?page=1");
},1e3);
setTimeout(function(){
history.pushState({page: 2}, "title 2", "?page=2");
},2e3);
setTimeout(function(){
history.replaceState({page: 3}, "title 3", "?page=3");
},3e3);
setTimeout(function(){
document.location.hash = 'asd';
},4e3);
setTimeout(function(){
history.back(); // alerts "location: http://example.com/example.html?page=3#asd, state: {"page":3}"
},5e3);
setTimeout(function(){
history.back(); // alerts "location: http://example.com/example.html?page=1, state: {"page":1}"
},6e3);
setTimeout(function(){
history.back(); // alerts "location: http://example.com/example.html, state: null
},7e3);
setTimeout(function(){
history.go(2); // alerts "location: http://example.com/example.html?page=3, state: {"page":3}
},8e3);
})();
</script>
</body>
</html>

View File

@ -1,62 +0,0 @@
<html>
<head>
<title>HTML5 History API Demo</title>
</head>
<body>
<textarea id="log" style="width:100%;height:400px;margin:1em;"></textarea>
<div id="url" style="border:1px black dotted;height:1em;margin:1em;"></div>
<div id="buttons" style="margin:1em;"></div>
<script type="text/javascript">
var $url = document.getElementById('url'), $log = document.getElementById('log');
window.onpopstate = function(event) {
var message =
"onpopstate: "+
"location: " + location.href + ", " +
"data: " + JSON.stringify(event.state) +
"\n\n"
;
$url.innerHTML = location.href;
$log.innerHTML += message;
console.log(message);
};
window.onhashchange = function(event) {
var message =
"onhashchange: "+
"location: " + location.href + ", "+
"hash: " + location.hash +
"\n\n"
;
$url.innerHTML = location.href;
$log.innerHTML += message;
console.log(message);
};
// Prepare Buttons
var
buttons = document.getElementById('buttons'),
scripts = [
'history.pushState({state:1}, "State 1", "?state=1");',
'history.pushState({state:2}, "State 2", "?state=2");',
'history.replaceState({state:3}, "State 3", "?state=3");',
'location.hash = Math.random();',
'history.back();',
'history.forward();',
'document.location.href = document.location.href.replace(/[\#\?].*/,"");'
],
buttonsHTML = ''
;
// Add Buttons
for ( var i=0,n=scripts.length; i<n; ++i ) {
var _script = scripts[i];
buttonsHTML +=
'<li><button onclick=\'javascript:'+_script+'\'>'+_script+'</button></li>';
}
buttons.innerHTML = buttonsHTML;
</script>
</body>
</html>

View File

@ -1,23 +0,0 @@
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>
Navigator Output
</title>
<style>
label { font-weight:bold; }
label:after { content: ":"; margin-right:5px; }
</style>
</head>
<body>
<div id="nav"></div>
<script>
var nav = document.getElementById('nav'), i,v;
for ( i in navigator ) {
var v = navigator[i];
nav.innerHTML += '<div><label>'+i+'</label>'+v+'</div>';
}
</script>
</body>
</html>

View File

@ -1,61 +0,0 @@
<html>
<head>
<title>Safari Hash ReplaceState History Traversal Bug</title>
</head>
<body>
<p>This demo demonstrates an issue with Safari 5.0.4 (6533.20.27) handing of hashes and replace state. When a hash is set, and then replaced using replaceState the history list are then broken, when traversing back the hash does not change.</p>
<p>Note: The issue requires a clean history list, as such this should always be opened in a new tab/window where there are no prior history items.</p>
<p>Reported by <a href="http://balupton.com">Benjamin Lupton</a> author of <a href="http://github.com/balupton/history.js">History.js</a></p>
<button id="bug">bug</button>
<button id="workaround">workaround</button>
<button id="reset">reset</button>
<textarea id="log" style="width:100%;height:200px;margin-top:1em;"></textarea>
<script type="text/javascript">
(function(){
window.onpopstate = function(event) {
var message = ("onpopstate: location: " + document.location.href);
document.getElementById('log').innerHTML += message+"\n\n";
};
window.onhashchange = function(event) {
var message = ("onhashchange: location: " + document.location.href);
document.getElementById('log').innerHTML += message+"\n\n";
};
document.getElementById('bug').onclick = function(){
setTimeout(function(){
document.location.hash = Math.random();
},1e3);
setTimeout(function(){
history.replaceState(null,'','?blah');
},2e3);
setTimeout(function(){
history.back(); // should take us to the initial page, it doesn't
},3e3);
};
document.getElementById('workaround').onclick = function(){
setTimeout(function(){
history.pushState(null,'','#'+Math.random());
},1e3);
setTimeout(function(){
history.replaceState(null,'','?blah');
},2e3);
setTimeout(function(){
history.back(); // will take us to the initial page
},3e3);
};
document.getElementById('reset').onclick = function(){
document.location.href = document.location.href.replace(/[\#\?].*/,"");
};
})();
</script>
</body>
</html>

View File

@ -1,10 +0,0 @@
Copyright (c) 2011, Benjamin Arthur Lupton
All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
• Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
• Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
• Neither the name of Benjamin Arthur Lupton nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

View File

@ -1,57 +0,0 @@
{
"name": "history.js",
"version": "1.7.1-r2",
"description": "History.js gracefully supports the HTML5 History/State APIs (pushState, replaceState, onPopState) in all browsers. Including continued support for data, titles, replaceState. Supports jQuery, MooTools and Prototype. For HTML5 browsers this means that you can modify the URL directly, without needing to use hashes anymore. For HTML4 browsers it will revert back to using the old onhashchange functionality.",
"homepage": "https://github.com/balupton/history.js",
"keywords": [
"javascript",
"html5 history api",
"hashchange",
"popstate",
"pushstate",
"replacestate",
"hashes",
"hashbang"
],
"author": {
"name": "Benjamin Lupton",
"email": "b@lupton.cc",
"web": "http://balupton.com"
},
"maintainers": [
{
"name": "Benjamin Lupton",
"email": "b@lupton.cc",
"web": "http://balupton.com"
}
],
"contributors": [
{
"name": "Benjamin Lupton",
"email": "b@lupton.cc",
"web": "http://balupton.com"
}
],
"bugs": {
"web": "https://github.com/balupton/history.js/issues"
},
"licenses": [
{
"type": "New-BSD",
"url": "http://creativecommons.org/licenses/BSD/"
}
],
"repository": {
"type": "git",
"url": "http://github.com/balupton/history.js.git"
},
"dependencies": {
"buildr": "0.8.x"
},
"engines": {
},
"directories": {
"out": "./scripts/compressed",
"src": "./scripts/uncompressed"
}
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1 +0,0 @@
(function(a,b){"use strict";var c=a.History=a.History||{},d=a.jQuery;if(typeof c.Adapter!="undefined")throw new Error("History.js Adapter has already been loaded...");c.Adapter={bind:function(a,b,c){d(a).bind(b,c)},trigger:function(a,b,c){d(a).trigger(b,c)},extractEventData:function(a,c,d){var e=c&&c.originalEvent&&c.originalEvent[a]||d&&d[a]||b;return e},onDomLoad:function(a){d(a)}},typeof c.init!="undefined"&&c.init()})(window)

View File

@ -1 +0,0 @@
(function(a,b){"use strict";var c=a.History=a.History||{},d=a.MooTools,e=a.Element;if(typeof c.Adapter!="undefined")throw new Error("History.js Adapter has already been loaded...");Object.append(e.NativeEvents,{popstate:2,hashchange:2}),c.Adapter={bind:function(a,b,c){var d=typeof a=="string"?document.id(a):a;d.addEvent(b,c)},trigger:function(a,b,c){var d=typeof a=="string"?document.id(a):a;d.fireEvent(b,c)},extractEventData:function(a,c){var d=c&&c.event&&c.event[a]||c&&c[a]||b;return d},onDomLoad:function(b){a.addEvent("domready",b)}},typeof c.init!="undefined"&&c.init()})(window)

View File

@ -1 +0,0 @@
(function(a,b){"use strict";var c=a.History=a.History||{};if(typeof c.Adapter!="undefined")throw new Error("History.js Adapter has already been loaded...");c.Adapter={handlers:{},_uid:1,uid:function(a){return a._uid||(a._uid=c.Adapter._uid++)},bind:function(a,b,d){var e=c.Adapter.uid(a);c.Adapter.handlers[e]=c.Adapter.handlers[e]||{},c.Adapter.handlers[e][b]=c.Adapter.handlers[e][b]||[],c.Adapter.handlers[e][b].push(d),a["on"+b]=function(a,b){return function(d){c.Adapter.trigger(a,b,d)}}(a,b)},trigger:function(a,b,d){d=d||{};var e=c.Adapter.uid(a),f,g;c.Adapter.handlers[e]=c.Adapter.handlers[e]||{},c.Adapter.handlers[e][b]=c.Adapter.handlers[e][b]||[];for(f=0,g=c.Adapter.handlers[e][b].length;f<g;++f)c.Adapter.handlers[e][b][f].apply(this,[d])},extractEventData:function(a,c){var d=c&&c[a]||b;return d},onDomLoad:function(b){var c=a.setTimeout(function(){b()},2e3);a.onload=function(){clearTimeout(c),b()}}},typeof c.init!="undefined"&&c.init()})(window)

View File

@ -1 +0,0 @@
(function(a,b){"use strict";var c=a.History=a.History||{},d=a.document,e=a.RightJS,f=e.$;if(typeof c.Adapter!="undefined")throw new Error("History.js Adapter has already been loaded...");c.Adapter={bind:function(a,b,c){f(a).on(b,c)},trigger:function(a,b,c){f(a).fire(b,c)},extractEventData:function(a,c){var d=c&&c._&&c._[a]||b;return d},onDomLoad:function(a){f(d).onReady(a)}},typeof c.init!="undefined"&&c.init()})(window)

View File

@ -1 +0,0 @@
(function(a,b){"use strict";var c=a.History=a.History||{},d=a.Zepto;if(typeof c.Adapter!="undefined")throw new Error("History.js Adapter has already been loaded...");c.Adapter={bind:function(a,b,c){(new d(a)).bind(b,c)},trigger:function(a,b){(new d(a)).trigger(b)},extractEventData:function(a,c){var d=c&&c[a]||b;return d},onDomLoad:function(a){new d(a)}},typeof c.init!="undefined"&&c.init()})(window)

View File

@ -1 +0,0 @@
(function(a,b){"use strict";var c=a.document,d=a.setTimeout||d,e=a.clearTimeout||e,f=a.setInterval||f,g=a.History=a.History||{};if(typeof g.initHtml4!="undefined")throw new Error("History.js HTML4 Support has already been loaded...");g.initHtml4=function(){if(typeof g.initHtml4.initialized!="undefined")return!1;g.initHtml4.initialized=!0,g.enabled=!0,g.savedHashes=[],g.isLastHash=function(a){var b=g.getHashByIndex(),c;return c=a===b,c},g.saveHash=function(a){return g.isLastHash(a)?!1:(g.savedHashes.push(a),!0)},g.getHashByIndex=function(a){var b=null;return typeof a=="undefined"?b=g.savedHashes[g.savedHashes.length-1]:a<0?b=g.savedHashes[g.savedHashes.length+a]:b=g.savedHashes[a],b},g.discardedHashes={},g.discardedStates={},g.discardState=function(a,b,c){var d=g.getHashByState(a),e;return e={discardedState:a,backState:c,forwardState:b},g.discardedStates[d]=e,!0},g.discardHash=function(a,b,c){var d={discardedHash:a,backState:c,forwardState:b};return g.discardedHashes[a]=d,!0},g.discardedState=function(a){var b=g.getHashByState(a),c;return c=g.discardedStates[b]||!1,c},g.discardedHash=function(a){var b=g.discardedHashes[a]||!1;return b},g.recycleState=function(a){var b=g.getHashByState(a);return g.discardedState(a)&&delete g.discardedStates[b],!0},g.emulated.hashChange&&(g.hashChangeInit=function(){g.checkerFunction=null;var b="",d,e,h,i;return g.isInternetExplorer()?(d="historyjs-iframe",e=c.createElement("iframe"),e.setAttribute("id",d),e.style.display="none",c.body.appendChild(e),e.contentWindow.document.open(),e.contentWindow.document.close(),h="",i=!1,g.checkerFunction=function(){if(i)return!1;i=!0;var c=g.getHash()||"",d=g.unescapeHash(e.contentWindow.document.location.hash)||"";return c!==b?(b=c,d!==c&&(h=d=c,e.contentWindow.document.open(),e.contentWindow.document.close(),e.contentWindow.document.location.hash=g.escapeHash(c)),g.Adapter.trigger(a,"hashchange")):d!==h&&(h=d,g.setHash(d,!1)),i=!1,!0}):g.checkerFunction=function(){var c=g.getHash();return c!==b&&(b=c,g.Adapter.trigger(a,"hashchange")),!0},g.intervalList.push(f(g.checkerFunction,g.options.hashChangeInterval)),!0},g.Adapter.onDomLoad(g.hashChangeInit)),g.emulated.pushState&&(g.onHashChange=function(b){var d=b&&b.newURL||c.location.href,e=g.getHashByUrl(d),f=null,h=null,i=null,j;return g.isLastHash(e)?(g.busy(!1),!1):(g.doubleCheckComplete(),g.saveHash(e),e&&g.isTraditionalAnchor(e)?(g.Adapter.trigger(a,"anchorchange"),g.busy(!1),!1):(f=g.extractState(g.getFullUrl(e||c.location.href,!1),!0),g.isLastSavedState(f)?(g.busy(!1),!1):(h=g.getHashByState(f),j=g.discardedState(f),j?(g.getHashByIndex(-2)===g.getHashByState(j.forwardState)?g.back(!1):g.forward(!1),!1):(g.pushState(f.data,f.title,f.url,!1),!0))))},g.Adapter.bind(a,"hashchange",g.onHashChange),g.pushState=function(b,d,e,f){if(g.getHashByUrl(e))throw new Error("History.js does not support states with fragement-identifiers (hashes/anchors).");if(f!==!1&&g.busy())return g.pushQueue({scope:g,callback:g.pushState,args:arguments,queue:f}),!1;g.busy(!0);var h=g.createStateObject(b,d,e),i=g.getHashByState(h),j=g.getState(!1),k=g.getHashByState(j),l=g.getHash();return g.storeState(h),g.expectedStateId=h.id,g.recycleState(h),g.setTitle(h),i===k?(g.busy(!1),!1):i!==l&&i!==g.getShortUrl(c.location.href)?(g.setHash(i,!1),!1):(g.saveState(h),g.Adapter.trigger(a,"statechange"),g.busy(!1),!0)},g.replaceState=function(a,b,c,d){if(g.getHashByUrl(c))throw new Error("History.js does not support states with fragement-identifiers (hashes/anchors).");if(d!==!1&&g.busy())return g.pushQueue({scope:g,callback:g.replaceState,args:arguments,queue:d}),!1;g.busy(!0);var e=g.createStateObject(a,b,c),f=g.getState(!1),h=g.getStateByIndex(-2);return g.discardState(f,e,h),g.pushState(e.data,e.title,e.url,!1),!0}),g.emulated.pushState&&g.getHash()&&!g.emulated.hashChange&&g.Adapter.onDomLoad(function(){g.Adapter.trigger(a,"hashchange")})},typeof g.init!="undefined"&&g.init()})(window)

File diff suppressed because one or more lines are too long

View File

@ -1 +0,0 @@
window.JSON||(window.JSON={}),function(){function f(a){return a<10?"0"+a:a}function quote(a){return escapable.lastIndex=0,escapable.test(a)?'"'+a.replace(escapable,function(a){var b=meta[a];return typeof b=="string"?b:"\\u"+("0000"+a.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+a+'"'}function str(a,b){var c,d,e,f,g=gap,h,i=b[a];i&&typeof i=="object"&&typeof i.toJSON=="function"&&(i=i.toJSON(a)),typeof rep=="function"&&(i=rep.call(b,a,i));switch(typeof i){case"string":return quote(i);case"number":return isFinite(i)?String(i):"null";case"boolean":case"null":return String(i);case"object":if(!i)return"null";gap+=indent,h=[];if(Object.prototype.toString.apply(i)==="[object Array]"){f=i.length;for(c=0;c<f;c+=1)h[c]=str(c,i)||"null";return e=h.length===0?"[]":gap?"[\n"+gap+h.join(",\n"+gap)+"\n"+g+"]":"["+h.join(",")+"]",gap=g,e}if(rep&&typeof rep=="object"){f=rep.length;for(c=0;c<f;c+=1)d=rep[c],typeof d=="string"&&(e=str(d,i),e&&h.push(quote(d)+(gap?": ":":")+e))}else for(d in i)Object.hasOwnProperty.call(i,d)&&(e=str(d,i),e&&h.push(quote(d)+(gap?": ":":")+e));return e=h.length===0?"{}":gap?"{\n"+gap+h.join(",\n"+gap)+"\n"+g+"}":"{"+h.join(",")+"}",gap=g,e}}"use strict",typeof Date.prototype.toJSON!="function"&&(Date.prototype.toJSON=function(a){return isFinite(this.valueOf())?this.getUTCFullYear()+"-"+f(this.getUTCMonth()+1)+"-"+f(this.getUTCDate())+"T"+f(this.getUTCHours())+":"+f(this.getUTCMinutes())+":"+f(this.getUTCSeconds())+"Z":null},String.prototype.toJSON=Number.prototype.toJSON=Boolean.prototype.toJSON=function(a){return this.valueOf()});var JSON=window.JSON,cx=/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,escapable=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,gap,indent,meta={"\b":"\\b","\t":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"},rep;typeof JSON.stringify!="function"&&(JSON.stringify=function(a,b,c){var d;gap="",indent="";if(typeof c=="number")for(d=0;d<c;d+=1)indent+=" ";else typeof c=="string"&&(indent=c);rep=b;if(!b||typeof b=="function"||typeof b=="object"&&typeof b.length=="number")return str("",{"":a});throw new Error("JSON.stringify")}),typeof JSON.parse!="function"&&(JSON.parse=function(text,reviver){function walk(a,b){var c,d,e=a[b];if(e&&typeof e=="object")for(c in e)Object.hasOwnProperty.call(e,c)&&(d=walk(e,c),d!==undefined?e[c]=d:delete e[c]);return reviver.call(a,b,e)}var j;text=String(text),cx.lastIndex=0,cx.test(text)&&(text=text.replace(cx,function(a){return"\\u"+("0000"+a.charCodeAt(0).toString(16)).slice(-4)}));if(/^[\],:{}\s]*$/.test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,"@").replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,"]").replace(/(?:^|:|,)(?:\s*\[)+/g,"")))return j=eval("("+text+")"),typeof reviver=="function"?walk({"":j},""):j;throw new SyntaxError("JSON.parse")})}()

View File

@ -1,77 +0,0 @@
/**
* History.js jQuery Adapter
* @author Benjamin Arthur Lupton <contact@balupton.com>
* @copyright 2010-2011 Benjamin Arthur Lupton <contact@balupton.com>
* @license New BSD License <http://creativecommons.org/licenses/BSD/>
*/
// Closure
(function(window,undefined){
"use strict";
// Localise Globals
var
History = window.History = window.History||{},
jQuery = window.jQuery;
// Check Existence
if ( typeof History.Adapter !== 'undefined' ) {
throw new Error('History.js Adapter has already been loaded...');
}
// Add the Adapter
History.Adapter = {
/**
* History.Adapter.bind(el,event,callback)
* @param {Element|string} el
* @param {string} event - custom and standard events
* @param {function} callback
* @return {void}
*/
bind: function(el,event,callback){
jQuery(el).bind(event,callback);
},
/**
* History.Adapter.trigger(el,event)
* @param {Element|string} el
* @param {string} event - custom and standard events
* @param {Object=} extra - a object of extra event data (optional)
* @return {void}
*/
trigger: function(el,event,extra){
jQuery(el).trigger(event,extra);
},
/**
* History.Adapter.extractEventData(key,event,extra)
* @param {string} key - key for the event data to extract
* @param {string} event - custom and standard events
* @param {Object=} extra - a object of extra event data (optional)
* @return {mixed}
*/
extractEventData: function(key,event,extra){
// jQuery Native then jQuery Custom
var result = (event && event.originalEvent && event.originalEvent[key]) || (extra && extra[key]) || undefined;
// Return
return result;
},
/**
* History.Adapter.onDomLoad(callback)
* @param {function} callback
* @return {void}
*/
onDomLoad: function(callback) {
jQuery(callback);
}
};
// Try and Initialise History
if ( typeof History.init !== 'undefined' ) {
History.init();
}
})(window);

View File

@ -1,84 +0,0 @@
/**
* History.js MooTools Adapter
* @author Benjamin Arthur Lupton <contact@balupton.com>
* @copyright 2010-2011 Benjamin Arthur Lupton <contact@balupton.com>
* @license New BSD License <http://creativecommons.org/licenses/BSD/>
*/
// Closure
(function(window,undefined){
"use strict";
// Localise Globals
var
History = window.History = window.History||{},
MooTools = window.MooTools,
Element = window.Element;
// Check Existence
if ( typeof History.Adapter !== 'undefined' ) {
throw new Error('History.js Adapter has already been loaded...');
}
// Make MooTools aware of History.js Events
Object.append(Element.NativeEvents,{
'popstate':2,
'hashchange':2
});
// Add the Adapter
History.Adapter = {
/**
* History.Adapter.bind(el,event,callback)
* @param {Element|string} el
* @param {string} event - custom and standard events
* @param {function} callback
* @return {void}
*/
bind: function(el,event,callback){
var El = typeof el === 'string' ? document.id(el) : el;
El.addEvent(event,callback);
},
/**
* History.Adapter.trigger(el,event)
* @param {Element|string} el
* @param {string} event - custom and standard events
* @param {Object=} extra - a object of extra event data (optional)
* @return void
*/
trigger: function(el,event,extra){
var El = typeof el === 'string' ? document.id(el) : el;
El.fireEvent(event,extra);
},
/**
* History.Adapter.extractEventData(key,event,extra)
* @param {string} key - key for the event data to extract
* @param {string} event - custom and standard events
* @return {mixed}
*/
extractEventData: function(key,event){
// MooTools Native then MooTools Custom
var result = (event && event.event && event.event[key]) || (event && event[key]) || undefined;
// Return
return result;
},
/**
* History.Adapter.onDomLoad(callback)
* @param {function} callback
* @return {void}
*/
onDomLoad: function(callback) {
window.addEvent('domready',callback);
}
};
// Try and Initialise History
if ( typeof History.init !== 'undefined' ) {
History.init();
}
})(window);

View File

@ -1,121 +0,0 @@
/**
* History.js Native Adapter
* @author Benjamin Arthur Lupton <contact@balupton.com>
* @copyright 2010-2011 Benjamin Arthur Lupton <contact@balupton.com>
* @license New BSD License <http://creativecommons.org/licenses/BSD/>
*/
// Closure
(function(window,undefined){
"use strict";
// Localise Globals
var History = window.History = window.History||{};
// Check Existence
if ( typeof History.Adapter !== 'undefined' ) {
throw new Error('History.js Adapter has already been loaded...');
}
// Add the Adapter
History.Adapter = {
/**
* History.Adapter.handlers[uid][eventName] = Array
*/
handlers: {},
/**
* History.Adapter._uid
* The current element unique identifier
*/
_uid: 1,
/**
* History.Adapter.uid(element)
* @param {Element} element
* @return {String} uid
*/
uid: function(element){
return element._uid || (element._uid = History.Adapter._uid++);
},
/**
* History.Adapter.bind(el,event,callback)
* @param {Element} element
* @param {String} eventName - custom and standard events
* @param {Function} callback
* @return
*/
bind: function(element,eventName,callback){
// Prepare
var uid = History.Adapter.uid(element);
// Apply Listener
History.Adapter.handlers[uid] = History.Adapter.handlers[uid] || {};
History.Adapter.handlers[uid][eventName] = History.Adapter.handlers[uid][eventName] || [];
History.Adapter.handlers[uid][eventName].push(callback);
// Bind Global Listener
element['on'+eventName] = (function(element,eventName){
return function(event){
History.Adapter.trigger(element,eventName,event);
};
})(element,eventName);
},
/**
* History.Adapter.trigger(el,event)
* @param {Element} element
* @param {String} eventName - custom and standard events
* @param {Object} event - a object of event data
* @return
*/
trigger: function(element,eventName,event){
// Prepare
event = event || {};
var uid = History.Adapter.uid(element),
i,n;
// Apply Listener
History.Adapter.handlers[uid] = History.Adapter.handlers[uid] || {};
History.Adapter.handlers[uid][eventName] = History.Adapter.handlers[uid][eventName] || [];
// Fire Listeners
for ( i=0,n=History.Adapter.handlers[uid][eventName].length; i<n; ++i ) {
History.Adapter.handlers[uid][eventName][i].apply(this,[event]);
}
},
/**
* History.Adapter.extractEventData(key,event,extra)
* @param {String} key - key for the event data to extract
* @param {String} event - custom and standard events
* @return {mixed}
*/
extractEventData: function(key,event){
var result = (event && event[key]) || undefined;
return result;
},
/**
* History.Adapter.onDomLoad(callback)
* @param {Function} callback
* @return
*/
onDomLoad: function(callback) {
var timeout = window.setTimeout(function(){
callback();
},2000);
window.onload = function(){
clearTimeout(timeout);
callback();
};
}
};
// Try and Initialise History
if ( typeof History.init !== 'undefined' ) {
History.init();
}
})(window);

View File

@ -1,78 +0,0 @@
/**
* History.js RightJS Adapter
* @author Benjamin Arthur Lupton <contact@balupton.com>
* @copyright 2010-2011 Benjamin Arthur Lupton <contact@balupton.com>
* @license New BSD License <http://creativecommons.org/licenses/BSD/>
*/
// Closure
(function(window,undefined){
"use strict";
// Localise Globals
var
History = window.History = window.History||{},
document = window.document,
RightJS = window.RightJS,
$ = RightJS.$;
// Check Existence
if ( typeof History.Adapter !== 'undefined' ) {
throw new Error('History.js Adapter has already been loaded...');
}
// Add the Adapter
History.Adapter = {
/**
* History.Adapter.bind(el,event,callback)
* @param {Element|Selector} el
* @param {String} event - custom and standard events
* @param {Function} callback
* @return
*/
bind: function(el,event,callback){
$(el).on(event,callback);
},
/**
* History.Adapter.trigger(el,event)
* @param {Element|Selector} el
* @param {String} event - custom and standard events
* @param {Object} extraEventData - a object of extra event data
* @return
*/
trigger: function(el,event,extraEventData){
$(el).fire(event,extraEventData);
},
/**
* History.Adapter.extractEventData(key,event,extra)
* @param {String} key - key for the event data to extract
* @param {String} event - custom and standard events
* @return {mixed}
*/
extractEventData: function(key,event){
// Right.js Native
// Right.js Custom
var result = (event && event._ && event._[key]) || undefined;
// Return
return result;
},
/**
* History.Adapter.onDomLoad(callback)
* @param {Function} callback
* @return
*/
onDomLoad: function(callback) {
$(document).onReady(callback);
}
};
// Try and Initialise History
if ( typeof History.init !== 'undefined' ) {
History.init();
}
})(window);

View File

@ -1,74 +0,0 @@
/**
* History.js Zepto Adapter
* @author Benjamin Arthur Lupton <contact@balupton.com>
* @copyright 2010-2011 Benjamin Arthur Lupton <contact@balupton.com>
* @license New BSD License <http://creativecommons.org/licenses/BSD/>
*/
// Closure
(function(window,undefined){
"use strict";
// Localise Globals
var
History = window.History = window.History||{},
Zepto = window.Zepto;
// Check Existence
if ( typeof History.Adapter !== 'undefined' ) {
throw new Error('History.js Adapter has already been loaded...');
}
// Add the Adapter
History.Adapter = {
/**
* History.Adapter.bind(el,event,callback)
* @param {Element|string} el
* @param {string} event - custom and standard events
* @param {function} callback
* @return {void}
*/
bind: function(el,event,callback){
new Zepto(el).bind(event,callback);
},
/**
* History.Adapter.trigger(el,event)
* @param {Element|string} el
* @param {string} event - custom and standard events
* @return {void}
*/
trigger: function(el,event){
new Zepto(el).trigger(event);
},
/**
* History.Adapter.extractEventData(key,event,extra)
* @param {string} key - key for the event data to extract
* @param {string} event - custom and standard events
* @return {mixed}
*/
extractEventData: function(key,event){
// Zepto Native
var result = (event && event[key]) || undefined;
// Return
return result;
},
/**
* History.Adapter.onDomLoad(callback)
* @param {function} callback
* @return {void}
*/
onDomLoad: function(callback) {
new Zepto(callback);
}
};
// Try and Initialise History
if ( typeof History.init !== 'undefined' ) {
History.init();
}
})(window);

View File

@ -1,621 +0,0 @@
/**
* History.js HTML4 Support
* Depends on the HTML5 Support
* @author Benjamin Arthur Lupton <contact@balupton.com>
* @copyright 2010-2011 Benjamin Arthur Lupton <contact@balupton.com>
* @license New BSD License <http://creativecommons.org/licenses/BSD/>
*/
(function(window,undefined){
"use strict";
// ========================================================================
// Initialise
// Localise Globals
var
document = window.document, // Make sure we are using the correct document
setTimeout = window.setTimeout||setTimeout,
clearTimeout = window.clearTimeout||clearTimeout,
setInterval = window.setInterval||setInterval,
History = window.History = window.History||{}; // Public History Object
// Check Existence
if ( typeof History.initHtml4 !== 'undefined' ) {
throw new Error('History.js HTML4 Support has already been loaded...');
}
// ========================================================================
// Initialise HTML4 Support
// Initialise HTML4 Support
History.initHtml4 = function(){
// Initialise
if ( typeof History.initHtml4.initialized !== 'undefined' ) {
// Already Loaded
return false;
}
else {
History.initHtml4.initialized = true;
}
// ====================================================================
// Properties
/**
* History.enabled
* Is History enabled?
*/
History.enabled = true;
// ====================================================================
// Hash Storage
/**
* History.savedHashes
* Store the hashes in an array
*/
History.savedHashes = [];
/**
* History.isLastHash(newHash)
* Checks if the hash is the last hash
* @param {string} newHash
* @return {boolean} true
*/
History.isLastHash = function(newHash){
// Prepare
var oldHash = History.getHashByIndex(),
isLast;
// Check
isLast = newHash === oldHash;
// Return isLast
return isLast;
};
/**
* History.saveHash(newHash)
* Push a Hash
* @param {string} newHash
* @return {boolean} true
*/
History.saveHash = function(newHash){
// Check Hash
if ( History.isLastHash(newHash) ) {
return false;
}
// Push the Hash
History.savedHashes.push(newHash);
// Return true
return true;
};
/**
* History.getHashByIndex()
* Gets a hash by the index
* @param {integer} index
* @return {string}
*/
History.getHashByIndex = function(index){
// Prepare
var hash = null;
// Handle
if ( typeof index === 'undefined' ) {
// Get the last inserted
hash = History.savedHashes[History.savedHashes.length-1];
}
else if ( index < 0 ) {
// Get from the end
hash = History.savedHashes[History.savedHashes.length+index];
}
else {
// Get from the beginning
hash = History.savedHashes[index];
}
// Return hash
return hash;
};
// ====================================================================
// Discarded States
/**
* History.discardedHashes
* A hashed array of discarded hashes
*/
History.discardedHashes = {};
/**
* History.discardedStates
* A hashed array of discarded states
*/
History.discardedStates = {};
/**
* History.discardState(State)
* Discards the state by ignoring it through History
* @param {object} State
* @return {true}
*/
History.discardState = function(discardedState,forwardState,backState){
//History.debug('History.discardState', arguments);
// Prepare
var discardedStateHash = History.getHashByState(discardedState),
discardObject;
// Create Discard Object
discardObject = {
'discardedState': discardedState,
'backState': backState,
'forwardState': forwardState
};
// Add to DiscardedStates
History.discardedStates[discardedStateHash] = discardObject;
// Return true
return true;
};
/**
* History.discardHash(hash)
* Discards the hash by ignoring it through History
* @param {string} hash
* @return {true}
*/
History.discardHash = function(discardedHash,forwardState,backState){
//History.debug('History.discardState', arguments);
// Create Discard Object
var discardObject = {
'discardedHash': discardedHash,
'backState': backState,
'forwardState': forwardState
};
// Add to discardedHash
History.discardedHashes[discardedHash] = discardObject;
// Return true
return true;
};
/**
* History.discardState(State)
* Checks to see if the state is discarded
* @param {object} State
* @return {bool}
*/
History.discardedState = function(State){
// Prepare
var StateHash = History.getHashByState(State),
discarded;
// Check
discarded = History.discardedStates[StateHash]||false;
// Return true
return discarded;
};
/**
* History.discardedHash(hash)
* Checks to see if the state is discarded
* @param {string} State
* @return {bool}
*/
History.discardedHash = function(hash){
// Check
var discarded = History.discardedHashes[hash]||false;
// Return true
return discarded;
};
/**
* History.recycleState(State)
* Allows a discarded state to be used again
* @param {object} data
* @param {string} title
* @param {string} url
* @return {true}
*/
History.recycleState = function(State){
//History.debug('History.recycleState', arguments);
// Prepare
var StateHash = History.getHashByState(State);
// Remove from DiscardedStates
if ( History.discardedState(State) ) {
delete History.discardedStates[StateHash];
}
// Return true
return true;
};
// ====================================================================
// HTML4 HashChange Support
if ( History.emulated.hashChange ) {
/*
* We must emulate the HTML4 HashChange Support by manually checking for hash changes
*/
/**
* History.hashChangeInit()
* Init the HashChange Emulation
*/
History.hashChangeInit = function(){
// Define our Checker Function
History.checkerFunction = null;
// Define some variables that will help in our checker function
var lastDocumentHash = '',
iframeId, iframe,
lastIframeHash, checkerRunning;
// Handle depending on the browser
if ( History.isInternetExplorer() ) {
// IE6 and IE7
// We need to use an iframe to emulate the back and forward buttons
// Create iFrame
iframeId = 'historyjs-iframe';
iframe = document.createElement('iframe');
// Adjust iFarme
iframe.setAttribute('id', iframeId);
iframe.style.display = 'none';
// Append iFrame
document.body.appendChild(iframe);
// Create initial history entry
iframe.contentWindow.document.open();
iframe.contentWindow.document.close();
// Define some variables that will help in our checker function
lastIframeHash = '';
checkerRunning = false;
// Define the checker function
History.checkerFunction = function(){
// Check Running
if ( checkerRunning ) {
return false;
}
// Update Running
checkerRunning = true;
// Fetch
var documentHash = History.getHash()||'',
iframeHash = History.unescapeHash(iframe.contentWindow.document.location.hash)||'';
// The Document Hash has changed (application caused)
if ( documentHash !== lastDocumentHash ) {
// Equalise
lastDocumentHash = documentHash;
// Create a history entry in the iframe
if ( iframeHash !== documentHash ) {
//History.debug('hashchange.checker: iframe hash change', 'documentHash (new):', documentHash, 'iframeHash (old):', iframeHash);
// Equalise
lastIframeHash = iframeHash = documentHash;
// Create History Entry
iframe.contentWindow.document.open();
iframe.contentWindow.document.close();
// Update the iframe's hash
iframe.contentWindow.document.location.hash = History.escapeHash(documentHash);
}
// Trigger Hashchange Event
History.Adapter.trigger(window,'hashchange');
}
// The iFrame Hash has changed (back button caused)
else if ( iframeHash !== lastIframeHash ) {
//History.debug('hashchange.checker: iframe hash out of sync', 'iframeHash (new):', iframeHash, 'documentHash (old):', documentHash);
// Equalise
lastIframeHash = iframeHash;
// Update the Hash
History.setHash(iframeHash,false);
}
// Reset Running
checkerRunning = false;
// Return true
return true;
};
}
else {
// We are not IE
// Firefox 1 or 2, Opera
// Define the checker function
History.checkerFunction = function(){
// Prepare
var documentHash = History.getHash();
// The Document Hash has changed (application caused)
if ( documentHash !== lastDocumentHash ) {
// Equalise
lastDocumentHash = documentHash;
// Trigger Hashchange Event
History.Adapter.trigger(window,'hashchange');
}
// Return true
return true;
};
}
// Apply the checker function
History.intervalList.push(setInterval(History.checkerFunction, History.options.hashChangeInterval));
// Done
return true;
}; // History.hashChangeInit
// Bind hashChangeInit
History.Adapter.onDomLoad(History.hashChangeInit);
} // History.emulated.hashChange
// ====================================================================
// HTML5 State Support
// Non-Native pushState Implementation
if ( History.emulated.pushState ) {
/*
* We must emulate the HTML5 State Management by using HTML4 HashChange
*/
/**
* History.onHashChange(event)
* Trigger HTML5's window.onpopstate via HTML4 HashChange Support
*/
History.onHashChange = function(event){
//History.debug('History.onHashChange', arguments);
// Prepare
var currentUrl = ((event && event.newURL) || document.location.href),
currentHash = History.getHashByUrl(currentUrl),
currentState = null,
currentStateHash = null,
currentStateHashExits = null,
discardObject;
// Check if we are the same state
if ( History.isLastHash(currentHash) ) {
// There has been no change (just the page's hash has finally propagated)
//History.debug('History.onHashChange: no change');
History.busy(false);
return false;
}
// Reset the double check
History.doubleCheckComplete();
// Store our location for use in detecting back/forward direction
History.saveHash(currentHash);
// Expand Hash
if ( currentHash && History.isTraditionalAnchor(currentHash) ) {
//History.debug('History.onHashChange: traditional anchor', currentHash);
// Traditional Anchor Hash
History.Adapter.trigger(window,'anchorchange');
History.busy(false);
return false;
}
// Create State
currentState = History.extractState(History.getFullUrl(currentHash||document.location.href,false),true);
// Check if we are the same state
if ( History.isLastSavedState(currentState) ) {
//History.debug('History.onHashChange: no change');
// There has been no change (just the page's hash has finally propagated)
History.busy(false);
return false;
}
// Create the state Hash
currentStateHash = History.getHashByState(currentState);
// Check if we are DiscardedState
discardObject = History.discardedState(currentState);
if ( discardObject ) {
// Ignore this state as it has been discarded and go back to the state before it
if ( History.getHashByIndex(-2) === History.getHashByState(discardObject.forwardState) ) {
// We are going backwards
//History.debug('History.onHashChange: go backwards');
History.back(false);
} else {
// We are going forwards
//History.debug('History.onHashChange: go forwards');
History.forward(false);
}
return false;
}
// Push the new HTML5 State
//History.debug('History.onHashChange: success hashchange');
History.pushState(currentState.data,currentState.title,currentState.url,false);
// End onHashChange closure
return true;
};
History.Adapter.bind(window,'hashchange',History.onHashChange);
/**
* History.pushState(data,title,url)
* Add a new State to the history object, become it, and trigger onpopstate
* We have to trigger for HTML4 compatibility
* @param {object} data
* @param {string} title
* @param {string} url
* @return {true}
*/
History.pushState = function(data,title,url,queue){
//History.debug('History.pushState: called', arguments);
// Check the State
if ( History.getHashByUrl(url) ) {
throw new Error('History.js does not support states with fragement-identifiers (hashes/anchors).');
}
// Handle Queueing
if ( queue !== false && History.busy() ) {
// Wait + Push to Queue
//History.debug('History.pushState: we must wait', arguments);
History.pushQueue({
scope: History,
callback: History.pushState,
args: arguments,
queue: queue
});
return false;
}
// Make Busy
History.busy(true);
// Fetch the State Object
var newState = History.createStateObject(data,title,url),
newStateHash = History.getHashByState(newState),
oldState = History.getState(false),
oldStateHash = History.getHashByState(oldState),
html4Hash = History.getHash();
// Store the newState
History.storeState(newState);
History.expectedStateId = newState.id;
// Recycle the State
History.recycleState(newState);
// Force update of the title
History.setTitle(newState);
// Check if we are the same State
if ( newStateHash === oldStateHash ) {
//History.debug('History.pushState: no change', newStateHash);
History.busy(false);
return false;
}
// Update HTML4 Hash
if ( newStateHash !== html4Hash && newStateHash !== History.getShortUrl(document.location.href) ) {
//History.debug('History.pushState: update hash', newStateHash, html4Hash);
History.setHash(newStateHash,false);
return false;
}
// Update HTML5 State
History.saveState(newState);
// Fire HTML5 Event
//History.debug('History.pushState: trigger popstate');
History.Adapter.trigger(window,'statechange');
History.busy(false);
// End pushState closure
return true;
};
/**
* History.replaceState(data,title,url)
* Replace the State and trigger onpopstate
* We have to trigger for HTML4 compatibility
* @param {object} data
* @param {string} title
* @param {string} url
* @return {true}
*/
History.replaceState = function(data,title,url,queue){
//History.debug('History.replaceState: called', arguments);
// Check the State
if ( History.getHashByUrl(url) ) {
throw new Error('History.js does not support states with fragement-identifiers (hashes/anchors).');
}
// Handle Queueing
if ( queue !== false && History.busy() ) {
// Wait + Push to Queue
//History.debug('History.replaceState: we must wait', arguments);
History.pushQueue({
scope: History,
callback: History.replaceState,
args: arguments,
queue: queue
});
return false;
}
// Make Busy
History.busy(true);
// Fetch the State Objects
var newState = History.createStateObject(data,title,url),
oldState = History.getState(false),
previousState = History.getStateByIndex(-2);
// Discard Old State
History.discardState(oldState,newState,previousState);
// Alias to PushState
History.pushState(newState.data,newState.title,newState.url,false);
// End replaceState closure
return true;
};
} // History.emulated.pushState
// ====================================================================
// Initialise
// Non-Native pushState Implementation
if ( History.emulated.pushState ) {
/**
* Ensure initial state is handled correctly
*/
if ( History.getHash() && !History.emulated.hashChange ) {
History.Adapter.onDomLoad(function(){
History.Adapter.trigger(window,'hashchange');
});
}
} // History.emulated.pushState
}; // History.initHtml4
// Try and Initialise History
if ( typeof History.init !== 'undefined' ) {
History.init();
}
})(window);

File diff suppressed because it is too large Load Diff

View File

@ -1,480 +0,0 @@
/*
http://www.JSON.org/json2.js
2011-01-18
Public Domain.
NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.
See http://www.JSON.org/js.html
This code should be minified before deployment.
See http://javascript.crockford.com/jsmin.html
USE YOUR OWN COPY. IT IS EXTREMELY UNWISE TO LOAD CODE FROM SERVERS YOU DO
NOT CONTROL.
This file creates a global JSON object containing two methods: stringify
and parse.
JSON.stringify(value, replacer, space)
value any JavaScript value, usually an object or array.
replacer an optional parameter that determines how object
values are stringified for objects. It can be a
function or an array of strings.
space an optional parameter that specifies the indentation
of nested structures. If it is omitted, the text will
be packed without extra whitespace. If it is a number,
it will specify the number of spaces to indent at each
level. If it is a string (such as '\t' or '&nbsp;'),
it contains the characters used to indent at each level.
This method produces a JSON text from a JavaScript value.
When an object value is found, if the object contains a toJSON
method, its toJSON method will be called and the result will be
stringified. A toJSON method does not serialize: it returns the
value represented by the name/value pair that should be serialized,
or undefined if nothing should be serialized. The toJSON method
will be passed the key associated with the value, and this will be
bound to the value
For example, this would serialize Dates as ISO strings.
Date.prototype.toJSON = function (key) {
function f(n) {
// Format integers to have at least two digits.
return n < 10 ? '0' + n : n;
}
return this.getUTCFullYear() + '-' +
f(this.getUTCMonth() + 1) + '-' +
f(this.getUTCDate()) + 'T' +
f(this.getUTCHours()) + ':' +
f(this.getUTCMinutes()) + ':' +
f(this.getUTCSeconds()) + 'Z';
};
You can provide an optional replacer method. It will be passed the
key and value of each member, with this bound to the containing
object. The value that is returned from your method will be
serialized. If your method returns undefined, then the member will
be excluded from the serialization.
If the replacer parameter is an array of strings, then it will be
used to select the members to be serialized. It filters the results
such that only members with keys listed in the replacer array are
stringified.
Values that do not have JSON representations, such as undefined or
functions, will not be serialized. Such values in objects will be
dropped; in arrays they will be replaced with null. You can use
a replacer function to replace those with JSON values.
JSON.stringify(undefined) returns undefined.
The optional space parameter produces a stringification of the
value that is filled with line breaks and indentation to make it
easier to read.
If the space parameter is a non-empty string, then that string will
be used for indentation. If the space parameter is a number, then
the indentation will be that many spaces.
Example:
text = JSON.stringify(['e', {pluribus: 'unum'}]);
// text is '["e",{"pluribus":"unum"}]'
text = JSON.stringify(['e', {pluribus: 'unum'}], null, '\t');
// text is '[\n\t"e",\n\t{\n\t\t"pluribus": "unum"\n\t}\n]'
text = JSON.stringify([new Date()], function (key, value) {
return this[key] instanceof Date ?
'Date(' + this[key] + ')' : value;
});
// text is '["Date(---current time---)"]'
JSON.parse(text, reviver)
This method parses a JSON text to produce an object or array.
It can throw a SyntaxError exception.
The optional reviver parameter is a function that can filter and
transform the results. It receives each of the keys and values,
and its return value is used instead of the original value.
If it returns what it received, then the structure is not modified.
If it returns undefined then the member is deleted.
Example:
// Parse the text. Values that look like ISO date strings will
// be converted to Date objects.
myData = JSON.parse(text, function (key, value) {
var a;
if (typeof value === 'string') {
a =
/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2}(?:\.\d*)?)Z$/.exec(value);
if (a) {
return new Date(Date.UTC(+a[1], +a[2] - 1, +a[3], +a[4],
+a[5], +a[6]));
}
}
return value;
});
myData = JSON.parse('["Date(09/09/2001)"]', function (key, value) {
var d;
if (typeof value === 'string' &&
value.slice(0, 5) === 'Date(' &&
value.slice(-1) === ')') {
d = new Date(value.slice(5, -1));
if (d) {
return d;
}
}
return value;
});
This is a reference implementation. You are free to copy, modify, or
redistribute.
*/
/*jslint evil: true, strict: false, regexp: false */
/*members "", "\b", "\t", "\n", "\f", "\r", "\"", JSON, "\\", apply,
call, charCodeAt, getUTCDate, getUTCFullYear, getUTCHours,
getUTCMinutes, getUTCMonth, getUTCSeconds, hasOwnProperty, join,
lastIndex, length, parse, prototype, push, replace, slice, stringify,
test, toJSON, toString, valueOf
*/
// Create a JSON object only if one does not already exist. We create the
// methods in a closure to avoid creating global variables.
if (!window.JSON) {
window.JSON = {};
}
(function () {
"use strict";
function f(n) {
// Format integers to have at least two digits.
return n < 10 ? '0' + n : n;
}
if (typeof Date.prototype.toJSON !== 'function') {
Date.prototype.toJSON = function (key) {
return isFinite(this.valueOf()) ?
this.getUTCFullYear() + '-' +
f(this.getUTCMonth() + 1) + '-' +
f(this.getUTCDate()) + 'T' +
f(this.getUTCHours()) + ':' +
f(this.getUTCMinutes()) + ':' +
f(this.getUTCSeconds()) + 'Z' : null;
};
String.prototype.toJSON =
Number.prototype.toJSON =
Boolean.prototype.toJSON = function (key) {
return this.valueOf();
};
}
var JSON = window.JSON,
cx = /[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
escapable = /[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
gap,
indent,
meta = { // table of character substitutions
'\b': '\\b',
'\t': '\\t',
'\n': '\\n',
'\f': '\\f',
'\r': '\\r',
'"' : '\\"',
'\\': '\\\\'
},
rep;
function quote(string) {
// If the string contains no control characters, no quote characters, and no
// backslash characters, then we can safely slap some quotes around it.
// Otherwise we must also replace the offending characters with safe escape
// sequences.
escapable.lastIndex = 0;
return escapable.test(string) ? '"' + string.replace(escapable, function (a) {
var c = meta[a];
return typeof c === 'string' ? c :
'\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4);
}) + '"' : '"' + string + '"';
}
function str(key, holder) {
// Produce a string from holder[key].
var i, // The loop counter.
k, // The member key.
v, // The member value.
length,
mind = gap,
partial,
value = holder[key];
// If the value has a toJSON method, call it to obtain a replacement value.
if (value && typeof value === 'object' &&
typeof value.toJSON === 'function') {
value = value.toJSON(key);
}
// If we were called with a replacer function, then call the replacer to
// obtain a replacement value.
if (typeof rep === 'function') {
value = rep.call(holder, key, value);
}
// What happens next depends on the value's type.
switch (typeof value) {
case 'string':
return quote(value);
case 'number':
// JSON numbers must be finite. Encode non-finite numbers as null.
return isFinite(value) ? String(value) : 'null';
case 'boolean':
case 'null':
// If the value is a boolean or null, convert it to a string. Note:
// typeof null does not produce 'null'. The case is included here in
// the remote chance that this gets fixed someday.
return String(value);
// If the type is 'object', we might be dealing with an object or an array or
// null.
case 'object':
// Due to a specification blunder in ECMAScript, typeof null is 'object',
// so watch out for that case.
if (!value) {
return 'null';
}
// Make an array to hold the partial results of stringifying this object value.
gap += indent;
partial = [];
// Is the value an array?
if (Object.prototype.toString.apply(value) === '[object Array]') {
// The value is an array. Stringify every element. Use null as a placeholder
// for non-JSON values.
length = value.length;
for (i = 0; i < length; i += 1) {
partial[i] = str(i, value) || 'null';
}
// Join all of the elements together, separated with commas, and wrap them in
// brackets.
v = partial.length === 0 ? '[]' : gap ?
'[\n' + gap + partial.join(',\n' + gap) + '\n' + mind + ']' :
'[' + partial.join(',') + ']';
gap = mind;
return v;
}
// If the replacer is an array, use it to select the members to be stringified.
if (rep && typeof rep === 'object') {
length = rep.length;
for (i = 0; i < length; i += 1) {
k = rep[i];
if (typeof k === 'string') {
v = str(k, value);
if (v) {
partial.push(quote(k) + (gap ? ': ' : ':') + v);
}
}
}
} else {
// Otherwise, iterate through all of the keys in the object.
for (k in value) {
if (Object.hasOwnProperty.call(value, k)) {
v = str(k, value);
if (v) {
partial.push(quote(k) + (gap ? ': ' : ':') + v);
}
}
}
}
// Join all of the member texts together, separated with commas,
// and wrap them in braces.
v = partial.length === 0 ? '{}' : gap ?
'{\n' + gap + partial.join(',\n' + gap) + '\n' + mind + '}' :
'{' + partial.join(',') + '}';
gap = mind;
return v;
}
}
// If the JSON object does not yet have a stringify method, give it one.
if (typeof JSON.stringify !== 'function') {
JSON.stringify = function (value, replacer, space) {
// The stringify method takes a value and an optional replacer, and an optional
// space parameter, and returns a JSON text. The replacer can be a function
// that can replace values, or an array of strings that will select the keys.
// A default replacer method can be provided. Use of the space parameter can
// produce text that is more easily readable.
var i;
gap = '';
indent = '';
// If the space parameter is a number, make an indent string containing that
// many spaces.
if (typeof space === 'number') {
for (i = 0; i < space; i += 1) {
indent += ' ';
}
// If the space parameter is a string, it will be used as the indent string.
} else if (typeof space === 'string') {
indent = space;
}
// If there is a replacer, it must be a function or an array.
// Otherwise, throw an error.
rep = replacer;
if (replacer && typeof replacer !== 'function' &&
(typeof replacer !== 'object' ||
typeof replacer.length !== 'number')) {
throw new Error('JSON.stringify');
}
// Make a fake root object containing our value under the key of ''.
// Return the result of stringifying the value.
return str('', {'': value});
};
}
// If the JSON object does not yet have a parse method, give it one.
if (typeof JSON.parse !== 'function') {
JSON.parse = function (text, reviver) {
// The parse method takes a text and an optional reviver function, and returns
// a JavaScript value if the text is a valid JSON text.
var j;
function walk(holder, key) {
// The walk method is used to recursively walk the resulting structure so
// that modifications can be made.
var k, v, value = holder[key];
if (value && typeof value === 'object') {
for (k in value) {
if (Object.hasOwnProperty.call(value, k)) {
v = walk(value, k);
if (v !== undefined) {
value[k] = v;
} else {
delete value[k];
}
}
}
}
return reviver.call(holder, key, value);
}
// Parsing happens in four stages. In the first stage, we replace certain
// Unicode characters with escape sequences. JavaScript handles many characters
// incorrectly, either silently deleting them, or treating them as line endings.
text = String(text);
cx.lastIndex = 0;
if (cx.test(text)) {
text = text.replace(cx, function (a) {
return '\\u' +
('0000' + a.charCodeAt(0).toString(16)).slice(-4);
});
}
// In the second stage, we run the text against regular expressions that look
// for non-JSON patterns. We are especially concerned with '()' and 'new'
// because they can cause invocation, and '=' because it can cause mutation.
// But just to be safe, we want to reject all unexpected forms.
// We split the second stage into 4 regexp operations in order to work around
// crippling inefficiencies in IE's and Safari's regexp engines. First we
// replace the JSON backslash pairs with '@' (a non-JSON character). Second, we
// replace all simple value tokens with ']' characters. Third, we delete all
// open brackets that follow a colon or comma or that begin the text. Finally,
// we look to see that the remaining characters are only whitespace or ']' or
// ',' or ':' or '{' or '}'. If that is so, then the text is safe for eval.
if (/^[\],:{}\s]*$/
.test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g, '@')
.replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, ']')
.replace(/(?:^|:|,)(?:\s*\[)+/g, ''))) {
// In the third stage we use the eval function to compile the text into a
// JavaScript structure. The '{' operator is subject to a syntactic ambiguity
// in JavaScript: it can begin a block or an object literal. We wrap the text
// in parens to eliminate the ambiguity.
j = eval('(' + text + ')');
// In the optional fourth stage, we recursively walk the new structure, passing
// each name/value pair to a reviver function for possible transformation.
return typeof reviver === 'function' ?
walk({'': j}, '') : j;
}
// If the text is not JSON parseable, then a SyntaxError is thrown.
throw new SyntaxError('JSON.parse');
};
}
}());

View File

@ -1,22 +0,0 @@
<?php
# Locations
$dir = dirname(__FILE__);
$out = "$dir/../tests";
# Base URL
$base_url = '/';
$tests_url = $base_url.'tests';
# Data
$browsers = array(
'html4+html5',
'html5'
);
$adapters = array(
'jquery',
'mootools',
'native',
'right',
'zepto'
);

View File

@ -1,45 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<title>History.js Test Suite</title>
<style type="text/css">
body,html,iframe {
padding:0;
margin:0;
outline:none;
border:none;
}
.browser {
padding-top:1em;
}
.adapter {
padding-top:1em;
}
</style>
</head>
<body>
<h1>History.js Test Suite</h1>
<p>HTML5 Browsers must pass the HTML4+HTML5 tests</p>
<p>HTML4 Browsers must pass the HTML4 tests and should fail the HTML5 tests</p>
<?php
foreach ( $browsers as $browser ) :
echo '<div class="browser">';
foreach ( $adapters as $adapter ) :
echo '<div class="adapter">';
# Url
$url = "${browser}.${adapter}.html";
# Title
$Browser = ucwords($browser);
$Adapter = ucwords($adapter);
$title = "History.js ${Browser} ${Adapter} Test Suite";
# Render
?><a href="<?=$url?>"><?=$title?></a><?php
echo '</div>';
endforeach;
echo '</div>';
endforeach;
?>
</body>
</html>

View File

@ -1,51 +0,0 @@
<?php
# Url
$url = "${browser}.${adapter}.html";
# Titles
$Browser = strtoupper($browser);
$Adapter = ucwords($adapter);
$title = "History.js ${Browser} ${Adapter} Test Suite";
?><!DOCTYPE html>
<html debug="true">
<head>
<meta http-equiv="Expires" CONTENT="Mon, 06 Jan 1990 00:00:01 GMT" />
<meta http-equiv="PRAGMA" CONTENT="NO-CACHE" />
<meta http-equiv="CACHE-CONTROL" CONTENT="NO-CACHE" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<title><?=$title?></title>
<!-- Check -->
<script>
var href = window.document.location.href,
test_url = href.replace(/(history\.js\/tests\/[^\/\?\#]+).*/,'$1');
if ( test_url !== href ) {
window.document.location.href = test_url;
}
</script>
<!-- Framework -->
<script src="../vendor/<?=$adapter?>.js"></script>
<!-- QUnit -->
<link rel="stylesheet" href="../vendor/qunit/qunit/qunit.css" type="text/css" media="screen">
<script src="../vendor/qunit/qunit/qunit.js"></script>
</head>
<body>
<!-- Elements -->
<h1 id="qunit-header"><?=$title?></h1>
<h2 id="qunit-banner"></h2>
<div id="qunit-testrunner-toolbar"></div>
<h2 id="qunit-userAgent"></h2>
<ol id="qunit-tests"></ol>
<div id="qunit-fixture">test markup</div>
<button onclick="history.back()">back</button><button onclick="history.forward()">forward</button>
<textarea id="log" style="width:100%;height:400px"></textarea>
<!-- History.js -->
<script src="../scripts/bundled/<?=$browser?>/<?=$adapter?>.history.js"></script>
<!-- Tests -->
<script src="tests.js"></script>
</body>
</html>

View File

@ -1,23 +0,0 @@
<?php
# Header
require_once(dirname(__FILE__).'/_header.php');
# Index
ob_start();
require($dir.'/all.php');
$contents = ob_get_contents();
ob_end_clean();
file_put_contents($out.'/index.html', $contents);
# Each
foreach ( $browsers as $browser )
foreach ( $adapters as $adapter ) {
ob_start();
require($dir.'/each.php');
$contents = ob_get_contents();
ob_end_clean();
file_put_contents($out."/${url}", $contents);
}
# Done
?><html><body><a href="../tests">Tests</a></body></html>

View File

@ -1,13 +0,0 @@
Options +FollowSymlinks
RewriteEngine On
# Clean Adapter
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ([^\.]+)$ $1.html [NC,L,QSA]
# Can someone smarter than me make it so:
# http://localhost/history.js/tests/uncompressed-html5-persistant-jquery
# Does not redirect to:
# http://localhost/history.js/tests/uncompressed-html5-persistant-jquery.html
# But still accesses that url

View File

@ -1,43 +0,0 @@
<!DOCTYPE html>
<html debug="true">
<head>
<meta http-equiv="Expires" CONTENT="Mon, 06 Jan 1990 00:00:01 GMT" />
<meta http-equiv="PRAGMA" CONTENT="NO-CACHE" />
<meta http-equiv="CACHE-CONTROL" CONTENT="NO-CACHE" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<title>History.js HTML4+HTML5 Jquery Test Suite</title>
<!-- Check -->
<script>
var href = window.document.location.href,
test_url = href.replace(/(history\.js\/tests\/[^\/\?\#]+).*/,'$1');
if ( test_url !== href ) {
window.document.location.href = test_url;
}
</script>
<!-- Framework -->
<script src="../vendor/jquery.js"></script>
<!-- QUnit -->
<link rel="stylesheet" href="../vendor/qunit/qunit/qunit.css" type="text/css" media="screen">
<script src="../vendor/qunit/qunit/qunit.js"></script>
</head>
<body>
<!-- Elements -->
<h1 id="qunit-header">History.js HTML4+HTML5 Jquery Test Suite</h1>
<h2 id="qunit-banner"></h2>
<div id="qunit-testrunner-toolbar"></div>
<h2 id="qunit-userAgent"></h2>
<ol id="qunit-tests"></ol>
<div id="qunit-fixture">test markup</div>
<button onclick="history.back()">back</button><button onclick="history.forward()">forward</button>
<textarea id="log" style="width:100%;height:400px"></textarea>
<!-- History.js -->
<script src="../scripts/bundled/html4+html5/jquery.history.js"></script>
<!-- Tests -->
<script src="tests.js"></script>
</body>
</html>

View File

@ -1,43 +0,0 @@
<!DOCTYPE html>
<html debug="true">
<head>
<meta http-equiv="Expires" CONTENT="Mon, 06 Jan 1990 00:00:01 GMT" />
<meta http-equiv="PRAGMA" CONTENT="NO-CACHE" />
<meta http-equiv="CACHE-CONTROL" CONTENT="NO-CACHE" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<title>History.js HTML4+HTML5 Mootools Test Suite</title>
<!-- Check -->
<script>
var href = window.document.location.href,
test_url = href.replace(/(history\.js\/tests\/[^\/\?\#]+).*/,'$1');
if ( test_url !== href ) {
window.document.location.href = test_url;
}
</script>
<!-- Framework -->
<script src="../vendor/mootools.js"></script>
<!-- QUnit -->
<link rel="stylesheet" href="../vendor/qunit/qunit/qunit.css" type="text/css" media="screen">
<script src="../vendor/qunit/qunit/qunit.js"></script>
</head>
<body>
<!-- Elements -->
<h1 id="qunit-header">History.js HTML4+HTML5 Mootools Test Suite</h1>
<h2 id="qunit-banner"></h2>
<div id="qunit-testrunner-toolbar"></div>
<h2 id="qunit-userAgent"></h2>
<ol id="qunit-tests"></ol>
<div id="qunit-fixture">test markup</div>
<button onclick="history.back()">back</button><button onclick="history.forward()">forward</button>
<textarea id="log" style="width:100%;height:400px"></textarea>
<!-- History.js -->
<script src="../scripts/bundled/html4+html5/mootools.history.js"></script>
<!-- Tests -->
<script src="tests.js"></script>
</body>
</html>

View File

@ -1,43 +0,0 @@
<!DOCTYPE html>
<html debug="true">
<head>
<meta http-equiv="Expires" CONTENT="Mon, 06 Jan 1990 00:00:01 GMT" />
<meta http-equiv="PRAGMA" CONTENT="NO-CACHE" />
<meta http-equiv="CACHE-CONTROL" CONTENT="NO-CACHE" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<title>History.js HTML4+HTML5 Native Test Suite</title>
<!-- Check -->
<script>
var href = window.document.location.href,
test_url = href.replace(/(history\.js\/tests\/[^\/\?\#]+).*/,'$1');
if ( test_url !== href ) {
window.document.location.href = test_url;
}
</script>
<!-- Framework -->
<script src="../vendor/native.js"></script>
<!-- QUnit -->
<link rel="stylesheet" href="../vendor/qunit/qunit/qunit.css" type="text/css" media="screen">
<script src="../vendor/qunit/qunit/qunit.js"></script>
</head>
<body>
<!-- Elements -->
<h1 id="qunit-header">History.js HTML4+HTML5 Native Test Suite</h1>
<h2 id="qunit-banner"></h2>
<div id="qunit-testrunner-toolbar"></div>
<h2 id="qunit-userAgent"></h2>
<ol id="qunit-tests"></ol>
<div id="qunit-fixture">test markup</div>
<button onclick="history.back()">back</button><button onclick="history.forward()">forward</button>
<textarea id="log" style="width:100%;height:400px"></textarea>
<!-- History.js -->
<script src="../scripts/bundled/html4+html5/native.history.js"></script>
<!-- Tests -->
<script src="tests.js"></script>
</body>
</html>

View File

@ -1,43 +0,0 @@
<!DOCTYPE html>
<html debug="true">
<head>
<meta http-equiv="Expires" CONTENT="Mon, 06 Jan 1990 00:00:01 GMT" />
<meta http-equiv="PRAGMA" CONTENT="NO-CACHE" />
<meta http-equiv="CACHE-CONTROL" CONTENT="NO-CACHE" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<title>History.js HTML4+HTML5 Right Test Suite</title>
<!-- Check -->
<script>
var href = window.document.location.href,
test_url = href.replace(/(history\.js\/tests\/[^\/\?\#]+).*/,'$1');
if ( test_url !== href ) {
window.document.location.href = test_url;
}
</script>
<!-- Framework -->
<script src="../vendor/right.js"></script>
<!-- QUnit -->
<link rel="stylesheet" href="../vendor/qunit/qunit/qunit.css" type="text/css" media="screen">
<script src="../vendor/qunit/qunit/qunit.js"></script>
</head>
<body>
<!-- Elements -->
<h1 id="qunit-header">History.js HTML4+HTML5 Right Test Suite</h1>
<h2 id="qunit-banner"></h2>
<div id="qunit-testrunner-toolbar"></div>
<h2 id="qunit-userAgent"></h2>
<ol id="qunit-tests"></ol>
<div id="qunit-fixture">test markup</div>
<button onclick="history.back()">back</button><button onclick="history.forward()">forward</button>
<textarea id="log" style="width:100%;height:400px"></textarea>
<!-- History.js -->
<script src="../scripts/bundled/html4+html5/right.history.js"></script>
<!-- Tests -->
<script src="tests.js"></script>
</body>
</html>

View File

@ -1,43 +0,0 @@
<!DOCTYPE html>
<html debug="true">
<head>
<meta http-equiv="Expires" CONTENT="Mon, 06 Jan 1990 00:00:01 GMT" />
<meta http-equiv="PRAGMA" CONTENT="NO-CACHE" />
<meta http-equiv="CACHE-CONTROL" CONTENT="NO-CACHE" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<title>History.js HTML4+HTML5 Zepto Test Suite</title>
<!-- Check -->
<script>
var href = window.document.location.href,
test_url = href.replace(/(history\.js\/tests\/[^\/\?\#]+).*/,'$1');
if ( test_url !== href ) {
window.document.location.href = test_url;
}
</script>
<!-- Framework -->
<script src="../vendor/zepto.js"></script>
<!-- QUnit -->
<link rel="stylesheet" href="../vendor/qunit/qunit/qunit.css" type="text/css" media="screen">
<script src="../vendor/qunit/qunit/qunit.js"></script>
</head>
<body>
<!-- Elements -->
<h1 id="qunit-header">History.js HTML4+HTML5 Zepto Test Suite</h1>
<h2 id="qunit-banner"></h2>
<div id="qunit-testrunner-toolbar"></div>
<h2 id="qunit-userAgent"></h2>
<ol id="qunit-tests"></ol>
<div id="qunit-fixture">test markup</div>
<button onclick="history.back()">back</button><button onclick="history.forward()">forward</button>
<textarea id="log" style="width:100%;height:400px"></textarea>
<!-- History.js -->
<script src="../scripts/bundled/html4+html5/zepto.history.js"></script>
<!-- Tests -->
<script src="tests.js"></script>
</body>
</html>

View File

@ -1,43 +0,0 @@
<!DOCTYPE html>
<html debug="true">
<head>
<meta http-equiv="Expires" CONTENT="Mon, 06 Jan 1990 00:00:01 GMT" />
<meta http-equiv="PRAGMA" CONTENT="NO-CACHE" />
<meta http-equiv="CACHE-CONTROL" CONTENT="NO-CACHE" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<title>History.js HTML5 Jquery Test Suite</title>
<!-- Check -->
<script>
var href = window.document.location.href,
test_url = href.replace(/(history\.js\/tests\/[^\/\?\#]+).*/,'$1');
if ( test_url !== href ) {
window.document.location.href = test_url;
}
</script>
<!-- Framework -->
<script src="../vendor/jquery.js"></script>
<!-- QUnit -->
<link rel="stylesheet" href="../vendor/qunit/qunit/qunit.css" type="text/css" media="screen">
<script src="../vendor/qunit/qunit/qunit.js"></script>
</head>
<body>
<!-- Elements -->
<h1 id="qunit-header">History.js HTML5 Jquery Test Suite</h1>
<h2 id="qunit-banner"></h2>
<div id="qunit-testrunner-toolbar"></div>
<h2 id="qunit-userAgent"></h2>
<ol id="qunit-tests"></ol>
<div id="qunit-fixture">test markup</div>
<button onclick="history.back()">back</button><button onclick="history.forward()">forward</button>
<textarea id="log" style="width:100%;height:400px"></textarea>
<!-- History.js -->
<script src="../scripts/bundled/html5/jquery.history.js"></script>
<!-- Tests -->
<script src="tests.js"></script>
</body>
</html>

View File

@ -1,43 +0,0 @@
<!DOCTYPE html>
<html debug="true">
<head>
<meta http-equiv="Expires" CONTENT="Mon, 06 Jan 1990 00:00:01 GMT" />
<meta http-equiv="PRAGMA" CONTENT="NO-CACHE" />
<meta http-equiv="CACHE-CONTROL" CONTENT="NO-CACHE" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<title>History.js HTML5 Mootools Test Suite</title>
<!-- Check -->
<script>
var href = window.document.location.href,
test_url = href.replace(/(history\.js\/tests\/[^\/\?\#]+).*/,'$1');
if ( test_url !== href ) {
window.document.location.href = test_url;
}
</script>
<!-- Framework -->
<script src="../vendor/mootools.js"></script>
<!-- QUnit -->
<link rel="stylesheet" href="../vendor/qunit/qunit/qunit.css" type="text/css" media="screen">
<script src="../vendor/qunit/qunit/qunit.js"></script>
</head>
<body>
<!-- Elements -->
<h1 id="qunit-header">History.js HTML5 Mootools Test Suite</h1>
<h2 id="qunit-banner"></h2>
<div id="qunit-testrunner-toolbar"></div>
<h2 id="qunit-userAgent"></h2>
<ol id="qunit-tests"></ol>
<div id="qunit-fixture">test markup</div>
<button onclick="history.back()">back</button><button onclick="history.forward()">forward</button>
<textarea id="log" style="width:100%;height:400px"></textarea>
<!-- History.js -->
<script src="../scripts/bundled/html5/mootools.history.js"></script>
<!-- Tests -->
<script src="tests.js"></script>
</body>
</html>

View File

@ -1,43 +0,0 @@
<!DOCTYPE html>
<html debug="true">
<head>
<meta http-equiv="Expires" CONTENT="Mon, 06 Jan 1990 00:00:01 GMT" />
<meta http-equiv="PRAGMA" CONTENT="NO-CACHE" />
<meta http-equiv="CACHE-CONTROL" CONTENT="NO-CACHE" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<title>History.js HTML5 Native Test Suite</title>
<!-- Check -->
<script>
var href = window.document.location.href,
test_url = href.replace(/(history\.js\/tests\/[^\/\?\#]+).*/,'$1');
if ( test_url !== href ) {
window.document.location.href = test_url;
}
</script>
<!-- Framework -->
<script src="../vendor/native.js"></script>
<!-- QUnit -->
<link rel="stylesheet" href="../vendor/qunit/qunit/qunit.css" type="text/css" media="screen">
<script src="../vendor/qunit/qunit/qunit.js"></script>
</head>
<body>
<!-- Elements -->
<h1 id="qunit-header">History.js HTML5 Native Test Suite</h1>
<h2 id="qunit-banner"></h2>
<div id="qunit-testrunner-toolbar"></div>
<h2 id="qunit-userAgent"></h2>
<ol id="qunit-tests"></ol>
<div id="qunit-fixture">test markup</div>
<button onclick="history.back()">back</button><button onclick="history.forward()">forward</button>
<textarea id="log" style="width:100%;height:400px"></textarea>
<!-- History.js -->
<script src="../scripts/bundled/html5/native.history.js"></script>
<!-- Tests -->
<script src="tests.js"></script>
</body>
</html>

View File

@ -1,43 +0,0 @@
<!DOCTYPE html>
<html debug="true">
<head>
<meta http-equiv="Expires" CONTENT="Mon, 06 Jan 1990 00:00:01 GMT" />
<meta http-equiv="PRAGMA" CONTENT="NO-CACHE" />
<meta http-equiv="CACHE-CONTROL" CONTENT="NO-CACHE" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<title>History.js HTML5 Right Test Suite</title>
<!-- Check -->
<script>
var href = window.document.location.href,
test_url = href.replace(/(history\.js\/tests\/[^\/\?\#]+).*/,'$1');
if ( test_url !== href ) {
window.document.location.href = test_url;
}
</script>
<!-- Framework -->
<script src="../vendor/right.js"></script>
<!-- QUnit -->
<link rel="stylesheet" href="../vendor/qunit/qunit/qunit.css" type="text/css" media="screen">
<script src="../vendor/qunit/qunit/qunit.js"></script>
</head>
<body>
<!-- Elements -->
<h1 id="qunit-header">History.js HTML5 Right Test Suite</h1>
<h2 id="qunit-banner"></h2>
<div id="qunit-testrunner-toolbar"></div>
<h2 id="qunit-userAgent"></h2>
<ol id="qunit-tests"></ol>
<div id="qunit-fixture">test markup</div>
<button onclick="history.back()">back</button><button onclick="history.forward()">forward</button>
<textarea id="log" style="width:100%;height:400px"></textarea>
<!-- History.js -->
<script src="../scripts/bundled/html5/right.history.js"></script>
<!-- Tests -->
<script src="tests.js"></script>
</body>
</html>

View File

@ -1,43 +0,0 @@
<!DOCTYPE html>
<html debug="true">
<head>
<meta http-equiv="Expires" CONTENT="Mon, 06 Jan 1990 00:00:01 GMT" />
<meta http-equiv="PRAGMA" CONTENT="NO-CACHE" />
<meta http-equiv="CACHE-CONTROL" CONTENT="NO-CACHE" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<title>History.js HTML5 Zepto Test Suite</title>
<!-- Check -->
<script>
var href = window.document.location.href,
test_url = href.replace(/(history\.js\/tests\/[^\/\?\#]+).*/,'$1');
if ( test_url !== href ) {
window.document.location.href = test_url;
}
</script>
<!-- Framework -->
<script src="../vendor/zepto.js"></script>
<!-- QUnit -->
<link rel="stylesheet" href="../vendor/qunit/qunit/qunit.css" type="text/css" media="screen">
<script src="../vendor/qunit/qunit/qunit.js"></script>
</head>
<body>
<!-- Elements -->
<h1 id="qunit-header">History.js HTML5 Zepto Test Suite</h1>
<h2 id="qunit-banner"></h2>
<div id="qunit-testrunner-toolbar"></div>
<h2 id="qunit-userAgent"></h2>
<ol id="qunit-tests"></ol>
<div id="qunit-fixture">test markup</div>
<button onclick="history.back()">back</button><button onclick="history.forward()">forward</button>
<textarea id="log" style="width:100%;height:400px"></textarea>
<!-- History.js -->
<script src="../scripts/bundled/html5/zepto.history.js"></script>
<!-- Tests -->
<script src="tests.js"></script>
</body>
</html>

View File

@ -1,3 +0,0 @@
<?php
header('Content-type: image/jpeg');
sleep(10);

View File

@ -1,25 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<title>History.js Test Suite</title>
<style type="text/css">
body,html,iframe {
padding:0;
margin:0;
outline:none;
border:none;
}
.browser {
padding-top:1em;
}
.adapter {
padding-top:1em;
}
</style>
</head>
<body>
<h1>History.js Test Suite</h1>
<p>HTML5 Browsers must pass the HTML4+HTML5 tests</p>
<p>HTML4 Browsers must pass the HTML4 tests and should fail the HTML5 tests</p>
<div class="browser"><div class="adapter"><a href="html4+html5.jquery.html">History.js Html4+html5 Jquery Test Suite</a></div><div class="adapter"><a href="html4+html5.mootools.html">History.js Html4+html5 Mootools Test Suite</a></div><div class="adapter"><a href="html4+html5.native.html">History.js Html4+html5 Native Test Suite</a></div><div class="adapter"><a href="html4+html5.right.html">History.js Html4+html5 Right Test Suite</a></div><div class="adapter"><a href="html4+html5.zepto.html">History.js Html4+html5 Zepto Test Suite</a></div></div><div class="browser"><div class="adapter"><a href="html5.jquery.html">History.js Html5 Jquery Test Suite</a></div><div class="adapter"><a href="html5.mootools.html">History.js Html5 Mootools Test Suite</a></div><div class="adapter"><a href="html5.native.html">History.js Html5 Native Test Suite</a></div><div class="adapter"><a href="html5.right.html">History.js Html5 Right Test Suite</a></div><div class="adapter"><a href="html5.zepto.html">History.js Html5 Zepto Test Suite</a></div></div></body>
</html>

View File

@ -1,254 +0,0 @@
(function(){
var
History = window.History,
document = window.document,
test = window.test,
same = window.same;
// Check
if ( !History.enabled ) {
throw new Error('History.js is disabled');
}
// Prepare
History.options.debug = false;
// Variables
var
States = {
// Home
0: {
'url': document.location.href.replace(/#.*$/,''),
'title': ''
},
// One
1: {
'data': {
'state': 1,
'rand': Math.random()
},
'title': 'State 1',
'url': '?state=1'
},
// Two
2: {
'data': {
'state': 2,
'rand': Math.random()
},
'title': 'State 2',
'url': '?state=2&asd=%20asd%2520asd'
},
// Three
3: {
'url': '?state=3'
},
// Four
4: {
'data': {
'state': 4,
'trick': true,
'rand': Math.random()
},
'title': 'State 4',
'url': '?state=3'
},
// Log
5: {
'url': '?state=1#log'
},
// Six
6: {
'data': {
'state': 6,
'rand': Math.random()
},
'url': 'six.html'
},
// Seven
7: {
'url': 'seven'
},
// Eight
8: {
'url': '/eight'
}
},
stateOrder = [0,1,2,3,4,3,1,0,1,3,4,3,1,0,6,7,8,1,8,7,6,0],
currentTest = 0;
// Original Title
var title = document.title;
var banner;
var checkStatus = function(){
banner = banner || document.getElementById('qunit-banner');
var status = banner.className !== 'qunit-fail';
return status;
};
// Check State
var checkState = function(){
if ( !checkStatus() ) {
throw new Error('A test has failed');
}
var
stateIndex = stateOrder[currentTest],
expectedState = History.normalizeState(States[stateIndex]),
actualState = History.getState(false);
++currentTest;
document.title = title+': '+actualState.url;
var
testName = 'Test '+currentTest,
stateName = 'State '+stateIndex;
test(testName,function(){
History.log('Completed: '+testName +' / '+ stateName);
same(actualState,expectedState,stateName);
});
// Image Load to Stress Test Safari and Opera
(new Image()).src = "image.php";
};
// Check the Initial State
checkState();
// State Change
History.Adapter.bind(window,'statechange',checkState);
// Log
var addLog = function(){
var args = arguments;
History.queue(function(){
History.log.apply(History,args);
});
};
// Dom Load
History.Adapter.onDomLoad(function(){
setTimeout(function(){
// ----------------------------------------------------------------------
// Test State Functionality: Adding
// Test 2 / State 1 (0 -> 1)
// Tests HTML4 -> HTML5 Graceful Upgrade
addLog('Test 2',History.queues.length,History.busy.flag);
History.setHash(History.getHashByState(States[1]));
// Test 3 / State 2 (1 -> 2)
addLog('Test 3',History.queues.length,History.busy.flag);
History.pushState(States[2].data, States[2].title, States[2].url);
// Test 3-2 / State 2 (2 -> 2) / No Change
addLog('Test 3-2',History.queues.length,History.busy.flag);
History.pushState(States[2].data, States[2].title, States[2].url);
// Test 3-3 / State 2 (2 -> 2) / No Change
addLog('Test 3-3',History.queues.length,History.busy.flag);
History.replaceState(States[2].data, States[2].title, States[2].url);
// Test 4 / State 3 (2 -> 3)
addLog('Test 4',History.queues.length,History.busy.flag);
History.replaceState(States[3].data, States[3].title, States[3].url);
// Test 5 / State 4 (3 -> 4)
addLog('Test 5',History.queues.length,History.busy.flag);
History.pushState(States[4].data, States[4].title, States[4].url);
// ----------------------------------------------------------------------
// Test State Functionality: Traversing
// Test 6 / State 3 (4 -> 3)
// Test 7 / State 1 (3 -> 2 -> 1)
addLog('Test 6,7',History.queues.length,History.busy.flag);
History.go(-2);
// Test 8 / State 0 (1 -> 0)
// Tests Default State
addLog('Test 8',History.queues.length,History.busy.flag);
History.back();
// Test 9 / State 1 (0 -> 1)
// Test 10 / State 3 (1 -> 2 -> 3)
addLog('Test 9,10',History.queues.length,History.busy.flag);
History.go(2);
// Test 11 / State 4 (3 -> 4)
addLog('Test 11',History.queues.length,History.busy.flag);
History.forward();
// Test 12 / State 3 (4 -> 3)
addLog('Test 12',History.queues.length,History.busy.flag);
History.back();
// Test 13 / State 1 (3 -> 2 -> 1)
addLog('Test 13',History.queues.length,History.busy.flag);
History.back();
// ----------------------------------------------------------------------
// Test State Functionality: Traditional Anchors
// Test 13-2 / State 1 (1 -> #log) / No Change
addLog('Test 13-2',History.queues.length,History.busy.flag);
History.setHash('log');
// Test 13-3 / State 1 (#log -> 1) / No Change
addLog('Test 13-3',History.queues.length,History.busy.flag);
History.back();
// Test 14 / State 0 (1 -> 0)
addLog('Test 14',History.queues.length,History.busy.flag);
History.back();
// ----------------------------------------------------------------------
// Test URL Handling: Adding
// Test 15 / State 6 (1 -> 6)
// Also tests data with no title
addLog('Test 15',History.queues.length,History.busy.flag);
History.pushState(States[6].data, States[6].title, States[6].url);
// Test 16 / State 7 (6 -> 7)
addLog('Test 16',History.queues.length,History.busy.flag);
History.pushState(States[7].data, States[7].title, States[7].url);
// Test 17 / State 7 (7 -> 8)
addLog('Test 17',History.queues.length,History.busy.flag);
History.pushState(States[8].data, States[8].title, States[8].url);
// Test 18 / State 1 (8 -> 1)
// Should be /eight?state=1
addLog('Test 18',History.queues.length,History.busy.flag);
History.pushState(States[1].data, States[1].title, States[1].url);
// ----------------------------------------------------------------------
// Test URL Handling: Traversing
// Test 19 / State 8 (1 -> 8)
addLog('Test 19',History.queues.length,History.busy.flag);
History.back();
// Test 20 / State 7 (8 -> 7)
addLog('Test 20',History.queues.length,History.busy.flag);
History.back();
// Test 21 / State 6 (7 -> 6)
addLog('Test 21',History.queues.length,History.busy.flag);
History.back();
// Test 22 / State 0 (6 -> 0)
addLog('Test 22',History.queues.length,History.busy.flag);
History.back();
},1000); // wait for test one to complete
});
})();

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +0,0 @@
.project
*~
*.diff
*.patch
.DS_Store

View File

@ -1,27 +0,0 @@
[QUnit](http://docs.jquery.com/QUnit) - A JavaScript Unit Testing framework.
================================
QUnit is a powerful, easy-to-use, JavaScript test suite. It's used by the jQuery
project to test its code and plugins but is capable of testing any generic
JavaScript code (and even capable of testing JavaScript code on the server-side).
QUnit is especially useful for regression testing: Whenever a bug is reported,
write a test that asserts the existence of that particular bug. Then fix it and
commit both. Every time you work on the code again, run the tests. If the bug
comes up again - a regression - you'll spot it immediately and know how to fix
it, because you know what code you just changed.
Having good unit test coverage makes safe refactoring easy and cheap. You can
run the tests after each small refactoring step and always know what change
broke something.
QUnit is similar to other unit testing frameworks like JUnit, but makes use of
the features JavaScript provides and helps with testing code in the browser, eg.
with it's stop/start facilities for testing asynchronous code.
If you are interested in helping developing QUnit, you are in the right place.
For related discussions, visit the
[QUnit and Testing forum](http://forum.jquery.com/qunit-and-testing).
Planning for a qunitjs.com site and other testing tools related work now happens
on the [jQuery Testing Team planning wiki](http://jquerytesting.pbworks.com/w/page/41556026/FrontPage).

View File

@ -1,21 +0,0 @@
{
"name": "qunit",
"author": {
"name": "John Resig",
"email": "jeresig@gmail.com",
"url": "http://ejohn.org/"
},
"maintainer": {
"name": "Jörn Zaefferer",
"email": "joern.zaefferer@googlemail.com",
"url": "http://bassistance.de/"
},
"url": "http://docs.jquery.com/QUnit",
"license": {
"name": "MIT",
"url": "http://www.opensource.org/licenses/mit-license.php"
},
"description": "An easy-to-use JavaScript Unit Testing framework.",
"keywords": [ "testing", "unit", "jquery" ],
"lib": "qunit"
}

View File

@ -1,225 +0,0 @@
/**
* QUnit - A JavaScript Unit Testing Framework
*
* http://docs.jquery.com/QUnit
*
* Copyright (c) 2011 John Resig, Jörn Zaefferer
* Dual licensed under the MIT (MIT-LICENSE.txt)
* or GPL (GPL-LICENSE.txt) licenses.
*/
/** Font Family and Sizes */
#qunit-tests, #qunit-header, #qunit-banner, #qunit-testrunner-toolbar, #qunit-userAgent, #qunit-testresult {
font-family: "Helvetica Neue Light", "HelveticaNeue-Light", "Helvetica Neue", Calibri, Helvetica, Arial, sans-serif;
}
#qunit-testrunner-toolbar, #qunit-userAgent, #qunit-testresult, #qunit-tests li { font-size: small; }
#qunit-tests { font-size: smaller; }
/** Resets */
#qunit-tests, #qunit-tests ol, #qunit-header, #qunit-banner, #qunit-userAgent, #qunit-testresult {
margin: 0;
padding: 0;
}
/** Header */
#qunit-header {
padding: 0.5em 0 0.5em 1em;
color: #8699a4;
background-color: #0d3349;
font-size: 1.5em;
line-height: 1em;
font-weight: normal;
border-radius: 15px 15px 0 0;
-moz-border-radius: 15px 15px 0 0;
-webkit-border-top-right-radius: 15px;
-webkit-border-top-left-radius: 15px;
}
#qunit-header a {
text-decoration: none;
color: #c2ccd1;
}
#qunit-header a:hover,
#qunit-header a:focus {
color: #fff;
}
#qunit-banner {
height: 5px;
}
#qunit-testrunner-toolbar {
padding: 0.5em 0 0.5em 2em;
color: #5E740B;
background-color: #eee;
}
#qunit-userAgent {
padding: 0.5em 0 0.5em 2.5em;
background-color: #2b81af;
color: #fff;
text-shadow: rgba(0, 0, 0, 0.5) 2px 2px 1px;
}
/** Tests: Pass/Fail */
#qunit-tests {
list-style-position: inside;
}
#qunit-tests li {
padding: 0.4em 0.5em 0.4em 2.5em;
border-bottom: 1px solid #fff;
list-style-position: inside;
}
#qunit-tests.hidepass li.pass, #qunit-tests.hidepass li.running {
display: none;
}
#qunit-tests li strong {
cursor: pointer;
}
#qunit-tests li a {
padding: 0.5em;
color: #c2ccd1;
text-decoration: none;
}
#qunit-tests li a:hover,
#qunit-tests li a:focus {
color: #000;
}
#qunit-tests ol {
margin-top: 0.5em;
padding: 0.5em;
background-color: #fff;
border-radius: 15px;
-moz-border-radius: 15px;
-webkit-border-radius: 15px;
box-shadow: inset 0px 2px 13px #999;
-moz-box-shadow: inset 0px 2px 13px #999;
-webkit-box-shadow: inset 0px 2px 13px #999;
}
#qunit-tests table {
border-collapse: collapse;
margin-top: .2em;
}
#qunit-tests th {
text-align: right;
vertical-align: top;
padding: 0 .5em 0 0;
}
#qunit-tests td {
vertical-align: top;
}
#qunit-tests pre {
margin: 0;
white-space: pre-wrap;
word-wrap: break-word;
}
#qunit-tests del {
background-color: #e0f2be;
color: #374e0c;
text-decoration: none;
}
#qunit-tests ins {
background-color: #ffcaca;
color: #500;
text-decoration: none;
}
/*** Test Counts */
#qunit-tests b.counts { color: black; }
#qunit-tests b.passed { color: #5E740B; }
#qunit-tests b.failed { color: #710909; }
#qunit-tests li li {
margin: 0.5em;
padding: 0.4em 0.5em 0.4em 0.5em;
background-color: #fff;
border-bottom: none;
list-style-position: inside;
}
/*** Passing Styles */
#qunit-tests li li.pass {
color: #5E740B;
background-color: #fff;
border-left: 26px solid #C6E746;
}
#qunit-tests .pass { color: #528CE0; background-color: #D2E0E6; }
#qunit-tests .pass .test-name { color: #366097; }
#qunit-tests .pass .test-actual,
#qunit-tests .pass .test-expected { color: #999999; }
#qunit-banner.qunit-pass { background-color: #C6E746; }
/*** Failing Styles */
#qunit-tests li li.fail {
color: #710909;
background-color: #fff;
border-left: 26px solid #EE5757;
}
#qunit-tests > li:last-child {
border-radius: 0 0 15px 15px;
-moz-border-radius: 0 0 15px 15px;
-webkit-border-bottom-right-radius: 15px;
-webkit-border-bottom-left-radius: 15px;
}
#qunit-tests .fail { color: #000000; background-color: #EE5757; }
#qunit-tests .fail .test-name,
#qunit-tests .fail .module-name { color: #000000; }
#qunit-tests .fail .test-actual { color: #EE5757; }
#qunit-tests .fail .test-expected { color: green; }
#qunit-banner.qunit-fail { background-color: #EE5757; }
/** Result */
#qunit-testresult {
padding: 0.5em 0.5em 0.5em 2.5em;
color: #2b81af;
background-color: #D2E0E6;
border-bottom: 1px solid white;
}
/** Fixture */
#qunit-fixture {
position: absolute;
top: -10000px;
left: -10000px;
}

File diff suppressed because it is too large Load Diff

View File

@ -1,24 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<title>QUnit Test Suite</title>
<link rel="stylesheet" href="../qunit/qunit.css" type="text/css" media="screen">
<script type="text/javascript" src="../qunit/qunit.js"></script>
<script type="text/javascript" src="test.js"></script>
<script type="text/javascript" src="same.js"></script>
<script>
var logs = ["begin", "testStart", "testDone", "log", "moduleStart", "moduleDone", "done"];
for (var i = 0; i < logs.length; i++) {
(function() {
var log = logs[i];
QUnit[log] = function() {
console.log(log, arguments);
};
})();
}
</script>
</head>
<body>
<div id="qunit-fixture">test markup</div>
</body>
</html>

View File

@ -1,19 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>QUnit Test Suite</title>
<link rel="stylesheet" href="../qunit/qunit.css" type="text/css" media="screen">
<script type="text/javascript" src="../qunit/qunit.js"></script>
<script type="text/javascript" src="test.js"></script>
<script type="text/javascript" src="same.js"></script>
</head>
<body>
<h1 id="qunit-header">QUnit Test Suite</h1>
<h2 id="qunit-banner"></h2>
<div id="qunit-testrunner-toolbar"></div>
<h2 id="qunit-userAgent"></h2>
<ol id="qunit-tests"></ol>
<div id="qunit-fixture">test markup</div>
</body>
</html>

View File

@ -1,17 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<title>QUnit Test Suite</title>
<link rel="stylesheet" href="../qunit/qunit.css" type="text/css" media="screen">
<script type="text/javascript" src="../qunit/qunit.js"></script>
<script type="text/javascript" src="logs.js"></script>
</head>
<body>
<h1 id="qunit-header">QUnit Test Suite</h1>
<h2 id="qunit-banner"></h2>
<div id="qunit-testrunner-toolbar"></div>
<h2 id="qunit-userAgent"></h2>
<ol id="qunit-tests"></ol>
<div id="qunit-fixture">test markup</div>
</body>
</html>

View File

@ -1,150 +0,0 @@
// TODO disable reordering for this suite!
var begin = 0,
moduleStart = 0,
moduleDone = 0,
testStart = 0,
testDone = 0,
log = 0,
moduleContext,
moduleDoneContext,
testContext,
testDoneContext,
logContext;
QUnit.begin = function() {
begin++;
};
QUnit.done = function() {
};
QUnit.moduleStart = function(context) {
moduleStart++;
moduleContext = context;
};
QUnit.moduleDone = function(context) {
moduleDone++;
moduleDoneContext = context;
};
QUnit.testStart = function(context) {
testStart++;
testContext = context;
};
QUnit.testDone = function(context) {
testDone++;
testDoneContext = context;
};
QUnit.log = function(context) {
log++;
logContext = context;
};
var logs = ["begin", "testStart", "testDone", "log", "moduleStart", "moduleDone", "done"];
for (var i = 0; i < logs.length; i++) {
(function() {
var log = logs[i],
logger = QUnit[log];
QUnit[log] = function() {
console.log(log, arguments);
logger.apply(this, arguments);
};
})();
}
module("logs1");
test("test1", 13, function() {
equal(begin, 1);
equal(moduleStart, 1);
equal(testStart, 1);
equal(testDone, 0);
equal(moduleDone, 0);
deepEqual(logContext, {
result: true,
message: undefined,
actual: 0,
expected: 0
});
equal("foo", "foo", "msg");
deepEqual(logContext, {
result: true,
message: "msg",
actual: "foo",
expected: "foo"
});
strictEqual(testDoneContext, undefined);
deepEqual(testContext, {
name: "test1"
});
strictEqual(moduleDoneContext, undefined);
deepEqual(moduleContext, {
name: "logs1"
});
equal(log, 12);
});
test("test2", 10, function() {
equal(begin, 1);
equal(moduleStart, 1);
equal(testStart, 2);
equal(testDone, 1);
equal(moduleDone, 0);
deepEqual(testDoneContext, {
name: "test1",
failed: 0,
passed: 13,
total: 13
});
deepEqual(testContext, {
name: "test2"
});
strictEqual(moduleDoneContext, undefined);
deepEqual(moduleContext, {
name: "logs1"
});
equal(log, 22);
});
module("logs2");
test("test1", 9, function() {
equal(begin, 1);
equal(moduleStart, 2);
equal(testStart, 3);
equal(testDone, 2);
equal(moduleDone, 1);
deepEqual(testContext, {
name: "test1"
});
deepEqual(moduleDoneContext, {
name: "logs1",
failed: 0,
passed: 23,
total: 23
});
deepEqual(moduleContext, {
name: "logs2"
});
equal(log, 31);
});
test("test2", 8, function() {
equal(begin, 1);
equal(moduleStart, 2);
equal(testStart, 4);
equal(testDone, 3);
equal(moduleDone, 1);
deepEqual(testContext, {
name: "test2"
});
deepEqual(moduleContext, {
name: "logs2"
});
equal(log, 39);
});

File diff suppressed because it is too large Load Diff

View File

@ -1,324 +0,0 @@
test("module without setup/teardown (default)", function() {
expect(1);
ok(true);
});
test("expect in test", 3, function() {
ok(true);
ok(true);
ok(true);
});
test("expect in test", 1, function() {
ok(true);
});
module("setup test", {
setup: function() {
ok(true);
}
});
test("module with setup", function() {
expect(2);
ok(true);
});
test("module with setup, expect in test call", 2, function() {
ok(true);
});
var state;
module("setup/teardown test", {
setup: function() {
state = true;
ok(true);
},
teardown: function() {
ok(true);
}
});
test("module with setup/teardown", function() {
expect(3);
ok(true);
});
module("setup/teardown test 2");
test("module without setup/teardown", function() {
expect(1);
ok(true);
});
if (typeof setTimeout !== 'undefined') {
state = 'fail';
module("teardown and stop", {
teardown: function() {
equal(state, "done", "Test teardown.");
}
});
test("teardown must be called after test ended", function() {
expect(1);
stop();
setTimeout(function() {
state = "done";
start();
}, 13);
});
module("async setup test", {
setup: function() {
stop();
setTimeout(function(){
ok(true);
start();
}, 500);
}
});
asyncTest("module with async setup", function() {
expect(2);
ok(true);
start();
});
module("async teardown test", {
teardown: function() {
stop();
setTimeout(function(){
ok(true);
start();
}, 500);
}
});
asyncTest("module with async teardown", function() {
expect(2);
ok(true);
start();
});
module("asyncTest");
asyncTest("asyncTest", function() {
expect(2);
ok(true);
setTimeout(function() {
state = "done";
ok(true);
start();
}, 13);
});
asyncTest("asyncTest", 2, function() {
ok(true);
setTimeout(function() {
state = "done";
ok(true);
start();
}, 13);
});
test("sync", 2, function() {
stop();
setTimeout(function() {
ok(true);
start();
}, 13);
stop();
setTimeout(function() {
ok(true);
start();
}, 125);
});
}
module("save scope", {
setup: function() {
this.foo = "bar";
},
teardown: function() {
deepEqual(this.foo, "bar");
}
});
test("scope check", function() {
expect(2);
deepEqual(this.foo, "bar");
});
module("simple testEnvironment setup", {
foo: "bar",
bugid: "#5311" // example of meta-data
});
test("scope check", function() {
deepEqual(this.foo, "bar");
});
test("modify testEnvironment",function() {
this.foo="hamster";
});
test("testEnvironment reset for next test",function() {
deepEqual(this.foo, "bar");
});
module("testEnvironment with object", {
options:{
recipe:"soup",
ingredients:["hamster","onions"]
}
});
test("scope check", function() {
deepEqual(this.options, {recipe:"soup",ingredients:["hamster","onions"]}) ;
});
test("modify testEnvironment",function() {
// since we do a shallow copy, the testEnvironment can be modified
this.options.ingredients.push("carrots");
});
test("testEnvironment reset for next test",function() {
deepEqual(this.options, {recipe:"soup",ingredients:["hamster","onions","carrots"]}, "Is this a bug or a feature? Could do a deep copy") ;
});
module("testEnvironment tests");
function makeurl() {
var testEnv = QUnit.current_testEnvironment;
var url = testEnv.url || 'http://example.com/search';
var q = testEnv.q || 'a search test';
return url + '?q='+encodeURIComponent(q);
}
test("makeurl working",function() {
equal( QUnit.current_testEnvironment, this, 'The current testEnvironment is global');
equal( makeurl(), 'http://example.com/search?q=a%20search%20test', 'makeurl returns a default url if nothing specified in the testEnvironment');
});
module("testEnvironment with makeurl settings", {
url: 'http://google.com/',
q: 'another_search_test'
});
test("makeurl working with settings from testEnvironment", function() {
equal( makeurl(), 'http://google.com/?q=another_search_test', 'rather than passing arguments, we use test metadata to form the url');
});
test("each test can extend the module testEnvironment", {
q:'hamstersoup'
}, function() {
equal( makeurl(), 'http://google.com/?q=hamstersoup', 'url from module, q from test');
});
module("jsDump");
test("jsDump output", function() {
equals( QUnit.jsDump.parse([1, 2]), "[\n 1,\n 2\n]" );
equals( QUnit.jsDump.parse({top: 5, left: 0}), "{\n \"top\": 5,\n \"left\": 0\n}" );
if (typeof document !== 'undefined' && document.getElementById("qunit-header")) {
equals( QUnit.jsDump.parse(document.getElementById("qunit-header")), "<h1 id=\"qunit-header\"></h1>" );
equals( QUnit.jsDump.parse(document.getElementsByTagName("h1")), "[\n <h1 id=\"qunit-header\"></h1>\n]" );
}
});
module("assertions");
test("raises",function() {
function CustomError( message ) {
this.message = message;
}
CustomError.prototype.toString = function() {
return this.message;
};
raises(
function() {
throw "error"
}
);
raises(
function() {
throw "error"
},
'raises with just a message, no expected'
);
raises(
function() {
throw new CustomError();
},
CustomError,
'raised error is an instance of CustomError'
);
raises(
function() {
throw new CustomError("some error description");
},
/description/,
"raised error message contains 'description'"
);
raises(
function() {
throw new CustomError("some error description");
},
function( err ) {
if ( (err instanceof CustomError) && /description/.test(err) ) {
return true;
}
},
"custom validation function"
);
});
if (typeof document !== "undefined") {
module("fixture");
test("setup", function() {
document.getElementById("qunit-fixture").innerHTML = "foobar";
});
test("basics", function() {
equal( document.getElementById("qunit-fixture").innerHTML, "test markup", "automatically reset" );
});
}
module("custom assertions");
(function() {
function mod2(value, expected, message) {
var actual = value % 2;
QUnit.push(actual == expected, actual, expected, message);
}
test("mod2", function() {
mod2(2, 0, "2 % 2 == 0");
mod2(3, 1, "3 % 2 == 1");
})
})();
(function() {
var reset = QUnit.reset;
function afterTest() {
ok( false, "reset should not modify test status" );
}
module("reset");
test("reset runs assertions", function() {
QUnit.reset = function() {
afterTest();
reset.apply( this, arguments );
};
});
test("reset runs assertions2", function() {
QUnit.reset = reset;
});
})();
module("noglobals", {
teardown: function() {
delete window.badGlobalVariableIntroducedInTest;
}
});
test("let teardown clean up globals", function() {
// this test will always pass if run without ?noglobals=true
window.badGlobalVariableIntroducedInTest = true;
});

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long