Skip to content

Commit

Permalink
adding ajaxCrawlable (code name: fragbango) functionality. code and u…
Browse files Browse the repository at this point in the history
…nit tests are done, just needs documentation and examples.
  • Loading branch information
cowboy committed Aug 27, 2010
1 parent aa12c92 commit 8a8530f
Show file tree
Hide file tree
Showing 14 changed files with 406 additions and 117 deletions.
4 changes: 2 additions & 2 deletions 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.

Expand Down Expand Up @@ -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.
Expand Down
42 changes: 22 additions & 20 deletions docs/files/jquery-ba-bbq-js.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/index/Files.html
Expand Up @@ -13,7 +13,7 @@

<div id=Index><div class=IPageTitle>File Index</div><div class=INavigationBar>$#! &middot; 0-9 &middot; A &middot; B &middot; C &middot; D &middot; E &middot; F &middot; G &middot; H &middot; I &middot; <a href="#J">J</a> &middot; K &middot; L &middot; M &middot; N &middot; O &middot; P &middot; Q &middot; R &middot; S &middot; T &middot; U &middot; V &middot; W &middot; X &middot; Y &middot; Z</div><table border=0 cellspacing=0 cellpadding=0><tr><td class=IHeading id=IFirstHeading><a name="J"></a>J</td><td></td></tr><tr><td class=ISymbolPrefix id=IFirstSymbolPrefix>&nbsp;</td><td class=IEntry><a href="../files/jquery-ba-bbq-js.html#jQuery_BBQ:Back_ButtonQuery_Library" id=link1 onMouseOver="ShowTip(event, 'tt1', 'link1')" onMouseOut="HideTip('tt1')" class=ISymbol>jQuery BBQ:<wbr>Back Button&amp;Query Library</a></td></tr><tr><td class=ISymbolPrefix id=ILastSymbolPrefix>&nbsp;</td><td class=IEntry><a href="../files/jquery-ba-bbq-js.html#jQuery_hashchange_event" id=link2 onMouseOver="ShowTip(event, 'tt2', 'link2')" onMouseOut="HideTip('tt2')" class=ISymbol>jQuery hashchange event</a></td></tr></table>
<!--START_ND_TOOLTIPS-->
<div class=CToolTip id="tt1"><div class=CFile><b>Version: 1.3pre, Last updated: 8/20/2010</b></div></div><div class=CToolTip id="tt2"><div class=CFile><b>Version: 1.3, Last updated: 7/21/2010</b></div></div><!--END_ND_TOOLTIPS-->
<div class=CToolTip id="tt1"><div class=CFile><b>Version: 1.3pre, Last updated: 8/26/2010</b></div></div><div class=CToolTip id="tt2"><div class=CFile><b>Version: 1.3, Last updated: 7/21/2010</b></div></div><!--END_ND_TOOLTIPS-->

</div><!--Index-->

Expand Down
26 changes: 15 additions & 11 deletions docs/index/Functions.html

Large diffs are not rendered by default.

32 changes: 18 additions & 14 deletions docs/index/General.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/javascript/searchdata.js
Expand Up @@ -32,7 +32,7 @@ var indexSectionsWithContent = {
"Functions": {
"Symbols": false,
"Numbers": false,
"A": false,
"A": true,
"B": false,
"C": false,
"D": true,
Expand Down
4 changes: 2 additions & 2 deletions 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
Binary file modified docs/nd/Data/IndexInfo.nd
Binary file not shown.
Binary file modified docs/nd/Data/SymbolTable.nd
Binary file not shown.
20 changes: 20 additions & 0 deletions docs/search/FunctionsA.html
@@ -0,0 +1,20 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">

<html><head><link rel="stylesheet" type="text/css" href="../styles/main.css"><script language=JavaScript src="../javascript/main.js"></script></head><body class="PopupSearchResultsPage" onLoad="NDOnLoad()"><script language=JavaScript><!--
if (browserType) {document.write("<div class=" + browserType + ">");if (browserVer) {document.write("<div class=" + browserVer + ">"); }}// --></script>

<!-- Generated by Natural Docs, version 1.4 -->
<!-- http://www.naturaldocs.org -->

<!-- saved from url=(0026)http://www.naturaldocs.org -->




<div id=Index><div class=SRStatus id=Loading>Loading...</div><table border=0 cellspacing=0 cellpadding=0><div class=SRResult id=SR_ajaxCrawlable><div class=IEntry><a href="../files/jquery-ba-bbq-js.html#jQuery.param.fragment.ajaxCrawlable" target=_parent class=ISymbol>ajaxCrawlable</a>, <span class=IParent>jQuery.<wbr>param.<wbr>fragment</span></div></div></table><div class=SRStatus id=Searching>Searching...</div><div class=SRStatus id=NoMatches>No Matches</div><script type="text/javascript"><!--
document.getElementById("Loading").style.display="none";
document.getElementById("NoMatches").style.display="none";
var searchResults = new SearchResults("searchResults", "HTML");
searchResults.Search();
--></script></div><script language=JavaScript><!--
if (browserType) {if (browserVer) {document.write("</div>"); }document.write("</div>");}// --></script></body></html>
20 changes: 20 additions & 0 deletions docs/search/GeneralA.html
@@ -0,0 +1,20 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">

<html><head><link rel="stylesheet" type="text/css" href="../styles/main.css"><script language=JavaScript src="../javascript/main.js"></script></head><body class="PopupSearchResultsPage" onLoad="NDOnLoad()"><script language=JavaScript><!--
if (browserType) {document.write("<div class=" + browserType + ">");if (browserVer) {document.write("<div class=" + browserVer + ">"); }}// --></script>

<!-- Generated by Natural Docs, version 1.4 -->
<!-- http://www.naturaldocs.org -->

<!-- saved from url=(0026)http://www.naturaldocs.org -->




<div id=Index><div class=SRStatus id=Loading>Loading...</div><table border=0 cellspacing=0 cellpadding=0><div class=SRResult id=SR_ajaxCrawlable><div class=IEntry><a href="../files/jquery-ba-bbq-js.html#jQuery.param.fragment.ajaxCrawlable" target=_parent class=ISymbol>ajaxCrawlable</a>, <span class=IParent>jQuery.<wbr>param.<wbr>fragment</span></div></div></table><div class=SRStatus id=Searching>Searching...</div><div class=SRStatus id=NoMatches>No Matches</div><script type="text/javascript"><!--
document.getElementById("Loading").style.display="none";
document.getElementById("NoMatches").style.display="none";
var searchResults = new SearchResults("searchResults", "HTML");
searchResults.Search();
--></script></div><script language=JavaScript><!--
if (browserType) {if (browserVer) {document.write("</div>"); }document.write("</div>");}// --></script></body></html>
75 changes: 57 additions & 18 deletions 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
Expand All @@ -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/
Expand Down Expand Up @@ -45,12 +45,14 @@
//
// About: Release History
//
// 1.3pre - (8/20/2010) Integrated <jQuery hashchange event> v1.3, which adds
// 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.
// 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!
Expand Down Expand Up @@ -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 = {};

Expand All @@ -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
Expand Down Expand Up @@ -259,15 +264,15 @@
// 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] || '';

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.
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions jquery.ba-bbq.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 8a8530f

Please sign in to comment.