|
| 1 | +/*! |
| 2 | + * jQuery hashchange event - v1.3 - 7/21/2010 |
| 3 | + * http://benalman.com/projects/jquery-hashchange-plugin/ |
| 4 | + * |
| 5 | + * Copyright (c) 2010 "Cowboy" Ben Alman |
| 6 | + * Dual licensed under the MIT and GPL licenses. |
| 7 | + * http://benalman.com/about/license/ |
| 8 | + */ |
| 9 | + |
1 | 10 | // Script: jQuery hashchange event |
2 | | -// |
| 11 | +// |
3 | 12 | // *Version: 1.3, Last updated: 7/21/2010* |
4 | 13 | // |
5 | 14 | // Project Home - http://benalman.com/projects/jquery-hashchange-plugin/ |
|
76 | 85 | // extra awesomeness that BBQ provides. This plugin will be included as |
77 | 86 | // part of jQuery BBQ, but also be available separately. |
78 | 87 |
|
79 | | -(function( $, window, undefined ) { |
| 88 | +(function($,window,undefined){ |
| 89 | + '$:nomunge'; // Used by YUI compressor. |
| 90 | + |
80 | 91 | // Reused string. |
81 | 92 | var str_hashchange = 'hashchange', |
82 | 93 |
|
|
242 | 253 | // event for browsers that don't natively support it, including creating a |
243 | 254 | // polling loop to watch for hash changes and in IE 6/7 creating a hidden |
244 | 255 | // Iframe to enable back and forward. |
245 | | - fake_onhashchange = (function() { |
| 256 | + fake_onhashchange = (function(){ |
246 | 257 | var self = {}, |
247 | 258 | timeout_id, |
248 | 259 |
|
249 | 260 | // Remember the initial hash so it doesn't get triggered immediately. |
250 | 261 | last_hash = get_fragment(), |
251 | 262 |
|
252 | | - fn_retval = function( val ) { return val; }, |
| 263 | + fn_retval = function(val){ return val; }, |
253 | 264 | history_set = fn_retval, |
254 | 265 | history_get = fn_retval; |
255 | 266 |
|
|
286 | 297 | // vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv |
287 | 298 | // vvvvvvvvvvvvvvvvvvv REMOVE IF NOT SUPPORTING IE6/7/8 vvvvvvvvvvvvvvvvvvv |
288 | 299 | // vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv |
289 | | - window.attachEvent && !window.addEventListener && !supports_onhashchange && (function() { |
| 300 | + window.attachEvent && !window.addEventListener && !supports_onhashchange && (function(){ |
290 | 301 | // Not only do IE6/7 need the "magical" Iframe treatment, but so does IE8 |
291 | 302 | // when running in "IE7 compatibility" mode. |
292 | 303 |
|
|
295 | 306 |
|
296 | 307 | // When the event is bound and polling starts in IE 6/7, create a hidden |
297 | 308 | // Iframe for history handling. |
298 | | - self.start = function() { |
| 309 | + self.start = function(){ |
299 | 310 | if ( !iframe ) { |
300 | 311 | iframe_src = $.fn[ str_hashchange ].src; |
301 | 312 | iframe_src = iframe_src && iframe_src + get_fragment(); |
|
306 | 317 |
|
307 | 318 | // When Iframe has completely loaded, initialize the history and |
308 | 319 | // start polling. |
309 | | - .one( 'load', function() { |
| 320 | + .one( 'load', function(){ |
310 | 321 | iframe_src || history_set( get_fragment() ); |
311 | 322 | poll(); |
312 | 323 | }) |
|
322 | 333 | // prettify the back/next history menu entries. Since IE sometimes |
323 | 334 | // errors with "Unspecified error" the very first time this is set |
324 | 335 | // (yes, very useful) wrap this with a try/catch block. |
325 | | - doc.onpropertychange = function() { |
| 336 | + doc.onpropertychange = function(){ |
326 | 337 | try { |
327 | 338 | if ( event.propertyName === 'title' ) { |
328 | 339 | iframe.document.title = doc.title; |
|
359 | 370 | iframe_doc.open(); |
360 | 371 |
|
361 | 372 | // Set document.domain for the Iframe document as well, if necessary. |
362 | | - domain && iframe_doc.write( '<script>document.domain="' + domain + '"<\/script>' ); |
| 373 | + domain && iframe_doc.write( '<script>document.domain="' + domain + '"</script>' ); |
363 | 374 |
|
364 | 375 | iframe_doc.close(); |
365 | 376 |
|
|
0 commit comments