From 8a8530f26e2398cd65aef6a044f0438233ca3dd6 Mon Sep 17 00:00:00 2001 From: Ben Alman Date: Fri, 27 Aug 2010 02:27:18 +0000 Subject: [PATCH] adding ajaxCrawlable (code name: fragbango) functionality. code and unit tests are done, just needs documentation and examples. --- README.markdown | 4 +- docs/files/jquery-ba-bbq-js.html | 42 ++--- docs/index/Files.html | 2 +- docs/index/Functions.html | 26 +-- docs/index/General.html | 32 ++-- docs/javascript/searchdata.js | 2 +- docs/nd/Data/FileInfo.nd | 4 +- docs/nd/Data/IndexInfo.nd | Bin 188 -> 188 bytes docs/nd/Data/SymbolTable.nd | Bin 9471 -> 9692 bytes docs/search/FunctionsA.html | 20 +++ docs/search/GeneralA.html | 20 +++ jquery.ba-bbq.js | 75 ++++++-- jquery.ba-bbq.min.js | 4 +- unit/unit.js | 292 ++++++++++++++++++++++++++----- 14 files changed, 406 insertions(+), 117 deletions(-) create mode 100644 docs/search/FunctionsA.html create mode 100644 docs/search/GeneralA.html diff --git a/README.markdown b/README.markdown index e6929c7..74eb264 100644 --- a/README.markdown +++ b/README.markdown @@ -1,7 +1,7 @@ # jQuery BBQ: Back Button & Query Library # [http://benalman.com/projects/jquery-bbq-plugin/](http://benalman.com/projects/jquery-bbq-plugin/) -Version: 1.3pre, Last updated: 8/20/2010 +Version: 1.3pre, Last updated: 8/26/2010 jQuery BBQ enables simple, yet powerful bookmarkable #hash history via a cross-browser window.onhashchange event. In addition, jQuery BBQ provides a full jQuery.deparam() method, along with both fragment and query string parse and merge utility methods. @@ -54,7 +54,7 @@ Safari: Back Button from a different domain ## Release History ## -1.3pre - (8/20/2010) Integrated jQuery hashchange event v1.3, which adds document.title and document.domain support in IE6/7, BlackBerry support, better Iframe hiding for accessibility reasons, and the new jQuery.fn.hashchange "shortcut" method. Added the jQuery.param.sorted method which reduces the possibility of extraneous hashchange event triggering. +1.3pre - (8/26/2010) Integrated jQuery hashchange event v1.3, which adds document.title and document.domain support in IE6/7, BlackBerry support, better Iframe hiding for accessibility reasons, and the new jQuery.fn.hashchange "shortcut" method. Added the jQuery.param.sorted method which reduces the possibility of extraneous hashchange event triggering. Added the jQuery.param.fragment.ajaxCrawlable method which can be used to enable Google "AJAX Crawlable mode." 1.2.1 - (2/17/2010) Actually fixed the stale window.location Safari bug from jQuery hashchange event in BBQ, which was the main reason for the previous release! 1.2 - (2/16/2010) Integrated jQuery hashchange event v1.2, which fixes a Safari bug, the event can now be bound before DOM ready, and IE6/7 page should no longer scroll when the event is first bound. Also added the jQuery.param.fragment.noEscape method, and reworked the hashchange event (BBQ) internal "add" method to be compatible with changes made to the jQuery 1.4.2 special events API. 1.1.1 - (1/22/2010) Integrated jQuery hashchange event v1.1, which fixes an obscure IE8 EmulateIE7 meta tag compatibility mode bug. diff --git a/docs/files/jquery-ba-bbq-js.html b/docs/files/jquery-ba-bbq-js.html index b5a5da7..ee2b110 100644 --- a/docs/files/jquery-ba-bbq-js.html +++ b/docs/files/jquery-ba-bbq-js.html @@ -11,7 +11,7 @@ -

jQuery BBQ: Back Button & Query Library

Version: 1.3pre, Last updated: 8/20/2010

Project Homehttp://benalman.com/projects/jquery-bbq-plugin/
GitHubhttp://github.com/cowboy/jquery-bbq/
Sourcehttp://github.com/cowboy/jquery-bbq/raw/master/jquery.ba-bbq.js
(Minified)http://github.com/cowboy/jquery-bbq/raw/master/jquery.ba-bbq.min.js (2.2kb gzipped)
Summary
jQuery BBQ: Back Button & Query LibraryVersion: 1.3pre, Last updated: 8/20/2010
LicenseCopyright © 2010 “Cowboy” Ben Alman, Dual licensed under the MIT and GPL licenses.
ExamplesThese working examples, complete with fully commented code, illustrate a few ways in which this plugin can be used.
Support and TestingInformation about what version or versions of jQuery this plugin has been tested with, what browsers it has been tested in, and where the unit tests reside (so you can test it yourself).
Release History
Param (to string)
Functions
jQuery.param.querystringRetrieve the query string from a URL or if no arguments are passed, the current window.location.
jQuery.param.querystring (build url)Merge a URL, with or without pre-existing query string params, plus any object, params string or URL containing query string params into a new URL.
jQuery.param.fragmentRetrieve the fragment (hash) from a URL or if no arguments are passed, the current window.location.
jQuery.param.fragment (build url)Merge a URL, with or without pre-existing fragment (hash) params, plus any object, params string or URL containing fragment (hash) params into a new URL.
jQuery.param.sortedReturns a params string equivalent to that returned by the internal jQuery.param method, but sorted, which makes it suitable for use as a cache key.
jQuery.param.fragment.noEscapeSpecify characters that will be left unescaped when fragments are created or merged using jQuery.param.fragment, or when the fragment is modified using jQuery.bbq.pushState.
Deparam (from string)
Functions
jQuery.deparamDeserialize a params string into an object, optionally coercing numbers, booleans, null and undefined values; this method is the counterpart to the internal jQuery.param method.
jQuery.deparam.querystringParse the query string from a URL or the current window.location, deserializing it into an object, optionally coercing numbers, booleans, null and undefined values.
jQuery.deparam.fragmentParse the fragment (hash) from a URL or the current window.location, deserializing it into an object, optionally coercing numbers, booleans, null and undefined values.
Element manipulation
Functions
jQuery.elemUrlAttrGet the internal “Default URL attribute per tag” list, or augment the list with additional tag-attribute pairs, in case the defaults are insufficient.
jQuery.fn.querystringUpdate URL attribute in one or more elements, merging the current URL (with or without pre-existing query string params) plus any params object or string into a new URL, which is then set into that attribute.
jQuery.fn.fragmentUpdate URL attribute in one or more elements, merging the current URL (with or without pre-existing fragment/hash params) plus any params object or string into a new URL, which is then set into that attribute.
History, hashchange event
Functions
jQuery.bbq.pushStateAdds a ‘state’ into the browser history at the current position, setting location.hash and triggering any bound hashchange event callbacks (provided the new state is different than the previous state).
jQuery.bbq.getStateRetrieves the current ‘state’ from the browser history, parsing location.hash for a specific key or returning an object containing the entire state, optionally coercing numbers, booleans, null and undefined values.
jQuery.bbq.removeStateRemove one or more keys from the current browser history ‘state’, creating a new state, setting location.hash and triggering any bound hashchange event callbacks (provided the new state is different than the previous state).
Events
hashchange event (BBQ)In jQuery 1.4 and newer, the event object passed into any hashchange event callback is augmented with a copy of the location.hash fragment at the time the event was triggered as its event.fragment property.
Files
jQuery hashchange eventVersion: 1.3, Last updated: 7/21/2010
LicenseCopyright © 2010 “Cowboy” Ben Alman, Dual licensed under the MIT and GPL licenses.
ExamplesThese working examples, complete with fully commented code, illustrate a few ways in which this plugin can be used.
Support and TestingInformation about what version or versions of jQuery this plugin has been tested with, what browsers it has been tested in, and where the unit tests reside (so you can test it yourself).
Known issuesWhile this jQuery hashchange event implementation is quite stable and robust, there are a few unfortunate browser bugs surrounding expected hashchange event-based behaviors, independent of any JavaScript window.onhashchange abstraction.
Release History
Functions
jQuery.fn.hashchangeBind a handler to the window.onhashchange event or trigger all bound window.onhashchange event handlers.
Properties
jQuery.fn.hashchange.delayThe numeric interval (in milliseconds) at which the hashchange event polling loop executes.
jQuery.fn.hashchange.domainIf you’re setting document.domain in your JavaScript, and you want hash history to work in IE6/7, not only must this property be set, but you must also set document.domain BEFORE jQuery is loaded into the page.
jQuery.fn.hashchange.srcIf, for some reason, you need to specify an Iframe src file (for example, when setting document.domain as in jQuery.fn.hashchange.domain), you can do so using this property.
Events
hashchange eventFired when location.hash changes.
+

jQuery BBQ: Back Button & Query Library

Version: 1.3pre, Last updated: 8/26/2010

Project Homehttp://benalman.com/projects/jquery-bbq-plugin/
GitHubhttp://github.com/cowboy/jquery-bbq/
Sourcehttp://github.com/cowboy/jquery-bbq/raw/master/jquery.ba-bbq.js
(Minified)http://github.com/cowboy/jquery-bbq/raw/master/jquery.ba-bbq.min.js (2.2kb gzipped)
Summary
jQuery BBQ: Back Button & Query LibraryVersion: 1.3pre, Last updated: 8/26/2010
LicenseCopyright © 2010 “Cowboy” Ben Alman, Dual licensed under the MIT and GPL licenses.
ExamplesThese working examples, complete with fully commented code, illustrate a few ways in which this plugin can be used.
Support and TestingInformation about what version or versions of jQuery this plugin has been tested with, what browsers it has been tested in, and where the unit tests reside (so you can test it yourself).
Release History
Param (to string)
Functions
jQuery.param.querystringRetrieve the query string from a URL or if no arguments are passed, the current window.location.
jQuery.param.querystring (build url)Merge a URL, with or without pre-existing query string params, plus any object, params string or URL containing query string params into a new URL.
jQuery.param.fragmentRetrieve the fragment (hash) from a URL or if no arguments are passed, the current window.location.
jQuery.param.fragment (build url)Merge a URL, with or without pre-existing fragment (hash) params, plus any object, params string or URL containing fragment (hash) params into a new URL.
jQuery.param.sortedReturns a params string equivalent to that returned by the internal jQuery.param method, but sorted, which makes it suitable for use as a cache key.
jQuery.param.fragment.noEscapeSpecify characters that will be left unescaped when fragments are created or merged using jQuery.param.fragment, or when the fragment is modified using jQuery.bbq.pushState.
jQuery.param.fragment.ajaxCrawlableTODO: DESCRIBE
Deparam (from string)
Functions
jQuery.deparamDeserialize a params string into an object, optionally coercing numbers, booleans, null and undefined values; this method is the counterpart to the internal jQuery.param method.
jQuery.deparam.querystringParse the query string from a URL or the current window.location, deserializing it into an object, optionally coercing numbers, booleans, null and undefined values.
jQuery.deparam.fragmentParse the fragment (hash) from a URL or the current window.location, deserializing it into an object, optionally coercing numbers, booleans, null and undefined values.
Element manipulation
Functions
jQuery.elemUrlAttrGet the internal “Default URL attribute per tag” list, or augment the list with additional tag-attribute pairs, in case the defaults are insufficient.
jQuery.fn.querystringUpdate URL attribute in one or more elements, merging the current URL (with or without pre-existing query string params) plus any params object or string into a new URL, which is then set into that attribute.
jQuery.fn.fragmentUpdate URL attribute in one or more elements, merging the current URL (with or without pre-existing fragment/hash params) plus any params object or string into a new URL, which is then set into that attribute.
History, hashchange event
Functions
jQuery.bbq.pushStateAdds a ‘state’ into the browser history at the current position, setting location.hash and triggering any bound hashchange event callbacks (provided the new state is different than the previous state).
jQuery.bbq.getStateRetrieves the current ‘state’ from the browser history, parsing location.hash for a specific key or returning an object containing the entire state, optionally coercing numbers, booleans, null and undefined values.
jQuery.bbq.removeStateRemove one or more keys from the current browser history ‘state’, creating a new state, setting location.hash and triggering any bound hashchange event callbacks (provided the new state is different than the previous state).
Events
hashchange event (BBQ)In jQuery 1.4 and newer, the event object passed into any hashchange event callback is augmented with a copy of the location.hash fragment at the time the event was triggered as its event.fragment property.
Files
jQuery hashchange eventVersion: 1.3, Last updated: 7/21/2010
LicenseCopyright © 2010 “Cowboy” Ben Alman, Dual licensed under the MIT and GPL licenses.
ExamplesThese working examples, complete with fully commented code, illustrate a few ways in which this plugin can be used.
Support and TestingInformation about what version or versions of jQuery this plugin has been tested with, what browsers it has been tested in, and where the unit tests reside (so you can test it yourself).
Known issuesWhile this jQuery hashchange event implementation is quite stable and robust, there are a few unfortunate browser bugs surrounding expected hashchange event-based behaviors, independent of any JavaScript window.onhashchange abstraction.
Release History
Functions
jQuery.fn.hashchangeBind a handler to the window.onhashchange event or trigger all bound window.onhashchange event handlers.
Properties
jQuery.fn.hashchange.delayThe numeric interval (in milliseconds) at which the hashchange event polling loop executes.
jQuery.fn.hashchange.domainIf you’re setting document.domain in your JavaScript, and you want hash history to work in IE6/7, not only must this property be set, but you must also set document.domain BEFORE jQuery is loaded into the page.
jQuery.fn.hashchange.srcIf, for some reason, you need to specify an Iframe src file (for example, when setting document.domain as in jQuery.fn.hashchange.domain), you can do so using this property.
Events
hashchange eventFired when location.hash changes.

License

Copyright © 2010 “Cowboy” Ben Alman, Dual licensed under the MIT and GPL licenses.  http://benalman.com/about/license/

@@ -19,9 +19,9 @@

Support and Testing

Information about what version or versions of jQuery this plugin has been tested with, what browsers it has been tested in, and where the unit tests reside (so you can test it yourself).

jQuery Versions1.2.6, 1.3.2, 1.4.1, 1.4.2
Browsers TestedInternet Explorer 6-8, Firefox 2-4, Chrome 5-6, Safari 3.2-5, Opera 9.6-10.60, iPhone 3.1, Android 1.6-2.2, BlackBerry 4.6-5.
Unit Testshttp://benalman.com/code/projects/jquery-bbq/unit/
-

Release History

1.3pre(8/20/2010) Integrated jQuery hashchange event v1.3, which adds document.title and document.domain support in IE6/7, BlackBerry support, better Iframe hiding for accessibility reasons, and the new jQuery.fn.hashchange “shortcut” method.  Added the jQuery.param.sorted method which reduces the possibility of extraneous hashchange event triggering.
1.2.1(2/17/2010) Actually fixed the stale window.location Safari bug from jQuery hashchange event in BBQ, which was the main reason for the previous release!
1.2(2/16/2010) Integrated jQuery hashchange event v1.2, which fixes a Safari bug, the event can now be bound before DOM ready, and IE6/7 page should no longer scroll when the event is first bound.  Also added the jQuery.param.fragment.noEscape method, and reworked the hashchange event (BBQ) internal “add” method to be compatible with changes made to the jQuery 1.4.2 special events API.
1.1.1(1/22/2010) Integrated jQuery hashchange event v1.1, which fixes an obscure IE8 EmulateIE7 meta tag compatibility mode bug.
1.1(1/9/2010) Broke out the jQuery BBQ event.special hashchange event functionality into a separate plugin for users who want just the basic event & back button support, without all the extra awesomeness that BBQ provides.  This plugin will be included as part of jQuery BBQ, but also be available separately.  See jQuery hashchange event plugin for more information.  Also added the jQuery.bbq.removeState method and added additional jQuery.deparam examples.
1.0.3(12/2/2009) Fixed an issue in IE 6 where location.search and location.hash would report incorrectly if the hash contained the ? character.  Also jQuery.param.querystring and jQuery.param.fragment will no longer parse params out of a URL that doesn’t contain ? or #, respectively.
1.0.2(10/10/2009) Fixed an issue in IE 6/7 where the hidden IFRAME caused a “This page contains both secure and nonsecure items.” warning when used on an https:// page.
1.0.1(10/7/2009) Fixed an issue in IE 8.  Since both “IE7” and “IE8 Compatibility View” modes erroneously report that the browser supports the native window.onhashchange event, a slightly more robust test needed to be added.
1.0(10/2/2009) Initial release
+

Release History

1.3pre(8/26/2010) Integrated jQuery hashchange event v1.3, which adds document.title and document.domain support in IE6/7, BlackBerry support, better Iframe hiding for accessibility reasons, and the new jQuery.fn.hashchange “shortcut” method.  Added the jQuery.param.sorted method which reduces the possibility of extraneous hashchange event triggering.  Added the jQuery.param.fragment.ajaxCrawlable method which can be used to enable Google “AJAX Crawlable mode.”
1.2.1(2/17/2010) Actually fixed the stale window.location Safari bug from jQuery hashchange event in BBQ, which was the main reason for the previous release!
1.2(2/16/2010) Integrated jQuery hashchange event v1.2, which fixes a Safari bug, the event can now be bound before DOM ready, and IE6/7 page should no longer scroll when the event is first bound.  Also added the jQuery.param.fragment.noEscape method, and reworked the hashchange event (BBQ) internal “add” method to be compatible with changes made to the jQuery 1.4.2 special events API.
1.1.1(1/22/2010) Integrated jQuery hashchange event v1.1, which fixes an obscure IE8 EmulateIE7 meta tag compatibility mode bug.
1.1(1/9/2010) Broke out the jQuery BBQ event.special hashchange event functionality into a separate plugin for users who want just the basic event & back button support, without all the extra awesomeness that BBQ provides.  This plugin will be included as part of jQuery BBQ, but also be available separately.  See jQuery hashchange event plugin for more information.  Also added the jQuery.bbq.removeState method and added additional jQuery.deparam examples.
1.0.3(12/2/2009) Fixed an issue in IE 6 where location.search and location.hash would report incorrectly if the hash contained the ? character.  Also jQuery.param.querystring and jQuery.param.fragment will no longer parse params out of a URL that doesn’t contain ? or #, respectively.
1.0.2(10/10/2009) Fixed an issue in IE 6/7 where the hidden IFRAME caused a “This page contains both secure and nonsecure items.” warning when used on an https:// page.
1.0.1(10/7/2009) Fixed an issue in IE 8.  Since both “IE7” and “IE8 Compatibility View” modes erroneously report that the browser supports the native window.onhashchange event, a slightly more robust test needed to be added.
1.0(10/2/2009) Initial release
-

Param (to string)

Summary
Functions
jQuery.param.querystringRetrieve the query string from a URL or if no arguments are passed, the current window.location.
jQuery.param.querystring (build url)Merge a URL, with or without pre-existing query string params, plus any object, params string or URL containing query string params into a new URL.
jQuery.param.fragmentRetrieve the fragment (hash) from a URL or if no arguments are passed, the current window.location.
jQuery.param.fragment (build url)Merge a URL, with or without pre-existing fragment (hash) params, plus any object, params string or URL containing fragment (hash) params into a new URL.
jQuery.param.sortedReturns a params string equivalent to that returned by the internal jQuery.param method, but sorted, which makes it suitable for use as a cache key.
jQuery.param.fragment.noEscapeSpecify characters that will be left unescaped when fragments are created or merged using jQuery.param.fragment, or when the fragment is modified using jQuery.bbq.pushState.
+

Param (to string)

Summary
Functions
jQuery.param.querystringRetrieve the query string from a URL or if no arguments are passed, the current window.location.
jQuery.param.querystring (build url)Merge a URL, with or without pre-existing query string params, plus any object, params string or URL containing query string params into a new URL.
jQuery.param.fragmentRetrieve the fragment (hash) from a URL or if no arguments are passed, the current window.location.
jQuery.param.fragment (build url)Merge a URL, with or without pre-existing fragment (hash) params, plus any object, params string or URL containing fragment (hash) params into a new URL.
jQuery.param.sortedReturns a params string equivalent to that returned by the internal jQuery.param method, but sorted, which makes it suitable for use as a cache key.
jQuery.param.fragment.noEscapeSpecify characters that will be left unescaped when fragments are created or merged using jQuery.param.fragment, or when the fragment is modified using jQuery.bbq.pushState.
jQuery.param.fragment.ajaxCrawlableTODO: DESCRIBE

Functions

@@ -35,7 +35,9 @@

jQuery.param.sorted

Returns a params string equivalent to that returned by the internal jQuery.param method, but sorted, which makes it suitable for use as a cache key.

For example, in most browsers jQuery.param({z:1,a:2}) returns “z=1&a=2” and jQuery.param({a:2,z:1}) returns “a=2&z=1”.  Even though both the objects being serialized and the resulting params strings are equivalent, if these params strings were set into the location.hash fragment sequentially, the hashchange event would be triggered unnecessarily, since the strings are different (even though the data described by them is the same).  By sorting the params string, unecessary hashchange event triggering can be avoided.

Usage

jQuery.param.sorted( obj [, traditional ] );

Arguments

obj(Object) An object to be serialized.
traditional(Boolean) Params deep/shallow serialization mode.  See the documentation at http://api.jquery.com/jQuery.param/ for more detail.

Returns

(String) A sorted params string.

-

jQuery.param.fragment.noEscape

Specify characters that will be left unescaped when fragments are created or merged using jQuery.param.fragment, or when the fragment is modified using jQuery.bbq.pushState.  This option only applies to serialized data object fragments, and not set-as-string fragments.  Does not affect the query string.  Defaults to “,/” (comma, forward slash).

Note that this is considered a purely aesthetic option, and will help to create URLs that “look pretty” in the address bar or bookmarks, without affecting functionality in any way.  That being said, be careful to not unescape characters that are used as delimiters or serve a special purpose, such as the “#?&=+” (octothorpe, question mark, ampersand, equals, plus) characters.

Usage

jQuery.param.fragment.noEscape( [ chars ] );

Arguments

chars(String) The characters to not escape in the fragment.  If unspecified, defaults to empty string (escape all characters).

Returns

Nothing.

+

jQuery.param.fragment.noEscape

Specify characters that will be left unescaped when fragments are created or merged using jQuery.param.fragment, or when the fragment is modified using jQuery.bbq.pushState.  This option only applies to serialized data object fragments, and not set-as-string fragments.  Does not affect the query string.  Defaults to “,/” (comma, forward slash).

Note that this is considered a purely aesthetic option, and will help to create URLs that “look pretty” in the address bar or bookmarks, without affecting functionality in any way.  That being said, be careful to not unescape characters that are used as delimiters or serve a special purpose, such as the “#?&=+” (octothorpe, question mark, ampersand, equals, plus) characters.

Usage

jQuery.param.fragment.noEscape( [ chars ] );

Arguments

chars(String) The characters to not escape in the fragment.  If unspecified, defaults to empty string (escape all characters).

Returns

Nothing.

+ +

jQuery.param.fragment.ajaxCrawlable

TODO: DESCRIBE

Usage

jQuery.param.fragment.ajaxCrawlable( [ state ] );

Arguments

state(Boolean) TODO: DESCRIBE

Returns

(Boolean) The current ajaxCrawlable state.

Deparam (from string)

Summary
Functions
jQuery.deparamDeserialize a params string into an object, optionally coercing numbers, booleans, null and undefined values; this method is the counterpart to the internal jQuery.param method.
jQuery.deparam.querystringParse the query string from a URL or the current window.location, deserializing it into an object, optionally coercing numbers, booleans, null and undefined values.
jQuery.deparam.fragmentParse the fragment (hash) from a URL or the current window.location, deserializing it into an object, optionally coercing numbers, booleans, null and undefined values.
@@ -51,37 +53,37 @@

Functions

-

jQuery.elemUrlAttr

Get the internal “Default URL attribute per tag” list, or augment the list with additional tag-attribute pairs, in case the defaults are insufficient.

In the jQuery.fn.querystring and jQuery.fn.fragment methods, this list is used to determine which attribute contains the URL to be modified, if an “attr” param is not specified.

Default Tag-Attribute List

ahref
basehref
iframesrc
imgsrc
inputsrc
formaction
linkhref
scriptsrc

Usage

jQuery.elemUrlAttr( [ tag_attr ] );

Arguments

tag_attr(Object) An object containing a list of tag names and their associated default attribute names in the format { tag: ‘attr’, ...  } to be merged into the internal tag-attribute list.

Returns

(Object) An object containing all stored tag-attribute values.

+

jQuery.elemUrlAttr

Get the internal “Default URL attribute per tag” list, or augment the list with additional tag-attribute pairs, in case the defaults are insufficient.

In the jQuery.fn.querystring and jQuery.fn.fragment methods, this list is used to determine which attribute contains the URL to be modified, if an “attr” param is not specified.

Default Tag-Attribute List

ahref
basehref
iframesrc
imgsrc
inputsrc
formaction
linkhref
scriptsrc

Usage

jQuery.elemUrlAttr( [ tag_attr ] );

Arguments

tag_attr(Object) An object containing a list of tag names and their associated default attribute names in the format { tag: ‘attr’, ...  } to be merged into the internal tag-attribute list.

Returns

(Object) An object containing all stored tag-attribute values.

-

jQuery.fn.querystring

Update URL attribute in one or more elements, merging the current URL (with or without pre-existing query string params) plus any params object or string into a new URL, which is then set into that attribute.  Like jQuery.param.querystring (build url), but for all elements in a jQuery collection.

Usage

jQuery('selector').querystring( [ attr, ] params [, merge_mode ] );

Arguments

attr(String) Optional name of an attribute that will contain a URL to merge params or url into.  See jQuery.elemUrlAttr for a list of default attributes.
params(Object) A params object to be merged into the URL attribute.
params(String) A URL containing query string params, or params string to be merged into the URL attribute.
merge_mode(Number) Merge behavior defaults to 0 if merge_mode is not specified, and is as-follows:
  • 0: params in the params argument will override any params in attr URL.
  • 1: any params in attr URL will override params in the params argument.
  • 2: params argument will completely replace any query string in attr URL.

Returns

(jQuery) The initial jQuery collection of elements, but with modified URL attribute values.

+

jQuery.fn.querystring

Update URL attribute in one or more elements, merging the current URL (with or without pre-existing query string params) plus any params object or string into a new URL, which is then set into that attribute.  Like jQuery.param.querystring (build url), but for all elements in a jQuery collection.

Usage

jQuery('selector').querystring( [ attr, ] params [, merge_mode ] );

Arguments

attr(String) Optional name of an attribute that will contain a URL to merge params or url into.  See jQuery.elemUrlAttr for a list of default attributes.
params(Object) A params object to be merged into the URL attribute.
params(String) A URL containing query string params, or params string to be merged into the URL attribute.
merge_mode(Number) Merge behavior defaults to 0 if merge_mode is not specified, and is as-follows:
  • 0: params in the params argument will override any params in attr URL.
  • 1: any params in attr URL will override params in the params argument.
  • 2: params argument will completely replace any query string in attr URL.

Returns

(jQuery) The initial jQuery collection of elements, but with modified URL attribute values.

-

jQuery.fn.fragment

Update URL attribute in one or more elements, merging the current URL (with or without pre-existing fragment/hash params) plus any params object or string into a new URL, which is then set into that attribute.  Like jQuery.param.fragment (build url), but for all elements in a jQuery collection.

Usage

jQuery('selector').fragment( [ attr, ] params [, merge_mode ] );

Arguments

attr(String) Optional name of an attribute that will contain a URL to merge params into.  See jQuery.elemUrlAttr for a list of default attributes.
params(Object) A params object to be merged into the URL attribute.
params(String) A URL containing fragment (hash) params, or params string to be merged into the URL attribute.
merge_mode(Number) Merge behavior defaults to 0 if merge_mode is not specified, and is as-follows:
  • 0: params in the params argument will override any params in attr URL.
  • 1: any params in attr URL will override params in the params argument.
  • 2: params argument will completely replace any fragment (hash) in attr URL.

Returns

(jQuery) The initial jQuery collection of elements, but with modified URL attribute values.

+

jQuery.fn.fragment

Update URL attribute in one or more elements, merging the current URL (with or without pre-existing fragment/hash params) plus any params object or string into a new URL, which is then set into that attribute.  Like jQuery.param.fragment (build url), but for all elements in a jQuery collection.

Usage

jQuery('selector').fragment( [ attr, ] params [, merge_mode ] );

Arguments

attr(String) Optional name of an attribute that will contain a URL to merge params into.  See jQuery.elemUrlAttr for a list of default attributes.
params(Object) A params object to be merged into the URL attribute.
params(String) A URL containing fragment (hash) params, or params string to be merged into the URL attribute.
merge_mode(Number) Merge behavior defaults to 0 if merge_mode is not specified, and is as-follows:
  • 0: params in the params argument will override any params in attr URL.
  • 1: any params in attr URL will override params in the params argument.
  • 2: params argument will completely replace any fragment (hash) in attr URL.

Returns

(jQuery) The initial jQuery collection of elements, but with modified URL attribute values.

-

History, hashchange event

Summary
Functions
jQuery.bbq.pushStateAdds a ‘state’ into the browser history at the current position, setting location.hash and triggering any bound hashchange event callbacks (provided the new state is different than the previous state).
jQuery.bbq.getStateRetrieves the current ‘state’ from the browser history, parsing location.hash for a specific key or returning an object containing the entire state, optionally coercing numbers, booleans, null and undefined values.
jQuery.bbq.removeStateRemove one or more keys from the current browser history ‘state’, creating a new state, setting location.hash and triggering any bound hashchange event callbacks (provided the new state is different than the previous state).
Events
hashchange event (BBQ)In jQuery 1.4 and newer, the event object passed into any hashchange event callback is augmented with a copy of the location.hash fragment at the time the event was triggered as its event.fragment property.
Files
jQuery hashchange eventVersion: 1.3, Last updated: 7/21/2010
LicenseCopyright © 2010 “Cowboy” Ben Alman, Dual licensed under the MIT and GPL licenses.
ExamplesThese working examples, complete with fully commented code, illustrate a few ways in which this plugin can be used.
Support and TestingInformation about what version or versions of jQuery this plugin has been tested with, what browsers it has been tested in, and where the unit tests reside (so you can test it yourself).
Known issuesWhile this jQuery hashchange event implementation is quite stable and robust, there are a few unfortunate browser bugs surrounding expected hashchange event-based behaviors, independent of any JavaScript window.onhashchange abstraction.
Release History
Functions
jQuery.fn.hashchangeBind a handler to the window.onhashchange event or trigger all bound window.onhashchange event handlers.
Properties
jQuery.fn.hashchange.delayThe numeric interval (in milliseconds) at which the hashchange event polling loop executes.
jQuery.fn.hashchange.domainIf you’re setting document.domain in your JavaScript, and you want hash history to work in IE6/7, not only must this property be set, but you must also set document.domain BEFORE jQuery is loaded into the page.
jQuery.fn.hashchange.srcIf, for some reason, you need to specify an Iframe src file (for example, when setting document.domain as in jQuery.fn.hashchange.domain), you can do so using this property.
Events
hashchange eventFired when location.hash changes.
+

History, hashchange event

Summary
Functions
jQuery.bbq.pushStateAdds a ‘state’ into the browser history at the current position, setting location.hash and triggering any bound hashchange event callbacks (provided the new state is different than the previous state).
jQuery.bbq.getStateRetrieves the current ‘state’ from the browser history, parsing location.hash for a specific key or returning an object containing the entire state, optionally coercing numbers, booleans, null and undefined values.
jQuery.bbq.removeStateRemove one or more keys from the current browser history ‘state’, creating a new state, setting location.hash and triggering any bound hashchange event callbacks (provided the new state is different than the previous state).
Events
hashchange event (BBQ)In jQuery 1.4 and newer, the event object passed into any hashchange event callback is augmented with a copy of the location.hash fragment at the time the event was triggered as its event.fragment property.
Files
jQuery hashchange eventVersion: 1.3, Last updated: 7/21/2010
LicenseCopyright © 2010 “Cowboy” Ben Alman, Dual licensed under the MIT and GPL licenses.
ExamplesThese working examples, complete with fully commented code, illustrate a few ways in which this plugin can be used.
Support and TestingInformation about what version or versions of jQuery this plugin has been tested with, what browsers it has been tested in, and where the unit tests reside (so you can test it yourself).
Known issuesWhile this jQuery hashchange event implementation is quite stable and robust, there are a few unfortunate browser bugs surrounding expected hashchange event-based behaviors, independent of any JavaScript window.onhashchange abstraction.
Release History
Functions
jQuery.fn.hashchangeBind a handler to the window.onhashchange event or trigger all bound window.onhashchange event handlers.
Properties
jQuery.fn.hashchange.delayThe numeric interval (in milliseconds) at which the hashchange event polling loop executes.
jQuery.fn.hashchange.domainIf you’re setting document.domain in your JavaScript, and you want hash history to work in IE6/7, not only must this property be set, but you must also set document.domain BEFORE jQuery is loaded into the page.
jQuery.fn.hashchange.srcIf, for some reason, you need to specify an Iframe src file (for example, when setting document.domain as in jQuery.fn.hashchange.domain), you can do so using this property.
Events
hashchange eventFired when location.hash changes.

Functions

-

jQuery.bbq.pushState

Adds a ‘state’ into the browser history at the current position, setting location.hash and triggering any bound hashchange event callbacks (provided the new state is different than the previous state).

If no arguments are passed, an empty state is created, which is just a shortcut for jQuery.bbq.pushState( {}, 2 ).

Usage

jQuery.bbq.pushState( [ params [, merge_mode ] ] );

Arguments

params(String) A serialized params string or a hash string beginning with # to merge into location.hash.
params(Object) A params object to merge into location.hash.
merge_mode(Number) Merge behavior defaults to 0 if merge_mode is not specified (unless a hash string beginning with # is specified, in which case merge behavior defaults to 2), and is as-follows:
  • 0: params in the params argument will override any params in the current state.
  • 1: any params in the current state will override params in the params argument.
  • 2: params argument will completely replace current state.

Returns

Nothing.

Additional Notes

  • Setting an empty state may cause the browser to scroll.
  • Unlike the fragment and querystring methods, if a hash string beginning with # is specified as the params agrument, merge_mode defaults to 2.
+

jQuery.bbq.pushState

Adds a ‘state’ into the browser history at the current position, setting location.hash and triggering any bound hashchange event callbacks (provided the new state is different than the previous state).

If no arguments are passed, an empty state is created, which is just a shortcut for jQuery.bbq.pushState( {}, 2 ).

Usage

jQuery.bbq.pushState( [ params [, merge_mode ] ] );

Arguments

params(String) A serialized params string or a hash string beginning with # to merge into location.hash.
params(Object) A params object to merge into location.hash.
merge_mode(Number) Merge behavior defaults to 0 if merge_mode is not specified (unless a hash string beginning with # is specified, in which case merge behavior defaults to 2), and is as-follows:
  • 0: params in the params argument will override any params in the current state.
  • 1: any params in the current state will override params in the params argument.
  • 2: params argument will completely replace current state.

Returns

Nothing.

Additional Notes

  • Setting an empty state may cause the browser to scroll.
  • Unlike the fragment and querystring methods, if a hash string beginning with # is specified as the params agrument, merge_mode defaults to 2.

jQuery.bbq.getState

Retrieves the current ‘state’ from the browser history, parsing location.hash for a specific key or returning an object containing the entire state, optionally coercing numbers, booleans, null and undefined values.

Usage

jQuery.bbq.getState( [ key ] [, coerce ] );

Arguments

key(String) An optional state key for which to return a value.
coerce(Boolean) If true, coerces any numbers or true, false, null, and undefined to their actual value.  Defaults to false.

Returns

(Anything) If key is passed, returns the value corresponding with that key in the location.hash ‘state’, or undefined.  If not, an object representing the entire ‘state’ is returned.

-

jQuery.bbq.removeState

Remove one or more keys from the current browser history ‘state’, creating a new state, setting location.hash and triggering any bound hashchange event callbacks (provided the new state is different than the previous state).

If no arguments are passed, an empty state is created, which is just a shortcut for jQuery.bbq.pushState( {}, 2 ).

Usage

jQuery.bbq.removeState( [ key [, key ... ] ] );

Arguments

key(String) One or more key values to remove from the current state, passed as individual arguments.
key(Array) A single array argument that contains a list of key values to remove from the current state.

Returns

Nothing.

Additional Notes

  • Setting an empty state may cause the browser to scroll.
+

jQuery.bbq.removeState

Remove one or more keys from the current browser history ‘state’, creating a new state, setting location.hash and triggering any bound hashchange event callbacks (provided the new state is different than the previous state).

If no arguments are passed, an empty state is created, which is just a shortcut for jQuery.bbq.pushState( {}, 2 ).

Usage

jQuery.bbq.removeState( [ key [, key ... ] ] );

Arguments

key(String) One or more key values to remove from the current state, passed as individual arguments.
key(Array) A single array argument that contains a list of key values to remove from the current state.

Returns

Nothing.

Additional Notes

  • Setting an empty state may cause the browser to scroll.

Events

-

hashchange event (BBQ)

Usage in jQuery 1.4 and newer

In jQuery 1.4 and newer, the event object passed into any hashchange event callback is augmented with a copy of the location.hash fragment at the time the event was triggered as its event.fragment property.  In addition, the event.getState method operates on this property (instead of location.hash) which allows this fragment-as-a-state to be referenced later, even after window.location may have changed.

Note that event.fragment and event.getState are not defined according to W3C (or any other) specification, but will still be available whether or not the hashchange event exists natively in the browser, because of the utility they provide.

The event.fragment property contains the output of jQuery.param.fragment and the event.getState method is equivalent to the jQuery.bbq.getState method.

$(window).bind( 'hashchange', function( event ) {
+

hashchange event (BBQ)

Usage in jQuery 1.4 and newer

In jQuery 1.4 and newer, the event object passed into any hashchange event callback is augmented with a copy of the location.hash fragment at the time the event was triggered as its event.fragment property.  In addition, the event.getState method operates on this property (instead of location.hash) which allows this fragment-as-a-state to be referenced later, even after window.location may have changed.

Note that event.fragment and event.getState are not defined according to W3C (or any other) specification, but will still be available whether or not the hashchange event exists natively in the browser, because of the utility they provide.

The event.fragment property contains the output of jQuery.param.fragment and the event.getState method is equivalent to the jQuery.bbq.getState method.

$(window).bind( 'hashchange', function( event ) {
   var hash_str = event.fragment,
     param_obj = event.getState(),
     param_val = event.getState( 'param_name' ),
     param_val_coerced = event.getState( 'param_name', true );
   ...
-});

Usage in jQuery 1.3.2

In jQuery 1.3.2, the event object cannot to be augmented as in jQuery 1.4+, so the fragment state isn’t bound to the event object and must instead be parsed using the jQuery.param.fragment and jQuery.bbq.getState methods.

$(window).bind( 'hashchange', function( event ) {
+});

Usage in jQuery 1.3.2

In jQuery 1.3.2, the event object cannot to be augmented as in jQuery 1.4+, so the fragment state isn’t bound to the event object and must instead be parsed using the jQuery.param.fragment and jQuery.bbq.getState methods.

$(window).bind( 'hashchange', function( event ) {
   var hash_str = $.param.fragment(),
     param_obj = $.bbq.getState(),
     param_val = $.bbq.getState( 'param_name' ),
     param_val_coerced = $.bbq.getState( 'param_name', true );
   ...
-});

Additional Notes

  • Due to changes in the special events API, jQuery BBQ v1.2 or newer is required to enable the augmented event object in jQuery 1.4.2 and newer.
  • See jQuery hashchange event for more detailed information.
+});

Additional Notes

  • Due to changes in the special events API, jQuery BBQ v1.2 or newer is required to enable the augmented event object in jQuery 1.4.2 and newer.
  • See jQuery hashchange event for more detailed information.

Files

@@ -95,23 +97,23 @@

Known issues

While this jQuery hashchange event implementation is quite stable and robust, there are a few unfortunate browser bugs surrounding expected hashchange event-based behaviors, independent of any JavaScript window.onhashchange abstraction.  See the following examples for more information:

Chrome: Back Buttonhttp://benalman.com/code/projects/jquery-hashchange/examples/bug-chrome-back-button/
Firefox: Remote XMLHttpRequesthttp://benalman.com/code/projects/jquery-hashchange/examples/bug-firefox-remote-xhr/
WebKit: Back Button in an Iframehttp://benalman.com/code/projects/jquery-hashchange/examples/bug-webkit-hash-iframe/
Safari: Back Button from a different domainhttp://benalman.com/code/projects/jquery-hashchange/examples/bug-safari-back-from-diff-domain/

Also note that should a browser natively support the window.onhashchange event, but not report that it does, the fallback polling loop will be used.

-

Release History

1.3(7/21/2010) Reorganized IE6/7 Iframe code to make it more “removable” for mobile-only development.  Added IE6/7 document.title support.  Attempted to make Iframe as hidden as possible by using techniques from http://www.paciellogroup.com/blog/?p=604.  Added support for the “shortcut” format $(window).hashchange( fn ) and $(window).hashchange() like jQuery provides for built-in events.  Renamed jQuery.hashchangeDelay to jQuery.fn.hashchange.delay and lowered its default value to 50.  Added jQuery.fn.hashchange.domain and jQuery.fn.hashchange.src properties plus document-domain.html file to address access denied issues when setting document.domain in IE6/7.
1.2(2/11/2010) Fixed a bug where coming back to a page using this plugin from a page on another domain would cause an error in Safari 4.  Also, IE6/7 Iframe is now inserted after the body (this actually works), which prevents the page from scrolling when the event is first bound.  Event can also now be bound before DOM ready, but it won’t be usable before then in IE6/7.
1.1(1/21/2010) Incorporated document.documentMode test to fix IE8 bug where browser version is incorrectly reported as 8.0, despite inclusion of the X-UA-Compatible IE=EmulateIE7 meta tag.
1.0(1/9/2010) Initial Release.  Broke out the jQuery BBQ event.special window.onhashchange functionality into a separate plugin for users who want just the basic event & back button support, without all the extra awesomeness that BBQ provides.  This plugin will be included as part of jQuery BBQ, but also be available separately.
+

Release History

1.3(7/21/2010) Reorganized IE6/7 Iframe code to make it more “removable” for mobile-only development.  Added IE6/7 document.title support.  Attempted to make Iframe as hidden as possible by using techniques from http://www.paciellogroup.com/blog/?p=604.  Added support for the “shortcut” format $(window).hashchange( fn ) and $(window).hashchange() like jQuery provides for built-in events.  Renamed jQuery.hashchangeDelay to jQuery.fn.hashchange.delay and lowered its default value to 50.  Added jQuery.fn.hashchange.domain and jQuery.fn.hashchange.src properties plus document-domain.html file to address access denied issues when setting document.domain in IE6/7.
1.2(2/11/2010) Fixed a bug where coming back to a page using this plugin from a page on another domain would cause an error in Safari 4.  Also, IE6/7 Iframe is now inserted after the body (this actually works), which prevents the page from scrolling when the event is first bound.  Event can also now be bound before DOM ready, but it won’t be usable before then in IE6/7.
1.1(1/21/2010) Incorporated document.documentMode test to fix IE8 bug where browser version is incorrectly reported as 8.0, despite inclusion of the X-UA-Compatible IE=EmulateIE7 meta tag.
1.0(1/9/2010) Initial Release.  Broke out the jQuery BBQ event.special window.onhashchange functionality into a separate plugin for users who want just the basic event & back button support, without all the extra awesomeness that BBQ provides.  This plugin will be included as part of jQuery BBQ, but also be available separately.

Functions

-

jQuery.fn.hashchange

Bind a handler to the window.onhashchange event or trigger all bound window.onhashchange event handlers.  This behavior is consistent with jQuery’s built-in event handlers.

Usage

jQuery(window).hashchange( [ handler ] );

Arguments

handler(Function) Optional handler to be bound to the hashchange event.  This is a “shortcut” for the more verbose form: jQuery(window).bind( ‘hashchange’, handler ).  If handler is omitted, all bound window.onhashchange event handlers will be triggered.  This is a shortcut for the more verbose jQuery(window).trigger( ‘hashchange’ ).  These forms are described in the hashchange event section.

Returns

(jQuery) The initial jQuery collection of elements.

+

jQuery.fn.hashchange

Bind a handler to the window.onhashchange event or trigger all bound window.onhashchange event handlers.  This behavior is consistent with jQuery’s built-in event handlers.

Usage

jQuery(window).hashchange( [ handler ] );

Arguments

handler(Function) Optional handler to be bound to the hashchange event.  This is a “shortcut” for the more verbose form: jQuery(window).bind( ‘hashchange’, handler ).  If handler is omitted, all bound window.onhashchange event handlers will be triggered.  This is a shortcut for the more verbose jQuery(window).trigger( ‘hashchange’ ).  These forms are described in the hashchange event section.

Returns

(jQuery) The initial jQuery collection of elements.

Properties

-

jQuery.fn.hashchange.delay

The numeric interval (in milliseconds) at which the hashchange event polling loop executes.  Defaults to 50.

+

jQuery.fn.hashchange.delay

The numeric interval (in milliseconds) at which the hashchange event polling loop executes.  Defaults to 50.

-

jQuery.fn.hashchange.domain

If you’re setting document.domain in your JavaScript, and you want hash history to work in IE6/7, not only must this property be set, but you must also set document.domain BEFORE jQuery is loaded into the page.  This property is only applicable if you are supporting IE6/7 (or IE8 operating in “IE7 compatibility” mode).

In addition, the jQuery.fn.hashchange.src property must be set to the path of the included “document-domain.html” file, which can be renamed or modified if necessary (note that the document.domain specified must be the same in both your main JavaScript as well as in this file).

Usage

jQuery.fn.hashchange.domain = document.domain;

+

jQuery.fn.hashchange.domain

If you’re setting document.domain in your JavaScript, and you want hash history to work in IE6/7, not only must this property be set, but you must also set document.domain BEFORE jQuery is loaded into the page.  This property is only applicable if you are supporting IE6/7 (or IE8 operating in “IE7 compatibility” mode).

In addition, the jQuery.fn.hashchange.src property must be set to the path of the included “document-domain.html” file, which can be renamed or modified if necessary (note that the document.domain specified must be the same in both your main JavaScript as well as in this file).

Usage

jQuery.fn.hashchange.domain = document.domain;

-

jQuery.fn.hashchange.src

If, for some reason, you need to specify an Iframe src file (for example, when setting document.domain as in jQuery.fn.hashchange.domain), you can do so using this property.  Note that when using this property, history won’t be recorded in IE6/7 until the Iframe src file loads.  This property is only applicable if you are supporting IE6/7 (or IE8 operating in “IE7 compatibility” mode).

Usage

jQuery.fn.hashchange.src = ‘path/to/file.html’;

+

jQuery.fn.hashchange.src

If, for some reason, you need to specify an Iframe src file (for example, when setting document.domain as in jQuery.fn.hashchange.domain), you can do so using this property.  Note that when using this property, history won’t be recorded in IE6/7 until the Iframe src file loads.  This property is only applicable if you are supporting IE6/7 (or IE8 operating in “IE7 compatibility” mode).

Usage

jQuery.fn.hashchange.src = ‘path/to/file.html’;

Events

-

hashchange event

Fired when location.hash changes.  In browsers that support it, the native HTML5 window.onhashchange event is used, otherwise a polling loop is initialized, running every jQuery.fn.hashchange.delay milliseconds to see if the hash has changed.  In IE6/7 (and IE8 operating in “IE7 compatibility” mode), a hidden Iframe is created to allow the back button and hash-based history to work.

Usage as described in jQuery.fn.hashchange

// Bind an event handler.
+

hashchange event

Fired when location.hash changes.  In browsers that support it, the native HTML5 window.onhashchange event is used, otherwise a polling loop is initialized, running every jQuery.fn.hashchange.delay milliseconds to see if the hash has changed.  In IE6/7 (and IE8 operating in “IE7 compatibility” mode), a hidden Iframe is created to allow the back button and hash-based history to work.

Usage as described in jQuery.fn.hashchange

// Bind an event handler.
 jQuery(window).hashchange( function(e) {
   var hash = location.hash;
   ...
@@ -140,7 +142,7 @@
 
 
 
-
Retrieve the fragment (hash) from a URL or if no arguments are passed, the current window.location.
Adds a ‘state’ into the browser history at the current position, setting location.hash and triggering any bound hashchange event callbacks (provided the new state is different than the previous state).
Fired when location.hash changes.
If you’re setting document.domain in your JavaScript, and you want hash history to work in IE6/7, not only must this property be set, but you must also set document.domain BEFORE jQuery is loaded into the page.
Version: 1.3, Last updated: 7/21/2010
Bind a handler to the window.onhashchange event or trigger all bound window.onhashchange event handlers.
Returns a params string equivalent to that returned by the internal jQuery.param method, but sorted, which makes it suitable for use as a cache key.
Specify characters that will be left unescaped when fragments are created or merged using jQuery.param.fragment, or when the fragment is modified using jQuery.bbq.pushState.
In jQuery 1.4 and newer, the event object passed into any hashchange event callback is augmented with a copy of the location.hash fragment at the time the event was triggered as its event.fragment property.
Remove one or more keys from the current browser history ‘state’, creating a new state, setting location.hash and triggering any bound hashchange event callbacks (provided the new state is different than the previous state).
Deserialize a params string into an object, optionally coercing numbers, booleans, null and undefined values; this method is the counterpart to the internal jQuery.param method.
Retrieve the query string from a URL or if no arguments are passed, the current window.location.
Update URL attribute in one or more elements, merging the current URL (with or without pre-existing query string params) plus any params object or string into a new URL, which is then set into that attribute.
Update URL attribute in one or more elements, merging the current URL (with or without pre-existing fragment/hash params) plus any params object or string into a new URL, which is then set into that attribute.
Merge a URL, with or without pre-existing query string params, plus any object, params string or URL containing query string params into a new URL.
Get the internal “Default URL attribute per tag” list, or augment the list with additional tag-attribute pairs, in case the defaults are insufficient.
Merge a URL, with or without pre-existing fragment (hash) params, plus any object, params string or URL containing fragment (hash) params into a new URL.
Retrieves the current ‘state’ from the browser history, parsing location.hash for a specific key or returning an object containing the entire state, optionally coercing numbers, booleans, null and undefined values.
The numeric interval (in milliseconds) at which the hashchange event polling loop executes.
If, for some reason, you need to specify an Iframe src file (for example, when setting document.domain as in jQuery.fn.hashchange.domain), you can do so using this property.
+
Retrieve the fragment (hash) from a URL or if no arguments are passed, the current window.location.
Adds a ‘state’ into the browser history at the current position, setting location.hash and triggering any bound hashchange event callbacks (provided the new state is different than the previous state).
Fired when location.hash changes.
If you’re setting document.domain in your JavaScript, and you want hash history to work in IE6/7, not only must this property be set, but you must also set document.domain BEFORE jQuery is loaded into the page.
Version: 1.3, Last updated: 7/21/2010
Bind a handler to the window.onhashchange event or trigger all bound window.onhashchange event handlers.
Returns a params string equivalent to that returned by the internal jQuery.param method, but sorted, which makes it suitable for use as a cache key.
TODO: DESCRIBE
Specify characters that will be left unescaped when fragments are created or merged using jQuery.param.fragment, or when the fragment is modified using jQuery.bbq.pushState.
In jQuery 1.4 and newer, the event object passed into any hashchange event callback is augmented with a copy of the location.hash fragment at the time the event was triggered as its event.fragment property.
Remove one or more keys from the current browser history ‘state’, creating a new state, setting location.hash and triggering any bound hashchange event callbacks (provided the new state is different than the previous state).
Deserialize a params string into an object, optionally coercing numbers, booleans, null and undefined values; this method is the counterpart to the internal jQuery.param method.
Retrieve the query string from a URL or if no arguments are passed, the current window.location.
Update URL attribute in one or more elements, merging the current URL (with or without pre-existing query string params) plus any params object or string into a new URL, which is then set into that attribute.
Update URL attribute in one or more elements, merging the current URL (with or without pre-existing fragment/hash params) plus any params object or string into a new URL, which is then set into that attribute.
Merge a URL, with or without pre-existing query string params, plus any object, params string or URL containing query string params into a new URL.
Get the internal “Default URL attribute per tag” list, or augment the list with additional tag-attribute pairs, in case the defaults are insufficient.
Merge a URL, with or without pre-existing fragment (hash) params, plus any object, params string or URL containing fragment (hash) params into a new URL.
Retrieves the current ‘state’ from the browser history, parsing location.hash for a specific key or returning an object containing the entire state, optionally coercing numbers, booleans, null and undefined values.
The numeric interval (in milliseconds) at which the hashchange event polling loop executes.
If, for some reason, you need to specify an Iframe src file (for example, when setting document.domain as in jQuery.fn.hashchange.domain), you can do so using this property.
diff --git a/docs/index/Files.html b/docs/index/Files.html index ba2753b..56be94e 100644 --- a/docs/index/Files.html +++ b/docs/index/Files.html @@ -13,7 +13,7 @@
File Index
$#! · 0-9 · 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
J
 jQuery BBQ:Back Button&Query Library
 jQuery hashchange event
-
Version: 1.3pre, Last updated: 8/20/2010
Version: 1.3, Last updated: 7/21/2010
+
Version: 1.3pre, Last updated: 8/26/2010
Version: 1.3, Last updated: 7/21/2010
diff --git a/docs/index/Functions.html b/docs/index/Functions.html index a1b6efa..91b024d 100644 --- a/docs/index/Functions.html +++ b/docs/index/Functions.html @@ -11,45 +11,49 @@ -
Function Index
$#! · 0-9 · 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
D
 deparam, jQuery
E
 elemUrlAttr, jQuery
F
 fragment
 fragment(build url), jQuery.param
G
 getState, jQuery.bbq
H
 hashchange, jQuery.fn
N
 noEscape, jQuery.param.fragment
P
 pushState, jQuery.bbq
Q
 querystring
 querystring(build url), jQuery.param
R
 removeState, jQuery.bbq
S
 sorted, jQuery.param
+
Function Index
$#! · 0-9 · 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
A
 ajaxCrawlable, jQuery.param.fragment
D
 deparam, jQuery
E
 elemUrlAttr, jQuery
F
 fragment
 fragment(build url), jQuery.param
G
 getState, jQuery.bbq
H
 hashchange, jQuery.fn
N
 noEscape, jQuery.param.fragment
P
 pushState, jQuery.bbq
Q
 querystring
 querystring(build url), jQuery.param
R
 removeState, jQuery.bbq
S
 sorted, jQuery.param
-
Deserialize a params string into an object, optionally coercing numbers, booleans, null and undefined values; this method is the counterpart to the internal jQuery.param method.
+
TODO: DESCRIBE
-
Get the internal “Default URL attribute per tag” list, or augment the list with additional tag-attribute pairs, in case the defaults are insufficient.
+
Deserialize a params string into an object, optionally coercing numbers, booleans, null and undefined values; this method is the counterpart to the internal jQuery.param method.
-
Parse the fragment (hash) from a URL or the current window.location, deserializing it into an object, optionally coercing numbers, booleans, null and undefined values.
Update URL attribute in one or more elements, merging the current URL (with or without pre-existing fragment/hash params) plus any params object or string into a new URL, which is then set into that attribute.
Retrieve the fragment (hash) from a URL or if no arguments are passed, the current window.location.
Merge a URL, with or without pre-existing fragment (hash) params, plus any object, params string or URL containing fragment (hash) params into a new URL.
+
Get the internal “Default URL attribute per tag” list, or augment the list with additional tag-attribute pairs, in case the defaults are insufficient.
-
Retrieves the current ‘state’ from the browser history, parsing location.hash for a specific key or returning an object containing the entire state, optionally coercing numbers, booleans, null and undefined values.
+
Parse the fragment (hash) from a URL or the current window.location, deserializing it into an object, optionally coercing numbers, booleans, null and undefined values.
Update URL attribute in one or more elements, merging the current URL (with or without pre-existing fragment/hash params) plus any params object or string into a new URL, which is then set into that attribute.
Retrieve the fragment (hash) from a URL or if no arguments are passed, the current window.location.
Merge a URL, with or without pre-existing fragment (hash) params, plus any object, params string or URL containing fragment (hash) params into a new URL.
-
Bind a handler to the window.onhashchange event or trigger all bound window.onhashchange event handlers.
+
Retrieves the current ‘state’ from the browser history, parsing location.hash for a specific key or returning an object containing the entire state, optionally coercing numbers, booleans, null and undefined values.
-
Specify characters that will be left unescaped when fragments are created or merged using jQuery.param.fragment, or when the fragment is modified using jQuery.bbq.pushState.
+
Bind a handler to the window.onhashchange event or trigger all bound window.onhashchange event handlers.
-
Adds a ‘state’ into the browser history at the current position, setting location.hash and triggering any bound hashchange event callbacks (provided the new state is different than the previous state).
+
Specify characters that will be left unescaped when fragments are created or merged using jQuery.param.fragment, or when the fragment is modified using jQuery.bbq.pushState.
-
Parse the query string from a URL or the current window.location, deserializing it into an object, optionally coercing numbers, booleans, null and undefined values.
Update URL attribute in one or more elements, merging the current URL (with or without pre-existing query string params) plus any params object or string into a new URL, which is then set into that attribute.
Retrieve the query string from a URL or if no arguments are passed, the current window.location.
Merge a URL, with or without pre-existing query string params, plus any object, params string or URL containing query string params into a new URL.
+
Adds a ‘state’ into the browser history at the current position, setting location.hash and triggering any bound hashchange event callbacks (provided the new state is different than the previous state).
-
Remove one or more keys from the current browser history ‘state’, creating a new state, setting location.hash and triggering any bound hashchange event callbacks (provided the new state is different than the previous state).
+
Parse the query string from a URL or the current window.location, deserializing it into an object, optionally coercing numbers, booleans, null and undefined values.
Update URL attribute in one or more elements, merging the current URL (with or without pre-existing query string params) plus any params object or string into a new URL, which is then set into that attribute.
Retrieve the query string from a URL or if no arguments are passed, the current window.location.
Merge a URL, with or without pre-existing query string params, plus any object, params string or URL containing query string params into a new URL.
-
Returns a params string equivalent to that returned by the internal jQuery.param method, but sorted, which makes it suitable for use as a cache key.
+
Remove one or more keys from the current browser history ‘state’, creating a new state, setting location.hash and triggering any bound hashchange event callbacks (provided the new state is different than the previous state).
+ + + +
Returns a params string equivalent to that returned by the internal jQuery.param method, but sorted, which makes it suitable for use as a cache key.
diff --git a/docs/index/General.html b/docs/index/General.html index a318859..a8c6df3 100644 --- a/docs/index/General.html +++ b/docs/index/General.html @@ -11,57 +11,61 @@ -
Index
$#! · 0-9 · 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
D
 delay, jQuery.fn.hashchange
 deparam, jQuery
 Deparam(from string)
 domain, jQuery.fn.hashchange
E
 Element manipulation
 elemUrlAttr, jQuery
 Events
 Examples
F
 Files
 fragment
 fragment(build url), jQuery.param
 Functions
G
 getState, jQuery.bbq
H
 hashchange, jQuery.fn
 hashchange event
 hashchange event(BBQ)
 History,hashchange event
J
 jQuery BBQ:Back Button&Query Library
 jQuery hashchange event
K
 Known issues
L
 License
N
 noEscape, jQuery.param.fragment
P
 Param(to string)
 Properties
 pushState, jQuery.bbq
Q
 querystring
 querystring(build url), jQuery.param
R
 Release History
 removeState, jQuery.bbq
S
 sorted, jQuery.param
 src, jQuery.fn.hashchange
 Support and Testing
+
Index
$#! · 0-9 · 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
A
 ajaxCrawlable, jQuery.param.fragment
D
 delay, jQuery.fn.hashchange
 deparam, jQuery
 Deparam(from string)
 domain, jQuery.fn.hashchange
E
 Element manipulation
 elemUrlAttr, jQuery
 Events
 Examples
F
 Files
 fragment
 fragment(build url), jQuery.param
 Functions
G
 getState, jQuery.bbq
H
 hashchange, jQuery.fn
 hashchange event
 hashchange event(BBQ)
 History,hashchange event
J
 jQuery BBQ:Back Button&Query Library
 jQuery hashchange event
K
 Known issues
L
 License
N
 noEscape, jQuery.param.fragment
P
 Param(to string)
 Properties
 pushState, jQuery.bbq
Q
 querystring
 querystring(build url), jQuery.param
R
 Release History
 removeState, jQuery.bbq
S
 sorted, jQuery.param
 src, jQuery.fn.hashchange
 Support and Testing
-
The numeric interval (in milliseconds) at which the hashchange event polling loop executes.
Deserialize a params string into an object, optionally coercing numbers, booleans, null and undefined values; this method is the counterpart to the internal jQuery.param method.
If you’re setting document.domain in your JavaScript, and you want hash history to work in IE6/7, not only must this property be set, but you must also set document.domain BEFORE jQuery is loaded into the page.
+
TODO: DESCRIBE
-
Get the internal “Default URL attribute per tag” list, or augment the list with additional tag-attribute pairs, in case the defaults are insufficient.
These working examples, complete with fully commented code, illustrate a few ways in which this plugin can be used.
+
The numeric interval (in milliseconds) at which the hashchange event polling loop executes.
Deserialize a params string into an object, optionally coercing numbers, booleans, null and undefined values; this method is the counterpart to the internal jQuery.param method.
If you’re setting document.domain in your JavaScript, and you want hash history to work in IE6/7, not only must this property be set, but you must also set document.domain BEFORE jQuery is loaded into the page.
-
Parse the fragment (hash) from a URL or the current window.location, deserializing it into an object, optionally coercing numbers, booleans, null and undefined values.
Update URL attribute in one or more elements, merging the current URL (with or without pre-existing fragment/hash params) plus any params object or string into a new URL, which is then set into that attribute.
Retrieve the fragment (hash) from a URL or if no arguments are passed, the current window.location.
Merge a URL, with or without pre-existing fragment (hash) params, plus any object, params string or URL containing fragment (hash) params into a new URL.
+
Get the internal “Default URL attribute per tag” list, or augment the list with additional tag-attribute pairs, in case the defaults are insufficient.
These working examples, complete with fully commented code, illustrate a few ways in which this plugin can be used.
-
Retrieves the current ‘state’ from the browser history, parsing location.hash for a specific key or returning an object containing the entire state, optionally coercing numbers, booleans, null and undefined values.
+
Parse the fragment (hash) from a URL or the current window.location, deserializing it into an object, optionally coercing numbers, booleans, null and undefined values.
Update URL attribute in one or more elements, merging the current URL (with or without pre-existing fragment/hash params) plus any params object or string into a new URL, which is then set into that attribute.
Retrieve the fragment (hash) from a URL or if no arguments are passed, the current window.location.
Merge a URL, with or without pre-existing fragment (hash) params, plus any object, params string or URL containing fragment (hash) params into a new URL.
-
Bind a handler to the window.onhashchange event or trigger all bound window.onhashchange event handlers.
Fired when location.hash changes.
In jQuery 1.4 and newer, the event object passed into any hashchange event callback is augmented with a copy of the location.hash fragment at the time the event was triggered as its event.fragment property.
+
Retrieves the current ‘state’ from the browser history, parsing location.hash for a specific key or returning an object containing the entire state, optionally coercing numbers, booleans, null and undefined values.
-
Version: 1.3pre, Last updated: 8/20/2010
Version: 1.3, Last updated: 7/21/2010
+
Bind a handler to the window.onhashchange event or trigger all bound window.onhashchange event handlers.
Fired when location.hash changes.
In jQuery 1.4 and newer, the event object passed into any hashchange event callback is augmented with a copy of the location.hash fragment at the time the event was triggered as its event.fragment property.
-
While this jQuery hashchange event implementation is quite stable and robust, there are a few unfortunate browser bugs surrounding expected hashchange event-based behaviors, independent of any JavaScript window.onhashchange abstraction.
+
Version: 1.3pre, Last updated: 8/26/2010
Version: 1.3, Last updated: 7/21/2010
-
Copyright © 2010 “Cowboy” Ben Alman, Dual licensed under the MIT and GPL licenses.
+
While this jQuery hashchange event implementation is quite stable and robust, there are a few unfortunate browser bugs surrounding expected hashchange event-based behaviors, independent of any JavaScript window.onhashchange abstraction.
-
Specify characters that will be left unescaped when fragments are created or merged using jQuery.param.fragment, or when the fragment is modified using jQuery.bbq.pushState.
+
Copyright © 2010 “Cowboy” Ben Alman, Dual licensed under the MIT and GPL licenses.
-
Adds a ‘state’ into the browser history at the current position, setting location.hash and triggering any bound hashchange event callbacks (provided the new state is different than the previous state).
+
Specify characters that will be left unescaped when fragments are created or merged using jQuery.param.fragment, or when the fragment is modified using jQuery.bbq.pushState.
-
Parse the query string from a URL or the current window.location, deserializing it into an object, optionally coercing numbers, booleans, null and undefined values.
Update URL attribute in one or more elements, merging the current URL (with or without pre-existing query string params) plus any params object or string into a new URL, which is then set into that attribute.
Retrieve the query string from a URL or if no arguments are passed, the current window.location.
Merge a URL, with or without pre-existing query string params, plus any object, params string or URL containing query string params into a new URL.
+
Adds a ‘state’ into the browser history at the current position, setting location.hash and triggering any bound hashchange event callbacks (provided the new state is different than the previous state).
-
Remove one or more keys from the current browser history ‘state’, creating a new state, setting location.hash and triggering any bound hashchange event callbacks (provided the new state is different than the previous state).
+
Parse the query string from a URL or the current window.location, deserializing it into an object, optionally coercing numbers, booleans, null and undefined values.
Update URL attribute in one or more elements, merging the current URL (with or without pre-existing query string params) plus any params object or string into a new URL, which is then set into that attribute.
Retrieve the query string from a URL or if no arguments are passed, the current window.location.
Merge a URL, with or without pre-existing query string params, plus any object, params string or URL containing query string params into a new URL.
-
Returns a params string equivalent to that returned by the internal jQuery.param method, but sorted, which makes it suitable for use as a cache key.
If, for some reason, you need to specify an Iframe src file (for example, when setting document.domain as in jQuery.fn.hashchange.domain), you can do so using this property.
Information about what version or versions of jQuery this plugin has been tested with, what browsers it has been tested in, and where the unit tests reside (so you can test it yourself).
+
Remove one or more keys from the current browser history ‘state’, creating a new state, setting location.hash and triggering any bound hashchange event callbacks (provided the new state is different than the previous state).
+ + + +
Returns a params string equivalent to that returned by the internal jQuery.param method, but sorted, which makes it suitable for use as a cache key.
If, for some reason, you need to specify an Iframe src file (for example, when setting document.domain as in jQuery.fn.hashchange.domain), you can do so using this property.
Information about what version or versions of jQuery this plugin has been tested with, what browsers it has been tested in, and where the unit tests reside (so you can test it yourself).
diff --git a/docs/javascript/searchdata.js b/docs/javascript/searchdata.js index 51b0a94..0e5262a 100644 --- a/docs/javascript/searchdata.js +++ b/docs/javascript/searchdata.js @@ -32,7 +32,7 @@ var indexSectionsWithContent = { "Functions": { "Symbols": false, "Numbers": false, - "A": false, + "A": true, "B": false, "C": false, "D": true, diff --git a/docs/nd/Data/FileInfo.nd b/docs/nd/Data/FileInfo.nd index 58ee69e..199996e 100644 --- a/docs/nd/Data/FileInfo.nd +++ b/docs/nd/Data/FileInfo.nd @@ -1,4 +1,4 @@ 1.4 JavaScript -/srv/projects/jquery-bbq-dev/jquery.ba-bbq.js 1282314036 1 jQuery BBQ: Back Button & Query Library -/srv/projects/jquery-bbq-dev/jquery.ba-bbq.min.js 1282316475 0 /srv/projects/jquery-bbq-dev/jquery.ba-bbq.min.js +/srv/projects/jquery-bbq-dev/jquery.ba-bbq.js 1282876144 1 jQuery BBQ: Back Button & Query Library +/srv/projects/jquery-bbq-dev/jquery.ba-bbq.min.js 1282876213 0 /srv/projects/jquery-bbq-dev/jquery.ba-bbq.min.js diff --git a/docs/nd/Data/IndexInfo.nd b/docs/nd/Data/IndexInfo.nd index 1319ee14c55f857b29d526084d3951c79163e95a..79e191d6ab0c535511afb4e436ed4117baa62e0b 100644 GIT binary patch delta 11 ScmdnPxQB6qIV0mlixvPDw*!#? delta 11 ScmdnPxQB6qIU~bFixvPDvjdO- diff --git a/docs/nd/Data/SymbolTable.nd b/docs/nd/Data/SymbolTable.nd index 9562eeccfe054beef688e976bfeeb006c16dbc4f..11ac1d062fb97851c098663a574cefbb3a7cefd8 100644 GIT binary patch delta 206 zcmezGdB=MLKQA+@TjoSQ)5&sDT$Af~zfb1p&ELG8uaJ9kfOI>TnZA*Mp@EHllHFzv zDGkQS52e3O&XO188Yk8tfe8>Et?@PeE$) zGnrz>$qDjYlSSmiChwQ?1_@3smh%Cc5kI+BAr#2ZpL|l@b@C;JfXOY2AwWLYWF5r_ iupS8ofyv79ew!VX!kM5F=oTx=2TVT2FFJXziW2~IzCkPi delta 150 zcmccP{oiu~KksBFWueLW;)avE`E(`+@_wJp&+D{#J6|F9=ABX+jFUB_+PMt$jSLJ8 zZ1j`tCO?$^I(dhR#O4&)Y{tp!RHP + + + + + + + + + + + +
Loading...
ajaxCrawlable, jQuery.param.fragment
Searching...
No Matches
\ No newline at end of file diff --git a/docs/search/GeneralA.html b/docs/search/GeneralA.html new file mode 100644 index 0000000..51cfcd5 --- /dev/null +++ b/docs/search/GeneralA.html @@ -0,0 +1,20 @@ + + + + + + + + + + + + +
Loading...
ajaxCrawlable, jQuery.param.fragment
Searching...
No Matches
\ No newline at end of file diff --git a/jquery.ba-bbq.js b/jquery.ba-bbq.js index 72fd967..5ac2982 100644 --- a/jquery.ba-bbq.js +++ b/jquery.ba-bbq.js @@ -1,5 +1,5 @@ /*! - * jQuery BBQ: Back Button & Query Library - v1.3pre - 8/20/2010 + * jQuery BBQ: Back Button & Query Library - v1.3pre - 8/26/2010 * http://benalman.com/projects/jquery-bbq-plugin/ * * Copyright (c) 2010 "Cowboy" Ben Alman @@ -9,7 +9,7 @@ // Script: jQuery BBQ: Back Button & Query Library // -// *Version: 1.3pre, Last updated: 8/20/2010* +// *Version: 1.3pre, Last updated: 8/26/2010* // // Project Home - http://benalman.com/projects/jquery-bbq-plugin/ // GitHub - http://github.com/cowboy/jquery-bbq/ @@ -45,12 +45,14 @@ // // About: Release History // -// 1.3pre - (8/20/2010) Integrated v1.3, which adds +// 1.3pre - (8/26/2010) Integrated v1.3, which adds // document.title and document.domain support in IE6/7, BlackBerry // support, better Iframe hiding for accessibility reasons, and the new // "shortcut" method. Added the // method which reduces the possibility of -// extraneous hashchange event triggering. +// extraneous hashchange event triggering. Added the +// method which can be used to +// enable Google "AJAX Crawlable mode." // 1.2.1 - (2/17/2010) Actually fixed the stale window.location Safari bug from // in BBQ, which was the main reason for the // previous release! @@ -108,15 +110,18 @@ str_querystring = 'querystring', str_fragment = 'fragment', str_elemUrlAttr = 'elemUrlAttr', - str_location = 'location', str_href = 'href', str_src = 'src', // Reused RegExp. - re_trim_querystring = /^.*\?|#.*$/g, - re_trim_fragment = /^.*\#/, + re_params_querystring = /^.*\?|#.*$/g, + re_params_fragment, + re_fragment, re_no_escape, + ajax_crawlable, + fragment_prefix, + // Used by jQuery.elemUrlAttr. elemUrlAttr_cache = {}; @@ -139,7 +144,7 @@ // Get location.hash (or what you'd expect location.hash to be) sans any // leading #. Thanks for making this necessary, Firefox! function get_fragment( url ) { - return url.replace( /^[^#]*#?(.*)$/, '$1' ); + return url.replace( re_fragment, '$2' ); }; // Get location.search (or what you'd expect location.search to be) sans any @@ -259,7 +264,7 @@ // matches[1] = url part that precedes params, not including trailing ?/# // matches[2] = params, not including leading ?/# // matches[3] = if in 'querystring' mode, hash including leading #, otherwise '' - matches = url.match( is_fragment ? /^([^#]*)\#?(.*)$/ : /^([^#?]*)\??([^#]*)(#?.*)/ ); + matches = url.match( is_fragment ? re_fragment : /^([^#?]*)\??([^#]*)(#?.*)/ ); // Get the hash if in 'querystring' mode, and it exists. hash = matches[3] || ''; @@ -267,7 +272,7 @@ if ( merge_mode === 2 && is_string( params ) ) { // If merge_mode is 2 and params is a string, merge the fragment / query // string into the URL wholesale, without converting it into an object. - qs = params.replace( is_fragment ? re_trim_fragment : re_trim_querystring, '' ); + qs = params.replace( is_fragment ? re_params_fragment : re_params_querystring, '' ); } else { // Convert relevant params in url to object. @@ -299,12 +304,12 @@ // Build URL from the base url, querystring and hash. In 'querystring' // mode, ? is only added if a query string exists. In 'fragment' mode, # // is always added. - result = matches[1] + ( is_fragment ? '#' : qs || !matches[1] ? '?' : '' ) + qs + hash; + result = matches[1] + ( is_fragment ? fragment_prefix : qs || !matches[1] ? '?' : '' ) + qs + hash; } else { // If URL was passed in, parse params from URL string, otherwise parse // params from window.location. - result = get_func( url !== undefined ? url : window[ str_location ][ str_href ] ); + result = get_func( url !== undefined ? url : location.href ); } return result; @@ -401,6 +406,41 @@ // "uglifying up the URL" the most. jq_param_fragment.noEscape( ',/' ); + // Method: jQuery.param.fragment.ajaxCrawlable + // + // TODO: DESCRIBE + // + // Usage: + // + // > jQuery.param.fragment.ajaxCrawlable( [ state ] ); + // + // Arguments: + // + // state - (Boolean) TODO: DESCRIBE + // + // Returns: + // + // (Boolean) The current ajaxCrawlable state. + + jq_param_fragment.ajaxCrawlable = function( state ) { + if ( state !== undefined ) { + if ( state ) { + re_params_fragment = /^.*(?:#!|#)/; + re_fragment = /^([^#]*)(?:#!|#)?(.*)$/; + fragment_prefix = '#!'; + } else { + re_params_fragment = /^.*#/; + re_fragment = /^([^#]*)#?(.*)$/; + fragment_prefix = '#'; + } + ajax_crawlable = !!state; + } + + return ajax_crawlable; + }; + + jq_param_fragment.ajaxCrawlable( 0 ); + // Section: Deparam (from string) // // Method: jQuery.deparam @@ -566,7 +606,7 @@ url_or_params = jq_param[ is_fragment ? str_fragment : str_querystring ](); } else { url_or_params = is_string( url_or_params ) - ? url_or_params.replace( is_fragment ? re_trim_fragment : re_trim_querystring, '' ) + ? url_or_params.replace( is_fragment ? re_params_fragment : re_params_querystring, '' ) : url_or_params; } @@ -770,13 +810,12 @@ var has_args = params !== undefined, // Merge params into window.location using $.param.fragment. - url = jq_param_fragment( window[ str_location ][ str_href ], + url = jq_param_fragment( location.href, has_args ? params : {}, has_args ? merge_mode : 2 ); - // Set new window.location.href. If hash is empty, use just # to prevent - // browser from reloading the page. Note that Safari 3 & Chrome barf on - // location.hash = '#'. - window[ str_location ][ str_href ] = url + ( /#/.test( url ) ? '' : '#' ); + // Set new window.location.href. Note that Safari 3 & Chrome barf on + // location.hash = '#' so the entire URL is set. + location.href = url; }; // Method: jQuery.bbq.getState diff --git a/jquery.ba-bbq.min.js b/jquery.ba-bbq.min.js index f6015fc..80de36f 100644 --- a/jquery.ba-bbq.min.js +++ b/jquery.ba-bbq.min.js @@ -1,12 +1,12 @@ /* - * jQuery BBQ: Back Button & Query Library - v1.3pre - 8/20/2010 + * jQuery BBQ: Back Button & Query Library - v1.3pre - 8/26/2010 * http://benalman.com/projects/jquery-bbq-plugin/ * * Copyright (c) 2010 "Cowboy" Ben Alman * Dual licensed under the MIT and GPL licenses. * http://benalman.com/about/license/ */ -(function($,q){var i,n=Array.prototype.slice,s=decodeURIComponent,a=$.param,j,c,m,w,b=$.bbq=$.bbq||{},r,v,k,e=$.event.special,d="hashchange",B="querystring",E="fragment",z="elemUrlAttr",g="location",l="href",u="src",y=/^.*\?|#.*$/g,x=/^.*\#/,h,D={};function F(G){return typeof G==="string"}function C(H){var G=n.call(arguments,1);return function(){return H.apply(this,G.concat(n.call(arguments)))}}function o(G){return G.replace(/^[^#]*#?(.*)$/,"$1")}function p(G){return G.replace(/(?:^[^?#]*\?([^#]*).*$)?.*/,"$1")}function f(I,N,G,J,H){var P,M,L,O,K;if(J!==i){L=G.match(I?/^([^#]*)\#?(.*)$/:/^([^#?]*)\??([^#]*)(#?.*)/);K=L[3]||"";if(H===2&&F(J)){M=J.replace(I?x:y,"")}else{O=m(L[2]);J=F(J)?m[I?E:B](J):J;M=H===2?J:H===1?$.extend({},J,O):$.extend({},O,J);M=j(M);if(I){M=M.replace(h,s)}}P=L[1]+(I?"#":M||!L[1]?"?":"")+M+K}else{P=N(G!==i?G:q[g][l])}return P}a[B]=C(f,0,p);a[E]=c=C(f,1,o);a.sorted=j=function(H,I){var G=[],J={};$.each(a(H,I).split("&"),function(N,K){var M=K.replace(/(?:%5B|=).*$/,""),L=J[M];if(!L){L=J[M]=[];G.push(M)}L.push(K)});return $.map(G.sort(),function(K){return J[K]}).join("&")};c.noEscape=function(H){H=H||"";var G=$.map(H.split(""),encodeURIComponent);h=new RegExp(G.join("|"),"g")};c.noEscape(",/");$.deparam=m=function(J,G){var I={},H={"true":!0,"false":!1,"null":null};$.each(J.replace(/\+/g," ").split("&"),function(M,R){var L=R.split("="),Q=s(L[0]),K,P=I,N=0,S=Q.split("]["),O=S.length-1;if(/\[/.test(S[0])&&/\]$/.test(S[O])){S[O]=S[O].replace(/\]$/,"");S=S.shift().split("[").concat(S);O=S.length-1}else{O=0}if(L.length===2){K=s(L[1]);if(G){K=K&&!isNaN(K)?+K:K==="undefined"?i:H[K]!==i?H[K]:K}if(O){for(;N<=O;N++){Q=S[N]===""?P.length:S[N];P=P[Q]=N