first global commit
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -0,0 +1 @@
|
||||
.build
|
||||
@@ -0,0 +1,76 @@
|
||||
## History
|
||||
|
||||
- v1.7.1 - October 4 2011
|
||||
- Added a new native adapter which is framework agnostic (can be used with, or without any framework)
|
||||
- Provided bundled files
|
||||
- Added RightJS adapter
|
||||
- Updated supported browser listing
|
||||
- Added sessionStorage support in core instead of optional Amplify.js Store support
|
||||
- Fixed issue with state id generation growing slower over time
|
||||
- Closes #104, #95, #102, #92, #81, #90, #94, #93, #91, #67, #83, #54, #45
|
||||
|
||||
- v1.7.0 - April 1 2011
|
||||
- Added `History.enabled` property (refer to usage section). This reflects whether or not History.js is enabled for our particular browser. For instance, if we have not included support for a HTML4 browser and we are accessing through a HTML4 browser then `History.enabled` will be `false`.
|
||||
- Added (optional but recommended) Data Persistance and Synchronisation Support thanks to [AppendTo's](http://appendto.com/) [Amplify.js](http://amplifyjs.com/) (refer to installation and compatibility sections for details)
|
||||
- Made HTML5 SUIDs more transparent - [Reported](https://github.com/balupton/history.js/issues#issue/34) by [azago](https://github.com/azago) and [Mark Jaquith](http://markjaquith.com/)
|
||||
- Fixed Session Storage Issue - Reported by a whole bunch of different people; [one](https://github.com/balupton/history.js/issues#issue/36), [two](https://github.com/balupton/history.js/issues#issue/37), [three](http://getsatisfaction.com/balupton/topics/history_js_1_6_losing_state_after_manual_page_reload)
|
||||
- Fixed URL Encoding Issue - [Reported](https://github.com/balupton/history.js/issues/#issue/33) by [Rob Madole](http://robmadole.com/)
|
||||
- Disabled support for IE6,7,8 when using the Prototype Adapter (there is nothing we can do about this, it is due to a bug in the prototype library) - [Reported](https://github.com/balupton/history.js/issues#issue/39) by [Sindre Wimberger](http://sindre.at/)
|
||||
- URLs in the State Hashes for HTML4 Browsers are now even shorter - [Discussion](https://github.com/balupton/history.js/issues#issue/28)
|
||||
- Fixed a issue with the MooTools Adapter and JSON with IE7 and IE8
|
||||
|
||||
- v1.6.0 - March 22 2011
|
||||
- Added Zepto adapter thanks to [Matt Garrett](http://twitter.com/#!/matthewgarrett)
|
||||
- The readme now references the supported versions of the libraries we use
|
||||
- Updated vendors to the most recent versions. jQuery 1.5.1 and Mootools 1.3.1
|
||||
- Reverted versions of Safari iOS prior to version 4.3 to be HTML4 browsers, Safari iOS 4.3 is a HTML5 browser
|
||||
- Refined code in History.js and its adapters
|
||||
- Fixed issue with extra state being inserted on Safari 5 requiring an extra click on the back button to go home - [Reported](https://github.com/balupton/history.js/issues#issue/17) by [Rob Madole](http://robmadole.com/)
|
||||
- Fixed issue with Safari 5 and Safari iOS 4 sometimes failing to apply the state change under busy conditions - Solution conceived with [Matt Garrett](http://twitter.com/matthewgarrett)
|
||||
- Fixed issue with HTML4 browsers requiring a query-string in the urls of states - [Reported](https://github.com/balupton/history.js/issues#issue/26) by [azago](https://github.com/azago)
|
||||
- Fixed issue with HTML4 browsers requiring title in the states in order to use state data - [Reported](https://github.com/balupton/history.js/issues#issue/25) by [Jonathan McLaughlin](http://system-werks.com/)
|
||||
- Fixed issue with HTML4 browsers failing is a state is pushed/replaced twice in a row - [Reported](https://github.com/balupton/history.js/issues#issue/17) by [Joey Baker](http://byjoeybaker.com/)
|
||||
- **B/C BREAK:** The `statechange` event now only fires if the state has changed; it no longer fires on page initialisation. This is following the [Firefox 4 History API Changes](http://hacks.mozilla.org/2011/03/history-api-changes-in-firefox-4/) which we agree with - this breaks standard, but makes more sense.
|
||||
|
||||
- v1.5.0 - February 12 2011
|
||||
- Moved to UglifyJS instead of Google Closure
|
||||
- Split HTML4 functionality from HTML5 functionality
|
||||
- Installation details have changed (the filenames are different)
|
||||
|
||||
- v1.4.1 - February 10 2011
|
||||
- Added HTML History API Support for Safari 5 and Safari iOS 4.2.1
|
||||
- Cleaned code a bit (mostly with unit tests)
|
||||
|
||||
- v1.4.0 - February 10 2011
|
||||
- Unit Testing now uses [QUnit](http://docs.jquery.com/Qunit)
|
||||
- Corrected Safari 5 Support
|
||||
- Now uses queues instead of timeouts
|
||||
- This means the API works exactly as expected, no more need to wrap calls in timeouts
|
||||
- Included a Subscribe Form in the Demo for Version Updates via Email
|
||||
- Small updates to Documentation
|
||||
|
||||
- v1.3.1 - February 4 2011
|
||||
- Improved Documentation
|
||||
|
||||
- v1.3.0 - January 31 2011
|
||||
- Support for cleaner HTML4 States
|
||||
|
||||
- v1.2.1 - January 30 2011
|
||||
- Fixed History.log always being called - [reported by dlee](https://github.com/balupton/history.js/issues/#issue/2)
|
||||
- Re-Added `History.go(index)` support
|
||||
|
||||
- v1.2.0 - January 25 2011
|
||||
- Support for HTML4 States in HTML5 Browsers (added test)
|
||||
- Updates of Documentation
|
||||
|
||||
- v1.1.0 - January 24 2011
|
||||
- Developed a series of automated test cases
|
||||
- Fixed issue with traditional anchors
|
||||
- Fixed issue with differing replaceState functionality in HTML4 Browsers
|
||||
- Fixed issue with Google Chrome artefacts being carried over to the initial state
|
||||
- Provided `onstatechange` and `onanchorchange` events
|
||||
|
||||
- v1.0.0 - January 22 2011
|
||||
- Supported `History.pushState` and `History.replaceState` degradation
|
||||
- Supported jQuery, MooTools and Prototype Frameworks
|
||||
|
||||
@@ -0,0 +1,245 @@
|
||||
Welcome to History.js (v1.7.1 - October 4 2011)
|
||||
==================
|
||||
|
||||
[](https://flattr.com/submit/auto?user_id=balupton&url=https://github.com/balupton/history.js&title=History.js&language=&tags=github&category=software)
|
||||
|
||||
|
||||
This project is the successor of [jQuery History](http://balupton.com/projects/jquery-history), it aims to:
|
||||
|
||||
- Follow the [HTML5 History API](https://developer.mozilla.org/en/DOM/Manipulating_the_browser_history) as much as possible
|
||||
- Provide a cross-compatible experience for all HTML5 Browsers (they all implement the HTML5 History API a little bit differently causing different behaviours and sometimes bugs - History.js fixes this ensuring the experience is as expected / the same / great throughout the HTML5 browsers)
|
||||
- Provide a backwards-compatible experience for all HTML4 Browsers using a hash-fallback (including continued support for the HTML5 History API's `data`, `title`, `pushState` and `replaceState`) with the option to [remove HTML4 support if it is not right for your application](https://github.com/balupton/history.js/wiki/Intelligent-State-Handling)
|
||||
- Provide a forwards-compatible experience for HTML4 States to HTML5 States (so if a hash-fallbacked url is accessed by a HTML5 browser it is naturally transformed into its non-hashed url equivalent)
|
||||
- Provide support for as many javascript frameworks as possible via adapters; especially [jQuery](http://jquery.com/), [MooTools](http://mootools.net/), [Prototype](http://www.prototypejs.org/) and [Zepto](http://zeptojs.com/)
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
### Working with History.js:
|
||||
|
||||
``` javascript
|
||||
(function(window,undefined){
|
||||
|
||||
// Prepare
|
||||
var History = window.History; // Note: We are using a capital H instead of a lower h
|
||||
if ( !History.enabled ) {
|
||||
// History.js is disabled for this browser.
|
||||
// This is because we can optionally choose to support HTML4 browsers or not.
|
||||
return false;
|
||||
}
|
||||
|
||||
// Bind to StateChange Event
|
||||
History.Adapter.bind(window,'statechange',function(){ // Note: We are using statechange instead of popstate
|
||||
var State = History.getState(); // Note: We are using History.getState() instead of event.state
|
||||
History.log(State.data, State.title, State.url);
|
||||
});
|
||||
|
||||
// Change our States
|
||||
History.pushState({state:1}, "State 1", "?state=1"); // logs {state:1}, "State 1", "?state=1"
|
||||
History.pushState({state:2}, "State 2", "?state=2"); // logs {state:2}, "State 2", "?state=2"
|
||||
History.replaceState({state:3}, "State 3", "?state=3"); // logs {state:3}, "State 3", "?state=3"
|
||||
History.pushState(null, null, "?state=4"); // logs {}, '', "?state=4"
|
||||
History.back(); // logs {state:3}, "State 3", "?state=3"
|
||||
History.back(); // logs {state:1}, "State 1", "?state=1"
|
||||
History.back(); // logs {}, "Home Page", "?"
|
||||
History.go(2); // logs {state:3}, "State 3", "?state=3"
|
||||
|
||||
})(window);
|
||||
```
|
||||
|
||||
To ajaxify your entire website with the HTML5 History API, History.js and jQuery [this snippet of code](https://gist.github.com/854622) is all you need. It's that easy.
|
||||
|
||||
### How would the above operations look in a HTML5 Browser?
|
||||
|
||||
1. www.mysite.com
|
||||
1. www.mysite.com/?state=1
|
||||
1. www.mysite.com/?state=2
|
||||
1. www.mysite.com/?state=3
|
||||
1. www.mysite.com/?state=4
|
||||
1. www.mysite.com/?state=3
|
||||
1. www.mysite.com/?state=1
|
||||
1. www.mysite.com
|
||||
1. www.mysite.com/?state=3
|
||||
|
||||
> Note: These urls also work in HTML4 browsers and Search Engines. So no need for the hashbang (`#!`) fragment-identifier that google ["recommends"](https://github.com/balupton/history.js/wiki/Intelligent-State-Handling).
|
||||
|
||||
### How would they look in a HTML4 Browser?
|
||||
|
||||
1. www.mysite.com
|
||||
1. www.mysite.com/#?state=1&_suid=1
|
||||
1. www.mysite.com/#?state=2&_suid=2
|
||||
1. www.mysite.com/#?state=3&_suid=3
|
||||
1. www.mysite.com/#?state=4
|
||||
1. www.mysite.com/#?state=3&_suid=3
|
||||
1. www.mysite.com/#?state=1&_suid=1
|
||||
1. www.mysite.com
|
||||
1. www.mysite.com/#?state=3&_suid=3
|
||||
|
||||
> Note 1: These urls also work in HTML5 browsers - we use `replaceState` to transform these HTML4 states into their HTML5 equivalents so the user won't even notice :-)
|
||||
>
|
||||
> Note 2: These urls will be automatically url-encoded in IE6 to prevent certain browser-specific bugs.
|
||||
>
|
||||
> Note 3: Support for HTML4 browsers (this hash fallback) is optional [- why supporting HTML4 browsers could be either good or bad based on my app's use cases](https://github.com/balupton/history.js/wiki/Intelligent-State-Handling)
|
||||
|
||||
### What's the deal with the SUIDs used in the HTML4 States?
|
||||
|
||||
- SUIDs (State Unique Identifiers) are used when we utilise a `title` and/or `data` in our state. Adding a SUID allows us to associate particular states with data and titles while keeping the urls as simple as possible (don't worry it's all tested, working and a lot smarter than I'm making it out to be).
|
||||
- If you aren't utilising `title` or `data` then we don't even include a SUID (as there is no need for it) - as seen by State 4 above :-)
|
||||
- We also shrink the urls to make sure that the smallest url will be used. For instance we will adjust `http://www.mysite.com/#http://www.mysite.com/projects/History.js` to become `http://www.mysite.com/#/projects/History.js` automatically. (again tested, working, and smarter).
|
||||
- It works with domains, subdomains, subdirectories, whatever - doesn't matter where you put it. It's smart.
|
||||
- Safari 5 will also have a SUID appended to the URL, it is entirely transparent but just a visible side-effect. It is required to fix a bug with Safari 5.
|
||||
|
||||
### Is there a working demo?
|
||||
|
||||
- Sure is, give it a download and navigate to the demo directory in your browser :-)
|
||||
- If you are after something a bit more adventurous than a end-user demo, open up the tests directory in your browser and editor - it'll rock your world and show all the vast use cases that History.js supports.
|
||||
|
||||
|
||||
## Download & Installation
|
||||
|
||||
- Download History.js and upload it to your webserver. Download links: [tar.gz](https://github.com/balupton/history.js/tarball/master) or [zip](https://github.com/balupton/history.js/zipball/master)
|
||||
|
||||
- Include History.js
|
||||
|
||||
- For [jQuery](http://jquery.com/) v1.3+
|
||||
|
||||
``` html
|
||||
<script src="http://www.yourwebsite.com/history.js/scripts/bundled/html4+html5/jquery.history.js"></script>
|
||||
```
|
||||
|
||||
- For [Mootools](http://mootools.net/) v1.3+
|
||||
|
||||
``` html
|
||||
<script src="http://www.yourwebsite.com/history.js/scripts/bundled/html4+html5/mootools.history.js"></script>
|
||||
```
|
||||
|
||||
- For [Right.js](http://rightjs.org/) v2.2+
|
||||
|
||||
``` html
|
||||
<script src="http://www.yourwebsite.com/history.js/scripts/bundled/html4+html5/right.history.js"></script>
|
||||
```
|
||||
|
||||
- For [Zepto](http://zeptojs.com/) v0.5+
|
||||
|
||||
``` html
|
||||
<script src="http://www.yourwebsite.com/history.js/scripts/bundled/html4+html5/zepto.history.js"></script>
|
||||
```
|
||||
|
||||
- For everything else
|
||||
|
||||
``` html
|
||||
<script src="http://www.yourwebsite.com/history.js/scripts/bundled/html4+html5/native.history.js"></script>
|
||||
```
|
||||
|
||||
> Note: If you want to only support HTML5 Browsers and not HTML4 Browsers (so no hash fallback support) then just change the `/html4+html5/` part in the urls to just `/html5/`. [Why supporting HTML4 browsers could be either good or bad based on my app's use cases](https://github.com/balupton/history.js/wiki/Intelligent-State-Handling)
|
||||
|
||||
|
||||
## Get Updates
|
||||
|
||||
- For Commit RSS/Atom Updates:
|
||||
- You can subscribe via the [GitHub Commit Atom Feed](http://feeds.feedburner.com/historyjs)
|
||||
- For GitHub News Feed Updates:
|
||||
- You can click the "watch" button up the top right of History.js's [GitHub Project Page](https://github.com/balupton/history.js)
|
||||
|
||||
|
||||
## Get Support
|
||||
|
||||
- History.js is maintained by people like you. If you find a bug, report it to the [GitHub Issue Tracker](https://github.com/balupton/history.js/issues). If you've fixed a bug submit a [Pull Request](https://github.com/balupton/history.js/pulls) and add your fork to the [Network Wiki Page](https://github.com/balupton/history.js/wiki/Network).
|
||||
|
||||
- If you would like paid support and trainings, or have job offers, then refer to the [Network Wiki Page](https://github.com/balupton/history.js/wiki/Network). If you are qualified with History.js, then be sure to add your details to that page too.
|
||||
|
||||
- If your company uses History.js on your projects, and would like to see it grow and prosper (better documentation, bugfixes, upgrades, maintenance, etc.) and would love to become a corporate sponsor then do email sponsor@bevry.me
|
||||
|
||||
- If you would like free support for History.js, then [post your question](http://stackoverflow.com/questions/ask) on [Stackoverflow](http://stackoverflow.com/about) and be sure to use the `history.js` tag when asking your question.
|
||||
|
||||
- If you've created a website that uses History.js, or know of one. Then be sure to add it to the [Showcase Wiki Page](https://github.com/balupton/history.js/wiki/Showcase).
|
||||
|
||||
- If you'd love to +1 or like this project, then be sure to tweet about it and click the "watch" button up the top of its [Project Page](https://github.com/balupton/history.js).
|
||||
|
||||
- For anything else, refer to the [History.js GitHub Wiki Site](https://github.com/balupton/history.js/wiki).
|
||||
|
||||
Thanks! every bit of help really does make a difference!
|
||||
|
||||
|
||||
## Browsers: Tested and Working In
|
||||
|
||||
### HTML5 Browsers
|
||||
|
||||
- Firefox 4+
|
||||
- Chrome 8+
|
||||
- Opera 11.5
|
||||
- Safari 5.0+
|
||||
- Safari iOS 4.3+
|
||||
|
||||
### HTML4 Browsers
|
||||
|
||||
- IE 6, 7, 8, 9
|
||||
- Firefox 3
|
||||
- Opera 10, 11.0
|
||||
- Safari 4
|
||||
- Safari iOS 4.2, 4.1, 4.0, 3.2
|
||||
|
||||
|
||||
## Exposed API
|
||||
|
||||
### Functions
|
||||
|
||||
- `History.pushState(data,title,url)` <br/> Pushes a new state to the browser; `data` can be null or an object, `title` can be null or a string, `url` must be a string
|
||||
- `History.replaceState(data,title,url)` <br/> Replaces the existing state with a new state to the browser; `data` can be null or an object, `title` can be null or a string, `url` must be a string
|
||||
- `History.getState()` <br/> Gets the current state of the browser, returns an object with `data`, `title` and `url`
|
||||
- `History.getHash()` <br/> Gets the current hash of the browser
|
||||
- `History.Adapter.bind(element,event,callback)` <br/> A framework independent event binder, you may either use this or your framework's native event binder.
|
||||
- `History.Adapter.trigger(element,event)` <br/> A framework independent event trigger, you may either use this or your framework's native event trigger.
|
||||
- `History.Adapter.onDomLoad(callback)` <br/> A framework independent onDomLoad binder, you may either use this or your framework's native onDomLoad binder.
|
||||
- `History.back()` <br/> Go back once through the history (same as hitting the browser's back button)
|
||||
- `History.forward()` <br/> Go forward once through the history (same as hitting the browser's forward button)
|
||||
- `History.go(X)` <br/> If X is negative go back through history X times, if X is positive go forwards through history X times
|
||||
- `History.log(...)` <br/> Logs messages to the console, the log element, and fallbacks to alert if neither of those two exist
|
||||
- `History.debug(...)` <br/> Same as `History.log` but only runs if `History.debug.enable === true`
|
||||
|
||||
### Events
|
||||
|
||||
- `window.onstatechange` <br/> Fired when the state of the page changes (does not include hash changes)
|
||||
- `window.onanchorchange` <br/> Fired when the anchor of the page changes (does not include state hashes)
|
||||
|
||||
|
||||
## Notes on Compatibility
|
||||
|
||||
- History.js **solves** the following browser bugs:
|
||||
- HTML5 Browsers
|
||||
- Chrome 8 sometimes does not contain the correct state data when traversing back to the initial state
|
||||
- Safari 5, Safari iOS 4 and Firefox 3 and 4 do not fire the `onhashchange` event when the page is loaded with a hash
|
||||
- Safari 5 and Safari iOS 4 do not fire the `onpopstate` event when the hash has changed unlike the other browsers
|
||||
- Safari 5 and Safari iOS 4 fail to return to the correct state once a hash is replaced by a `replaceState` call / [bug report](https://bugs.webkit.org/show_bug.cgi?id=56249)
|
||||
- Safari 5 and Safari iOS 4 sometimes fail to apply the state change under busy conditions / [bug report](https://bugs.webkit.org/show_bug.cgi?id=42940)
|
||||
- Google Chrome 8,9,10 and Firefox 4 prior to the RC will always fire `onpopstate` once the page has loaded / [change recommendation](http://hacks.mozilla.org/2011/03/history-api-changes-in-firefox-4/)
|
||||
- Safari iOS 4.0, 4.1, 4.2 have a working HTML5 History API - although the actual back buttons of the browsers do not work, therefore we treat them as HTML4 browsers
|
||||
- None of the HTML5 browsers actually utilise the `title` argument to the `pushState` and `replaceState` calls
|
||||
- HTML4 Browsers
|
||||
- Old browsers like MSIE 6,7 and Firefox 2 do not have a `onhashchange` event
|
||||
- MSIE 6 and 7 sometimes do not apply a hash even it was told to (requiring a second call to the apply function)
|
||||
- Non-Opera HTML4 browsers sometimes do not apply the hash when the hash is not `urlencoded`
|
||||
- All Browsers
|
||||
- State data and titles do not persist once the site is left and then returned (includes page refreshes)
|
||||
- State titles are never applied to the `document.title`
|
||||
- ReplaceState functionality is emulated in HTML4 browsers by discarding the replaced state, so when the discarded state is accessed it is skipped using the appropriate `History.back()` / `History.forward()` call
|
||||
- Data persistance and synchronisation works like so: Every second or so, the SUIDs and URLs of the states will synchronise between the store and the local session. When a new session opens a familiar state (via the SUID or the URL) and it is not found locally then it will attempt to load the last known stored state with that information.
|
||||
- URLs will be unescaped to the maximum, so for instance the URL `?key=a%20b%252c` will become `?key=a b c`. This is to ensure consistency between browser url encodings.
|
||||
- Changing the hash of the page causes `onpopstate` to fire (this is expected/standard functionality). To ensure correct compatibility between HTML5 and HTML4 browsers the following events have been created:
|
||||
- `window.onstatechange`: this is the same as the `onpopstate` event except it does not fire for traditional anchors
|
||||
- `window.onanchorchange`: this is the same as the `onhashchange` event except it does not fire for states
|
||||
- Known Issues
|
||||
- Opera 11 fails to create history entries when under stressful loads (events fire perfectly, just the history events fail) - there is nothing we can do about this
|
||||
- Mercury iOS fails to apply url changes (hashes and HTML5 History API states) - there is nothing we can do about this
|
||||
|
||||
|
||||
|
||||
## History
|
||||
|
||||
You can discover the history inside the [History.md](https://github.com/balupton/history.js/blob/master/History.md#files) file
|
||||
|
||||
|
||||
## License
|
||||
|
||||
Licensed under the [New BSD License](http://opensource.org/licenses/BSD-3-Clause)
|
||||
<br/>Copyright © 2011-2012 [Benjamin Arthur Lupton](http://balupton.com)
|
||||
+281
@@ -0,0 +1,281 @@
|
||||
# Requires
|
||||
buildr = require 'buildr'
|
||||
util = require 'util'
|
||||
|
||||
# Options
|
||||
options =
|
||||
watch: false
|
||||
compress: true
|
||||
|
||||
# Configs
|
||||
configs =
|
||||
standard:
|
||||
# Options
|
||||
name: 'standard'
|
||||
watch: options.watch
|
||||
|
||||
# Paths
|
||||
srcPath: __dirname+'/scripts/uncompressed'
|
||||
outPath: __dirname+'/scripts/compressed'
|
||||
|
||||
# Checking
|
||||
checkScripts: true
|
||||
jshintOptions:
|
||||
browser: true
|
||||
laxbreak: true
|
||||
boss: true
|
||||
undef: true
|
||||
onevar: true
|
||||
strict: true
|
||||
noarg: true
|
||||
|
||||
# Compression (without outPath only the generated bundle files are compressed)
|
||||
compressScripts: options.compress # Array or true or false
|
||||
|
||||
other: [
|
||||
|
||||
# -----------------------------
|
||||
# JQUERY
|
||||
|
||||
{
|
||||
# Options
|
||||
name: 'html4+html5+jquery'
|
||||
watch: options.watch
|
||||
|
||||
# Paths
|
||||
srcPath: __dirname+'/scripts/uncompressed'
|
||||
|
||||
# Compression (without outPath only the generated bundle files are compressed)
|
||||
compressScripts: options.compress # Array or true or false
|
||||
|
||||
# Order
|
||||
scriptsOrder: [
|
||||
'json2.js'
|
||||
'history.adapter.jquery.js'
|
||||
'history.html4.js'
|
||||
'history.js'
|
||||
]
|
||||
|
||||
# Bundling
|
||||
bundleScriptPath: __dirname+'/scripts/bundled/html4+html5/jquery.history.js'
|
||||
}
|
||||
{
|
||||
# Options
|
||||
name: 'html5+jquery'
|
||||
watch: options.watch
|
||||
|
||||
# Paths
|
||||
srcPath: __dirname+'/scripts/uncompressed'
|
||||
|
||||
# Compression (without outPath only the generated bundle files are compressed)
|
||||
compressScripts: options.compress # Array or true or false
|
||||
|
||||
# Order
|
||||
scriptsOrder: [
|
||||
'history.adapter.jquery.js'
|
||||
'history.js'
|
||||
]
|
||||
|
||||
# Bundling
|
||||
bundleScriptPath: __dirname+'/scripts/bundled/html5/jquery.history.js'
|
||||
}
|
||||
|
||||
|
||||
# -----------------------------
|
||||
# MOOTOOLS
|
||||
|
||||
{
|
||||
# Options
|
||||
name: 'html4+html5+mootools'
|
||||
watch: options.watch
|
||||
|
||||
# Paths
|
||||
srcPath: __dirname+'/scripts/uncompressed'
|
||||
|
||||
# Compression (without outPath only the generated bundle files are compressed)
|
||||
compressScripts: options.compress # Array or true or false
|
||||
|
||||
# Order
|
||||
scriptsOrder: [
|
||||
'json2.js'
|
||||
'history.adapter.mootools.js'
|
||||
'history.html4.js'
|
||||
'history.js'
|
||||
]
|
||||
|
||||
# Bundling
|
||||
bundleScriptPath: __dirname+'/scripts/bundled/html4+html5/mootools.history.js'
|
||||
}
|
||||
{
|
||||
# Options
|
||||
name: 'html5+mootools'
|
||||
watch: options.watch
|
||||
|
||||
# Paths
|
||||
srcPath: __dirname+'/scripts/uncompressed'
|
||||
|
||||
# Compression (without outPath only the generated bundle files are compressed)
|
||||
compressScripts: options.compress # Array or true or false
|
||||
|
||||
# Order
|
||||
scriptsOrder: [
|
||||
'history.adapter.mootools.js'
|
||||
'history.js'
|
||||
]
|
||||
|
||||
# Bundling
|
||||
bundleScriptPath: __dirname+'/scripts/bundled/html5/mootools.history.js'
|
||||
}
|
||||
|
||||
|
||||
# -----------------------------
|
||||
# NATIVE
|
||||
|
||||
{
|
||||
# Options
|
||||
name: 'html4+html5+native'
|
||||
watch: options.watch
|
||||
|
||||
# Paths
|
||||
srcPath: __dirname+'/scripts/uncompressed'
|
||||
|
||||
# Compression (without outPath only the generated bundle files are compressed)
|
||||
compressScripts: options.compress # Array or true or false
|
||||
|
||||
# Order
|
||||
scriptsOrder: [
|
||||
'json2.js'
|
||||
'history.adapter.native.js'
|
||||
'history.html4.js'
|
||||
'history.js'
|
||||
]
|
||||
|
||||
# Bundling
|
||||
bundleScriptPath: __dirname+'/scripts/bundled/html4+html5/native.history.js'
|
||||
}
|
||||
{
|
||||
# Options
|
||||
name: 'html5+native'
|
||||
watch: options.watch
|
||||
|
||||
# Paths
|
||||
srcPath: __dirname+'/scripts/uncompressed'
|
||||
|
||||
# Compression (without outPath only the generated bundle files are compressed)
|
||||
compressScripts: options.compress # Array or true or false
|
||||
|
||||
# Order
|
||||
scriptsOrder: [
|
||||
'history.adapter.native.js'
|
||||
'history.js'
|
||||
]
|
||||
|
||||
# Bundling
|
||||
bundleScriptPath: __dirname+'/scripts/bundled/html5/native.history.js'
|
||||
}
|
||||
|
||||
|
||||
# -----------------------------
|
||||
# RIGHT.JS
|
||||
|
||||
{
|
||||
# Options
|
||||
name: 'html4+html5+right'
|
||||
watch: options.watch
|
||||
|
||||
# Paths
|
||||
srcPath: __dirname+'/scripts/uncompressed'
|
||||
|
||||
# Compression (without outPath only the generated bundle files are compressed)
|
||||
compressScripts: options.compress # Array or true or false
|
||||
|
||||
# Order
|
||||
scriptsOrder: [
|
||||
'json2.js'
|
||||
'history.adapter.right.js'
|
||||
'history.html4.js'
|
||||
'history.js'
|
||||
]
|
||||
|
||||
# Bundling
|
||||
bundleScriptPath: __dirname+'/scripts/bundled/html4+html5/right.history.js'
|
||||
}
|
||||
{
|
||||
# Options
|
||||
name: 'html5+right'
|
||||
watch: options.watch
|
||||
|
||||
# Paths
|
||||
srcPath: __dirname+'/scripts/uncompressed'
|
||||
|
||||
# Compression (without outPath only the generated bundle files are compressed)
|
||||
compressScripts: options.compress # Array or true or false
|
||||
|
||||
# Order
|
||||
scriptsOrder: [
|
||||
'history.adapter.right.js'
|
||||
'history.js'
|
||||
]
|
||||
|
||||
# Bundling
|
||||
bundleScriptPath: __dirname+'/scripts/bundled/html5/right.history.js'
|
||||
}
|
||||
|
||||
|
||||
# -----------------------------
|
||||
# ZEPTO
|
||||
|
||||
{
|
||||
# Options
|
||||
name: 'html4+html5+zepto'
|
||||
watch: options.watch
|
||||
|
||||
# Paths
|
||||
srcPath: __dirname+'/scripts/uncompressed'
|
||||
|
||||
# Compression (without outPath only the generated bundle files are compressed)
|
||||
compressScripts: options.compress # Array or true or false
|
||||
|
||||
# Order
|
||||
scriptsOrder: [
|
||||
'json2.js'
|
||||
'history.adapter.zepto.js'
|
||||
'history.html4.js'
|
||||
'history.js'
|
||||
]
|
||||
|
||||
# Bundling
|
||||
bundleScriptPath: __dirname+'/scripts/bundled/html4+html5/zepto.history.js'
|
||||
}
|
||||
{
|
||||
# Options
|
||||
name: 'html5+zepto'
|
||||
watch: options.watch
|
||||
|
||||
# Paths
|
||||
srcPath: __dirname+'/scripts/uncompressed'
|
||||
|
||||
# Compression (without outPath only the generated bundle files are compressed)
|
||||
compressScripts: options.compress # Array or true or false
|
||||
|
||||
# Order
|
||||
scriptsOrder: [
|
||||
'history.adapter.zepto.js'
|
||||
'history.js'
|
||||
]
|
||||
|
||||
# Bundling
|
||||
bundleScriptPath: __dirname+'/scripts/bundled/html5/zepto.history.js'
|
||||
}
|
||||
]
|
||||
|
||||
# Standard
|
||||
standardConfig = configs.standard
|
||||
standardConfig.successHandler = ->
|
||||
for config in configs.other
|
||||
buildrInstance = buildr.createInstance config
|
||||
buildrInstance.process()
|
||||
|
||||
# Process
|
||||
standardBuildr = buildr.createInstance configs.standard
|
||||
standardBuildr.process()
|
||||
+58
@@ -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>
|
||||
+62
@@ -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>
|
||||
+37
@@ -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>
|
||||
+86
@@ -0,0 +1,86 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<title>
|
||||
History.js
|
||||
</title>
|
||||
</head>
|
||||
<body style="padding-bottom:40px">
|
||||
<!-- Scripts -->
|
||||
<script>if ( typeof window.JSON === 'undefined' ) { document.write('<script src="../scripts/uncompressed/json2.js"><\/script>'); }</script>
|
||||
<script src="../vendor/jquery.js"></script>
|
||||
<script src="../scripts/bundled/html4+html5/jquery.history.js"></script>
|
||||
|
||||
<!-- HTML -->
|
||||
<div id="wrap">
|
||||
<!-- Intro -->
|
||||
<h1><a href="https://github.com/balupton/History.js">History.js</a> by <a href="http://balupton.com">Benjamin Lupton</a></h1>
|
||||
<p>History.js gracefully supports the <a href="https://developer.mozilla.org/en/DOM/Manipulating_the_browser_history">HTML5 History/State APIs</a> (pushState, replaceState, onPopState) in all browsers. Including continued support for data, titles, replaceState. Supports <a href="http://jquery.com/">jQuery</a>, <a href="http://mootools.net">MooTools</a> and <a href="http://prototypejs.org">Prototype</a>. For HTML5 browsers this means that you can modify the URL directly, without needing to use hashes anymore. For HTML4 browsers it will revert back to using the old onhashchange functionality.</p>
|
||||
|
||||
<!-- Textarea for Logging -->
|
||||
<textarea id="log" style="width:100%;height:400px"></textarea>
|
||||
|
||||
<!-- Note -->
|
||||
<p>Click through the buttons in order and you'll get the results demonstrated in the <a href="../README.md">README.md</a> file.</p>
|
||||
|
||||
<!-- Buttons -->
|
||||
<ul id="buttons">
|
||||
</ul>
|
||||
|
||||
<!-- Our Script -->
|
||||
<script>
|
||||
(function(window,undefined){
|
||||
|
||||
// Check Location
|
||||
if ( document.location.protocol === 'file:' ) {
|
||||
alert('The HTML5 History API (and thus History.js) do not work on files, please upload it to a server.');
|
||||
}
|
||||
|
||||
// Establish Variables
|
||||
var
|
||||
History = window.History, // Note: We are using a capital H instead of a lower h
|
||||
State = History.getState(),
|
||||
$log = $('#log');
|
||||
|
||||
// Log Initial State
|
||||
History.log('initial:', State.data, State.title, State.url);
|
||||
|
||||
// Bind to State Change
|
||||
History.Adapter.bind(window,'statechange',function(){ // Note: We are using statechange instead of popstate
|
||||
// Log the State
|
||||
var State = History.getState(); // Note: We are using History.getState() instead of event.state
|
||||
History.log('statechange:', State.data, State.title, State.url);
|
||||
});
|
||||
|
||||
// Prepare Buttons
|
||||
var
|
||||
buttons = document.getElementById('buttons'),
|
||||
scripts = [
|
||||
'History.pushState({state:1,rand:Math.random()}, "State 1", "?state=1"); // logs {state:1,rand:"some random value"}, "State 1", "?state=1"',
|
||||
'History.pushState({state:2,rand:Math.random()}, "State 2", "?state=2"); // logs {state:2,rand:"some random value"}, "State 2", "?state=2"',
|
||||
'History.replaceState({state:3,rand:Math.random()}, "State 3", "?state=3"); // logs {state:3,rand:"some random value"}, "State 3", "?state=3"',
|
||||
'History.pushState(null, null, "?state=4"); // logs {}, "", "?state=4"',
|
||||
'History.back(); // logs {state:3}, "State 3", "?state=3"',
|
||||
'History.back(); // logs {state:1}, "State 1", "?state=1"',
|
||||
'History.back(); // logs {}, "The page you started at", "?"',
|
||||
'History.go(2); // logs {state:3}, "State 3", "?state=3"'
|
||||
],
|
||||
buttonsHTML = ''
|
||||
;
|
||||
|
||||
// Add Buttons
|
||||
for ( var i=0,n=scripts.length; i<n; ++i ) {
|
||||
var _script = scripts[i];
|
||||
buttonsHTML +=
|
||||
'<li><button onclick=\'javascript:'+_script+'\'>'+_script+'</button></li>';
|
||||
}
|
||||
buttons.innerHTML = buttonsHTML;
|
||||
|
||||
})(window);
|
||||
</script>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
+43
@@ -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>
|
||||
+62
@@ -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>
|
||||
+23
@@ -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>
|
||||
+61
@@ -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>
|
||||
@@ -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.
|
||||
@@ -0,0 +1,57 @@
|
||||
{
|
||||
"name": "history.js",
|
||||
"version": "1.7.1-r2",
|
||||
"description": "History.js gracefully supports the HTML5 History/State APIs (pushState, replaceState, onPopState) in all browsers. Including continued support for data, titles, replaceState. Supports jQuery, MooTools and Prototype. For HTML5 browsers this means that you can modify the URL directly, without needing to use hashes anymore. For HTML4 browsers it will revert back to using the old onhashchange functionality.",
|
||||
"homepage": "https://github.com/balupton/history.js",
|
||||
"keywords": [
|
||||
"javascript",
|
||||
"html5 history api",
|
||||
"hashchange",
|
||||
"popstate",
|
||||
"pushstate",
|
||||
"replacestate",
|
||||
"hashes",
|
||||
"hashbang"
|
||||
],
|
||||
"author": {
|
||||
"name": "Benjamin Lupton",
|
||||
"email": "b@lupton.cc",
|
||||
"web": "http://balupton.com"
|
||||
},
|
||||
"maintainers": [
|
||||
{
|
||||
"name": "Benjamin Lupton",
|
||||
"email": "b@lupton.cc",
|
||||
"web": "http://balupton.com"
|
||||
}
|
||||
],
|
||||
"contributors": [
|
||||
{
|
||||
"name": "Benjamin Lupton",
|
||||
"email": "b@lupton.cc",
|
||||
"web": "http://balupton.com"
|
||||
}
|
||||
],
|
||||
"bugs": {
|
||||
"web": "https://github.com/balupton/history.js/issues"
|
||||
},
|
||||
"licenses": [
|
||||
{
|
||||
"type": "New-BSD",
|
||||
"url": "http://creativecommons.org/licenses/BSD/"
|
||||
}
|
||||
],
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "http://github.com/balupton/history.js.git"
|
||||
},
|
||||
"dependencies": {
|
||||
"buildr": "0.8.x"
|
||||
},
|
||||
"engines": {
|
||||
},
|
||||
"directories": {
|
||||
"out": "./scripts/compressed",
|
||||
"src": "./scripts/uncompressed"
|
||||
}
|
||||
}
|
||||
+1
File diff suppressed because one or more lines are too long
+1
File diff suppressed because one or more lines are too long
+1
File diff suppressed because one or more lines are too long
+1
File diff suppressed because one or more lines are too long
+1
File diff suppressed because one or more lines are too long
+1
File diff suppressed because one or more lines are too long
+1
File diff suppressed because one or more lines are too long
+1
File diff suppressed because one or more lines are too long
sites/all/themes/gui/perfarttimeline/js/libs/balupton-history/scripts/bundled/html5/right.history.js
Executable
+1
File diff suppressed because one or more lines are too long
sites/all/themes/gui/perfarttimeline/js/libs/balupton-history/scripts/bundled/html5/zepto.history.js
Executable
+1
File diff suppressed because one or more lines are too long
+1
@@ -0,0 +1 @@
|
||||
(function(a,b){"use strict";var c=a.History=a.History||{},d=a.jQuery;if(typeof c.Adapter!="undefined")throw new Error("History.js Adapter has already been loaded...");c.Adapter={bind:function(a,b,c){d(a).bind(b,c)},trigger:function(a,b,c){d(a).trigger(b,c)},extractEventData:function(a,c,d){var e=c&&c.originalEvent&&c.originalEvent[a]||d&&d[a]||b;return e},onDomLoad:function(a){d(a)}},typeof c.init!="undefined"&&c.init()})(window)
|
||||
+1
@@ -0,0 +1 @@
|
||||
(function(a,b){"use strict";var c=a.History=a.History||{},d=a.MooTools,e=a.Element;if(typeof c.Adapter!="undefined")throw new Error("History.js Adapter has already been loaded...");Object.append(e.NativeEvents,{popstate:2,hashchange:2}),c.Adapter={bind:function(a,b,c){var d=typeof a=="string"?document.id(a):a;d.addEvent(b,c)},trigger:function(a,b,c){var d=typeof a=="string"?document.id(a):a;d.fireEvent(b,c)},extractEventData:function(a,c){var d=c&&c.event&&c.event[a]||c&&c[a]||b;return d},onDomLoad:function(b){a.addEvent("domready",b)}},typeof c.init!="undefined"&&c.init()})(window)
|
||||
+1
@@ -0,0 +1 @@
|
||||
(function(a,b){"use strict";var c=a.History=a.History||{};if(typeof c.Adapter!="undefined")throw new Error("History.js Adapter has already been loaded...");c.Adapter={handlers:{},_uid:1,uid:function(a){return a._uid||(a._uid=c.Adapter._uid++)},bind:function(a,b,d){var e=c.Adapter.uid(a);c.Adapter.handlers[e]=c.Adapter.handlers[e]||{},c.Adapter.handlers[e][b]=c.Adapter.handlers[e][b]||[],c.Adapter.handlers[e][b].push(d),a["on"+b]=function(a,b){return function(d){c.Adapter.trigger(a,b,d)}}(a,b)},trigger:function(a,b,d){d=d||{};var e=c.Adapter.uid(a),f,g;c.Adapter.handlers[e]=c.Adapter.handlers[e]||{},c.Adapter.handlers[e][b]=c.Adapter.handlers[e][b]||[];for(f=0,g=c.Adapter.handlers[e][b].length;f<g;++f)c.Adapter.handlers[e][b][f].apply(this,[d])},extractEventData:function(a,c){var d=c&&c[a]||b;return d},onDomLoad:function(b){var c=a.setTimeout(function(){b()},2e3);a.onload=function(){clearTimeout(c),b()}}},typeof c.init!="undefined"&&c.init()})(window)
|
||||
+1
@@ -0,0 +1 @@
|
||||
(function(a,b){"use strict";var c=a.History=a.History||{},d=a.document,e=a.RightJS,f=e.$;if(typeof c.Adapter!="undefined")throw new Error("History.js Adapter has already been loaded...");c.Adapter={bind:function(a,b,c){f(a).on(b,c)},trigger:function(a,b,c){f(a).fire(b,c)},extractEventData:function(a,c){var d=c&&c._&&c._[a]||b;return d},onDomLoad:function(a){f(d).onReady(a)}},typeof c.init!="undefined"&&c.init()})(window)
|
||||
+1
@@ -0,0 +1 @@
|
||||
(function(a,b){"use strict";var c=a.History=a.History||{},d=a.Zepto;if(typeof c.Adapter!="undefined")throw new Error("History.js Adapter has already been loaded...");c.Adapter={bind:function(a,b,c){(new d(a)).bind(b,c)},trigger:function(a,b){(new d(a)).trigger(b)},extractEventData:function(a,c){var d=c&&c[a]||b;return d},onDomLoad:function(a){new d(a)}},typeof c.init!="undefined"&&c.init()})(window)
|
||||
Executable
+1
@@ -0,0 +1 @@
|
||||
(function(a,b){"use strict";var c=a.document,d=a.setTimeout||d,e=a.clearTimeout||e,f=a.setInterval||f,g=a.History=a.History||{};if(typeof g.initHtml4!="undefined")throw new Error("History.js HTML4 Support has already been loaded...");g.initHtml4=function(){if(typeof g.initHtml4.initialized!="undefined")return!1;g.initHtml4.initialized=!0,g.enabled=!0,g.savedHashes=[],g.isLastHash=function(a){var b=g.getHashByIndex(),c;return c=a===b,c},g.saveHash=function(a){return g.isLastHash(a)?!1:(g.savedHashes.push(a),!0)},g.getHashByIndex=function(a){var b=null;return typeof a=="undefined"?b=g.savedHashes[g.savedHashes.length-1]:a<0?b=g.savedHashes[g.savedHashes.length+a]:b=g.savedHashes[a],b},g.discardedHashes={},g.discardedStates={},g.discardState=function(a,b,c){var d=g.getHashByState(a),e;return e={discardedState:a,backState:c,forwardState:b},g.discardedStates[d]=e,!0},g.discardHash=function(a,b,c){var d={discardedHash:a,backState:c,forwardState:b};return g.discardedHashes[a]=d,!0},g.discardedState=function(a){var b=g.getHashByState(a),c;return c=g.discardedStates[b]||!1,c},g.discardedHash=function(a){var b=g.discardedHashes[a]||!1;return b},g.recycleState=function(a){var b=g.getHashByState(a);return g.discardedState(a)&&delete g.discardedStates[b],!0},g.emulated.hashChange&&(g.hashChangeInit=function(){g.checkerFunction=null;var b="",d,e,h,i;return g.isInternetExplorer()?(d="historyjs-iframe",e=c.createElement("iframe"),e.setAttribute("id",d),e.style.display="none",c.body.appendChild(e),e.contentWindow.document.open(),e.contentWindow.document.close(),h="",i=!1,g.checkerFunction=function(){if(i)return!1;i=!0;var c=g.getHash()||"",d=g.unescapeHash(e.contentWindow.document.location.hash)||"";return c!==b?(b=c,d!==c&&(h=d=c,e.contentWindow.document.open(),e.contentWindow.document.close(),e.contentWindow.document.location.hash=g.escapeHash(c)),g.Adapter.trigger(a,"hashchange")):d!==h&&(h=d,g.setHash(d,!1)),i=!1,!0}):g.checkerFunction=function(){var c=g.getHash();return c!==b&&(b=c,g.Adapter.trigger(a,"hashchange")),!0},g.intervalList.push(f(g.checkerFunction,g.options.hashChangeInterval)),!0},g.Adapter.onDomLoad(g.hashChangeInit)),g.emulated.pushState&&(g.onHashChange=function(b){var d=b&&b.newURL||c.location.href,e=g.getHashByUrl(d),f=null,h=null,i=null,j;return g.isLastHash(e)?(g.busy(!1),!1):(g.doubleCheckComplete(),g.saveHash(e),e&&g.isTraditionalAnchor(e)?(g.Adapter.trigger(a,"anchorchange"),g.busy(!1),!1):(f=g.extractState(g.getFullUrl(e||c.location.href,!1),!0),g.isLastSavedState(f)?(g.busy(!1),!1):(h=g.getHashByState(f),j=g.discardedState(f),j?(g.getHashByIndex(-2)===g.getHashByState(j.forwardState)?g.back(!1):g.forward(!1),!1):(g.pushState(f.data,f.title,f.url,!1),!0))))},g.Adapter.bind(a,"hashchange",g.onHashChange),g.pushState=function(b,d,e,f){if(g.getHashByUrl(e))throw new Error("History.js does not support states with fragement-identifiers (hashes/anchors).");if(f!==!1&&g.busy())return g.pushQueue({scope:g,callback:g.pushState,args:arguments,queue:f}),!1;g.busy(!0);var h=g.createStateObject(b,d,e),i=g.getHashByState(h),j=g.getState(!1),k=g.getHashByState(j),l=g.getHash();return g.storeState(h),g.expectedStateId=h.id,g.recycleState(h),g.setTitle(h),i===k?(g.busy(!1),!1):i!==l&&i!==g.getShortUrl(c.location.href)?(g.setHash(i,!1),!1):(g.saveState(h),g.Adapter.trigger(a,"statechange"),g.busy(!1),!0)},g.replaceState=function(a,b,c,d){if(g.getHashByUrl(c))throw new Error("History.js does not support states with fragement-identifiers (hashes/anchors).");if(d!==!1&&g.busy())return g.pushQueue({scope:g,callback:g.replaceState,args:arguments,queue:d}),!1;g.busy(!0);var e=g.createStateObject(a,b,c),f=g.getState(!1),h=g.getStateByIndex(-2);return g.discardState(f,e,h),g.pushState(e.data,e.title,e.url,!1),!0}),g.emulated.pushState&&g.getHash()&&!g.emulated.hashChange&&g.Adapter.onDomLoad(function(){g.Adapter.trigger(a,"hashchange")})},typeof g.init!="undefined"&&g.init()})(window)
|
||||
Executable
+1
File diff suppressed because one or more lines are too long
Executable
+1
@@ -0,0 +1 @@
|
||||
window.JSON||(window.JSON={}),function(){function f(a){return a<10?"0"+a:a}function quote(a){return escapable.lastIndex=0,escapable.test(a)?'"'+a.replace(escapable,function(a){var b=meta[a];return typeof b=="string"?b:"\\u"+("0000"+a.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+a+'"'}function str(a,b){var c,d,e,f,g=gap,h,i=b[a];i&&typeof i=="object"&&typeof i.toJSON=="function"&&(i=i.toJSON(a)),typeof rep=="function"&&(i=rep.call(b,a,i));switch(typeof i){case"string":return quote(i);case"number":return isFinite(i)?String(i):"null";case"boolean":case"null":return String(i);case"object":if(!i)return"null";gap+=indent,h=[];if(Object.prototype.toString.apply(i)==="[object Array]"){f=i.length;for(c=0;c<f;c+=1)h[c]=str(c,i)||"null";return e=h.length===0?"[]":gap?"[\n"+gap+h.join(",\n"+gap)+"\n"+g+"]":"["+h.join(",")+"]",gap=g,e}if(rep&&typeof rep=="object"){f=rep.length;for(c=0;c<f;c+=1)d=rep[c],typeof d=="string"&&(e=str(d,i),e&&h.push(quote(d)+(gap?": ":":")+e))}else for(d in i)Object.hasOwnProperty.call(i,d)&&(e=str(d,i),e&&h.push(quote(d)+(gap?": ":":")+e));return e=h.length===0?"{}":gap?"{\n"+gap+h.join(",\n"+gap)+"\n"+g+"}":"{"+h.join(",")+"}",gap=g,e}}"use strict",typeof Date.prototype.toJSON!="function"&&(Date.prototype.toJSON=function(a){return isFinite(this.valueOf())?this.getUTCFullYear()+"-"+f(this.getUTCMonth()+1)+"-"+f(this.getUTCDate())+"T"+f(this.getUTCHours())+":"+f(this.getUTCMinutes())+":"+f(this.getUTCSeconds())+"Z":null},String.prototype.toJSON=Number.prototype.toJSON=Boolean.prototype.toJSON=function(a){return this.valueOf()});var JSON=window.JSON,cx=/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,escapable=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,gap,indent,meta={"\b":"\\b","\t":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"},rep;typeof JSON.stringify!="function"&&(JSON.stringify=function(a,b,c){var d;gap="",indent="";if(typeof c=="number")for(d=0;d<c;d+=1)indent+=" ";else typeof c=="string"&&(indent=c);rep=b;if(!b||typeof b=="function"||typeof b=="object"&&typeof b.length=="number")return str("",{"":a});throw new Error("JSON.stringify")}),typeof JSON.parse!="function"&&(JSON.parse=function(text,reviver){function walk(a,b){var c,d,e=a[b];if(e&&typeof e=="object")for(c in e)Object.hasOwnProperty.call(e,c)&&(d=walk(e,c),d!==undefined?e[c]=d:delete e[c]);return reviver.call(a,b,e)}var j;text=String(text),cx.lastIndex=0,cx.test(text)&&(text=text.replace(cx,function(a){return"\\u"+("0000"+a.charCodeAt(0).toString(16)).slice(-4)}));if(/^[\],:{}\s]*$/.test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,"@").replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,"]").replace(/(?:^|:|,)(?:\s*\[)+/g,"")))return j=eval("("+text+")"),typeof reviver=="function"?walk({"":j},""):j;throw new SyntaxError("JSON.parse")})}()
|
||||
+77
@@ -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);
|
||||
|
||||
+84
@@ -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);
|
||||
+121
@@ -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 and Initialise History
|
||||
if ( typeof History.init !== 'undefined' ) {
|
||||
History.init();
|
||||
}
|
||||
|
||||
})(window);
|
||||
+78
@@ -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);
|
||||
+74
@@ -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);
|
||||
Executable
+621
@@ -0,0 +1,621 @@
|
||||
/**
|
||||
* History.js HTML4 Support
|
||||
* Depends on the HTML5 Support
|
||||
* @author Benjamin Arthur Lupton <contact@balupton.com>
|
||||
* @copyright 2010-2011 Benjamin Arthur Lupton <contact@balupton.com>
|
||||
* @license New BSD License <http://creativecommons.org/licenses/BSD/>
|
||||
*/
|
||||
|
||||
(function(window,undefined){
|
||||
"use strict";
|
||||
|
||||
// ========================================================================
|
||||
// Initialise
|
||||
|
||||
// Localise Globals
|
||||
var
|
||||
document = window.document, // Make sure we are using the correct document
|
||||
setTimeout = window.setTimeout||setTimeout,
|
||||
clearTimeout = window.clearTimeout||clearTimeout,
|
||||
setInterval = window.setInterval||setInterval,
|
||||
History = window.History = window.History||{}; // Public History Object
|
||||
|
||||
// Check Existence
|
||||
if ( typeof History.initHtml4 !== 'undefined' ) {
|
||||
throw new Error('History.js HTML4 Support has already been loaded...');
|
||||
}
|
||||
|
||||
|
||||
// ========================================================================
|
||||
// Initialise HTML4 Support
|
||||
|
||||
// Initialise HTML4 Support
|
||||
History.initHtml4 = function(){
|
||||
// Initialise
|
||||
if ( typeof History.initHtml4.initialized !== 'undefined' ) {
|
||||
// Already Loaded
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
History.initHtml4.initialized = true;
|
||||
}
|
||||
|
||||
|
||||
// ====================================================================
|
||||
// Properties
|
||||
|
||||
/**
|
||||
* History.enabled
|
||||
* Is History enabled?
|
||||
*/
|
||||
History.enabled = true;
|
||||
|
||||
|
||||
// ====================================================================
|
||||
// Hash Storage
|
||||
|
||||
/**
|
||||
* History.savedHashes
|
||||
* Store the hashes in an array
|
||||
*/
|
||||
History.savedHashes = [];
|
||||
|
||||
/**
|
||||
* History.isLastHash(newHash)
|
||||
* Checks if the hash is the last hash
|
||||
* @param {string} newHash
|
||||
* @return {boolean} true
|
||||
*/
|
||||
History.isLastHash = function(newHash){
|
||||
// Prepare
|
||||
var oldHash = History.getHashByIndex(),
|
||||
isLast;
|
||||
|
||||
// Check
|
||||
isLast = newHash === oldHash;
|
||||
|
||||
// Return isLast
|
||||
return isLast;
|
||||
};
|
||||
|
||||
/**
|
||||
* History.saveHash(newHash)
|
||||
* Push a Hash
|
||||
* @param {string} newHash
|
||||
* @return {boolean} true
|
||||
*/
|
||||
History.saveHash = function(newHash){
|
||||
// Check Hash
|
||||
if ( History.isLastHash(newHash) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Push the Hash
|
||||
History.savedHashes.push(newHash);
|
||||
|
||||
// Return true
|
||||
return true;
|
||||
};
|
||||
|
||||
/**
|
||||
* History.getHashByIndex()
|
||||
* Gets a hash by the index
|
||||
* @param {integer} index
|
||||
* @return {string}
|
||||
*/
|
||||
History.getHashByIndex = function(index){
|
||||
// Prepare
|
||||
var hash = null;
|
||||
|
||||
// Handle
|
||||
if ( typeof index === 'undefined' ) {
|
||||
// Get the last inserted
|
||||
hash = History.savedHashes[History.savedHashes.length-1];
|
||||
}
|
||||
else if ( index < 0 ) {
|
||||
// Get from the end
|
||||
hash = History.savedHashes[History.savedHashes.length+index];
|
||||
}
|
||||
else {
|
||||
// Get from the beginning
|
||||
hash = History.savedHashes[index];
|
||||
}
|
||||
|
||||
// Return hash
|
||||
return hash;
|
||||
};
|
||||
|
||||
|
||||
// ====================================================================
|
||||
// Discarded States
|
||||
|
||||
/**
|
||||
* History.discardedHashes
|
||||
* A hashed array of discarded hashes
|
||||
*/
|
||||
History.discardedHashes = {};
|
||||
|
||||
/**
|
||||
* History.discardedStates
|
||||
* A hashed array of discarded states
|
||||
*/
|
||||
History.discardedStates = {};
|
||||
|
||||
/**
|
||||
* History.discardState(State)
|
||||
* Discards the state by ignoring it through History
|
||||
* @param {object} State
|
||||
* @return {true}
|
||||
*/
|
||||
History.discardState = function(discardedState,forwardState,backState){
|
||||
//History.debug('History.discardState', arguments);
|
||||
// Prepare
|
||||
var discardedStateHash = History.getHashByState(discardedState),
|
||||
discardObject;
|
||||
|
||||
// Create Discard Object
|
||||
discardObject = {
|
||||
'discardedState': discardedState,
|
||||
'backState': backState,
|
||||
'forwardState': forwardState
|
||||
};
|
||||
|
||||
// Add to DiscardedStates
|
||||
History.discardedStates[discardedStateHash] = discardObject;
|
||||
|
||||
// Return true
|
||||
return true;
|
||||
};
|
||||
|
||||
/**
|
||||
* History.discardHash(hash)
|
||||
* Discards the hash by ignoring it through History
|
||||
* @param {string} hash
|
||||
* @return {true}
|
||||
*/
|
||||
History.discardHash = function(discardedHash,forwardState,backState){
|
||||
//History.debug('History.discardState', arguments);
|
||||
// Create Discard Object
|
||||
var discardObject = {
|
||||
'discardedHash': discardedHash,
|
||||
'backState': backState,
|
||||
'forwardState': forwardState
|
||||
};
|
||||
|
||||
// Add to discardedHash
|
||||
History.discardedHashes[discardedHash] = discardObject;
|
||||
|
||||
// Return true
|
||||
return true;
|
||||
};
|
||||
|
||||
/**
|
||||
* History.discardState(State)
|
||||
* Checks to see if the state is discarded
|
||||
* @param {object} State
|
||||
* @return {bool}
|
||||
*/
|
||||
History.discardedState = function(State){
|
||||
// Prepare
|
||||
var StateHash = History.getHashByState(State),
|
||||
discarded;
|
||||
|
||||
// Check
|
||||
discarded = History.discardedStates[StateHash]||false;
|
||||
|
||||
// Return true
|
||||
return discarded;
|
||||
};
|
||||
|
||||
/**
|
||||
* History.discardedHash(hash)
|
||||
* Checks to see if the state is discarded
|
||||
* @param {string} State
|
||||
* @return {bool}
|
||||
*/
|
||||
History.discardedHash = function(hash){
|
||||
// Check
|
||||
var discarded = History.discardedHashes[hash]||false;
|
||||
|
||||
// Return true
|
||||
return discarded;
|
||||
};
|
||||
|
||||
/**
|
||||
* History.recycleState(State)
|
||||
* Allows a discarded state to be used again
|
||||
* @param {object} data
|
||||
* @param {string} title
|
||||
* @param {string} url
|
||||
* @return {true}
|
||||
*/
|
||||
History.recycleState = function(State){
|
||||
//History.debug('History.recycleState', arguments);
|
||||
// Prepare
|
||||
var StateHash = History.getHashByState(State);
|
||||
|
||||
// Remove from DiscardedStates
|
||||
if ( History.discardedState(State) ) {
|
||||
delete History.discardedStates[StateHash];
|
||||
}
|
||||
|
||||
// Return true
|
||||
return true;
|
||||
};
|
||||
|
||||
|
||||
// ====================================================================
|
||||
// HTML4 HashChange Support
|
||||
|
||||
if ( History.emulated.hashChange ) {
|
||||
/*
|
||||
* We must emulate the HTML4 HashChange Support by manually checking for hash changes
|
||||
*/
|
||||
|
||||
/**
|
||||
* History.hashChangeInit()
|
||||
* Init the HashChange Emulation
|
||||
*/
|
||||
History.hashChangeInit = function(){
|
||||
// Define our Checker Function
|
||||
History.checkerFunction = null;
|
||||
|
||||
// Define some variables that will help in our checker function
|
||||
var lastDocumentHash = '',
|
||||
iframeId, iframe,
|
||||
lastIframeHash, checkerRunning;
|
||||
|
||||
// Handle depending on the browser
|
||||
if ( History.isInternetExplorer() ) {
|
||||
// IE6 and IE7
|
||||
// We need to use an iframe to emulate the back and forward buttons
|
||||
|
||||
// Create iFrame
|
||||
iframeId = 'historyjs-iframe';
|
||||
iframe = document.createElement('iframe');
|
||||
|
||||
// Adjust iFarme
|
||||
iframe.setAttribute('id', iframeId);
|
||||
iframe.style.display = 'none';
|
||||
|
||||
// Append iFrame
|
||||
document.body.appendChild(iframe);
|
||||
|
||||
// Create initial history entry
|
||||
iframe.contentWindow.document.open();
|
||||
iframe.contentWindow.document.close();
|
||||
|
||||
// Define some variables that will help in our checker function
|
||||
lastIframeHash = '';
|
||||
checkerRunning = false;
|
||||
|
||||
// Define the checker function
|
||||
History.checkerFunction = function(){
|
||||
// Check Running
|
||||
if ( checkerRunning ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Update Running
|
||||
checkerRunning = true;
|
||||
|
||||
// Fetch
|
||||
var documentHash = History.getHash()||'',
|
||||
iframeHash = History.unescapeHash(iframe.contentWindow.document.location.hash)||'';
|
||||
|
||||
// The Document Hash has changed (application caused)
|
||||
if ( documentHash !== lastDocumentHash ) {
|
||||
// Equalise
|
||||
lastDocumentHash = documentHash;
|
||||
|
||||
// Create a history entry in the iframe
|
||||
if ( iframeHash !== documentHash ) {
|
||||
//History.debug('hashchange.checker: iframe hash change', 'documentHash (new):', documentHash, 'iframeHash (old):', iframeHash);
|
||||
|
||||
// Equalise
|
||||
lastIframeHash = iframeHash = documentHash;
|
||||
|
||||
// Create History Entry
|
||||
iframe.contentWindow.document.open();
|
||||
iframe.contentWindow.document.close();
|
||||
|
||||
// Update the iframe's hash
|
||||
iframe.contentWindow.document.location.hash = History.escapeHash(documentHash);
|
||||
}
|
||||
|
||||
// Trigger Hashchange Event
|
||||
History.Adapter.trigger(window,'hashchange');
|
||||
}
|
||||
|
||||
// The iFrame Hash has changed (back button caused)
|
||||
else if ( iframeHash !== lastIframeHash ) {
|
||||
//History.debug('hashchange.checker: iframe hash out of sync', 'iframeHash (new):', iframeHash, 'documentHash (old):', documentHash);
|
||||
|
||||
// Equalise
|
||||
lastIframeHash = iframeHash;
|
||||
|
||||
// Update the Hash
|
||||
History.setHash(iframeHash,false);
|
||||
}
|
||||
|
||||
// Reset Running
|
||||
checkerRunning = false;
|
||||
|
||||
// Return true
|
||||
return true;
|
||||
};
|
||||
}
|
||||
else {
|
||||
// We are not IE
|
||||
// Firefox 1 or 2, Opera
|
||||
|
||||
// Define the checker function
|
||||
History.checkerFunction = function(){
|
||||
// Prepare
|
||||
var documentHash = History.getHash();
|
||||
|
||||
// The Document Hash has changed (application caused)
|
||||
if ( documentHash !== lastDocumentHash ) {
|
||||
// Equalise
|
||||
lastDocumentHash = documentHash;
|
||||
|
||||
// Trigger Hashchange Event
|
||||
History.Adapter.trigger(window,'hashchange');
|
||||
}
|
||||
|
||||
// Return true
|
||||
return true;
|
||||
};
|
||||
}
|
||||
|
||||
// Apply the checker function
|
||||
History.intervalList.push(setInterval(History.checkerFunction, History.options.hashChangeInterval));
|
||||
|
||||
// Done
|
||||
return true;
|
||||
}; // History.hashChangeInit
|
||||
|
||||
// Bind hashChangeInit
|
||||
History.Adapter.onDomLoad(History.hashChangeInit);
|
||||
|
||||
} // History.emulated.hashChange
|
||||
|
||||
|
||||
// ====================================================================
|
||||
// HTML5 State Support
|
||||
|
||||
// Non-Native pushState Implementation
|
||||
if ( History.emulated.pushState ) {
|
||||
/*
|
||||
* We must emulate the HTML5 State Management by using HTML4 HashChange
|
||||
*/
|
||||
|
||||
/**
|
||||
* History.onHashChange(event)
|
||||
* Trigger HTML5's window.onpopstate via HTML4 HashChange Support
|
||||
*/
|
||||
History.onHashChange = function(event){
|
||||
//History.debug('History.onHashChange', arguments);
|
||||
|
||||
// Prepare
|
||||
var currentUrl = ((event && event.newURL) || document.location.href),
|
||||
currentHash = History.getHashByUrl(currentUrl),
|
||||
currentState = null,
|
||||
currentStateHash = null,
|
||||
currentStateHashExits = null,
|
||||
discardObject;
|
||||
|
||||
// Check if we are the same state
|
||||
if ( History.isLastHash(currentHash) ) {
|
||||
// There has been no change (just the page's hash has finally propagated)
|
||||
//History.debug('History.onHashChange: no change');
|
||||
History.busy(false);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Reset the double check
|
||||
History.doubleCheckComplete();
|
||||
|
||||
// Store our location for use in detecting back/forward direction
|
||||
History.saveHash(currentHash);
|
||||
|
||||
// Expand Hash
|
||||
if ( currentHash && History.isTraditionalAnchor(currentHash) ) {
|
||||
//History.debug('History.onHashChange: traditional anchor', currentHash);
|
||||
// Traditional Anchor Hash
|
||||
History.Adapter.trigger(window,'anchorchange');
|
||||
History.busy(false);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Create State
|
||||
currentState = History.extractState(History.getFullUrl(currentHash||document.location.href,false),true);
|
||||
|
||||
// Check if we are the same state
|
||||
if ( History.isLastSavedState(currentState) ) {
|
||||
//History.debug('History.onHashChange: no change');
|
||||
// There has been no change (just the page's hash has finally propagated)
|
||||
History.busy(false);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Create the state Hash
|
||||
currentStateHash = History.getHashByState(currentState);
|
||||
|
||||
// Check if we are DiscardedState
|
||||
discardObject = History.discardedState(currentState);
|
||||
if ( discardObject ) {
|
||||
// Ignore this state as it has been discarded and go back to the state before it
|
||||
if ( History.getHashByIndex(-2) === History.getHashByState(discardObject.forwardState) ) {
|
||||
// We are going backwards
|
||||
//History.debug('History.onHashChange: go backwards');
|
||||
History.back(false);
|
||||
} else {
|
||||
// We are going forwards
|
||||
//History.debug('History.onHashChange: go forwards');
|
||||
History.forward(false);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// Push the new HTML5 State
|
||||
//History.debug('History.onHashChange: success hashchange');
|
||||
History.pushState(currentState.data,currentState.title,currentState.url,false);
|
||||
|
||||
// End onHashChange closure
|
||||
return true;
|
||||
};
|
||||
History.Adapter.bind(window,'hashchange',History.onHashChange);
|
||||
|
||||
/**
|
||||
* History.pushState(data,title,url)
|
||||
* Add a new State to the history object, become it, and trigger onpopstate
|
||||
* We have to trigger for HTML4 compatibility
|
||||
* @param {object} data
|
||||
* @param {string} title
|
||||
* @param {string} url
|
||||
* @return {true}
|
||||
*/
|
||||
History.pushState = function(data,title,url,queue){
|
||||
//History.debug('History.pushState: called', arguments);
|
||||
|
||||
// Check the State
|
||||
if ( History.getHashByUrl(url) ) {
|
||||
throw new Error('History.js does not support states with fragement-identifiers (hashes/anchors).');
|
||||
}
|
||||
|
||||
// Handle Queueing
|
||||
if ( queue !== false && History.busy() ) {
|
||||
// Wait + Push to Queue
|
||||
//History.debug('History.pushState: we must wait', arguments);
|
||||
History.pushQueue({
|
||||
scope: History,
|
||||
callback: History.pushState,
|
||||
args: arguments,
|
||||
queue: queue
|
||||
});
|
||||
return false;
|
||||
}
|
||||
|
||||
// Make Busy
|
||||
History.busy(true);
|
||||
|
||||
// Fetch the State Object
|
||||
var newState = History.createStateObject(data,title,url),
|
||||
newStateHash = History.getHashByState(newState),
|
||||
oldState = History.getState(false),
|
||||
oldStateHash = History.getHashByState(oldState),
|
||||
html4Hash = History.getHash();
|
||||
|
||||
// Store the newState
|
||||
History.storeState(newState);
|
||||
History.expectedStateId = newState.id;
|
||||
|
||||
// Recycle the State
|
||||
History.recycleState(newState);
|
||||
|
||||
// Force update of the title
|
||||
History.setTitle(newState);
|
||||
|
||||
// Check if we are the same State
|
||||
if ( newStateHash === oldStateHash ) {
|
||||
//History.debug('History.pushState: no change', newStateHash);
|
||||
History.busy(false);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Update HTML4 Hash
|
||||
if ( newStateHash !== html4Hash && newStateHash !== History.getShortUrl(document.location.href) ) {
|
||||
//History.debug('History.pushState: update hash', newStateHash, html4Hash);
|
||||
History.setHash(newStateHash,false);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Update HTML5 State
|
||||
History.saveState(newState);
|
||||
|
||||
// Fire HTML5 Event
|
||||
//History.debug('History.pushState: trigger popstate');
|
||||
History.Adapter.trigger(window,'statechange');
|
||||
History.busy(false);
|
||||
|
||||
// End pushState closure
|
||||
return true;
|
||||
};
|
||||
|
||||
/**
|
||||
* History.replaceState(data,title,url)
|
||||
* Replace the State and trigger onpopstate
|
||||
* We have to trigger for HTML4 compatibility
|
||||
* @param {object} data
|
||||
* @param {string} title
|
||||
* @param {string} url
|
||||
* @return {true}
|
||||
*/
|
||||
History.replaceState = function(data,title,url,queue){
|
||||
//History.debug('History.replaceState: called', arguments);
|
||||
|
||||
// Check the State
|
||||
if ( History.getHashByUrl(url) ) {
|
||||
throw new Error('History.js does not support states with fragement-identifiers (hashes/anchors).');
|
||||
}
|
||||
|
||||
// Handle Queueing
|
||||
if ( queue !== false && History.busy() ) {
|
||||
// Wait + Push to Queue
|
||||
//History.debug('History.replaceState: we must wait', arguments);
|
||||
History.pushQueue({
|
||||
scope: History,
|
||||
callback: History.replaceState,
|
||||
args: arguments,
|
||||
queue: queue
|
||||
});
|
||||
return false;
|
||||
}
|
||||
|
||||
// Make Busy
|
||||
History.busy(true);
|
||||
|
||||
// Fetch the State Objects
|
||||
var newState = History.createStateObject(data,title,url),
|
||||
oldState = History.getState(false),
|
||||
previousState = History.getStateByIndex(-2);
|
||||
|
||||
// Discard Old State
|
||||
History.discardState(oldState,newState,previousState);
|
||||
|
||||
// Alias to PushState
|
||||
History.pushState(newState.data,newState.title,newState.url,false);
|
||||
|
||||
// End replaceState closure
|
||||
return true;
|
||||
};
|
||||
|
||||
} // History.emulated.pushState
|
||||
|
||||
|
||||
|
||||
// ====================================================================
|
||||
// Initialise
|
||||
|
||||
// Non-Native pushState Implementation
|
||||
if ( History.emulated.pushState ) {
|
||||
/**
|
||||
* Ensure initial state is handled correctly
|
||||
*/
|
||||
if ( History.getHash() && !History.emulated.hashChange ) {
|
||||
History.Adapter.onDomLoad(function(){
|
||||
History.Adapter.trigger(window,'hashchange');
|
||||
});
|
||||
}
|
||||
|
||||
} // History.emulated.pushState
|
||||
|
||||
}; // History.initHtml4
|
||||
|
||||
// Try and Initialise History
|
||||
if ( typeof History.init !== 'undefined' ) {
|
||||
History.init();
|
||||
}
|
||||
|
||||
})(window);
|
||||
Executable
+1943
File diff suppressed because it is too large
Load Diff
Executable
+480
@@ -0,0 +1,480 @@
|
||||
/*
|
||||
http://www.JSON.org/json2.js
|
||||
2011-01-18
|
||||
|
||||
Public Domain.
|
||||
|
||||
NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.
|
||||
|
||||
See http://www.JSON.org/js.html
|
||||
|
||||
|
||||
This code should be minified before deployment.
|
||||
See http://javascript.crockford.com/jsmin.html
|
||||
|
||||
USE YOUR OWN COPY. IT IS EXTREMELY UNWISE TO LOAD CODE FROM SERVERS YOU DO
|
||||
NOT CONTROL.
|
||||
|
||||
|
||||
This file creates a global JSON object containing two methods: stringify
|
||||
and parse.
|
||||
|
||||
JSON.stringify(value, replacer, space)
|
||||
value any JavaScript value, usually an object or array.
|
||||
|
||||
replacer an optional parameter that determines how object
|
||||
values are stringified for objects. It can be a
|
||||
function or an array of strings.
|
||||
|
||||
space an optional parameter that specifies the indentation
|
||||
of nested structures. If it is omitted, the text will
|
||||
be packed without extra whitespace. If it is a number,
|
||||
it will specify the number of spaces to indent at each
|
||||
level. If it is a string (such as '\t' or ' '),
|
||||
it contains the characters used to indent at each level.
|
||||
|
||||
This method produces a JSON text from a JavaScript value.
|
||||
|
||||
When an object value is found, if the object contains a toJSON
|
||||
method, its toJSON method will be called and the result will be
|
||||
stringified. A toJSON method does not serialize: it returns the
|
||||
value represented by the name/value pair that should be serialized,
|
||||
or undefined if nothing should be serialized. The toJSON method
|
||||
will be passed the key associated with the value, and this will be
|
||||
bound to the value
|
||||
|
||||
For example, this would serialize Dates as ISO strings.
|
||||
|
||||
Date.prototype.toJSON = function (key) {
|
||||
function f(n) {
|
||||
// Format integers to have at least two digits.
|
||||
return n < 10 ? '0' + n : n;
|
||||
}
|
||||
|
||||
return this.getUTCFullYear() + '-' +
|
||||
f(this.getUTCMonth() + 1) + '-' +
|
||||
f(this.getUTCDate()) + 'T' +
|
||||
f(this.getUTCHours()) + ':' +
|
||||
f(this.getUTCMinutes()) + ':' +
|
||||
f(this.getUTCSeconds()) + 'Z';
|
||||
};
|
||||
|
||||
You can provide an optional replacer method. It will be passed the
|
||||
key and value of each member, with this bound to the containing
|
||||
object. The value that is returned from your method will be
|
||||
serialized. If your method returns undefined, then the member will
|
||||
be excluded from the serialization.
|
||||
|
||||
If the replacer parameter is an array of strings, then it will be
|
||||
used to select the members to be serialized. It filters the results
|
||||
such that only members with keys listed in the replacer array are
|
||||
stringified.
|
||||
|
||||
Values that do not have JSON representations, such as undefined or
|
||||
functions, will not be serialized. Such values in objects will be
|
||||
dropped; in arrays they will be replaced with null. You can use
|
||||
a replacer function to replace those with JSON values.
|
||||
JSON.stringify(undefined) returns undefined.
|
||||
|
||||
The optional space parameter produces a stringification of the
|
||||
value that is filled with line breaks and indentation to make it
|
||||
easier to read.
|
||||
|
||||
If the space parameter is a non-empty string, then that string will
|
||||
be used for indentation. If the space parameter is a number, then
|
||||
the indentation will be that many spaces.
|
||||
|
||||
Example:
|
||||
|
||||
text = JSON.stringify(['e', {pluribus: 'unum'}]);
|
||||
// text is '["e",{"pluribus":"unum"}]'
|
||||
|
||||
|
||||
text = JSON.stringify(['e', {pluribus: 'unum'}], null, '\t');
|
||||
// text is '[\n\t"e",\n\t{\n\t\t"pluribus": "unum"\n\t}\n]'
|
||||
|
||||
text = JSON.stringify([new Date()], function (key, value) {
|
||||
return this[key] instanceof Date ?
|
||||
'Date(' + this[key] + ')' : value;
|
||||
});
|
||||
// text is '["Date(---current time---)"]'
|
||||
|
||||
|
||||
JSON.parse(text, reviver)
|
||||
This method parses a JSON text to produce an object or array.
|
||||
It can throw a SyntaxError exception.
|
||||
|
||||
The optional reviver parameter is a function that can filter and
|
||||
transform the results. It receives each of the keys and values,
|
||||
and its return value is used instead of the original value.
|
||||
If it returns what it received, then the structure is not modified.
|
||||
If it returns undefined then the member is deleted.
|
||||
|
||||
Example:
|
||||
|
||||
// Parse the text. Values that look like ISO date strings will
|
||||
// be converted to Date objects.
|
||||
|
||||
myData = JSON.parse(text, function (key, value) {
|
||||
var a;
|
||||
if (typeof value === 'string') {
|
||||
a =
|
||||
/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2}(?:\.\d*)?)Z$/.exec(value);
|
||||
if (a) {
|
||||
return new Date(Date.UTC(+a[1], +a[2] - 1, +a[3], +a[4],
|
||||
+a[5], +a[6]));
|
||||
}
|
||||
}
|
||||
return value;
|
||||
});
|
||||
|
||||
myData = JSON.parse('["Date(09/09/2001)"]', function (key, value) {
|
||||
var d;
|
||||
if (typeof value === 'string' &&
|
||||
value.slice(0, 5) === 'Date(' &&
|
||||
value.slice(-1) === ')') {
|
||||
d = new Date(value.slice(5, -1));
|
||||
if (d) {
|
||||
return d;
|
||||
}
|
||||
}
|
||||
return value;
|
||||
});
|
||||
|
||||
|
||||
This is a reference implementation. You are free to copy, modify, or
|
||||
redistribute.
|
||||
*/
|
||||
|
||||
/*jslint evil: true, strict: false, regexp: false */
|
||||
|
||||
/*members "", "\b", "\t", "\n", "\f", "\r", "\"", JSON, "\\", apply,
|
||||
call, charCodeAt, getUTCDate, getUTCFullYear, getUTCHours,
|
||||
getUTCMinutes, getUTCMonth, getUTCSeconds, hasOwnProperty, join,
|
||||
lastIndex, length, parse, prototype, push, replace, slice, stringify,
|
||||
test, toJSON, toString, valueOf
|
||||
*/
|
||||
|
||||
|
||||
// Create a JSON object only if one does not already exist. We create the
|
||||
// methods in a closure to avoid creating global variables.
|
||||
|
||||
if (!window.JSON) {
|
||||
window.JSON = {};
|
||||
}
|
||||
|
||||
(function () {
|
||||
"use strict";
|
||||
|
||||
function f(n) {
|
||||
// Format integers to have at least two digits.
|
||||
return n < 10 ? '0' + n : n;
|
||||
}
|
||||
|
||||
if (typeof Date.prototype.toJSON !== 'function') {
|
||||
|
||||
Date.prototype.toJSON = function (key) {
|
||||
|
||||
return isFinite(this.valueOf()) ?
|
||||
this.getUTCFullYear() + '-' +
|
||||
f(this.getUTCMonth() + 1) + '-' +
|
||||
f(this.getUTCDate()) + 'T' +
|
||||
f(this.getUTCHours()) + ':' +
|
||||
f(this.getUTCMinutes()) + ':' +
|
||||
f(this.getUTCSeconds()) + 'Z' : null;
|
||||
};
|
||||
|
||||
String.prototype.toJSON =
|
||||
Number.prototype.toJSON =
|
||||
Boolean.prototype.toJSON = function (key) {
|
||||
return this.valueOf();
|
||||
};
|
||||
}
|
||||
|
||||
var JSON = window.JSON,
|
||||
cx = /[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
|
||||
escapable = /[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,
|
||||
gap,
|
||||
indent,
|
||||
meta = { // table of character substitutions
|
||||
'\b': '\\b',
|
||||
'\t': '\\t',
|
||||
'\n': '\\n',
|
||||
'\f': '\\f',
|
||||
'\r': '\\r',
|
||||
'"' : '\\"',
|
||||
'\\': '\\\\'
|
||||
},
|
||||
rep;
|
||||
|
||||
|
||||
function quote(string) {
|
||||
|
||||
// If the string contains no control characters, no quote characters, and no
|
||||
// backslash characters, then we can safely slap some quotes around it.
|
||||
// Otherwise we must also replace the offending characters with safe escape
|
||||
// sequences.
|
||||
|
||||
escapable.lastIndex = 0;
|
||||
return escapable.test(string) ? '"' + string.replace(escapable, function (a) {
|
||||
var c = meta[a];
|
||||
return typeof c === 'string' ? c :
|
||||
'\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4);
|
||||
}) + '"' : '"' + string + '"';
|
||||
}
|
||||
|
||||
|
||||
function str(key, holder) {
|
||||
|
||||
// Produce a string from holder[key].
|
||||
|
||||
var i, // The loop counter.
|
||||
k, // The member key.
|
||||
v, // The member value.
|
||||
length,
|
||||
mind = gap,
|
||||
partial,
|
||||
value = holder[key];
|
||||
|
||||
// If the value has a toJSON method, call it to obtain a replacement value.
|
||||
|
||||
if (value && typeof value === 'object' &&
|
||||
typeof value.toJSON === 'function') {
|
||||
value = value.toJSON(key);
|
||||
}
|
||||
|
||||
// If we were called with a replacer function, then call the replacer to
|
||||
// obtain a replacement value.
|
||||
|
||||
if (typeof rep === 'function') {
|
||||
value = rep.call(holder, key, value);
|
||||
}
|
||||
|
||||
// What happens next depends on the value's type.
|
||||
|
||||
switch (typeof value) {
|
||||
case 'string':
|
||||
return quote(value);
|
||||
|
||||
case 'number':
|
||||
|
||||
// JSON numbers must be finite. Encode non-finite numbers as null.
|
||||
|
||||
return isFinite(value) ? String(value) : 'null';
|
||||
|
||||
case 'boolean':
|
||||
case 'null':
|
||||
|
||||
// If the value is a boolean or null, convert it to a string. Note:
|
||||
// typeof null does not produce 'null'. The case is included here in
|
||||
// the remote chance that this gets fixed someday.
|
||||
|
||||
return String(value);
|
||||
|
||||
// If the type is 'object', we might be dealing with an object or an array or
|
||||
// null.
|
||||
|
||||
case 'object':
|
||||
|
||||
// Due to a specification blunder in ECMAScript, typeof null is 'object',
|
||||
// so watch out for that case.
|
||||
|
||||
if (!value) {
|
||||
return 'null';
|
||||
}
|
||||
|
||||
// Make an array to hold the partial results of stringifying this object value.
|
||||
|
||||
gap += indent;
|
||||
partial = [];
|
||||
|
||||
// Is the value an array?
|
||||
|
||||
if (Object.prototype.toString.apply(value) === '[object Array]') {
|
||||
|
||||
// The value is an array. Stringify every element. Use null as a placeholder
|
||||
// for non-JSON values.
|
||||
|
||||
length = value.length;
|
||||
for (i = 0; i < length; i += 1) {
|
||||
partial[i] = str(i, value) || 'null';
|
||||
}
|
||||
|
||||
// Join all of the elements together, separated with commas, and wrap them in
|
||||
// brackets.
|
||||
|
||||
v = partial.length === 0 ? '[]' : gap ?
|
||||
'[\n' + gap + partial.join(',\n' + gap) + '\n' + mind + ']' :
|
||||
'[' + partial.join(',') + ']';
|
||||
gap = mind;
|
||||
return v;
|
||||
}
|
||||
|
||||
// If the replacer is an array, use it to select the members to be stringified.
|
||||
|
||||
if (rep && typeof rep === 'object') {
|
||||
length = rep.length;
|
||||
for (i = 0; i < length; i += 1) {
|
||||
k = rep[i];
|
||||
if (typeof k === 'string') {
|
||||
v = str(k, value);
|
||||
if (v) {
|
||||
partial.push(quote(k) + (gap ? ': ' : ':') + v);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
||||
// Otherwise, iterate through all of the keys in the object.
|
||||
|
||||
for (k in value) {
|
||||
if (Object.hasOwnProperty.call(value, k)) {
|
||||
v = str(k, value);
|
||||
if (v) {
|
||||
partial.push(quote(k) + (gap ? ': ' : ':') + v);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Join all of the member texts together, separated with commas,
|
||||
// and wrap them in braces.
|
||||
|
||||
v = partial.length === 0 ? '{}' : gap ?
|
||||
'{\n' + gap + partial.join(',\n' + gap) + '\n' + mind + '}' :
|
||||
'{' + partial.join(',') + '}';
|
||||
gap = mind;
|
||||
return v;
|
||||
}
|
||||
}
|
||||
|
||||
// If the JSON object does not yet have a stringify method, give it one.
|
||||
|
||||
if (typeof JSON.stringify !== 'function') {
|
||||
JSON.stringify = function (value, replacer, space) {
|
||||
|
||||
// The stringify method takes a value and an optional replacer, and an optional
|
||||
// space parameter, and returns a JSON text. The replacer can be a function
|
||||
// that can replace values, or an array of strings that will select the keys.
|
||||
// A default replacer method can be provided. Use of the space parameter can
|
||||
// produce text that is more easily readable.
|
||||
|
||||
var i;
|
||||
gap = '';
|
||||
indent = '';
|
||||
|
||||
// If the space parameter is a number, make an indent string containing that
|
||||
// many spaces.
|
||||
|
||||
if (typeof space === 'number') {
|
||||
for (i = 0; i < space; i += 1) {
|
||||
indent += ' ';
|
||||
}
|
||||
|
||||
// If the space parameter is a string, it will be used as the indent string.
|
||||
|
||||
} else if (typeof space === 'string') {
|
||||
indent = space;
|
||||
}
|
||||
|
||||
// If there is a replacer, it must be a function or an array.
|
||||
// Otherwise, throw an error.
|
||||
|
||||
rep = replacer;
|
||||
if (replacer && typeof replacer !== 'function' &&
|
||||
(typeof replacer !== 'object' ||
|
||||
typeof replacer.length !== 'number')) {
|
||||
throw new Error('JSON.stringify');
|
||||
}
|
||||
|
||||
// Make a fake root object containing our value under the key of ''.
|
||||
// Return the result of stringifying the value.
|
||||
|
||||
return str('', {'': value});
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
// If the JSON object does not yet have a parse method, give it one.
|
||||
|
||||
if (typeof JSON.parse !== 'function') {
|
||||
JSON.parse = function (text, reviver) {
|
||||
|
||||
// The parse method takes a text and an optional reviver function, and returns
|
||||
// a JavaScript value if the text is a valid JSON text.
|
||||
|
||||
var j;
|
||||
|
||||
function walk(holder, key) {
|
||||
|
||||
// The walk method is used to recursively walk the resulting structure so
|
||||
// that modifications can be made.
|
||||
|
||||
var k, v, value = holder[key];
|
||||
if (value && typeof value === 'object') {
|
||||
for (k in value) {
|
||||
if (Object.hasOwnProperty.call(value, k)) {
|
||||
v = walk(value, k);
|
||||
if (v !== undefined) {
|
||||
value[k] = v;
|
||||
} else {
|
||||
delete value[k];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return reviver.call(holder, key, value);
|
||||
}
|
||||
|
||||
|
||||
// Parsing happens in four stages. In the first stage, we replace certain
|
||||
// Unicode characters with escape sequences. JavaScript handles many characters
|
||||
// incorrectly, either silently deleting them, or treating them as line endings.
|
||||
|
||||
text = String(text);
|
||||
cx.lastIndex = 0;
|
||||
if (cx.test(text)) {
|
||||
text = text.replace(cx, function (a) {
|
||||
return '\\u' +
|
||||
('0000' + a.charCodeAt(0).toString(16)).slice(-4);
|
||||
});
|
||||
}
|
||||
|
||||
// In the second stage, we run the text against regular expressions that look
|
||||
// for non-JSON patterns. We are especially concerned with '()' and 'new'
|
||||
// because they can cause invocation, and '=' because it can cause mutation.
|
||||
// But just to be safe, we want to reject all unexpected forms.
|
||||
|
||||
// We split the second stage into 4 regexp operations in order to work around
|
||||
// crippling inefficiencies in IE's and Safari's regexp engines. First we
|
||||
// replace the JSON backslash pairs with '@' (a non-JSON character). Second, we
|
||||
// replace all simple value tokens with ']' characters. Third, we delete all
|
||||
// open brackets that follow a colon or comma or that begin the text. Finally,
|
||||
// we look to see that the remaining characters are only whitespace or ']' or
|
||||
// ',' or ':' or '{' or '}'. If that is so, then the text is safe for eval.
|
||||
|
||||
if (/^[\],:{}\s]*$/
|
||||
.test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g, '@')
|
||||
.replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, ']')
|
||||
.replace(/(?:^|:|,)(?:\s*\[)+/g, ''))) {
|
||||
|
||||
// In the third stage we use the eval function to compile the text into a
|
||||
// JavaScript structure. The '{' operator is subject to a syntactic ambiguity
|
||||
// in JavaScript: it can begin a block or an object literal. We wrap the text
|
||||
// in parens to eliminate the ambiguity.
|
||||
|
||||
j = eval('(' + text + ')');
|
||||
|
||||
// In the optional fourth stage, we recursively walk the new structure, passing
|
||||
// each name/value pair to a reviver function for possible transformation.
|
||||
|
||||
return typeof reviver === 'function' ?
|
||||
walk({'': j}, '') : j;
|
||||
}
|
||||
|
||||
// If the text is not JSON parseable, then a SyntaxError is thrown.
|
||||
|
||||
throw new SyntaxError('JSON.parse');
|
||||
};
|
||||
}
|
||||
}());
|
||||
+22
@@ -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'
|
||||
);
|
||||
|
||||
+45
@@ -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>
|
||||
+51
@@ -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>
|
||||
+23
@@ -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>
|
||||
+13
@@ -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
|
||||
Executable
+43
@@ -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>
|
||||
Executable
+43
@@ -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>
|
||||
Executable
+43
@@ -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>
|
||||
Executable
+43
@@ -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>
|
||||
Executable
+43
@@ -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>
|
||||
+43
@@ -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>
|
||||
+43
@@ -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>
|
||||
+43
@@ -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>
|
||||
+43
@@ -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>
|
||||
+43
@@ -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>
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
<?php
|
||||
header('Content-type: image/jpeg');
|
||||
sleep(10);
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>History.js Test Suite</title>
|
||||
<style type="text/css">
|
||||
body,html,iframe {
|
||||
padding:0;
|
||||
margin:0;
|
||||
outline:none;
|
||||
border:none;
|
||||
}
|
||||
.browser {
|
||||
padding-top:1em;
|
||||
}
|
||||
.adapter {
|
||||
padding-top:1em;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<h1>History.js Test Suite</h1>
|
||||
<p>HTML5 Browsers must pass the HTML4+HTML5 tests</p>
|
||||
<p>HTML4 Browsers must pass the HTML4 tests and should fail the HTML5 tests</p>
|
||||
<div class="browser"><div class="adapter"><a href="html4+html5.jquery.html">History.js Html4+html5 Jquery Test Suite</a></div><div class="adapter"><a href="html4+html5.mootools.html">History.js Html4+html5 Mootools Test Suite</a></div><div class="adapter"><a href="html4+html5.native.html">History.js Html4+html5 Native Test Suite</a></div><div class="adapter"><a href="html4+html5.right.html">History.js Html4+html5 Right Test Suite</a></div><div class="adapter"><a href="html4+html5.zepto.html">History.js Html4+html5 Zepto Test Suite</a></div></div><div class="browser"><div class="adapter"><a href="html5.jquery.html">History.js Html5 Jquery Test Suite</a></div><div class="adapter"><a href="html5.mootools.html">History.js Html5 Mootools Test Suite</a></div><div class="adapter"><a href="html5.native.html">History.js Html5 Native Test Suite</a></div><div class="adapter"><a href="html5.right.html">History.js Html5 Right Test Suite</a></div><div class="adapter"><a href="html5.zepto.html">History.js Html5 Zepto Test Suite</a></div></div></body>
|
||||
</html>
|
||||
+254
@@ -0,0 +1,254 @@
|
||||
(function(){
|
||||
|
||||
var
|
||||
History = window.History,
|
||||
document = window.document,
|
||||
test = window.test,
|
||||
same = window.same;
|
||||
|
||||
// Check
|
||||
if ( !History.enabled ) {
|
||||
throw new Error('History.js is disabled');
|
||||
}
|
||||
|
||||
// Prepare
|
||||
History.options.debug = false;
|
||||
|
||||
// Variables
|
||||
var
|
||||
States = {
|
||||
// Home
|
||||
0: {
|
||||
'url': document.location.href.replace(/#.*$/,''),
|
||||
'title': ''
|
||||
},
|
||||
// One
|
||||
1: {
|
||||
'data': {
|
||||
'state': 1,
|
||||
'rand': Math.random()
|
||||
},
|
||||
'title': 'State 1',
|
||||
'url': '?state=1'
|
||||
},
|
||||
// Two
|
||||
2: {
|
||||
'data': {
|
||||
'state': 2,
|
||||
'rand': Math.random()
|
||||
},
|
||||
'title': 'State 2',
|
||||
'url': '?state=2&asd=%20asd%2520asd'
|
||||
},
|
||||
// Three
|
||||
3: {
|
||||
'url': '?state=3'
|
||||
},
|
||||
// Four
|
||||
4: {
|
||||
'data': {
|
||||
'state': 4,
|
||||
'trick': true,
|
||||
'rand': Math.random()
|
||||
},
|
||||
'title': 'State 4',
|
||||
'url': '?state=3'
|
||||
},
|
||||
// Log
|
||||
5: {
|
||||
'url': '?state=1#log'
|
||||
},
|
||||
// Six
|
||||
6: {
|
||||
'data': {
|
||||
'state': 6,
|
||||
'rand': Math.random()
|
||||
},
|
||||
'url': 'six.html'
|
||||
},
|
||||
// Seven
|
||||
7: {
|
||||
'url': 'seven'
|
||||
},
|
||||
// Eight
|
||||
8: {
|
||||
'url': '/eight'
|
||||
}
|
||||
},
|
||||
stateOrder = [0,1,2,3,4,3,1,0,1,3,4,3,1,0,6,7,8,1,8,7,6,0],
|
||||
currentTest = 0;
|
||||
|
||||
// Original Title
|
||||
var title = document.title;
|
||||
|
||||
var banner;
|
||||
|
||||
var checkStatus = function(){
|
||||
banner = banner || document.getElementById('qunit-banner');
|
||||
var status = banner.className !== 'qunit-fail';
|
||||
return status;
|
||||
};
|
||||
|
||||
// Check State
|
||||
var checkState = function(){
|
||||
if ( !checkStatus() ) {
|
||||
throw new Error('A test has failed');
|
||||
}
|
||||
|
||||
var
|
||||
stateIndex = stateOrder[currentTest],
|
||||
expectedState = History.normalizeState(States[stateIndex]),
|
||||
actualState = History.getState(false);
|
||||
|
||||
++currentTest;
|
||||
|
||||
document.title = title+': '+actualState.url;
|
||||
|
||||
var
|
||||
testName = 'Test '+currentTest,
|
||||
stateName = 'State '+stateIndex;
|
||||
|
||||
test(testName,function(){
|
||||
History.log('Completed: '+testName +' / '+ stateName);
|
||||
same(actualState,expectedState,stateName);
|
||||
});
|
||||
|
||||
// Image Load to Stress Test Safari and Opera
|
||||
(new Image()).src = "image.php";
|
||||
};
|
||||
|
||||
// Check the Initial State
|
||||
checkState();
|
||||
|
||||
// State Change
|
||||
History.Adapter.bind(window,'statechange',checkState);
|
||||
|
||||
// Log
|
||||
var addLog = function(){
|
||||
var args = arguments;
|
||||
History.queue(function(){
|
||||
History.log.apply(History,args);
|
||||
});
|
||||
};
|
||||
|
||||
// Dom Load
|
||||
History.Adapter.onDomLoad(function(){
|
||||
setTimeout(function(){
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Test State Functionality: Adding
|
||||
|
||||
// Test 2 / State 1 (0 -> 1)
|
||||
// Tests HTML4 -> HTML5 Graceful Upgrade
|
||||
addLog('Test 2',History.queues.length,History.busy.flag);
|
||||
History.setHash(History.getHashByState(States[1]));
|
||||
|
||||
// Test 3 / State 2 (1 -> 2)
|
||||
addLog('Test 3',History.queues.length,History.busy.flag);
|
||||
History.pushState(States[2].data, States[2].title, States[2].url);
|
||||
|
||||
// Test 3-2 / State 2 (2 -> 2) / No Change
|
||||
addLog('Test 3-2',History.queues.length,History.busy.flag);
|
||||
History.pushState(States[2].data, States[2].title, States[2].url);
|
||||
|
||||
// Test 3-3 / State 2 (2 -> 2) / No Change
|
||||
addLog('Test 3-3',History.queues.length,History.busy.flag);
|
||||
History.replaceState(States[2].data, States[2].title, States[2].url);
|
||||
|
||||
// Test 4 / State 3 (2 -> 3)
|
||||
addLog('Test 4',History.queues.length,History.busy.flag);
|
||||
History.replaceState(States[3].data, States[3].title, States[3].url);
|
||||
|
||||
// Test 5 / State 4 (3 -> 4)
|
||||
addLog('Test 5',History.queues.length,History.busy.flag);
|
||||
History.pushState(States[4].data, States[4].title, States[4].url);
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Test State Functionality: Traversing
|
||||
|
||||
// Test 6 / State 3 (4 -> 3)
|
||||
// Test 7 / State 1 (3 -> 2 -> 1)
|
||||
addLog('Test 6,7',History.queues.length,History.busy.flag);
|
||||
History.go(-2);
|
||||
|
||||
// Test 8 / State 0 (1 -> 0)
|
||||
// Tests Default State
|
||||
addLog('Test 8',History.queues.length,History.busy.flag);
|
||||
History.back();
|
||||
|
||||
// Test 9 / State 1 (0 -> 1)
|
||||
// Test 10 / State 3 (1 -> 2 -> 3)
|
||||
addLog('Test 9,10',History.queues.length,History.busy.flag);
|
||||
History.go(2);
|
||||
|
||||
// Test 11 / State 4 (3 -> 4)
|
||||
addLog('Test 11',History.queues.length,History.busy.flag);
|
||||
History.forward();
|
||||
|
||||
// Test 12 / State 3 (4 -> 3)
|
||||
addLog('Test 12',History.queues.length,History.busy.flag);
|
||||
History.back();
|
||||
|
||||
// Test 13 / State 1 (3 -> 2 -> 1)
|
||||
addLog('Test 13',History.queues.length,History.busy.flag);
|
||||
History.back();
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Test State Functionality: Traditional Anchors
|
||||
|
||||
// Test 13-2 / State 1 (1 -> #log) / No Change
|
||||
addLog('Test 13-2',History.queues.length,History.busy.flag);
|
||||
History.setHash('log');
|
||||
|
||||
// Test 13-3 / State 1 (#log -> 1) / No Change
|
||||
addLog('Test 13-3',History.queues.length,History.busy.flag);
|
||||
History.back();
|
||||
|
||||
// Test 14 / State 0 (1 -> 0)
|
||||
addLog('Test 14',History.queues.length,History.busy.flag);
|
||||
History.back();
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Test URL Handling: Adding
|
||||
|
||||
// Test 15 / State 6 (1 -> 6)
|
||||
// Also tests data with no title
|
||||
addLog('Test 15',History.queues.length,History.busy.flag);
|
||||
History.pushState(States[6].data, States[6].title, States[6].url);
|
||||
|
||||
// Test 16 / State 7 (6 -> 7)
|
||||
addLog('Test 16',History.queues.length,History.busy.flag);
|
||||
History.pushState(States[7].data, States[7].title, States[7].url);
|
||||
|
||||
// Test 17 / State 7 (7 -> 8)
|
||||
addLog('Test 17',History.queues.length,History.busy.flag);
|
||||
History.pushState(States[8].data, States[8].title, States[8].url);
|
||||
|
||||
// Test 18 / State 1 (8 -> 1)
|
||||
// Should be /eight?state=1
|
||||
addLog('Test 18',History.queues.length,History.busy.flag);
|
||||
History.pushState(States[1].data, States[1].title, States[1].url);
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Test URL Handling: Traversing
|
||||
|
||||
// Test 19 / State 8 (1 -> 8)
|
||||
addLog('Test 19',History.queues.length,History.busy.flag);
|
||||
History.back();
|
||||
|
||||
// Test 20 / State 7 (8 -> 7)
|
||||
addLog('Test 20',History.queues.length,History.busy.flag);
|
||||
History.back();
|
||||
|
||||
// Test 21 / State 6 (7 -> 6)
|
||||
addLog('Test 21',History.queues.length,History.busy.flag);
|
||||
History.back();
|
||||
|
||||
// Test 22 / State 0 (6 -> 0)
|
||||
addLog('Test 22',History.queues.length,History.busy.flag);
|
||||
History.back();
|
||||
|
||||
},1000); // wait for test one to complete
|
||||
});
|
||||
|
||||
})();
|
||||
+9046
File diff suppressed because it is too large
Load Diff
Vendored
Executable
+5815
File diff suppressed because it is too large
Load Diff
+6
@@ -0,0 +1,6 @@
|
||||
.project
|
||||
*~
|
||||
*.diff
|
||||
*.patch
|
||||
.DS_Store
|
||||
|
||||
Vendored
Executable
+27
@@ -0,0 +1,27 @@
|
||||
[QUnit](http://docs.jquery.com/QUnit) - A JavaScript Unit Testing framework.
|
||||
================================
|
||||
|
||||
QUnit is a powerful, easy-to-use, JavaScript test suite. It's used by the jQuery
|
||||
project to test its code and plugins but is capable of testing any generic
|
||||
JavaScript code (and even capable of testing JavaScript code on the server-side).
|
||||
|
||||
QUnit is especially useful for regression testing: Whenever a bug is reported,
|
||||
write a test that asserts the existence of that particular bug. Then fix it and
|
||||
commit both. Every time you work on the code again, run the tests. If the bug
|
||||
comes up again - a regression - you'll spot it immediately and know how to fix
|
||||
it, because you know what code you just changed.
|
||||
|
||||
Having good unit test coverage makes safe refactoring easy and cheap. You can
|
||||
run the tests after each small refactoring step and always know what change
|
||||
broke something.
|
||||
|
||||
QUnit is similar to other unit testing frameworks like JUnit, but makes use of
|
||||
the features JavaScript provides and helps with testing code in the browser, eg.
|
||||
with it's stop/start facilities for testing asynchronous code.
|
||||
|
||||
If you are interested in helping developing QUnit, you are in the right place.
|
||||
For related discussions, visit the
|
||||
[QUnit and Testing forum](http://forum.jquery.com/qunit-and-testing).
|
||||
|
||||
Planning for a qunitjs.com site and other testing tools related work now happens
|
||||
on the [jQuery Testing Team planning wiki](http://jquerytesting.pbworks.com/w/page/41556026/FrontPage).
|
||||
Vendored
Executable
+21
@@ -0,0 +1,21 @@
|
||||
{
|
||||
"name": "qunit",
|
||||
"author": {
|
||||
"name": "John Resig",
|
||||
"email": "jeresig@gmail.com",
|
||||
"url": "http://ejohn.org/"
|
||||
},
|
||||
"maintainer": {
|
||||
"name": "Jörn Zaefferer",
|
||||
"email": "joern.zaefferer@googlemail.com",
|
||||
"url": "http://bassistance.de/"
|
||||
},
|
||||
"url": "http://docs.jquery.com/QUnit",
|
||||
"license": {
|
||||
"name": "MIT",
|
||||
"url": "http://www.opensource.org/licenses/mit-license.php"
|
||||
},
|
||||
"description": "An easy-to-use JavaScript Unit Testing framework.",
|
||||
"keywords": [ "testing", "unit", "jquery" ],
|
||||
"lib": "qunit"
|
||||
}
|
||||
Vendored
Executable
+225
@@ -0,0 +1,225 @@
|
||||
/**
|
||||
* QUnit - A JavaScript Unit Testing Framework
|
||||
*
|
||||
* http://docs.jquery.com/QUnit
|
||||
*
|
||||
* Copyright (c) 2011 John Resig, Jörn Zaefferer
|
||||
* Dual licensed under the MIT (MIT-LICENSE.txt)
|
||||
* or GPL (GPL-LICENSE.txt) licenses.
|
||||
*/
|
||||
|
||||
/** Font Family and Sizes */
|
||||
|
||||
#qunit-tests, #qunit-header, #qunit-banner, #qunit-testrunner-toolbar, #qunit-userAgent, #qunit-testresult {
|
||||
font-family: "Helvetica Neue Light", "HelveticaNeue-Light", "Helvetica Neue", Calibri, Helvetica, Arial, sans-serif;
|
||||
}
|
||||
|
||||
#qunit-testrunner-toolbar, #qunit-userAgent, #qunit-testresult, #qunit-tests li { font-size: small; }
|
||||
#qunit-tests { font-size: smaller; }
|
||||
|
||||
|
||||
/** Resets */
|
||||
|
||||
#qunit-tests, #qunit-tests ol, #qunit-header, #qunit-banner, #qunit-userAgent, #qunit-testresult {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
|
||||
/** Header */
|
||||
|
||||
#qunit-header {
|
||||
padding: 0.5em 0 0.5em 1em;
|
||||
|
||||
color: #8699a4;
|
||||
background-color: #0d3349;
|
||||
|
||||
font-size: 1.5em;
|
||||
line-height: 1em;
|
||||
font-weight: normal;
|
||||
|
||||
border-radius: 15px 15px 0 0;
|
||||
-moz-border-radius: 15px 15px 0 0;
|
||||
-webkit-border-top-right-radius: 15px;
|
||||
-webkit-border-top-left-radius: 15px;
|
||||
}
|
||||
|
||||
#qunit-header a {
|
||||
text-decoration: none;
|
||||
color: #c2ccd1;
|
||||
}
|
||||
|
||||
#qunit-header a:hover,
|
||||
#qunit-header a:focus {
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
#qunit-banner {
|
||||
height: 5px;
|
||||
}
|
||||
|
||||
#qunit-testrunner-toolbar {
|
||||
padding: 0.5em 0 0.5em 2em;
|
||||
color: #5E740B;
|
||||
background-color: #eee;
|
||||
}
|
||||
|
||||
#qunit-userAgent {
|
||||
padding: 0.5em 0 0.5em 2.5em;
|
||||
background-color: #2b81af;
|
||||
color: #fff;
|
||||
text-shadow: rgba(0, 0, 0, 0.5) 2px 2px 1px;
|
||||
}
|
||||
|
||||
|
||||
/** Tests: Pass/Fail */
|
||||
|
||||
#qunit-tests {
|
||||
list-style-position: inside;
|
||||
}
|
||||
|
||||
#qunit-tests li {
|
||||
padding: 0.4em 0.5em 0.4em 2.5em;
|
||||
border-bottom: 1px solid #fff;
|
||||
list-style-position: inside;
|
||||
}
|
||||
|
||||
#qunit-tests.hidepass li.pass, #qunit-tests.hidepass li.running {
|
||||
display: none;
|
||||
}
|
||||
|
||||
#qunit-tests li strong {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
#qunit-tests li a {
|
||||
padding: 0.5em;
|
||||
color: #c2ccd1;
|
||||
text-decoration: none;
|
||||
}
|
||||
#qunit-tests li a:hover,
|
||||
#qunit-tests li a:focus {
|
||||
color: #000;
|
||||
}
|
||||
|
||||
#qunit-tests ol {
|
||||
margin-top: 0.5em;
|
||||
padding: 0.5em;
|
||||
|
||||
background-color: #fff;
|
||||
|
||||
border-radius: 15px;
|
||||
-moz-border-radius: 15px;
|
||||
-webkit-border-radius: 15px;
|
||||
|
||||
box-shadow: inset 0px 2px 13px #999;
|
||||
-moz-box-shadow: inset 0px 2px 13px #999;
|
||||
-webkit-box-shadow: inset 0px 2px 13px #999;
|
||||
}
|
||||
|
||||
#qunit-tests table {
|
||||
border-collapse: collapse;
|
||||
margin-top: .2em;
|
||||
}
|
||||
|
||||
#qunit-tests th {
|
||||
text-align: right;
|
||||
vertical-align: top;
|
||||
padding: 0 .5em 0 0;
|
||||
}
|
||||
|
||||
#qunit-tests td {
|
||||
vertical-align: top;
|
||||
}
|
||||
|
||||
#qunit-tests pre {
|
||||
margin: 0;
|
||||
white-space: pre-wrap;
|
||||
word-wrap: break-word;
|
||||
}
|
||||
|
||||
#qunit-tests del {
|
||||
background-color: #e0f2be;
|
||||
color: #374e0c;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
#qunit-tests ins {
|
||||
background-color: #ffcaca;
|
||||
color: #500;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
/*** Test Counts */
|
||||
|
||||
#qunit-tests b.counts { color: black; }
|
||||
#qunit-tests b.passed { color: #5E740B; }
|
||||
#qunit-tests b.failed { color: #710909; }
|
||||
|
||||
#qunit-tests li li {
|
||||
margin: 0.5em;
|
||||
padding: 0.4em 0.5em 0.4em 0.5em;
|
||||
background-color: #fff;
|
||||
border-bottom: none;
|
||||
list-style-position: inside;
|
||||
}
|
||||
|
||||
/*** Passing Styles */
|
||||
|
||||
#qunit-tests li li.pass {
|
||||
color: #5E740B;
|
||||
background-color: #fff;
|
||||
border-left: 26px solid #C6E746;
|
||||
}
|
||||
|
||||
#qunit-tests .pass { color: #528CE0; background-color: #D2E0E6; }
|
||||
#qunit-tests .pass .test-name { color: #366097; }
|
||||
|
||||
#qunit-tests .pass .test-actual,
|
||||
#qunit-tests .pass .test-expected { color: #999999; }
|
||||
|
||||
#qunit-banner.qunit-pass { background-color: #C6E746; }
|
||||
|
||||
/*** Failing Styles */
|
||||
|
||||
#qunit-tests li li.fail {
|
||||
color: #710909;
|
||||
background-color: #fff;
|
||||
border-left: 26px solid #EE5757;
|
||||
}
|
||||
|
||||
#qunit-tests > li:last-child {
|
||||
border-radius: 0 0 15px 15px;
|
||||
-moz-border-radius: 0 0 15px 15px;
|
||||
-webkit-border-bottom-right-radius: 15px;
|
||||
-webkit-border-bottom-left-radius: 15px;
|
||||
}
|
||||
|
||||
#qunit-tests .fail { color: #000000; background-color: #EE5757; }
|
||||
#qunit-tests .fail .test-name,
|
||||
#qunit-tests .fail .module-name { color: #000000; }
|
||||
|
||||
#qunit-tests .fail .test-actual { color: #EE5757; }
|
||||
#qunit-tests .fail .test-expected { color: green; }
|
||||
|
||||
#qunit-banner.qunit-fail { background-color: #EE5757; }
|
||||
|
||||
|
||||
/** Result */
|
||||
|
||||
#qunit-testresult {
|
||||
padding: 0.5em 0.5em 0.5em 2.5em;
|
||||
|
||||
color: #2b81af;
|
||||
background-color: #D2E0E6;
|
||||
|
||||
border-bottom: 1px solid white;
|
||||
}
|
||||
|
||||
/** Fixture */
|
||||
|
||||
#qunit-fixture {
|
||||
position: absolute;
|
||||
top: -10000px;
|
||||
left: -10000px;
|
||||
}
|
||||
Vendored
Executable
+1442
File diff suppressed because it is too large
Load Diff
Vendored
Executable
+24
@@ -0,0 +1,24 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>QUnit Test Suite</title>
|
||||
<link rel="stylesheet" href="../qunit/qunit.css" type="text/css" media="screen">
|
||||
<script type="text/javascript" src="../qunit/qunit.js"></script>
|
||||
<script type="text/javascript" src="test.js"></script>
|
||||
<script type="text/javascript" src="same.js"></script>
|
||||
<script>
|
||||
var logs = ["begin", "testStart", "testDone", "log", "moduleStart", "moduleDone", "done"];
|
||||
for (var i = 0; i < logs.length; i++) {
|
||||
(function() {
|
||||
var log = logs[i];
|
||||
QUnit[log] = function() {
|
||||
console.log(log, arguments);
|
||||
};
|
||||
})();
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<div id="qunit-fixture">test markup</div>
|
||||
</body>
|
||||
</html>
|
||||
Vendored
Executable
+19
@@ -0,0 +1,19 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<title>QUnit Test Suite</title>
|
||||
<link rel="stylesheet" href="../qunit/qunit.css" type="text/css" media="screen">
|
||||
<script type="text/javascript" src="../qunit/qunit.js"></script>
|
||||
<script type="text/javascript" src="test.js"></script>
|
||||
<script type="text/javascript" src="same.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<h1 id="qunit-header">QUnit Test Suite</h1>
|
||||
<h2 id="qunit-banner"></h2>
|
||||
<div id="qunit-testrunner-toolbar"></div>
|
||||
<h2 id="qunit-userAgent"></h2>
|
||||
<ol id="qunit-tests"></ol>
|
||||
<div id="qunit-fixture">test markup</div>
|
||||
</body>
|
||||
</html>
|
||||
Vendored
Executable
+17
@@ -0,0 +1,17 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>QUnit Test Suite</title>
|
||||
<link rel="stylesheet" href="../qunit/qunit.css" type="text/css" media="screen">
|
||||
<script type="text/javascript" src="../qunit/qunit.js"></script>
|
||||
<script type="text/javascript" src="logs.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<h1 id="qunit-header">QUnit Test Suite</h1>
|
||||
<h2 id="qunit-banner"></h2>
|
||||
<div id="qunit-testrunner-toolbar"></div>
|
||||
<h2 id="qunit-userAgent"></h2>
|
||||
<ol id="qunit-tests"></ol>
|
||||
<div id="qunit-fixture">test markup</div>
|
||||
</body>
|
||||
</html>
|
||||
Vendored
Executable
+150
@@ -0,0 +1,150 @@
|
||||
// TODO disable reordering for this suite!
|
||||
|
||||
|
||||
var begin = 0,
|
||||
moduleStart = 0,
|
||||
moduleDone = 0,
|
||||
testStart = 0,
|
||||
testDone = 0,
|
||||
log = 0,
|
||||
moduleContext,
|
||||
moduleDoneContext,
|
||||
testContext,
|
||||
testDoneContext,
|
||||
logContext;
|
||||
|
||||
QUnit.begin = function() {
|
||||
begin++;
|
||||
};
|
||||
QUnit.done = function() {
|
||||
};
|
||||
QUnit.moduleStart = function(context) {
|
||||
moduleStart++;
|
||||
moduleContext = context;
|
||||
};
|
||||
QUnit.moduleDone = function(context) {
|
||||
moduleDone++;
|
||||
moduleDoneContext = context;
|
||||
};
|
||||
QUnit.testStart = function(context) {
|
||||
testStart++;
|
||||
testContext = context;
|
||||
};
|
||||
QUnit.testDone = function(context) {
|
||||
testDone++;
|
||||
testDoneContext = context;
|
||||
};
|
||||
QUnit.log = function(context) {
|
||||
log++;
|
||||
logContext = context;
|
||||
};
|
||||
|
||||
var logs = ["begin", "testStart", "testDone", "log", "moduleStart", "moduleDone", "done"];
|
||||
for (var i = 0; i < logs.length; i++) {
|
||||
(function() {
|
||||
var log = logs[i],
|
||||
logger = QUnit[log];
|
||||
QUnit[log] = function() {
|
||||
console.log(log, arguments);
|
||||
logger.apply(this, arguments);
|
||||
};
|
||||
})();
|
||||
}
|
||||
|
||||
module("logs1");
|
||||
|
||||
test("test1", 13, function() {
|
||||
equal(begin, 1);
|
||||
equal(moduleStart, 1);
|
||||
equal(testStart, 1);
|
||||
equal(testDone, 0);
|
||||
equal(moduleDone, 0);
|
||||
|
||||
deepEqual(logContext, {
|
||||
result: true,
|
||||
message: undefined,
|
||||
actual: 0,
|
||||
expected: 0
|
||||
});
|
||||
equal("foo", "foo", "msg");
|
||||
deepEqual(logContext, {
|
||||
result: true,
|
||||
message: "msg",
|
||||
actual: "foo",
|
||||
expected: "foo"
|
||||
});
|
||||
strictEqual(testDoneContext, undefined);
|
||||
deepEqual(testContext, {
|
||||
name: "test1"
|
||||
});
|
||||
strictEqual(moduleDoneContext, undefined);
|
||||
deepEqual(moduleContext, {
|
||||
name: "logs1"
|
||||
});
|
||||
|
||||
equal(log, 12);
|
||||
});
|
||||
test("test2", 10, function() {
|
||||
equal(begin, 1);
|
||||
equal(moduleStart, 1);
|
||||
equal(testStart, 2);
|
||||
equal(testDone, 1);
|
||||
equal(moduleDone, 0);
|
||||
|
||||
deepEqual(testDoneContext, {
|
||||
name: "test1",
|
||||
failed: 0,
|
||||
passed: 13,
|
||||
total: 13
|
||||
});
|
||||
deepEqual(testContext, {
|
||||
name: "test2"
|
||||
});
|
||||
strictEqual(moduleDoneContext, undefined);
|
||||
deepEqual(moduleContext, {
|
||||
name: "logs1"
|
||||
});
|
||||
|
||||
equal(log, 22);
|
||||
});
|
||||
|
||||
module("logs2");
|
||||
|
||||
test("test1", 9, function() {
|
||||
equal(begin, 1);
|
||||
equal(moduleStart, 2);
|
||||
equal(testStart, 3);
|
||||
equal(testDone, 2);
|
||||
equal(moduleDone, 1);
|
||||
|
||||
deepEqual(testContext, {
|
||||
name: "test1"
|
||||
});
|
||||
deepEqual(moduleDoneContext, {
|
||||
name: "logs1",
|
||||
failed: 0,
|
||||
passed: 23,
|
||||
total: 23
|
||||
});
|
||||
deepEqual(moduleContext, {
|
||||
name: "logs2"
|
||||
});
|
||||
|
||||
equal(log, 31);
|
||||
});
|
||||
test("test2", 8, function() {
|
||||
equal(begin, 1);
|
||||
equal(moduleStart, 2);
|
||||
equal(testStart, 4);
|
||||
equal(testDone, 3);
|
||||
equal(moduleDone, 1);
|
||||
|
||||
deepEqual(testContext, {
|
||||
name: "test2"
|
||||
});
|
||||
deepEqual(moduleContext, {
|
||||
name: "logs2"
|
||||
});
|
||||
|
||||
equal(log, 39);
|
||||
});
|
||||
Vendored
Executable
+1421
File diff suppressed because it is too large
Load Diff
Vendored
Executable
+324
@@ -0,0 +1,324 @@
|
||||
test("module without setup/teardown (default)", function() {
|
||||
expect(1);
|
||||
ok(true);
|
||||
});
|
||||
|
||||
test("expect in test", 3, function() {
|
||||
ok(true);
|
||||
ok(true);
|
||||
ok(true);
|
||||
});
|
||||
|
||||
test("expect in test", 1, function() {
|
||||
ok(true);
|
||||
});
|
||||
|
||||
module("setup test", {
|
||||
setup: function() {
|
||||
ok(true);
|
||||
}
|
||||
});
|
||||
|
||||
test("module with setup", function() {
|
||||
expect(2);
|
||||
ok(true);
|
||||
});
|
||||
|
||||
test("module with setup, expect in test call", 2, function() {
|
||||
ok(true);
|
||||
});
|
||||
|
||||
var state;
|
||||
|
||||
module("setup/teardown test", {
|
||||
setup: function() {
|
||||
state = true;
|
||||
ok(true);
|
||||
},
|
||||
teardown: function() {
|
||||
ok(true);
|
||||
}
|
||||
});
|
||||
|
||||
test("module with setup/teardown", function() {
|
||||
expect(3);
|
||||
ok(true);
|
||||
});
|
||||
|
||||
module("setup/teardown test 2");
|
||||
|
||||
test("module without setup/teardown", function() {
|
||||
expect(1);
|
||||
ok(true);
|
||||
});
|
||||
|
||||
if (typeof setTimeout !== 'undefined') {
|
||||
state = 'fail';
|
||||
|
||||
module("teardown and stop", {
|
||||
teardown: function() {
|
||||
equal(state, "done", "Test teardown.");
|
||||
}
|
||||
});
|
||||
|
||||
test("teardown must be called after test ended", function() {
|
||||
expect(1);
|
||||
stop();
|
||||
setTimeout(function() {
|
||||
state = "done";
|
||||
start();
|
||||
}, 13);
|
||||
});
|
||||
|
||||
module("async setup test", {
|
||||
setup: function() {
|
||||
stop();
|
||||
setTimeout(function(){
|
||||
ok(true);
|
||||
start();
|
||||
}, 500);
|
||||
}
|
||||
});
|
||||
|
||||
asyncTest("module with async setup", function() {
|
||||
expect(2);
|
||||
ok(true);
|
||||
start();
|
||||
});
|
||||
|
||||
module("async teardown test", {
|
||||
teardown: function() {
|
||||
stop();
|
||||
setTimeout(function(){
|
||||
ok(true);
|
||||
start();
|
||||
}, 500);
|
||||
}
|
||||
});
|
||||
|
||||
asyncTest("module with async teardown", function() {
|
||||
expect(2);
|
||||
ok(true);
|
||||
start();
|
||||
});
|
||||
|
||||
module("asyncTest");
|
||||
|
||||
asyncTest("asyncTest", function() {
|
||||
expect(2);
|
||||
ok(true);
|
||||
setTimeout(function() {
|
||||
state = "done";
|
||||
ok(true);
|
||||
start();
|
||||
}, 13);
|
||||
});
|
||||
|
||||
asyncTest("asyncTest", 2, function() {
|
||||
ok(true);
|
||||
setTimeout(function() {
|
||||
state = "done";
|
||||
ok(true);
|
||||
start();
|
||||
}, 13);
|
||||
});
|
||||
|
||||
test("sync", 2, function() {
|
||||
stop();
|
||||
setTimeout(function() {
|
||||
ok(true);
|
||||
start();
|
||||
}, 13);
|
||||
stop();
|
||||
setTimeout(function() {
|
||||
ok(true);
|
||||
start();
|
||||
}, 125);
|
||||
});
|
||||
}
|
||||
|
||||
module("save scope", {
|
||||
setup: function() {
|
||||
this.foo = "bar";
|
||||
},
|
||||
teardown: function() {
|
||||
deepEqual(this.foo, "bar");
|
||||
}
|
||||
});
|
||||
test("scope check", function() {
|
||||
expect(2);
|
||||
deepEqual(this.foo, "bar");
|
||||
});
|
||||
|
||||
module("simple testEnvironment setup", {
|
||||
foo: "bar",
|
||||
bugid: "#5311" // example of meta-data
|
||||
});
|
||||
test("scope check", function() {
|
||||
deepEqual(this.foo, "bar");
|
||||
});
|
||||
test("modify testEnvironment",function() {
|
||||
this.foo="hamster";
|
||||
});
|
||||
test("testEnvironment reset for next test",function() {
|
||||
deepEqual(this.foo, "bar");
|
||||
});
|
||||
|
||||
module("testEnvironment with object", {
|
||||
options:{
|
||||
recipe:"soup",
|
||||
ingredients:["hamster","onions"]
|
||||
}
|
||||
});
|
||||
test("scope check", function() {
|
||||
deepEqual(this.options, {recipe:"soup",ingredients:["hamster","onions"]}) ;
|
||||
});
|
||||
test("modify testEnvironment",function() {
|
||||
// since we do a shallow copy, the testEnvironment can be modified
|
||||
this.options.ingredients.push("carrots");
|
||||
});
|
||||
test("testEnvironment reset for next test",function() {
|
||||
deepEqual(this.options, {recipe:"soup",ingredients:["hamster","onions","carrots"]}, "Is this a bug or a feature? Could do a deep copy") ;
|
||||
});
|
||||
|
||||
|
||||
module("testEnvironment tests");
|
||||
|
||||
function makeurl() {
|
||||
var testEnv = QUnit.current_testEnvironment;
|
||||
var url = testEnv.url || 'http://example.com/search';
|
||||
var q = testEnv.q || 'a search test';
|
||||
return url + '?q='+encodeURIComponent(q);
|
||||
}
|
||||
|
||||
test("makeurl working",function() {
|
||||
equal( QUnit.current_testEnvironment, this, 'The current testEnvironment is global');
|
||||
equal( makeurl(), 'http://example.com/search?q=a%20search%20test', 'makeurl returns a default url if nothing specified in the testEnvironment');
|
||||
});
|
||||
|
||||
module("testEnvironment with makeurl settings", {
|
||||
url: 'http://google.com/',
|
||||
q: 'another_search_test'
|
||||
});
|
||||
test("makeurl working with settings from testEnvironment", function() {
|
||||
equal( makeurl(), 'http://google.com/?q=another_search_test', 'rather than passing arguments, we use test metadata to form the url');
|
||||
});
|
||||
test("each test can extend the module testEnvironment", {
|
||||
q:'hamstersoup'
|
||||
}, function() {
|
||||
equal( makeurl(), 'http://google.com/?q=hamstersoup', 'url from module, q from test');
|
||||
});
|
||||
|
||||
module("jsDump");
|
||||
test("jsDump output", function() {
|
||||
equals( QUnit.jsDump.parse([1, 2]), "[\n 1,\n 2\n]" );
|
||||
equals( QUnit.jsDump.parse({top: 5, left: 0}), "{\n \"top\": 5,\n \"left\": 0\n}" );
|
||||
if (typeof document !== 'undefined' && document.getElementById("qunit-header")) {
|
||||
equals( QUnit.jsDump.parse(document.getElementById("qunit-header")), "<h1 id=\"qunit-header\"></h1>" );
|
||||
equals( QUnit.jsDump.parse(document.getElementsByTagName("h1")), "[\n <h1 id=\"qunit-header\"></h1>\n]" );
|
||||
}
|
||||
});
|
||||
|
||||
module("assertions");
|
||||
test("raises",function() {
|
||||
function CustomError( message ) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
CustomError.prototype.toString = function() {
|
||||
return this.message;
|
||||
};
|
||||
|
||||
raises(
|
||||
function() {
|
||||
throw "error"
|
||||
}
|
||||
);
|
||||
|
||||
raises(
|
||||
function() {
|
||||
throw "error"
|
||||
},
|
||||
'raises with just a message, no expected'
|
||||
);
|
||||
|
||||
raises(
|
||||
function() {
|
||||
throw new CustomError();
|
||||
},
|
||||
CustomError,
|
||||
'raised error is an instance of CustomError'
|
||||
);
|
||||
|
||||
raises(
|
||||
function() {
|
||||
throw new CustomError("some error description");
|
||||
},
|
||||
/description/,
|
||||
"raised error message contains 'description'"
|
||||
);
|
||||
|
||||
raises(
|
||||
function() {
|
||||
throw new CustomError("some error description");
|
||||
},
|
||||
function( err ) {
|
||||
if ( (err instanceof CustomError) && /description/.test(err) ) {
|
||||
return true;
|
||||
}
|
||||
},
|
||||
"custom validation function"
|
||||
);
|
||||
|
||||
});
|
||||
|
||||
if (typeof document !== "undefined") {
|
||||
|
||||
module("fixture");
|
||||
test("setup", function() {
|
||||
document.getElementById("qunit-fixture").innerHTML = "foobar";
|
||||
});
|
||||
test("basics", function() {
|
||||
equal( document.getElementById("qunit-fixture").innerHTML, "test markup", "automatically reset" );
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
module("custom assertions");
|
||||
(function() {
|
||||
function mod2(value, expected, message) {
|
||||
var actual = value % 2;
|
||||
QUnit.push(actual == expected, actual, expected, message);
|
||||
}
|
||||
test("mod2", function() {
|
||||
mod2(2, 0, "2 % 2 == 0");
|
||||
mod2(3, 1, "3 % 2 == 1");
|
||||
})
|
||||
})();
|
||||
|
||||
(function() {
|
||||
var reset = QUnit.reset;
|
||||
function afterTest() {
|
||||
ok( false, "reset should not modify test status" );
|
||||
}
|
||||
module("reset");
|
||||
test("reset runs assertions", function() {
|
||||
QUnit.reset = function() {
|
||||
afterTest();
|
||||
reset.apply( this, arguments );
|
||||
};
|
||||
});
|
||||
test("reset runs assertions2", function() {
|
||||
QUnit.reset = reset;
|
||||
});
|
||||
})();
|
||||
|
||||
module("noglobals", {
|
||||
teardown: function() {
|
||||
delete window.badGlobalVariableIntroducedInTest;
|
||||
}
|
||||
});
|
||||
test("let teardown clean up globals", function() {
|
||||
// this test will always pass if run without ?noglobals=true
|
||||
window.badGlobalVariableIntroducedInTest = true;
|
||||
});
|
||||
+6014
File diff suppressed because it is too large
Load Diff
+1193
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,274 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
|
||||
Version 2, June 1991
|
||||
|
||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc. 675 Mass Ave,
|
||||
Cambridge, MA 02139, USA. Everyone is permitted to copy and distribute
|
||||
verbatim copies of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The licenses for most software are designed to take away your freedom to
|
||||
share and change it. By contrast, the GNU General Public License is
|
||||
intended to guarantee your freedom to share and change free software--to
|
||||
make sure the software is free for all its users. This General Public License
|
||||
applies to most of the Free Software Foundation's software and to any other
|
||||
program whose authors commit to using it. (Some other Free Software
|
||||
Foundation software is covered by the GNU Library General Public License
|
||||
instead.) You can apply it to your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not price. Our
|
||||
General Public Licenses are designed to make sure that you have the
|
||||
freedom to distribute copies of free software (and charge for this service if
|
||||
you wish), that you receive source code or can get it if you want it, that you
|
||||
can change the software or use pieces of it in new free programs; and that
|
||||
you know you can do these things.
|
||||
|
||||
To protect your rights, we need to make restrictions that forbid anyone to
|
||||
deny you these rights or to ask you to surrender the rights. These restrictions
|
||||
translate to certain responsibilities for you if you distribute copies of the
|
||||
software, or if you modify it.
|
||||
|
||||
For example, if you distribute copies of such a program, whether gratis or for
|
||||
a fee, you must give the recipients all the rights that you have. You must make
|
||||
sure that they, too, receive or can get the source code. And you must show
|
||||
them these terms so they know their rights.
|
||||
|
||||
We protect your rights with two steps: (1) copyright the software, and (2)
|
||||
offer you this license which gives you legal permission to copy, distribute
|
||||
and/or modify the software.
|
||||
|
||||
Also, for each author's protection and ours, we want to make certain that
|
||||
everyone understands that there is no warranty for this free software. If the
|
||||
software is modified by someone else and passed on, we want its recipients
|
||||
to know that what they have is not the original, so that any problems
|
||||
introduced by others will not reflect on the original authors' reputations.
|
||||
|
||||
Finally, any free program is threatened constantly by software patents. We
|
||||
wish to avoid the danger that redistributors of a free program will individually
|
||||
obtain patent licenses, in effect making the program proprietary. To prevent
|
||||
this, we have made it clear that any patent must be licensed for everyone's
|
||||
free use or not licensed at all.
|
||||
|
||||
The precise terms and conditions for copying, distribution and modification
|
||||
follow.
|
||||
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND
|
||||
MODIFICATION
|
||||
|
||||
0. This License applies to any program or other work which contains a notice
|
||||
placed by the copyright holder saying it may be distributed under the terms
|
||||
of this General Public License. The "Program", below, refers to any such
|
||||
program or work, and a "work based on the Program" means either the
|
||||
Program or any derivative work under copyright law: that is to say, a work
|
||||
containing the Program or a portion of it, either verbatim or with
|
||||
modifications and/or translated into another language. (Hereinafter, translation
|
||||
is included without limitation in the term "modification".) Each licensee is
|
||||
addressed as "you".
|
||||
|
||||
Activities other than copying, distribution and modification are not covered
|
||||
by this License; they are outside its scope. The act of running the Program is
|
||||
not restricted, and the output from the Program is covered only if its contents
|
||||
constitute a work based on the Program (independent of having been made
|
||||
by running the Program). Whether that is true depends on what the Program
|
||||
does.
|
||||
|
||||
1. You may copy and distribute verbatim copies of the Program's source
|
||||
code as you receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice and
|
||||
disclaimer of warranty; keep intact all the notices that refer to this License
|
||||
and to the absence of any warranty; and give any other recipients of the
|
||||
Program a copy of this License along with the Program.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy, and you
|
||||
may at your option offer warranty protection in exchange for a fee.
|
||||
|
||||
2. You may modify your copy or copies of the Program or any portion of it,
|
||||
thus forming a work based on the Program, and copy and distribute such
|
||||
modifications or work under the terms of Section 1 above, provided that you
|
||||
also meet all of these conditions:
|
||||
|
||||
a) You must cause the modified files to carry prominent notices stating that
|
||||
you changed the files and the date of any change.
|
||||
|
||||
b) You must cause any work that you distribute or publish, that in whole or in
|
||||
part contains or is derived from the Program or any part thereof, to be
|
||||
licensed as a whole at no charge to all third parties under the terms of this
|
||||
License.
|
||||
|
||||
c) If the modified program normally reads commands interactively when run,
|
||||
you must cause it, when started running for such interactive use in the most
|
||||
ordinary way, to print or display an announcement including an appropriate
|
||||
copyright notice and a notice that there is no warranty (or else, saying that
|
||||
you provide a warranty) and that users may redistribute the program under
|
||||
these conditions, and telling the user how to view a copy of this License.
|
||||
(Exception: if the Program itself is interactive but does not normally print such
|
||||
an announcement, your work based on the Program is not required to print
|
||||
an announcement.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If identifiable
|
||||
sections of that work are not derived from the Program, and can be
|
||||
reasonably considered independent and separate works in themselves, then
|
||||
this License, and its terms, do not apply to those sections when you distribute
|
||||
them as separate works. But when you distribute the same sections as part
|
||||
of a whole which is a work based on the Program, the distribution of the
|
||||
whole must be on the terms of this License, whose permissions for other
|
||||
licensees extend to the entire whole, and thus to each and every part
|
||||
regardless of who wrote it.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest your rights to
|
||||
work written entirely by you; rather, the intent is to exercise the right to
|
||||
control the distribution of derivative or collective works based on the
|
||||
Program.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Program
|
||||
with the Program (or with a work based on the Program) on a volume of a
|
||||
storage or distribution medium does not bring the other work under the scope
|
||||
of this License.
|
||||
|
||||
3. You may copy and distribute the Program (or a work based on it, under
|
||||
Section 2) in object code or executable form under the terms of Sections 1
|
||||
and 2 above provided that you also do one of the following:
|
||||
|
||||
a) Accompany it with the complete corresponding machine-readable source
|
||||
code, which must be distributed under the terms of Sections 1 and 2 above
|
||||
on a medium customarily used for software interchange; or,
|
||||
|
||||
b) Accompany it with a written offer, valid for at least three years, to give
|
||||
any third party, for a charge no more than your cost of physically performing
|
||||
source distribution, a complete machine-readable copy of the corresponding
|
||||
source code, to be distributed under the terms of Sections 1 and 2 above on
|
||||
a medium customarily used for software interchange; or,
|
||||
|
||||
c) Accompany it with the information you received as to the offer to distribute
|
||||
corresponding source code. (This alternative is allowed only for
|
||||
noncommercial distribution and only if you received the program in object
|
||||
code or executable form with such an offer, in accord with Subsection b
|
||||
above.)
|
||||
|
||||
The source code for a work means the preferred form of the work for
|
||||
making modifications to it. For an executable work, complete source code
|
||||
means all the source code for all modules it contains, plus any associated
|
||||
interface definition files, plus the scripts used to control compilation and
|
||||
installation of the executable. However, as a special exception, the source
|
||||
code distributed need not include anything that is normally distributed (in
|
||||
either source or binary form) with the major components (compiler, kernel,
|
||||
and so on) of the operating system on which the executable runs, unless that
|
||||
component itself accompanies the executable.
|
||||
|
||||
If distribution of executable or object code is made by offering access to
|
||||
copy from a designated place, then offering equivalent access to copy the
|
||||
source code from the same place counts as distribution of the source code,
|
||||
even though third parties are not compelled to copy the source along with the
|
||||
object code.
|
||||
|
||||
4. You may not copy, modify, sublicense, or distribute the Program except as
|
||||
expressly provided under this License. Any attempt otherwise to copy,
|
||||
modify, sublicense or distribute the Program is void, and will automatically
|
||||
terminate your rights under this License. However, parties who have received
|
||||
copies, or rights, from you under this License will not have their licenses
|
||||
terminated so long as such parties remain in full compliance.
|
||||
|
||||
5. You are not required to accept this License, since you have not signed it.
|
||||
However, nothing else grants you permission to modify or distribute the
|
||||
Program or its derivative works. These actions are prohibited by law if you
|
||||
do not accept this License. Therefore, by modifying or distributing the
|
||||
Program (or any work based on the Program), you indicate your acceptance
|
||||
of this License to do so, and all its terms and conditions for copying,
|
||||
distributing or modifying the Program or works based on it.
|
||||
|
||||
6. Each time you redistribute the Program (or any work based on the
|
||||
Program), the recipient automatically receives a license from the original
|
||||
licensor to copy, distribute or modify the Program subject to these terms and
|
||||
conditions. You may not impose any further restrictions on the recipients'
|
||||
exercise of the rights granted herein. You are not responsible for enforcing
|
||||
compliance by third parties to this License.
|
||||
|
||||
7. If, as a consequence of a court judgment or allegation of patent
|
||||
infringement or for any other reason (not limited to patent issues), conditions
|
||||
are imposed on you (whether by court order, agreement or otherwise) that
|
||||
contradict the conditions of this License, they do not excuse you from the
|
||||
conditions of this License. If you cannot distribute so as to satisfy
|
||||
simultaneously your obligations under this License and any other pertinent
|
||||
obligations, then as a consequence you may not distribute the Program at all.
|
||||
For example, if a patent license would not permit royalty-free redistribution
|
||||
of the Program by all those who receive copies directly or indirectly through
|
||||
you, then the only way you could satisfy both it and this License would be to
|
||||
refrain entirely from distribution of the Program.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under any
|
||||
particular circumstance, the balance of the section is intended to apply and
|
||||
the section as a whole is intended to apply in other circumstances.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any patents or
|
||||
other property right claims or to contest validity of any such claims; this
|
||||
section has the sole purpose of protecting the integrity of the free software
|
||||
distribution system, which is implemented by public license practices. Many
|
||||
people have made generous contributions to the wide range of software
|
||||
distributed through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing to
|
||||
distribute software through any other system and a licensee cannot impose
|
||||
that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to be a
|
||||
consequence of the rest of this License.
|
||||
|
||||
8. If the distribution and/or use of the Program is restricted in certain
|
||||
countries either by patents or by copyrighted interfaces, the original copyright
|
||||
holder who places the Program under this License may add an explicit
|
||||
geographical distribution limitation excluding those countries, so that
|
||||
distribution is permitted only in or among countries not thus excluded. In such
|
||||
case, this License incorporates the limitation as if written in the body of this
|
||||
License.
|
||||
|
||||
9. The Free Software Foundation may publish revised and/or new versions
|
||||
of the General Public License from time to time. Such new versions will be
|
||||
similar in spirit to the present version, but may differ in detail to address new
|
||||
problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Program specifies
|
||||
a version number of this License which applies to it and "any later version",
|
||||
you have the option of following the terms and conditions either of that
|
||||
version or of any later version published by the Free Software Foundation. If
|
||||
the Program does not specify a version number of this License, you may
|
||||
choose any version ever published by the Free Software Foundation.
|
||||
|
||||
10. If you wish to incorporate parts of the Program into other free programs
|
||||
whose distribution conditions are different, write to the author to ask for
|
||||
permission. For software which is copyrighted by the Free Software
|
||||
Foundation, write to the Free Software Foundation; we sometimes make
|
||||
exceptions for this. Our decision will be guided by the two goals of
|
||||
preserving the free status of all derivatives of our free software and of
|
||||
promoting the sharing and reuse of software generally.
|
||||
|
||||
NO WARRANTY
|
||||
|
||||
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE,
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT
|
||||
PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE
|
||||
STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
|
||||
OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT
|
||||
WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED,
|
||||
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND
|
||||
PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
|
||||
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL
|
||||
NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR
|
||||
AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR
|
||||
ANY OTHER PARTY WHO MAY MODIFY AND/OR
|
||||
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE
|
||||
LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL,
|
||||
SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES
|
||||
ARISING OUT OF THE USE OR INABILITY TO USE THE
|
||||
PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA
|
||||
OR DATA BEING RENDERED INACCURATE OR LOSSES
|
||||
SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE
|
||||
PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN
|
||||
IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF
|
||||
THE POSSIBILITY OF SUCH DAMAGES.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
@@ -0,0 +1 @@
|
||||
Hello !
|
||||
@@ -0,0 +1,420 @@
|
||||
/**
|
||||
* Grid()
|
||||
* by Bachir Soussi-Chiadmi www.g-u-i.net
|
||||
* version 2.0
|
||||
*/
|
||||
|
||||
(function($) {
|
||||
function Grid(ctx, settings){
|
||||
|
||||
var _defaults = {
|
||||
children:'', // tell which dom elmt to target, by default $ctx.children();
|
||||
cell_w: 20, cell_h: 20,
|
||||
cell_padding:{t:5,r:5,b:5,l:5}, // with or without padding cell width and height are the same
|
||||
padding:{t:5,r:5,b:5,l:5}, // padding (in cell) inside the grid where not placed element
|
||||
gouttiere: 5, // space between cells h and v
|
||||
lines: 20, columns: 20,// how much line and columns grid has
|
||||
grille: false, // see the grid with cell's free space infos
|
||||
groove: 0, // add groove attitude (randomize placement)
|
||||
positioning_mode:'random', // positioning_mode play with with the position on items
|
||||
max_distance:0, // distance max between prev item and current item. O = no limit
|
||||
min_distance:0, // distance min between prev item and current item. O = no limit
|
||||
},
|
||||
$ctx = $(ctx),
|
||||
_cells = new Array(),
|
||||
_positions = new Array(),
|
||||
_grid = this;
|
||||
|
||||
this.ctx = $ctx;
|
||||
this.settings = $.extend({}, _defaults, settings);
|
||||
|
||||
this.settings.init_maxdist = this.settings.max_distance;
|
||||
this.settings.init_mindist = this.settings.min_distance;
|
||||
|
||||
|
||||
// $.log('this.settings', this.settings);
|
||||
|
||||
// set dom grille visualsation context if enabled
|
||||
if (this.settings.grille) {
|
||||
$ctx.append('<div class="grille"><div>');
|
||||
$('.grille', $ctx).css({
|
||||
'width': '100%',
|
||||
'height': '100%',
|
||||
'position': 'relative'
|
||||
});
|
||||
}
|
||||
|
||||
// create all empty cells
|
||||
for (var l = 0; l < this.settings.lines; l++) {
|
||||
_cells[l] = new Array();
|
||||
for (var c = 0; c < this.settings.columns; c++) {
|
||||
_cells[l][c] = new Cell(this, c, l);
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
function _setPrevCell(){
|
||||
// _grid.prev_cell = false;
|
||||
switch(_grid.settings.positioning_mode){
|
||||
case 'lefttop': // add items from top left to bootm rif-ght
|
||||
_grid.prev_cell = _cells[0][0];
|
||||
break;
|
||||
case 'center': // add items from center of grid to both side randomly
|
||||
_grid.prev_cell = _cells[Math.floor(_grid.settings.lines*.5)][Math.floor(_grid.settings.columns*.5)];
|
||||
break;
|
||||
case 'borders': // add items from center of grid to both side randomly
|
||||
var side = Math.floor(Math.random()*4);
|
||||
// $.log('side = '+side);
|
||||
switch(side){
|
||||
case 0 :
|
||||
_grid.prev_cell = _cells[0][Math.floor(_grid.settings.columns*Math.random())];
|
||||
break;
|
||||
case 1 :
|
||||
_grid.prev_cell = _cells[_grid.settings.lines-1][Math.floor(_grid.settings.columns*Math.random())];
|
||||
break;
|
||||
case 2 :
|
||||
_grid.prev_cell = _cells[Math.floor(_grid.settings.lines*Math.random())][0];
|
||||
break;
|
||||
case 3 :
|
||||
_grid.prev_cell = _cells[Math.floor(_grid.settings.lines*Math.random())][_grid.settings.columns-1];
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 'random': // add items randomly
|
||||
default:
|
||||
_grid.prev_cell = _cells[Math.floor(_grid.settings.lines*Math.random())][Math.floor(_grid.settings.columns*Math.random())];
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
_setPrevCell();
|
||||
|
||||
|
||||
/**
|
||||
* placeTargets()
|
||||
*/
|
||||
function _placeTargets(){
|
||||
|
||||
_grid.settings.max_distance = _grid.settings.init_maxdist;
|
||||
_grid.settings.min_distance = _grid.settings.init_mindist;
|
||||
|
||||
|
||||
// parse targets
|
||||
var $targets = _grid.settings.children != '' ? $(_grid.settings.children+':not(.grid-placed)', $ctx) : $ctx.children(':not(.grid-placed)');
|
||||
|
||||
$targets.each(function() {
|
||||
|
||||
var $this = $(this),
|
||||
// get the width and height ( ! on cell unit ! how much cells it takes ? ) of item to be positioned
|
||||
this_cells_w = Math.ceil($this.width() / (_grid.settings.cell_w + _grid.settings.gouttiere)),
|
||||
this_cells_h = Math.ceil($this.height() / (_grid.settings.cell_h + _grid.settings.gouttiere)),
|
||||
// get free cells function of width and height of item
|
||||
free_cells = new Array();
|
||||
|
||||
while(free_cells.length == 0){
|
||||
free_cells = getFreeCells(this_cells_w, this_cells_h);
|
||||
if(free_cells.length == 0)
|
||||
_grid.settings.max_distance = _grid.settings.max_distance*1.2;
|
||||
}
|
||||
|
||||
if(free_cells.length > 0){
|
||||
|
||||
// positioning mode, to change this mode uncomment/comment lines after description
|
||||
switch(_grid.settings.positioning_mode){
|
||||
case 'lefttop': // add items from top left to bootm rif-ght
|
||||
var cell_num = 0,
|
||||
cell = free_cells[cell_num];
|
||||
break;
|
||||
default: // add items from center of grid to both side randomly
|
||||
// var cell_num = Math.floor((free_cells.length-1)*0.5 + (-2+Math.random()*4));
|
||||
// cell_num = cell_num > free_cells.length-1 ? free_cells.length-1 : ( cell_num < 0 ? 0 : cell_num );
|
||||
// var cell = free_cells[cell_num];
|
||||
var cell_num = Math.round(Math.random() * (free_cells.length - 1)),
|
||||
cell = free_cells[cell_num];
|
||||
break;
|
||||
}
|
||||
|
||||
_grid.prev_cell = cell;
|
||||
|
||||
var line_limit_loop = cell.row() + (this_cells_h),
|
||||
column_limit_loop = cell.column() + (this_cells_w);
|
||||
|
||||
for (var l = cell.row(); l < line_limit_loop; l++) {
|
||||
for (var c = cell.column(); c < column_limit_loop; c++) {
|
||||
var temp_cell = _cells[l][c];
|
||||
temp_cell.setFull();
|
||||
};
|
||||
};
|
||||
|
||||
// get tp and left coordinates
|
||||
// should be directly recorded in the cell object
|
||||
var top = cell.row() * (_grid.settings.cell_h + _grid.settings.gouttiere),
|
||||
left = cell.column() * (_grid.settings.cell_w + _grid.settings.gouttiere),
|
||||
groove = _grid.settings.groove;
|
||||
|
||||
// set groove ;)
|
||||
top = !groove ? top: top + Math.round(Math.random() * groove - groove / 2);
|
||||
left = !groove ? left: left + Math.round(Math.random() * groove - groove / 2);
|
||||
|
||||
// apply ccs position
|
||||
top += _grid.settings.cell_padding.t;
|
||||
left += _grid.settings.cell_padding.l;
|
||||
|
||||
var event = jQuery.Event("grid_positioned");
|
||||
event.top = top;
|
||||
event.left = left;
|
||||
|
||||
$this.css({
|
||||
'top': top,
|
||||
'left': left
|
||||
}).addClass('grid-positioned').trigger(event);
|
||||
}else{
|
||||
// $.log('GRID no free cells left');
|
||||
// if no free cells exist
|
||||
$this.css({
|
||||
'border': '2px solid red',
|
||||
'opacity': 0.2
|
||||
}).trigger('grid_removed');//.remove();
|
||||
}
|
||||
$this.addClass('grid-placed').trigger('grid_placed');
|
||||
}); // end children each
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* getFreeCells()
|
||||
*
|
||||
* @ width in cells
|
||||
* @ height in cells
|
||||
*
|
||||
* return array of cell objects
|
||||
*
|
||||
*/
|
||||
function getFreeCells(this_cells_w, this_cells_h){
|
||||
|
||||
var free_cells = new Array(),
|
||||
padding = _grid.settings.padding,
|
||||
// max_dist = _grid.settings.max_distance,
|
||||
// min_dist = _grid.settings.min_distance,
|
||||
max_dist_l = _grid.settings.lines * _grid.settings.max_distance,
|
||||
min_dist_l = _grid.settings.lines * _grid.settings.min_distance,
|
||||
max_dist_c = _grid.settings.columns * _grid.settings.max_distance,
|
||||
min_dist_c = _grid.settings.columns * _grid.settings.min_distance,
|
||||
prev_cell = _grid.prev_cell;
|
||||
|
||||
// $.log()
|
||||
|
||||
for (var l = 0; l < _grid.settings.lines; l++) {
|
||||
for (var c = 0; c < _grid.settings.columns; c++) {
|
||||
var cell = _cells[l][c];
|
||||
|
||||
/*
|
||||
TODO about the max_dist keep in mind that all element will not always be 1 cell elemnts !!
|
||||
*/
|
||||
|
||||
// here is a big stuff of conditionning
|
||||
// we check a lot of things
|
||||
// 1 - basicly if the cell is free
|
||||
// 2 - if the cell is under the padding limits
|
||||
// 3 - if she has enought space arround her
|
||||
// 4 - if we got a prev cell
|
||||
// 4.1 - if we got a max_dist != 0
|
||||
// 4.1.1 - if the cell is under the max limits
|
||||
// 4.2 - if we got a min_dist != 0
|
||||
// 4.2.1 - if the cell is behind the min limits
|
||||
|
||||
// if (cell.isFree() // if cell is free
|
||||
// && (cell.row() > padding.t && cell.row() < _grid.settings.lines - padding.b
|
||||
// && cell.column() > padding.l && cell.column() < _grid.settings.columns - padding.r
|
||||
// )
|
||||
// && (
|
||||
// (cell.getAround().right + 1) >= this_cells_w // if enought free space on the right
|
||||
// && (cell.getAround().bottom + 1) >= this_cells_h // if enought free space on the bottom
|
||||
// )
|
||||
// && ( !_grid.prev_cell // else if _grid.prev_cell undefined it's true
|
||||
// || ( // check max_dist AND min_dist
|
||||
// (!max_dist // if max_distance is 0 return (stop condition) true
|
||||
// || ( cell.row() < prev_cell.row()+max_dist && cell.row() > prev_cell.row()-max_dist
|
||||
// && cell.column() < prev_cell.column()+max_dist && cell.column() > prev_cell.column()-max_dist )// if we got max_distance and prev_cell we check the distance
|
||||
// )
|
||||
// &&
|
||||
// (!min_dist // if min_distance is 0 return (stop condition) true
|
||||
// || ( (cell.row() > prev_cell.row()+min_dist || cell.row() < prev_cell.row()-min_dist)
|
||||
// || (cell.column() > prev_cell.column()+min_dist || cell.column() < prev_cell.column()-min_dist) )// if we got min_distance and prev_cell we check the distance
|
||||
// )
|
||||
// )
|
||||
// )
|
||||
// ) { // true of first big stuff if
|
||||
|
||||
if (cell.isFree() // if cell is free
|
||||
&& (cell.row() > padding.t && cell.row() < _grid.settings.lines - padding.b
|
||||
&& cell.column() > padding.l && cell.column() < _grid.settings.columns - padding.r
|
||||
)
|
||||
&& (
|
||||
(cell.getAround().right + 1) >= this_cells_w // if enought free space on the right
|
||||
&& (cell.getAround().bottom + 1) >= this_cells_h // if enought free space on the bottom
|
||||
)
|
||||
&& ( !_grid.prev_cell // else if _grid.prev_cell undefined it's true
|
||||
|| ( // check max_dist AND min_dist
|
||||
((!max_dist_l && !max_dist_c) // if max_dist_l AND max_dist_c are 0 return (stop condition) true
|
||||
|| ( (!max_dist_l || (cell.row() < prev_cell.row()+max_dist_l && cell.row() > prev_cell.row()-max_dist_l)) // if max_dist_l is 0, return true, so abort "between test" on lines
|
||||
&& (!max_dist_c || (cell.column() < prev_cell.column()+max_dist_c && cell.column() > prev_cell.column()-max_dist_c)) ) // if max_dist_c is 0, return true, so abort "between test" on columns
|
||||
) // if we got max_distance and prev_cell we check the distance
|
||||
&&
|
||||
((!min_dist_l && !min_dist_c) // if min_dist_l AND min_dist_c are 0 return (stop condition) true
|
||||
|| ( (!min_dist_l || (cell.row() > prev_cell.row()+min_dist_c || cell.row() < prev_cell.row()-min_dist_c))
|
||||
|| (!min_dist_c || (cell.column() > prev_cell.column()+min_dist_c || cell.column() < prev_cell.column()-min_dist_c)) )// if we got min_distance and prev_cell we check the distance
|
||||
)
|
||||
)
|
||||
)
|
||||
) { // true of first big stuff if
|
||||
var good = true;
|
||||
for (var i = 1; i < this_cells_w; i++) { // for each free cells needed on right
|
||||
var temp_cell = _cells[l][c + i];
|
||||
if ((temp_cell.getAround().bottom + 1) < this_cells_h) { // if enought free space on bottom
|
||||
good = false;
|
||||
break;
|
||||
}
|
||||
};
|
||||
if (good) free_cells.push(cell);
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
return free_cells;
|
||||
}
|
||||
|
||||
/**
|
||||
* Cell()
|
||||
*/
|
||||
function Cell(g, c, r) {
|
||||
var _grid = g,
|
||||
_column = c,
|
||||
_row = r,
|
||||
_free = true,
|
||||
_free_cell_right = _grid.settings.columns - 1 - c,
|
||||
_free_cell_bottom = _grid.settings.lines - 1 - l;
|
||||
|
||||
if (_grid.settings.grille) {
|
||||
var _table = '<table>';
|
||||
_table += '<tr><td> </td><td> </td><td> </td></tr>';
|
||||
// _table += '<tr><td> </td><td class="state">'+_free+'</td><td class="fr">'+_free_cell_right+'</td></tr>';
|
||||
_table += '<tr><td> </td><td> </td><td class="fr">' + _free_cell_right + '</td></tr>';
|
||||
_table += '<tr><td> </td><td class="fb">' + _free_cell_bottom + '</td><td> </td></tr>';
|
||||
_table += '</table>';
|
||||
_grid.ctx.find('.grille').append('<div class="cell-' + l + '-' + c + '">' + _table + '<div>');
|
||||
var _dom = $('.cell-' + l + '-' + c, _grid.ctx.find('.grille'));
|
||||
_dom.css({
|
||||
'position': 'absolute',
|
||||
'top': _row * (_grid.settings.cell_h + _grid.settings.gouttiere) + _grid.settings.cell_padding.t,
|
||||
'left': _column * (_grid.settings.cell_w + _grid.settings.gouttiere) + _grid.settings.cell_padding.l,
|
||||
'width': _grid.settings.cell_w,
|
||||
'height': _grid.settings.cell_h,
|
||||
'backgroundColor': '#00FF00',
|
||||
'opacity': 0.6
|
||||
});
|
||||
// $('td', _dom).css({
|
||||
// 'fontSize': '8px'
|
||||
// });
|
||||
}
|
||||
|
||||
this.isFree = function() { return _free; };
|
||||
|
||||
this.getPos = function() { return { c: _column, l: _row }; };
|
||||
this.column = function() { return _column; };
|
||||
this.row = function() { return _row; };
|
||||
|
||||
this.getAround = function() { return { right: _free_cell_right, bottom: _free_cell_bottom }; };
|
||||
|
||||
this.setFull = function() {
|
||||
|
||||
_free = false;
|
||||
_free_cell_bottom = -1;
|
||||
_free_cell_right = -1;
|
||||
|
||||
if (_grid.settings.grille) {
|
||||
_dom.css({
|
||||
'backgroundColor': '#0000FF'
|
||||
});
|
||||
$('.fb', _dom).html(_free_cell_bottom);
|
||||
$('.fr', _dom).html(_free_cell_right);
|
||||
}
|
||||
|
||||
_propageFreeCells();
|
||||
};
|
||||
|
||||
this.setFreeCellsRight = function(right) {
|
||||
if (_free) {
|
||||
// $.log('_setFreeCellRigth | _free_cell_right = ' + _free_cell_right + ' | new right = ' + right);
|
||||
_free_cell_right = right;
|
||||
if (_grid.settings.grille) $('.fr', _dom).html(_free_cell_right);
|
||||
_propageFreeCellsLeft();
|
||||
}
|
||||
};
|
||||
|
||||
this.setFreeCellsBottom = function(bottom) {
|
||||
if (_free) {
|
||||
// $.log('_setFreeCellsBottom | _free_cell_bottom = ' + _free_cell_bottom + ' | new right = ' + bottom);
|
||||
_free_cell_bottom = bottom;
|
||||
if (_grid.settings.grille) $('.fb', _dom).html(_free_cell_bottom);
|
||||
_propageFreeCellsTop();
|
||||
}
|
||||
};
|
||||
|
||||
function _propageFreeCells() {
|
||||
// $.log('_propageFreeCells');
|
||||
_propageFreeCellsLeft();
|
||||
_propageFreeCellsTop();
|
||||
};
|
||||
|
||||
function _propageFreeCellsLeft() {
|
||||
// $.log('_propageFreeCellsLeft | _column = '+_column);
|
||||
if (_column > 0) {
|
||||
var left_cel = _cells[_row][_column - 1];
|
||||
left_cel.setFreeCellsRight(_free_cell_right + 1);
|
||||
}
|
||||
};
|
||||
|
||||
function _propageFreeCellsTop() {
|
||||
// $.log('_propageFreeCellsTop | _row = '+_row);
|
||||
if (_row > 0) {
|
||||
var top_cel = _cells[_row - 1][_column];
|
||||
top_cel.setFreeCellsBottom(_free_cell_bottom + 1);
|
||||
}
|
||||
};
|
||||
|
||||
if (typeof Cell.initialized == "undefined") {
|
||||
Cell.prototype.infos = function() {
|
||||
//console.log('cell | column = ' + this.column() + ', line = ' + this.row() + ', free = ' + this.isFree() + ', free cell right = ' + this.getAround().right + ', free cell bottom = ' + this.getAround().bottom);
|
||||
};
|
||||
|
||||
Cell.initialized = true;
|
||||
}
|
||||
}; // cell()
|
||||
|
||||
if (typeof Node.initialized == "undefined") {
|
||||
|
||||
Grid.prototype.refresh = function() {
|
||||
_placeTargets();
|
||||
};
|
||||
|
||||
Grid.prototype.resetPrevCell = function() {
|
||||
_setPrevCell();
|
||||
// this.prev_cell = false;
|
||||
};
|
||||
|
||||
|
||||
Node.initialized = true;
|
||||
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
$.fn.grid = function(settings) {
|
||||
return this.each(function(index) {
|
||||
$(this).data('grid', new Grid(this, settings));
|
||||
});
|
||||
}
|
||||
})(jQuery);
|
||||
@@ -0,0 +1,380 @@
|
||||
/**
|
||||
* Grid()
|
||||
* by Bachir Soussi-Chiadmi www.g-u-i.net
|
||||
* version 2.0
|
||||
*/
|
||||
|
||||
function Grid(ctx, settings){
|
||||
|
||||
|
||||
var _defaults = {
|
||||
children:'', // tell which dom elmt to target, by default $ctx.children();
|
||||
cell_w: 20, cell_h: 20,
|
||||
cell_padding:{t:5,r:5,b:5,l:5}, // with or without padding cell width and height are the same
|
||||
padding:{t:5,r:5,b:5,l:5}, // padding (in cell) inside the grid where not placed element
|
||||
gouttiere: 5, // space between cells h and v
|
||||
lines: 20, columns: 20,// how much line and columns grid has
|
||||
grille: false, // see the grid with cell's free space infos
|
||||
groove: 0, // add groove attitude (randomize placement)
|
||||
positioning_mode:'random', // positioning_mode play with with the position on items
|
||||
max_distance:0, // distance max between prev item and current item. O = no limit
|
||||
min_distance:0, // distance min between prev item and current item. O = no limit
|
||||
},
|
||||
$ctx = ctx,
|
||||
_cells = new Array(),
|
||||
_positions = new Array(),
|
||||
_grid = this;
|
||||
|
||||
this.ctx = $ctx;
|
||||
this.settings = $.extend({}, _defaults, settings);
|
||||
|
||||
|
||||
|
||||
// $.log('this.settings', this.settings);
|
||||
|
||||
// set dom grille visualsation context if enabled
|
||||
if (this.settings.grille) {
|
||||
$ctx.append('<div class="grille"><div>');
|
||||
$('.grille', $ctx).css({
|
||||
'width': '100%',
|
||||
'height': '100%',
|
||||
'position': 'relative'
|
||||
});
|
||||
}
|
||||
|
||||
// create all empty cells
|
||||
for (var l = 0; l < this.settings.lines; l++) {
|
||||
_cells[l] = new Array();
|
||||
for (var c = 0; c < this.settings.columns; c++) {
|
||||
_cells[l][c] = new Cell(this, c, l);
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
function _setPrevCell(){
|
||||
// _grid.prev_cell = false;
|
||||
switch(_grid.settings.positioning_mode){
|
||||
case 'lefttop': // add items from top left to bootm rif-ght
|
||||
_grid.prev_cell = _cells[0][0];
|
||||
break;
|
||||
case 'center': // add items from center of grid to both side randomly
|
||||
_grid.prev_cell = _cells[Math.floor(_grid.settings.lines*.5)][Math.floor(_grid.settings.columns*.5)];
|
||||
break;
|
||||
case 'borders': // add items from center of grid to both side randomly
|
||||
var side = Math.floor(Math.random()*4);
|
||||
$.log('side = '+side);
|
||||
switch(side){
|
||||
case 0 :
|
||||
_grid.prev_cell = _cells[0][Math.floor(_grid.settings.columns*Math.random())];
|
||||
break;
|
||||
case 1 :
|
||||
_grid.prev_cell = _cells[_grid.settings.lines-1][Math.floor(_grid.settings.columns*Math.random())];
|
||||
break;
|
||||
case 2 :
|
||||
_grid.prev_cell = _cells[Math.floor(_grid.settings.lines*Math.random())][0];
|
||||
break;
|
||||
case 3 :
|
||||
_grid.prev_cell = _cells[Math.floor(_grid.settings.lines*Math.random())][_grid.settings.columns-1];
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 'random': // add items randomly
|
||||
default:
|
||||
_grid.prev_cell = _cells[Math.floor(_grid.settings.lines*Math.random())][Math.floor(_grid.settings.columns*Math.random())];
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
_setPrevCell();
|
||||
|
||||
|
||||
/**
|
||||
* placeTargets()
|
||||
*/
|
||||
function _placeTargets(){
|
||||
// parse targets
|
||||
var $targets = _grid.settings.children != '' ? $(_grid.settings.children+':not(.grid-placed)', $ctx) : $ctx.children(':not(.grid-placed)');
|
||||
|
||||
$targets.each(function() {
|
||||
|
||||
var $this = $(this),
|
||||
// get the width and height ( ! on cell unit ! how much cells it takes ? ) of item to be positioned
|
||||
this_cells_w = Math.ceil($this.width() / (_grid.settings.cell_w + _grid.settings.gouttiere)),
|
||||
this_cells_h = Math.ceil($this.height() / (_grid.settings.cell_h + _grid.settings.gouttiere)),
|
||||
// get free cells function of width and height of item
|
||||
free_cells = getFreeCells(this_cells_w, this_cells_h);
|
||||
if(free_cells.length > 0){
|
||||
|
||||
// positioning mode, to change this mode uncomment/comment lines after description
|
||||
switch(_grid.settings.positioning_mode){
|
||||
case 'lefttop': // add items from top left to bootm rif-ght
|
||||
var cell_num = 0,
|
||||
cell = free_cells[cell_num];
|
||||
break;
|
||||
default: // add items from center of grid to both side randomly
|
||||
// var cell_num = Math.floor((free_cells.length-1)*0.5 + (-2+Math.random()*4));
|
||||
// cell_num = cell_num > free_cells.length-1 ? free_cells.length-1 : ( cell_num < 0 ? 0 : cell_num );
|
||||
// var cell = free_cells[cell_num];
|
||||
var cell_num = Math.round(Math.random() * (free_cells.length - 1)),
|
||||
cell = free_cells[cell_num];
|
||||
break;
|
||||
}
|
||||
|
||||
_grid.prev_cell = cell;
|
||||
|
||||
var line_limit_loop = cell.row() + (this_cells_h),
|
||||
column_limit_loop = cell.column() + (this_cells_w);
|
||||
|
||||
for (var l = cell.row(); l < line_limit_loop; l++) {
|
||||
for (var c = cell.column(); c < column_limit_loop; c++) {
|
||||
var temp_cell = _cells[l][c];
|
||||
temp_cell.setFull();
|
||||
};
|
||||
};
|
||||
|
||||
// get tp and left coordinates
|
||||
// should be directly recorded in the cell object
|
||||
var top = cell.row() * (_grid.settings.cell_h + _grid.settings.gouttiere),
|
||||
left = cell.column() * (_grid.settings.cell_w + _grid.settings.gouttiere),
|
||||
groove = _grid.settings.groove;
|
||||
|
||||
// set groove ;)
|
||||
top = !groove ? top: top + Math.round(Math.random() * groove - groove / 2);
|
||||
left = !groove ? left: left + Math.round(Math.random() * groove - groove / 2);
|
||||
|
||||
// apply ccs position
|
||||
top += _grid.settings.cell_padding.t;
|
||||
left += _grid.settings.cell_padding.l;
|
||||
|
||||
var event = jQuery.Event("grid_positioned");
|
||||
event.top = top;
|
||||
event.left = left;
|
||||
|
||||
$this.css({
|
||||
'top': top,
|
||||
'left': left
|
||||
}).addClass('grid-positioned').trigger(event);
|
||||
}else{
|
||||
$.log('GRID no free cells left');
|
||||
// if no free cells exist
|
||||
$this.css({
|
||||
'border': '2px solid red',
|
||||
'opacity': 0.2
|
||||
}).trigger('grid_removed');//.remove();
|
||||
}
|
||||
$this.addClass('grid-placed').trigger('grid_placed');
|
||||
}); // end children each
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* getFreeCells()
|
||||
*
|
||||
* @ width in cells
|
||||
* @ height in cells
|
||||
*
|
||||
* return array of cell objects
|
||||
*
|
||||
*/
|
||||
function getFreeCells(this_cells_w, this_cells_h){
|
||||
|
||||
var free_cells = new Array(),
|
||||
padding = _grid.settings.padding,
|
||||
max_dist = _grid.settings.max_distance,
|
||||
min_dist = _grid.settings.min_distance,
|
||||
prev_cell = _grid.prev_cell;
|
||||
|
||||
// $.log()
|
||||
|
||||
for (var l = 0; l < _grid.settings.lines; l++) {
|
||||
for (var c = 0; c < _grid.settings.columns; c++) {
|
||||
var cell = _cells[l][c];
|
||||
|
||||
/*
|
||||
TODO about the max_dist keep in mind that all element will not always be 1 cell elemnts !!
|
||||
*/
|
||||
|
||||
// here is a big stuff of conditionning
|
||||
// we check a lot of things
|
||||
// 1 - basicly if the cell is free
|
||||
// 2 - if the cell is under the padding limits
|
||||
// 3 - if she has enought space arround her
|
||||
// 4 - if we got a prev cell
|
||||
// 4.1 - if we got a max_dist != 0
|
||||
// 4.1.1 - if the cell is under the max limits
|
||||
// 4.2 - if we got a min_dist != 0
|
||||
// 4.2.1 - if the cell is behind the min limits
|
||||
|
||||
if (cell.isFree() // if cell is free
|
||||
&& (cell.row() > padding.t && cell.row() < _grid.settings.lines - padding.b
|
||||
&& cell.column() > padding.l && cell.column() < _grid.settings.columns - padding.r
|
||||
)
|
||||
&& (
|
||||
(cell.getAround().right + 1) >= this_cells_w // if enought free space on the right
|
||||
&& (cell.getAround().bottom + 1) >= this_cells_h // if enought free space on the bottom
|
||||
)
|
||||
&& ( !_grid.prev_cell // else if _grid.prev_cell undefined it's true
|
||||
|| ( // check max_dist AND min_dist
|
||||
(!max_dist // if max_distance is 0 return (stop condition) true
|
||||
|| ( cell.row() < prev_cell.row()+max_dist && cell.row() > prev_cell.row()-max_dist
|
||||
&& cell.column() < prev_cell.column()+max_dist && cell.column() > prev_cell.column()-max_dist )// if we got max_distance and prev_cell we check the distance
|
||||
)
|
||||
&&
|
||||
(!min_dist // if min_distance is 0 return (stop condition) true
|
||||
|| ( (cell.row() > prev_cell.row()+min_dist || cell.row() < prev_cell.row()-min_dist)
|
||||
|| (cell.column() > prev_cell.column()+min_dist || cell.column() < prev_cell.column()-min_dist) )// if we got min_distance and prev_cell we check the distance
|
||||
)
|
||||
)
|
||||
)
|
||||
) { // true of first big stuff if
|
||||
var good = true;
|
||||
for (var i = 1; i < this_cells_w; i++) { // for each free cells needed on right
|
||||
var temp_cell = _cells[l][c + i];
|
||||
if ((temp_cell.getAround().bottom + 1) < this_cells_h) { // if enought free space on bottom
|
||||
good = false;
|
||||
break;
|
||||
}
|
||||
};
|
||||
if (good) free_cells.push(cell);
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
return free_cells;
|
||||
}
|
||||
|
||||
/**
|
||||
* Cell()
|
||||
*/
|
||||
function Cell(g, c, r) {
|
||||
var _grid = g,
|
||||
_column = c,
|
||||
_row = r,
|
||||
_free = true,
|
||||
_free_cell_right = _grid.settings.columns - 1 - c,
|
||||
_free_cell_bottom = _grid.settings.lines - 1 - l;
|
||||
|
||||
if (_grid.settings.grille) {
|
||||
var _table = '<table>';
|
||||
_table += '<tr><td> </td><td> </td><td> </td></tr>';
|
||||
// _table += '<tr><td> </td><td class="state">'+_free+'</td><td class="fr">'+_free_cell_right+'</td></tr>';
|
||||
_table += '<tr><td> </td><td> </td><td class="fr">' + _free_cell_right + '</td></tr>';
|
||||
_table += '<tr><td> </td><td class="fb">' + _free_cell_bottom + '</td><td> </td></tr>';
|
||||
_table += '</table>';
|
||||
_grid.ctx.find('.grille').append('<div class="cell-' + l + '-' + c + '">' + _table + '<div>');
|
||||
var _dom = $('.cell-' + l + '-' + c, _grid.ctx.find('.grille'));
|
||||
_dom.css({
|
||||
'position': 'absolute',
|
||||
'top': _row * (_grid.settings.cell_h + _grid.settings.gouttiere) + _grid.settings.cell_padding.t,
|
||||
'left': _column * (_grid.settings.cell_w + _grid.settings.gouttiere) + _grid.settings.cell_padding.l,
|
||||
'width': _grid.settings.cell_w,
|
||||
'height': _grid.settings.cell_h,
|
||||
'backgroundColor': '#00FF00',
|
||||
'opacity': 0.6
|
||||
});
|
||||
// $('td', _dom).css({
|
||||
// 'fontSize': '8px'
|
||||
// });
|
||||
}
|
||||
|
||||
this.isFree = function() { return _free; };
|
||||
|
||||
this.getPos = function() { return { c: _column, l: _row }; };
|
||||
this.column = function() { return _column; };
|
||||
this.row = function() { return _row; };
|
||||
|
||||
this.getAround = function() { return { right: _free_cell_right, bottom: _free_cell_bottom }; };
|
||||
|
||||
this.setFull = function() {
|
||||
|
||||
_free = false;
|
||||
_free_cell_bottom = -1;
|
||||
_free_cell_right = -1;
|
||||
|
||||
if (_grid.settings.grille) {
|
||||
_dom.css({
|
||||
'backgroundColor': '#0000FF'
|
||||
});
|
||||
$('.fb', _dom).html(_free_cell_bottom);
|
||||
$('.fr', _dom).html(_free_cell_right);
|
||||
}
|
||||
|
||||
_propageFreeCells();
|
||||
};
|
||||
|
||||
this.setFreeCellsRight = function(right) {
|
||||
if (_free) {
|
||||
// $.log('_setFreeCellRigth | _free_cell_right = ' + _free_cell_right + ' | new right = ' + right);
|
||||
_free_cell_right = right;
|
||||
if (_grid.settings.grille) $('.fr', _dom).html(_free_cell_right);
|
||||
_propageFreeCellsLeft();
|
||||
}
|
||||
};
|
||||
|
||||
this.setFreeCellsBottom = function(bottom) {
|
||||
if (_free) {
|
||||
// $.log('_setFreeCellsBottom | _free_cell_bottom = ' + _free_cell_bottom + ' | new right = ' + bottom);
|
||||
_free_cell_bottom = bottom;
|
||||
if (_grid.settings.grille) $('.fb', _dom).html(_free_cell_bottom);
|
||||
_propageFreeCellsTop();
|
||||
}
|
||||
};
|
||||
|
||||
function _propageFreeCells() {
|
||||
// $.log('_propageFreeCells');
|
||||
_propageFreeCellsLeft();
|
||||
_propageFreeCellsTop();
|
||||
};
|
||||
|
||||
function _propageFreeCellsLeft() {
|
||||
// $.log('_propageFreeCellsLeft | _column = '+_column);
|
||||
if (_column > 0) {
|
||||
var left_cel = _cells[_row][_column - 1];
|
||||
left_cel.setFreeCellsRight(_free_cell_right + 1);
|
||||
}
|
||||
};
|
||||
|
||||
function _propageFreeCellsTop() {
|
||||
// $.log('_propageFreeCellsTop | _row = '+_row);
|
||||
if (_row > 0) {
|
||||
var top_cel = _cells[_row - 1][_column];
|
||||
top_cel.setFreeCellsBottom(_free_cell_bottom + 1);
|
||||
}
|
||||
};
|
||||
|
||||
if (typeof Cell.initialized == "undefined") {
|
||||
Cell.prototype.infos = function() {
|
||||
$.log('cell | column = ' + this.column() + ', line = ' + this.row() + ', free = ' + this.isFree() + ', free cell right = ' + this.getAround().right + ', free cell bottom = ' + this.getAround().bottom);
|
||||
};
|
||||
|
||||
Cell.initialized = true;
|
||||
}
|
||||
}; // cell()
|
||||
|
||||
if (typeof Node.initialized == "undefined") {
|
||||
|
||||
Grid.prototype.refresh = function() {
|
||||
_placeTargets();
|
||||
};
|
||||
|
||||
Grid.prototype.resetPrevCell = function() {
|
||||
_setPrevCell();
|
||||
// this.prev_cell = false;
|
||||
};
|
||||
|
||||
|
||||
Node.initialized = true;
|
||||
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
(function($) {
|
||||
$.fn.grid = function(settings) {
|
||||
return this.each(function(index) {
|
||||
$(this).data('grid', new Grid(this, settings));
|
||||
});
|
||||
}
|
||||
})(jQuery);
|
||||
+1
@@ -0,0 +1 @@
|
||||
*.min.js
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
softTabs = false
|
||||
tabSize = 2
|
||||
|
||||
[ text.plain ]
|
||||
softWrap = true
|
||||
wrapColumn = "Use Window Frame"
|
||||
softTabs = true
|
||||
tabSize = 4
|
||||
|
||||
[ "*.md" ]
|
||||
fileType = "text.plain"
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
language: node_js
|
||||
node_js:
|
||||
- 0.8
|
||||
before_script:
|
||||
- npm install grunt
|
||||
script: grunt ci --verbose
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
HEAD
|
||||
-----
|
||||
- Support for AMD.
|
||||
|
||||
- Removed deprecated method `$.cookie('name', null)` for deleting a cookie,
|
||||
use `$.removeCookie('name')`.
|
||||
|
||||
- `$.cookie('name')` now returns `undefined` in case such cookie does not exist
|
||||
(was `null`). Because the return value is still falsy, testing for existence
|
||||
of a cookie like `if ( $.cookie('foo') )` keeps working without change.
|
||||
|
||||
1.3.1
|
||||
-----
|
||||
- Fixed issue where it was no longer possible to check for an arbitrary cookie,
|
||||
while json is set to true, there was a SyntaxError thrown from JSON.parse.
|
||||
|
||||
- Fixed issue where RFC 2068 decoded cookies were not properly read.
|
||||
|
||||
1.3.0
|
||||
-----
|
||||
- Configuration options: `raw`, `json`. Replaces raw option, becomes config:
|
||||
|
||||
```javascript
|
||||
$.cookie.raw = true; // bypass encoding/decoding the cookie value
|
||||
$.cookie.json = true; // automatically JSON stringify/parse value
|
||||
```
|
||||
|
||||
Thus the default options now cleanly contain cookie attributes only.
|
||||
|
||||
- Removing licensing under GPL Version 2, the plugin is now released under MIT License only
|
||||
(keeping it simple and following the jQuery library itself here).
|
||||
|
||||
- Bugfix: Properly handle RFC 2068 quoted cookie values.
|
||||
|
||||
- Added component.json for bower.
|
||||
|
||||
- Added jQuery plugin package manifest.
|
||||
|
||||
- `$.cookie()` returns all available cookies.
|
||||
|
||||
1.2.0
|
||||
-----
|
||||
- Adding `$.removeCookie('foo')` for deleting a cookie, using `$.cookie('foo', null)` is now deprecated.
|
||||
|
||||
1.1
|
||||
---
|
||||
- Adding default options.
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
Copyright 2013 Klaus Hartl
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
+122
@@ -0,0 +1,122 @@
|
||||
# jquery.cookie [](https://travis-ci.org/carhartl/jquery-cookie)
|
||||
|
||||
A simple, lightweight jQuery plugin for reading, writing and deleting cookies.
|
||||
|
||||
## Installation
|
||||
|
||||
Include script *after* the jQuery library (unless you are packaging scripts somehow else):
|
||||
|
||||
<script src="/path/to/jquery.cookie.js"></script>
|
||||
|
||||
**Do not include the script directly from GitHub (http://raw.github.com/...).** The file is being served as text/plain and as such being blocked
|
||||
in Internet Explorer on Windows 7 for instance (because of the wrong MIME type). Bottom line: GitHub is not a CDN.
|
||||
|
||||
The plugin can also be loaded as AMD module.
|
||||
|
||||
## Usage
|
||||
|
||||
Create session cookie:
|
||||
|
||||
$.cookie('the_cookie', 'the_value');
|
||||
|
||||
Create expiring cookie, 7 days from then:
|
||||
|
||||
$.cookie('the_cookie', 'the_value', { expires: 7 });
|
||||
|
||||
Create expiring cookie, valid across entire site:
|
||||
|
||||
$.cookie('the_cookie', 'the_value', { expires: 7, path: '/' });
|
||||
|
||||
Read cookie:
|
||||
|
||||
$.cookie('the_cookie'); // => "the_value"
|
||||
$.cookie('not_existing'); // => undefined
|
||||
|
||||
Read all available cookies:
|
||||
|
||||
$.cookie(); // => { "the_cookie": "the_value", "...remaining": "cookies" }
|
||||
|
||||
Delete cookie:
|
||||
|
||||
// Returns true when cookie was found, false when no cookie was found...
|
||||
$.removeCookie('the_cookie');
|
||||
|
||||
// Same path as when the cookie was written...
|
||||
$.removeCookie('the_cookie', { path: '/' });
|
||||
|
||||
*Note: when deleting a cookie, you must pass the exact same path, domain and secure options that were used to set the cookie, unless you're relying on the default options that is.*
|
||||
|
||||
## Configuration
|
||||
|
||||
### raw
|
||||
|
||||
By default the cookie value is encoded/decoded when writing/reading, using `encodeURIComponent`/`decodeURIComponent`. Bypass this by setting raw to true:
|
||||
|
||||
$.cookie.raw = true;
|
||||
|
||||
### json
|
||||
|
||||
Turn on automatic storage of JSON objects passed as the cookie value. Assumes `JSON.stringify` and `JSON.parse`:
|
||||
|
||||
$.cookie.json = true;
|
||||
|
||||
## Cookie Options
|
||||
|
||||
### expires
|
||||
|
||||
Cookie attributes can be set globally by setting properties of the `$.cookie.defaults` object or individually for each call to `$.cookie()` by passing a plain object to the options argument. Per-call options override the default options.
|
||||
|
||||
expires: 365
|
||||
|
||||
Define lifetime of the cookie. Value can be a `Number` which will be interpreted as days from time of creation or a `Date` object. If omitted, the cookie becomes a session cookie.
|
||||
|
||||
### path
|
||||
|
||||
path: '/'
|
||||
|
||||
Define the path where the cookie is valid. *By default the path of the cookie is the path of the page where the cookie was created (standard browser behavior).* If you want to make it available for instance across the entire domain use `path: '/'`. Default: path of page where the cookie was created.
|
||||
|
||||
**Note regarding Internet Explorer:**
|
||||
|
||||
> Due to an obscure bug in the underlying WinINET InternetGetCookie implementation, IE’s document.cookie will not return a cookie if it was set with a path attribute containing a filename.
|
||||
|
||||
(From [Internet Explorer Cookie Internals (FAQ)](http://blogs.msdn.com/b/ieinternals/archive/2009/08/20/wininet-ie-cookie-internals-faq.aspx))
|
||||
|
||||
This means one cannot set a path using `path: window.location.pathname` in case such pathname contains a filename like so: `/check.html` (or at least, such cookie cannot be read correctly).
|
||||
|
||||
### domain
|
||||
|
||||
domain: 'example.com'
|
||||
|
||||
Define the domain where the cookie is valid. Default: domain of page where the cookie was created.
|
||||
|
||||
### secure
|
||||
|
||||
secure: true
|
||||
|
||||
If true, the cookie transmission requires a secure protocol (https). Default: `false`.
|
||||
|
||||
## Tests
|
||||
|
||||
Requires Node. Startup server:
|
||||
|
||||
$ node test/server.js
|
||||
|
||||
Open in browser:
|
||||
|
||||
$ open http://0.0.0.0:8124/test/index.html
|
||||
|
||||
For quick *non cross-browser* testing use grunt:
|
||||
|
||||
$ grunt
|
||||
|
||||
## Development
|
||||
|
||||
- Source hosted at [GitHub](https://github.com/carhartl/jquery-cookie)
|
||||
- Report issues, questions, feature requests on [GitHub Issues](https://github.com/carhartl/jquery-cookie/issues)
|
||||
|
||||
Pull requests are very welcome! Make sure your patches are well tested. Please create a topic branch for every separate change you make.
|
||||
|
||||
## Authors
|
||||
|
||||
[Klaus Hartl](https://github.com/carhartl)
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"name": "jquery.cookie",
|
||||
"version": "1.3.1",
|
||||
"main": [
|
||||
"./jquery.cookie.js"
|
||||
],
|
||||
"dependencies": {
|
||||
"jquery": ">=1.0"
|
||||
}
|
||||
}
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
{
|
||||
"name": "cookie",
|
||||
"version": "1.3.1",
|
||||
"title": "jQuery Cookie",
|
||||
"description": "A simple, lightweight jQuery plugin for reading, writing and deleting cookies.",
|
||||
"author": {
|
||||
"name": "Klaus Hartl",
|
||||
"url": "https://github.com/carhartl"
|
||||
},
|
||||
"maintainers": [
|
||||
{
|
||||
"name": "Klaus Hartl",
|
||||
"url": "https://github.com/carhartl"
|
||||
},
|
||||
{
|
||||
"name": "Fagner Martins",
|
||||
"url": "https://github.com/FagnerMartinsBrack"
|
||||
}
|
||||
],
|
||||
"licenses": [
|
||||
{
|
||||
"type": "MIT",
|
||||
"url": "https://raw.github.com/carhartl/jquery-cookie/master/MIT-LICENSE.txt"
|
||||
}
|
||||
],
|
||||
"dependencies": {
|
||||
"jquery": ">=1.0"
|
||||
},
|
||||
"bugs": "https://github.com/carhartl/jquery-cookie/issues",
|
||||
"homepage": "https://github.com/carhartl/jquery-cookie",
|
||||
"docs": "https://github.com/carhartl/jquery-cookie#readme"
|
||||
}
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
/*global module */
|
||||
module.exports = function (grunt) {
|
||||
'use strict';
|
||||
|
||||
grunt.initConfig({
|
||||
pkg: '<json:cookie.jquery.json>',
|
||||
meta: {
|
||||
banner: '/*! <%= pkg.title %> v<%= pkg.version %> | <%= pkg.licenses[0].type %> */'
|
||||
},
|
||||
qunit: {
|
||||
files: ['test/index.html']
|
||||
},
|
||||
lint: {
|
||||
files: [
|
||||
'grunt.js',
|
||||
'jquery.cookie.js'
|
||||
]
|
||||
},
|
||||
jshint: {
|
||||
options: {
|
||||
boss: true,
|
||||
browser: true,
|
||||
curly: true,
|
||||
eqeqeq: true,
|
||||
eqnull: true,
|
||||
expr: true,
|
||||
evil: true,
|
||||
newcap: true,
|
||||
noarg: true,
|
||||
undef: true
|
||||
},
|
||||
globals: {
|
||||
define: true,
|
||||
jQuery: true
|
||||
}
|
||||
},
|
||||
min: {
|
||||
dist: {
|
||||
src: ['<banner>', 'jquery.cookie.js'],
|
||||
dest: 'jquery.cookie-<%= pkg.version %>.min.js'
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
grunt.registerTask('default', 'lint qunit');
|
||||
|
||||
// Travis CI task.
|
||||
grunt.registerTask('ci', 'default');
|
||||
};
|
||||
+90
@@ -0,0 +1,90 @@
|
||||
/*!
|
||||
* jQuery Cookie Plugin v1.3.1
|
||||
* https://github.com/carhartl/jquery-cookie
|
||||
*
|
||||
* Copyright 2013 Klaus Hartl
|
||||
* Released under the MIT license
|
||||
*/
|
||||
(function (factory) {
|
||||
if (typeof define === 'function' && define.amd && define.amd.jQuery) {
|
||||
// AMD. Register as anonymous module.
|
||||
define(['jquery'], factory);
|
||||
} else {
|
||||
// Browser globals.
|
||||
factory(jQuery);
|
||||
}
|
||||
}(function ($) {
|
||||
|
||||
var pluses = /\+/g;
|
||||
|
||||
function raw(s) {
|
||||
return s;
|
||||
}
|
||||
|
||||
function decoded(s) {
|
||||
return decodeURIComponent(s.replace(pluses, ' '));
|
||||
}
|
||||
|
||||
function converted(s) {
|
||||
if (s.indexOf('"') === 0) {
|
||||
// This is a quoted cookie as according to RFC2068, unescape
|
||||
s = s.slice(1, -1).replace(/\\"/g, '"').replace(/\\\\/g, '\\');
|
||||
}
|
||||
return config.json ? JSON.parse(s) : s;
|
||||
}
|
||||
|
||||
var config = $.cookie = function (key, value, options) {
|
||||
|
||||
// write
|
||||
if (value !== undefined) {
|
||||
options = $.extend({}, config.defaults, options);
|
||||
|
||||
if (typeof options.expires === 'number') {
|
||||
var days = options.expires, t = options.expires = new Date();
|
||||
t.setDate(t.getDate() + days);
|
||||
}
|
||||
|
||||
value = config.json ? JSON.stringify(value) : String(value);
|
||||
|
||||
return (document.cookie = [
|
||||
encodeURIComponent(key), '=', config.raw ? value : encodeURIComponent(value),
|
||||
options.expires ? '; expires=' + options.expires.toUTCString() : '', // use expires attribute, max-age is not supported by IE
|
||||
options.path ? '; path=' + options.path : '',
|
||||
options.domain ? '; domain=' + options.domain : '',
|
||||
options.secure ? '; secure' : ''
|
||||
].join(''));
|
||||
}
|
||||
|
||||
// read
|
||||
var decode = config.raw ? raw : decoded;
|
||||
var cookies = document.cookie.split('; ');
|
||||
var result = key ? undefined : {};
|
||||
for (var i = 0, l = cookies.length; i < l; i++) {
|
||||
var parts = cookies[i].split('=');
|
||||
var name = decode(parts.shift());
|
||||
var cookie = decode(parts.join('='));
|
||||
|
||||
if (key && key === name) {
|
||||
result = converted(cookie);
|
||||
break;
|
||||
}
|
||||
|
||||
if (!key) {
|
||||
result[name] = converted(cookie);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
config.defaults = {};
|
||||
|
||||
$.removeCookie = function (key, options) {
|
||||
if ($.cookie(key) !== undefined) {
|
||||
$.cookie(key, '', $.extend(options, { expires: -1 }));
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
}));
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>jquery.cookie Test Suite</title>
|
||||
<link rel="stylesheet" href="http://code.jquery.com/qunit/qunit-1.10.0.css">
|
||||
<script src="http://code.jquery.com/jquery-1.9.0.min.js"></script>
|
||||
<script src="http://code.jquery.com/qunit/qunit-1.10.0.js"></script>
|
||||
<script src="../jquery.cookie.js"></script>
|
||||
<script src="tests.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<h1 id="qunit-header">jquery.cookie Test Suite</h1>
|
||||
<h2 id="qunit-banner"></h2>
|
||||
<div id="qunit-testrunner-toolbar"></div>
|
||||
<h2 id="qunit-userAgent"></h2>
|
||||
<ol id="qunit-tests"></ol>
|
||||
</body>
|
||||
</html>
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<title></title>
|
||||
<script src="http://code.jquery.com/jquery-1.9.0.min.js"></script>
|
||||
<script src="../jquery.cookie.js"></script>
|
||||
<script>
|
||||
try {
|
||||
Object.defineProperty(document, "cookie", { get: function() { return "first=one; ; second=two"; } });
|
||||
window.testValue = $.cookie("second");
|
||||
window.ok = true;
|
||||
} catch (er) {
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
</body>
|
||||
</html>
|
||||
Vendored
Executable
+24
@@ -0,0 +1,24 @@
|
||||
var http = require('http');
|
||||
var url = require('url');
|
||||
var path = require('path');
|
||||
var fs = require('fs');
|
||||
|
||||
http.createServer(function(request, response) {
|
||||
var uri = url.parse(request.url).pathname;
|
||||
var filename = path.join(process.cwd(), uri);
|
||||
|
||||
fs.readFile(filename, 'binary', function(err, file) {
|
||||
if (err) {
|
||||
response.writeHead(500, { 'Content-Type': 'text/plain' });
|
||||
response.write(err + '\n');
|
||||
response.end();
|
||||
return;
|
||||
}
|
||||
|
||||
response.writeHead(200, filename.match(/\.js$/) ? { 'Content-Type': 'text/javascript' } : {});
|
||||
response.write(file, 'utf-8');
|
||||
response.end();
|
||||
});
|
||||
}).listen(8124, '0.0.0.0');
|
||||
|
||||
console.log('Test suite at http://0.0.0.0:8124/test/index.html');
|
||||
+239
@@ -0,0 +1,239 @@
|
||||
var lifecycle = {
|
||||
teardown: function () {
|
||||
$.cookie.defaults = {};
|
||||
delete $.cookie.raw;
|
||||
delete $.cookie.json;
|
||||
$.each($.cookie(), $.removeCookie);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
module('read', lifecycle);
|
||||
|
||||
test('simple value', function () {
|
||||
expect(1);
|
||||
document.cookie = 'c=v';
|
||||
equal($.cookie('c'), 'v', 'should return value');
|
||||
});
|
||||
|
||||
test('empty value', function () {
|
||||
expect(1);
|
||||
// IE saves cookies with empty string as "c; ", e.g. without "=" as opposed to EOMB, which
|
||||
// resulted in a bug while reading such a cookie.
|
||||
$.cookie('c', '');
|
||||
equal($.cookie('c'), '', 'should return value');
|
||||
});
|
||||
|
||||
test('not existing', function () {
|
||||
expect(1);
|
||||
strictEqual($.cookie('whatever'), undefined, 'return undefined');
|
||||
});
|
||||
|
||||
test('RFC 2068 quoted string', function () {
|
||||
expect(1);
|
||||
document.cookie = 'c="v@address.com\\"\\\\\\""';
|
||||
equal($.cookie('c'), 'v@address.com"\\"', 'should decode RFC 2068 quoted string');
|
||||
});
|
||||
|
||||
test('decode', function () {
|
||||
expect(1);
|
||||
document.cookie = encodeURIComponent(' c') + '=' + encodeURIComponent(' v');
|
||||
equal($.cookie(' c'), ' v', 'should decode key and value');
|
||||
});
|
||||
|
||||
test('decode pluses to space for server side written cookie', function () {
|
||||
expect(1);
|
||||
document.cookie = 'c=foo+bar';
|
||||
equal($.cookie('c'), 'foo bar', 'should convert pluses back to space');
|
||||
});
|
||||
|
||||
test('raw = true', function () {
|
||||
expect(2);
|
||||
$.cookie.raw = true;
|
||||
|
||||
document.cookie = 'c=%20v';
|
||||
equal($.cookie('c'), '%20v', 'should not decode value');
|
||||
|
||||
// see https://github.com/carhartl/jquery-cookie/issues/50
|
||||
$.cookie('c', 'foo=bar');
|
||||
equal($.cookie('c'), 'foo=bar', 'should include the entire value');
|
||||
});
|
||||
|
||||
test('json = true', function () {
|
||||
expect(1);
|
||||
$.cookie.json = true;
|
||||
|
||||
if ('JSON' in window) {
|
||||
$.cookie('c', { foo: 'bar' });
|
||||
deepEqual($.cookie('c'), { foo: 'bar'}, 'should parse JSON');
|
||||
} else {
|
||||
ok(true);
|
||||
}
|
||||
});
|
||||
|
||||
test('not existing with json = true', function () {
|
||||
expect(1);
|
||||
$.cookie.json = true;
|
||||
|
||||
if ('JSON' in window) {
|
||||
equal($.cookie('whatever'), null, 'should return null');
|
||||
} else {
|
||||
ok(true);
|
||||
}
|
||||
});
|
||||
|
||||
asyncTest('malformed cookie value in IE (#88, #117)', function() {
|
||||
expect(1);
|
||||
// Sandbox in an iframe so that we can poke around with document.cookie.
|
||||
var iframe = $('<iframe src="sandbox.html"></iframe>')[0];
|
||||
$(iframe).on('load', function() {
|
||||
start();
|
||||
if (iframe.contentWindow.ok) {
|
||||
equal(iframe.contentWindow.testValue, 'two', 'reads all cookie values, skipping duplicate occurences of "; "');
|
||||
} else {
|
||||
// Skip the test where we can't stub document.cookie using
|
||||
// Object.defineProperty. Seems to work fine in
|
||||
// Chrome, Firefox and IE 8+.
|
||||
ok(true, 'N/A');
|
||||
}
|
||||
});
|
||||
document.body.appendChild(iframe);
|
||||
});
|
||||
|
||||
test('return all cookies', function() {
|
||||
$.cookie('c', 'v');
|
||||
$.cookie('foo', 'bar');
|
||||
deepEqual($.cookie(), {
|
||||
c: 'v',
|
||||
foo: 'bar'
|
||||
}, 'should return all cookies');
|
||||
$.each($.cookie(), $.removeCookie);
|
||||
|
||||
$.cookie.json = true;
|
||||
$.cookie('c', { foo: 'bar' });
|
||||
deepEqual($.cookie(), {
|
||||
c: { foo: 'bar' }
|
||||
}, 'should return all cookies with JSON parsed');
|
||||
});
|
||||
|
||||
|
||||
module('write', lifecycle);
|
||||
|
||||
test('String primitive', function () {
|
||||
expect(1);
|
||||
$.cookie('c', 'v');
|
||||
equal($.cookie('c'), 'v', 'should write value');
|
||||
});
|
||||
|
||||
test('String object', function () {
|
||||
expect(1);
|
||||
$.cookie('c', new String('v'));
|
||||
equal($.cookie('c'), 'v', 'should write value');
|
||||
});
|
||||
|
||||
test('value "[object Object]"', function () {
|
||||
expect(1);
|
||||
$.cookie('c', '[object Object]');
|
||||
equal($.cookie('c'), '[object Object]', 'should write value');
|
||||
});
|
||||
|
||||
test('number', function () {
|
||||
expect(1);
|
||||
$.cookie('c', 1234);
|
||||
equal($.cookie('c'), '1234', 'should write value');
|
||||
});
|
||||
|
||||
test('expires option as days from now', function() {
|
||||
expect(1);
|
||||
var sevenDaysFromNow = new Date();
|
||||
sevenDaysFromNow.setDate(sevenDaysFromNow.getDate() + 7);
|
||||
equal($.cookie('c', 'v', { expires: 7 }), 'c=v; expires=' + sevenDaysFromNow.toUTCString(),
|
||||
'should write the cookie string with expires');
|
||||
});
|
||||
|
||||
test('expires option as Date instance', function() {
|
||||
expect(1);
|
||||
var sevenDaysFromNow = new Date();
|
||||
sevenDaysFromNow.setDate(sevenDaysFromNow.getDate() + 7);
|
||||
equal($.cookie('c', 'v', { expires: sevenDaysFromNow }), 'c=v; expires=' + sevenDaysFromNow.toUTCString(),
|
||||
'should write the cookie string with expires');
|
||||
});
|
||||
|
||||
test('invalid expires option (in the past)', function() {
|
||||
expect(1);
|
||||
var yesterday = new Date();
|
||||
yesterday.setDate(yesterday.getDate() - 1);
|
||||
$.cookie('c', 'v', { expires: yesterday });
|
||||
equal($.cookie('c'), null, 'should not save already expired cookie');
|
||||
});
|
||||
|
||||
test('return value', function () {
|
||||
expect(1);
|
||||
equal($.cookie('c', 'v'), 'c=v', 'should return written cookie string');
|
||||
});
|
||||
|
||||
test('defaults', function () {
|
||||
expect(2);
|
||||
$.cookie.defaults.path = '/foo';
|
||||
ok($.cookie('c', 'v').match(/path=\/foo/), 'should use options from defaults');
|
||||
ok($.cookie('c', 'v', { path: '/bar' }).match(/path=\/bar/), 'options argument has precedence');
|
||||
});
|
||||
|
||||
test('raw = true', function () {
|
||||
expect(1);
|
||||
$.cookie.raw = true;
|
||||
equal($.cookie('c', ' v').split('=')[1], ' v', 'should not encode');
|
||||
});
|
||||
|
||||
test('json = true', function () {
|
||||
expect(1);
|
||||
$.cookie.json = true;
|
||||
|
||||
if ('JSON' in window) {
|
||||
$.cookie('c', { foo: 'bar' });
|
||||
equal(document.cookie, 'c=' + encodeURIComponent(JSON.stringify({ foo: 'bar' })), 'should stringify JSON');
|
||||
} else {
|
||||
ok(true);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
module('removeCookie', lifecycle);
|
||||
|
||||
test('deletion', function() {
|
||||
expect(1);
|
||||
$.cookie('c', 'v');
|
||||
$.removeCookie('c');
|
||||
equal(document.cookie, '', 'should delete the cookie');
|
||||
});
|
||||
|
||||
test('return', function() {
|
||||
expect(2);
|
||||
strictEqual($.removeCookie('c'), false, "return false if the cookie wasn't found");
|
||||
|
||||
$.cookie('c', 'v');
|
||||
strictEqual($.removeCookie('c'), true, 'return true if the cookie was found');
|
||||
});
|
||||
|
||||
test('with options', function() {
|
||||
expect(3);
|
||||
var originalCookie = $.cookie;
|
||||
var callCount = 0;
|
||||
|
||||
$.cookie = function() {
|
||||
callCount++;
|
||||
if (callCount === 1) {
|
||||
// see https://github.com/carhartl/jquery-cookie/issues/99
|
||||
equal(arguments.length, 1, 'look up cookie instead of accidently writing a new');
|
||||
return 'cookie'; // act as if a cookie was found...
|
||||
}
|
||||
if (callCount === 2) {
|
||||
equal(arguments[2].foo, 'bar', 'pass along options when deleting cookie');
|
||||
}
|
||||
};
|
||||
|
||||
$.removeCookie('c', { foo: 'bar' });
|
||||
equal(callCount, 2);
|
||||
|
||||
$.cookie = originalCookie;
|
||||
});
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,120 @@
|
||||
/*
|
||||
* CSS Styles that are needed by jScrollPane for it to operate correctly.
|
||||
*
|
||||
* Include this stylesheet in your site or copy and paste the styles below into your stylesheet - jScrollPane
|
||||
* may not operate correctly without them.
|
||||
*/
|
||||
|
||||
.jspContainer
|
||||
{
|
||||
overflow: hidden;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.jspPane
|
||||
{
|
||||
position: absolute;
|
||||
}
|
||||
|
||||
.jspVerticalBar
|
||||
{
|
||||
position: absolute;
|
||||
top: 0;
|
||||
right: 0;
|
||||
width: 16px;
|
||||
height: 100%;
|
||||
background: red;
|
||||
}
|
||||
|
||||
.jspHorizontalBar
|
||||
{
|
||||
position: absolute;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 16px;
|
||||
background: red;
|
||||
}
|
||||
|
||||
.jspVerticalBar *,
|
||||
.jspHorizontalBar *
|
||||
{
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.jspCap
|
||||
{
|
||||
display: none;
|
||||
}
|
||||
|
||||
.jspHorizontalBar .jspCap
|
||||
{
|
||||
float: left;
|
||||
}
|
||||
|
||||
.jspTrack
|
||||
{
|
||||
background: #dde;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.jspDrag
|
||||
{
|
||||
background: #bbd;
|
||||
position: relative;
|
||||
top: 0;
|
||||
left: 0;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.jspHorizontalBar .jspTrack,
|
||||
.jspHorizontalBar .jspDrag
|
||||
{
|
||||
float: left;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.jspArrow
|
||||
{
|
||||
background: #50506d;
|
||||
text-indent: -20000px;
|
||||
display: block;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.jspArrow.jspDisabled
|
||||
{
|
||||
cursor: default;
|
||||
background: #80808d;
|
||||
}
|
||||
|
||||
.jspVerticalBar .jspArrow
|
||||
{
|
||||
height: 16px;
|
||||
}
|
||||
|
||||
.jspHorizontalBar .jspArrow
|
||||
{
|
||||
width: 16px;
|
||||
float: left;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.jspVerticalBar .jspArrow:focus
|
||||
{
|
||||
outline: none;
|
||||
}
|
||||
|
||||
.jspCorner
|
||||
{
|
||||
background: #eeeef4;
|
||||
float: left;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
/* Yuk! CSS Hack for IE6 3 pixel bug :( */
|
||||
* html .jspCorner
|
||||
{
|
||||
margin: 0 -3px 0 0;
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
/*
|
||||
* jScrollPane - v2.0.0beta12 - 2012-05-14
|
||||
* http://jscrollpane.kelvinluck.com/
|
||||
*
|
||||
* Copyright (c) 2010 Kelvin Luck
|
||||
* Dual licensed under the MIT and GPL licenses.
|
||||
*/
|
||||
(function(b,a,c){b.fn.jScrollPane=function(e){function d(D,O){var ay,Q=this,Y,aj,v,al,T,Z,y,q,az,aE,au,i,I,h,j,aa,U,ap,X,t,A,aq,af,am,G,l,at,ax,x,av,aH,f,L,ai=true,P=true,aG=false,k=false,ao=D.clone(false,false).empty(),ac=b.fn.mwheelIntent?"mwheelIntent.jsp":"mousewheel.jsp";aH=D.css("paddingTop")+" "+D.css("paddingRight")+" "+D.css("paddingBottom")+" "+D.css("paddingLeft");f=(parseInt(D.css("paddingLeft"),10)||0)+(parseInt(D.css("paddingRight"),10)||0);function ar(aQ){var aL,aN,aM,aJ,aI,aP,aO=false,aK=false;ay=aQ;if(Y===c){aI=D.scrollTop();aP=D.scrollLeft();D.css({overflow:"hidden",padding:0});aj=D.innerWidth()+f;v=D.innerHeight();D.width(aj);Y=b('<div class="jspPane" />').css("padding",aH).append(D.children());al=b('<div class="jspContainer" />').css({width:aj+"px",height:v+"px"}).append(Y).appendTo(D)}else{D.css("width","");aO=ay.stickToBottom&&K();aK=ay.stickToRight&&B();aJ=D.innerWidth()+f!=aj||D.outerHeight()!=v;if(aJ){aj=D.innerWidth()+f;v=D.innerHeight();al.css({width:aj+"px",height:v+"px"})}if(!aJ&&L==T&&Y.outerHeight()==Z){D.width(aj);return}L=T;Y.css("width","");D.width(aj);al.find(">.jspVerticalBar,>.jspHorizontalBar").remove().end()}Y.css("overflow","auto");if(aQ.contentWidth){T=aQ.contentWidth}else{T=Y[0].scrollWidth}Z=Y[0].scrollHeight;Y.css("overflow","");y=T/aj;q=Z/v;az=q>1;aE=y>1;if(!(aE||az)){D.removeClass("jspScrollable");Y.css({top:0,width:al.width()-f});n();E();R();w()}else{D.addClass("jspScrollable");aL=ay.maintainPosition&&(I||aa);if(aL){aN=aC();aM=aA()}aF();z();F();if(aL){N(aK?(T-aj):aN,false);M(aO?(Z-v):aM,false)}J();ag();an();if(ay.enableKeyboardNavigation){S()}if(ay.clickOnTrack){p()}C();if(ay.hijackInternalLinks){m()}}if(ay.autoReinitialise&&!av){av=setInterval(function(){ar(ay)},ay.autoReinitialiseDelay)}else{if(!ay.autoReinitialise&&av){clearInterval(av)}}aI&&D.scrollTop(0)&&M(aI,false);aP&&D.scrollLeft(0)&&N(aP,false);D.trigger("jsp-initialised",[aE||az])}function aF(){if(az){al.append(b('<div class="jspVerticalBar" />').append(b('<div class="jspCap jspCapTop" />'),b('<div class="jspTrack" />').append(b('<div class="jspDrag" />').append(b('<div class="jspDragTop" />'),b('<div class="jspDragBottom" />'))),b('<div class="jspCap jspCapBottom" />')));U=al.find(">.jspVerticalBar");ap=U.find(">.jspTrack");au=ap.find(">.jspDrag");if(ay.showArrows){aq=b('<a class="jspArrow jspArrowUp" />').bind("mousedown.jsp",aD(0,-1)).bind("click.jsp",aB);af=b('<a class="jspArrow jspArrowDown" />').bind("mousedown.jsp",aD(0,1)).bind("click.jsp",aB);if(ay.arrowScrollOnHover){aq.bind("mouseover.jsp",aD(0,-1,aq));af.bind("mouseover.jsp",aD(0,1,af))}ak(ap,ay.verticalArrowPositions,aq,af)}t=v;al.find(">.jspVerticalBar>.jspCap:visible,>.jspVerticalBar>.jspArrow").each(function(){t-=b(this).outerHeight()});au.hover(function(){au.addClass("jspHover")},function(){au.removeClass("jspHover")}).bind("mousedown.jsp",function(aI){b("html").bind("dragstart.jsp selectstart.jsp",aB);au.addClass("jspActive");var s=aI.pageY-au.position().top;b("html").bind("mousemove.jsp",function(aJ){V(aJ.pageY-s,false)}).bind("mouseup.jsp mouseleave.jsp",aw);return false});o()}}function o(){ap.height(t+"px");I=0;X=ay.verticalGutter+ap.outerWidth();Y.width(aj-X-f);try{if(U.position().left===0){Y.css("margin-left",X+"px")}}catch(s){}}function z(){if(aE){al.append(b('<div class="jspHorizontalBar" />').append(b('<div class="jspCap jspCapLeft" />'),b('<div class="jspTrack" />').append(b('<div class="jspDrag" />').append(b('<div class="jspDragLeft" />'),b('<div class="jspDragRight" />'))),b('<div class="jspCap jspCapRight" />')));am=al.find(">.jspHorizontalBar");G=am.find(">.jspTrack");h=G.find(">.jspDrag");if(ay.showArrows){ax=b('<a class="jspArrow jspArrowLeft" />').bind("mousedown.jsp",aD(-1,0)).bind("click.jsp",aB);x=b('<a class="jspArrow jspArrowRight" />').bind("mousedown.jsp",aD(1,0)).bind("click.jsp",aB);
|
||||
if(ay.arrowScrollOnHover){ax.bind("mouseover.jsp",aD(-1,0,ax));x.bind("mouseover.jsp",aD(1,0,x))}ak(G,ay.horizontalArrowPositions,ax,x)}h.hover(function(){h.addClass("jspHover")},function(){h.removeClass("jspHover")}).bind("mousedown.jsp",function(aI){b("html").bind("dragstart.jsp selectstart.jsp",aB);h.addClass("jspActive");var s=aI.pageX-h.position().left;b("html").bind("mousemove.jsp",function(aJ){W(aJ.pageX-s,false)}).bind("mouseup.jsp mouseleave.jsp",aw);return false});l=al.innerWidth();ah()}}function ah(){al.find(">.jspHorizontalBar>.jspCap:visible,>.jspHorizontalBar>.jspArrow").each(function(){l-=b(this).outerWidth()});G.width(l+"px");aa=0}function F(){if(aE&&az){var aI=G.outerHeight(),s=ap.outerWidth();t-=aI;b(am).find(">.jspCap:visible,>.jspArrow").each(function(){l+=b(this).outerWidth()});l-=s;v-=s;aj-=aI;G.parent().append(b('<div class="jspCorner" />').css("width",aI+"px"));o();ah()}if(aE){Y.width((al.outerWidth()-f)+"px")}Z=Y.outerHeight();q=Z/v;if(aE){at=Math.ceil(1/y*l);if(at>ay.horizontalDragMaxWidth){at=ay.horizontalDragMaxWidth}else{if(at<ay.horizontalDragMinWidth){at=ay.horizontalDragMinWidth}}h.width(at+"px");j=l-at;ae(aa)}if(az){A=Math.ceil(1/q*t);if(A>ay.verticalDragMaxHeight){A=ay.verticalDragMaxHeight}else{if(A<ay.verticalDragMinHeight){A=ay.verticalDragMinHeight}}au.height(A+"px");i=t-A;ad(I)}}function ak(aJ,aL,aI,s){var aN="before",aK="after",aM;if(aL=="os"){aL=/Mac/.test(navigator.platform)?"after":"split"}if(aL==aN){aK=aL}else{if(aL==aK){aN=aL;aM=aI;aI=s;s=aM}}aJ[aN](aI)[aK](s)}function aD(aI,s,aJ){return function(){H(aI,s,this,aJ);this.blur();return false}}function H(aL,aK,aO,aN){aO=b(aO).addClass("jspActive");var aM,aJ,aI=true,s=function(){if(aL!==0){Q.scrollByX(aL*ay.arrowButtonSpeed)}if(aK!==0){Q.scrollByY(aK*ay.arrowButtonSpeed)}aJ=setTimeout(s,aI?ay.initialDelay:ay.arrowRepeatFreq);aI=false};s();aM=aN?"mouseout.jsp":"mouseup.jsp";aN=aN||b("html");aN.bind(aM,function(){aO.removeClass("jspActive");aJ&&clearTimeout(aJ);aJ=null;aN.unbind(aM)})}function p(){w();if(az){ap.bind("mousedown.jsp",function(aN){if(aN.originalTarget===c||aN.originalTarget==aN.currentTarget){var aL=b(this),aO=aL.offset(),aM=aN.pageY-aO.top-I,aJ,aI=true,s=function(){var aR=aL.offset(),aS=aN.pageY-aR.top-A/2,aP=v*ay.scrollPagePercent,aQ=i*aP/(Z-v);if(aM<0){if(I-aQ>aS){Q.scrollByY(-aP)}else{V(aS)}}else{if(aM>0){if(I+aQ<aS){Q.scrollByY(aP)}else{V(aS)}}else{aK();return}}aJ=setTimeout(s,aI?ay.initialDelay:ay.trackClickRepeatFreq);aI=false},aK=function(){aJ&&clearTimeout(aJ);aJ=null;b(document).unbind("mouseup.jsp",aK)};s();b(document).bind("mouseup.jsp",aK);return false}})}if(aE){G.bind("mousedown.jsp",function(aN){if(aN.originalTarget===c||aN.originalTarget==aN.currentTarget){var aL=b(this),aO=aL.offset(),aM=aN.pageX-aO.left-aa,aJ,aI=true,s=function(){var aR=aL.offset(),aS=aN.pageX-aR.left-at/2,aP=aj*ay.scrollPagePercent,aQ=j*aP/(T-aj);if(aM<0){if(aa-aQ>aS){Q.scrollByX(-aP)}else{W(aS)}}else{if(aM>0){if(aa+aQ<aS){Q.scrollByX(aP)}else{W(aS)}}else{aK();return}}aJ=setTimeout(s,aI?ay.initialDelay:ay.trackClickRepeatFreq);aI=false},aK=function(){aJ&&clearTimeout(aJ);aJ=null;b(document).unbind("mouseup.jsp",aK)};s();b(document).bind("mouseup.jsp",aK);return false}})}}function w(){if(G){G.unbind("mousedown.jsp")}if(ap){ap.unbind("mousedown.jsp")}}function aw(){b("html").unbind("dragstart.jsp selectstart.jsp mousemove.jsp mouseup.jsp mouseleave.jsp");if(au){au.removeClass("jspActive")}if(h){h.removeClass("jspActive")}}function V(s,aI){if(!az){return}if(s<0){s=0}else{if(s>i){s=i}}if(aI===c){aI=ay.animateScroll}if(aI){Q.animate(au,"top",s,ad)}else{au.css("top",s);ad(s)}}function ad(aI){if(aI===c){aI=au.position().top}al.scrollTop(0);I=aI;var aL=I===0,aJ=I==i,aK=aI/i,s=-aK*(Z-v);if(ai!=aL||aG!=aJ){ai=aL;aG=aJ;D.trigger("jsp-arrow-change",[ai,aG,P,k])}u(aL,aJ);Y.css("top",s);D.trigger("jsp-scroll-y",[-s,aL,aJ]).trigger("scroll")}function W(aI,s){if(!aE){return}if(aI<0){aI=0}else{if(aI>j){aI=j}}if(s===c){s=ay.animateScroll}if(s){Q.animate(h,"left",aI,ae)
|
||||
}else{h.css("left",aI);ae(aI)}}function ae(aI){if(aI===c){aI=h.position().left}al.scrollTop(0);aa=aI;var aL=aa===0,aK=aa==j,aJ=aI/j,s=-aJ*(T-aj);if(P!=aL||k!=aK){P=aL;k=aK;D.trigger("jsp-arrow-change",[ai,aG,P,k])}r(aL,aK);Y.css("left",s);D.trigger("jsp-scroll-x",[-s,aL,aK]).trigger("scroll")}function u(aI,s){if(ay.showArrows){aq[aI?"addClass":"removeClass"]("jspDisabled");af[s?"addClass":"removeClass"]("jspDisabled")}}function r(aI,s){if(ay.showArrows){ax[aI?"addClass":"removeClass"]("jspDisabled");x[s?"addClass":"removeClass"]("jspDisabled")}}function M(s,aI){var aJ=s/(Z-v);V(aJ*i,aI)}function N(aI,s){var aJ=aI/(T-aj);W(aJ*j,s)}function ab(aV,aQ,aJ){var aN,aK,aL,s=0,aU=0,aI,aP,aO,aS,aR,aT;try{aN=b(aV)}catch(aM){return}aK=aN.outerHeight();aL=aN.outerWidth();al.scrollTop(0);al.scrollLeft(0);while(!aN.is(".jspPane")){s+=aN.position().top;aU+=aN.position().left;aN=aN.offsetParent();if(/^body|html$/i.test(aN[0].nodeName)){return}}aI=aA();aO=aI+v;if(s<aI||aQ){aR=s-ay.verticalGutter}else{if(s+aK>aO){aR=s-v+aK+ay.verticalGutter}}if(aR){M(aR,aJ)}aP=aC();aS=aP+aj;if(aU<aP||aQ){aT=aU-ay.horizontalGutter}else{if(aU+aL>aS){aT=aU-aj+aL+ay.horizontalGutter}}if(aT){N(aT,aJ)}}function aC(){return -Y.position().left}function aA(){return -Y.position().top}function K(){var s=Z-v;return(s>20)&&(s-aA()<10)}function B(){var s=T-aj;return(s>20)&&(s-aC()<10)}function ag(){al.unbind(ac).bind(ac,function(aL,aM,aK,aI){var aJ=aa,s=I;Q.scrollBy(aK*ay.mouseWheelSpeed,-aI*ay.mouseWheelSpeed,false);return aJ==aa&&s==I})}function n(){al.unbind(ac)}function aB(){return false}function J(){Y.find(":input,a").unbind("focus.jsp").bind("focus.jsp",function(s){ab(s.target,false)})}function E(){Y.find(":input,a").unbind("focus.jsp")}function S(){var s,aI,aK=[];aE&&aK.push(am[0]);az&&aK.push(U[0]);Y.focus(function(){D.focus()});D.attr("tabindex",0).unbind("keydown.jsp keypress.jsp").bind("keydown.jsp",function(aN){if(aN.target!==this&&!(aK.length&&b(aN.target).closest(aK).length)){return}var aM=aa,aL=I;switch(aN.keyCode){case 40:case 38:case 34:case 32:case 33:case 39:case 37:s=aN.keyCode;aJ();break;case 35:M(Z-v);s=null;break;case 36:M(0);s=null;break}aI=aN.keyCode==s&&aM!=aa||aL!=I;return !aI}).bind("keypress.jsp",function(aL){if(aL.keyCode==s){aJ()}return !aI});if(ay.hideFocus){D.css("outline","none");if("hideFocus" in al[0]){D.attr("hideFocus",true)}}else{D.css("outline","");if("hideFocus" in al[0]){D.attr("hideFocus",false)}}function aJ(){var aM=aa,aL=I;switch(s){case 40:Q.scrollByY(ay.keyboardSpeed,false);break;case 38:Q.scrollByY(-ay.keyboardSpeed,false);break;case 34:case 32:Q.scrollByY(v*ay.scrollPagePercent,false);break;case 33:Q.scrollByY(-v*ay.scrollPagePercent,false);break;case 39:Q.scrollByX(ay.keyboardSpeed,false);break;case 37:Q.scrollByX(-ay.keyboardSpeed,false);break}aI=aM!=aa||aL!=I;return aI}}function R(){D.attr("tabindex","-1").removeAttr("tabindex").unbind("keydown.jsp keypress.jsp")}function C(){if(location.hash&&location.hash.length>1){var aK,aI,aJ=escape(location.hash.substr(1));try{aK=b("#"+aJ+', a[name="'+aJ+'"]')}catch(s){return}if(aK.length&&Y.find(aJ)){if(al.scrollTop()===0){aI=setInterval(function(){if(al.scrollTop()>0){ab(aK,true);b(document).scrollTop(al.position().top);clearInterval(aI)}},50)}else{ab(aK,true);b(document).scrollTop(al.position().top)}}}}function m(){if(b(document.body).data("jspHijack")){return}b(document.body).data("jspHijack",true);b(document.body).delegate("a[href*=#]","click",function(s){var aI=this.href.substr(0,this.href.indexOf("#")),aK=location.href,aO,aP,aJ,aM,aL,aN;if(location.href.indexOf("#")!==-1){aK=location.href.substr(0,location.href.indexOf("#"))}if(aI!==aK){return}aO=escape(this.href.substr(this.href.indexOf("#")+1));aP;try{aP=b("#"+aO+', a[name="'+aO+'"]')}catch(aQ){return}if(!aP.length){return}aJ=aP.closest(".jspScrollable");aM=aJ.data("jsp");aM.scrollToElement(aP,true);if(aJ[0].scrollIntoView){aL=b(a).scrollTop();aN=aP.offset().top;if(aN<aL||aN>aL+b(a).height()){aJ[0].scrollIntoView()}}s.preventDefault()
|
||||
})}function an(){var aJ,aI,aL,aK,aM,s=false;al.unbind("touchstart.jsp touchmove.jsp touchend.jsp click.jsp-touchclick").bind("touchstart.jsp",function(aN){var aO=aN.originalEvent.touches[0];aJ=aC();aI=aA();aL=aO.pageX;aK=aO.pageY;aM=false;s=true}).bind("touchmove.jsp",function(aQ){if(!s){return}var aP=aQ.originalEvent.touches[0],aO=aa,aN=I;Q.scrollTo(aJ+aL-aP.pageX,aI+aK-aP.pageY);aM=aM||Math.abs(aL-aP.pageX)>5||Math.abs(aK-aP.pageY)>5;return aO==aa&&aN==I}).bind("touchend.jsp",function(aN){s=false}).bind("click.jsp-touchclick",function(aN){if(aM){aM=false;return false}})}function g(){var s=aA(),aI=aC();D.removeClass("jspScrollable").unbind(".jsp");D.replaceWith(ao.append(Y.children()));ao.scrollTop(s);ao.scrollLeft(aI);if(av){clearInterval(av)}}b.extend(Q,{reinitialise:function(aI){aI=b.extend({},ay,aI);ar(aI)},scrollToElement:function(aJ,aI,s){ab(aJ,aI,s)},scrollTo:function(aJ,s,aI){N(aJ,aI);M(s,aI)},scrollToX:function(aI,s){N(aI,s)},scrollToY:function(s,aI){M(s,aI)},scrollToPercentX:function(aI,s){N(aI*(T-aj),s)},scrollToPercentY:function(aI,s){M(aI*(Z-v),s)},scrollBy:function(aI,s,aJ){Q.scrollByX(aI,aJ);Q.scrollByY(s,aJ)},scrollByX:function(s,aJ){var aI=aC()+Math[s<0?"floor":"ceil"](s),aK=aI/(T-aj);W(aK*j,aJ)},scrollByY:function(s,aJ){var aI=aA()+Math[s<0?"floor":"ceil"](s),aK=aI/(Z-v);V(aK*i,aJ)},positionDragX:function(s,aI){W(s,aI)},positionDragY:function(aI,s){V(aI,s)},animate:function(aI,aL,s,aK){var aJ={};aJ[aL]=s;aI.animate(aJ,{duration:ay.animateDuration,easing:ay.animateEase,queue:false,step:aK})},getContentPositionX:function(){return aC()},getContentPositionY:function(){return aA()},getContentWidth:function(){return T},getContentHeight:function(){return Z},getPercentScrolledX:function(){return aC()/(T-aj)},getPercentScrolledY:function(){return aA()/(Z-v)},getIsScrollableH:function(){return aE},getIsScrollableV:function(){return az},getContentPane:function(){return Y},scrollToBottom:function(s){V(i,s)},hijackInternalLinks:b.noop,destroy:function(){g()}});ar(O)}e=b.extend({},b.fn.jScrollPane.defaults,e);b.each(["mouseWheelSpeed","arrowButtonSpeed","trackClickSpeed","keyboardSpeed"],function(){e[this]=e[this]||e.speed});return this.each(function(){var f=b(this),g=f.data("jsp");if(g){g.reinitialise(e)}else{g=new d(f,e);f.data("jsp",g)}})};b.fn.jScrollPane.defaults={showArrows:false,maintainPosition:true,stickToBottom:false,stickToRight:false,clickOnTrack:true,autoReinitialise:false,autoReinitialiseDelay:500,verticalDragMinHeight:0,verticalDragMaxHeight:99999,horizontalDragMinWidth:0,horizontalDragMaxWidth:99999,contentWidth:c,animateScroll:false,animateDuration:300,animateEase:"linear",hijackInternalLinks:false,verticalGutter:4,horizontalGutter:4,mouseWheelSpeed:0,arrowButtonSpeed:0,arrowRepeatFreq:50,arrowScrollOnHover:false,trackClickSpeed:0,trackClickRepeatFreq:70,verticalArrowPositions:"split",horizontalArrowPositions:"split",enableKeyboardNavigation:true,hideFocus:false,keyboardSpeed:0,initialDelay:300,speed:30,scrollPagePercent:0.8}})(jQuery,this);
|
||||
@@ -0,0 +1,16 @@
|
||||
/*
|
||||
*
|
||||
* jQuery listnav plugin
|
||||
* Copyright (c) 2009 iHwy, Inc.
|
||||
* Author: Jack Killpatrick
|
||||
*
|
||||
* Version 2.1 (08/09/2009)
|
||||
* Requires jQuery 1.3.2, jquery 1.2.6 or jquery 1.2.x plus the jquery dimensions plugin
|
||||
*
|
||||
* Visit http://www.ihwy.com/labs/jquery-listnav-plugin.aspx for more information.
|
||||
*
|
||||
* Dual licensed under the MIT and GPL licenses:
|
||||
* http://www.opensource.org/licenses/mit-license.php
|
||||
* http://www.gnu.org/licenses/gpl.html
|
||||
*
|
||||
*/(function(e){e.fn.listnav=function(t){var n=e.extend({},e.fn.listnav.defaults,t),r=["_","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","-"],i=!1;n.prefixes=e.map(n.prefixes,function(e){return e.toLowerCase()});return this.each(function(){function v(){t.append(x());u=e(".ln-letters",t).slice(0,1);n.showCounts&&(a=e(".ln-letter-count",t).slice(0,1));g();w();n.flagDisabled&&b();S();n.includeAll||o.show();n.includeAll||e(".all",u).remove();n.includeNums||e("._",u).remove();n.includeOther||e(".-",u).remove();e(":last",u).addClass("ln-last");if(e.cookie&&n.cookieName!=null){var s=e.cookie(n.cookieName);s!=null&&(n.initLetter=s)}if(n.initLetter!=""){i=!0;e("."+n.initLetter.toLowerCase(),u).slice(0,1).click()}else if(n.includeAll)e(".all",u).addClass("ln-selected");else for(var f=n.includeNums?0:1;f<r.length;f++)if(l[r[f]]>0){i=!0;e("."+r[f],u).slice(0,1).click();break}}function m(){a.css({top:e(".a",u).slice(0,1).offset({margin:!1,border:!0}).top-a.outerHeight({margin:!0})})}function g(){var t,r,i,s,u,a=n.prefixes.length>0;e(o).children().each(function(){u=e(this),r="";n.attribute&&(t=e.trim(u.attr(n.attribute)).toLowerCase());if(!n.attribute||t=="")t=e.trim(u.text()).toLowerCase();if(t!=""){if(a){s=t.split(" ");if(s.length>1&&e.inArray(s[0],n.prefixes)>-1){r=s[1].charAt(0);y(r,u,!0)}}r=t.charAt(0);y(r,u)}})}function y(e,t,n){/\W/.test(e)&&(e="-");isNaN(e)||(e="_");t.addClass("ln-"+e);l[e]==undefined&&(l[e]=0);l[e]++;n||c++}function b(){for(var t=0;t<r.length;t++)l[r[t]]==undefined&&e("."+r[t],u).addClass("ln-disabled")}function w(){o.append('<li class="ln-no-match" style="display:none">'+n.noMatchText+"</li>")}function E(t){if(e(t).hasClass("all"))return c;var n=l[e(t).attr("class").split(" ")[0]];return n!=undefined?n:0}function S(){n.showCounts&&t.mouseover(function(){m()});if(n.showCounts){e("a",u).mouseover(function(){var t=e(this).position().left,n=e(this).outerWidth({margin:!0})-1+"px",r=E(this);a.css({left:t,width:n}).text(r).show()});e("a",u).mouseout(function(){a.hide()})}e("a",u).click(function(){e("a.ln-selected",u).removeClass("ln-selected");var t=e(this).attr("class").split(" ")[0];if(t=="all"){o.children().show();o.children(".ln-no-match").hide();h=!0}else{if(h){o.children().hide();h=!1}else d!=""&&o.children(".ln-"+d).hide();var r=E(this);if(r>0){o.children(".ln-no-match").hide();o.children(".ln-"+t).show()}else o.children(".ln-no-match").show();d=t}e.cookie&&n.cookieName!=null&&e.cookie(n.cookieName,t);e(this).addClass("ln-selected");e(this).blur();!i&&n.onClick!=null?n.onClick(t):i=!1;return!1})}function x(){var e=[];for(var t=1;t<r.length;t++){e.length==0&&e.push('<a class="all" href="#">ALL</a><a class="_" href="#">0-9</a>');e.push('<a class="'+r[t]+'" href="#">'+(r[t]=="-"?"...":r[t].toUpperCase())+"</a>")}return'<div class="ln-letters">'+e.join("")+"</div>"+(n.showCounts?'<div class="ln-letter-count" style="display:none; position:absolute; top:0; left:0; width:20px;">0</div>':"")}var t,s,o,u,a,f;f=this.id;t=e("<div/>");o=e(this);o.before(t);var l={},c=0,h=!0,p=0,d="";v()})};e.fn.listnav.defaults={initLetter:"",includeAll:!0,includeOther:!0,includeNums:!0,flagDisabled:!0,noMatchText:"No matching entries",showCounts:!1,cookieName:null,onClick:null,prefixes:[],attribute:!1}})(jQuery);
|
||||
@@ -0,0 +1,235 @@
|
||||
/*
|
||||
*
|
||||
* jQuery listnav plugin
|
||||
* Copyright (c) 2009 iHwy, Inc.
|
||||
* Author: Jack Killpatrick
|
||||
*
|
||||
* Version 2.1 (08/09/2009)
|
||||
* Requires jQuery 1.3.2, jquery 1.2.6 or jquery 1.2.x plus the jquery dimensions plugin
|
||||
*
|
||||
* Visit http://www.ihwy.com/labs/jquery-listnav-plugin.aspx for more information.
|
||||
*
|
||||
* Dual licensed under the MIT and GPL licenses:
|
||||
* http://www.opensource.org/licenses/mit-license.php
|
||||
* http://www.gnu.org/licenses/gpl.html
|
||||
*
|
||||
*/
|
||||
|
||||
(function($) {
|
||||
$.fn.listnav = function(options) {
|
||||
var opts = $.extend({}, $.fn.listnav.defaults, options);
|
||||
var letters = ['_', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '-'];
|
||||
var firstClick = false;
|
||||
opts.prefixes = $.map(opts.prefixes, function(n) { return n.toLowerCase(); });
|
||||
|
||||
return this.each(function() {
|
||||
var $wrapper, list, $list, $letters, $letterCount, id;
|
||||
id = this.id;
|
||||
//$wrapper = $('#' + id + '-nav'); // user must abide by the convention: <ul id="myList"> for list and <div id="myList-nav"> for nav wrapper
|
||||
|
||||
$wrapper = $('<div/>');
|
||||
$list = $(this);
|
||||
$list.before($wrapper);
|
||||
|
||||
var counts = {}, allCount = 0, isAll = true, numCount = 0, prevLetter = '';
|
||||
|
||||
function init() {
|
||||
$wrapper.append(createLettersHtml());
|
||||
|
||||
$letters = $('.ln-letters', $wrapper).slice(0, 1); // will always be a single item
|
||||
if (opts.showCounts) $letterCount = $('.ln-letter-count', $wrapper).slice(0, 1); // will always be a single item
|
||||
|
||||
addClasses();
|
||||
addNoMatchLI();
|
||||
if (opts.flagDisabled) addDisabledClass();
|
||||
bindHandlers();
|
||||
|
||||
if (!opts.includeAll) $list.show(); // show the list in case the recommendation for includeAll=false was taken
|
||||
|
||||
// remove nav items we don't need
|
||||
//
|
||||
if (!opts.includeAll) $('.all', $letters).remove();
|
||||
if (!opts.includeNums) $('._', $letters).remove();
|
||||
if (!opts.includeOther) $('.-', $letters).remove();
|
||||
|
||||
$(':last', $letters).addClass('ln-last'); // allows for styling a case where last item needs right border set (because items before that only have top, left and bottom so that border between items isn't doubled)
|
||||
|
||||
if ($.cookie && (opts.cookieName != null)) {
|
||||
var cookieLetter = $.cookie(opts.cookieName);
|
||||
if (cookieLetter != null) opts.initLetter = cookieLetter;
|
||||
}
|
||||
|
||||
// decide what to show first
|
||||
//
|
||||
if (opts.initLetter != '') {
|
||||
firstClick = true;
|
||||
$('.' + opts.initLetter.toLowerCase(), $letters).slice(0, 1).click(); // click the initLetter if there was one
|
||||
}
|
||||
else {
|
||||
if (opts.includeAll) $('.all', $letters).addClass('ln-selected'); // showing all: we don't need to click this: the whole list is already loaded
|
||||
else { // ALL link is hidden, click the first letter that will display LI's
|
||||
for (var i = ((opts.includeNums) ? 0 : 1); i < letters.length; i++) {
|
||||
if (counts[letters[i]] > 0) {
|
||||
firstClick = true;
|
||||
$('.' + letters[i], $letters).slice(0, 1).click();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// positions the letter count div above the letter links (so we only have to do it once: after this we just change it's left position via mouseover)
|
||||
//
|
||||
function setLetterCountTop() {
|
||||
$letterCount.css({ top: $('.a', $letters).slice(0, 1).offset({ margin: false, border: true }).top - $letterCount.outerHeight({ margin: true }) }); // note: don't set top based on '.all': it might not be visible
|
||||
}
|
||||
|
||||
// adds a class to each LI that has text content inside of it (ie, inside an <a>, a <div>, nested DOM nodes, etc)
|
||||
//
|
||||
function addClasses() {
|
||||
var str, firstChar, firstWord, spl, $this, hasPrefixes = (opts.prefixes.length > 0);
|
||||
$($list).children().each(function() {
|
||||
$this = $(this), firstChar = '';
|
||||
if(opts.attribute){
|
||||
str = $.trim($this.attr(opts.attribute)).toLowerCase();
|
||||
}
|
||||
if(!opts.attribute || str == ''){
|
||||
str = $.trim($this.text()).toLowerCase();
|
||||
}
|
||||
if (str != '') {
|
||||
if (hasPrefixes) {
|
||||
spl = str.split(' ');
|
||||
if ((spl.length > 1) && ($.inArray(spl[0], opts.prefixes) > -1)) {
|
||||
firstChar = spl[1].charAt(0);
|
||||
addLetterClass(firstChar, $this, true);
|
||||
}
|
||||
}
|
||||
firstChar = str.charAt(0);
|
||||
addLetterClass(firstChar, $this);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function addLetterClass(firstChar, $el, isPrefix) {
|
||||
if (/\W/.test(firstChar)) firstChar = '-'; // not A-Z, a-z or 0-9, so considered "other"
|
||||
if (!isNaN(firstChar)) firstChar = '_'; // use '_' if the first char is a number
|
||||
$el.addClass('ln-' + firstChar);
|
||||
|
||||
if (counts[firstChar] == undefined) counts[firstChar] = 0;
|
||||
counts[firstChar]++;
|
||||
if (!isPrefix) allCount++;
|
||||
}
|
||||
|
||||
function addDisabledClass() {
|
||||
for (var i = 0; i < letters.length; i++) {
|
||||
if (counts[letters[i]] == undefined) $('.' + letters[i], $letters).addClass('ln-disabled');
|
||||
}
|
||||
}
|
||||
|
||||
function addNoMatchLI() {
|
||||
$list.append('<li class="ln-no-match" style="display:none">' + opts.noMatchText + '</li>');
|
||||
}
|
||||
|
||||
function getLetterCount(el) {
|
||||
if ($(el).hasClass('all')) return allCount;
|
||||
else {
|
||||
var count = counts[$(el).attr('class').split(' ')[0]];
|
||||
return (count != undefined) ? count : 0; // some letters may not have a count in the hash
|
||||
}
|
||||
}
|
||||
|
||||
function bindHandlers() {
|
||||
|
||||
// sets the top position of the count div in case something above it on the page has resized
|
||||
//
|
||||
if (opts.showCounts) {
|
||||
$wrapper.mouseover(function() {
|
||||
setLetterCountTop();
|
||||
});
|
||||
}
|
||||
|
||||
// mouseover for each letter: shows the count above the letter
|
||||
//
|
||||
if (opts.showCounts) {
|
||||
$('a', $letters).mouseover(function() {
|
||||
var left = $(this).position().left;
|
||||
var width = ($(this).outerWidth({ margin: true }) - 1) + 'px'; // the -1 is to tweak the width a bit due to a seeming inaccuracy in jquery ui/dimensions outerWidth (same result in FF2 and IE6/7)
|
||||
var count = getLetterCount(this);
|
||||
$letterCount.css({ left: left, width: width }).text(count).show(); // set left position and width of letter count, set count text and show it
|
||||
});
|
||||
|
||||
// mouseout for each letter: hide the count
|
||||
//
|
||||
$('a', $letters).mouseout(function() {
|
||||
$letterCount.hide();
|
||||
});
|
||||
}
|
||||
|
||||
// click handler for letters: shows/hides relevant LI's
|
||||
//
|
||||
$('a', $letters).click(function() {
|
||||
$('a.ln-selected', $letters).removeClass('ln-selected');
|
||||
|
||||
var letter = $(this).attr('class').split(' ')[0];
|
||||
|
||||
if (letter == 'all') {
|
||||
$list.children().show();
|
||||
$list.children('.ln-no-match').hide();
|
||||
isAll = true;
|
||||
} else {
|
||||
if (isAll) {
|
||||
$list.children().hide();
|
||||
isAll = false;
|
||||
} else if (prevLetter != '') $list.children('.ln-' + prevLetter).hide();
|
||||
|
||||
var count = getLetterCount(this);
|
||||
if (count > 0) {
|
||||
$list.children('.ln-no-match').hide(); // in case it's showing
|
||||
$list.children('.ln-' + letter).show();
|
||||
}
|
||||
else $list.children('.ln-no-match').show();
|
||||
|
||||
prevLetter = letter;
|
||||
}
|
||||
|
||||
if ($.cookie && (opts.cookieName != null)) $.cookie(opts.cookieName, letter);
|
||||
|
||||
|
||||
$(this).addClass('ln-selected');
|
||||
$(this).blur();
|
||||
if (!firstClick && (opts.onClick != null)) opts.onClick(letter);
|
||||
else firstClick = false;
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
// creates the HTML for the letter links
|
||||
//
|
||||
function createLettersHtml() {
|
||||
var html = [];
|
||||
for (var i = 1; i < letters.length; i++) {
|
||||
if (html.length == 0) html.push('<a class="all" href="#">ALL</a><a class="_" href="#">0-9</a>');
|
||||
html.push('<a class="' + letters[i] + '" href="#">' + ((letters[i] == '-') ? '...' : letters[i].toUpperCase()) + '</a>');
|
||||
}
|
||||
return '<div class="ln-letters">' + html.join('') + '</div>' + ((opts.showCounts) ? '<div class="ln-letter-count" style="display:none; position:absolute; top:0; left:0; width:20px;">0</div>' : ''); // the styling for ln-letter-count is to give us a starting point for the element, which will be repositioned when made visible (ie, should not need to be styled by the user)
|
||||
}
|
||||
|
||||
init();
|
||||
});
|
||||
};
|
||||
|
||||
$.fn.listnav.defaults = {
|
||||
initLetter: '',
|
||||
includeAll: true,
|
||||
includeOther: true,
|
||||
includeNums: true,
|
||||
flagDisabled: true,
|
||||
noMatchText: 'No matching entries',
|
||||
showCounts: false,
|
||||
cookieName: null,
|
||||
onClick: null,
|
||||
prefixes: [],
|
||||
attribute: false,
|
||||
};
|
||||
})(jQuery);
|
||||
@@ -0,0 +1,84 @@
|
||||
/*! Copyright (c) 2011 Brandon Aaron (http://brandonaaron.net)
|
||||
* Licensed under the MIT License (LICENSE.txt).
|
||||
*
|
||||
* Thanks to: http://adomas.org/javascript-mouse-wheel/ for some pointers.
|
||||
* Thanks to: Mathias Bank(http://www.mathias-bank.de) for a scope bug fix.
|
||||
* Thanks to: Seamus Leahy for adding deltaX and deltaY
|
||||
*
|
||||
* Version: 3.0.6
|
||||
*
|
||||
* Requires: 1.2.2+
|
||||
*/
|
||||
|
||||
(function($) {
|
||||
|
||||
var types = ['DOMMouseScroll', 'mousewheel'];
|
||||
|
||||
if ($.event.fixHooks) {
|
||||
for ( var i=types.length; i; ) {
|
||||
$.event.fixHooks[ types[--i] ] = $.event.mouseHooks;
|
||||
}
|
||||
}
|
||||
|
||||
$.event.special.mousewheel = {
|
||||
setup: function() {
|
||||
if ( this.addEventListener ) {
|
||||
for ( var i=types.length; i; ) {
|
||||
this.addEventListener( types[--i], handler, false );
|
||||
}
|
||||
} else {
|
||||
this.onmousewheel = handler;
|
||||
}
|
||||
},
|
||||
|
||||
teardown: function() {
|
||||
if ( this.removeEventListener ) {
|
||||
for ( var i=types.length; i; ) {
|
||||
this.removeEventListener( types[--i], handler, false );
|
||||
}
|
||||
} else {
|
||||
this.onmousewheel = null;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
$.fn.extend({
|
||||
mousewheel: function(fn) {
|
||||
return fn ? this.bind("mousewheel", fn) : this.trigger("mousewheel");
|
||||
},
|
||||
|
||||
unmousewheel: function(fn) {
|
||||
return this.unbind("mousewheel", fn);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
function handler(event) {
|
||||
var orgEvent = event || window.event, args = [].slice.call( arguments, 1 ), delta = 0, returnValue = true, deltaX = 0, deltaY = 0;
|
||||
event = $.event.fix(orgEvent);
|
||||
event.type = "mousewheel";
|
||||
|
||||
// Old school scrollwheel delta
|
||||
if ( orgEvent.wheelDelta ) { delta = orgEvent.wheelDelta/120; }
|
||||
if ( orgEvent.detail ) { delta = -orgEvent.detail/3; }
|
||||
|
||||
// New school multidimensional scroll (touchpads) deltas
|
||||
deltaY = delta;
|
||||
|
||||
// Gecko
|
||||
if ( orgEvent.axis !== undefined && orgEvent.axis === orgEvent.HORIZONTAL_AXIS ) {
|
||||
deltaY = 0;
|
||||
deltaX = -1*delta;
|
||||
}
|
||||
|
||||
// Webkit
|
||||
if ( orgEvent.wheelDeltaY !== undefined ) { deltaY = orgEvent.wheelDeltaY/120; }
|
||||
if ( orgEvent.wheelDeltaX !== undefined ) { deltaX = -1*orgEvent.wheelDeltaX/120; }
|
||||
|
||||
// Add event and delta to the front of the arguments
|
||||
args.unshift(event, delta, deltaX, deltaY);
|
||||
|
||||
return ($.event.dispatch || $.event.handle).apply(this, args);
|
||||
}
|
||||
|
||||
})(jQuery);
|
||||
+4
File diff suppressed because one or more lines are too long
@@ -0,0 +1,76 @@
|
||||
/**
|
||||
* @author trixta
|
||||
* @version 1.2
|
||||
*/
|
||||
(function($){
|
||||
|
||||
var mwheelI = {
|
||||
pos: [-260, -260]
|
||||
},
|
||||
minDif = 3,
|
||||
doc = document,
|
||||
root = doc.documentElement,
|
||||
body = doc.body,
|
||||
longDelay, shortDelay
|
||||
;
|
||||
|
||||
function unsetPos(){
|
||||
if(this === mwheelI.elem){
|
||||
mwheelI.pos = [-260, -260];
|
||||
mwheelI.elem = false;
|
||||
minDif = 3;
|
||||
}
|
||||
}
|
||||
|
||||
$.event.special.mwheelIntent = {
|
||||
setup: function(){
|
||||
var jElm = $(this).bind('mousewheel', $.event.special.mwheelIntent.handler);
|
||||
if( this !== doc && this !== root && this !== body ){
|
||||
jElm.bind('mouseleave', unsetPos);
|
||||
}
|
||||
jElm = null;
|
||||
return true;
|
||||
},
|
||||
teardown: function(){
|
||||
$(this)
|
||||
.unbind('mousewheel', $.event.special.mwheelIntent.handler)
|
||||
.unbind('mouseleave', unsetPos)
|
||||
;
|
||||
return true;
|
||||
},
|
||||
handler: function(e, d){
|
||||
var pos = [e.clientX, e.clientY];
|
||||
if( this === mwheelI.elem || Math.abs(mwheelI.pos[0] - pos[0]) > minDif || Math.abs(mwheelI.pos[1] - pos[1]) > minDif ){
|
||||
mwheelI.elem = this;
|
||||
mwheelI.pos = pos;
|
||||
minDif = 250;
|
||||
|
||||
clearTimeout(shortDelay);
|
||||
shortDelay = setTimeout(function(){
|
||||
minDif = 10;
|
||||
}, 200);
|
||||
clearTimeout(longDelay);
|
||||
longDelay = setTimeout(function(){
|
||||
minDif = 3;
|
||||
}, 1500);
|
||||
e = $.extend({}, e, {type: 'mwheelIntent'});
|
||||
return $.event.handle.apply(this, arguments);
|
||||
}
|
||||
}
|
||||
};
|
||||
$.fn.extend({
|
||||
mwheelIntent: function(fn) {
|
||||
return fn ? this.bind("mwheelIntent", fn) : this.trigger("mwheelIntent");
|
||||
},
|
||||
|
||||
unmwheelIntent: function(fn) {
|
||||
return this.unbind("mwheelIntent", fn);
|
||||
}
|
||||
});
|
||||
|
||||
$(function(){
|
||||
body = doc.body;
|
||||
//assume that document is always scrollable, doesn't hurt if not
|
||||
$(doc).bind('mwheelIntent.mwheelIntentDefault', $.noop);
|
||||
});
|
||||
})(jQuery);
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user