librairies to bower

This commit is contained in:
sarah garcin 2015-05-06 15:05:01 +02:00
parent 1313e1f0e2
commit da4d135279
135 changed files with 247157 additions and 4 deletions

View File

@ -0,0 +1,23 @@
{
"name": "materiobasetheme",
"version": "1.0.0",
"authors": [
"sarah garcin <sarah@g-u-i.me>"
],
"license": "MIT",
"homepage": "http://materio.com",
"ignore": [
"**/.*",
"node_modules",
"bower_components",
"test",
"tests"
],
"dependencies": {
"foundation": "~5.5.1",
"history.js": "~1.8.0",
"jquery.columnizer": "~1.6.2",
"jquery.hotkeys": "jeresig/jquery.hotkeys#~0.2.0",
"jquery.lazyload": "~1.9.5"
}
}

View File

@ -0,0 +1,15 @@
{
"name": "history.js",
"version": "1.8.0",
"homepage": "https://github.com/browserstate/history.js",
"_release": "1.8.0",
"_resolution": {
"type": "version",
"tag": "1.8.0",
"commit": "6c6c8b951b03fa725adb11b1087d73b0b6f0ac82"
},
"_source": "git://github.com/browserstate/history.js.git",
"_target": "~1.8.0",
"_originalSource": "history.js",
"_direct": true
}

View File

@ -0,0 +1,4 @@
.build
/node_modules
/.idea
npm-debug.log

View File

@ -0,0 +1,141 @@
## History
- v1.8b2 - June 22 2013
- Introduced uncompressed bundled files #287
- Copied component.json to bower.json #291 and used right tag #286
- Fixed wrong argument passed to History.getHash() #305, #297, #292 (@Izkata)
- v1.8b1 - May 31 2013
- Fixed "encoded string automatically unencoded on html5 browsers" #282, #236, #272
- v1.8a4 - February 13 2013
- Fixed coffee script warnings (ExtJS & Dojo adapter, IE 6 iFrame)
- Updated qUnit to release 1.11.0, jQuery to release 1.9.1
- v1.8a3 - February 5 2013
- Added tests for Dojo and ExtJS
- Changed setting of title and url
- Testing status
- All HTML5 Native Adapter fail in all browsers on Test 10
- All other HTML5 tests work fine
- All other HTML4 tests fail in Test 4 (in IE)
- v1.8a2 - January 21 2013
- Fixed hashchange / statechange triggers: e.g. if a user in a HTML5 browser clicks a link, statechange is fired, in a HTML4 browser only hashchange, but state has also changed
- UTF8 / url encoding / decoding tested and so resolved: #64, #107, #108, #162, #177, #187, #205, #207, #210, #228, #251
- Fixed #244
- v1.8a1 - January 19 2013
- Pass options to `init()` as json is now supported
- Added unicode demo
- Introduced `getCurrentIndex()`, so you can get previous state by `History.getStateByIndex(getCurrentIndex()-1)`
- Fixed HTML4 endless loop when url starts with a slash (e.g. /welcome/hello) #239, #232, #185
- Bundled and compressed all scripts
- Responsed (and therefore solved) or old issues from balupton repository: #250, #242, #238, #234, #224, #213, #206, #195, #183, #181, #180, #179, #175, #168
- Fixed (or merged and therefore fixed) old issues from balupton repository: #248, #239, #236, #235, #229, #221, #220, #218, #215, #214, #212, #203, #191, #189, #172, #171, #166
- Feedback for UTF8 / url encode issues necessary, related problems (thanks to riyad)
- #64, #107, #108, #162, #177, #187, #205, #207, #210, #228
- v1.7.2 - January 18 2013
- Updated project README
- Integrated ExtJS Adapter (thanks to @seanadkinson!)
- Merged from forks
- added option to force no suid (@hrunting, @sbearcsiro)
- provide a consistent URI-encoded document.location.href (@hrunting, @sbearcsiro)
- Change History.getHash to return consistent hash, ala History.getLocationHref (@sbearcsiro)
- Fix an issue where HTML4 replaceState wasn't firing when SUIDs were disabled and the url didn't change (@sbearcsiro)
- Make extractId ignore the fragment if one is present (normally the hash is passed without an fragment) (@sbearcsiro)
- Remove all encoding / decoding of URLs except when creating or extracting a fragment, based on the assumption that all inputs to replaceState / pushState are appropriately encoded (@sbearcsiro)
- Change escapeHash/unescapeHash methods to use encodeURI/decodeURI instead of window.escape/unescape (@sbearcsiro)
- Fixed issue #158 (@sbearcsiro)
- isEmptyObject should use hasOwnProperty: prevents from always returning true if the Object.prototype is extended (@Alexander Johansson)
- Add potential fix for IE8 not returning full hashed url from getLocationHref when hash contains encoded characters (@sbearcsiro)
- Match current W3C popState event semantics for HTML4 (@STRML)
- Added History.options.html4Mode for easier debugging (@gigafied)
- Added History.options.delayInit (Boolean). (@gigafied)
- Added error testing and quota relief for sessionStorage.setItem (@jamie-pate)
- Fix IE 6 HTTPS warning (@Daniel15)
- Fixed bug in html4 pushState function which left History in a busy state (@joelarson4)
- Disable session storage if it's present but not working, thanks to @paulschreiber (@sbearcsiro)
- Add Lakin Wecker's dojo adapter (@sbearcsiro)
- Add dojo 1.8 tests (@sbearcsiro)
- Change dojo adapter to not use dojo events, it seems to break other parts of dojo (@sbearcsiro)
- Removes stray spaces so that the build script can run. (@billmag)
- fixed an issue in Safari's Private Browsing mode where setItem throws an exception (@billmag)
- Adds better error handling for the quota exceeded problem seen with the iPad. (@billmag)
- Consolidated var in sessionStorage to the top of the function. Re-build compressed and bundled. (@billmag)
- 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

@ -0,0 +1,292 @@
Welcome to History.js <br/> v1.8b2, June 22 2013
==================
[![Flattr this project](http://api.flattr.com/button/flattr-badge-large.png)](https://flattr.com/submit/auto?user_id=balupton&url=https://github.com/browserstate/history.js&title=History.js&language=&tags=github&category=software)
## News
- 22/06/2013: Beta 2 of v1.8 is released. Fixes and uncompressed bundled files.
- 31/05/2013: Beta 1 of v1.8 is released. Fixes.
- 14/02/2013: Alpha 4 of v1.8 is released. Fixes.
- 05/02/2013: Alpha 3 of v1.8 is released. Tests updated.
- 21/01/2013: Alpha 2 of v1.8 is released. Correct statechange behaviour.
- 19/01/2013: Alpha 1 of v1.8 is released. Started to categorize old balupton's issues.
### History
See the [`History.md`](https://github.com/browserstate/history.js/blob/master/History.md#files) file for a detailed list of features, changes, solved issues and bugs
### Involve
Please create an issue if something doesn't work or if there is a browser specific bug. I'll try to fix it as soon as possible. Please send me your Pull requests if you have a nice solution! I'm also going to review old issues in balupton's repository and try to solve them too.
## Aims
- 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/browserstate/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 [Dojo](http://dojotoolkit.org/), [ExtJS](http://www.sencha.com/), [jQuery](http://jquery.com/), [MooTools](http://mootools.net/), [Right.js](http://rightjs.org/) and [Zepto](http://zeptojs.com/).
## Usage
### Instant
To ajaxify your entire website with the HTML5 History API, History.js and jQuery the [Ajaxify Script](https://github.com/browserstate/ajaxify) is all you need. It's that easy.
### Ruby On Rails
If you are using Rails, then the easiest way for you to try History.js would be to use [Wiselinks](https://github.com/igor-alexandrov/wiselinks) gem. Wiselinks integrates into Rails application and allows you to start using History.js with three lines of code.
### Working with History.js directly
``` javascript
(function(window,undefined){
// 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
});
// 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);
```
### 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/browserstate/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/browserstate/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/browserstate/history.js/tarball/master) or [zip](https://github.com/browserstate/history.js/zipball/master)
- Include History.js
- For [Dojo](http://dojotoolkit.org/) v1.8+
``` html
<script src="http://www.yourwebsite.com/history.js/scripts/bundled/html4+html5/dojo.history.js"></script>
```
- For [ExtJs](http://www.sencha.com/) v1.8+
``` html
<script src="http://www.yourwebsite.com/history.js/scripts/bundled/html4+html5/extjs.history.js"></script>
```
- 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/`. See [Why supporting HTML4 browsers could be either good or bad based on my app's use cases](https://github.com/browserstate/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/browserstate/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/browserstate/history.js/issues). If you've fixed a bug submit a [Pull Request](https://github.com/browserstate/history.js/pulls) and add your fork to the [Network Wiki Page](https://github.com/browserstate/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/browserstate/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, be sure to add it to the [Showcase Wiki Page](https://github.com/browserstate/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/browserstate/history.js).
- For anything else, refer to the [History.js GitHub Wiki Site](https://github.com/browserstate/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, (10)
- Firefox 3
- Opera 10, 11.0
- Safari 4
- Safari iOS 4.2, 4.1, 4.0, 3.2
## Exposed API
### Functions
#### States
- `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.getStateByIndex` <br/> Gets a state by the index
- `History.getCurrentIndex` <br/> Gets the current index
- `History.getHash()` <br/> Gets the current hash of the browser
#### Adapter
- `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.
#### Navigation
- `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
#### Debug
- `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`
### Options
- `History.options.hashChangeInterval` <br/> How long should the interval be before hashchange checks
- `History.options.safariPollInterval` <br/> How long should the interval be before safari poll checks
- `History.options.doubleCheckInterval` <br/> How long should the interval be before we perform a double check
- `History.options.disableSuid` <br/> Force History not to append suid
- `History.options.storeInterval` <br/> How long should we wait between store calls
- `History.options.busyDelay` <br/> How long should we wait between busy events
- `History.options.debug` <br/> If true will enable debug messages to be logged
- `History.options.initialTitle` <br/> What is the title of the initial state
- `History.options.html4Mode` <br/> If true, will force HTMl4 mode (hashtags)
- `History.options.delayInit` <br/> Want to override default options and call init manually.
### 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)
## 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
## 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
## History
You can discover the history inside the [History.md](https://github.com/browserstate/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+ [Benjamin Arthur Lupton](http://balupton.com)

View File

@ -0,0 +1,4 @@
{
"name": "history.js",
"version": "1.8.0"
}

View File

@ -0,0 +1,372 @@
# Requires
buildr = require 'buildr'
util = require 'util'
# Options
options =
watch: false
compress: false
# Configs
configs =
standard:
# Options
name: 'standard'
watch: options.watch
# Paths
srcPath: __dirname+'/scripts/uncompressed'
# 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: [
# -----------------------------
# Dojo Toolkit
{
# Options
name: 'html4+html5+dojo'
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.dojo.js'
'history.html4.js'
'history.js'
]
# Bundling
bundleScriptPath: __dirname+'/scripts/bundled-uncompressed/html4+html5/dojo.history.js'
}
{
# Options
name: 'html5+dojo'
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.dojo.js'
'history.js'
]
# Bundling
bundleScriptPath: __dirname+'/scripts/bundled-uncompressed/html5/dojo.history.js'
}
# -----------------------------
# ExtJS
{
# Options
name: 'html4+html5+extjs'
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.extjs.js'
'history.html4.js'
'history.js'
]
# Bundling
bundleScriptPath: __dirname+'/scripts/bundled-uncompressed/html4+html5/extjs.history.js'
}
{
# Options
name: 'html5+extjs'
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.extjs.js'
'history.js'
]
# Bundling
bundleScriptPath: __dirname+'/scripts/bundled-uncompressed/html5/extjs.history.js'
}
# -----------------------------
# 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-uncompressed/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-uncompressed/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-uncompressed/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-uncompressed/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-uncompressed/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-uncompressed/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-uncompressed/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-uncompressed/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-uncompressed/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-uncompressed/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

@ -0,0 +1,373 @@
# 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: [
# -----------------------------
# Dojo Toolkit
{
# Options
name: 'html4+html5+dojo'
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.dojo.js'
'history.html4.js'
'history.js'
]
# Bundling
bundleScriptPath: __dirname+'/scripts/bundled/html4+html5/dojo.history.js'
}
{
# Options
name: 'html5+dojo'
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.dojo.js'
'history.js'
]
# Bundling
bundleScriptPath: __dirname+'/scripts/bundled/html5/dojo.history.js'
}
# -----------------------------
# ExtJS
{
# Options
name: 'html4+html5+extjs'
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.extjs.js'
'history.html4.js'
'history.js'
]
# Bundling
bundleScriptPath: __dirname+'/scripts/bundled/html4+html5/extjs.history.js'
}
{
# Options
name: 'html5+extjs'
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.extjs.js'
'history.js'
]
# Bundling
bundleScriptPath: __dirname+'/scripts/bundled/html5/extjs.history.js'
}
# -----------------------------
# 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

@ -0,0 +1,4 @@
{
"name": "history.js",
"version": "1.8.0"
}

View File

@ -0,0 +1,58 @@
<!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

@ -0,0 +1,62 @@
<!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

@ -0,0 +1,37 @@
<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

@ -0,0 +1,84 @@
<!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>History.js</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
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

@ -0,0 +1,43 @@
<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

@ -0,0 +1,62 @@
<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

@ -0,0 +1,23 @@
<!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

@ -0,0 +1,61 @@
<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

@ -0,0 +1,79 @@
<!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>History.js</h1>
<p>History.js gracefully supports unicode.</p>
<!-- Textarea for Logging -->
<textarea id="log" style="width:100%;height:400px"></textarea>
<!-- 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
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", "?läu=ßüs"); // logs {state:1,rand:"some random value"}, "State 1", "?l#äu=ßüs"',
'History.pushState({state:2,rand:Math.random()}, "State 2", "?chinese=リオれ"); // logs {state:2,rand:"some random value"}, "State 2", "/chinese/2"',
'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

@ -0,0 +1,10 @@
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

@ -0,0 +1,67 @@
{
"name": "history.js",
"version": "1.8.0",
"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/browserstate/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"
},
{
"name": "Andreas Bernhard",
"email": "andreas@bernhard.im",
"web": "http://www.bs-infosys.com"
}
],
"contributors": [
{
"name": "Benjamin Lupton",
"email": "b@lupton.cc",
"web": "http://balupton.com"
},
{
"name": "Andreas Bernhard",
"email": "andreas@bernhard.im",
"web": "http://www.bs-infosys.com"
}
],
"bugs": {
"web": "https://github.com/browserstate/history.js/issues"
},
"licenses": [
{
"type": "New-BSD",
"url": "http://creativecommons.org/licenses/BSD/"
}
],
"repository": {
"type": "git",
"url": "http://github.com/browserstate/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

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

@ -0,0 +1 @@
(function(e,t){"use strict";var n=e.History=e.History||{},r=e.require;if(typeof n.Adapter!="undefined")throw new Error("History.js Adapter has already been loaded...");n.Adapter={handlers:{},_uid:1,uid:function(e){return e._uid||(e._uid=n.Adapter._uid++)},bind:function(e,t,r){var i=n.Adapter.uid(e);n.Adapter.handlers[i]=n.Adapter.handlers[i]||{},n.Adapter.handlers[i][t]=n.Adapter.handlers[i][t]||[],n.Adapter.handlers[i][t].push(r),e["on"+t]=function(e,t){return function(r){n.Adapter.trigger(e,t,r)}}(e,t)},trigger:function(e,t,r){r=r||{};var i=n.Adapter.uid(e),s,o;n.Adapter.handlers[i]=n.Adapter.handlers[i]||{},n.Adapter.handlers[i][t]=n.Adapter.handlers[i][t]||[];for(s=0,o=n.Adapter.handlers[i][t].length;s<o;++s)n.Adapter.handlers[i][t][s].apply(this,[r])},extractEventData:function(e,n){var r=n&&n[e]||t;return r},onDomLoad:function(e){r(["dojo/ready"],function(t){t(e)})}},typeof n.init!="undefined"&&n.init()})(window)

View File

@ -0,0 +1 @@
(function(e,t){"use strict";var n=e.History=e.History||{},r=e.Ext;e.JSON={stringify:r.JSON.encode,parse:r.JSON.decode};if(typeof n.Adapter!="undefined")throw new Error("History.js Adapter has already been loaded...");n.Adapter={observables:{},bind:function(e,t,n,i){r.EventManager.addListener(e,t,n,i);var s=r.id(e,"history-"),o=this.observables[s];o||(o=r.create("Ext.util.Observable"),this.observables[s]=o),o.on(t,n,i)},trigger:function(e,t,n){var i=r.id(e,"history-"),s=this.observables[i];s&&s.fireEvent(t,n)},extractEventData:function(e,n,r){var i=n&&n.browserEvent&&n.browserEvent[e]||r&&r[e]||t;return i},onDomLoad:function(e){r.onReady(e)}},typeof n.init!="undefined"&&n.init()})(window)

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1 @@
typeof JSON!="object"&&(JSON={}),function(){"use strict";function f(e){return e<10?"0"+e:e}function quote(e){return escapable.lastIndex=0,escapable.test(e)?'"'+e.replace(escapable,function(e){var t=meta[e];return typeof t=="string"?t:"\\u"+("0000"+e.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+e+'"'}function str(e,t){var n,r,i,s,o=gap,u,a=t[e];a&&typeof a=="object"&&typeof a.toJSON=="function"&&(a=a.toJSON(e)),typeof rep=="function"&&(a=rep.call(t,e,a));switch(typeof a){case"string":return quote(a);case"number":return isFinite(a)?String(a):"null";case"boolean":case"null":return String(a);case"object":if(!a)return"null";gap+=indent,u=[];if(Object.prototype.toString.apply(a)==="[object Array]"){s=a.length;for(n=0;n<s;n+=1)u[n]=str(n,a)||"null";return i=u.length===0?"[]":gap?"[\n"+gap+u.join(",\n"+gap)+"\n"+o+"]":"["+u.join(",")+"]",gap=o,i}if(rep&&typeof rep=="object"){s=rep.length;for(n=0;n<s;n+=1)typeof rep[n]=="string"&&(r=rep[n],i=str(r,a),i&&u.push(quote(r)+(gap?": ":":")+i))}else for(r in a)Object.prototype.hasOwnProperty.call(a,r)&&(i=str(r,a),i&&u.push(quote(r)+(gap?": ":":")+i));return i=u.length===0?"{}":gap?"{\n"+gap+u.join(",\n"+gap)+"\n"+o+"}":"{"+u.join(",")+"}",gap=o,i}}typeof Date.prototype.toJSON!="function"&&(Date.prototype.toJSON=function(e){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(e){return this.valueOf()});var 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","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"},rep;typeof JSON.stringify!="function"&&(JSON.stringify=function(e,t,n){var r;gap="",indent="";if(typeof n=="number")for(r=0;r<n;r+=1)indent+=" ";else typeof n=="string"&&(indent=n);rep=t;if(!t||typeof t=="function"||typeof t=="object"&&typeof t.length=="number")return str("",{"":e});throw new Error("JSON.stringify")}),typeof JSON.parse!="function"&&(JSON.parse=function(text,reviver){function walk(e,t){var n,r,i=e[t];if(i&&typeof i=="object")for(n in i)Object.prototype.hasOwnProperty.call(i,n)&&(r=walk(i,n),r!==undefined?i[n]=r:delete i[n]);return reviver.call(e,t,i)}var j;text=String(text),cx.lastIndex=0,cx.test(text)&&(text=text.replace(cx,function(e){return"\\u"+("0000"+e.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

@ -0,0 +1,121 @@
/**
* History.js Dojo Adapter
*
* Essentially the same as the native adapter but uses dojo/ready for the dom load callback.
*
* @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||{},
require = window.require;
// 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) {
require(["dojo/ready"], function(ready) {
ready(callback);
});
}
};
// Try to Initialise History
if ( typeof History.init !== 'undefined' ) {
History.init();
}
})(window);

View File

@ -0,0 +1,92 @@
/**
* History.js ExtJS Adapter
* @author Sean Adkinson <sean.adkinson@gmail.com>
* @copyright 2012 Sean Adkinson <sean.adkinson@gmail.com>
* @license New BSD License <http://creativecommons.org/licenses/BSD/>
*/
// Closure
(function(window,undefined){
"use strict";
// Localise Globals
var
History = window.History = window.History||{},
Ext = window.Ext;
window.JSON = {
stringify: Ext.JSON.encode,
parse: Ext.JSON.decode
};
// Check Existence
if ( typeof History.Adapter !== 'undefined' ) {
throw new Error('History.js Adapter has already been loaded...');
}
// Add the Adapter
History.Adapter = {
observables: {},
/**
* History.Adapter.bind(el,event,callback)
* @param {Element|string} el
* @param {string} event - custom and standard events
* @param {function} callback
* @param {Object} scope
* @return {void}
*/
bind: function(element,eventName,callback,scope){
Ext.EventManager.addListener(element, eventName, callback, scope);
//bind an observable to the element that will let us "trigger" events on it
var id = Ext.id(element, 'history-'), observable = this.observables[id];
if (!observable) {
observable = Ext.create('Ext.util.Observable');
this.observables[id] = observable;
}
observable.on(eventName, callback, scope);
},
/**
* 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(element,eventName,extra){
var id = Ext.id(element, 'history-'), observable = this.observables[id];
if (observable) {
observable.fireEvent(eventName, 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){
var result = (event && event.browserEvent && event.browserEvent[key]) || (extra && extra[key]) || undefined;
return result;
},
/**
* History.Adapter.onDomLoad(callback)
* @param {function} callback
* @return {void}
*/
onDomLoad: function(callback) {
Ext.onReady(callback);
}
};
// Try and Initialise History
if ( typeof History.init !== 'undefined' ) {
History.init();
}
})(window);

View File

@ -0,0 +1,77 @@
/**
* 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

@ -0,0 +1,84 @@
/**
* 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

@ -0,0 +1,121 @@
/**
* 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 to Initialise History
if ( typeof History.init !== 'undefined' ) {
History.init();
}
})(window);

View File

@ -0,0 +1,78 @@
/**
* 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

@ -0,0 +1,74 @@
/**
* 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

@ -0,0 +1,685 @@
/**
* 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.isHashEqual(newHash, oldHash)
* Checks to see if two hashes are functionally equal
* @param {string} newHash
* @param {string} oldHash
* @return {boolean} true
*/
History.isHashEqual = function(newHash, oldHash){
newHash = encodeURIComponent(newHash).replace(/%25/g, "%");
oldHash = encodeURIComponent(oldHash).replace(/%25/g, "%");
return newHash === oldHash;
};
/**
* 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.discardedState(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,
startedWithHash = Boolean(History.getHash());
// 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
// IE 6 requires iframe to have a src on HTTPS pages, otherwise it will throw a
// "This page contains both secure and nonsecure items" warning.
iframe.setAttribute('id', iframeId);
iframe.setAttribute('src', '#');
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.getHash(iframe.contentWindow.document);
// 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;
// If there is no iframe hash that means we're at the original
// iframe state.
// And if there was a hash on the original request, the original
// iframe state was replaced instantly, so skip this state and take
// the user back to where they came from.
if (startedWithHash && iframeHash === '') {
History.back();
}
else {
// 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) || History.getLocationHref()),
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||History.getLocationHref()),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,encodeURI(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);
// We assume that the URL passed in is URI-encoded, but this makes
// sure that it's fully URI encoded; any '%'s that are encoded are
// converted back into '%'s
url = encodeURI(url).replace(/%25/g, "%");
// Check the State
if ( History.getHashByUrl(url) ) {
throw new Error('History.js does not support states with fragment-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(),
wasExpected = History.expectedStateId == newState.id;
// 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 HTML5 State
History.saveState(newState);
// Fire HTML5 Event
if(!wasExpected)
History.Adapter.trigger(window,'statechange');
// Update HTML4 Hash
if ( !History.isHashEqual(newStateHash, html4Hash) && !History.isHashEqual(newStateHash, History.getShortUrl(History.getLocationHref())) ) {
History.setHash(newStateHash,false);
}
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);
// We assume that the URL passed in is URI-encoded, but this makes
// sure that it's fully URI encoded; any '%'s that are encoded are
// converted back into '%'s
url = encodeURI(url).replace(/%25/g, "%");
// Check the State
if ( History.getHashByUrl(url) ) {
throw new Error('History.js does not support states with fragment-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),
newStateHash = History.getHashByState(newState),
oldState = History.getState(false),
oldStateHash = History.getHashByState(oldState),
previousState = History.getStateByIndex(-2);
// Discard Old State
History.discardState(oldState,newState,previousState);
// If the url hasn't changed, just store and save the state
// and fire a statechange event to be consistent with the
// html 5 api
if ( newStateHash === oldStateHash ) {
// Store the newState
History.storeState(newState);
History.expectedStateId = newState.id;
// Recycle the State
History.recycleState(newState);
// Force update of the title
History.setTitle(newState);
// Update HTML5 State
History.saveState(newState);
// Fire HTML5 Event
//History.debug('History.pushState: trigger popstate');
History.Adapter.trigger(window,'statechange');
History.busy(false);
}
else {
// 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 to Initialise History
if ( typeof History.init !== 'undefined' ) {
History.init();
}
})(window);

View File

@ -0,0 +1,486 @@
/*
json2.js
2012-10-08
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, regexp: true */
/*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 (typeof JSON !== 'object') {
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 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) {
if (typeof rep[i] === 'string') {
k = rep[i];
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.prototype.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.prototype.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

@ -0,0 +1,22 @@
<?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

@ -0,0 +1,45 @@
<!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

@ -0,0 +1,51 @@
<?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

@ -0,0 +1,23 @@
<?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

@ -0,0 +1,13 @@
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

@ -0,0 +1,55 @@
<!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 Dojo 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/dojo.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 Dojo 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/uncompressed/json2.js"></script>
<script src="../scripts/uncompressed/history.adapter.dojo.js"></script>
<script src="../scripts/uncompressed/history.html4.js"></script>
<script src="../scripts/uncompressed/history.js"></script>
<!--
<script src="../scripts/bundled/html4+html5/dojo.history.js"></script>
-->
<!-- Tests -->
<!--
-->
<script src="tests.js"></script>
</body>
</html>

View File

@ -0,0 +1,55 @@
<!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 ExtJS 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/extjs.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 ExtJS 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/uncompressed/json2.js"></script>
<script src="../scripts/uncompressed/history.adapter.extjs.js"></script>
<script src="../scripts/uncompressed/history.html4.js"></script>
<script src="../scripts/uncompressed/history.js"></script>
<!--
<script src="../scripts/bundled/html4+html5/extjs.history.js"></script>
-->
<!-- Tests -->
<!--
-->
<script src="tests.js"></script>
</body>
</html>

View File

@ -0,0 +1,43 @@
<!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

@ -0,0 +1,43 @@
<!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

@ -0,0 +1,43 @@
<!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

@ -0,0 +1,43 @@
<!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

@ -0,0 +1,43 @@
<!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

@ -0,0 +1,43 @@
<!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 Dojo 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/dojo.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 Dojo 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/dojo.history.js"></script>
<!-- Tests -->
<script src="tests.js"></script>
</body>
</html>

View File

@ -0,0 +1,43 @@
<!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 ExtJS 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/extjs.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 ExtJS 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/extjs.history.js"></script>
<!-- Tests -->
<script src="tests.js"></script>
</body>
</html>

View File

@ -0,0 +1,43 @@
<!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

@ -0,0 +1,43 @@
<!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

@ -0,0 +1,43 @@
<!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

@ -0,0 +1,43 @@
<!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

@ -0,0 +1,43 @@
<!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

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

View File

@ -0,0 +1,47 @@
<!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-bottom:1em;
float: left;
margin-right: 5em;
}
.adapter {
padding-bottom:1em;
}
</style>
</head>
<body>
<h1>History.js Test Suite</h1>
<p>HTML5 Browsers must pass the HTML4+HTML5 tests, HTML4 Browsers must pass the HTML4 tests and should fail the HTML5 tests.</p>
<div class="browser">
<h2>HTML 4+5</h2>
<div class="adapter"><a href="html4+HTML5.dojo.html">Dojo Test Suite</a></div>
<div class="adapter"><a href="html4+HTML5.extjs.html">ExtJS Test Suite</a></div>
<div class="adapter"><a href="HTML4+HTML5.jquery.html">jQuery Test Suite</a></div>
<div class="adapter"><a href="HTML4+HTML5.mootools.html">Mootools Test Suite</a></div>
<div class="adapter"><a href="HTML4+HTML5.native.html">Native Test Suite</a></div>
<div class="adapter"><a href="HTML4+HTML5.right.html">Right Test Suite</a></div>
<div class="adapter"><a href="HTML4+HTML5.zepto.html">Zepto Test Suite</a> (Zepto doesn't support IE)</div>
</div>
<div class="browser">
<h2>HTML 5</h2>
<div class="adapter"><a href="HTML5.dojo.html">Dojo Test Suite</a></div>
<div class="adapter"><a href="HTML5.extjs.html">ExtJS Test Suite</a></div>
<div class="adapter"><a href="HTML5.jquery.html">jQuery Test Suite</a></div>
<div class="adapter"><a href="HTML5.mootools.html">Mootools Test Suite</a></div>
<div class="adapter"><a href="HTML5.native.html">Native Test Suite</a></div>
<div class="adapter"><a href="HTML5.right.html">Right Test Suite</a></div>
<div class="adapter"><a href="HTML5.zepto.html">Zepto Test Suite</a> (Zepto doesn't support IE)</div>
</div>
</body>
</html>

View File

@ -0,0 +1,254 @@
(function(){
var
History = window.History,
document = window.document,
test = window.test,
deepEqual = window.deepEqual;
// 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);
deepEqual(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

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,8 @@
.project
*~
*.diff
*.patch
.DS_Store
.settings
node_modules
dist/

View File

@ -0,0 +1,55 @@
Jörn Zaefferer <joern.zaefferer@gmail.com>
Ariel Flesler <aflesler@gmail.com>
Scott González <scott.gonzalez@gmail.com>
Richard Worth <rdworth@gmail.com>
Philippe Rathé <prathe@gmail.com>
John Resig <jeresig@gmail.com>
Will Moffat <will_git@hamstersoup.com>
Jan Kassens <jan@kassens.net>
Ziling Zhao <zizhao@cisco.com>
Ryan Szulczewski <musicmanryan@gmail.com>
Chris Lloyd <christopher.lloyd@gmail.com>
Louis-Rémi Babé <public@lrbabe.com>
Jake Archibald <jake.archibald@bbc.co.uk>
Frances Berriman <frances.berriman@bbc.co.uk>
Rune Halvorsen <runefh@gmail.com>
Chris Thatcher <thatcher.christopher@gmail.com>
Fábio Rehm <fgrehm@gmail.com>
Leon Sorokin <leeoniya@gmail.com>
Douglas Neiner <doug@pixelgraphics.us>
Paul Elliott <paul@hashrocket.com>
Nikita Vasilyev <me@elv1s.ru>
Benjamin Lee <leebenjp@gmail.com>
Paul Irish <paul.irish@gmail.com>
Oleg Slobodskoi <oleg008@gmail.com>
Anton Matzneller <obhvsbypqghgc@gmail.com>
Aurélien Bombo
Mathias Bynens <mathias@qiwi.be>
Erik Vold <erikvvold@gmail.com>
Wesley Walser <waw325@gmail.com>
Rob Kinninmont <robk@twitter.com>
Marc Portier <marc.portier@gmail.com>
Michael Righi <michael@righi.me>
Timo Tijhof <krinklemail@gmail.com>
Jan Alonzo <jmalonzo@taguchimail.com>
Daniel Trebbien <dtrebbien@gmail.com>
Bob Fanger <bfanger@gmail.com>
Markus Messner-Chaney <markus.messner-chaney@xing.com>
Trevor Parscal <trevorparscal@gmail.com>
Ashar Voultoiz <hashar@free.fr>
Jimmy Mabey <jimmy@velsoft.com>
Domenic Denicola <domenic@domenicdenicola.com>
Mike Sherov <mike.sherov@gmail.com>
Seong-A Kong <simonz@daumcorp.com>
Graham Conzett <conzett@gmail.com>
Niall Smart <niall@pobox.com>
Johan Sörlin <spocke@moxiecode.com>
Gijs Kruitbosch <gijskruitbosch@gmail.com>
Erkan Yilmaz <erkan77@gmail.com>
Jonathan Sanchez <jsanchezpando@cirb.irisnet.be>
Keith Cirkel <github@keithcirkel.co.uk>
Rick Waldron <waldron.rick@gmail.com>
Herbert Vojčík <herby@mailbox.sk>
Richard Gibson <richard.gibson@gmail.com>
Alex J Burke <alex@alexjeffburke.com>
Sergii Kliuchnyk <sergiikliuchnyk@gmail.com>

View File

@ -0,0 +1,496 @@
1.11.0 / 2013-01-20
==================
* Diff: Fix exception on property "constructor". Fixes #394.
* Composite Add-on: Test suites can be named by including an obj with name & path props within array param for .testSuites()
* Fix URL generator to take protocol and host into account to fix usage with file protocol in IE7/8
* Fix issue with Error.prototype.toString in IE 7
* Refactor jsDump for "node". Fixes #381.
* Show contents of text nodes in jsDump.node. Fixes #380.
* Escape text. Fixes #379.
* Rewrote most of the JUnitLogger addon as it was in bad shape: unused variables, duplicate effort that QUnit handles internally (e.g. tallying number of total assertions, failed assertions, etc.), sub-optimal XmlWriter implementation, etc.
* Phantomjs: Include source in assertion details
* Phantomjs: Removed the polling mechanism in favor of PhantomJS 1.6+'s `WebPage#onCallback`
* Delay start() until init() happened. Fixes #358. Closes #373.
* urlConfig: Fix checkbox event for oldIE. Fixes #369. Closes #370.
* Issue #365: Fix module picker for oldIE. Closes #366.
* Fixes #344 - Capture and show test duration.
* Rename tests to assertions in summary. Fixes #336 - Summary counts assertions but mentions 'tests'.
* Assert: Implement propEqual and notPropEqual. Fixes #317.
* Canvas addon: Use 0.6 as alpha value to avoid inconsistencies between browsers. Fixes #342
* Remove global variable "assert". Fixes #341.
* Add a test for loading tests asynchronously
* Improve start()-called-too-often fix, initialize semaphore at 1, fixes autostart=false case. Also provide stack for the offending start() call
* There's type-free objects in Firefox, extend objectType() to allow null match. Fixes #315
* Push a failing assertion when calling start() while already running. Resets anyway to keep other tests going. Fixes #314
* Adds Ninja Theme
* Extend jsdump to output Error objects as such, including the message property. Extend throws to provide 'expected' value when possible. Fixes #307
* Use classes to collapse assertion groups. Fixes #269
* Readme for junitlogger addon
* Better readme for composite addon
* Make `throws` ES3 compatible
* Composite: Adds test whether iframe contains content. Fixes #318 - Composite: Raises "global failure" in Opera
* Apply the same exception handling for test and teardown try/catch as for setup
1.10.0 / 2012-08-30
==================
* Simplify licensing: Only MIT, no more MIT/GPL dual licensing.
* Scroll the window back to top after tests finished running. Fixes #304
* Simplify phantomjs runner to use module property in testDone callback
* Adds module and test name to the information that is returned in the callback provided to QUnit.log(Function). Fixes #296
* Make QUnit.expect() (without arguments) a getter. Fixes #226
* Compare the ES6 sticky (y) property for RegExp. Can't add to tests yet. Fixes #284 - deepEqual for RegExp should compare
* onerror: force display of global errors despite URL parameters. Fixes #288 - Global failures can be filtered out by test-limiting URL parameters
* Remove conditional codepath based on jQuery presence from reset().
* Add module filter to UI
* Keep a local reference to Date. Fixes #283.
* Update copyright to jQuery Foundation.
1.9.0 / 2012-07-11
==================
* added jsdoc for QUnit.assert functions
* Styling: radius to 5px and small pass/error border, remove inner shadow
* Move checkboxes into toolbar and give them labels and descriptions (as tooltip). Fixes #274 - Improve urlFilter API and UI
* Where we recieve no exception in throws() use a relevant message.
* Also make module filter case-insensitive. Follow-up to #252
* Banner: Link should ignore "testNumber" and "module". Fixes #270
* Rename assert.raises to assert.throws. Fixes #267
* Change package.json name property to 'qunitjs' to avoid conflicht with node-qunit; will publish next release to npm
1.8.0 / 2012-06-14
==================
* Improve window.onerror handling
* (issue #260) config.current should be reset at the right time.
* Filter: Implement 'module' url parameter. Fixes #252
* raises: ignore global exceptions stemming from test. Fixes #257 - Globally-executed errors sneak past raises in IE
1.7.0 / 2012-06-07
==================
* Add config.requireExpects. Fixes #207 - Add option to require all tests to call expect().
* Improve extractStacktrace() implementation. Fixes #254 - Include all relevant stack lines
* Make filters case-insensitive. Partial fix for #252
* is() expects lowercase types. Fixes #250 - Expected Date value is not displayed properly
* Fix phantomjs addon header and add readme. Fixes #239
* Add some hints to composite addon readme. Fixes #251
* Track tests by the order in which they were run and create rerun links based on that number. Fixes #241 - Make Rerun link run only a single test.
* Use QUnit.push for raises implementation. Fixes #243
* CLI runner for phantomjs
* Fix jshint validation until they deal with /** */ comments properly
* Update validTest() : Simplify logic, clarify vars and add comments
* Refactor assertion helpers into QUnit.assert (backwards compatible)
* Add Rerun link to placeholders. Fixes #240
1.6.0 / 2012-05-04
==================
* Save stack for each test, use that for failed expect() results, points at the line where test() was called. Fixes #209
* Prefix test-output id and ignore that in noglobals check. Fixes #212
* Only check for an exports object to detect a CommonJS enviroment. Fixes #237 - Incompatibility with require.js
* Add testswarm integration as grunt task
* Added padding on URL config checkboxes.
* Cleanup composite addon: Use callback registration instead of overwriting them. Set the correct src on rerun link (and dblclick). Remove the composite test itself, as that was a crazy hack not worth maintaining
* Cleanup reset() test and usage - run testDone callback first, to allow listeneres ignoring reset assertions
* Double clicking on composite test rows opens individual test page
* test-message for all message-bearing API reporting details
1.5.0 / 2012-04-04
==================
* Modify "Running..." to display test name. Fixes #220
* Fixed clearing of sessionStorage in Firefox 3.6.
* Fixes #217 by calling "block" with config.current.testEnvironment
* Add stats results to data. QUnit.jUnitReport function take one argument { xml:'<?xml ...', results:{failed:0, passed:0, total:0, time:0} }
* Add link to MDN about stack property
1.4.0 / 2012-03-10
==================
* Prefix test-related session-storage items to make removal more specific. Fixes #213 - Keep hide-passed state when clearing session storage
* Update grunt.js with seperate configs for qunit.js and grunt.js, also add tests but disable for now, not passing yet. Add grunt to devDependencies
* typo
* Cleanup grunt.js, no need for the banner
* Fix lint errors and some formatting issues. Use QUnit.pushFailure for noglobals and global error handler.
* Fix a missing expect in logs test
* Add grunt.js configuration and include some usage instructions in the readme
* Update package.json
* Partially revert af27eae841c3e1c01c46de72d676f1047e1ee375 - can't move reset around, so also don't wrap in try-catch, as the result of that is effectively swallowed. Can't output the result as the outputting is already done.
* Add QUnit.pushFailure to log error conditions like exceptions. Accepts stacktrace as second argument, allowing extraction with catched exceptions (useful even in Safari). Remove old fail() function that would just log to console, not useful anymore as regular test output is much more useful by now. Move up QUnit.reset() call to just make that another failed assertion. Used to not make a test fail. Fixes #210
* Update equals and same deprecations to use QUnit.push to provide correct source lines. Fixes #211
* Add a test file for narwhal integration. Has to use print instead of console.log. Fails when an assertion fails, something about setInterval...
* Apply notrycatch option to setup and teardown as well. Fixes #203. Reorder noglobals check to allow teardown to remove globals that were introduced intentionally. Fixes #204
* Extend exports object with QUnit properties at the end of the file to export everything.
* Output source line for ok() assertions. Fixes #202
* Make test fail if no assertions run. Fixes #178
* Sort object output alphabetically in order to improve diffs of objects where properties were set in a different order. Fixes #206
* Revert "Change fixture reset behavior", changing #194 and #195 to wontfix.
1.3.0 / 2012-02-26
==================
* Cleanup test markup
* Fix the jQuery branch of fixture reset. Would break when no fixture exists.
* Added initial version of a junitlogger addon.
* Escape document.title before inserting into markup. Extends fix for #127
* Catch assertions running outside of test() context, make sure source is provided even for ok(). Fixes #98
* Improve global object access, based on comments for 1a9120651d5464773256d8a1f2cf2eabe38ea5b3
* Clear all sessionStorage entries once all tests passed. Helps getting rid of items from renamed tests. Fixes #101
* Set fixed dimensions for #qunit-fixture. Fixes #114
* Extend nodejs test runner to check for stacktrace output, twice
* Extend nodejs test runner to check for stacktrace output
* Generate more base markup, but allow the user to exclude that completelty or choose their own. Fixes #127
* Add a simple test file to check basic nodejs integration works
* Check for global object to find setTimeout in node
* Fix CommonJS export by assigning QUnit to module.exports.
* Remove the testEnviromentArg to test(). Most obscure, never used anywhere. test() is still heavily overloaded with argument shifting, this makes it a little more sane. Fixes #172
* Serialize expected and actual values only when test fails. Speeds up output of valid tests, especially for lots of large objects. Fixes #183
* Fix sourceFromsTacktrace to get the right line in Firefox. Shift the 'error' line away in Chrome to get a match.
* Fix references to test/deepEqual.js
* In autorun mode, moduleDone is called without matching moduleStart. Fix issue #184
* Fixture test: allow anything falsy in test as getAttribute in oldIE will return empty string instead of null. We don't really care.
* Keep label and checkbox together ( http://i.imgur.com/5Wk3A.png )
* Add readme for themes
* Fix bad global in reset()
* Some cleanup in theme addons
* Update headers
* Update nv.html, add gabe theme based on https://github.com/jquery/qunit/pull/188
* Experiemental custom theme based on https://github.com/jquery/qunit/pull/62 by NV
* Replace deprecated same and equals aliases with placeholders that just throw errors, providing a hint at what to use instead. Rename test file to match that.
* Can't rely on outerHTML for Firefox < 11. Use cloneNode instead.
* Merge remote branch 'conzett/master'
* Cleanup whitespace
* Update sessionStorage support test to latest version from Modernizr, trying to setItem to avoid QUOTA_EXCEEDED_EXCEPTION
* Change fixture reset behavior
* Merge pull request #181 from simonz/development
* Escaping test names
* Show exception stack when test failed
1.2.0 / 2011-11-24
==================
* remove uses of equals(), as it's deprecated in favor of equal()
* Code review of "Allow objects with no prototype to be tested against object literals."
* Allow objects with no prototype to tested against object literals.
* Fix IE8 "Member not found" error
* Using node-qunit port, the start/stop function are not exposed so we need to prefix any call to them with 'QUnit'. Aka: start() -> QUnit.start()
* Remove the 'let teardown clean up globals test' - IE<9 doesn't support (==buggy) deleting window properties, and that's not worth the trouble, as everything else passes just fine. Fixes #155
* Fix globals in test.js, part 2
* Fix globals in test.js. ?tell wwalser to use ?noglobals everyonce in a while
* Extend readme regarding release process
1.1.0 / 2011-10-11
==================
* Fixes #134 - Add a window.onerror handler. Makes uncaught errors actually fail the testsuite, instead of going by unnoticed.
* Whitespace cleanup
* Merge remote branch 'trevorparscal/master'
* Fixed IE compatibility issues with using toString on NodeList objects, which in some browsers results in [object Object] rather than [object NodeList]. Now using duck typing for NodeList objects based on the presence of length, length being a number, presence of item method (which will be typeof string in IE and function in others, so we just check that it's not undefined) and that item(0) returns the same value as [0], unless it's empty, in which case item(0) will return 0, while [0] would return undefined. Tested in IE6, IE8, Firefox 6, Safari 5 and Chrome 16.
* Update readme with basic notes on releases
* More whitespace/parens cleanup
* Check if setTimeout is available before trying to delay running the next task. Fixes #160
* Whitespace/formatting fix, remove unnecessary parens
* Use alias for Object.prototype.toString
* Merge remote branch 'trevorparscal/master'
* Merge remote branch 'wwalser/recursionBug'
* Default 'expected' to null in asyncTest(), same as in test() itself.
* Whitespace cleanup
* Merge remote branch 'mmchaney/master'
* Merge remote branch 'Krinkle/master'
* Using === instead of ==
* Added more strict array type detection for dump output, and allowed NodeList objects to be output as arrays
* Fixes a bug where after an async test, assertions could move between test cases because of internal state (config.current) being incorrectly set
* Simplified check for assertion count and adjusted whitespace
* Redo of fixing issue #156 (Support Object.prototype extending environment). * QUnit.diff: Throws exception without this if Object.prototype is set (Property 'length' of undefined. Since Object.prototype.foo doesn't have a property 'rows') * QUnit.url: Without this fix, if Object.prototype.foo is set, the url will be set to ?foo=...&the=rest. * saveGlobals: Without this fix, whenever a member is added to Object.prototype, saveGlobals will think it was a global variable in this loop. --- This time using the call method instead of obj.hasOwnProperty(key), which may fail if the object has that as it's own property (touché!).
* Handle expect(0) as expected, i.e. expect(0); ok(true, foo); will cause a test to fail
1.0.0 / 2011-10-06
==================
* Make QUnit work with TestSwarm
* Run other addons tests as composite addon demo. Need to move that to /test folder once this setup actually works
* Add-on: New assertion-type: step()
* added parameter to start and stop allowing a user to increment/decrement the semaphore more than once per call
* Update readmes with .md extension for GitHub to render them as markdown
* Update close-enough addon to include readme and match (new) naming convetions
* Merge remote branch 'righi/close-enough-addon'
* Canvas addon: Update file referneces
* Update canvas addon: Rename files and add README
* Merge remote branch 'wwalser/composite'
* Fix #142 - Backslash characters in messages should not be escaped
* Add module name to testStart and testDone callbacks
* Removed extra columns in object literals. Closes #153
* Remove dead links in comments.
* Merge remote branch 'wwalser/multipleCallbacks'
* Fixed syntax error and CommonJS incompatibilities in package.json
* Allow multiple callbacks to be registered.
* Add placeholder for when Safari may end up providing useful error handling
* changed file names to match addon naming convention
* Whitespace
* Created the composite addon.
* Using array and object literals.
* Issue #140: Make toggle system configurable.
* Merge remote branch 'tweetdeck/master'
* Adds the 'close enough' addon to determine if numbers are acceptably close enough in value.
* Fix recursion support in jsDump, along with tests. Fixes #63 and #100
* Adding a QUnit.config.altertitle flag which will allow users to opt-out of the functionality introduced in 60147ca0164e3d810b8a9bf46981c3d9cc569efc
* Refactor window.load handler into QUnit.load, makes it possible to call it manually.
* More whitespace cleanup
* Merge remote branch 'erikvold/one-chk-in-title'
* Whitespace
* Merge remote branch 'wwalser/syncStopCalls'
* Introducing the first QUnit addon, based on https://github.com/jquery/qunit/pull/84 - adds QUnit.pixelEqual assertion method, along with example tests.
* Remove config.hidepassed setting in test.js, wasn't intended to land in master.
* Expose QUnit.config.hidepassed setting. Overrides sessionStorage and enables enabling the feature programmatically. Fixes #133
* Fix formatting (css whitespace) for tracebacks.
* Expose extend, id, and addEvent methods.
* minor comment typo correction
* Ignore Eclipse WTP .settings
* Set 'The jQuery Project' as author in package.json
* Fixes a bug where synchronous calls to stop would cause tests to end before start was called again
* Point to planning testing wiki in readme
* only add one checkmark to the document.title
* Escape the stacktrace output before setting it as innerHTML, since it tends to contain `<` and `>` characters.
* Cleanup whitespace
* Run module.teardown before checking for pollution. Fixes #109 - noglobals should run after module teardown
* Fix accidental global variable "not"
* Update document.title status to use more robust unicode escape sequences, works even when served with non-utf-8-charset.
* Modify document.title when suite is done to show success/failure in tab, allows you to see the overall result without seeing the tab content.
* Merge pull request #107 from sexyprout/master
* Set a generic font
* Add/update headers
* Drop support for deprecated #main in favor of #qunit-fixture. If this breaks your testsuite, replace id="main" with id="qunit-fixture". Fixes #103
* Remove the same key as the one being set. Partial fix for #101
* Don't modify expected-count when checking pollution. The failing assertion isn't expected, so shouldn't be counted. And if expect wasn't used, the count is misleading.
* Fix order of noglobals check to produce correct introduced/delete error messages
* Prepend module name to sessionStorage keys to avoid conflicts
* Store filter-tests only when checked
* Write to sessionStorage only bad tests
* Moved QUnit.url() defintion after QUnit properties are merged into the global scope. Fixes #93 - QUnit url/extend function breaking urls in jQuery ajax test component
* Add a "Rerun" link to each test to replce the dblclick (still supported, for now).
* Fixed the regex for parsing the name of a test when double clicking to filter.
* Merge remote branch 'scottgonzalez/url'
* Added checkboxes to show which flags are currently on and allow toggling them.
* Retain all querystring parameters when filtering a test via double click.
* Added better querystring parsing. Now storing all querystring params in QUnit.urlParams so that we can carry the params forward when filtering to a specific test. This removes the ability to specify multiple filters.
* Make reordering optional (QUnit.config.reorder = false) and optimize "Hide passed tests" mode by also hiding "Running [testname]" entries.
* Added missing semicolons and wrapped undefined key in quotes.
* Optimize test hiding, add class on page load if stored in sessionStorage
* Optimize the hiding of passed tests.
* Position test results above test list, making it visible without ever having to scroll. Create a placeholder to avoid pushing down results later.
* Don't check for existing qunit-testresult element, it gets killed on init anyway.
* Added URL flag ?notrycatch (ala ?noglobals) for debugging exceptions. Won't try/catch test code, giving better debugging changes on the original exceptions. Fixes #72
* Always show quni-toolbar (if at all specified), persist checkbox via sessionStorage. Fixes #47
* Use non-html testname for calls to fail(). Fixes #77
* Overhaul of QUnit.callbacks. Consistent single argument with related properties, with additonal runtime property for QUnit.done
* Extended test/logs.html to capture more of the callbacks.
* Fixed moduleStart/Done callbacks. Added test/logs.html to test these callbacks. To be extended.
* Update copyright and license header. Fixes #61
* Formatting fix.
* Use a semaphore to synchronize stop() and start() calls. Fixes #76
* Merge branch 'master' of https://github.com/paulirish/qunit into paulirish-master
* Added two tests for previous QUnit.raises behaviour. For #69
* add optional 2. arg to QUnit.raises #69.
* fix references inside Complex Instances Nesting to what was originally intended.
* Qualify calls to ok() in raises() for compability with CLI enviroments.
* Fix done() handling, check for blocking, not block property
* Fix moduleStart/Done and done callbacks.
* Replacing sessionStorage test with the one from Modernizr/master (instead of current release). Here's hoping it'll work for some time.
* Updated test for availibility of sessionStorage, based on test from Modernizr. Fixes #64
* Defer test execution when previous run passed, persisted via sessionStorage. Fixes #49
* Refactored module handling and queuing to enable selective defer of test runs.
* Move assertions property from config to Test
* Move expected-tests property from config to Test
* Refactored test() method to delegate to a Test object to encapsulate all properties and methods of a single test, allowing further modifications.
* Adding output of sourcefile and linenumber of failed assertions (except ok()). Only limited cross-browser support for now. Fixes #60
* Drop 'hide missing tests' feature. Fixes #48
* Adding readme. Fixes #58
* Merge branch 'prettydiff'
* Improve jsDump output with formatted diffs.
* Cleanup whitespace
* Cleanup whitespace
* Added additional guards around browser specific code and cleaned up jsDump code
* Added guards around tests which are only for browsers
* cleaned up setTimeout undefined checking and double done on test finish
* fixing .gitignore
* making window setTimeout query more consistent
* Moved expect-code back to beginning of function, where it belongs. Fixes #52
* Bread crumb in header: Link to suite without filters, add link to current page based on the filter, if present. Fixes #50
* Make the toolbar element optional when checking for show/hide of test results. Fixes #46
* Adding headless.html to manually test logging and verify that QUnit works without output elements. Keeping #qunit-fixture as a few tests actually use that.
* Fix for QUnit.moduleDone, get rid of initial bogus log. Fixes #33
* Pass raw data (result, message, actual, expected) as third argument to QUnit.log. Fixes #32
* Dump full exception. Not pretty, but functional (see issue Pretty diff for pretty output). Fixes #31
* Don't let QUnit.reset() cause assertions to run. Manually applied from Scott Gonzalez branch. Fixes #34
* Added missing semicolons. Fixes #37
* Show okay/failed instead of undefined. Fixes #38
* Expose push as QUnit.push to build custom assertions. Fixes #39
* Respect filter pass selection when writing new results. Fixes #43
* Cleanup tests, removing asyncTest-undefined check and formatting
* Reset: Fall back to innerHTML when jQuery isn't available. Fixes #44
* Merge branch 'master' of github.com:jquery/qunit
* reset doesn't exist here - fixes #28.
* - less css cruft, better readability - replaced inline style for test counts with "counts" class - test counts now use a "failed"/"passed" vs "pass"/"fail", shorter/more distinct selectors - pulled all test counts styling together and up (they're always the same regardless of section pass/fail state)
* Adding .gitignore file
* Removing diff test - diffing works fine, as the browser collapses whitespace in its output, but the test can't do that and isn't worth fixing.
* Always synchronize the done-step (it'll set the timeout when necessary), fixes timing race conditions.
* Insert location.href as an anchor around the header. Fixes issue #29
* - kill double ;; in escapeHtml. oops
* Removed html escaping from QUnit.diff, as input is already escaped, only leads to double escaping. Replaced newlines with single whitespace.
* Optimized and cleaned up CSS file
* Making the reset-method non-global (only module, test and assertions should be global), and fixing the fixture reset by using jQuery's html() method again, doesn't work with innerHTML, yet
* Introducing #qunit-fixture element, deprecating the (never documented) #main element. Doesn't require inline styles and is now independent of jQuery.
* Ammending previous commit: Remove jQuery-core specific resets (will be replaced within jQuery testsuite). Fixes issue #19 - QUnit.reset() removes global jQuery ajax event handlers
* Remove jQuery-core specific resets (will be replaced within jQuery testsuite). Fixes issue #19 - QUnit.reset() removes global jQuery ajax event handlers
* Cleaning up rubble from the previous commit.
* Added raises assertion, reusing some of kennsnyder's code.
* Merged kensnyder's object detection code. Original message: Streamlined object detection and exposed QUnit.objectType as a function.
* Fixed some bad formatting.
* Move various QUnit properties below the globals-export to avoid init becoming a global method. Fixes issue #11 - Remove 'init' function from a global namespace
* Improved output when expected != actual: Output both only then, and add a diff. Fixes issue #10 - Show diff if equal() or deepEqual() failed
* Expand failed tests on load. Fixes issue #8 - Failed tests expanded on load
* Set location.search for url-filtering instead of location.href. Fixes issue #7 - Modify location.search instead of location.href on test double-click
* Add QUnit.begin() callback. Fixes issue #6 - Add 'start' callback.
* add css style for result (".test-actual") in passed tests
* Fixed output escaping by using leeoniya's custom escaping along with innerHTML. Also paves the way for outputting diffs.
* Cleanup
* Revert "Revert part of bad merge, back to using createTextNode"
* Revert part of bad merge, back to using createTextNode
* Fixed doubleclick-handler and filtering to rerun only a single test.
* Add ability to css style a test's messages, expected and actual results. Merged from Leon Sorokin (leeoniya).
* Remove space between module name and colon
* - removed "module" wording from reports (unneeded and cluttery) - added and modified css to make module & test names styleable
* Logging support for Each test can extend the module testEnvironment
* Fixing whitespace
* Update tests to use equal() and deepEqual() rather than the deprecated equals() and same()
* Consistent argument names for deepEqual
* Skip DOM part of jsDump test if using a SSJS environment without a DOM
* Improve async testing by creating the result element before running the test, updating it later. If the test fails, its clear which test is the culprit.
* Add autostart option to config. Set via QUnit.config.autostart = false; start later via QUnit.start()
* Expose QUnit.config, but don't make config a global
* Expose QUnit.config as global to make external workarounds easier
* Merge branch 'asyncsetup'
* Allowing async setup and teardown. Fixes http://github.com/jquery/qunit/issues#issue/20
* Always output expected and actual result (no reason not to). Fixes http://github.com/jquery/qunit/issues#issue/21
* More changes to the detection of types in jsDump's typeOf.
* Change the typeOf checks in QUnit to be more accurate.
* Added test for jsDump and modified its options to properly output results when document.createTextNode is used; currently tests for DOM elements cause a stackoverflow error in IEs, works fine, with the correct output, elsewhere
* Always use jsDump to output result objects into messages, making the output for passing assertions more useful
* Make it so that the display is updated, at least, once a second - also prevents scripts from executing for too long and causing problems.
* added tests and patch for qunit.equiv to avoid circular references in objects and arrays
* No reason to continue looping, we can stop at this point. Thanks to Chris Thatcher for the suggestion.
* Use createTextNode instead of innerHTML for showing test result since expected and actual might be something that looks like a tag.
* 'Test card' design added
* switched green to blue for top-level pass + reduced padding
* Bringing the QUnit API in line with the CommonJS API.
* Explicitly set list-style-position: inside on result LIs.
* Madness with border-radius.
* Corrected banner styles for new class names
* Added rounded corners and removed body rules for embedded tests
* Resolving merge conflicts.
* added colouring for value summary
* adding some extra text colours
* added styles for toolbar
* added new styles
* IE 6 and 7 weren't respecting the CSS rules for the banner, used a different technique instead.
* Went a bit further and made extra-sure that the target was specified correctly.
* Fixed problem where double-clicking an entry in IE caused an error to occur.
* Path for http://dev.jquery.com/ticket/5426 - fix the microformat test result
* Fixed test() to use 'expected' 2nd param
* Remove the named function expressions, to stop Safari 2 from freaking out. Fixes #5.
* Each test can extend the module testEnvironment
* Extra test for current test environment
* Make the current testEnvironment available to utility functions
* typeOf in QUnit.jsDump now uses QUnit.is
* hoozit in QUnit.equiv now uses QUnit.is
* Properly set label attributes.
* Some minor tweaks to RyanS' GETParams change.
* left a console.log in :(
* Took into account a fringe case when using qunit with testswarm. Trying to run all the tests with the extra url params from testswarm would make qunit look for a testsuite that did not exist
* need to set config.currentModule to have correct names and working filters
* Support logging of testEnvironment
* async tests aren't possible on rhino
* Fixed a missing QUnit.reset().
* The QUnit. prefix was missing from the uses of the start() method.
* Merged lifecycle object into testEnvironment
* "replacing totally wrong diff algorithm with a working one" Patch from kassens (manually applied).
* fixing jslint errors in test.js
* Fixed: testDone() was always called with 0 failures in CommonJS mode
* Fixed: moduleDone() was invoked on first call to module()
* Added a new asyncTest method - removes the need for having to call start() at the beginning of an asynchronous test.
* Added support for expected numbers in the test method.
* Fixed broken dynamic loading of tests (can now dynamically load tests and done still works properly).
* Simplified the logic for calling 'done' and pushing off new tests - was causing too many inconsistencies otherwise.
* Simplified the markup for the QUnit test test suite.
* Realized that it's really easy to handle the case where stop() has been called and then an exception is thrown.
* Added in better logging support. Now handle moduleStart/moduleDone and testStart/testDone. Also make sure that done only fires once at the end.
* Made it so that you can reset the suite to an initial state (at which point tests can be dynamically loaded and run, for example).
* Re-worked QUnit to handle dynamic loading of additional code (the 'done' code will be re-run after additional code is loaded).
* Removed the old SVN version stuff.
* Moved the QUnit source into a separate directory and updated the test suite/packages files.
* Added in CommonJS support for exporting the QUnit functionality.
* Missing quote from package.json.
* Fixed trailing comma in package.json.
* Added a CommonJS/Narwhal package.json file.
* Accidentally reverted the jsDump/equiv changes that had been made.
* Hide the filter toolbar if it's not needed. Also exposed the jsDump and equiv objects on QUnit.
* Retooled the QUnit CSS to be more generic.
* Renamed the QUnit files from testrunner/testsuite to QUnit.
* Expose QUnit.equiv and QUnit.jsDump in QUnit.
* Moved the QUnit test directory into the QUnit directory.
* Reworked the QUnit CSS (moved jQuery-specific stuff out, made all the other selectors more specific).
* Removed the #main reset for non-jQuery code (QUnit.reset can be overwritten with your own reset code).
* Moved the QUnit toolbar inline.
* Switched to using a qunit- prefix for special elements (banner, userAgent, and tests).
* Missed a case in QUnit where an element was assumed to exist.
* QUnit's isSet and isObj are no longer needed - you should use same instead.
* Make sure that QUnit's equiv entity escaping is enabled by default (otherwise the output gets kind of crazy).
* Refactored QUnit, completely reorganized the structure of the file. Additionally made it so that QUnit can run outside of a browser (inside Rhino, for example).
* Removed some legacy and jQuery-specific test methods.
* Added callbacks for tests and modules. It's now possible to reproduce the full display of the testrunner without using the regular rendering.
* QUnit no longer depends upon rendering the results (it can work simply by using the logging callbacks).
* Made QUnit no longer require jQuery (it is now a standalone, framework independent, test runner).
* Reverted the noglobals changed from QUnit - causing chaos in the jQuery test suite.
* qunit: removed noglobals flag, instead always check for globals after teardown; if a test has to introduce a global "myVar", use delete window.myVar in teardown or at the end of a test
* qunit: don't child selectors when IE should behave nicely, too
* qunit: improvment for the test-scope: create a new object and call setup, the test, and teardown in the scope of that object - allows you to provide test fixtures to each test without messing with global data; kudos to Martin Häcker for the contribution
* qunit: added missing semicolons
* qunit: fixed a semicolon, that should have been a comma
* QUnit: implemented error handling for Opera as proposed by #3628
* qunit: fix for http://dev.jquery.com/ticket/3215 changing wording of testresults, to something more positive (x of y passed, z failed)
* QUnit: testrunner.js: Ensures equality of types (String, Boolean, Number) declared with the 'new' prefix. See comments #3, #4 and #5 on http://philrathe.com/articles/equiv
* qunit: wrap name of test in span when a module is used for better styling
* qunit: auto-prepend default mark (#header, #banner, #userAgent, #tests) when not present
* Landing some changes to add logging to QUnit (so that it's easier to hook in to when a test finishes).
* Added checkbox for hiding missing tests (tests that fail with the text 'missing test - untested code is broken code')
* qunit: eol-style:native and mime-type
* HTML being injected for the test result wasn't valid HTML.
* qunit: setting mimetype for testsuite.css
* qunit: update to Ariel's noglobals patch to support async tests as well
* Landing Ariel's change - checks for global variable leakage.
* qunit: run module-teardown in its own synchronize block to synchronize with async tests (ugh)
* qunit: same: equiv - completely refactored in the testrunner.
* testrunner.js: - Update equiv to support Date and RegExp. - Change behavior when comparing function: - abort when in an instance of Object (when references comparison failed) - skip otherwise (like before)
* qunit: code refactoring and cleanup
* QUnit: update equiv to latest version, handling multiple arguments and NaN, see http://philrathe.com/articles/equiv
* QUnit: cleanup, deprecating compare, compare2 and serialArray: usage now throws an error with a helpful message
* QUnit: optional timeout argument for stop, while making tests undetermined, useful for debugging
* QUnit: added toolbar with "hide passed tests" checkbox to help focus on failed tests
* QUnit: minor output formatting
* QUnit: adding same-assertion for a recursive comparsion of primite values, arrays and objects, thanks to Philippe Rathé for the contribution, including tests
* QUnit: adding same-assertion for a recursive comparsion of primite values, arrays and objects, thanks to Philippe Rathé for the contribution, including tests
* QUnit: adding same-assertion for a recursive comparsion of primite values, arrays and objects, thanks to Philippe Rathé for the contribution, including tests
* qunit: use window.load to initialize tests, allowing other code to run on document-ready before starting to run tests
* qunit: allow either setup or teardown, instead of both or nothing
* qunit: make everything private by default, expose only public API; removed old timeout-option (non-deterministic, disabled for a long time anyway); use local $ reference instead of global jQuery reference; minor code cleanup (var config instead of _config; queue.shift instead of slice)
* qunit: added support for module level setup/teardown callbacks
* qunit: modified example for equals to avoid confusion with parameter ordering
* qunit: added id/classes to result element to enable integration with browser automation tools, see http://docs.jquery.com/QUnit#Integration_into_Browser_Automation_Tools
* qunit: replaced $ alias with jQuery (merged from jquery/test/data/testrunner.js)
* qunit: fixed inline documentation for equals
* qunit testrunner - catch and log possible error during reset()
* QUnit: Switched out Date and Rev for Id.
* qunit: when errors are thrown in a test, the message is successfully show on all browsers.
* qunit: added license header
* qunit: moved jquery testrunner to top-level project, see http://docs.jquery.com/QUnit
* Share project 'qunit' into 'https://jqueryjs.googlecode.com/svn'

View File

@ -0,0 +1,63 @@
[QUnit](http://qunitjs.com) - A JavaScript Unit Testing Framework.
================================
QUnit is a powerful, easy-to-use, JavaScript unit testing framework. 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, e.g.
with its 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).
Development
-----------
To submit patches, fork the repository, create a branch for the change. Then implement
the change, run `grunt` to lint and test it, then commit, push and create a pull request.
Include some background for the change in the commit message and `Fixes #nnn`, referring
to the issue number you're addressing.
To run `grunt`, you need `node` and `npm`, then `npm install grunt -g`. That gives you a global
grunt binary. For additional grunt tasks, also run `npm install`.
Releases
--------
Install git-extras and run `git changelog` to update History.md. Clean up the
changelog, removing merge commits or whitespace cleanups.
Update qunit/qunit.js|css and package.json to the release version, commit and
tag (Put the 'v' in front of the tag, e.g. `v1.8.0`), update them again to
the next version, commit and push commits and tags:
git push --tags origin master
To upload to code.jquery.com (replace $version accordingly), ssh to code.origin.jquery.com:
cp qunit/qunit.js /var/www/html/code.jquery.com/qunit/qunit-$version.js
cp qunit/qunit.css /var/www/html/code.jquery.com/qunit/qunit-$version.css
Then update /var/www/html/code.jquery.com/index.html and purge it with:
curl -s http://code.origin.jquery.com/?reload
Update web-base-template to link to those files for qunitjs.com.
Publish to npm via
npm publish

View File

@ -0,0 +1,101 @@
/*global config:true, task:true*/
module.exports = function( grunt ) {
grunt.loadNpmTasks( "grunt-git-authors" );
grunt.initConfig({
pkg: '<json:package.json>',
qunit: {
qunit: [
'test/index.html',
'test/async.html'
// TODO figure out why this fails on our Jenkins server (Linux)
// 'test/logs.html'
],
addons: [
'addons/canvas/canvas.html',
'addons/close-enough/close-enough.html',
'addons/composite/composite-demo-test.html'
// TODO same as above
// 'addons/step/step.html'
]
},
lint: {
qunit: 'qunit/qunit.js',
addons: 'addons/**.js',
tests: 'test/**.js',
grunt: 'grunt.js'
},
// TODO remove this once grunt 0.4 is out, see jquery-ui for other details
jshint: (function() {
function parserc( path ) {
var rc = grunt.file.readJSON( (path || "") + ".jshintrc" ),
settings = {
options: rc,
globals: {}
};
(rc.predef || []).forEach(function( prop ) {
settings.globals[ prop ] = true;
});
delete rc.predef;
return settings;
}
return {
qunit: parserc( "qunit/" ),
addons: parserc( "addons/" ),
tests: parserc( "test/" )
};
})()
});
grunt.registerTask( "build-git", function( sha ) {
function processor( content ) {
var tagline = " - A JavaScript Unit Testing Framework";
return content.replace( tagline, "-" + sha + " " + grunt.template.today('isoDate') + tagline );
}
grunt.file.copy( "qunit/qunit.css", "dist/qunit-git.css", {
process: processor
});
grunt.file.copy( "qunit/qunit.js", "dist/qunit-git.js", {
process: processor
});
});
grunt.registerTask( "testswarm", function( commit, configFile ) {
var testswarm = require( "testswarm" ),
config = grunt.file.readJSON( configFile ).qunit,
runs = {},
done = this.async();
["index", "async"].forEach(function (suite) {
runs[suite] = config.testUrl + commit + "/test/" + suite + ".html";
});
testswarm.createClient( {
url: config.swarmUrl,
pollInterval: 10000,
timeout: 1000 * 60 * 30
} )
.addReporter( testswarm.reporters.cli )
.auth( {
id: config.authUsername,
token: config.authToken
} )
.addjob(
{
name: 'QUnit commit #<a href="https://github.com/jquery/qunit/commit/' + commit + '">' + commit.substr( 0, 10 ) + '</a>',
runs: runs,
browserSets: config.browserSets
}, function( err, passed ) {
if ( err ) {
grunt.log.error( err );
}
done( passed );
}
);
});
grunt.registerTask('default', 'lint qunit');
};

View File

@ -0,0 +1,37 @@
{
"name": "qunitjs",
"title": "QUnit",
"description": "An easy-to-use JavaScript Unit Testing framework.",
"version": "1.12.0pre",
"author": {
"name": "jQuery Foundation and other contributors",
"url": "https://github.com/jquery/qunit/blob/master/AUTHORS.txt"
},
"contributors": [
"John Resig <jeresig@gmail.com> (http://ejohn.org/)",
"Jörn Zaefferer <joern.zaefferer@gmail.com> (http://bassistance.de/)"
],
"homepage": "http://qunitjs.com",
"repository": {
"type": "git",
"url": "git://github.com/jquery/qunit.git"
},
"bugs": {
"url": "https://github.com/jquery/qunit/issues"
},
"license": {
"name": "MIT",
"url": "http://www.opensource.org/licenses/mit-license.php"
},
"keywords": [
"testing",
"unit",
"jquery"
],
"main": "qunit/qunit.js",
"devDependencies": {
"grunt": "0.3.x",
"grunt-git-authors": "1.0.0",
"testswarm": "1.0.0-alpha"
}
}

Some files were not shown because too many files have changed in this diff Show More